Skip to content
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 shader compilation if Oren-nayar render_mode is used #49418

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,21 @@ void light_compute(vec3 N, vec3 L, vec3 V, vec3 light_color, float attenuation,
diffuse_brdf_NL = lightScatter * viewScatter * energyFactor;
*/
}
#elif defined(DIFFUSE_OREN_NAYAR)

{
// see http://mimosa-pudica.net/improved-oren-nayar.html
float LdotV = dot(L, V);

float s = LdotV - NdotL * NdotV;
float t = mix(1.0, max(NdotL, NdotV), step(0.0, s));

float sigma2 = roughness * roughness; // TODO: this needs checking
vec3 A = 1.0 + sigma2 * (-0.5 / (sigma2 + 0.33) + 0.17 * diffuse_light / (sigma2 + 0.13));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed diffuse_color to diffuse_light since diffuse_color is removed in 4.0, maybe this should be a specular_light? cc @clayjohn

float B = 0.45 * sigma2 / (sigma2 + 0.09);

diffuse_brdf_NL = cNdotL * (A + vec3(B) * s / t) * (1.0 / M_PI);
}
#else
// lambert
diffuse_brdf_NL = cNdotL * (1.0 / M_PI);
Expand Down