[Bf-blender-cvs] [2c1396b6cbb] blender2.8: Eevee: Hair: Fix normal distribution of previous commit.

Clément Foucault noreply at git.blender.org
Sun May 13 23:04:36 CEST 2018


Commit: 2c1396b6cbbe503a1d1af0a7da1f09d3086abec6
Author: Clément Foucault
Date:   Sun May 13 23:12:45 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB2c1396b6cbbe503a1d1af0a7da1f09d3086abec6

Eevee: Hair: Fix normal distribution of previous commit.

Now it starts to look correct!

===================================================================

M	source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl

===================================================================

diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
index d777f9f5397..ca33aa99ed9 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
@@ -173,8 +173,10 @@ void CLOSURE_NAME(
 	vec3 T = normalize(worldNormal); /* meh, TODO fix worldNormal misnaming. */
 	vec3 B = normalize(cross(V, T));
 	N = cross(T, B); /* Normal facing view */
-
-	N = N * abs(rand.z) + B * rand.y;
+	/* We want a cosine distribution. */
+	float cos_theta = rand.x * 2.0 - 1.0;
+	float sin_theta = sqrt(max(0.0, 1.0f - cos_theta*cos_theta));;
+	N = N * sin_theta + B * cos_theta;
 #endif
 
 	/* ---------------------------------------------------------------- */



More information about the Bf-blender-cvs mailing list