mirror of
https://github.com/Ed94/DuctTaped_GL.git
synced 2025-07-01 09:21:02 -07:00
Translated to standard c++ after big clean of adhesive from non-standard branch
This commit is contained in:
14
Shaders/BasicLight.frag
Normal file
14
Shaders/BasicLight.frag
Normal file
@ -0,0 +1,14 @@
|
||||
#version 330 core
|
||||
|
||||
|
||||
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = vec4(1.0); // set all 4 vector values to 1.0
|
||||
}
|
14
Shaders/BasicLight.vert
Normal file
14
Shaders/BasicLight.vert
Normal file
@ -0,0 +1,14 @@
|
||||
#version 330 core
|
||||
|
||||
layout (location = 0) in vec3 aPos;
|
||||
|
||||
|
||||
|
||||
uniform mat4 ScreenSpaceTransform;
|
||||
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ScreenSpaceTransform * vec4(aPos, 1.0);
|
||||
}
|
48
Shaders/PhongShader.frag
Normal file
48
Shaders/PhongShader.frag
Normal file
@ -0,0 +1,48 @@
|
||||
#version 330 core
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec3 FragPosition ;
|
||||
in vec3 Normal ;
|
||||
in vec3 LightViewPosition;
|
||||
|
||||
uniform vec3 ObjectColor ;
|
||||
uniform vec3 LightColor ;
|
||||
|
||||
uniform float AmbientStrength ;
|
||||
uniform float DiffuseStrength ;
|
||||
uniform float SpecularStrength;
|
||||
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
// Ambient
|
||||
|
||||
vec3 ambient = AmbientStrength * LightColor ;
|
||||
|
||||
// Diffuse
|
||||
|
||||
vec3 direction = normalize(Normal );
|
||||
vec3 lightDirection = normalize(LightViewPosition - FragPosition);
|
||||
|
||||
float diffuseMagnitude = max(dot(direction, lightDirection), 0.0);
|
||||
|
||||
vec3 diffuse = DiffuseStrength * diffuseMagnitude * LightColor;
|
||||
|
||||
// Specular
|
||||
|
||||
vec3 viewDirection = normalize(-FragPosition);
|
||||
|
||||
vec3 reflectionDirection = reflect(-lightDirection, direction);
|
||||
|
||||
float spec = pow(max(dot(viewDirection, reflectionDirection), 0.0), 32);
|
||||
|
||||
vec3 specular = SpecularStrength * spec * LightColor;
|
||||
|
||||
// Combining
|
||||
|
||||
vec3 result = (ambient + diffuse + specular) * ObjectColor;
|
||||
|
||||
FragColor = vec4(result, 1.0);
|
||||
}
|
34
Shaders/PhongShader.vert
Normal file
34
Shaders/PhongShader.vert
Normal file
@ -0,0 +1,34 @@
|
||||
#version 330 core
|
||||
|
||||
#define VertexIndex 0
|
||||
#define NormalIndex 1
|
||||
#define TextureIndex 2
|
||||
|
||||
layout (location = VertexIndex ) in vec3 VertPosition;
|
||||
layout (location = NormalIndex ) in vec3 VertNormal ;
|
||||
layout (location = TextureIndex) in vec3 VertTexture ;
|
||||
|
||||
out vec3 FragPosition ;
|
||||
out vec3 Normal ;
|
||||
out vec3 LightViewPosition;
|
||||
|
||||
uniform mat4 InverseModelSpace;
|
||||
|
||||
uniform mat4 ModelSpace;
|
||||
uniform mat4 Viewport ;
|
||||
uniform mat4 Projection;
|
||||
|
||||
uniform vec3 LightPosition;
|
||||
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = Projection * Viewport * ModelSpace * vec4(VertPosition, 1.0);
|
||||
|
||||
FragPosition = vec3(Viewport * ModelSpace * vec4(VertPosition, 1.0));
|
||||
|
||||
Normal = mat3(transpose(InverseModelSpace)) * VertNormal;
|
||||
|
||||
LightViewPosition = vec3(Viewport * vec4(LightPosition, 1.0));
|
||||
}
|
Reference in New Issue
Block a user