Mise à jour du dépôt en fonction du .gitignore

This commit is contained in:
Troispoils 2024-02-25 22:03:08 +01:00
parent 1f0f033fad
commit 4a59748e67
224 changed files with 6785 additions and 0 deletions

View file

@ -0,0 +1,8 @@
#version 330 core
in vec3 vertexColor;
out vec4 FragColor;
void main() {
FragColor = vec4(vertexColor, 1.0);
}

View file

@ -0,0 +1,14 @@
#version 330 core
layout (location = 0) in vec3 aPosition;
layout (location = 1) in vec3 aColor;
uniform mat4 view;
uniform mat4 projection;
out vec3 vertexColor;
void main() {
gl_Position = projection * view * vec4(aPosition, 1.0);
vertexColor = aColor;
}

View file

@ -0,0 +1,49 @@
#version 330 core
out vec4 FragColor;
//In order to calculate some basic lighting we need a few things per model basis, and a few things per fragment basis:
uniform vec3 objectColor; //The color of the object.
uniform vec3 lightColor; //The color of the light.
uniform vec3 lightPos; //The position of the light.
uniform vec3 viewPos; //The position of the view and/or of the player.
uniform vec4 lineColor;
uniform sampler2D texture0;
in vec3 Normal; //The normal of the fragment is calculated in the vertex shader.
in vec3 FragPos; //The fragment position.
in vec4 Color;
void main()
{
//The ambient color is the color where the light does not directly hit the object.
//You can think of it as an underlying tone throughout the object. Or the light coming from the scene/the sky (not the sun).
float ambientStrength = 1;
vec4 textureColor = Color;
vec3 ambient = ambientStrength * lightColor * textureColor;
//We calculate the light direction, and make sure the normal is normalized.
vec3 norm = normalize(Normal);
vec3 lightDir = normalize(lightPos - FragPos); //Note: The light is pointing from the light to the fragment
//The diffuse part of the phong model.
//This is the part of the light that gives the most, it is the color of the object where it is hit by light.
float diff = max(dot(norm, lightDir), 0.0); //We make sure the value is non negative with the max function.
vec3 diffuse = diff * lightColor;
//The specular light is the light that shines from the object, like light hitting metal.
//The calculations are explained much more detailed in the web version of the tutorials.
float specularStrength = 0.5;
vec3 viewDir = normalize(viewPos - FragPos);
vec3 reflectDir = reflect(-lightDir, norm);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 32); //The 32 is the shininess of the material.
vec3 specular = specularStrength * spec * lightColor;
//At last we add all the light components together and multiply with the color of the object. Then we set the color
//and makes sure the alpha value is 1
vec3 result = (ambient + diffuse + specular) * objectColor * textureColor;
FragColor = lineColor * vec4(result, 1.0);
//Note we still use the light color * object color from the last tutorial.
//This time the light values are in the phong model (ambient, diffuse and specular)
}

View file

@ -0,0 +1,17 @@
#version 330
out vec4 outputColor;
uniform vec3 viewPos;
in vec4 Color;
in vec4 FarColor;
in vec3 FragPos;
void main()
{
float distance = length(viewPos - FragPos);
float interpolationFactor = clamp(distance / 1000, 0.0, 1.0);
outputColor = mix(Color, FarColor, interpolationFactor);
}

View file

@ -0,0 +1,20 @@
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec4 aColor;
layout (location = 2) in vec4 aColorFar;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
out vec3 FragPos;
out vec4 Color;
out vec4 FarColor;
void main()
{
gl_Position = vec4(aPos, 1.0) * model * view * projection;
FragPos = vec3(vec4(aPos, 1.0) * model);
Color = aColor;
FarColor = aColorFar;
}