Use textureLodOffset. Save some ALU!

This commit is contained in:
Hans-Kristian Arntzen 2016-02-23 23:04:48 +01:00
parent 7f80f00a4a
commit 1d33c8decb
3 changed files with 3 additions and 5 deletions

View file

@ -24,15 +24,13 @@ layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
#define PI 3.1415926535
void main()
{
float u = vTexCoord.x * global.SourceSize.x - 0.5;
float a = fract(u);
vec2 tex = vec2((floor(u) + 0.5) * global.SourceSize.z, vTexCoord.y);
#define TEX(x, y) textureLod(Source, tex + vec2(x * global.SourceSize.z, 0.0), 0.0).rgb
#define TEX(x, y) textureLodOffset(Source, tex, 0.0, ivec2(x, y)).rgb
vec3 i0 = TEX(-1, 0);
vec3 i1 = TEX( 0, 0);

View file

@ -42,7 +42,7 @@ void main()
tex.y = floor(tex.y) + 0.5;
tex = tex * global.SourceSize.zw;
#define TEX(x, y) textureLod(Source, tex + vec2(0, y * global.SourceSize.w), 0.0).rgb
#define TEX(x, y) textureLodOffset(Source, tex, 0.0, ivec2(x, y)).rgb
vec3 l0 = TEX(0, -1);
vec3 l1 = TEX(0, 0);
vec3 l2 = TEX(0, 1);

View file

@ -43,7 +43,7 @@ void main()
float a = fract(u);
vec2 tex = vec2((floor(u) + 0.5) * global.SourceSize.z, vTexCoord.y);
#define TEX(x, y) textureLod(Source, tex + vec2(x * global.SourceSize.z, 0.0), 0.0).rgb
#define TEX(x, y) textureLodOffset(Source, tex, 0.0, ivec2(x, y)).rgb
vec3 color =
kernel(a + 1.0) * TEX(-1, 0) +