[Bf-blender-cvs] [f6ffe12ddb4] blender2.8: OpenGL: convert old texture2D calls in FX shaders

Mike Erwin noreply at git.blender.org
Fri May 19 17:10:44 CEST 2017


Commit: f6ffe12ddb4426bec802d099c3538a9b31e72f8c
Author: Mike Erwin
Date:   Fri May 19 10:41:42 2017 -0400
Branches: blender2.8
https://developer.blender.org/rBf6ffe12ddb4426bec802d099c3538a9b31e72f8c

OpenGL: convert old texture2D calls in FX shaders

And one texture1D call.

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

M	source/blender/gpu/shaders/gpu_shader_fx_depth_resolve.glsl
M	source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl
M	source/blender/gpu/shaders/gpu_shader_fx_dof_hq_frag.glsl
M	source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl
M	source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_frag.glsl

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

diff --git a/source/blender/gpu/shaders/gpu_shader_fx_depth_resolve.glsl b/source/blender/gpu/shaders/gpu_shader_fx_depth_resolve.glsl
index 9221e3def2c..c4e7cff2b0b 100644
--- a/source/blender/gpu/shaders/gpu_shader_fx_depth_resolve.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_fx_depth_resolve.glsl
@@ -1,11 +1,10 @@
 uniform sampler2D depthbuffer;
 
 in vec4 uvcoordsvar;
-#define texture2D texture
 
 void main(void)
 {
-	float depth = texture2D(depthbuffer, uvcoordsvar.xy).r;
+	float depth = texture(depthbuffer, uvcoordsvar.xy).r;
 
 	/* XRay background, discard */
 	if (depth >= 1.0) {
diff --git a/source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl b/source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl
index b8feb8280b2..15d30e75969 100644
--- a/source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl
@@ -29,7 +29,6 @@ in vec2 depth_uv3;
 in vec2 depth_uv4;
 
 out vec4 FragColor;
-#define texture2D texture
 
 float calculate_far_coc(in float zdepth)
 {
@@ -65,40 +64,40 @@ void first_pass()
 	offset_row[2] = 3.0 * offset_row[0];
 
 	/* heavily blur the image */
-	vec4 color = texture2D(colorbuffer, color_uv1);
-	color += texture2D(colorbuffer, color_uv1 + offset_row[1]);
-	color += texture2D(colorbuffer, color_uv2);
-	color += texture2D(colorbuffer, color_uv2 + offset_row[1]);
+	vec4 color = texture(colorbuffer, color_uv1);
+	color += texture(colorbuffer, color_uv1 + offset_row[1]);
+	color += texture(colorbuffer, color_uv2);
+	color += texture(colorbuffer, color_uv2 + offset_row[1]);
 	color /= 4.0;
 
-	depth.r = texture2D(depthbuffer, depth_uv1).r;
-	depth.g = texture2D(depthbuffer, depth_uv2).r;
-	depth.b = texture2D(depthbuffer, depth_uv3).r;
-	depth.a = texture2D(depthbuffer, depth_uv4).r;
+	depth.r = texture(depthbuffer, depth_uv1).r;
+	depth.g = texture(depthbuffer, depth_uv2).r;
+	depth.b = texture(depthbuffer, depth_uv3).r;
+	depth.a = texture(depthbuffer, depth_uv4).r;
 
 	zdepth = get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), depth);
 	coc = calculate_near_coc(zdepth);
 
-	depth.r = texture2D(depthbuffer, depth_uv1 + offset_row[0]).r;
-	depth.g = texture2D(depthbuffer, depth_uv2 + offset_row[0]).r;
-	depth.b = texture2D(depthbuffer, depth_uv3 + offset_row[0]).r;
-	depth.a = texture2D(depthbuffer, depth_uv4 + offset_row[0]).r;
+	depth.r = texture(depthbuffer, depth_uv1 + offset_row[0]).r;
+	depth.g = texture(depthbuffer, depth_uv2 + offset_row[0]).r;
+	depth.b = texture(depthbuffer, depth_uv3 + offset_row[0]).r;
+	depth.a = texture(depthbuffer, depth_uv4 + offset_row[0]).r;
 
 	zdepth = get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), depth);
 	coc = max(calculate_near_coc(zdepth), coc);
 
