Asset+Component+Render: Render quads in the world as 3D objects
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user