SPIRV-Cross/shaders-no-opt/frag/texture1d-emulation.es.frag
Hans-Kristian Arntzen 1c88730e12 GLSL: Implement 1D texture emulation for ES.
ES does not support 1D images at all. Fake it by promoting 1D images to
2D.
2022-05-27 11:51:34 +02:00

33 lines
950 B
GLSL

#version 450
layout(set = 0, binding = 0) uniform sampler1D uSamp;
layout(set = 0, binding = 1) uniform sampler1DShadow uSampShadow;
layout(set = 0, binding = 2) uniform sampler1DArray uSampArray;
layout(set = 0, binding = 3) uniform sampler1DArrayShadow uSampArrayShadow;
layout(set = 0, binding = 4, r32f) uniform image1D uImage;
layout(location = 0) in vec4 vUV;
layout(location = 0) out vec4 FragColor;
void main()
{
// 1D
FragColor = texture(uSamp, vUV.x);
FragColor += textureProj(uSamp, vUV.xy);
FragColor += texelFetch(uSamp, int(vUV.x), 0);
// 1D Shadow
FragColor += texture(uSampShadow, vUV.xyz);
FragColor += textureProj(uSampShadow, vUV);
// 1D Array
FragColor = texture(uSampArray, vUV.xy);
FragColor += texelFetch(uSampArray, ivec2(vUV.xy), 0);
// 1D Array Shadow
FragColor += texture(uSampArrayShadow, vUV.xyz);
// 1D images
FragColor += imageLoad(uImage, int(vUV.x));
imageStore(uImage, int(vUV.x), FragColor);
}