forked from AcademySoftwareFoundation/MaterialX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmx_translucent_bsdf.glsl
More file actions
29 lines (24 loc) · 885 Bytes
/
mx_translucent_bsdf.glsl
File metadata and controls
29 lines (24 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// We fake diffuse transmission by using diffuse reflection from the opposite side.
// So this BTDF is really a BRDF.
void mx_translucent_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, vec3 normal, inout BSDF bsdf)
{
bsdf.throughput = vec3(0.0);
// Invert normal since we're transmitting light from the other side
float NdotL = dot(L, -normal);
if (NdotL <= 0.0 || weight < M_FLOAT_EPS)
{
return;
}
bsdf.response = color * weight * NdotL * M_PI_INV;
}
void mx_translucent_bsdf_indirect(vec3 V, float weight, vec3 color, vec3 normal, inout BSDF bsdf)
{
bsdf.throughput = vec3(0.0);
if (weight < M_FLOAT_EPS)
{
return;
}
// Invert normal since we're transmitting light from the other side
vec3 Li = mx_environment_irradiance(-normal);
bsdf.response = Li * color * weight;
}