54 lines
1.3 KiB
GLSL
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;
|
|
}
|