Initial commit - restart from existing code
This commit is contained in:
16
assets/shaders/basicColor/basicColor.frag
Normal file
16
assets/shaders/basicColor/basicColor.frag
Normal file
@@ -0,0 +1,16 @@
|
||||
#version 330 core
|
||||
// The result : color of the fragment.
|
||||
out vec4 FragColor;
|
||||
|
||||
|
||||
// The input variable from the vertex shader (same name and same type).
|
||||
in vec3 color;
|
||||
uniform float intensity;
|
||||
uniform vec4 colorDiffuse0; // Input Color.
|
||||
|
||||
void main() {
|
||||
|
||||
vec3 ambient = vec3(0.7333, 0.7333, 0.7333);
|
||||
vec3 diffuse = color;
|
||||
FragColor = intensity * vec4(ambient + diffuse, 1.0)*colorDiffuse0;
|
||||
}
|
||||
30
assets/shaders/basicColor/basicColor.vert
Normal file
30
assets/shaders/basicColor/basicColor.vert
Normal file
@@ -0,0 +1,30 @@
|
||||
#version 330 core
|
||||
// Input : vertex attributes.
|
||||
layout (location = 0) in vec3 aPos; // Position of the vertex.
|
||||
layout (location = 1) in vec3 aNormal; // Normal of the vertex.
|
||||
layout (location = 2) in vec2 aTexCoords; // Texture coordonate of the vertex.
|
||||
layout (location = 3) in vec3 aTangent; // Texture coordonate of the vertex.
|
||||
layout (location = 4) in vec3 aBitangent; // Texture coordonate of the vertex.
|
||||
|
||||
// The result : color of the fragment.
|
||||
out vec3 color;
|
||||
|
||||
// Uniform input variable.
|
||||
uniform mat4 projection; // Projection of the camera.
|
||||
uniform mat4 model; // Transforms transformation.
|
||||
uniform mat4 view; // View transformation of the camera.
|
||||
uniform vec3 lightPos;
|
||||
|
||||
void main() {
|
||||
|
||||
gl_Position = projection * view * model * vec4(aPos, 1.0);
|
||||
vec4 newPos = model * vec4(aPos, 1.0);
|
||||
// vec4 newNormal = model * vec4(aNormal, 1.0);
|
||||
vec3 newPos3 = newPos.xyz;
|
||||
// vec3 newNormal3 = newNormal.xyz;
|
||||
vec3 newNormal3 = mat3(transpose(inverse(model))) * aNormal;
|
||||
vec3 lightVec = vec3(normalize((lightPos - newPos3)));
|
||||
float diffuse = dot(lightVec, newNormal3);
|
||||
//color = vec3(1,1,1);
|
||||
color = vec3(diffuse);
|
||||
}
|
||||
Reference in New Issue
Block a user