When GLSL sources were first included in Blender they were treated as data (like blend files) and had no license header. Since then GLSL has been used for more sophisticated features (EEVEE & real-time compositing) where it makes sense to include licensing information. Add SPDX copyright headers to *.glsl files, matching headers used for C/C++, also include GLSL files in the license checking script. As leading C-comments are now stripped, added binary size of comments is no longer a concern. Ref !111247
41 lines
1.0 KiB
GLSL
41 lines
1.0 KiB
GLSL
/* SPDX-FileCopyrightText: 2019-2022 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
float fresnel_dielectric_cos(float cosi, float eta)
|
|
{
|
|
/* compute fresnel reflectance without explicitly computing
|
|
* the refracted direction */
|
|
float c = abs(cosi);
|
|
float g = eta * eta - 1.0 + c * c;
|
|
float result;
|
|
|
|
if (g > 0.0) {
|
|
g = sqrt(g);
|
|
float A = (g - c) / (g + c);
|
|
float B = (c * (g + c) - 1.0) / (c * (g - c) + 1.0);
|
|
result = 0.5 * A * A * (1.0 + B * B);
|
|
}
|
|
else {
|
|
result = 1.0; /* TIR (no refracted component) */
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
float fresnel_dielectric(vec3 Incoming, vec3 Normal, float eta)
|
|
{
|
|
/* compute fresnel reflectance without explicitly computing
|
|
* the refracted direction */
|
|
return fresnel_dielectric_cos(dot(Incoming, Normal), eta);
|
|
}
|
|
|
|
void node_fresnel(float ior, vec3 N, out float result)
|
|
{
|
|
N = normalize(N);
|
|
vec3 V = cameraVec(g_data.P);
|
|
|
|
float eta = max(ior, 0.00001);
|
|
result = fresnel_dielectric(V, N, (FrontFacing) ? eta : 1.0 / eta);
|
|
}
|