# save me!the specular item of my vertex shader

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

## Recommended Posts

the code below didn't use halfway vector,instead compute the phong item directly using the this formula:2*(N.L)-L;BUT it didn't works ,i don't know y!I guess when multiplying these matrix and vector, some singularity condition or precision problem appears.when i rotate the viewpoint to the shadow back of the object(light is fixed),it should be supposed to be black,but it didn't ,instead,the whole object is lighten to be bright!Can anyone find out what the problem is and a solution? below is the shader code(part of it that cause problem) //compute the Reflect vector,here s is the diffuse item,i swear it's right vector Reflect = ((2*s*10*innorm) - 10*LightDirection) ; //transform the reflect to view space Reflect.w = 0.0f; Reflect = mul(Reflect ,View ); Reflect.w = 0.0f; Reflect = normalize(Reflect ); //here is the viewpoint,it's fixed in view space vector ViewPos = {0.0f, 0.0f, -10.0f, 0.0f}; //inpos is the input.position,the postion vector of vertex //it should be trans to view space too vector posinview =mul(inpos , World); posinview =mul(posinview , View); //so the view direction is gotten vector ViewDir = ViewPos - posinview ; ViewDir.w = 0.0f; ViewDir = normalize( ViewDir); //finally we get the phong item,(R.V)^8 vector specular =pow(saturate(dot( ViewDir,Reflect)), 8);

1. 1
Rutin
38
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 104
• 11
• ### Forum Statistics

• Total Topics
632977
• Total Posts
3009676
• ### Who's Online (See full list)

There are no registered users currently online

×