fast-nuclear-sim/assets/shader/main.vsh

48 lines
966 B
V Shell
Raw Normal View History

2024-01-31 00:12:14 +11:00
#version 460 core
#extension GL_ARB_bindless_texture : require
layout (location = 0) in sampler2D aTex;
layout (location = 1) in vec2 aTexPos;
layout (location = 2) in vec4 aPos;
layout (location = 3) in vec3 aNormal;
2024-02-16 21:50:46 +11:00
layout (location = 4) in vec4 aColour;
2024-02-23 19:23:18 +11:00
layout (location = 5) in vec3 aMaterial;
2024-03-03 12:12:21 +11:00
layout (location = 6) in float aTransformIndex;
2024-01-31 00:12:14 +11:00
uniform mat4 model;
uniform mat4 camera;
2024-01-31 00:12:14 +11:00
uniform mat4 projection;
2024-03-03 12:12:21 +11:00
layout (binding = 3) readonly buffer TransformBuffer
{
mat4 transforms[];
};
2024-02-23 19:23:18 +11:00
out VS_OUT {
vec3 normal;
vec4 colour;
vec3 pos;
vec2 tex_pos;
vec3 material;
} vout;
out flat sampler2D frag_tex;
2024-01-31 00:12:14 +11:00
void main()
{
2024-03-03 12:12:21 +11:00
mat4 m = (aTransformIndex >= 0.f ? transforms[int(aTransformIndex)] : mat4(1.f)) * model;
mat4 mvp = camera * m;
2024-02-23 19:23:18 +11:00
vec4 pos = mvp * aPos;
2024-03-03 12:12:21 +11:00
vout.normal = mat3(m) * aNormal;
vout.pos = (m * aPos).xyz;
2024-02-23 19:23:18 +11:00
vout.colour = aColour;
vout.tex_pos = aTexPos;
vout.material = aMaterial;
frag_tex = aTex;
2024-01-31 00:12:14 +11:00
gl_Position = projection * pos;
}