[Bf-blender-cvs] [0790db4] viewport_experiments: signed coc matches the low quality one.

Antony Riakiotakis noreply at git.blender.org
Tue Jan 6 20:01:47 CET 2015


Commit: 0790db4f5cb34b33719fe4c024737555fce62b4b
Author: Antony Riakiotakis
Date:   Tue Jan 6 20:01:32 2015 +0100
Branches: viewport_experiments
https://developer.blender.org/rB0790db4f5cb34b33719fe4c024737555fce62b4b

signed coc matches the low quality one.

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

M	source/blender/gpu/shaders/gpu_shader_fx_dof_high_frag.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 be54244..8b7974c 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
@@ -16,11 +16,13 @@ uniform sampler2D cocbuffer;
 
 // this includes focal distance in x and aperture size in y
 uniform vec4 dof_params;
+// viewvectors for reconstruction of world space
+uniform vec4 viewvecs[3];
 
 /* coc calculation, positive is far coc, negative is near */
-float calculate_signed_coc(in float zdepth)
+vec4 calculate_signed_coc(in vec4 zdepth)
 {
-	float coc = dof_params.x * (1.0 - dof_params.y / zdepth);
+	vec4 coc = dof_params.x * (vec4(1.0) - vec4(dof_params.y) / zdepth);
 
 	/* multiply by 1.0 / sensor size to get the normalized size */
 	return coc * dof_params.z;
@@ -28,16 +30,19 @@ float calculate_signed_coc(in float zdepth)
 
 void half_downsample_frag(void)
 {
-	vec4 depthv;
-	depthv.r = calculate_signed_coc(texture2D(depthbuffer, depth_uv1).r);
-	depthv.g = calculate_signed_coc(texture2D(depthbuffer, depth_uv2).r);
-	depthv.b = calculate_signed_coc(texture2D(depthbuffer, depth_uv3).r);
-	depthv.a = calculate_signed_coc(texture2D(depthbuffer, depth_uv4).r);
+	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;
+	
+	coc = calculate_signed_coc(get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), depthv));
 	
 	/* near coc, keep the min here */
-	gl_FragData[1].r = max(-min(min(depthv.r, depthv.g), min(depthv.b, depthv.a)), 0.0);
+	gl_FragData[1].r = max(-min(min(coc.r, coc.g), min(coc.b, coc.a)), 0.0);
 	/* far coc keep the max */
-	gl_FragData[1].g = max(max(max(depthv.r, depthv.g), max(depthv.b, depthv.a)), 0.0);
+	gl_FragData[1].g = max(max(max(coc.r, coc.g), max(coc.b, coc.a)), 0.0);
 	/* framebuffer output 1 is bound to half size color. linear filtering should take care of averaging here */
 	gl_FragData[0] = texture2D(colorbuffer, uvcoordsvar.xy);
 }




More information about the Bf-blender-cvs mailing list