[Bf-blender-cvs] [6148295] viewport_experiments: fragment shader to downsample near circle of confusion - rename texture coordinates so it's clearer they are reusable.

Antony Riakiotakis noreply at git.blender.org
Fri Jan 9 16:49:13 CET 2015


Commit: 6148295f1ab3a9a68e92878a9fcbef7af33be96a
Author: Antony Riakiotakis
Date:   Tue Jan 6 20:27:52 2015 +0100
Branches: viewport_experiments
https://developer.blender.org/rB6148295f1ab3a9a68e92878a9fcbef7af33be96a

fragment shader to downsample near circle of confusion - rename texture
coordinates so it's clearer they are reusable.

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

M	source/blender/gpu/shaders/gpu_shader_fx_dof_high_frag.glsl
M	source/blender/gpu/shaders/gpu_shader_fx_dof_high_vert.glsl

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

diff --git a/source/blender/gpu/shaders/gpu_shader_fx_dof_high_frag.glsl b/source/blender/gpu/shaders/gpu_shader_fx_dof_high_frag.glsl
index 8b7974c..851dd3e 100644
--- a/source/blender/gpu/shaders/gpu_shader_fx_dof_high_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_fx_dof_high_frag.glsl
@@ -2,10 +2,10 @@ uniform vec2 invrendertargetdim;
 
 //texture coordinates for framebuffer read
 varying vec4 uvcoordsvar;
-varying vec2 depth_uv1;
-varying vec2 depth_uv2;
-varying vec2 depth_uv3;
-varying vec2 depth_uv4;
+varying vec2 uv1;
+varying vec2 uv2;
+varying vec2 uv3;
+varying vec2 uv4;
 
 // color buffer
 uniform sampler2D colorbuffer;
@@ -32,10 +32,10 @@ void half_downsample_frag(void)
 {
 	vec4 depthv, coc;
 	
-	depthv.r = texture2D(depthbuffer, depth_uv1).r;
-	depthv.g = texture2D(depthbuffer, depth_uv2).r;
-	depthv.b = texture2D(depthbuffer, depth_uv3).r;
-	depthv.a = texture2D(depthbuffer, depth_uv4).r;
+	depthv.r = texture2D(depthbuffer, uv1).r;
+	depthv.g = texture2D(depthbuffer, uv2).r;
+	depthv.b = texture2D(depthbuffer, uv3).r;
+	depthv.a = texture2D(depthbuffer, uv4).r;
 	
 	coc = calculate_signed_coc(get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), depthv));
 	
@@ -47,6 +47,21 @@ void half_downsample_frag(void)
 	gl_FragData[0] = texture2D(colorbuffer, uvcoordsvar.xy);
 }
 
+
+void downsample_coc(void)
+{
+	/* basically here we just assemble all nearby values from the texture and use the maximum for near coc 
+	 * this ensures the gathe as scatter technique at the end will work */
+	
+	vec4 coc;
+	coc.r = texture2D(cocbuffer, uv1).r;
+	coc.g = texture2D(cocbuffer, uv2).r;
+	coc.b = texture2D(cocbuffer, uv3).r;
+	coc.a = texture2D(cocbuffer, uv4).r;
+	
+	gl_FragColor.r = max(max(coc.r, coc.g), max(coc.b, coc.a));
+}
+
 void final_combine_frag(void)
 {
 	vec4 coc = texture2D(cocbuffer, uvcoordsvar.xy);
diff --git a/source/blender/gpu/shaders/gpu_shader_fx_dof_high_vert.glsl b/source/blender/gpu/shaders/gpu_shader_fx_dof_high_vert.glsl
index 7feccbe..fef4541 100644
--- a/source/blender/gpu/shaders/gpu_shader_fx_dof_high_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_fx_dof_high_vert.glsl
@@ -2,10 +2,10 @@ uniform vec2 invrendertargetdim;
 
 //texture coordinates for framebuffer read
 varying vec4 uvcoordsvar;
-varying vec2 depth_uv1;
-varying vec2 depth_uv2;
-varying vec2 depth_uv3;
-varying vec2 depth_uv4;
+varying vec2 uv1;
+varying vec2 uv2;
+varying vec2 uv3;
+varying vec2 uv4;
 
 
 void vert_half_downsample(void)
@@ -13,10 +13,10 @@ void vert_half_downsample(void)
 	uvcoordsvar = gl_MultiTexCoord0;
 	gl_Position = gl_Vertex;
 	
-	depth_uv1 = gl_MultiTexCoord0.xy + vec2(-0.5, -0.5) * invrendertargetdim;
-	depth_uv2 = gl_MultiTexCoord0.xy + vec2(-0.5, 0.5) * invrendertargetdim;
-	depth_uv3 = gl_MultiTexCoord0.xy + vec2(0.5, -0.5) * invrendertargetdim;
-	depth_uv4 = gl_MultiTexCoord0.xy + vec2(0.5, 0.5) * invrendertargetdim;
+	uv1 = gl_MultiTexCoord0.xy + vec2(-0.5, -0.5) * invrendertargetdim;
+	uv2 = gl_MultiTexCoord0.xy + vec2(-0.5, 0.5) * invrendertargetdim;
+	uv3 = gl_MultiTexCoord0.xy + vec2(0.5, -0.5) * invrendertargetdim;
+	uv4 = gl_MultiTexCoord0.xy + vec2(0.5, 0.5) * invrendertargetdim;
 }
 
 void vert_final_combine(void)




More information about the Bf-blender-cvs mailing list