Changeset 3034 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 10/16/08 19:51:16 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r3026 r3034 175 175 const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord, 0, 0)).w; 176 176 177 float4 position; 178 position.xyz = eyePos - viewDir * eyeDepth; 179 177 const float4 worldPos = float4(eyePos - viewDir * eyeDepth, 1); 180 178 181 179 // diffuse intensity … … 193 191 ) 194 192 { 195 position.w = 1.0f; 196 197 float4 lightSpacePos = mul(shadowMatrix, position); 193 float4 lightSpacePos = mul(shadowMatrix, worldPos); 198 194 lightSpacePos /= lightSpacePos.w; 199 195 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg
r3026 r3034 179 179 const float3 eyeSpacePos = -viewDir * eyeDepth; 180 180 181 const float3 centerPosition = eyePos + eyeSpacePos; 182 const float4 realPos = float4(centerPosition, 1.0f); 181 const float4 worldPos = float4(eyePos + eyeSpacePos, 1.0f); 183 182 184 183 // calculcate the current projected depth for next frame 185 float4 currentPos = mul(modelViewProj, realPos); 184 float4 currentPos = mul(modelViewProj, worldPos); 185 186 186 const float w = SAMPLE_RADIUS / currentPos.w; 187 187 currentPos /= currentPos.w; 188 188 189 const float currentDepth = currentPos.z * 1e-3f; 189 190 … … 197 198 //-- compute temporally smoothing 198 199 199 200 200 // reprojection new frame into old one 201 201 // calculate projected depth 202 float4 projPos = mul(oldModelViewProj, realPos);202 float4 projPos = mul(oldModelViewProj, worldPos); 203 203 projPos /= projPos.w; 204 204 … … 210 210 211 211 // retrieve the sample from the last frame 212 float3 oldSsao = tex2D(oldSsaoTex, tex) ;213 float3 oldIllum = tex2D(oldIllumTex, tex) ;212 float3 oldSsao = tex2D(oldSsaoTex, tex).xyz; 213 float3 oldIllum = tex2D(oldIllumTex, tex).xyz; 214 214 215 215 const float oldDepth = oldSsao.z; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r3031 r3034 15 15 16 16 float4 color: COLOR0; 17 float4 worldPos: TEXCOORD1; // worldposition17 float4 eyePos: TEXCOORD1; // eye position 18 18 float3 normal: TEXCOORD2; 19 19 }; … … 24 24 { 25 25 float4 color: COLOR0; 26 float4 position: POSITION; // eye space26 //float4 position: POSITION; 27 27 float4 texCoord: TEXCOORD0; 28 28 29 29 float4 winPos: WPOS; 30 float4 worldPos: TEXCOORD1; // worldposition30 float4 eyePos: TEXCOORD1; // eye position 31 31 float3 normal: TEXCOORD2; 32 32 }; … … 40 40 }; 41 41 42 42 43 #pragma position_invariant vtx 43 44 44 vtxout vtx(vtxin IN, 45 uniform float4x4 modelView) 45 vtxout vtx(vtxin IN) 46 46 { 47 47 vtxout OUT; … … 50 50 OUT.texCoord = IN.texCoord; 51 51 52 //OUT.worldPos = mul(glstate.matrix.inverse.projection, OUT.position);53 OUT.worldPos = mul(modelView, IN.position);54 52 // transform the vertex position into eye space 53 OUT.eyePos = mul(glstate.matrix.modelview[0], IN.position); 54 // transform the vertex position into post projection space 55 55 OUT.position = mul(glstate.matrix.mvp, IN.position); 56 56 … … 60 60 } 61 61 62 63 // bilinear interpolation64 inline float3 Interpol(float2 w, float3 bl, float3 br, float3 tl, float3 tr)65 {66 float3 x1 = lerp(bl, tl, w.y);67 float3 x2 = lerp(br, tr, w.y);68 float3 v = lerp(x1, x2, w.x);69 70 return v;71 }72 73 62 //#pragma position_invariant fragtex 74 63 75 64 pixel fragtex(fragin IN, 76 uniform sampler2D tex, 77 uniform float3 eyePos, 78 uniform float3 bl, 79 uniform float3 br, 80 uniform float3 tl, 81 uniform float3 tr 65 uniform sampler2D tex 82 66 ) 83 67 { … … 99 83 100 84 // compute eye linear depth 101 pix.col.w = length( eyePos - IN.worldPos.xyz);85 pix.col.w = length(IN.eyePos.xyz); 102 86 103 87 return pix; … … 105 89 106 90 107 pixel frag(fragin IN, 108 uniform float3 eyePos, 109 uniform float3 bl, 110 uniform float3 br, 111 uniform float3 tl, 112 uniform float3 tr) 91 pixel frag(fragin IN) 113 92 { 114 93 pixel pix; … … 119 98 pix.norm = IN.normal; 120 99 100 pix.col.w = length(IN.eyePos.xyz); 101 121 102 // hack: squeeze some information about the ambient term into the target 122 103 //pix.col.w = glstate.material.emission.x; 123 pix.col.w = length(eyePos - IN.worldPos.xyz);124 104 125 105 return pix; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3028 r3034 159 159 const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord, 0, 0)).w; 160 160 const float3 eyeSpacePos = -viewDir * eyeDepth; 161 const float3 centerPosition = eyePos + eyeSpacePos; 162 163 const float4 realPos = float4(centerPosition, 1.0f); 161 const float4 worldPos = float4(eyePos + eyeSpacePos, 1.0f); 164 162 165 163 … … 167 165 //-- calculcate the current projected depth for next frame 168 166 169 float4 currentPos = mul(modelViewProj, realPos);167 float4 currentPos = mul(modelViewProj, worldPos); 170 168 171 169 const float w = SAMPLE_RADIUS / currentPos.w; … … 185 183 186 184 // calculate projected depth 187 float4 projPos = mul(oldModelViewProj, realPos);185 float4 projPos = mul(oldModelViewProj, worldPos); 188 186 projPos /= projPos.w; 189 187 190 188 // the current depth projected into the old frame 191 189 const float projDepth = projPos.z * precisionScale;
Note: See TracChangeset
for help on using the changeset viewer.