- Timestamp:
- 11/20/08 10:12:28 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/normalMapping.cg
r3144 r3146 86 86 87 87 88 /************************************************************** /89 /* Shader computing the MRT output for normal mapped geoemtry*/90 /************************************************************** /88 /******************************************************************/ 89 /* Shader computing the MRT output for normal mapped geometry */ 90 /******************************************************************/ 91 91 92 92 … … 126 126 // compute tangent space - world space transform which is the transpose, 127 127 // as it is the inverse of a rotation matrix 128 float3x3 tangToWorldTrafo = transpose(float3x3(IN.tangent , IN.bitangent, IN.normal));128 float3x3 tangToWorldTrafo = transpose(float3x3(IN.tangent.xyz, IN.bitangent.xyz, IN.normal.xyz)); 129 129 const float3 tangentSpaceNorm = tex2Dlod(normalMap, float4(IN.texCoord.xy, 0, 0)).xyz; 130 130 pix.normal = mul(tangToWorldTrafo, tangentSpaceNorm); … … 136 136 pixel frag(fragin IN, 137 137 uniform float4x4 viewMatrix, 138 uniform sampler2D normalMap: TEXUNIT 1)138 uniform sampler2D normalMap: TEXUNIT0) 139 139 { 140 140 pixel pix; 141 141 // hack: use comination of emmisive + diffuse (emmisive used as constant ambient term) 142 142 pix.color = glstate.material.diffuse + glstate.material.emission; 143 // save world space normal in rt => transform back into world space by 144 // multiplying with inverse view. since transforming normal with T means to 145 // multiply with the inverse transpose of T, we multiple with Transp(Inv(Inv(view))) = Transp(view) 146 pix.normal = mul(transpose(viewMatrix), IN.normal).xyz; 143 147 144 // eye space depth 148 145 pix.color.w = length(IN.eyePos.xyz); … … 165 162 const float3 tangentSpaceNorm = tex2Dlod(normalMap, float4(IN.texCoord.xy, 0, 0)).xyz; 166 163 pix.normal = mul(tangToWorldTrafo, tangentSpaceNorm); 167 164 pix.normal = tangentSpaceNorm; 168 165 return pix; 169 166 }
Note: See TracChangeset
for help on using the changeset viewer.