Skip to content

Fix Specular Blinn function

Rafał Mikrut requested to merge github/fork/clayjohn/blinn-fix into master

Created by: clayjohn

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 uses pow(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 Screenshot (24)

This PR Blinn on left, GGX on right Screenshot (26)

Fixes: https://github.com/godotengine/godot/issues/33543

Merge request reports

Loading