31 lines
856 B
GLSL
31 lines
856 B
GLSL
#version 450 core
|
|
out gl_PerVertex { vec4 gl_Position; };
|
|
|
|
layout(std140, binding = 0) uniform PerFrame {
|
|
mat4 uView;
|
|
mat4 uProj;
|
|
vec4 uLightDir; // unused here
|
|
};
|
|
layout(std140, binding = 1) uniform PerObject {
|
|
mat4 uModel; // use this to scale the cube (e.g., 3.0)
|
|
};
|
|
|
|
layout(location = 0) in vec3 aPos;
|
|
layout(location = 1) in vec3 aNormal; // present, unused
|
|
layout(location = 2) in vec2 aUV; // present, unused
|
|
|
|
layout(location = 0) out vec3 vDir; // explicit location for SSO
|
|
|
|
void main() {
|
|
// Use uModel to scale your standard cube (e.g., 3.0) from CPU.
|
|
vec3 pLocal = mat3(uModel) * aPos;
|
|
|
|
// Rotation-only view (drop translation)
|
|
mat3 R = mat3(uView);
|
|
|
|
vDir = pLocal;
|
|
|
|
// Glue the cube to the camera (no translation), push to far plane
|
|
vec4 p = uProj * vec4(R * pLocal, 1.0);
|
|
gl_Position = vec4(p.xy, 1.0, 1.0);
|
|
} |