blob: f9691beee6fb1ac35843f51a8303c5ef9133916e (
plain)
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
|
/* TODO : clean this ifdef mess */
void world_normals_get(out vec3 N)
{
#ifndef VOLUMETRICS
# ifdef HAIR_SHADER
vec3 B = normalize(cross(worldNormal, hairTangent));
float cos_theta;
if (hairThicknessRes == 1) {
vec4 rand = texelFetch(utilTex, ivec3(ivec2(gl_FragCoord.xy) % LUT_SIZE, 2.0), 0);
/* Random cosine normal distribution on the hair surface. */
cos_theta = rand.x * 2.0 - 1.0;
}
else {
/* Shade as a cylinder. */
cos_theta = hairThickTime / hairThickness;
}
float sin_theta = sqrt(max(0.0, 1.0 - cos_theta * cos_theta));
N = normalize(worldNormal * sin_theta + B * cos_theta);
# else
N = gl_FrontFacing ? worldNormal : -worldNormal;
# endif
#else
generated_from_orco(vec3(0.0), N);
#endif
}
|