Skip to content

Commit 7abbbdc

Browse files
Fix edge case in mx_sheen_bsdf (AcademySoftwareFoundation#2280)
This changelist fixes an edge case in the GLSL function `mx_sheen_bsdf`, where setting `closureData.closureType` to `CLOSURE_TYPE_TRANSMISSION` caused the `dirAlbedo` variable to be referenced without any assigned value.
1 parent a518876 commit 7abbbdc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

libraries/pbrlib/genglsl/mx_sheen_bsdf.glsl

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ void mx_sheen_bsdf(ClosureData closureData, float weight, vec3 color, float roug
1414
N = mx_forward_facing_normal(N, V);
1515
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
1616

17-
float dirAlbedo;
1817
if (closureData.closureType == CLOSURE_TYPE_REFLECTION)
1918
{
19+
float dirAlbedo;
2020
if (mode == 0)
2121
{
2222
vec3 H = normalize(L + V);
@@ -39,9 +39,11 @@ void mx_sheen_bsdf(ClosureData closureData, float weight, vec3 color, float roug
3939
dirAlbedo = mx_zeltner_sheen_dir_albedo(NdotV, roughness);
4040
bsdf.response = dirAlbedo * fr * closureData.occlusion * weight;
4141
}
42+
bsdf.throughput = vec3(1.0 - dirAlbedo * weight);
4243
}
4344
else if (closureData.closureType == CLOSURE_TYPE_INDIRECT)
4445
{
46+
float dirAlbedo;
4547
if (mode == 0)
4648
{
4749
dirAlbedo = mx_imageworks_sheen_dir_albedo(NdotV, roughness);
@@ -54,7 +56,6 @@ void mx_sheen_bsdf(ClosureData closureData, float weight, vec3 color, float roug
5456

5557
vec3 Li = mx_environment_irradiance(N);
5658
bsdf.response = Li * color * dirAlbedo * weight;
59+
bsdf.throughput = vec3(1.0 - dirAlbedo * weight);
5760
}
58-
59-
bsdf.throughput = vec3(1.0 - dirAlbedo * weight);
6061
}

0 commit comments

Comments
 (0)