- Timestamp:
- 10/19/08 23:42:15 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r3041 r3045 3 3 { 4 4 float4 position: POSITION; 5 float 3normal: NORMAL;5 float4 normal: NORMAL; 6 6 float4 color: COLOR0; 7 7 float4 texCoord: TEXCOORD0; … … 17 17 float4 color: COLOR0; 18 18 float4 eyePos: TEXCOORD1; // eye position 19 float 3normal: TEXCOORD2;19 float4 normal: TEXCOORD2; 20 20 }; 21 21 … … 30 30 float4 winPos: WPOS; 31 31 float4 eyePos: TEXCOORD1; // eye position 32 float 3normal: TEXCOORD2;32 float4 normal: TEXCOORD2; 33 33 }; 34 34 … … 56 56 OUT.position = mul(glstate.matrix.mvp, IN.position); 57 57 58 OUT.normal = IN.normal;58 OUT.normal = mul(glstate.matrix.invtrans.modelview[0], IN.normal); 59 59 60 60 return OUT; … … 63 63 64 64 pixel fragtex(fragin IN, 65 uniform sampler2D tex 65 uniform sampler2D tex, 66 uniform float4x4 viewMatrix 66 67 ) 67 68 { … … 76 77 // hack: use combination of emmisive + diffuse (emmisive used as constant ambient term) 77 78 pix.col = (glstate.material.emission + glstate.material.diffuse) * texColor; 78 // save world space normal in rt 79 pix.norm = IN.normal; 79 // save world space normal in rt => transform back into world space by 80 // multiplying with inverse view. since transforming normal with T means to 81 // multiply with the inverse transpose of T, we multiple with Transp(Inv(Inv(view))) = Transp(view) 82 pix.norm = mul(transpose(viewMatrix), IN.normal); 80 83 // compute eye linear depth 81 84 pix.col.w = length(IN.eyePos.xyz); … … 87 90 88 91 89 pixel frag(fragin IN )92 pixel frag(fragin IN, uniform float4x4 viewMatrix) 90 93 { 91 94 pixel pix; 92 95 // hack: use comination of emmisive + diffuse (emmisive used as constant ambient term) 93 96 pix.col = glstate.material.diffuse + glstate.material.emission; 94 // save world space normal in rt 95 pix.norm = IN.normal; 97 // save world space normal in rt => transform back into world space by 98 // multiplying with inverse view. since transforming normal with T means to 99 // multiply with the inverse transpose of T, we multiple with Transp(Inv(Inv(view))) = Transp(view) 100 pix.norm = mul(transpose(viewMatrix), IN.normal); 96 101 // eye space depth 97 102 pix.col.w = length(IN.eyePos.xyz);
Note: See TracChangeset
for help on using the changeset viewer.