Sign in to follow this  

save me!the specular item of my vertex shader

This topic is 3635 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

This topic is 3635 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this