First commit
This commit is contained in:
commit
58c64ab472
62 changed files with 29291 additions and 0 deletions
5
res/shaders/light.frag
Normal file
5
res/shaders/light.frag
Normal file
|
@ -0,0 +1,5 @@
|
|||
#version 330
|
||||
|
||||
void main(){
|
||||
|
||||
}
|
1
res/shaders/light.vert
Normal file
1
res/shaders/light.vert
Normal file
|
@ -0,0 +1 @@
|
|||
#version 330
|
2
res/shaders/light_ambient.frag
Normal file
2
res/shaders/light_ambient.frag
Normal file
|
@ -0,0 +1,2 @@
|
|||
#version 330
|
||||
#include "main.frag"
|
1
res/shaders/light_ambient.vert
Normal file
1
res/shaders/light_ambient.vert
Normal file
|
@ -0,0 +1 @@
|
|||
#version 330
|
38
res/shaders/main.frag
Normal file
38
res/shaders/main.frag
Normal file
|
@ -0,0 +1,38 @@
|
|||
#version 330
|
||||
|
||||
in vec4 color;
|
||||
in vec3 normal;
|
||||
in vec2 out_coord_texture;
|
||||
uniform sampler2D myTexture;
|
||||
|
||||
uniform vec3 light_direction;
|
||||
uniform vec4 diffuse_light_color;
|
||||
uniform vec4 ambient_light;
|
||||
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
void main(){
|
||||
vec3 lightDir;
|
||||
float lightIntensity;
|
||||
|
||||
// Set the default output color to the ambient light value for all pixels.
|
||||
vec4 color1 = color * ambient_light;
|
||||
|
||||
// Invert the light direction for calculations.
|
||||
lightDir = -light_direction;
|
||||
|
||||
// Calculate the amount of light on this pixel.
|
||||
lightIntensity = clamp(dot(normal, lightDir), 0.0f, 1.0f);
|
||||
|
||||
if(lightIntensity > 0.0f)
|
||||
{
|
||||
// Determine the final diffuse color based on the diffuse color and the amount of light intensity.
|
||||
color1 += (diffuse_light_color * lightIntensity);
|
||||
}
|
||||
|
||||
// Clamp the final light color.
|
||||
color1 = clamp(color1, 0.0f, 1.0f);
|
||||
|
||||
frag_color = color1 * texture2D(myTexture,out_coord_texture);
|
||||
}
|
23
res/shaders/main.vert
Normal file
23
res/shaders/main.vert
Normal file
|
@ -0,0 +1,23 @@
|
|||
#version 330
|
||||
#include "light.vert"
|
||||
layout (location = 0) in vec3 in_position;
|
||||
layout (location = 1) in vec4 in_color;
|
||||
layout (location = 2) in vec2 in_coord_texture;
|
||||
layout (location = 3) in vec3 in_normal;
|
||||
|
||||
uniform mat4 transform;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 camera;
|
||||
|
||||
|
||||
out vec4 color;
|
||||
out vec3 normal;
|
||||
out vec2 out_coord_texture;
|
||||
|
||||
void main(){
|
||||
color = in_color;
|
||||
out_coord_texture = in_coord_texture;
|
||||
normal = mat3(transform) * in_normal;
|
||||
normal = normalize(normal);
|
||||
gl_Position = projection * camera * transform * vec4(in_position,1.0f);
|
||||
}
|
Reference in a new issue