This avoid confusion outside of the shader node GLSL code. The issue also is that Metal allow float to cast to bool implicitly but this create a compilation error on OpenGL.
34 lines
976 B
GLSL
34 lines
976 B
GLSL
/* SPDX-FileCopyrightText: 2019-2022 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
void node_bsdf_glass(vec4 color,
|
|
float roughness,
|
|
float ior,
|
|
vec3 N,
|
|
float weight,
|
|
const float do_multiscatter,
|
|
out Closure result)
|
|
{
|
|
N = safe_normalize(N);
|
|
vec3 V = cameraVec(g_data.P);
|
|
float NV = dot(N, V);
|
|
|
|
vec2 bsdf = bsdf_lut(NV, roughness, ior, do_multiscatter != 0.0);
|
|
|
|
ClosureReflection reflection_data;
|
|
reflection_data.weight = bsdf.x * weight;
|
|
reflection_data.color = color.rgb;
|
|
reflection_data.N = N;
|
|
reflection_data.roughness = roughness;
|
|
|
|
ClosureRefraction refraction_data;
|
|
refraction_data.weight = bsdf.y * weight;
|
|
refraction_data.color = color.rgb;
|
|
refraction_data.N = N;
|
|
refraction_data.roughness = roughness;
|
|
refraction_data.ior = ior;
|
|
|
|
result = closure_eval(reflection_data, refraction_data);
|
|
}
|