-	depth.r = texture2D(depthbuffer, depth_uv1 + offset_row[1]).r;
-	depth.g = texture2D(depthbuffer, depth_uv2 + offset_row[1]).r;
-	depth.b = texture2D(depthbuffer, depth_uv3 + offset_row[1]).r;
-	depth.a = texture2D(depthbuffer, depth_uv4 + offset_row[1]).r;
+	depth.r = texture(depthbuffer, depth_uv1 + offset_row[1]).r;
+	depth.g = texture(depthbuffer, depth_uv2 + offset_row[1]).r;
+	depth.b = texture(depthbuffer, depth_uv3 + offset_row[1]).r;
+	depth.a = texture(depthbuffer, depth_uv4 + offset_row[1]).r;
 
 	zdepth = get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), depth);
 	coc = max(calculate_near_coc(zdepth), coc);
 
-	depth.r = texture2D(depthbuffer, depth_uv1 + offset_row[2]).r;
-	depth.g = texture2D(depthbuffer, depth_uv2 + offset_row[2]).r;
-	depth.b = texture2D(depthbuffer, depth_uv3 + offset_row[2]).r;
-	depth.a = texture2D(depthbuffer, depth_uv4 + offset_row[2]).r;
+	depth.r = texture(depthbuffer, depth_uv1 + offset_row[2]).r;
+	depth.g = texture(depthbuffer, depth_uv2 + offset_row[2]).r;
+	depth.b = texture(depthbuffer, depth_uv3 + offset_row[2]).r;
+	depth.a = texture(depthbuffer, depth_uv4 + offset_row[2]).r;
 
 	zdepth = get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), depth);
 	coc = max(calculate_near_coc(zdepth), coc);
@@ -110,16 +109,16 @@ void first_pass()
 /* second pass, gaussian blur the downsampled image */
 void second_pass()
 {
-	vec4 depth = vec4(texture2D(depthbuffer, uvcoordsvar.xy).r);
+	vec4 depth = vec4(texture(depthbuffer, uvcoordsvar.xy).r);
 
 	/* clever sampling to sample 2 pixels at once. Of course it's not real gaussian sampling this way */
-	vec4 color =  texture2D(colorbuffer, uvcoordsvar.xy) * 0.3125;
-	color += texture2D(colorbuffer, uvcoordsvar.xy + invrendertargetdim) * 0.234375;
-	color += texture2D(colorbuffer, uvcoordsvar.xy + 2.5 * invrendertargetdim) * 0.09375;
-	color += texture2D(colorbuffer, uvcoordsvar.xy + 4.5 * invrendertargetdim) * 0.015625;
-	color += texture2D(colorbuffer, uvcoordsvar.xy - invrendertargetdim) * 0.234375;
-	color += texture2D(colorbuffer, uvcoordsvar.xy - 2.5 * invrendertargetdim) * 0.09375;
-	color += texture2D(colorbuffer, uvcoordsvar.xy - 4.5 * invrendertargetdim) * 0.015625;
+	vec4 color = texture(colorbuffer, uvcoordsvar.xy) * 0.3125;
+	color += texture(colorbuffer, uvcoordsvar.xy + invrendertargetdim) * 0.234375;
+	color += texture(colorbuffer, uvcoordsvar.xy + 2.5 * invrendertargetdim) * 0.09375;
+	color += texture(colorbuffer, uvcoordsvar.xy + 4.5 * invrendertargetdim) * 0.015625;
+	color += texture(colorbuffer, uvcoordsvar.xy - invrendertargetdim) * 0.234375;
+	color += texture(colorbuffer, uvcoordsvar.xy - 2.5 * invrendertargetdim) * 0.09375;
+	color += texture(colorbuffer, uvcoordsvar.xy - 4.5 * invrendertargetdim) * 0.015625;
 
 	FragColor = color;
 }
@@ -128,8 +127,8 @@ void second_pass()
 /* third pass, calculate the final coc from blurred and unblurred images */
 void third_pass()
 {
-	vec4 color =  texture2D(colorbuffer, uvcoordsvar.xy);
-	vec4 color_blurred =  texture2D(blurredcolorbuffer, uvcoordsvar.xy);
+	vec4 color = texture(colorbuffer, uvcoordsvar.xy);
+	vec4 color_blurred = texture(blurredcolorbuffer, uvcoordsvar.xy);
 	float coc = 2.0 * max(color_blurred.a, color.a); -color.a;
 	FragColor = vec4(color.rgb, coc);
 }
@@ -138,10 +137,10 @@ void third_pass()
 /* fourth pass, blur the final coc once to get rid of discontinuities */
 void fourth_pass()
 {
-	vec4 color = texture2D(colorbuffer, uvcoordsvar.xz);
-	color += texture2D(colorbuffer, uvcoordsvar.yz);
-	color += texture2D(colorbuffer, uvcoordsvar.xw);
-	color += texture2D(colorbuffer, uvcoordsvar.yw);
+	vec4 color = texture(colorbuffer, uvcoordsvar.xz);
+	color += texture(colorbuffer, uvcoordsvar.yz);
+	color += texture(colorbuffer, uvcoordsvar.xw);
+	color += texture(colorbuffer, uvcoordsvar.yw);
 
 	FragColor = color / 4.0;
 }
