0% found this document useful (0 votes)
5 views3 pages

Bad Shader 1

The document contains a fragment shader written in GLSL version 320 ES, which includes various definitions, constants, and functions for texture sampling and color manipulation. It attempts to implement a texture averaging algorithm but encounters compilation errors due to type mismatches between unsigned integers and integers in comparison operations. The errors indicate that the shader failed to compile successfully, resulting in no executable code being generated.

Uploaded by

bahrigaming566
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Bad Shader 1

The document contains a fragment shader written in GLSL version 320 ES, which includes various definitions, constants, and functions for texture sampling and color manipulation. It attempts to implement a texture averaging algorithm but encounters compilation errors due to type mismatches between unsigned integers and integers in comparison operations. The errors indicate that the shader failed to compile successfully, resulting in no executable code being generated.

Uploaded by

bahrigaming566
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

#version 320 es

#extension GL_EXT_shader_framebuffer_fetch : require


#define DRIVER_POWERVR 1
#define API_OPENGL 0
#define API_OPENGL_ES 1
#define API_D3D11 0
#define API_D3D12 0
#define API_VULKAN 0
#define API_METAL 0
precision highp float;
precision highp int;
precision highp sampler2D;
precision highp isampler2D;
precision highp usampler2D;
precision highp sampler2DMS;
precision highp usamplerBuffer;

#define GLSL 1
#define float2 vec2
#define float3 vec3
#define float4 vec4
#define int2 ivec2
#define int3 ivec3
#define int4 ivec4
#define uint2 uvec2
#define uint3 uvec3
#define uint4 uvec4
#define float2x2 mat2
#define float3x3 mat3
#define float4x4 mat4
#define mul(x, y) ((x) * (y))
#define nointerpolation flat
#define frac fract
#define lerp mix
#define CONSTANT const
#define GLOBAL
#define FOR_UNROLL for
#define FOR_LOOP for
#define IF_BRANCH if
#define IF_FLATTEN if
#define VECTOR_EQ(a, b) ((a) == (b))
#define VECTOR_NEQ(a, b) ((a) != (b))
#define VECTOR_COMP_EQ(a, b) equal((a), (b))
#define VECTOR_COMP_NEQ(a, b) notEqual((a), (b))
#define SAMPLE_TEXTURE(name, coords) texture(name, coords)
#define SAMPLE_TEXTURE_OFFSET(name, coords, offset) textureOffset(name, coords,
offset)
#define SAMPLE_TEXTURE_LEVEL(name, coords, level) textureLod(name, coords, level)
#define SAMPLE_TEXTURE_LEVEL_OFFSET(name, coords, level, offset)
textureLodOffset(name, coords, level, offset)
#define LOAD_TEXTURE(name, coords, mip) texelFetch(name, coords, mip)
#define LOAD_TEXTURE_MS(name, coords, sample) texelFetch(name, coords, int(sample))
#define LOAD_TEXTURE_OFFSET(name, coords, mip, offset) texelFetchOffset(name,
coords, mip, offset)
#define LOAD_TEXTURE_BUFFER(name, index) texelFetch(name, index)
#define BEGIN_ARRAY(type, size) type[size](
#define END_ARRAY )
float saturate(float value) { return clamp(value, 0.0, 1.0); }
float2 saturate(float2 value) { return clamp(value, float2(0.0, 0.0), float2(1.0,
1.0)); }
float3 saturate(float3 value) { return clamp(value, float3(0.0, 0.0, 0.0),
float3(1.0, 1.0, 1.0)); }
float4 saturate(float4 value) { return clamp(value, float4(0.0, 0.0, 0.0, 0.0),
float4(1.0, 1.0, 1.0, 1.0)); }

#define MULTISAMPLING 0
CONSTANT uint RESOLUTION_SCALE = 3u;
CONSTANT uint2 VRAM_SIZE = uint2(1024, 512) * RESOLUTION_SCALE;
CONSTANT float2 RCP_VRAM_SIZE = float2(1.0, 1.0) / float2(VRAM_SIZE);
CONSTANT uint MULTISAMPLES = 1u;
CONSTANT bool PER_SAMPLE_SHADING = false;

uint RGBA8ToRGBA5551(float4 v)
{
uint r = uint(roundEven(v.r * 31.0));
uint g = uint(roundEven(v.g * 31.0));
uint b = uint(roundEven(v.b * 31.0));
uint a = (v.a != 0.0) ? 1u : 0u;
return (r) | (g << 5) | (b << 10) | (a << 15);
}

float4 RGBA5551ToRGBA8(uint v)
{
uint r = (v & 31u);
uint g = ((v >> 5) & 31u);
uint b = ((v >> 10) & 31u);
uint a = ((v >> 15) & 1u);

return float4(float(r) / 31.0, float(g) / 31.0, float(b) / 31.0, float(a));


}
layout(std140, binding = 1) uniform UBOBlock
{
uint2 u_base_coords;
};

layout(binding = 0) uniform sampler2D samp0;


#define FACTOR 3
in VertexData {
float2 v_tex0;
};
#define v_pos gl_FragCoord
layout(location = 0) out float4 o_col0;

void main()

{
float3 color = float3(0.0, 0.0, 0.0);
uint2 base_coords = u_base_coords + uint2(v_pos.xy) * uint2(FACTOR, FACTOR);
for (uint offset_x = 0u; offset_x < FACTOR; offset_x++)
{
for (uint offset_y = 0u; offset_y < FACTOR; offset_y++)
color += LOAD_TEXTURE(samp0, int2(base_coords + uint2(offset_x, offset_y)),
0).rgb;
}
color /= float(FACTOR * FACTOR);
o_col0 = float4(color, 1.0);
}
Compile Fragment shader failed
Compile failed.
ERROR: 0:104: '<' : Wrong operand types. No operation '<' exists that takes a left-
hand operand of type 'uint' and a right operand of type 'const int' (and there is
no acceptable conversion)
ERROR: 0:106: '<' : Wrong operand types. No operation '<' exists that takes a left-
hand operand of type 'uint' and a right operand of type 'const int' (and there is
no acceptable conversion)
2 compilation errors. No code generated.

You might also like