Jump to content
  • Advertisement
Sign in to follow this  
dai_zeng

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.

If you intended to correct an error in the post then please contact us.

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);

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!