Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/gpu/shaders/material/gpu_shader_material_world_normals.glsl')
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_world_normals.glsl25
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_world_normals.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_world_normals.glsl
new file mode 100644
index 00000000000..f9691beee6f
--- /dev/null
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_world_normals.glsl
@@ -0,0 +1,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
+}