From 476128e0bd75305616f78982d15f84902944917b Mon Sep 17 00:00:00 2001 From: uis Date: Thu, 11 Jan 2024 21:26:12 +0300 Subject: [PATCH] Remove redundant texture sampling --- shader_glsl.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/shader_glsl.h b/shader_glsl.h index 230e754b..9d084f6f 100644 --- a/shader_glsl.h +++ b/shader_glsl.h @@ -334,25 +334,21 @@ " vec3 x4 = dp_texture2D(Texture_First, TexCoord1.xy + vec2( px.x, px.y)).rgb;\n", " vec3 x5 = dp_texture2D(Texture_First, TexCoord1.xy + vec2( px.x, 0.0)).rgb;\n", " vec3 x6 = dp_texture2D(Texture_First, TexCoord1.xy + vec2( px.x,-px.y)).rgb;\n", -" vec3 y1 = dp_texture2D(Texture_First, TexCoord1.xy + vec2( px.x,-px.y)).rgb;\n", " vec3 y2 = dp_texture2D(Texture_First, TexCoord1.xy + vec2( 0.0,-px.y)).rgb;\n", -" vec3 y3 = dp_texture2D(Texture_First, TexCoord1.xy + vec2(-px.x,-px.y)).rgb;\n", -" vec3 y4 = dp_texture2D(Texture_First, TexCoord1.xy + vec2( px.x, px.y)).rgb;\n", " vec3 y5 = dp_texture2D(Texture_First, TexCoord1.xy + vec2( 0.0, px.y)).rgb;\n", -" vec3 y6 = dp_texture2D(Texture_First, TexCoord1.xy + vec2(-px.x, px.y)).rgb;\n", " float px1 = -1.0 * dot(vec3(0.3, 0.59, 0.11), x1);\n", " float px2 = -2.0 * dot(vec3(0.3, 0.59, 0.11), x2);\n", " float px3 = -1.0 * dot(vec3(0.3, 0.59, 0.11), x3);\n", " float px4 = 1.0 * dot(vec3(0.3, 0.59, 0.11), x4);\n", " float px5 = 2.0 * dot(vec3(0.3, 0.59, 0.11), x5);\n", " float px6 = 1.0 * dot(vec3(0.3, 0.59, 0.11), x6);\n", -" float py1 = -1.0 * dot(vec3(0.3, 0.59, 0.11), y1);\n", +" float py1 = -px6;\n", " float py2 = -2.0 * dot(vec3(0.3, 0.59, 0.11), y2);\n", -" float py3 = -1.0 * dot(vec3(0.3, 0.59, 0.11), y3);\n", -" float py4 = 1.0 * dot(vec3(0.3, 0.59, 0.11), y4);\n", +" float py3 = px3;\n", +" float py4 = px4;\n", " float py5 = 2.0 * dot(vec3(0.3, 0.59, 0.11), y5);\n", -" float py6 = 1.0 * dot(vec3(0.3, 0.59, 0.11), y6);\n", -" sobel = 0.25 * abs(px1 + px2 + px3 + px4 + px5 + px6) + 0.25 * abs(py1 + py2 + py3 + py4 + py5 + py6);\n", +" float py6 = -px1;\n", +" sobel = 0.25 * (abs(px1 + px2 + px3 + px4 + px5 + px6) + abs(py1 + py2 + py3 + py4 + py5 + py6));\n", " dp_FragColor += dp_texture2D(Texture_First, TexCoord1.xy + PixelSize*UserVec1.x*vec2(-0.987688, -0.156434)) * UserVec1.y;\n", " dp_FragColor += dp_texture2D(Texture_First, TexCoord1.xy + PixelSize*UserVec1.x*vec2(-0.156434, -0.891007)) * UserVec1.y;\n", " dp_FragColor += dp_texture2D(Texture_First, TexCoord1.xy + PixelSize*UserVec1.x*vec2( 0.891007, -0.453990)) * UserVec1.y;\n", -- 2.39.2