Revision: 759
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=759&view=rev
Author: bharling
Date: 2008-10-16 08:44:11 +0000 (Thu, 16 Oct 2008)
Log Message:
-----------
Added PSSM Demo
Added Paths:
-----------
trunk/python-ogre/demos/PSSM_demo/
trunk/python-ogre/demos/PSSM_demo/Media/
trunk/python-ogre/demos/PSSM_demo/Media/_ambient.cg
trunk/python-ogre/demos/PSSM_demo/Media/_diffuse.cg
trunk/python-ogre/demos/PSSM_demo/Media/_shadow_caster.cg
trunk/python-ogre/demos/PSSM_demo/Media/_shadow_caster.program
trunk/python-ogre/demos/PSSM_demo/Media/ambient.program
trunk/python-ogre/demos/PSSM_demo/Media/cement.dds
trunk/python-ogre/demos/PSSM_demo/Media/cementNRM.dds
trunk/python-ogre/demos/PSSM_demo/Media/cementSPEC.dds
trunk/python-ogre/demos/PSSM_demo/Media/city.material
trunk/python-ogre/demos/PSSM_demo/Media/city.mesh
trunk/python-ogre/demos/PSSM_demo/Media/cityAO.dds
trunk/python-ogre/demos/PSSM_demo/Media/diffuse.program
trunk/python-ogre/demos/PSSM_demo/plugins.cfg
trunk/python-ogre/demos/PSSM_demo/pssm_demo.py
trunk/python-ogre/demos/PSSM_demo/resources.cfg
Added: trunk/python-ogre/demos/PSSM_demo/Media/_ambient.cg
===================================================================
--- trunk/python-ogre/demos/PSSM_demo/Media/_ambient.cg (rev 0)
+++ trunk/python-ogre/demos/PSSM_demo/Media/_ambient.cg 2008-10-16 08:44:11 UTC (rev 759)
@@ -0,0 +1,32 @@
+void ambient_vs(
+ float4 position : POSITION,
+ float2 diffuseUV : TEXCOORD0,
+ float2 aoUV : TEXCOORD1,
+
+ out float4 oPosition : POSITION,
+ out float2 oDiffuseUV : TEXCOORD0,
+ out float2 oAoUV : TEXCOORD1,
+
+ uniform float4x4 worldViewProj)
+{
+ oPosition = mul(worldViewProj, position);
+ oDiffuseUV = diffuseUV;
+ oAoUV = aoUV;
+}
+
+void ambient_ps(
+ float2 diffuseUV : TEXCOORD0,
+ float2 aoUV : TEXCOORD1,
+
+ out float4 colour : COLOR,
+
+ uniform float3 ambient,
+
+ uniform sampler2D diffuseMap,
+ uniform sampler2D AOMap
+ )
+{
+ colour = tex2D(diffuseMap, diffuseUV);
+ colour *= tex2D(AOMap, aoUV);
+ colour *= float4(ambient, 1);
+}
Added: trunk/python-ogre/demos/PSSM_demo/Media/_diffuse.cg
===================================================================
--- trunk/python-ogre/demos/PSSM_demo/Media/_diffuse.cg (rev 0)
+++ trunk/python-ogre/demos/PSSM_demo/Media/_diffuse.cg 2008-10-16 08:44:11 UTC (rev 759)
@@ -0,0 +1,149 @@
+void diffuse_vs(
+ float4 position : POSITION,
+ float3 normal : NORMAL,
+ float2 uv : TEXCOORD0,
+ float4 tangentPar : TANGENT0,
+
+ out float4 oPosition : POSITION,
+ out float3 oUv : TEXCOORD0,
+ out float3 oTSLightDir : TEXCOORD1,
+ out float3 oTSHalfAngle : TEXCOORD2,
+ out float4 oLightPosition0 : TEXCOORD3,
+ out float4 oLightPosition1 : TEXCOORD4,
+ out float4 oLightPosition2 : TEXCOORD5,
+
+ uniform float4 lightPosition, // object space
+ uniform float3 eyePosition, // object space
+ uniform float4x4 worldViewProjMatrix,
+ uniform float4x4 texWorldViewProjMatrix0,
+ uniform float4x4 texWorldViewProjMatrix1,
+ uniform float4x4 texWorldViewProjMatrix2)
+{
+ // calculate output position
+ oPosition = mul(worldViewProjMatrix, position);
+
+ // pass the main uvs straight through unchanged
+ oUv.xy = uv;
+ oUv.z = oPosition.z;
+
+ // calculate tangent space light vector
+ // Get object space light direction
+ float3 lightDir = normalize(lightPosition.xyz - (position * lightPosition.w).xyz);
+
+ // Get the tangent component.
+ float3 tangent = tangentPar.xyz;
+
+ // Calculate the binormal (NB we assume both normal and tangent are
+ // already normalised)
+ // NB looks like nvidia cross params are BACKWARDS to what you'd expect
+ // this equates to NxT, not TxN
+ float3 binormal = cross(tangent, normal) * tangentPar.w;
+
+ // Form a rotation matrix out of the vectors
+ float3x3 rotation = float3x3(tangent, binormal, normal);
+
+ // Transform the light vector according to this matrix
+ oTSLightDir = mul(rotation, lightDir);
+
+ // Calculate half-angle in tangent space
+ float3 eyeDir = normalize(eyePosition - position.xyz);
+ oTSHalfAngle = mul(rotation, normalize(eyeDir + lightDir));
+
+ // Calculate the position of vertex in light space
+ oLightPosition0 = mul(texWorldViewProjMatrix0, position);
+ oLightPosition1 = mul(texWorldViewProjMatrix1, position);
+ oLightPosition2 = mul(texWorldViewProjMatrix2, position);
+}
+
+float shadowPCF(sampler2D shadowMap, float4 shadowMapPos, float2 offset)
+{
+ shadowMapPos = shadowMapPos / shadowMapPos.w;
+ float2 uv = shadowMapPos.xy;
+ float3 o = float3(offset, -offset.x) * 0.3f;
+
+ // Note: We using 2x2 PCF. Good enough and is alot faster.
+ float c = (shadowMapPos.z <= tex2D(shadowMap, uv.xy - o.xy).r) ? 1 : 0; // top left
+ c += (shadowMapPos.z <= tex2D(shadowMap, uv.xy + o.xy).r) ? 1 : 0; // bottom right
+ c += (shadowMapPos.z <= tex2D(shadowMap, uv.xy + o.zy).r) ? 1 : 0; // bottom left
+ c += (shadowMapPos.z <= tex2D(shadowMap, uv.xy - o.zy).r) ? 1 : 0; // top right
+ //float c = (shadowMapPos.z <= tex2Dlod(shadowMap, uv.xyyy - o.xyyy).r) ? 1 : 0; // top left
+ //c += (shadowMapPos.z <= tex2Dlod(shadowMap, uv.xyyy + o.xyyy).r) ? 1 : 0; // bottom right
+ //c += (shadowMapPos.z <= tex2Dlod(shadowMap, uv.xyyy + o.zyyy).r) ? 1 : 0; // bottom left
+ //c += (shadowMapPos.z <= tex2Dlod(shadowMap, uv.xyyy - o.zyyy).r) ? 1 : 0; // top right
+ return c / 4;
+}
+
+// to put it simply, this does 100% per pixel diffuse lighting
+void diffuse_ps(
+ float3 uv : TEXCOORD0,
+ float3 TSlightDir : TEXCOORD1,
+ float3 TShalfAngle : TEXCOORD2,
+ float4 LightPosition0 : TEXCOORD3,
+ float4 LightPosition1 : TEXCOORD4,
+ float4 LightPosition2 : TEXCOORD5,
+
+ out float4 oColour : COLOR,
+
+ uniform float4 invShadowMapSize0,
+ uniform float4 invShadowMapSize1,
+ uniform float4 invShadowMapSize2,
+ uniform float4 pssmSplitPoints,
+ uniform sampler2D diffuse,
+ uniform sampler2D specular,
+ uniform sampler2D normalMap,
+ uniform sampler2D shadowMap0,
+ uniform sampler2D shadowMap1,
+ uniform sampler2D shadowMap2,
+ uniform float4 lightDiffuse,
+ uniform float4 lightSpecular
+ )
+{
+ // calculate shadow
+ float shadowing = 1.0f;
+ float4 splitColour;
+ if (uv.z <= pssmSplitPoints.y)
+ {
+ splitColour = float4(0.1, 0, 0, 1);
+ shadowing = shadowPCF(shadowMap0, LightPosition0, invShadowMapSize0.xy);
+ }
+ else if (uv.z <= pssmSplitPoints.z)
+ {
+ splitColour = float4(0, 0.1, 0, 1);
+ shadowing = shadowPCF(shadowMap1, LightPosition1, invShadowMapSize1.xy);
+ }
+ else
+ {
+ splitColour = float4(0.1, 0.1, 0, 1);
+ shadowing = shadowPCF(shadowMap2, LightPosition2, invShadowMapSize2.xy);
+ }
+
+ // retrieve normalised light vector, expand from range-compressed
+ float3 lightVec = normalize(TSlightDir);
+
+ // retrieve half angle and normalise through cube map
+ float3 halfAngle = normalize(TShalfAngle);
+
+ // get diffuse colour
+ float4 diffuseColour = tex2D(diffuse, uv.xy);
+
+ // specular
+ float4 specularColour = tex2D(specular, uv.xy);
+ float shininess = specularColour.w;
+ specularColour.w = 1;
+
+ // get bump map vector, again expand from range-compressed
+ float3 bumpVec = (tex2D(normalMap, uv.xy).wyz - 0.5) * 2;
+ bumpVec.z = sqrt(1 - bumpVec.x * bumpVec.x - bumpVec.y * bumpVec.y);
+ bumpVec = normalize(bumpVec);
+
+ // calculate lit value.
+ float4 lighting = lit(dot(bumpVec, lightVec), dot(bumpVec, halfAngle), shininess * 128);
+
+ // final lighting with diffuse and spec
+ oColour = (diffuseColour * lightDiffuse * lighting.y) + (lightSpecular * specularColour * lighting.z);
+ oColour.w = diffuseColour.w;
+
+ // Apply shadowing
+ oColour *= float4(shadowing, shadowing, shadowing, 1);
+ //oColour += splitColour;
+}
Added: trunk/python-ogre/demos/PSSM_demo/Media/_shadow_caster.cg
===================================================================
--- trunk/python-ogre/demos/PSSM_demo/Media/_shadow_caster.cg (rev 0)
+++ trunk/python-ogre/demos/PSSM_demo/Media/_shadow_caster.cg 2008-10-16 08:44:11 UTC (rev 759)
@@ -0,0 +1,29 @@
+void shadow_caster_vs(
+ float4 position : POSITION,
+
+ out float4 oPosition : POSITION,
+ out float2 oDepth : TEXCOORD0,
+
+ uniform float4x4 wvpMat)
+{
+ // this is the view space position
+ oPosition = mul(wvpMat, position);
+
+ // depth info for the fragment.
+ oDepth.x = oPosition.z;
+ oDepth.y = oPosition.w;
+
+ // clamp z to zero. seem to do the trick. :-/
+ //oPosition.z = max(oPosition.z, 0);
+}
+
+void shadow_caster_ps(
+ float2 depth : TEXCOORD0,
+
+ out float4 oColour : COLOR,
+
+ uniform float4 pssmSplitPoints)
+{
+ float finalDepth = depth.x / depth.y;
+ oColour = float4(finalDepth, finalDepth, finalDepth, 1);
+}
Added: trunk/python-ogre/demos/PSSM_demo/Media/_shadow_caster.program
===================================================================
--- trunk/python-ogre/demos/PSSM_demo/Media/_shadow_caster.program (rev 0)
+++ trunk/python-ogre/demos/PSSM_demo/Media/_shadow_caster.program 2008-10-16 08:44:11 UTC (rev 759)
@@ -0,0 +1,51 @@
+// declare the vertex shader (CG for the language)
+vertex_program shadow_caster_vs cg
+{
+ // source file
+ source _shadow_caster.cg
+ // will run on vertex shader 1.1+
+ profiles vs_1_1 arbvp1
+ // entry function
+ entry_point shadow_caster_vs
+
+ default_params
+ {
+ param_named_auto wvpMat worldviewproj_matrix
+ // this is the scene's depth range
+ //param_named_auto depthRange scene_depth_range
+ //param_named_auto optimalAdustFactor custom 0
+ }
+}
+
+// declare the fragment shader (CG for the language)
+fragment_program shadow_caster_ps cg
+{
+ // source file
+ source _shadow_caster.cg
+ // will run on pixel shader 2.0+
+ profiles ps_2_0 arbfp1
+ // entry function
+ entry_point shadow_caster_ps
+
+ default_params
+ {
+ }
+}
+
+material shadow_caster
+{
+ technique
+ {
+ // all this will do is write depth and depth\xB2 to red and green
+ pass
+ {
+ vertex_program_ref shadow_caster_vs
+ {
+ }
+
+ fragment_program_ref shadow_caster_ps
+ {
+ }
+ }
+ }
+}
Added: trunk/python-ogre/demos/PSSM_demo/Media/ambient.program
===================================================================
--- trunk/python-ogre/demos/PSSM_demo/Media/ambient.program (rev 0)
+++ trunk/python-ogre/demos/PSSM_demo/Media/ambient.program 2008-10-16 08:44:11 UTC (rev 759)
@@ -0,0 +1,23 @@
+vertex_program ambient_vs cg
+{
+ source _ambient.cg
+ profiles vs_1_1 arbvp1
+ entry_point ambient_vs
+
+ default_params
+ {
+ param_named_auto worldViewProj worldviewproj_matrix
+ }
+}
+
+fragment_program ambient_ps cg
+{
+ source _ambient.cg
+ profiles ps_2_0 arbfp1
+ entry_point ambient_ps
+
+ default_params
+ {
+ param_named_auto ambient derived_ambient_light_colour
+ }
+}
Added: trunk/python-ogre/demos/PSSM_demo/Media/cement.dds
===================================================================
(Binary files differ)
Property changes on: trunk/python-ogre/demos/PSSM_demo/Media/cement.dds
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/python-ogre/demos/PSSM_demo/Media/cementNRM.dds
===================================================================
(Binary files differ)
Property changes on: trunk/python-ogre/demos/PSSM_demo/Media/cementNRM.dds
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/python-ogre/demos/PSSM_demo/Media/cementSPEC.dds
===================================================================
(Binary files differ)
Property changes on: trunk/python-ogre/demos/PSSM_demo/Media/cementSPEC.dds
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/python-ogre/demos/PSSM_demo/Media/city.material
===================================================================
--- trunk/python-ogre/demos/PSSM_demo/Media/city.material (rev 0)
+++ trunk/python-ogre/demos/PSSM_demo/Media/city.material 2008-10-16 08:44:11 UTC (rev 759)
@@ -0,0 +1,88 @@
+abstract material _base
+{
+ technique
+ {
+ pass AMBIENT
+ {
+ ambient 0.4 0.4 0.5
+
+ vertex_program_ref ambient_vs {}
+ fragment_program_ref ambient_ps {}
+
+ texture_unit diffuse_tex
+ {
+ texture $diffuse
+ filtering anisotropic
+ max_anisotropy 16
+ }
+ texture_unit
+ {
+ texture $ambientOcclusion
+ filtering anisotropic
+ max_anisotropy 16
+ }
+ }
+ pass DIFFUSE
+ {
+ scene_blend add
+ iteration once directional
+ alpha_rejection greater_equal 128
+
+ ambient 0 0 0
+ diffuse 1 1 1
+ specular 1 1 1 128
+
+ vertex_program_ref shadowDiffuse_vs {}
+ fragment_program_ref shadowDiffuse_ps {}
+
+ texture_unit shadow_tex0
+ {
+ content_type shadow
+ filtering anisotropic
+ max_anisotropy 16
+ tex_address_mode clamp
+ }
+ texture_unit shadow_tex1
+ {
+ content_type shadow
+ filtering anisotropic
+ max_anisotropy 16
+ tex_address_mode clamp
+ }
+ texture_unit shadow_tex2
+ {
+ content_type shadow
+ filtering anisotropic
+ max_anisotropy 16
+ tex_address_mode clamp
+ }
+
+ texture_unit diffuse_tex
+ {
+ texture $diffuse
+ filtering anisotropic
+ max_anisotropy 16
+ }
+ texture_unit specular_tex
+ {
+ texture $specular
+ filtering anisotropic
+ max_anisotropy 16
+ }
+ texture_unit normal_tex
+ {
+ texture $normal
+ filtering anisotropic
+ max_anisotropy 16
+ }
+ }
+ }
+}
+
+material city : _base
+{
+ set $diffuse cement.dds
+ set $specular cementSPEC.dds
+ set $normal cementNRM.dds
+ set $ambientOcclusion cityAO.dds
+}
Added: trunk/python-ogre/demos/PSSM_demo/Media/city.mesh
===================================================================
(Binary files differ)
Property changes on: trunk/python-ogre/demos/PSSM_demo/Media/city.mesh
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/python-ogre/demos/PSSM_demo/Media/cityAO.dds
===================================================================
(Binary files differ)
Property changes on: trunk/python-ogre/demos/PSSM_demo/Media/cityAO.dds
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/python-ogre/demos/PSSM_demo/Media/diffuse.program
===================================================================
--- trunk/python-ogre/demos/PSSM_demo/Media/diffuse.program (rev 0)
+++ trunk/python-ogre/demos/PSSM_demo/Media/diffuse.program 2008-10-16 08:44:11 UTC (rev 759)
@@ -0,0 +1,37 @@
+vertex_program shadowDiffuse_vs cg
+{
+ source _diffuse.cg
+ profiles vs_1_1 arbvp1
+ entry_point diffuse_vs
+
+ default_params
+ {
+ param_named_auto lightPosition light_position_object_space 0
+ param_named_auto eyePosition camera_position_object_space
+ param_named_auto worldViewProjMatrix worldviewproj_matrix
+ param_named_auto texWorldViewProjMatrix0 texture_worldviewproj_matrix 0
+ param_named_auto texWorldViewProjMatrix1 texture_worldviewproj_matrix 1
+ param_named_auto texWorldViewProjMatrix2 texture_worldviewproj_matrix 2
+ //param_named_auto depthRange0 shadow_scene_depth_range 0
+ //param_named_auto depthRange1 shadow_scene_depth_range 1
+ //param_named_auto depthRange2 shadow_scene_depth_range 2
+ }
+}
+
+fragment_program shadowDiffuse_ps cg
+{
+ source _diffuse.cg
+ profiles ps_2_x arbfp1
+ //profiles ps_3_0 fp40
+ entry_point diffuse_ps
+
+ default_params
+ {
+ param_named_auto lightDiffuse light_diffuse_colour 0
+ param_named_auto lightSpecular light_specular_colour 0
+ param_named_auto invShadowMapSize0 inverse_texture_size 0
+ param_named_auto invShadowMapSize1 inverse_texture_size 1
+ param_named_auto invShadowMapSize2 inverse_texture_size 2
+ param_named_auto pssmSplitPoints custom 0
+ }
+}
Added: trunk/python-ogre/demos/PSSM_demo/plugins.cfg
===================================================================
--- trunk/python-ogre/demos/PSSM_demo/plugins.cfg (rev 0)
+++ trunk/python-ogre/demos/PSSM_demo/plugins.cfg 2008-10-16 08:44:11 UTC (rev 759)
@@ -0,0 +1,19 @@
+# Defines plugins to load
+
+## Use this for Windows
+# Define plugin folder
+PluginFolder=../../plugins
+Plugin=RenderSystem_GL.dll
+Plugin=RenderSystem_Direct3D9.dll
+Plugin=Plugin_ParticleFX.dll
+Plugin=Plugin_BSPSceneManager.dll
+Plugin=Plugin_OctreeSceneManager.dll
+Plugin=Plugin_CgProgramManager.dll
+
+##
+## NOTE use this for MacOS or Linux
+# Plugin=RenderSystem_GL
+# Plugin=Plugin_ParticleFX
+# Plugin=Plugin_BSPSceneManager
+# Plugin=Plugin_OctreeSceneManager
+# Plugin=Plugin_CgProgramManager
Added: trunk/python-ogre/demos/PSSM_demo/pssm_demo.py
===================================================================
--- trunk/python-ogre/demos/PSSM_demo/pssm_demo.py (rev 0)
+++ trunk/python-ogre/demos/PSSM_demo/pssm_demo.py 2008-10-16 08:44:11 UTC (rev 759)
@@ -0,0 +1,158 @@
+# This code is in the Public Domain
+# -----------------------------------------------------------------------------
+# This source file is part of Python-Ogre
+# For the latest info, see http://python-ogre.org/
+#
+# It is likely based on original code from OGRE and/or PyOgre
+# For the latest info, see http://www.ogre3d.org/
+#
+# You may use this sample code for anything you like, it is not covered by the
+# LGPL.
+# -----------------------------------------------------------------------------
+
+# NOTE:
+# This demo includes meshes and shaders by lf3thn4d
+# see below for more details:
+# http://www.ogre3d.org/phpBB2/viewtopic.php?t=41801&highlight=pssm
+
+# Authors Note:
+# This demo seems to perform much better on ATI cards than NVIDIA!
+
+import sys
+sys.path.insert(0,'..')
+import PythonOgreConfig
+
+import ogre.renderer.OGRE as ogre
+import ogre.io.OIS as OIS
+import SampleFramework as sf
+
+class PSSMDemoFrameListener(sf.FrameListener):
+ def __init__(self, rw, cam, light):
+ sf.FrameListener.__init__(self, rw, cam)
+ self.light = light
+ self.angle = ogre.Math.PI / 2
+ self.radius = 1000
+
+ def frameStarted(self, evt):
+ self.angle += evt.timeSinceLastFrame
+ xpos = self.radius * ogre.Math.Sin( ogre.Degree( self.angle ) * 5.0 )
+ zpos = self.radius * ogre.Math.Cos( ogre.Degree( self.angle ) * 5.0 )
+ pos = ogre.Vector3( xpos, 400, zpos )
+ self.light.setPosition( pos )
+ dirvec = -self.light.getPosition()
+ dirvec.normalise()
+ self.light.setDirection( dirvec )
+
+ return sf.FrameListener.frameStarted(self, evt)
+
+
+
+class ApplicationPSSM(sf.Application):
+
+ def __del__(self):
+ del self.pssmSetup
+
+ def _createScene(self):
+ self.sceneManager.setShadowTechnique(ogre.SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED)
+
+ # 3 textures per directional light
+ self.sceneManager.setShadowTextureCountPerLightType(ogre.Light.LT_DIRECTIONAL, 3);
+ self.sceneManager.setShadowTextureSettings(1024, 3, ogre.PF_FLOAT32_R);
+ self.sceneManager.setShadowTextureSelfShadow(True);
+ # Set up caster material - this is just a standard depth/shadow map caster
+ self.sceneManager.setShadowTextureCasterMaterial("shadow_caster");
+ self.camera.setNearClipDistance(1.0)
+ self.camera.setFarClipDistance(1000.0)
+
+ # shadow camera setup
+ self.pssmSetup = ogre.PSSMShadowCameraSetup()
+ self.pssmSetup.calculateSplitPoints(3, self.camera.getNearClipDistance(), self.camera.getFarClipDistance())
+ self.pssmSetup.setSplitPadding(5)
+ self.pssmSetup.setOptimalAdjustFactor(0, 2)
+ self.pssmSetup.setOptimalAdjustFactor(1, 1);
+ self.pssmSetup.setOptimalAdjustFactor(2, 0.5)
+
+ self.sceneManager.setShadowCameraSetup(self.pssmSetup)
+
+
+ # setup the sun light.
+ self.sceneManager.setAmbientLight(ogre.ColourValue(0.4, 0.4, 0.5));
+ self.mSunLight = self.sceneManager.createLight("_SunLight")
+ self.mSunLight.setType(ogre.Light.LT_DIRECTIONAL)
+ self.mSunLight.setDirection(ogre.Vector3(-1, -1, -1))
+ self.mSunLight.setDiffuseColour(ogre.ColourValue(1, 1, 1))
+ self.mSunLight.setSpecularColour(ogre.ColourValue(1,1,1))
+
+ # Create the Mesh -
+ # Note Mesh and Shaders courtesy of lf3thn4d
+ cityNode = self.sceneManager.getRootSceneNode().createChildSceneNode()
+ cityEntity = self.sceneManager.createEntity("City", "city.mesh")
+ cityNode.attachObject(cityEntity)
+ cityNode.setScale(10,10,10)
+
+ splitPoints = ogre.Vector4(0,0,0,0)
+ splitPointList = self.pssmSetup.getSplitPoints();
+ mat = ogre.MaterialManager.getSingleton().getByName("city")
+ splitPoints.y = splitPointList[1]
+ splitPoints.z = splitPointList[2]
+ mat.getTechnique(0).getPass(1).getFragmentProgramParameters().setNamedConstant("pssmSplitPoints", splitPoints)
+ self._createDebugShadowOverlays()
+
+ def _createDebugShadowOverlays(self):
+ baseWhite = ogre.MaterialManager.getSingletonPtr().getByName("BaseWhite")
+ DepthShadowTexture = baseWhite.clone("DepthShadowTexture0")
+ textureUnit = DepthShadowTexture.getTechnique(0).getPass(0).createTextureUnitState()
+ tex = self.sceneManager.getShadowTexture(0)
+ textureUnit.setTextureName(tex.getName())
+
+ DepthShadowTexture = baseWhite.clone("DepthShadowTexture1")
+ textureUnit = DepthShadowTexture.getTechnique(0).getPass(0).createTextureUnitState()
+ tex = self.sceneManager.getShadowTexture(1)
+ textureUnit.setTextureName(tex.getName())
+
+ DepthShadowTexture = baseWhite.clone("DepthShadowTexture2")
+ textureUnit = DepthShadowTexture.getTechnique(0).getPass(0).createTextureUnitState()
+ tex = self.sceneManager.getShadowTexture(2)
+ textureUnit.setTextureName(tex.getName())
+
+ overlayManager = ogre.OverlayManager.getSingleton()
+ # Create an overlay
+ self.mDebugOverlay = overlayManager.create("OverlayName")
+
+ # Create a panel
+ panel = overlayManager.createOverlayElement("Panel", "PanelName0")
+ panel.setMetricsMode(ogre.GMM_PIXELS)
+ panel.setPosition(10, 10)
+ panel.setDimensions(100, 100)
+ panel.setMaterialName("DepthShadowTexture0") # Optional background material
+ self.mDebugOverlay.add2D(panel)
+ panel = overlayManager.createOverlayElement("Panel", "PanelName1")
+ panel.setMetricsMode(ogre.GMM_PIXELS)
+ panel.setPosition(120, 10)
+ panel.setDimensions(100, 100)
+ panel.setMaterialName("DepthShadowTexture1") # Optional background material
+ self.mDebugOverlay.add2D(panel)
+ panel = overlayManager.createOverlayElement("Panel", "PanelName2")
+ panel.setMetricsMode(ogre.GMM_PIXELS)
+ panel.setPosition(230, 10)
+ panel.setDimensions(100, 100)
+ panel.setMaterialName("DepthShadowTexture2") # Optional background material
+ self.mDebugOverlay.add2D(panel)
+ self.mDebugOverlay.show()
+
+ def _createFrameListener(self):
+ self.frameListener = PSSMDemoFrameListener(self.renderWindow, self.camera, self.mSunLight)
+ self.root.addFrameListener(self.frameListener)
+
+
+
+if __name__ == '__main__':
+ import exceptions,sys
+ try:
+ application = ApplicationPSSM()
+ application.go()
+ except ogre.OgreException, e:
+ print e
+
+
+
Added: trunk/python-ogre/demos/PSSM_demo/resources.cfg
===================================================================
--- trunk/python-ogre/demos/PSSM_demo/resources.cfg (rev 0)
+++ trunk/python-ogre/demos/PSSM_demo/resources.cfg 2008-10-16 08:44:11 UTC (rev 759)
@@ -0,0 +1,5 @@
+[Bootstrap]
+Zip=../media/packs/OgreCore.zip
+
+[PSSMMedia]
+FileSystem=./Media
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|