# Transformed by ViewProjection or not?

This topic is 2244 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

 // Transform normal to world space. o.normalW = mul(Normal,gWorldInvTrans).xyz; // Transform and calculate eye pos float3 posW = mul(Pos,gWorld).xyz; o.toEyeW = gEyePosW - posW; // transform position from world space into view and then projection space o.Pos = mul(float4(Pos.xyz, 1.0f), mViewProj); 

 float4 VBlend2PS(float3 normalW : TEXCOORD0, float3 toEyeW : TEXCOORD1, float2 tex0 : TEXCOORD2) : COLOR { // Interpolated normals can become unnormal--so normalize. normalW = normalize(normalW); toEyeW = normalize(toEyeW); // Light vector is opposite the direction of the light. float3 lightVecW = lhtDir; // Compute the reflection vector. float3 r = reflect(-lightVecW, normalW); // Determine how much (if any) specular light makes it into the eye. float t = pow(max(dot(r, toEyeW), 0.0f), SpecPower); // Determine the diffuse light intensity that strikes the vertex. float s = max(dot(lightVecW, normalW), 0.0f); // Compute the ambient, diffuse and specular terms separatly. float3 spec = t*(MaterialSpec*lightSpec).rgb; float3 diffuse = s*(MaterialDiffuse*lightDiffuse).rgb; float3 ambient = MaterialAmbient*lightAmbient; // Get the texture color. float4 texColor = tex2D(TexS, tex0); // Combine the color from lighting with the texture color. //float3 color = (ambient + diffuse)*texColor.rgb + spec; float3 color = (ambient + diffuse).rgb + spec; // Sum all the terms together and copy over the diffuse alpha. //return float4(color, gMtrl.diffuse.a*texColor.a); return float4(color, MaterialDiffuse.a); } 

See that o.toEyeW, do I also transform it by the ViewProj transformation?
Thanks
Jack

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633312
• Total Posts
3011312
• ### Who's Online (See full list)

There are no registered users currently online

×