Files
test/source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl
Jason Fielder 9042773d93 GPU: Resolve compilation error in Metal caused by type ambiguity
Recent change in commit 3f778150a9
caused compilation errors in Metal due to type ambiguity. Updating call to
explicitly utilise floats where appropriate.

Authored by Apple: Michael Parkin-White

Co-authored-by: Michael Parkin-White <mparkinwhite@apple.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/115301
2023-11-27 11:50:25 +01:00

38 lines
1.1 KiB
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)
{
color = max(color, vec4(0.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);
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);
}