-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Specular Blinn function #33836
Fix Specular Blinn function #33836
Conversation
@@ -1547,157 +1545,157 @@ FRAGMENT_SHADER_CODE | |||
#endif // !USE_SHADOW_TO_OPACITY | |||
|
|||
#ifdef BASE_PASS | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't you add this extra scope a few commits ago in another PR? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but it made the code messier, and it is unnecessary now that I removed the environment scaling from the vertex_lighting code path
Seems like it was added by @reduz in 65fd37c. From a quick look at this commit it looks like he also added it for Phong, might be worth reviewing that too. BTW, I did a very quick test scenes, probably not with the best environment to see specular effects, but it seems that Specular Mode |
Yea, the Phong lighting definitely appears strange, but it is not as obviously incorrect as the blinn is. As for the specular modes, I fixed that in #33694, it just needs to be merged. :) The important part for that bug is the change to material.h. I could remove that part from the PR and make another one. |
Seems good, please do a similar PR for the Vulkan brach |
Thanks! |
I noticed an issue with the Specular Blinn code path while working on a fix to the vertex-lit code path. Previously our normalized blinn function was divided by
4.0 * cNdotV * cNdotL
. I am not sure why that term was included. It causes a weird circular artifact to appear, and it causes the specular lobe to slide around the entire mesh. None of the normalized-blinn NDFs and RDFs I could find used that term (not even Ogre3D's). However, I found that one of the current popular RDFs the modified-Blinn usespow(cNdotH, shininess) * cNdotL;
.Using this change and removing the above scaling factor results in a much nicer Blinn Specular. The specular lobe looks a lot like the SCHLICK_GGX, only it is a little smaller on smooth materials and a little brighter on rough materials.
Because vertex-lit materials are forced to use Blinn Specular, it is especially important that it look nice.
This also resolves another bug I found where IBL was being scaled too dark on vertex-lit materials.
MASTER
Blinn on left, GGX on right
This PR
Blinn on left, GGX on right
Fixes: #33543