rename shaders to .glsl
This commit is contained in:
57
fragmentshader.glsl
Normal file
57
fragmentshader.glsl
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
#version 460 core
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
struct Material {
|
||||||
|
//sampler2D diffuse;
|
||||||
|
//sampler2D specular;
|
||||||
|
float shininess;
|
||||||
|
vec3 color;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Light {
|
||||||
|
vec3 position;
|
||||||
|
vec3 direction;
|
||||||
|
float largecutoff;
|
||||||
|
float smallcutoff;
|
||||||
|
|
||||||
|
vec3 ambient;
|
||||||
|
vec3 diffuse;
|
||||||
|
vec3 specular;
|
||||||
|
};
|
||||||
|
|
||||||
|
in vec3 FragPos;
|
||||||
|
in vec3 Normal;
|
||||||
|
|
||||||
|
uniform vec3 viewPos;
|
||||||
|
uniform Material material;
|
||||||
|
uniform Light light;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec3 lightDir = normalize(light.position - FragPos);
|
||||||
|
|
||||||
|
// check if lighting is inside the spotlight cone
|
||||||
|
float theta = dot(lightDir, normalize(-light.direction));
|
||||||
|
|
||||||
|
float co = clamp((theta - light.largecutoff) / (light.smallcutoff - light.largecutoff), 0.0, 1.0);
|
||||||
|
// diffuse
|
||||||
|
vec3 norm = normalize(Normal);
|
||||||
|
float diff = max(dot(norm, lightDir), 0.0);
|
||||||
|
vec3 diffuse = light.diffuse * diff * material.color * co;
|
||||||
|
|
||||||
|
// specular
|
||||||
|
vec3 viewDir = normalize(viewPos - FragPos);
|
||||||
|
vec3 reflectDir = reflect(-lightDir, norm);
|
||||||
|
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
|
||||||
|
vec3 specular = light.specular * spec * material.color * co;
|
||||||
|
|
||||||
|
// attenuation
|
||||||
|
float distance = length(light.position - FragPos);
|
||||||
|
float atten = 1.0 / (1.0 + 0.1 * distance + 0.01 * (distance * distance));
|
||||||
|
|
||||||
|
diffuse *= atten;
|
||||||
|
specular *= atten;
|
||||||
|
|
||||||
|
vec3 result = light.ambient + diffuse + specular;
|
||||||
|
FragColor = vec4(result, 1.0);
|
||||||
|
}
|
||||||
11
trailfragshader.glsl
Normal file
11
trailfragshader.glsl
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#version 460 core
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
in vec3 FragPos;
|
||||||
|
|
||||||
|
uniform vec3 objectcolor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
FragColor = vec4(objectcolor, 1.0);
|
||||||
|
}
|
||||||
15
trailshader.glsl
Normal file
15
trailshader.glsl
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#version 460 core
|
||||||
|
layout (location = 0) in vec3 aPos;
|
||||||
|
|
||||||
|
out vec3 FragPos;
|
||||||
|
|
||||||
|
uniform mat4 model;
|
||||||
|
uniform mat4 view;
|
||||||
|
uniform mat4 projection;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
FragPos = vec3(model * vec4(aPos, 1.0));
|
||||||
|
|
||||||
|
gl_Position = projection * view * vec4(FragPos, 1.0);
|
||||||
|
}
|
||||||
18
vertexshader.glsl
Normal file
18
vertexshader.glsl
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#version 460 core
|
||||||
|
layout (location = 0) in vec3 aPos;
|
||||||
|
layout (location = 1) in vec3 aNormal;
|
||||||
|
|
||||||
|
out vec3 FragPos;
|
||||||
|
out vec3 Normal;
|
||||||
|
|
||||||
|
uniform mat4 model;
|
||||||
|
uniform mat4 view;
|
||||||
|
uniform mat4 projection;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
FragPos = vec3(model * vec4(aPos, 1.0));
|
||||||
|
Normal = mat3(transpose(inverse(model))) * aNormal;
|
||||||
|
|
||||||
|
gl_Position = projection * view * vec4(FragPos, 1.0);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user