mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-23 00:01:31 +11:00
Use textureLodOffset. Save some ALU!
This commit is contained in:
parent
7f80f00a4a
commit
1d33c8decb
|
@ -24,15 +24,13 @@ layout(location = 0) in vec2 vTexCoord;
|
||||||
layout(location = 0) out vec4 FragColor;
|
layout(location = 0) out vec4 FragColor;
|
||||||
layout(set = 0, binding = 2) uniform sampler2D Source;
|
layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
|
|
||||||
#define PI 3.1415926535
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
float u = vTexCoord.x * global.SourceSize.x - 0.5;
|
float u = vTexCoord.x * global.SourceSize.x - 0.5;
|
||||||
float a = fract(u);
|
float a = fract(u);
|
||||||
vec2 tex = vec2((floor(u) + 0.5) * global.SourceSize.z, vTexCoord.y);
|
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 i0 = TEX(-1, 0);
|
||||||
vec3 i1 = TEX( 0, 0);
|
vec3 i1 = TEX( 0, 0);
|
||||||
|
|
|
@ -42,7 +42,7 @@ void main()
|
||||||
tex.y = floor(tex.y) + 0.5;
|
tex.y = floor(tex.y) + 0.5;
|
||||||
tex = tex * global.SourceSize.zw;
|
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 l0 = TEX(0, -1);
|
||||||
vec3 l1 = TEX(0, 0);
|
vec3 l1 = TEX(0, 0);
|
||||||
vec3 l2 = TEX(0, 1);
|
vec3 l2 = TEX(0, 1);
|
||||||
|
|
|
@ -43,7 +43,7 @@ void main()
|
||||||
float a = fract(u);
|
float a = fract(u);
|
||||||
vec2 tex = vec2((floor(u) + 0.5) * global.SourceSize.z, vTexCoord.y);
|
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 =
|
vec3 color =
|
||||||
kernel(a + 1.0) * TEX(-1, 0) +
|
kernel(a + 1.0) * TEX(-1, 0) +
|
||||||
|
|
Loading…
Reference in a new issue