@@ -152,10 +151,10 @@ vec4 small_sample_blur(in sampler2D colorbuffer, in vec2 uv, in vec4 color)
 	vec4 result = weight * color;
 	weight *= 4.0;
 
-	result += weight * texture2D(colorbuffer, uv + color_uv1.xy);
-	result += weight * texture2D(colorbuffer, uv - color_uv1.xy);
-	result += weight * texture2D(colorbuffer, uv + color_uv1.yx);
-	result += weight * texture2D(colorbuffer, uv - color_uv1.yx);
+	result += weight * texture(colorbuffer, uv + color_uv1.xy);
+	result += weight * texture(colorbuffer, uv - color_uv1.xy);
+	result += weight * texture(colorbuffer, uv + color_uv1.yx);
+	result += weight * texture(colorbuffer, uv - color_uv1.yx);
 
 	return result;
 }
@@ -165,11 +164,11 @@ vec4 small_sample_blur(in sampler2D colorbuffer, in vec2 uv, in vec4 color)
 void fifth_pass()
 {
 	vec4 factors;
-	vec4 color_orig = texture2D(colorbuffer, uvcoordsvar.xy);
-	vec4 highblurred = texture2D(blurredcolorbuffer, uvcoordsvar.xy);
-	vec4 mediumblurred = texture2D(mblurredcolorbuffer, uvcoordsvar.xy);
+	vec4 color_orig = texture(colorbuffer, uvcoordsvar.xy);
+	vec4 highblurred = texture(blurredcolorbuffer, uvcoordsvar.xy);
+	vec4 mediumblurred = texture(mblurredcolorbuffer, uvcoordsvar.xy);
 	vec4 smallblurred = small_sample_blur(colorbuffer, uvcoordsvar.xy, color_orig);
-	float depth = texture2D(depthbuffer, uvcoordsvar.xy).r;
+	float depth = texture(depthbuffer, uvcoordsvar.xy).r;
 
 	float zdepth = get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), vec4(depth)).r;
 	float coc_far = clamp(calculate_far_coc(zdepth), 0.0, 1.0);
diff --git a/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_frag.glsl b/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_frag.glsl
index 913a8619270..c41c1d0820b 100644
--- a/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_frag.glsl
@@ -37,9 +37,6 @@ layout(location = 0) out vec4 fragData0;
 layout(location = 1) out vec4 fragData1;
 layout(location = 2) out vec4 fragData2;
 
-#define texture2D texture
-
-
 #define M_PI 3.1415926535897932384626433832795
 
 /* calculate 4 samples at once */
@@ -62,15 +59,15 @@ void downsample_pass()
 	float far_coc, near_coc;
 
 	/* custom downsampling. We need to be careful to sample nearest here to avoid leaks */
-	vec4 color1 = texture2D(colorbuffer, downsample1);
-	vec4 color2 = texture2D(colorbuffer, downsample2);
-	vec4 color3 = texture2D(colorbuffer, downsample3);
-	vec4 color4 = texture2D(colorbuffer, downsample4);
+	vec4 color1 = texture(colorbuffer, downsample1);
+	vec4 color2 = texture(colorbuffer, downsample2);
+	vec4 color3 = texture(colorbuffer, downsample3);
+	vec4 color4 = texture(colorbuffer, downsample4);
 
-	depth.r = texture2D(depthbuffer, downsample1).r;
-	depth.g = texture2D(depthbuffer, downsample2).r;
-	depth.b = texture2D(depthbuffer, downsample3).r;
-	depth.a = texture2D(depthbuffer, downsample4).r;
+	depth.r = texture(depthbuffer, downsample1).r;
+	depth.g = texture(depthbuffer, downsample2).r;
+	depth.b = texture(depthbuffer, downsample3).r;
+	depth.a = texture(depthbuffer, downsample4).r;
 
 	zdepth = get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), depth);
 	coc = calculate_coc(zdepth);
@@ -123,22 +120,22 @@ void accumulate_pass(void) {
 void final_pass(void) {
 	vec4 finalcolor;
 	float totalweight;
-	float depth = texture2D(depthbuffer, uvcoord).r;
+	float depth = texture(depthbuffer, uvcoord).r;
 
 	vec4 zdepth = get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), vec4(depth));
 	float coc_near = calculate_coc(zdepth).r;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list