#version 450

layout(location = 0) in vec3 inPosition;

layout(binding = 0) uniform UniformBufferObject {
    mat4 viewProjMatrix;
    mat4 modelMatrix;
    mat4 modelMatrixForNormals;
    vec4 cameraPosition;
    vec4 materialProperties;
    ivec4 userInput;
} ubo;

layout(location = 0) out vec3 outUVW;

void main() {
    // Remove translation from view matrix
    mat4 view = mat4(mat3(ubo.viewProjMatrix));
    
    // Cube vertices are in [-1,1] range, we want them at far plane
    vec4 pos = view * vec4(inPosition, 1.0);
    
    // Set z to w so depth = 1.0 (far plane) after perspective divide
    gl_Position = vec4(pos.x, pos.y, pos.w * (1.0f - 1e-5f), pos.w);
    
    // Pass through local position as UVW coordinates
    outUVW = inPosition;
}