Browse Source

Add model matrix, camera matrix to color and texture shader

master
Riyyi 4 years ago
parent
commit
4ff17823eb
  1. 0
      assets/glsl/color.frag
  2. 16
      assets/glsl/color.vert
  3. 12
      assets/glsl/simple.vert
  4. 3
      assets/glsl/texture.frag
  5. 11
      assets/glsl/texture.vert

0
assets/glsl/simple.frag → assets/glsl/color.frag

16
assets/glsl/color.vert

@ -0,0 +1,16 @@
#version 450 core
layout(location = 0) in vec3 a_position;
layout(location = 1) in vec4 a_color;
out vec4 v_color;
uniform mat4 u_projectionView;
uniform mat4 u_model;
void main()
{
v_color = a_color;
// Vclip = Camera projection * Camera view * Model transform * Vlocal
gl_Position = u_projectionView * u_model * vec4(a_position, 1.0f);
}

12
assets/glsl/simple.vert

@ -1,12 +0,0 @@
#version 450 core
layout(location = 0) in vec3 a_position;
layout(location = 1) in vec4 a_color;
out vec4 v_color;
void main()
{
v_color = a_color;
gl_Position = vec4(a_position, 1.0f);
}

3
assets/glsl/texture.frag

@ -2,11 +2,12 @@
layout(location = 0) out vec4 color; layout(location = 0) out vec4 color;
in vec4 v_color;
in vec2 v_texCoord; in vec2 v_texCoord;
uniform sampler2D u_texture; uniform sampler2D u_texture;
void main() void main()
{ {
color = texture(u_texture, v_texCoord); color = v_color * texture(u_texture, v_texCoord);
} }

11
assets/glsl/texture.vert

@ -1,12 +1,19 @@
#version 450 core #version 450 core
layout(location = 0) in vec3 a_position; layout(location = 0) in vec3 a_position;
layout(location = 1) in vec2 a_texCoord; layout(location = 1) in vec4 a_color;
layout(location = 2) in vec2 a_texCoord;
out vec4 v_color;
out vec2 v_texCoord; out vec2 v_texCoord;
uniform mat4 u_projectionView;
uniform mat4 u_model;
void main() void main()
{ {
v_color = a_color;
v_texCoord = a_texCoord; v_texCoord = a_texCoord;
gl_Position = vec4(a_position, 1.0f); // Vclip = Camera projection * Camera view * Model transform * Vlocal
gl_Position = u_projectionView * u_model * vec4(a_position, 1.0f);
} }

Loading…
Cancel
Save