EEVEE: Fix undefined behavior when using BSDF nodes inside volume shaders

This should fix T76171 Eevee bsdf shaders glitches
This commit is contained in:
Clément Foucault 2020-06-30 01:32:00 +02:00
parent f28e59bd74
commit 062a843bfb
Notes: blender-bot 2023-02-14 03:34:17 +01:00
Referenced by issue #77348, Blender LTS: Maintenance Task 2.83
Referenced by issue #76171, Eevee bsdf shaders glitches
14 changed files with 24 additions and 19 deletions

View File

@ -9,5 +9,5 @@ void node_ambient_occlusion(
}
#else
/* Stub ambient occlusion because it is not compatible with volumetrics. */
# define node_ambient_occlusion
# define node_ambient_occlusion(a, b, c, d, e) (e = CLOSURE_DEFAULT)
#endif

View File

@ -11,5 +11,5 @@ void node_bsdf_anisotropic(vec4 color,
}
#else
/* Stub anisotropic because it is not compatible with volumetrics. */
# define node_bsdf_anisotropic
# define node_bsdf_anisotropic(a, b, c, d, e, f, g) (g = CLOSURE_DEFAULT)
#endif

View File

@ -9,5 +9,5 @@ void node_bsdf_diffuse(vec4 color, float roughness, vec3 N, out Closure result)
}
#else
/* Stub diffuse because it is not compatible with volumetrics. */
# define node_bsdf_diffuse
# define node_bsdf_diffuse(a, b, c, d) (d = CLOSURE_DEFAULT)
#endif

View File

@ -40,4 +40,7 @@ void node_eevee_specular(vec4 diffuse,
closure_load_ssr_data(ssr_spec * alpha, roughness, normal, viewCameraVec, int(ssr_id), result);
}
#else
/* Stub specular because it is not compatible with volumetrics. */
# define node_eevee_specular(a, b, c, d, e, f, g, h, i, j, k, result) (result = CLOSURE_DEFAULT)
#endif

View File

@ -28,5 +28,5 @@ void node_bsdf_glass(
}
#else
/* Stub glass because it is not compatible with volumetrics. */
# define node_bsdf_glass
# define node_bsdf_glass(a, b, c, d, e, f) (f = CLOSURE_DEFAULT)
#endif

View File

@ -12,5 +12,5 @@ void node_bsdf_glossy(vec4 color, float roughness, vec3 N, float ssr_id, out Clo
}
#else
/* Stub glossy because it is not compatible with volumetrics. */
# define node_bsdf_glossy
# define node_bsdf_glossy(a, b, c, d, e) (e = CLOSURE_DEFAULT)
#endif

View File

@ -442,11 +442,13 @@ void node_bsdf_principled_glass(vec4 base_color,
result.transmittance = vec3(1.0 - alpha);
}
#else
/* clang-format off */
/* Stub principled because it is not compatible with volumetrics. */
# define node_bsdf_principled
# define node_bsdf_principled_dielectric
# define node_bsdf_principled_metallic
# define node_bsdf_principled_clearcoat
# define node_bsdf_principled_subsurface
# define node_bsdf_principled_glass
# define node_bsdf_principled(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, result) (result = CLOSURE_DEFAULT)
# define node_bsdf_principled_dielectric(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, result) (result = CLOSURE_DEFAULT)
# define node_bsdf_principled_metallic(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, result) (result = CLOSURE_DEFAULT)
# define node_bsdf_principled_clearcoat(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, result) (result = CLOSURE_DEFAULT)
# define node_bsdf_principled_subsurface(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, result) (result = CLOSURE_DEFAULT)
# define node_bsdf_principled_glass(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, result) (result = CLOSURE_DEFAULT)
/* clang-format on */
#endif

View File

@ -12,5 +12,5 @@ void node_bsdf_refraction(vec4 color, float roughness, float ior, vec3 N, out Cl
}
#else
/* Stub refraction because it is not compatible with volumetrics. */
# define node_bsdf_refraction
# define node_bsdf_refraction(a, b, c, d, e) (e = CLOSURE_DEFAULT)
#endif

View File

@ -24,5 +24,5 @@ void node_subsurface_scattering(vec4 color,
}
#else
/* Stub subsurface scattering because it is not compatible with volumetrics. */
# define node_subsurface_scattering
# define node_subsurface_scattering(a, b, c, d, e, f, g, h) (h = CLOSURE_DEFAULT)
#endif

View File

@ -5,5 +5,5 @@ void node_bsdf_toon(vec4 color, float size, float tsmooth, vec3 N, out Closure r
}
#else
/* Stub toon because it is not compatible with volumetrics. */
# define node_bsdf_toon
# define node_bsdf_toon(a, b, c, d, e) (e = CLOSURE_DEFAULT)
#endif

View File

@ -9,5 +9,5 @@ void node_bsdf_translucent(vec4 color, vec3 N, out Closure result)
}
#else
/* Stub translucent because it is not compatible with volumetrics. */
# define node_bsdf_translucent
# define node_bsdf_translucent(a, b, c) (c = CLOSURE_DEFAULT)
#endif

View File

@ -7,5 +7,5 @@ void node_bsdf_transparent(vec4 color, out Closure result)
}
#else
/* Stub transparent because it is not compatible with volumetrics. */
# define node_bsdf_transparent
# define node_bsdf_transparent(a, b) (b = CLOSURE_DEFAULT)
#endif

View File

@ -5,5 +5,5 @@ void node_bsdf_velvet(vec4 color, float sigma, vec3 N, out Closure result)
}
#else
/* Stub velvet because it is not compatible with volumetrics. */
# define node_bsdf_velvet
# define node_bsdf_velvet(a, b, c, d) (d = CLOSURE_DEFAULT)
#endif

View File

@ -26,6 +26,6 @@ void node_wireframe_screenspace(float size, vec2 barycentric, out float fac)
}
#else
/* Stub wireframe because it is not compatible with volumetrics. */
# define node_wireframe
# define node_wireframe_screenspace
# define node_wireframe(a, b, c, d) (d = 0.0)
# define node_wireframe_screenspace(a, b, c) (c = 0.0)
#endif