- Timestamp:
- 10/09/08 11:19:33 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r3016 r3017 17 17 float4 worldPos: TEXCOORD1; // world position 18 18 float3 normal: TEXCOORD2; 19 float4 mypos: TEXCOORD3;19 float4 projPos: TEXCOORD3; 20 20 }; 21 21 … … 28 28 float4 texCoord: TEXCOORD0; 29 29 30 float4 projPos: WPOS;30 float4 winPos: WPOS; 31 31 float4 worldPos: TEXCOORD1; // world position 32 32 float3 normal: TEXCOORD2; 33 float4 mypos: TEXCOORD3;33 float4 projPos: TEXCOORD3; 34 34 }; 35 35 … … 38 38 { 39 39 float4 col: COLOR0; 40 float 4norm: COLOR1;40 float3 norm: COLOR1; 41 41 float3 pos: COLOR2; 42 42 }; … … 59 59 60 60 OUT.normal = IN.normal; 61 OUT. mypos = OUT.position;61 OUT.projPos = OUT.position; 62 62 63 63 return OUT; … … 75 75 } 76 76 77 //#pragma position_invariant fragtex 77 78 78 79 pixel fragtex(fragin IN, … … 96 97 // hack: use combination of emmisive + diffuse (emmisive used as constant ambient term) 97 98 pix.col = (glstate.material.emission + glstate.material.diffuse) * texColor; 98 // save world space normal in third rt 99 pix.norm.xyz = IN.normal; 100 // store projection coordinates with positions (used for ssao) 101 pix.norm.w = IN.projPos.w; 99 // save world space normal in rt 100 pix.norm = IN.normal; 102 101 103 const float4 projPos = IN.mypos / IN.mypos.w;104 105 102 // hack: squeeze some information about ambient into the texture 106 103 //pix.col.w = glstate.material.emission.x; 107 104 108 105 // compute eye linear depth 109 const float 2 screenCoord = projPos.xy * 0.5f + 0.5f;110 const float magView = length(Interpol(screenCoord, bl, br, tl, tr));111 pix.col.w = length(eyePos - IN.worldPos.xyz) / magView;112 113 #if 0 114 // save world position in second render target115 pix.pos = IN.worldPos.xyz * maxDepth;116 #endif 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); 117 114 118 115 return pix; … … 132 129 pix.col = glstate.material.diffuse + glstate.material.emission; 133 130 134 pix.norm.xyz = IN.normal; 135 136 // store projection coordinates with positions (used for ssao) 137 pix.norm.w = IN.mypos.w; 138 139 const float4 projPos = IN.mypos / IN.mypos.w; 131 pix.norm = IN.normal; 140 132 141 133 // hack: squeeze some information about the ambient term into the target … … 143 135 144 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 145 139 float2 screenCoord = projPos.xy * 0.5f + 0.5f; 146 140 const float magView = length(Interpol(screenCoord, bl, br, tl, tr)); 147 pix.col.w = length(eyePos - IN.worldPos.xyz) / magView; 148 149 #if 0 150 pix.pos = IN.worldPos.xyz * maxDepth; 151 #endif 141 pix.col.w = length(eyePos - IN.worldPos.xyz) / magView; 152 142 153 143 return pix;
Note: See TracChangeset
for help on using the changeset viewer.