- Timestamp:
- 10/09/08 11:48:06 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r3017 r3018 17 17 float4 worldPos: TEXCOORD1; // world position 18 18 float3 normal: TEXCOORD2; 19 float4 projPos: TEXCOORD3;20 19 }; 21 20 … … 31 30 float4 worldPos: TEXCOORD1; // world position 32 31 float3 normal: TEXCOORD2; 33 float4 projPos: TEXCOORD3;34 32 }; 35 33 … … 59 57 60 58 OUT.normal = IN.normal; 61 OUT.projPos = OUT.position;62 59 63 60 return OUT; … … 104 101 105 102 // compute eye linear depth 106 const float4 projPos = IN.projPos / IN.projPos.w; 107 108 float2 screenCoord = projPos.xy * 0.5f + 0.5f; 109 110 const float3 viewVec = Interpol(screenCoord, bl, br, tl, tr); 111 const float invMagView = 1.0f / length(viewVec); 112 // note: has to done in this order, otherwise strange precision problems! 113 pix.col.w = invMagView * length(eyePos - IN.worldPos.xyz); 103 pix.col.w = length(eyePos - IN.worldPos.xyz); 114 104 115 105 return pix; … … 133 123 // hack: squeeze some information about the ambient term into the target 134 124 //pix.col.w = glstate.material.emission.x; 135 136 // compute eye linear depth and scale with lenght to avoid sqr root in pixel shader 137 const float4 projPos = IN.projPos / IN.projPos.w; 138 139 float2 screenCoord = projPos.xy * 0.5f + 0.5f; 140 const float magView = length(Interpol(screenCoord, bl, br, tl, tr)); 141 pix.col.w = length(eyePos - IN.worldPos.xyz) / magView; 125 pix.col.w = length(eyePos - IN.worldPos.xyz); 142 126 143 127 return pix;
Note: See TracChangeset
for help on using the changeset viewer.