[Python-ogre-commit] SF.net SVN: python-ogre:[779] trunk/python-ogre/demos/caelum
Brought to you by:
andy_miller,
roman_yakovenko
From: <and...@us...> - 2008-10-28 14:09:45
|
Revision: 779 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=779&view=rev Author: andy_miller Date: 2008-10-28 14:09:34 +0000 (Tue, 28 Oct 2008) Log Message: ----------- Update to latest Caelum and demo working again Modified Paths: -------------- trunk/python-ogre/demos/caelum/Demo_Caelum01.py trunk/python-ogre/demos/caelum/plugins.cfg trunk/python-ogre/demos/caelum/resources.cfg Removed Paths: ------------- trunk/python-ogre/demos/caelum/media/AltocumulusDetail.png trunk/python-ogre/demos/caelum/media/AltostratusDetail.png trunk/python-ogre/demos/caelum/media/AtmosphereDepth.png trunk/python-ogre/demos/caelum/media/CaelumDemoTerrain.cfg trunk/python-ogre/demos/caelum/media/CaelumGroundFog.cg trunk/python-ogre/demos/caelum/media/CaelumLayeredClouds.cg trunk/python-ogre/demos/caelum/media/CaelumPhaseMoon.cg trunk/python-ogre/demos/caelum/media/CaelumPointStarfield.cg trunk/python-ogre/demos/caelum/media/CaelumShaders.cg trunk/python-ogre/demos/caelum/media/CaelumSkyDome.cg trunk/python-ogre/demos/caelum/media/CirrostratusDetail.png trunk/python-ogre/demos/caelum/media/CirrusDetail.png trunk/python-ogre/demos/caelum/media/CloudCoverLookup.png trunk/python-ogre/demos/caelum/media/CloudLayer.png trunk/python-ogre/demos/caelum/media/CloudNoise1.png trunk/python-ogre/demos/caelum/media/EarthClearSky.png trunk/python-ogre/demos/caelum/media/EarthClearSky2.png trunk/python-ogre/demos/caelum/media/EarthClearSkyFog.png trunk/python-ogre/demos/caelum/media/GroundFog.material trunk/python-ogre/demos/caelum/media/GroundFog.program trunk/python-ogre/demos/caelum/media/Haze.program trunk/python-ogre/demos/caelum/media/LayeredCloud.cg trunk/python-ogre/demos/caelum/media/LayeredClouds.material trunk/python-ogre/demos/caelum/media/PointStarfield.material trunk/python-ogre/demos/caelum/media/SkyDome.material trunk/python-ogre/demos/caelum/media/SkyLightAbsorption.cg trunk/python-ogre/demos/caelum/media/Starfield.jpg trunk/python-ogre/demos/caelum/media/Starfield.material trunk/python-ogre/demos/caelum/media/Sun.material trunk/python-ogre/demos/caelum/media/SunGradient.png trunk/python-ogre/demos/caelum/media/Terrain.cfg trunk/python-ogre/demos/caelum/media/Terrain.material trunk/python-ogre/demos/caelum/media/moon.material trunk/python-ogre/demos/caelum/media/moon_disc.dds trunk/python-ogre/demos/caelum/media/noise1.png trunk/python-ogre/demos/caelum/media/noise2.png trunk/python-ogre/demos/caelum/media/noise3.png trunk/python-ogre/demos/caelum/media/noise4.png trunk/python-ogre/demos/caelum/media/sphere.mesh trunk/python-ogre/demos/caelum/media/sun_disc.png Modified: trunk/python-ogre/demos/caelum/Demo_Caelum01.py =================================================================== --- trunk/python-ogre/demos/caelum/Demo_Caelum01.py 2008-10-28 08:28:29 UTC (rev 778) +++ trunk/python-ogre/demos/caelum/Demo_Caelum01.py 2008-10-28 14:09:34 UTC (rev 779) @@ -1,6 +1,6 @@ ## /* ## ----------------------------------------------------------------------------- -## This source file is based on Caelum's CaelumTest1 +## This source file is based on Caelum's CaelumDemo ## ----------------------------------------------------------------------------- ## */ import sys @@ -13,89 +13,58 @@ import SampleFramework as sf import ctypes -## ------------------------------------------------------------------ -## our basic Python Ogre TerrainFrame Listener -## ------------------------------------------------------------------ -class TerrainFrameListener(sf.FrameListener): +class CaelumSampleFrameListener(sf.FrameListener): - def __init__(self, renderWindow, camera, sceneManager): - sf.FrameListener.__init__(self, renderWindow, camera) + def __init__(self, win, cam, app ): + sf.FrameListener.__init__(self, win, cam) + self.sceneManager = cam.getSceneManager() + self.window = win + self.camera = cam + self.paused=False + self.app = app + + # Pick components to create in the demo. + # You can comment any of those and it should still work + # Trying to disable one of these can be useful in finding problems. + componentMask = caelum.CaelumSystem.CaelumComponent ( + caelum.CaelumSystem.CAELUM_COMPONENT_SUN | + caelum.CaelumSystem.CAELUM_COMPONENT_MOON | + caelum.CaelumSystem.CAELUM_COMPONENT_SKY_DOME | + ## caelum.CaelumSystem.CAELUM_COMPONENT_IMAGE_STARFIELD | + caelum.CaelumSystem.CAELUM_COMPONENT_POINT_STARFIELD | + caelum.CaelumSystem.CAELUM_COMPONENT_CLOUDS | + 0); + componentMask = caelum.CaelumSystem.CAELUM_COMPONENTS_DEFAULT - self.sceneManager = sceneManager - self.camera = camera - self.moveSpeed = 50.0 - self.updateRay = ogre.Ray() - ## basic terrain ray query - pos = camera.getPosition() - d = ogre.Vector3().NEGATIVE_UNIT_Y - self.raySceneQuery = sceneManager.createRayQuery(ogre.Ray( pos, d )) + ## Initialise CaelumSystem. + self.mCaelumSystem = caelum.CaelumSystem (ogre.Root.getSingletonPtr(), self.sceneManager, componentMask) - ## -------------------------------------------------------------- - def frameStarted(self, frameEvent): + ## Set time acceleration. + self.mCaelumSystem.getUniversalClock ().setTimeScale (512) - ## call parent framelistener - ret = sf.FrameListener.frameStarted(self, frameEvent) + ## Register caelum as a listener. + self.app.renderWindow.addListener (self.mCaelumSystem) + ogre.Root.getSingletonPtr().addFrameListener (self.mCaelumSystem) - ## clamp camera to terrain - self.updateRay.setOrigin (self.camera.getPosition()) - self.updateRay.setDirection (ogre.Vector3().NEGATIVE_UNIT_Y) - self.raySceneQuery.Ray = self.updateRay - for queryResult in self.raySceneQuery.execute(): - if queryResult.worldFragment is not None: -# pos = self.camera.getPosition() -# self.camera.setPosition (pos.x, pos.y - queryResult.distance + 10.0, pos.z) -# break - wf = queryResult.worldFragment - self.camera.setPosition(self.camera.getPosition().x, - wf.singleIntersection.y + 10, - self.camera.getPosition().z) - break - return ret - - - - -class CaelumSpeedFrameListener(TerrainFrameListener): - def __init__(self, renderWindow, camera, sceneManager, caelumSystem): - TerrainFrameListener.__init__(self, renderWindow, camera, sceneManager) - - self.caelumSystem = caelumSystem - self.speedFactor = 0 - self.paused = False + self.UpdateSpeedFactor(self.mCaelumSystem.getUniversalClock ().getTimeScale ()) self.timeTillNextUpdate = 0 - self.PostFiltering = False - - self.UpdateSpeedFactor(self.caelumSystem.getUniversalClock ().getTimeScale ()) - - ## ------------------------------------------------------------------ - ## our own function to set time scale dependent on paused state - ## saves a few if / else - ## ------------------------------------------------------------------ -# def _setTimeScale(self, paused, t1, t2 ): -# t = t1 -# if not paused: -# t = t2 -# self.caelumSystem.getUniversalClock().setTimeScale(t) - + ## Update speed factors. def UpdateSpeedFactor(self, factor): - self.speedFactor = factor + self.speedFactor = factor; if self.paused: - t = 0 - else: - t= self.speedFactor - self.caelumSystem.getUniversalClock ().setTimeScale (t) - ogre.ControllerManager.getSingleton().setTimeFactor (t) + self.mCaelumSystem.getUniversalClock ().setTimeScale (0) + else: + self.mCaelumSystem.getUniversalClock ().setTimeScale (self.speedFactor) + + + def frameEnded(self, evt): + if not sf.FrameListener.frameEnded(self, evt): + return False - ## ------------------------------------------------------------------ - def frameStarted(self, frameEvent): - - # clamp to terrain - ret = TerrainFrameListener.frameStarted(self, frameEvent) - print "from framestarted", ret - return ret + ## Stop key repeat for these keys. ## keyboard input - self.timeTillNextUpdate -= frameEvent.timeSinceLastFrame + self.timeTillNextUpdate -= evt.timeSinceLastFrame if (self.timeTillNextUpdate<= 0): if (self.Keyboard.isKeyDown (ois.KC_SPACE)): self.timeTillNextUpdate = 1 @@ -113,187 +82,48 @@ if (self.Keyboard.isKeyDown(ois.KC_Z)): self.timeTillNextUpdate = 1 self.UpdateSpeedFactor(self.speedFactor * -1) + return True - if (self.Keyboard.isKeyDown(ois.KC_F1)): - self.timeTillNextUpdate = 1 - if self.PostFiltering: - self.PostFiltering = False - else: - self.PostFiltering = True - ogre.CompositorManager.getSingleton().setCompositorEnabled (self.window.getViewport (0), "Bloom", self.PostFiltering) - - ## Do some additional update. These should be removed from here; - ## CaelumSystem should do all required updates. - - ## Update the haze sun light position - if (self.caelumSystem.getSun ()): - mat = ogre.MaterialManager.getSingleton ().getByName ("CaelumDemoTerrain") - if mat.getTechnique (0).getPass ("CaelumHaze"): - mat.getTechnique (0).getPass ("CaelumHaze").getVertexProgramParameters ().setNamedConstant ("sunDirection", - self.caelumSystem.getSun ().getLightDirection ()) - return ret - -class TerrainApplication(sf.Application): - - def __init__(self): - self.caelumSystem = None ## Caelum system - self.caelumModel = None ## Caelum model - self.spm = None - self.raySceneQuery = None +class CaelumSampleApplication(sf.Application): + def _isPsycoEnabled(self): + return True - sf.Application.__init__(self) + def _createFrameListener ( self ): + self.FrameListener = CaelumSampleFrameListener (self.renderWindow, self.camera, self) + self.root.addFrameListener (self.FrameListener) - - def __del__(self): - - print "Remove Window Listener" - self.renderWindow.removeListener(self.caelumSystem) - self.root.removeFrameListener(self.frameListener) - self.frameListener = None - print "deleted Listeners" -# t = self.caelumSystem.getSun().setSunPositionModel(None) -# print "Sun is None", t -# t = self.caelumSystem.getSun().getSunPositionModel() -# print "Sun is None", t - - - - ## ==================================================================== - ## This the one difference between the python and c++ demo. In c++ the - ## Sun dtor deletes the SunPositionalModel. However in createScene we - ## need to hold a reference to SunPositionModel (self.spm) other - ## seg faults when it goes out of scope. Doing so means that a seg fault - ## when C++ tries to delete the sun.EarthSunPositionModel. Temp workaround - ## comment out the following in Sun.cpp and handle deletion ouselves. - ## - ## /* - ## if (mSunPositionModel) { - ## delete mSunPositionModel - ## mSunPositionModel = 0 - ## } - ## */ - ## - ## ==================================================================== - if self.spm: - self.spm = 0 - if self.caelumSystem: - self.caelumSystem.shutdown(False) - self.caelumSystem = None - - del self.camera - del self.sceneManager - del self.frameListener - del self.root - del self.renderWindow - - - def _chooseSceneManager(self): + def _chooseSceneManager( self ): self.sceneManager = self.root.createSceneManager("TerrainSceneManager") - def _createCamera(self): - self.camera = self.sceneManager.createCamera('PlayerCam') - + def _createCamera( self ): + ## Create the camera + self.camera = self.sceneManager.createCamera("PlayerCam") + ## Start the camera on a hill in the middle of the terrain ## looking towards Z+ (north). ## Sun should rise in the east(left) and set in the west(right). - self.camera.setPosition (ogre.Vector3(775, 100, 997)) - self.camera.lookAt (ogre.Vector3(775, 100, 1000)) - - ## Set camera clip distances. Its important to test with - ## an infinite clip distance. - self.camera.setFarClipDistance(0); - self.camera.setNearClipDistance(5); - - self.raySceneQuery = self.sceneManager.createRayQuery(ogre.Ray(self.camera.getPosition(), ogre.Vector3().NEGATIVE_UNIT_Y)) - + self.camera.setPosition (ogre.Vector3 (775, 100, 997)) + self.camera.lookAt (ogre.Vector3 (775, 100, 1000)) - def _createScene(self): - sceneManager = self.sceneManager - camera = self.camera - clouds = True - skyDome = True - - ## a little hack to let me test this on a machine with a crap graphics card - capabilities = ogre.Root.getSingleton().getRenderSystem().capabilities - if not capabilities.hasCapability(ogre.RSC_VERTEX_PROGRAM) or\ - not capabilities.hasCapability(ogre.RSC_FRAGMENT_PROGRAM): - skyDome = False - clouds = False - else: - ogre.CompositorManager.getSingleton().addCompositor(self.renderWindow.getViewport(0),"Bloom") - camera.setNearClipDistance(0.01) - componentMask = caelum.CaelumSystem.CaelumComponent( -# caelum.CaelumSystem.CAELUM_COMPONENT_SKY_DOME | -# caelum.CaelumSystem.CAELUM_COMPONENT_SUN | -# caelum.CaelumSystem.CAELUM_COMPONENT_MOON | -# caelum.CaelumSystem.CAELUM_COMPONENT_IMAGE_STARFIELD | -# caelum.CaelumSystem.CAELUM_COMPONENT_POINT_STARFIELD | -# caelum.CaelumSystem.CAELUM_COMPONENT_CLOUDS | -# caelum.CaelumSystem.CAELUM_COMPONENT_PRECIPITATION | -# caelum.CaelumSystem.CAELUM_COMPONENT_SCREEN_SPACE_FOG | -# caelum.CaelumSystem.CAELUM_COMPONENT_GROUND_FOG | + self.camera.setNearClipDistance(5) -# caelum.CaelumSystem.CAELUM_COMPONENTS_NONE | - caelum.CaelumSystem.CAELUM_COMPONENTS_DEFAULT | -# caelum.CaelumSystem.CAELUM_COMPONENTS_ALL | - - - 0 ) - print componentMask - ## Initialise Caelum - self.caelumSystem = caelum.CaelumSystem(self.root.getSingletonPtr(), self.sceneManager ,componentMask ) - - self.caelumSystem.setManageSceneFog(True) - self.caelumSystem.setSceneFogDensityMultiplier(0.0015) - self.caelumSystem.setManageAmbientLight (True) - self.caelumSystem.setMinimumAmbientLight (ogre.ColourValue (0, 0, 0.5)) - - ## This is how you switch the sun implementation. - ## This here is a no-op; but it's useful to test caelum doesn't crash when the second sun is created. - self.spheresun = caelum.SphereSun(self.sceneManager, self.caelumSystem.getCaelumCameraNode ()) - self.caelumSystem.setSun (self.spheresun) - - ## Setup sun options - if self.caelumSystem.getSun (): - self.caelumSystem.getSun ().setAmbientMultiplier (ogre.ColourValue(0.5, 0.5, 0.5)) - self.caelumSystem.getSun ().setDiffuseMultiplier (ogre.ColourValue(3, 3, 2.7)) - self.caelumSystem.getSun ().setSpecularMultiplier (ogre.ColourValue (5, 5, 5)) - self.caelumSystem.getSun ().setAutoDisable (True) - self.caelumSystem.getSun ().setAutoDisableThreshold (0.1) - - if (self.caelumSystem.getMoon ()): - self.caelumSystem.getMoon ().setAutoDisable (True) - self.caelumSystem.getMoon ().setAutoDisableThreshold (0.1) - -# ## Setup cloud options. -# ## Tweak these settings to make the demo look pretty. - if self.caelumSystem.getCloudSystem (): - - self.caelumSystem.getCloudSystem ().createLayerAtHeight(2000) - self.caelumSystem.getCloudSystem ().createLayerAtHeight(5000) - - self.caelumSystem.getCloudSystem ().getLayer(0).setCloudSpeed(ogre.Vector2(0.000005, -0.000009)) - self.caelumSystem.getCloudSystem ().getLayer(1).setCloudSpeed(ogre.Vector2(0.0000045, -0.0000085)) - - - ## Register caelum to the render target - self.renderWindow.addListener (self.caelumSystem) - ogre.Root.getSingletonPtr().addFrameListener( self.caelumSystem ) + ## Set camera clip distances. It's important to test with + ## an infinite clip distance. + self.camera.setFarClipDistance(0) + ##mCamera.setFarClipDistance(10000); + + def _createScene ( self ): ## Put some terrain in the scene self.sceneManager.setWorldGeometry ("CaelumDemoTerrain.cfg") - - def _createFrameListener(self): - # pass - # return - return - self.frameListener = CaelumSpeedFrameListener(self.renderWindow, self.camera,self.sceneManager, self.caelumSystem) -# self.root.addFrameListener(self.frameListener) - + self.sceneManager.setAmbientLight ( ogre.ColourValue(0,0,0 )) + + + if __name__ == '__main__': try: - application = TerrainApplication() + application = CaelumSampleApplication() application.go() except ogre.OgreException, e: Deleted: trunk/python-ogre/demos/caelum/media/AltocumulusDetail.png =================================================================== (Binary files differ) Deleted: trunk/python-ogre/demos/caelum/media/AltostratusDetail.png =================================================================== (Binary files differ) Deleted: trunk/python-ogre/demos/caelum/media/AtmosphereDepth.png =================================================================== (Binary files differ) Deleted: trunk/python-ogre/demos/caelum/media/CaelumDemoTerrain.cfg =================================================================== --- trunk/python-ogre/demos/caelum/media/CaelumDemoTerrain.cfg 2008-10-28 08:28:29 UTC (rev 778) +++ trunk/python-ogre/demos/caelum/media/CaelumDemoTerrain.cfg 2008-10-28 14:09:34 UTC (rev 779) @@ -1,35 +0,0 @@ -# Heightmap source -PageSource=Heightmap - -# Heightmap-source specific settings -Heightmap.image=terrain.png - -# How large is a page of tiles (in vertices)? Must be (2^n)+1 -PageSize=513 - -# How large is each tile? Must be (2^n)+1 and be smaller than PageSize -TileSize=65 - -# The maximum error allowed when determining which LOD to use -MaxPixelError=3 - -# The size of a terrain page, in world units -PageWorldX=1500 -PageWorldZ=1500 - -# Maximum height of the terrain -MaxHeight=100 - -# Upper LOD limit -MaxMipMapLevel=5 - -# The proportional distance range at which the LOD morph starts to take effect -# This is as a proportion of the distance between the current LODs effective range, -# and the effective range of the next lower LOD -LODMorphStart=0.2 - -# Use vertex program to morph LODs, if available -VertexProgramMorph=no - -# Caelum demo uses a custom material with fogging support. -CustomMaterialName=CaelumDemoTerrain Deleted: trunk/python-ogre/demos/caelum/media/CaelumGroundFog.cg =================================================================== --- trunk/python-ogre/demos/caelum/media/CaelumGroundFog.cg 2008-10-28 08:28:29 UTC (rev 778) +++ trunk/python-ogre/demos/caelum/media/CaelumGroundFog.cg 2008-10-28 14:09:34 UTC (rev 779) @@ -1,121 +0,0 @@ -/* -This file is part of Caelum. -See http://www.ogre3d.org/wiki/index.php/Caelum - -Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. - -Caelum is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published -by the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Caelum is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with Caelum. If not, see <http://www.gnu.org/licenses/>. -*/ - -// Return fogging through a layer of fog which drops exponentially by height. -// Foginess at a certain point is exp(-verticalDecay * (h - fogLevel)); -// A fogLevel from the ground fogginess is 1. -float ExpGroundFog (float invSinView, float h1, float h2, - float density, float verticalDecay, float fogLevel) -{ - // Integrate fog on a vertical line from h1 to h2. - float vFog = (-1 / verticalDecay) * - (exp (-verticalDecay * (h2 - fogLevel)) - - exp (-verticalDecay * (h1 - fogLevel))); - return 1 - exp (-density * invSinView * vFog); -} - -// Just like ExpGroundFog with infinite h2 -float ExpGroundFogInf (float invSinView, float h1, - float density, float verticalDecay, float fogLevel) -{ - // Integrate fog on a vertical line from h1 to h2. - float vFog = exp (-verticalDecay * (h1 - fogLevel)) / verticalDecay; - return 1 - exp (-density * invSinView * vFog); -} - -// Entry point for GroundFog vertex program. -void GroundFog_vp -( - float4 position : POSITION, - - out float4 oPosition : POSITION, - out float4 worldPos : TEXCOORD0, - - uniform float4x4 worldViewProj, - uniform float4x4 world -) { - oPosition = mul(worldViewProj, position); - worldPos = mul(world, position); -} - -// Entry point for GroundFog fragment program. -void GroundFog_fp -( - float3 worldPos : TEXCOORD0, - - uniform float3 camPos, - uniform float4 fogColour, - uniform float fogDensity, - uniform float fogVerticalDecay, - uniform float fogGroundLevel, - - out float4 oCol : COLOR -) { - float h1 = camPos.y; - float h2 = worldPos.y; - float invSinView = length(camPos - worldPos) / (h2 - h1); - float fog = ExpGroundFog(invSinView, - h1, h2, fogDensity, fogVerticalDecay, fogGroundLevel); - - oCol.rgb = fogColour.rgb; - oCol.a = fog; -} - -// Entry point for GroundFogDome vertex program. -void GroundFogDome_vp -( - in float4 position : POSITION, - out float4 oPosition : POSITION, - out float3 relPosition : TEXCOORD0, - uniform float4x4 worldViewProj -) { - oPosition = mul(worldViewProj, position); - relPosition = normalize(position); -} - -// Entry point for the GroundFogDome fragment program. -void GroundFogDome_fp -( - in float3 relPosition : TEXCOORD0, - - uniform float cameraHeight, - uniform float4 fogColour, - uniform float fogDensity, - uniform float fogVerticalDecay, - uniform float fogGroundLevel, - - out float4 oCol : COLOR -) { - // Fog magic. - float invSinView = 1 / (relPosition.y); - float h1 = cameraHeight; - float aFog; - - if (invSinView < 0) { - // Gazing into the abyss - aFog = 1; - } else { - aFog = saturate (ExpGroundFogInf ( - invSinView, h1, fogDensity, fogVerticalDecay, fogGroundLevel)); - } - - oCol.a = aFog; - oCol.rgb = fogColour.rgb; -} \ No newline at end of file Deleted: trunk/python-ogre/demos/caelum/media/CaelumLayeredClouds.cg =================================================================== --- trunk/python-ogre/demos/caelum/media/CaelumLayeredClouds.cg 2008-10-28 08:28:29 UTC (rev 778) +++ trunk/python-ogre/demos/caelum/media/CaelumLayeredClouds.cg 2008-10-28 14:09:34 UTC (rev 779) @@ -1,130 +0,0 @@ -/* -This file is part of Caelum. -See http://www.ogre3d.org/wiki/index.php/Caelum - -Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. - -Caelum is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published -by the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Caelum is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with Caelum. If not, see <http://www.gnu.org/licenses/>. -*/ - -// Global cloud textures -sampler cloud_shape1 : register(s0); -sampler cloud_shape2 : register(s1); -sampler cloud_detail : register(s2); - -// Get cloud layer intensity at a certain point. -float LayeredClouds_intensity -( - in float2 pos, - float cloudMassInvScale, - float cloudDetailInvScale, - float2 cloudMassOffset, - float2 cloudDetailOffset, - float cloudMassBlend, - float cloudDetailBlend, - float cloudCoverageThreshold -) -{ - // Calculate the base alpha - float2 finalMassOffset = cloudMassOffset + pos; - float aCloud = lerp(tex2D(cloud_shape1, finalMassOffset * cloudMassInvScale).r, - tex2D(cloud_shape2, finalMassOffset * cloudMassInvScale).r, - cloudMassBlend); - float aDetail = tex2D(cloud_detail, (cloudDetailOffset + pos) * cloudDetailInvScale).r; - aCloud = (aCloud + aDetail * cloudDetailBlend) / (1 + cloudDetailBlend); - return max(0, aCloud - cloudCoverageThreshold); -} - -// Entry point for Cloud vertex program. -void LayeredClouds_vp -( - in float4 position : POSITION, - in float2 uv : TEXCOORD0, - - uniform float4x4 worldViewProj, - uniform float3 sunDirection, - - out float4 oPosition : POSITION, - out float2 oUv : TEXCOORD0, - out float3 relPosition : TEXCOORD1, - out float sunGlow : TEXCOORD2 -) { - oPosition = mul(worldViewProj, position); - oUv = uv; - - // This is the relative position, or view direction. - relPosition = normalize (position.xyz); - - // Calculate the angle between the direction of the sun and the current - // view direction. This we call "glow" and ranges from 1 next to the sun - // to -1 in the opposite direction. - sunGlow = dot (relPosition, normalize (-sunDirection)); -} - -// Entry point for Cloud fragment program. -void LayeredClouds_fp -( - in float2 uv : TEXCOORD0, - in float3 relPosition : TEXCOORD1, - in float sunGlow : TEXCOORD2, - - uniform float cloudMassInvScale, - uniform float cloudDetailInvScale, - uniform float2 cloudMassOffset, - uniform float2 cloudDetailOffset, - uniform float cloudMassBlend, - uniform float cloudDetailBlend, - - uniform float cloudCoverageThreshold, - - uniform float4 sunColour, - uniform float4 fogColour, - uniform float cloudSharpness, - uniform float cloudThickness, - - out float4 oCol : COLOR -) { - // Initialize output. - oCol.rgba = float4(1, 1, 1, 0); - - // Get cloud intensity. - float intensity = LayeredClouds_intensity - ( - uv, - cloudMassInvScale, - cloudDetailInvScale, - cloudMassOffset, - cloudDetailOffset, - cloudMassBlend, - cloudDetailBlend, - cloudCoverageThreshold - ); - - // Opacity is exponential. - float aCloud = saturate(exp(cloudSharpness * intensity) - 1); - - float shine = pow(saturate(sunGlow), 8) / 4; - sunColour.rgb *= 1.5; - float3 cloudColour = fogColour.rgb * (1 - intensity / 3); - float thickness = saturate(0.8 - exp(-cloudThickness * (intensity + 0.2 - shine))); - - oCol.rgb = lerp(sunColour.rgb, cloudColour.rgb, thickness); - - // bottom 20th of the sky clouds vanish. - // Simple and effective.e - aCloud *= saturate (20 * relPosition.y); - - oCol.a = aCloud; - oCol.rgb = (oCol.rgb); -} \ No newline at end of file Deleted: trunk/python-ogre/demos/caelum/media/CaelumPhaseMoon.cg =================================================================== --- trunk/python-ogre/demos/caelum/media/CaelumPhaseMoon.cg 2008-10-28 08:28:29 UTC (rev 778) +++ trunk/python-ogre/demos/caelum/media/CaelumPhaseMoon.cg 2008-10-28 14:09:34 UTC (rev 779) @@ -1,61 +0,0 @@ -/* -This file is part of Caelum. -See http://www.ogre3d.org/wiki/index.php/Caelum - -Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. - -Caelum is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published -by the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Caelum is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with Caelum. If not, see <http://www.gnu.org/licenses/>. -*/ - -// Get how much of a certain point on the moon is seen (or not) because of the phase. -// uv is the rect position on moon; as seen from the earth. -// phase ranges from 0 to 2 -float MoonPhaseFactor(float2 uv, float phase) -{ - float alpha = 1.0; - - float srefx = uv.x - 0.5; - float refx = abs(uv.x - 0.5); - float refy = abs(uv.y - 0.5); - float refxfory = sqrt(0.25 - refy * refy); - float xmin = -refxfory; - float xmax = refxfory; - float xmin1 = (xmax - xmin) * (phase / 2) + xmin; - float xmin2 = (xmax - xmin) * phase + xmin; - if (srefx < xmin1) { - alpha = 0; - } else if (srefx < xmin2 && xmin1 != xmin2) { - alpha = (srefx - xmin1) / (xmin2 - xmin1); - } - - return alpha; -} - -void PhaseMoonFP -( - in float2 uv: TEXCOORD0, - uniform float phase, - uniform sampler2D moonDisc: register(s0), - out float4 outcol : COLOR -) -{ - outcol = tex2D(moonDisc, uv); - float alpha = MoonPhaseFactor(uv, phase); - - // Get luminance from the texture. - float lum = dot(outcol.rgb, float3(0.3333, 0.3333, 0.3333)); - //float lum = dot(outcol.rgb, float3(0.3, 0.59, 0.11)); - outcol.a = min(outcol.a, lum * alpha); - outcol.rgb /= lum; -} Deleted: trunk/python-ogre/demos/caelum/media/CaelumPointStarfield.cg =================================================================== --- trunk/python-ogre/demos/caelum/media/CaelumPointStarfield.cg 2008-10-28 08:28:29 UTC (rev 778) +++ trunk/python-ogre/demos/caelum/media/CaelumPointStarfield.cg 2008-10-28 14:09:34 UTC (rev 779) @@ -1,75 +0,0 @@ -/* -This file is part of Caelum. -See http://www.ogre3d.org/wiki/index.php/Caelum - -Copyright (c) 2008 Caelum team. See Contributors.txt for details. - -Caelum is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published -by the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Caelum is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with Caelum. If not, see <http://www.gnu.org/licenses/>. -*/ - -void StarPointVP -( - in float4 in_position : POSITION, - in float4 in_color : COLOR, - in float3 in_texcoord : TEXCOORD0, - - uniform float4x4 worldviewproj_matrix, - - // These params are in clipspace; not pixels - uniform float mag_scale, - uniform float mag0_size, - uniform float min_size, - uniform float max_size, - - // width/height - uniform float aspect_ratio, - - out float2 out_texcoord : TEXCOORD0, - out float4 out_position : POSITION, - out float4 out_color : COLOR -) -{ - out_position = mul(worldviewproj_matrix, in_position); - out_texcoord = in_texcoord.xy; - - float magnitude = in_texcoord.z; - float size = exp(mag_scale * magnitude) * mag0_size; - - // Fade below minSize. - float fade = saturate(size / min_size); - out_color = float4(in_color.rgb, fade * fade); - - // Clamp size to range. - size = clamp(size, min_size, max_size); - - // Spalt the billboard on the screen. - // It seems this can sometime mess order after transforms. - // Disabling culling works acceptably for the starfield. - out_position.xy += in_texcoord.xy * float2(size, size * aspect_ratio) * out_position.w; -} - -void StarPointFP -( - in float4 in_color : COLOR, - in float2 in_texcoord : TEXCOORD0, - - out float4 out_color : COLOR -) -{ - out_color = in_color; - float sqlen = dot(in_texcoord, in_texcoord); - - // A gaussian bell of sorts. - out_color.a *= 1.5 * exp(-(sqlen * 8)); -} \ No newline at end of file Deleted: trunk/python-ogre/demos/caelum/media/CaelumShaders.cg =================================================================== --- trunk/python-ogre/demos/caelum/media/CaelumShaders.cg 2008-10-28 08:28:29 UTC (rev 778) +++ trunk/python-ogre/demos/caelum/media/CaelumShaders.cg 2008-10-28 14:09:34 UTC (rev 779) @@ -1,380 +0,0 @@ -/* -This file is part of Caelum. -See http://www.ogre3d.org/wiki/index.php/Caelum - -Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. - -Caelum is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published -by the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Caelum is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with Caelum. If not, see <http://www.gnu.org/licenses/>. -*/ - -half bias (half b, half x) { - return pow (x, log (b) / log (0.5)); -} - -half4 sunlightInscatter (half4 sunColour, half absorption, half incidenceAngleCos, half sunlightScatteringFactor) { - half scatteredSunlight = bias (sunlightScatteringFactor * 0.5, incidenceAngleCos); - - sunColour = sunColour * (1 - absorption) * half4 (0.9, 0.5, 0.09, 1); - - return sunColour * scatteredSunlight; -} - -half fogExp (half z, half density) { - return 1 - clamp (pow (2.71828, -z * density), 0, 1); -} - -void SkyDome_vp (half4 position : POSITION, - half4 normal : NORMAL, - half2 uv : TEXCOORD0, - out half4 oPosition : POSITION, - out half4 oCol : COLOR, - out half2 oUv : TEXCOORD0, - out half incidenceAngleCos : TEXCOORD1, - out half y : TEXCOORD2, - out half3 oNormal : TEXCOORD3, - uniform half lightAbsorption, - uniform half4x4 worldViewProj, - uniform half3 sunDirection) -{ - sunDirection = normalize (sunDirection); - normal = normalize (normal); - half cosine = dot (-sunDirection, normal); - incidenceAngleCos = -cosine; - - y = -sunDirection.y; - - oPosition = mul(worldViewProj, position); - oCol = half4 (1, 1, 1, 1); - oUv = uv; - oNormal = -normal; -} - -void SkyDome_fp (half4 col : COLOR, - half2 uv : TEXCOORD0, - half incidenceAngleCos : TEXCOORD1, - half y : TEXCOORD2, - half3 normal : TEXCOORD3, - out half4 oCol : COLOR, - uniform sampler gradientsMap : register(s0), - uniform sampler1D atmRelativeDepth : register(s1), - uniform half4 hazeColour, - uniform half offset) -{ -// half4 sunColour = half4 (3, 2.5, 1, 1); - half4 sunColour = half4 (3, 3, 3, 1); - - half fogDensity = 15; - - // Haze amount calculation - half invHazeHeight = 100; - half haze = fogExp (pow (clamp (1 - normal.y, 0, 1), invHazeHeight), fogDensity); - - // Pass the colour - oCol = tex2D (gradientsMap, uv + half2 (offset, 0)) * col; - - // Sunlight inscatter - if (incidenceAngleCos > 0) { - half sunlightScatteringFactor = 0.05; - half sunlightScatteringLossFactor = 0.1; - half atmLightAbsorptionFactor = 0.1; - - oCol.rgb += sunlightInscatter (sunColour, - clamp (atmLightAbsorptionFactor * (1 - tex1D (atmRelativeDepth, y).r), 0, 1), - clamp (incidenceAngleCos, 0, 1), - sunlightScatteringFactor).rgb * (1 - sunlightScatteringLossFactor); - } - - // Haze pass - hazeColour.a = 1; - oCol = oCol * (1 - haze) + hazeColour * haze; -} - -void Haze_vp (half4 position : POSITION, - half4 normal : NORMAL, - out half4 oPosition : POSITION, - out half haze : TEXCOORD0, - out half2 sunlight : TEXCOORD1, - uniform half4x4 worldViewProj, - uniform half4 camPos, - uniform half3 sunDirection) -{ - sunDirection = normalize (sunDirection); - oPosition = mul(worldViewProj, position); - haze = length (camPos - position); - sunlight.x = dot (-sunDirection, normalize (position - camPos)); - sunlight.y = -sunDirection.y; -} - -void Haze_fp (half haze : TEXCOORD0, - half2 sunlight : TEXCOORD1, - out half4 oCol : COLOR, - uniform sampler1D atmRelativeDepth : register(s0), - uniform sampler2D gradientsMap : register (s1), - uniform half4 fogColour) -{ - half incidenceAngleCos = sunlight.x; - half y = sunlight.y; - - half4 sunColour = half4 (3, 2.5, 1, 1); - - half atmLightAbsorptionFactor = 0.1; // Factor determining the amount of light lost due to absorption - half fogDensity = 15; - - haze = fogExp (haze * 0.005, atmLightAbsorptionFactor); - - // Haze amount calculation - half invHazeHeight = 100; - half hazeAbsorption = fogExp (pow (1 - y, invHazeHeight), fogDensity); - - half4 hazeColour; - hazeColour = fogColour; - if (incidenceAngleCos > 0) { - half sunlightScatteringFactor = 0.1; // Factor determining the amount of scattering for the sun light - half sunlightScatteringLossFactor = 0.3; // Factor determining the amount of sun light intensity lost due to scattering - - half4 sunlightInscatterColour = sunlightInscatter (sunColour, - clamp ((1 - tex1D (atmRelativeDepth, y).r) * hazeAbsorption, 0, 1), - clamp (incidenceAngleCos, 0, 1), - sunlightScatteringFactor) * (1 - sunlightScatteringLossFactor); - hazeColour.rgb = hazeColour.rgb * (1 - sunlightInscatterColour.a) + sunlightInscatterColour.rgb * sunlightInscatterColour.a * haze; - } - - oCol = hazeColour; - oCol.a = haze; -} - - - -/////////////////////////////////////////////////////////////////////////////// - - - -// Global cloud textures -sampler cloud_shape1 : register(s0); -sampler cloud_shape2 : register(s1); -sampler cloud_detail : register(s2); - -// Get cloud layer intensity at a certain point. -float LayeredClouds_intensity -( - in float2 pos, - float cloudMassInvScale, - float cloudDetailInvScale, - float2 cloudMassOffset, - float2 cloudDetailOffset, - float cloudMassBlend, - float cloudDetailBlend, - float cloudCoverageThreshold -) -{ - // Calculate the base alpha - float2 finalMassOffset = cloudMassOffset + pos; - float aCloud = lerp(tex2D(cloud_shape1, finalMassOffset * cloudMassInvScale).r, - tex2D(cloud_shape2, finalMassOffset * cloudMassInvScale).r, - cloudMassBlend); - float aDetail = tex2D(cloud_detail, (cloudDetailOffset + pos) * cloudDetailInvScale).r; - aCloud = (aCloud + aDetail * cloudDetailBlend) / (1 + cloudDetailBlend); - return max(0, aCloud - cloudCoverageThreshold); -} - -// Entry point for Cloud vertex program. -void LayeredClouds_vp -( - in float4 position : POSITION, - in float2 uv : TEXCOORD0, - - uniform float4x4 worldViewProj, - uniform float3 sunDirection, - - out float4 oPosition : POSITION, - out float2 oUv : TEXCOORD0, - out float3 relPosition : TEXCOORD1, - out float sunGlow : TEXCOORD2 -) { - oPosition = mul(worldViewProj, position); - oUv = uv; - - // This is the relative position, or view direction. - relPosition = normalize (position.xyz); - - // Calculate the angle between the direction of the sun and the current - // view direction. This we call "glow" and ranges from 1 next to the sun - // to -1 in the opposite direction. - sunGlow = dot (relPosition, normalize (-sunDirection)); -} - -// Entry point for Cloud fragment program. -void LayeredClouds_fp -( - in float2 uv : TEXCOORD0, - in float3 relPosition : TEXCOORD1, - in float sunGlow : TEXCOORD2, - - uniform float cloudMassInvScale, - uniform float cloudDetailInvScale, - uniform float2 cloudMassOffset, - uniform float2 cloudDetailOffset, - uniform float cloudMassBlend, - uniform float cloudDetailBlend, - - uniform float cloudCoverageThreshold, - - uniform float4 sunColour, - uniform float4 fogColour, - uniform float cloudSharpness, - uniform float cloudThickness, - - out float4 oCol : COLOR -) { - // Initialize output. - oCol.rgba = float4(1, 1, 1, 0); - - // Get cloud intensity. - float intensity = LayeredClouds_intensity - ( - uv, - cloudMassInvScale, - cloudDetailInvScale, - cloudMassOffset, - cloudDetailOffset, - cloudMassBlend, - cloudDetailBlend, - cloudCoverageThreshold - ); - - // Opacity is exponential. - float aCloud = saturate(exp(cloudSharpness * intensity) - 1); - - float shine = pow(saturate(sunGlow), 8) / 4; - sunColour.rgb *= 1.5; - float3 cloudColour = fogColour.rgb * (1 - intensity / 3); - float thickness = saturate(0.8 - exp(-cloudThickness * (intensity + 0.2 - shine))); - - oCol.rgb = lerp(sunColour.rgb, cloudColour.rgb, thickness); - - // bottom 20th of the sky clouds vanish. - // Simple and effective.e - aCloud *= saturate (20 * relPosition.y); - - oCol.a = aCloud; - oCol.rgb = (oCol.rgb); -} - - - -/////////////////////////////////////////////////////////////////////////////// - - - -// Return fogging through a layer of fog which drops exponentially by height. -// Foginess at a certain point is exp(-verticalDecay * (h - fogLevel)); -// A fogLevel from the ground fogginess is 1. -float ExpGroundFog (float invSinView, float h1, float h2, - float density, float verticalDecay, float fogLevel) -{ - // Integrate fog on a vertical line from h1 to h2. - float vFog = (-1 / verticalDecay) * - (exp (-verticalDecay * (h2 - fogLevel)) - - exp (-verticalDecay * (h1 - fogLevel))); - return 1 - exp (-density * invSinView * vFog); -} - -// Just like ExpGroundFog with infinite h2 -float ExpGroundFogInf (float invSinView, float h1, - float density, float verticalDecay, float fogLevel) -{ - // Integrate fog on a vertical line from h1 to h2. - float vFog = exp (-verticalDecay * (h1 - fogLevel)) / verticalDecay; - return 1 - exp (-density * invSinView * vFog); -} - -// Entry point for GroundFog vertex program. -void GroundFog_vp -( - float4 position : POSITION, - - out float4 oPosition : POSITION, - out float4 worldPos : TEXCOORD0, - - uniform float4x4 worldViewProj, - uniform float4x4 world -) { - oPosition = mul(worldViewProj, position); - worldPos = mul(world, position); -} - -// Entry point for GroundFog fragment program. -void GroundFog_fp -( - float3 worldPos : TEXCOORD0, - - uniform float3 camPos, - uniform float4 fogColour, - uniform float fogDensity, - uniform float fogVerticalDecay, - uniform float fogGroundLevel, - - out float4 oCol : COLOR -) { - float h1 = camPos.y; - float h2 = worldPos.y; - float invSinView = length(camPos - worldPos) / (h2 - h1); - float fog = ExpGroundFog(invSinView, - h1, h2, fogDensity, fogVerticalDecay, fogGroundLevel); - - oCol.rgb = fogColour.rgb; - oCol.a = fog; -} - -// Entry point for GroundFogDome vertex program. -void GroundFogDome_vp -( - in float4 position : POSITION, - out float4 oPosition : POSITION, - out float3 relPosition : TEXCOORD0, - uniform float4x4 worldViewProj -) { - oPosition = mul(worldViewProj, position); - relPosition = normalize(position); -} - -// Entry point for the GroundFogDome fragment program. -void GroundFogDome_fp -( - in float3 relPosition : TEXCOORD0, - - uniform float cameraHeight, - uniform float4 fogColour, - uniform float fogDensity, - uniform float fogVerticalDecay, - uniform float fogGroundLevel, - - out float4 oCol : COLOR -) { - // Fog magic. - float invSinView = 1 / (relPosition.y); - float h1 = cameraHeight; - float aFog; - - if (invSinView < 0) { - // Gazing into the abyss - aFog = 0; - } else { - aFog = saturate (ExpGroundFogInf ( - invSinView, h1, fogDensity, fogVerticalDecay, fogGroundLevel)); - } - - oCol.a = aFog; - oCol.rgb = fogColour.rgb; -} \ No newline at end of file Deleted: trunk/python-ogre/demos/caelum/media/CaelumSkyDome.cg =================================================================== --- trunk/python-ogre/demos/caelum/media/CaelumSkyDome.cg 2008-10-28 08:28:29 UTC (rev 778) +++ trunk/python-ogre/demos/caelum/media/CaelumSkyDome.cg 2008-10-28 14:09:34 UTC (rev 779) @@ -1,157 +0,0 @@ -/* -This file is part of Caelum. -See http://www.ogre3d.org/wiki/index.php/Caelum - -Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. - -Caelum is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published -by the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Caelum is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with Caelum. If not, see <http://www.gnu.org/licenses/>. -*/ - -half bias (half b, half x) { - return pow (x, log (b) / log (0.5)); -} - -half4 sunlightInscatter (half4 sunColour, half absorption, half incidenceAngleCos, half sunlightScatteringFactor) { - half scatteredSunlight = bias (sunlightScatteringFactor * 0.5, incidenceAngleCos); - - sunColour = sunColour * (1 - absorption) * half4 (0.9, 0.5, 0.09, 1); - - return sunColour * scatteredSunlight; -} - -half fogExp (half z, half density) { - return 1 - clamp (pow (2.71828, -z * density), 0, 1); -} - -void SkyDome_vp (half4 position : POSITION, - half4 normal : NORMAL, - half2 uv : TEXCOORD0, - out half4 oPosition : POSITION, - out half4 oCol : COLOR, - out half2 oUv : TEXCOORD0, - out half incidenceAngleCos : TEXCOORD1, - out half y : TEXCOORD2, - out half3 oNormal : TEXCOORD3, - uniform half lightAbsorption, - uniform half4x4 worldViewProj, - uniform half3 sunDirection) -{ - sunDirection = normalize (sunDirection); - normal = normalize (normal); - half cosine = dot (-sunDirection, normal); - incidenceAngleCos = -cosine; - - y = -sunDirection.y; - - oPosition = mul(worldViewProj, position); - oCol = half4 (1, 1, 1, 1); - oUv = uv; - oNormal = -normal.xyz; -} - -void SkyDome_fp (half4 col : COLOR, - half2 uv : TEXCOORD0, - half incidenceAngleCos : TEXCOORD1, - half y : TEXCOORD2, - half3 normal : TEXCOORD3, - out half4 oCol : COLOR, - uniform sampler gradientsMap : register(s0), - uniform sampler1D atmRelativeDepth : register(s1), - uniform half4 hazeColour, - uniform half offset) -{ - half4 sunColour = half4 (3, 3, 3, 1); - -#ifdef HAZE - half fogDensity = 15; - // Haze amount calculation - half invHazeHeight = 100; - half haze = fogExp (pow (clamp (1 - normal.y, 0, 1), invHazeHeight), fogDensity); -#endif // HAZE - - // Pass the colour - oCol = tex2D (gradientsMap, uv + half2 (offset, 0)) * col; - - // Sunlight inscatter - if (incidenceAngleCos > 0) { - half sunlightScatteringFactor = 0.05; - half sunlightScatteringLossFactor = 0.1; - half atmLightAbsorptionFactor = 0.1; - - oCol.rgb += sunlightInscatter (sunColour, - clamp (atmLightAbsorptionFactor * (1 - tex1D (atmRelativeDepth, y).r), 0, 1), - clamp (incidenceAngleCos, 0, 1), - sunlightScatteringFactor).rgb * (1 - sunlightScatteringLossFactor); - } - -#ifdef HAZE - // Haze pass - hazeColour.a = 1; - oCol = oCol * (1 - haze) + hazeColour * haze; -#endif // HAZE -} - -void Haze_vp (half4 position : POSITION, - half4 normal : NORMAL, - out half4 oPosition : POSITION, - out half haze : TEXCOORD0, - out half2 sunlight : TEXCOORD1, - uniform half4x4 worldViewProj, - uniform half4 camPos, - uniform half3 sunDirection) -{ - sunDirection = normalize (sunDirection); - oPosition = mul(worldViewProj, position); - haze = length (camPos - position); - sunlight.x = dot (-sunDirection, normalize (position - camPos)); - sunlight.y = -sunDirection.y; -} - -void Haze_fp (half haze : TEXCOORD0, - half2 sunlight : TEXCOORD1, - out half4 oCol : COLOR, - uniform sampler1D atmRelativeDepth : register(s0), - uniform sampler2D gradientsMap : register (s1), - uniform half4 fogColour) -{ - half incidenceAngleCos = sunlight.x; - half y = sunlight.y; - - half4 sunColour = half4 (3, 2.5, 1, 1); - - half atmLightAbsorptionFactor = 0.1; // Factor determining the amount of light lost due to absorption - half fogDensity = 15; - - haze = fogExp (haze * 0.005, atmLightAbsorptionFactor); - - // Haze amount calculation - half invHazeHeight = 100; - half hazeAbsorption = fogExp (pow (1 - y, invHazeHeight), fogDensity); - - half4 hazeColour; - hazeColour = fogColour; - if (incidenceAngleCos > 0) { - half sunlightScatteringFactor = 0.1; // Factor determining the amount of scattering for the sun light - half sunlightScatteringLossFactor = 0.3; // Factor determining the amount of sun light intensity lost due to scattering - - half4 sunlightInscatterColour = sunlightInscatter (sunColour, - clamp ((1 - tex1D (atmRelativeDepth, y).r) * hazeAbsorption, 0, 1), - clamp (incidenceAngleCos, 0, 1), - sunlightScatteringFactor) * (1 - sunlightScatteringLossFactor); - hazeColour.rgb = hazeColour.rgb * (1 - sunlightInscatterColour.a) + sunlightInscatterColour.rgb * sunlightInscatterColour.a * haze; - } - - oCol = hazeColour; - oCol.a = haze; -} \ No newline at end of file Deleted: trunk/python-ogre/demos/caelum/media/CirrostratusDetail.png =================================================================== (Binary files differ) Deleted: trunk/python-ogre/demos/caelum/media/CirrusDetail.png =================================================================== (Binary files differ) Deleted: trunk/python-ogre/demos/caelum/media/CloudCoverLookup.png =================================================================== (Binary files differ) Deleted: trunk/python-ogre/demos/caelum/media/CloudLayer.png =================================================================== (Binary files differ) Deleted: trunk/python-ogre/demos/caelum/media/CloudNoise1.png =================================================================== (Binary files differ) Deleted: trunk/python-ogre/demos/caelum/media/EarthClearSky.png =================================================================== (Binary files differ) Deleted: trunk/python-ogre/demos/caelum/media/EarthClearSky2.png =================================================================== (Binary files differ) Deleted: trunk/python-ogre/demos/caelum/media/EarthClearSkyFog.png =================================================================== (Binary files differ) Deleted: trunk/python-ogre/demos/caelum/media/GroundFog.material =================================================================== --- trunk/python-ogre/demos/caelum/media/GroundFog.material 2008-10-28 08:28:29 UTC (rev 778) +++ trunk/python-ogre/demos/caelum/media/GroundFog.material 2008-10-28 14:09:34 UTC (rev 779) @@ -1,69 +0,0 @@ -// -//This file is part of Caelum. -//See http://www.ogre3d.org/wiki/index.php/Caelum -// -//Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. -// -//Caelum is free software: you can redistribute it and/or modify -//it under the terms of the GNU Lesser General Public License as published -//by the Free Software Foundation, either version 3 of the License, or -//(at your option) any later version. -// -//Caelum is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//GNU Lesser General Public License for more details. -// -//You should have received a copy of the GNU Lesser General Public License -//along with Caelum. If not, see <http://www.gnu.org/licenses/>. -// - -// Sample base material for using CaelumGroundFog. -material CaelumGroundFogBase -{ - technique Default - { - pass Main - { - fog_override true none - } - - // Fog pass - pass CaelumGroundFog - { - vertex_program_ref CaelumGroundFogVP - { - } - - fragment_program_ref CaelumGroundFogFP - { - } - - scene_blend alpha_blend - } - } -} - -material CaelumGroundFogDome -{ - technique - { - pass - { - lighting off - depth_check off - depth_write off - fog_override true - scene_blend alpha_blend - cull_hardware none - - vertex_program_ref CaelumGroundFogDomeVP - { - } - - fragment_program_ref CaelumGroundFogDomeFP - { - } - } - } -} \ No newline at end of file Deleted: trunk/python-ogre/demos/caelum/media/GroundFog.program =================================================================== --- trunk/python-ogre/demos/caelum/media/GroundFog.program 2008-10-28 08:28:29 UTC (rev 778) +++ trunk/python-ogre/demos/caelum/media/GroundFog.program 2008-10-28 14:09:34 UTC (rev 779) @@ -1,85 +0,0 @@ -// -//This file is part of Caelum. -//See http://www.ogre3d.org/wiki/index.php/Caelum -// -//Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. -// -//Caelum is free software: you can redistribute it and/or modify -//it under the terms of the GNU Lesser General Public License as published -//by the Free Software Foundation, either version 3 of the License, or -//(at your option) any later version. -// -//Caelum is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//GNU Lesser General Public License for more details. -// -//You should have received a copy of the GNU Lesser General Public License -//along with Caelum. If not, see <http://www.gnu.org/licenses/>. -// - -vertex_program CaelumGroundFogVP cg -{ - source CaelumGroundFog.cg - entry_point GroundFog_vp - profiles vs_2_x arbvp1 vp30 - compile_arguments -posinv - - default_params - { - param_named_auto worldViewProj worldviewproj_matrix - param_named_auto world world_matrix - } -} - -fragment_program CaelumGroundFogFP cg -{ - source CaelumGroundFog.cg - entry_point GroundFog_fp - profiles ps_2_x arbfp1 fp30 - - default_params - { - param_named_auto camPos camera_position - - // _auto seems wrong here, since the fog formulas are different than - // for standard exp fog. - param_named fogDensity float 0 - param_named fogVerticalDecay float 0 - param_named fogGroundLevel float 0 - param_named fogColour float4 0 0 0 0 - } -} - -vertex_program CaelumGroundFogDomeVP cg -{ - source CaelumGroundFog.cg - entry_point GroundFogDome_vp - profiles vs_2_0 arbvp1 - compile_arguments -posinv - - default_params - { - param_named_auto worldViewProj worldviewproj_matrix - } -} - -fragment_program CaelumGroundFogDomeFP cg -{ - source CaelumGroundFog.cg - entry_point GroundFogDome_fp - profiles ps_2_0 arbfp1 - - default_params - { - // Fog parameters. - param_named fogColour float4 0 0 0 0 - param_named fogDensity float 0 - param_named fogVerticalDecay float 0 - param_named fogGroundLevel float 0 - - // Send camera height. We can't send camera_position because - // the entity is always moved with the camera. Joy. - param_named cameraHeight float 0 - } -} \ No newline at end of file Deleted: trunk/python-ogre/demos/caelum/media/Haze.program =================================================================== --- trunk/python-ogre/demos/caelum/media/Haze.program 2008-10-28 08:28:29 UTC (rev 778) +++ trunk/python-ogre/demos/caelum/media/Haze.program 2008-10-28 14:09:34 UTC (rev 779) @@ -1,46 +0,0 @@ -// -//This file is part of Caelum. -//See http://www.ogre3d.org/wiki/index.php/Caelum -// -//Copyright (c) 2006-2007 Caelum team. See Contributors.txt for details. -// -//Caelum is free software: you can redistribute it and/or modify -//it under the terms of the GNU Lesser General Public License as published -//by the Free Software Foundation, either version 3 of the License, or -//(at your option) any later version. -// -//Caelum is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//GNU Lesser General Public License for more details. -// -//You should have received a copy of the GNU Lesser General Public License -//along with Caelum. If not, see <http://www.gnu.org/licenses/>. -// - -vertex_program CaelumHazeVP cg -{ - source CaelumSkyDome.cg - entry_point Haze_vp - profiles vs_2_0 arbvp1 vp30 - compile_arguments -posinv - - default_params - { - param_named_auto worldViewProj worldviewproj_matrix - param_named_auto camPos camera_position - } -} - -fragment_program CaelumHazeFP cg -{ - source CaelumSkyDome.cg - entry_point Haze_fp - profiles ps_2_0 arbfp1 fp30 - compile_arguments -posinv - - default_params - { - param_named_auto fogColour fog_colour - } -} \ No newline at end of file Deleted: trunk/python-ogre/demos/caelum/media/LayeredCloud.cg =================================================================== --- trunk/python-ogre/demos/caelum/media/LayeredCloud.cg 2008-10-28 08:28:29 UTC (rev 778) +++ trunk/python-ogre/demos/caelum/media/LayeredCloud.cg 2008-10-28 14:09:34 UTC (rev 779) @@ -1,90 +0,0 @@ -sampler cloud : register(s0); -sampler detail : register(s1); -sampler noise : register(s2); - -void main_vp (in float4 position : POSITION, - in float3 normal : NORMAL, - in float2 uv : TEXCOORD0, - in float4 colour : COLOR, - out float4 oPosition : POSITION, - out float4 oColour : COLOR, - out float2 oUv : TEXCOORD0, - out float oGlow : TEXCOORD1, - uniform float4x4 world, - uniform float4x4 worldViewProj, - uniform float3 eyePosition, - uniform float3 sunDirection) -{ - oPosition = mul(worldViewProj, position); - - oColour = colour; - - float3 relPosition = normalize (position); - sunDirection = normalize (-sunDirection); - - oGlow = clamp (dot (relPosition, sunDirection), 0, 1); - - oUv = uv; -} - -void main_fp (in float4 col : COLOR, - in float2 uv : TEXCOORD0, - in float glow : TEXCOORD1, - out float4 oCol : COLOR, - uniform float3 sunDirection, - uniform float4 sunColour, - uniform float time, - uniform float4 fogColour, - uniform float lightInvScattering, - uniform float absorptionFactor, - uniform float cloudInvScale, - uniform float detailInvScale, - uniform float noiseInvScale, - uniform float2 cloudSpeed, - uniform float2 detailSpeed, - uniform float haloThreshold) -{ - // Calculate sampler positions - float2 cloudOffset = cloudSpeed * time + uv; - float2 detailOffset = detailSpeed * time + uv; - // Calculate the base alpha - float a1 = tex2D (cloud, (cloudOffset) * cloudInvScale); - // If the base is transparent, it will be invisible and we can skip expensive calculatio... [truncated message content] |