Pong/resources/shaders/Billboard.vert
Karutoh b905a949f2
Some checks failed
Build & Release / Linux-AARCH64-Build (push) Failing after 1m29s
Build & Release / Windows-AMD64-Build (push) Failing after 1m40s
Build & Release / Linux-AMD64-Build (push) Successful in 3m5s
Added CI/CD.
2024-07-01 19:55:24 -07:00

54 lines
1.3 KiB
GLSL

#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 vPos;
layout(location = 1) in vec2 vUv;
layout(location = 0) out vec2 fUv;
layout(location = 1) out uint fChannels;
layout(binding = 0) uniform Transform
{
mat4 viewProj;
vec3 pos;
uint channels;
vec2 size;
} trans;
mat4 RemoveRotation(mat4 inMat)
{
inMat[0][0] = 1.0;
inMat[0][1] = 0.0;
inMat[0][2] = 0.0;
inMat[1][0] = 0.0;
inMat[1][1] = 1.0;
inMat[1][2] = 0.0;
inMat[2][0] = 0.0;
inMat[2][1] = 0.0;
inMat[2][2] = 1.0;
return inMat;
}
void main()
{
// The vec4 we will use to set gl_Position
vec4 pos = vec4(trans.pos, 1.0f);
// Adjust the position based on the camera view
// Extract the right and up vectors from the view matrix
vec3 right = vec3(trans.viewProj[0][0], trans.viewProj[1][0], trans.viewProj[2][0]);
vec3 up = vec3(trans.viewProj[0][1], trans.viewProj[1][1], trans.viewProj[2][1]);
// Adjust the quad vertices to face the camera
// The inPosition.xy should be in NDC space, from -1 to 1
pos.xyz += (right * vPos.x * trans.size.x) + (up * vPos.y * trans.size.y);
// Output position
gl_Position = trans.viewProj * pos;
// Pass through the texture coordinates
fUv = vUv;
fChannels = trans.channels;
}