Changeset 2373 for GTP/trunk/App/Demos/Illum/Ogre
- Timestamp:
- 05/14/07 11:03:30 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre
- Files:
-
- 5 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/MoriaHallBase.hlsl
r2368 r2373 26 26 uniform float3 wCamPos; 27 27 28 uniform float4x4 LightView[MAX_LIGHT]; 29 uniform float lightFarPlane[MAX_LIGHT]; 28 uniform float4 wLightPos1; 29 uniform float4 wLightPos2; 30 uniform float4 lightRange1; 31 uniform float4 lightRange2; 32 uniform float lightPower1; 33 uniform float lightPower2; 34 uniform float4 lightColor1; 35 uniform float4 lightColor2; 36 37 uniform float4x4 LightView1; 38 uniform float4x4 LightView2; 39 uniform float lightFarPlane1; 40 uniform float lightFarPlane2; 30 41 31 42 uniform float specularity; … … 36 47 float4 hPos : POSITION; 37 48 float4 texCoord : TEXCOORD0; 38 float 2 bumpTexCoord: TEXCOORD1;49 float4 texCoord2 : TEXCOORD1; 39 50 float3 wView : TEXCOORD2; 40 51 float3 wTangent : TEXCOORD3; … … 48 59 float2 texCoord1 : TEXCOORD0, 49 60 float2 texCoord2 : TEXCOORD1, 61 float2 atlasTex : TEXCOORD2, 50 62 float3 tangent : TEXCOORD3, 51 63 uniform float normalCoord) … … 55 67 OUT.texCoord = float4(texCoord1.xy, texCoord2.xy); 56 68 if(normalCoord == 0) 57 OUT. bumpTexCoord= texCoord1;69 OUT.texCoord2.xy = texCoord1; 58 70 else 59 OUT.bumpTexCoord = texCoord2; 71 OUT.texCoord2.xy = texCoord2; 72 73 OUT.texCoord2.zw = atlasTex; 60 74 61 75 OUT.hPos = mul(WorldViewProj, position); … … 71 85 } 72 86 73 float4 MoriaHallBase_PS(MORIA_HALL_BASE_VSOUT IN, 74 uniform float4 wLightPos, 75 uniform float4 lightRange, 76 uniform float lightPower, 77 uniform float4 lightColor):COLOR0 87 float4 MoriaHallBase_PS(MORIA_HALL_BASE_VSOUT IN):COLOR0 78 88 { 79 89 float4 Color = 0; 80 float3 N = NormalMap(IN.wTangent, IN.wBinormal, IN.wNormal, IN. bumpTexCoord, bumpMap);90 float3 N = NormalMap(IN.wTangent, IN.wBinormal, IN.wNormal, IN.texCoord2.xy, bumpMap); 81 91 float3 V = normalize(IN.wView); 82 92 // read textures 83 93 float4 diffuseColor = tex2D(tileTexture, IN.texCoord.zw) * tex2D(detailTexture, IN.texCoord.xy); 84 94 95 //---------------------------------------------------------------------------------------------------------------- 96 //light1 85 97 //light dir 86 float3 L = wLightPos .xyz - IN.wPos * wLightPos.w;98 float3 L = wLightPos1.xyz - IN.wPos * wLightPos1.w; 87 99 //illumination 88 100 float4 col; 89 col = Illumination(N, L, V, lightColor * lightPower, lightRange, diffuseColor, specularity); 90 //shadowing 91 float3 lightCPos = mul(LightView[0], float4(IN.wPos, 1)).xyz; 92 float shadow = shadowPoint(ShadowMap1Point, lightCPos, lightFarPlane[0]); 101 col = Illumination(N, L, V, lightColor1 * lightPower1, lightRange1, diffuseColor, specularity); 102 //shadowing 103 float3 lightCPos = mul(LightView1, float4(IN.wPos, 1)).xyz; 104 float shadow = shadowPoint(ShadowMap1Point, lightCPos, lightFarPlane1); 105 Color += col * shadow; 106 107 //---------------------------------------------------------------------------------------------------------------- 108 //light2 109 //light dir 110 L = wLightPos2.xyz - IN.wPos * wLightPos2.w; 111 //illumination 112 col = Illumination(N, L, V, lightColor2 * lightPower2, lightRange2, diffuseColor, specularity); 113 //shadowing 114 lightCPos = mul(LightView2, float4(IN.wPos, 1)).xyz; 115 shadow = shadowPoint(ShadowMap2Point, lightCPos, lightFarPlane2); 93 116 Color += col * shadow; 94 117 95 118 //do Path Map to gather indirect illumination 119 120 float4 indirect = PathMapIndirect(PathMap, WeightIndexMap, WeightMap, IN.texCoord2.zw) * 1.2; 121 indirect *= diffuseColor; 122 Color = Color + indirect; 123 96 124 //gather caustics for all casters 97 125 //return diffuseColor; -
GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/illum.hlsl
r2368 r2373 53 53 return (SHADOW_COLOR + (1 - SHADOW_COLOR) * light); 54 54 } 55 56 uniform float4 prmAtlasTilesHalfPixel; 57 uniform float allClusterCount; 58 uniform float clusterCount; 59 60 float4 PathMapIndirect(sampler2D PMTex, sampler2D weightIndexTex, sampler2D weightTex, float2 texAtlas) 61 { 62 int2 prmAtlasTiles = prmAtlasTilesHalfPixel.xy; 63 float2 atlasHalfPixel = prmAtlasTilesHalfPixel.zw; 64 65 float3 col = 0; 66 for(int iCluster = 0; iCluster < 32; iCluster++) 67 { 68 float2 prmTexPos = float2( 69 (texAtlas.x + (iCluster % prmAtlasTiles.x)) / prmAtlasTiles.x, 70 1.0 - (texAtlas.y + (iCluster / prmAtlasTiles.x)) / prmAtlasTiles.y);// + atlasHalfPixel; 71 72 float weightIndex = tex2D(weightIndexTex, float2(((float)iCluster + 0.5) / clusterCount, 0.5)).r; 73 float3 weight = tex2D(weightTex, float2((weightIndex + 0.5)/allClusterCount, 0.5)).rgb; 74 float3 val = tex2D(PMTex, prmTexPos).xyz; 75 if(length(val - float3(1,1,1))== 0) 76 val = 0; 77 col += val.xyz * weight; 78 } 79 80 return float4(col,1); 81 } -
GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/moria.material
r2368 r2373 21 21 IllumTechniques 22 22 { 23 //RenderTechnique PathMap24 //{25 //new_passes false26 //start_tex_id 327 //}23 RenderTechnique PathMap 24 { 25 new_passes false 26 start_tex_id 3 27 } 28 28 RenderTechnique DepthShadowReceiver 29 29 { 30 max_light_count 130 max_light_count 2 31 31 set_light_viewproj false 32 32 set_light_view true … … 48 48 fragment_program_ref GTP/MoriaDemo/MoriaHallBase_PS 49 49 { 50 param_named_auto wLightPos light_position 051 //param_named_auto wLightPoslight_position 152 param_named_auto lightRange light_attenuation 053 //param_named_auto lightRange[1]light_attenuation 154 param_named_auto lightPower light_power 055 //param_named_auto lightPower[1]light_power 156 param_named_auto lightColor light_diffuse_colour 057 //param_named_auto lightColor[1]light_diffuse_colour 150 param_named_auto wLightPos1 light_position 0 51 param_named_auto wLightPos2 light_position 1 52 param_named_auto lightRange1 light_attenuation 0 53 param_named_auto lightRange2 light_attenuation 1 54 param_named_auto lightPower1 light_power 0 55 param_named_auto lightPower2 light_power 1 56 param_named_auto lightColor1 light_diffuse_colour 0 57 param_named_auto lightColor2 light_diffuse_colour 1 58 58 param_named specularity float 120 59 59 } -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Blur.hlsl
r2368 r2373 24 24 uniform float height ) : COLOR 25 25 { 26 26 /* 27 27 float2 pixel = float2(1.0 / width, 1.0 / height); 28 28 float2 uv = IN.Position + pixel * 0.5; … … 35 35 36 36 sum /= samplesU * samplesV; 37 38 return sum; 39 return tex2D(Texture, uv); 37 */ 38 float du = 2.0 / width; 39 float dv = 2.0 / height; 40 float2 uv = IN.Position; 41 float4 sum = float4(0,0,0,0); 42 sum += tex2D(Texture,uv); 43 sum += tex2D(Texture,uv + float2(du,0)); 44 sum += tex2D(Texture,uv + float2(du,dv)); 45 sum += tex2D(Texture,uv + float2(0,dv)); 46 return sum / 4.0; 40 47 } 41 48 -
GTP/trunk/App/Demos/Illum/Ogre/src/Moria/include/Moria.h
r2367 r2373 182 182 mainLightNode = rootNode->createChildSceneNode(); 183 183 184 mainLightNode->setPosition(15, 10,15);184 mainLightNode->setPosition(15,5,15); 185 185 mainLight->setPowerScale(30); 186 186 //mainLight->setDirection(1,0, 0); … … 189 189 mainLight->setAttenuation(40.0, 0, 4, 0); 190 190 191 Light* blueLight = mSceneMgr->createLight("blueLight"); 192 blueLight->setType(Light::LT_POINT); 193 blueLight->setCastShadows(true); 194 blueLight->setDiffuseColour(ColourValue(0.45,0.75,0.8)); 195 blueLight->setPowerScale(30); 196 blueLight->setAttenuation(40.0, 0, 4, 0); 197 SceneNode* blueLightNode = rootNode->createChildSceneNode(); 198 blueLightNode->setPosition(15,10,15); 199 blueLightNode->attachObject(blueLight); 200 191 201 Vector4 v = mainLight->getAs4DVector(); 192 202 … … 240 250 mRoot->addFrameListener(mFrameListener); 241 251 OgreIlluminationManager::getSingleton().setPriority(3); 242 252 mRoot->addFrameListener(&OgreIlluminationManager::getSingleton()); 243 253 } 244 254
Note: See TracChangeset
for help on using the changeset viewer.