[Bf-blender-cvs] [e963efc] viewport_experiments: Normalize the depth to the -1.0 to 1.0 range as well.

Antony Riakiotakis noreply at git.blender.org
Tue Oct 21 20:33:51 CEST 2014


Commit: e963efcd19badec7de5ca962c514ae1faf8f7e7b
Author: Antony Riakiotakis
Date:   Mon Oct 20 21:46:29 2014 +0200
Branches: viewport_experiments
https://developer.blender.org/rBe963efcd19badec7de5ca962c514ae1faf8f7e7b

Normalize the depth to the -1.0 to 1.0 range as well.

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

M	source/blender/gpu/intern/gpu_compositing.c
M	source/blender/gpu/shaders/gpu_shader_fx_frag.glsl

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

diff --git a/source/blender/gpu/intern/gpu_compositing.c b/source/blender/gpu/intern/gpu_compositing.c
index 1aa1b5a..cf3c9e9 100644
--- a/source/blender/gpu/intern/gpu_compositing.c
+++ b/source/blender/gpu/intern/gpu_compositing.c
@@ -167,7 +167,6 @@ bool GPU_initialize_fx_passes(GPUFX *fx, rcti *rect, rcti *scissor_rect, int fxf
 }
 
 
-
 bool GPU_fx_do_composite_pass(GPUFX *fx, struct View3D *v3d) {
 	GPUShader *fx_shader;
 	int numslots = 0, i;
diff --git a/source/blender/gpu/shaders/gpu_shader_fx_frag.glsl b/source/blender/gpu/shaders/gpu_shader_fx_frag.glsl
index ce1909e..d373350 100644
--- a/source/blender/gpu/shaders/gpu_shader_fx_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_fx_frag.glsl
@@ -32,8 +32,8 @@ vec4 calculate_view_space_position(in vec2 uvcoords, float depth)
 {	
     //First we need to calculate the view space distance from the shader inputs
     //This will unfortunately depend on the precision of the depth buffer which is not linear
-    vec2 norm_scr = uvcoords * 2.0 - 1.0;
-    vec4 viewposition = vec4(norm_scr.x, norm_scr.y, depth, 1.0);
+    vec4 viewposition = vec4(uvcoords.x, uvcoords.y, depth, 1.0);
+    viewposition = viewposition * 2.0 - 1.0;
 
     // convert to view space now
     viewposition = gl_ProjectionMatrixInverse * viewposition;




More information about the Bf-blender-cvs mailing list