Hello!
I am working on a small side project, and am experimenting with a 24-but depth buffer shader.
Vertex:
out vec3 vNormal;
out vec3 vPosition;
out vec2 vTexCoords;
out vec4 vColour;
out float depth_space;
void main() {
vec4 object_space_pos = vec4(in_Position, 1.0);
vPosition = vec3(MATRIX_VIEW * MATRIX_OBJECT_POSITION) * in_Position;
vNormal = MATRIX_NORMAL * in_Normal;
vTexCoords = in_TextureCoord;
vColour = in_Colour * VECTOR_OBJECT_COLOUR;
// Set the correct vertex position
gl_Position = MATRIX_PROJECTION_VIEW * MATRIX_OBJECT_POSITION * object_space_pos;
vec4 viewSpacePos = MATRIX_VIEW * MATRIX_OBJECT_POSITION * object_space_pos;
depth_space = viewSpacePos.z / 300.0;
}
Fragment:
in vec3 vNormal;
in vec2 vTexCoords;
in vec4 vColour;
in vec3 vPosition;
in float depth_space;
vec3 floatToColor(float f) {
return vec3(floor(f*255.0)/255.0,fract(f*255.0),fract(f*255.0*255.0));
}
void main() {
vec4 textureSample = texture(sampler, vTexCoords);
if(textureSample.a <= 0){
discard;
}
out_Colour = vec4( floatToColor(depth_space), 1.0);
}
When running this shader in my game I run into this error:
[LWJGL] ARB_debug_output message
ID: 1282
Source: API
Type: ERROR
Severity: HIGH
Message: GL_INVALID_OPERATION error generated. Wrong component type or count.
What’s weird is that the shader seems to actually work… Here is the output:
What could be the issue?