[Bf-blender-cvs] [25789f24f2d] blender2.8: Eevee: Add some utils functions

Clément Foucault noreply at git.blender.org
Fri Aug 18 15:42:49 CEST 2017


Commit: 25789f24f2d6c6076e8b3d04a12a1a29c2732ba4
Author: Clément Foucault
Date:   Fri Aug 18 14:24:29 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB25789f24f2d6c6076e8b3d04a12a1a29c2732ba4

Eevee: Add some utils functions

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

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

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

diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
index ee2bc08a38a..fc339e93927 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
@@ -133,17 +133,31 @@ vec2 mip_ratio_interp(float mip) {
 /* ------- Fast Math ------- */
 
 /* [Drobot2014a] Low Level Optimizations for GCN */
-float fast_sqrt(float x)
+float fast_sqrt(float v)
 {
-	return intBitsToFloat(0x1fbd1df5 + (floatBitsToInt(x) >> 1));
+	return intBitsToFloat(0x1fbd1df5 + (floatBitsToInt(v) >> 1));
+}
+
+vec2 fast_sqrt(vec2 v)
+{
+	return intBitsToFloat(0x1fbd1df5 + (floatBitsToInt(v) >> 1));
 }
 
 /* [Eberly2014] GPGPU Programming for Games and Science */
-float fast_acos(float x)
+float fast_acos(float v)
 {
-	float res = -0.156583 * abs(x) + M_PI_2;
-	res *= fast_sqrt(1.0 - abs(x));
-	return (x >= 0) ? res : M_PI - res;
+	float res = -0.156583 * abs(v) + M_PI_2;
+	res *= fast_sqrt(1.0 - abs(v));
+	return (v >= 0) ? res : M_PI - res;
+}
+
+vec2 fast_acos(vec2 v)
+{
+	vec2 res = -0.156583 * abs(v) + M_PI_2;
+	res *= fast_sqrt(1.0 - abs(v));
+	v.x = (v.x >= 0) ? res.x : M_PI - res.x;
+	v.y = (v.y >= 0) ? res.y : M_PI - res.y;
+	return v;
 }
 
 float point_plane_projection_dist(vec3 lineorigin, vec3 planeorigin, vec3 planenormal)
@@ -280,6 +294,12 @@ float get_view_z_from_depth(float depth)
 	}
 }
 
+vec2 get_uvs_from_view(vec3 view)
+{
+	vec3 ndc = project_point(ProjectionMatrix, view);
+	return ndc.xy * 0.5 + 0.5;
+}
+
 vec3 get_view_space_from_depth(vec2 uvcoords, float depth)
 {
 	if (ProjectionMatrix[3][3] == 0.0) {



More information about the Bf-blender-cvs mailing list