Changeset 2818 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 07/07/08 10:52:03 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Files:
-
- 4 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2817 r2818 60 60 uniform sampler2D positions, 61 61 uniform sampler2D normals, 62 const uniform float4x4 ProjTrafo,63 62 uniform sampler2D noiseTexture 64 63 ) 65 64 { 66 65 // the current world position 67 float4 centerPositionW = tex2D(positions, IN.texCoord.xy); 68 float3 centerPosition = centerPositionW.xyz; 66 float4 centerPosition = tex2D(positions, IN.texCoord.xy); 67 // the w coordinate from the persp. projection 68 float w = centerPosition.w; 69 69 70 70 // the normal on the current position … … 87 87 //sample noisetex; r stores costheta, g stores sintheta 88 88 float3 noise = tex2D(noiseTexture, IN.texCoord.xy).xyz * 2.0f - 1.0f; 89 90 //float2 offsetTransformed = offset;//reflect(offset, noise.xy); 89 90 // rotation 91 //float2 offsetTransformed = offset; 91 92 float2 offsetTransformed; 92 93 offsetTransformed.x = noise.r * offset.x - noise.g * offset.y; … … 94 95 95 96 // weight with projected coordinate to reach similar kernel size for near and far 96 float2 texcoord = IN.texCoord.xy + offsetTransformed * areaSize * centerPositionW.w;97 float2 texcoord = IN.texCoord.xy + offsetTransformed * areaSize * w; 97 98 98 99 float3 sample_position = tex2D(positions, texcoord).xyz; 99 100 100 float3 vector_to_sample = sample_position - centerPosition ;101 float3 vector_to_sample = sample_position - centerPosition.xyz; 101 102 float length_to_sample = length(vector_to_sample); 102 103 float3 direction_to_sample = vector_to_sample / (length_to_sample + 1e-9f); … … 125 126 uniform sampler2D positions, 126 127 uniform sampler2D normals, 127 const uniform float4x4 ProjTrafo,128 128 uniform sampler2D noiseTexture) 129 129 { … … 137 137 138 138 // expand normal 139 normal = normal * 2.0f - 1.0f;139 normal = normalize(normal * 2.0f - 1.0f); 140 140 141 141 float4 position = tex2D(positions, IN.texCoord.xy); … … 146 146 float3 light = normalize(lightDir.xyz); 147 147 float3 light2 = normalize(lightDir2.xyz); 148 148 149 149 float diffuseLight = max(dot(normal, light), 0.0f); 150 150 float diffuseLight2 = max(dot(normal, light2), 0.0f); … … 152 152 float diffuse = diffuseLight + diffuseLight2; 153 153 154 float ao = ssao(IN, positions, normals, ProjTrafo,noiseTexture);154 float ao = ssao(IN, positions, normals, noiseTexture); 155 155 //OUT.color = ao; 156 156 OUT.color = ao * (ambient + diffuse) * color; 157 //OUT.color = (ambient + diffuse) * color; 158 159 //float4 currentPos = tex2D(normals, IN.texCoord.xy) * 0.5f + 0.5f; 160 //float4 currentPos = tex2D(normals, IN.texCoord.xy); 161 //OUT.color = currentPos; 157 //OUT.color = (ambient + diffuse) * color; 162 158 163 159 return OUT; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r2813 r2818 41 41 42 42 43 vtxout vtx(vtxin IN, uniform float4x4 ModelViewProj) 43 vtxout vtx(vtxin IN, 44 const uniform float4x4 ModelViewProj, 45 uniform float4x4 ModelMatrix) 44 46 { 45 47 vtxout OUT; 46 48 47 49 // transform the vertex position into eye space 48 OUT.position = mul(ModelViewProj, IN.position);49 50 50 OUT.color = IN.color; 51 51 52 52 OUT.texCoord = IN.texCoord; 53 OUT.worldPos = mul(ModelMatrix, IN.position); 54 55 // transform the vertex position into eye space 56 OUT.position = mul(ModelViewProj, OUT.worldPos); 57 53 58 OUT.worldPos = IN.position; 54 // eye pos with linear depth 55 //OUT.worldPos = OUT.position; 59 56 60 OUT.normal = IN.normal; 57 61 … … 66 70 pix.col = tex2D(tex, IN.texCoord.xy); 67 71 pix.pos = IN.worldPos * maxDepth; 72 pix.norm = IN.normal; 68 73 pix.pos.w = IN.projPos.w; 69 pix.norm = IN.normal;70 74 71 75 return pix;
Note: See TracChangeset
for help on using the changeset viewer.