Jump to content

  • Log In with Google      Sign In   
  • Create Account


Transformed by ViewProjection or not?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 lucky6969b   Members   -  Reputation: 528

Like
0Likes
Like

Posted 22 September 2012 - 10:14 PM

Extract of vertex Shader
// 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);

Pixel Shader
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

Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS