engine/assets/shaders/unlit.glsl
2024-12-31 03:54:01 +04:00

69 lines
1.5 KiB
GLSL

#extension GL_EXT_buffer_reference : require
#extension GL_EXT_scalar_block_layout : require
#extension GL_EXT_nonuniform_qualifier : require
#include "global.glsl"
layout(std430, buffer_reference, buffer_reference_align = 4) readonly buffer PositionBuffer
{
vec3 positions[];
};
struct OtherData
{
vec3 normal;
vec3 tangent;
vec2 uv;
};
layout(std430, buffer_reference, buffer_reference_align = 4) readonly buffer OtherDataBuffer
{
OtherData other_data[];
};
layout(push_constant, std430) uniform constants
{
mat4 local_to_world;
PositionBuffer positions;
OtherDataBuffer other_data;
uint color_texture;
uint color_sampler;
} PushConstants;
#if VERTEX_SHADER
// QUAD
vec2 positions[6] = vec2[](
vec2(-1, -1),
vec2(-1, 1),
vec2(1, 1),
vec2(1, 1),
vec2(1, -1),
vec2(-1, -1)
);
layout(location = 0) out vec2 OutUV;
void main() {
PositionBuffer positions_ptr = PushConstants.positions;
OtherDataBuffer other_data_ptr = PushConstants.other_data;
OutUV = other_data_ptr.other_data[gl_VertexIndex].uv;
gl_Position = vec4(positions_ptr.positions[gl_VertexIndex], 1.0) * PushConstants.local_to_world * Global.view.world_to_clip;
}
#endif
#if FRAGMENT_SHADER
layout(location = 0) in vec2 InUV;
layout(location = 0) out vec4 FragColor;
void main() {
FragColor = vec4(1); // vec4(texture(sampler2D(global_textures2d[PushConstants.color_texture], global_samplers[PushConstants.color_sampler]), InUV).rgb, 1.0);
}
#endif