feat: implemented default shader

This commit is contained in:
Sara 2024-09-17 21:37:13 +02:00
parent fdc92c8c20
commit a0be00407f
10 changed files with 129 additions and 19 deletions

View file

@ -0,0 +1,20 @@
#version 330
in vec2 fragTexCoord; // texture coordinate
in vec3 fragNormal; // normal direction
uniform sampler2D texture0;
uniform vec4 colDiffuse;
out vec4 finalColor;
uniform vec3 lightDirection; // direction of light
uniform vec4 ambient;
void main() {
vec4 texelColor = texture(texture0, fragTexCoord);
vec3 light_dot = vec3(pow(dot(fragNormal, lightDirection)-0.2, 3.0));
finalColor = texelColor * colDiffuse * vec4(light_dot, 1.0);
finalColor += texelColor * (ambient/10.0) * colDiffuse;
finalColor = pow(finalColor, vec4(vec3(0.6), 1.0));
}

View file

@ -0,0 +1,25 @@
#version 330
// Input vertex attributes
in vec3 vertexPosition;
in vec2 vertexTexCoord;
in vec3 vertexNormal;
in vec4 vertexColor;
// Input uniform values
uniform mat4 mvp;
uniform mat4 matModel;
// Output vertex attributes (to fragment shader)
out vec2 fragTexCoord;
out vec3 fragNormal;
void main()
{
// Send vertex attributes to fragment shader
fragTexCoord = vertexTexCoord;
fragNormal = normalize(vec3(matModel * vec4(vertexNormal, 1.0)));
// Calculate final vertex position
gl_Position = mvp*vec4(vertexPosition, 1.0);
}

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 496 B