GPU: Sanitize closure nodes inputs #115059
|
@ -16,8 +16,16 @@ void node_eevee_specular(vec4 diffuse,
|
|||
const float use_clearcoat,
|
||||
out Closure result)
|
||||
{
|
||||
diffuse = max(diffuse, vec4(0));
|
||||
specular = max(specular, vec4(0));
|
||||
roughness = saturate(roughness);
|
||||
emissive = max(emissive, vec4(0));
|
||||
N = safe_normalize(N);
|
||||
clearcoat = saturate(clearcoat);
|
||||
clearcoat_roughness = saturate(clearcoat_roughness);
|
||||
CN = safe_normalize(CN);
|
||||
occlusion = saturate(occlusion);
|
||||
|
||||
vec3 V = coordinate_incoming(g_data.P);
|
||||
|
||||
ClosureEmission emission_data;
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
void node_emission(vec4 color, float strength, float weight, out Closure result)
|
||||
{
|
||||
color = max(color, vec4(0));
|
||||
strength = max(strength, 0);
|
||||
|
||||
ClosureEmission emission_data;
|
||||
emission_data.weight = weight;
|
||||
emission_data.emission = color.rgb * strength;
|
||||
|
|
|
@ -10,7 +10,11 @@ void node_bsdf_glass(vec4 color,
|
|||
const float do_multiscatter,
|
||||
out Closure result)
|
||||
{
|
||||
color = max(color, vec4(0));
|
||||
roughness = saturate(roughness);
|
||||
ior = max(ior, 1e-5);
|
||||
N = safe_normalize(N);
|
||||
|
||||
vec3 V = coordinate_incoming(g_data.P);
|
||||
float NV = dot(N, V);
|
||||
|
||||
|
|
|
@ -12,7 +12,10 @@ void node_bsdf_glossy(vec4 color,
|
|||
const float do_multiscatter,
|
||||
out Closure result)
|
||||
{
|
||||
color = max(color, vec4(0));
|
||||
roughness = saturate(roughness);
|
||||
N = safe_normalize(N);
|
||||
|
||||
vec3 V = coordinate_incoming(g_data.P);
|
||||
float NV = dot(N, V);
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ void node_bsdf_hair(vec4 color,
|
|||
float weight,
|
||||
out Closure result)
|
||||
{
|
||||
color = max(color, vec4(0));
|
||||
|
||||
#if 0
|
||||
/* NOTE(fclem): This is the way it should be. But we don't have proper implementation of the hair
|
||||
* closure yet. For now fall back to a simpler diffuse surface so that we have at least a color
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
void node_bsdf_refraction(
|
||||
vec4 color, float roughness, float ior, vec3 N, float weight, out Closure result)
|
||||
{
|
||||
color = max(color, vec4(0));
|
||||
roughness = saturate(roughness);
|
||||
ior = max(ior, 1e-5);
|
||||
N = safe_normalize(N);
|
||||
|
||||
ClosureRefraction refraction_data;
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
void node_bsdf_sheen(vec4 color, float roughness, vec3 N, float weight, out Closure result)
|
||||
{
|
||||
color = max(color, vec4(0));
|
||||
roughness = saturate(roughness);
|
||||
N = safe_normalize(N);
|
||||
|
||||
/* Fallback to diffuse. */
|
||||
|
|
|
@ -12,6 +12,10 @@ void node_subsurface_scattering(vec4 color,
|
|||
float do_sss,
|
||||
out Closure result)
|
||||
{
|
||||
color = max(color, vec4(0));
|
||||
scale = max(scale, 0);
|
||||
radius = max(radius, vec3(0));
|
||||
ior = max(ior, 1e-5);
|
||||
N = safe_normalize(N);
|
||||
|
||||
ClosureDiffuse diffuse_data;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
void node_bsdf_toon(
|
||||
vec4 color, float size, float tsmooth, vec3 N, float weight, out Closure result)
|
||||
{
|
||||
color = max(color, vec4(0));
|
||||
N = safe_normalize(N);
|
||||
|
||||
/* Fallback to diffuse. */
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
void node_bsdf_translucent(vec4 color, vec3 N, float weight, out Closure result)
|
||||
{
|
||||
color = max(color, vec4(0));
|
||||
N = safe_normalize(N);
|
||||
|
||||
ClosureTranslucent translucent_data;
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
void node_bsdf_transparent(vec4 color, float weight, out Closure result)
|
||||
{
|
||||
color = max(color, vec4(0));
|
||||
|
||||
ClosureTransparency transparency_data;
|
||||
transparency_data.weight = weight;
|
||||
transparency_data.transmittance = color.rgb;
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
void node_volume_absorption(vec4 color, float density, float weight, out Closure result)
|
||||
{
|
||||
color = max(color, vec4(0));
|
||||
density = max(density, 0);
|
||||
|
||||
ClosureVolumeAbsorption volume_absorption_data;
|
||||
volume_absorption_data.weight = weight;
|
||||
volume_absorption_data.absorption = (1.0 - color.rgb) * density;
|
||||
|
|
|
@ -21,13 +21,20 @@ void node_volume_principled(vec4 color,
|
|||
float layer,
|
||||
out Closure result)
|
||||
{
|
||||
color = max(color, vec4(0));
|
||||
density = max(density, 0);
|
||||
absorption_color = max(absorption_color, vec4(0));
|
||||
emission_strength = max(emission_strength, 0);
|
||||
emission_color = max(emission_color, vec4(0));
|
||||
blackbody_intensity = max(blackbody_intensity, 0);
|
||||
blackbody_tint = max(blackbody_tint, vec4(0));
|
||||
temperature = max(temperature, 0);
|
||||
|
||||
vec3 absorption_coeff = vec3(0.0);
|
||||
vec3 scatter_coeff = vec3(0.0);
|
||||
vec3 emission_coeff = vec3(0.0);
|
||||
|
||||
/* Compute density. */
|
||||
density = max(density, 0.0);
|
||||
|
||||
if (density > 1e-5) {
|
||||
density = max(density * density_attribute.x, 0.0);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
void node_volume_scatter(
|
||||
vec4 color, float density, float anisotropy, float weight, out Closure result)
|
||||
{
|
||||
color = max(color, vec4(0));
|
||||
density = max(density, 0);
|
||||
|
||||
ClosureVolumeScatter volume_scatter_data;
|
||||
volume_scatter_data.weight = weight;
|
||||
volume_scatter_data.scattering = color.rgb * density;
|
||||
|
|
Loading…
Reference in New Issue