- Timestamp:
- 10/16/08 19:51:16 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note: See TracChangeset
for help on using the changeset viewer.