Changeset 3144 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 11/19/08 17:37:11 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/normalMapping.cg
r3131 r3144 2 2 /* Shader for normal mapped geoemtry */ 3 3 /*******************************************/ 4 5 /**************************************************************/6 /* Shader computing the MRT output for normal mapped geoemtry */7 /**************************************************************/8 9 4 10 5 // input … … 13 8 float4 position: POSITION; 14 9 float4 normal: NORMAL; 15 float4 tangent: COLOR0;10 float4 color: COLOR0; 16 11 float4 texCoord: TEXCOORD0; 17 12 }; … … 24 19 float4 texCoord: TEXCOORD0; 25 20 26 float4 tangent: COLOR0;21 float4 tangent: TEXCOORD6; 27 22 // eye position 28 23 float4 eyePos: TEXCOORD1; … … 31 26 float4 worldPos: TEXCOORD3; 32 27 float4 oldWorldPos: TEXCOORD4; 33 float4 bitangent: TEXCOORD5 28 float4 bitangent: TEXCOORD5; 34 29 }; 35 30 … … 38 33 struct fragin 39 34 { 40 float4 tangent: COLOR0;35 float4 tangent: TEXCOORD6; 41 36 float4 texCoord: TEXCOORD0; 42 37 … … 47 42 float4 worldPos: TEXCOORD3; 48 43 float4 oldWorldPos: TEXCOORD4; 49 float4 bitangent: TEXCOORD5 44 float4 bitangent: TEXCOORD5; 50 45 }; 51 46 … … 69 64 vtxout OUT; 70 65 71 OUT. color= IN.color;66 OUT.tangent = IN.color; 72 67 OUT.texCoord = IN.texCoord; 73 68 … … 84 79 OUT.tangent = mul(glstate.matrix.invtrans.modelview[0], IN.color); 85 80 86 OUT.bitangent = cross(IN.tangent, IN.normal);81 OUT.bitangent = float4(cross(IN.color.xyz, IN.normal.xyz), 1); 87 82 88 83 return OUT; 89 84 } 85 86 87 88 /**************************************************************/ 89 /* Shader computing the MRT output for normal mapped geoemtry */ 90 /**************************************************************/ 90 91 91 92 … … 126 127 // as it is the inverse of a rotation matrix 127 128 float3x3 tangToWorldTrafo = transpose(float3x3(IN.tangent, IN.bitangent, IN.normal)); 128 const float3 tangentSpaceNorm = tex2Dlod(normalMap, float4(IN.texCoord.xy ).xyz);129 const float3 tangentSpaceNorm = tex2Dlod(normalMap, float4(IN.texCoord.xy, 0, 0)).xyz; 129 130 pix.normal = mul(tangToWorldTrafo, tangentSpaceNorm); 130 131 … … 133 134 134 135 135 pixel frag(fragin IN, uniform float4x4 viewMatrix) 136 pixel frag(fragin IN, 137 uniform float4x4 viewMatrix, 138 uniform sampler2D normalMap: TEXUNIT1) 136 139 { 137 140 pixel pix; 138 141 // hack: use comination of emmisive + diffuse (emmisive used as constant ambient term) 139 pix.col = glstate.material.diffuse + glstate.material.emission;142 pix.color = glstate.material.diffuse + glstate.material.emission; 140 143 // save world space normal in rt => transform back into world space by 141 144 // multiplying with inverse view. since transforming normal with T means to 142 145 // multiply with the inverse transpose of T, we multiple with Transp(Inv(Inv(view))) = Transp(view) 143 pix.norm = mul(transpose(viewMatrix), IN.normal).xyz;146 pix.normal = mul(transpose(viewMatrix), IN.normal).xyz; 144 147 // eye space depth 145 pix.col .w = length(IN.eyePos.xyz);148 pix.color.w = length(IN.eyePos.xyz); 146 149 // the scene entity id 147 150 //pix.id = glstate.fog.color.xyz; … … 149 152 pix.offsVec = IN.oldWorldPos.xyz - IN.worldPos.xyz; 150 153 151 pixel pix;152 154 // compute tanget space in world space => transform basis vectors back into world space by 153 155 // multiplying with inverse view. since transforming normal with T means to … … 160 162 // compute tangent space - world space transform which is the transpose, 161 163 // as it is the inverse of a rotation matrix 162 float3x3 tangToWorldTrafo = transpose(float3x3(IN.tangent , IN.bitangent, IN.normal));163 const float3 tangentSpaceNorm = tex2Dlod(normalMap, float4(IN.texCoord.xy ).xyz);164 float3x3 tangToWorldTrafo = transpose(float3x3(IN.tangent.xyz, IN.bitangent.xyz, IN.normal.xyz)); 165 const float3 tangentSpaceNorm = tex2Dlod(normalMap, float4(IN.texCoord.xy, 0, 0)).xyz; 164 166 pix.normal = mul(tangToWorldTrafo, tangentSpaceNorm); 165 167 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3142 r3144 1 1 #include "../shaderenv.h" 2 2 3 3 4 //////////////////// … … 5 6 // based on shader of Alexander Kusternig 6 7 8 7 9 #define USE_EYESPACE_DEPTH 1 8 9 10 10 11
Note: See TracChangeset
for help on using the changeset viewer.