Asset+Component+Render: Render quads in the world as 3D objects

This commit is contained in:
Riyyi
2024-08-11 22:06:55 +02:00
parent b2ed951b1e
commit dcf2a85208
12 changed files with 59 additions and 30 deletions
@@ -9,16 +9,11 @@ out vec4 v_color;
out vec2 v_textureCoordinates;
out flat uint v_textureIndex;
layout(std140, binding = 0) uniform Camera
{
mat4 u_projectionView;
};
void main()
{
v_color = a_color;
v_textureCoordinates = a_textureCoordinates;
v_textureIndex = a_textureIndex;
// Vclip = Camera projection * Camera view * Model transform * Vlocal
gl_Position = u_projectionView * vec4(a_position, 1.0f);
// Vclip = Model transform * Vlocal
gl_Position = vec4(a_position, 1.0f);
}
+2 -1
View File
@@ -3,6 +3,7 @@
layout(location = 0) out vec4 color;
in vec3 v_normal;
in vec4 v_color;
in vec2 v_textureCoordinates;
in flat uint v_textureIndex;
@@ -10,7 +11,7 @@ uniform sampler2D u_textures[32];
void main()
{
vec4 textureColor = vec4(1.0f);
vec4 textureColor = v_color;
switch(v_textureIndex) {
case 0: break; // Texture unit 0 is reserved for no texture
case 1: textureColor *= texture(u_textures[1], v_textureCoordinates); break;
+5 -2
View File
@@ -2,10 +2,12 @@
layout(location = 0) in vec3 a_position;
layout(location = 1) in vec3 a_normal;
layout(location = 2) in vec2 a_textureCoordinates;
layout(location = 3) in uint a_textureIndex;
layout(location = 2) in vec4 a_color;
layout(location = 3) in vec2 a_textureCoordinates;
layout(location = 4) in uint a_textureIndex;
out vec3 v_normal;
out vec4 v_color;
out vec2 v_textureCoordinates;
out flat uint v_textureIndex;
@@ -17,6 +19,7 @@ layout(std140, binding = 0) uniform Camera
void main()
{
v_normal = a_normal;
v_color = a_color;
v_textureCoordinates = a_textureCoordinates;
v_textureIndex = a_textureIndex;
// Vclip = Camera projection * Camera view * Model transform * Vlocal