-
Notifications
You must be signed in to change notification settings - Fork 407
Open
Description
While transpiling glsl shaders to wgsl tint throws this error and fails.
error: 'fwidth' must only be called from uniform control flow
The error is from use of derivatives in a loop that might not have a uniform flow.
I think the root cause might be mx_subsurface_bsdf where mx_subsurface_scattering_approx based on the closureType.
Here is the function:
vec3 mx_subsurface_scattering_approx(vec3 N, vec3 L, vec3 P, vec3 albedo, vec3 mfp)
{
float curvature = length(fwidth(N)) / length(fwidth(P));
float radius = 1.0 / max(curvature, 0.01);
return albedo * mx_integrate_burley_diffusion(N, L, radius, mfp) / vec3(M_PI);
}
and loop
for (int activeLightIndex = 0; activeLightIndex < numLights; ++activeLightIndex)
...
mx_subsurface_bsdf(mx_subsurface_bsdf(closureData, subsurface, coat_affected_subsurface_color_out, subsurface_radius_scaled_out, subsurface_anisotropy, normal, subsurface_bsdf_out);
BSDF selected_subsurface_bsdf_out = BSDF(vec3(0.0),vec3(1.0));
...
Probably a suitable workaround would be to split mx_subsurface_bsdf?
Metadata
Metadata
Assignees
Labels
No labels