m
This commit is contained in:
commit
2321d0405d
25
grk/cw 6/shaders/shader_5_sun.frag
Normal file
25
grk/cw 6/shaders/shader_5_sun.frag
Normal file
@ -0,0 +1,25 @@
|
||||
#version 430 core
|
||||
|
||||
float AMBIENT = 0.1;
|
||||
|
||||
uniform vec3 color;
|
||||
uniform vec3 lightPos;
|
||||
|
||||
|
||||
in vec3 vecNormal;
|
||||
in vec3 worldPos;
|
||||
in vec2 vtc;
|
||||
|
||||
out vec4 outColor;
|
||||
|
||||
uniform sampler2D colorTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 lightDir = normalize(lightPos - worldPos);
|
||||
vec3 normal = normalize(vecNormal);
|
||||
float diffuse = max(0, dot(normal, lightDir));
|
||||
|
||||
vec4 textureColor = texture2D(colorTexture, vtc);
|
||||
outColor = vec4(vec3(textureColor) * min(1, AMBIENT + diffuse), 1.0) * 7.0;
|
||||
}
|
22
grk/cw 6/shaders/shader_5_sun.vert
Normal file
22
grk/cw 6/shaders/shader_5_sun.vert
Normal file
@ -0,0 +1,22 @@
|
||||
#version 430 core
|
||||
|
||||
layout(location = 0) in vec3 vertexPosition;
|
||||
layout(location = 1) in vec3 vertexNormal;
|
||||
layout(location = 2) in vec2 vertexTexCoord;
|
||||
|
||||
uniform mat4 transformation;
|
||||
uniform mat4 modelMatrix;
|
||||
|
||||
out vec3 vecNormal;
|
||||
out vec3 worldPos;
|
||||
out vec2 vtc;
|
||||
|
||||
void main()
|
||||
{
|
||||
worldPos = (modelMatrix * vec4(vertexPosition, 1)).xyz;
|
||||
vecNormal = (modelMatrix * vec4(vertexNormal, 1)).xyz;
|
||||
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
||||
|
||||
//vtc = vec2(vertexTexCoord.x, 1.0 - vertexTexCoord.y);
|
||||
vtc = vertexTexCoord;
|
||||
}
|
@ -374,6 +374,7 @@ void init(GLFWwindow* window)
|
||||
programSun = shaderLoader.CreateProgram("shaders/shader_sun.vert", "shaders/shader_sun.frag");
|
||||
programDepth = shaderLoader.CreateProgram("shaders/shader_smap.vert", "shaders/shader_smap.frag");
|
||||
//programTest = shaderLoader.CreateProgram("shaders/test.vert", "shaders/test.frag");
|
||||
programSun = shaderLoader.CreateProgram("shaders/shader_5_sun.vert", "shaders/shader_5_sun.frag");
|
||||
|
||||
loadModelToContext("./models/sphere.obj", sphereContext);
|
||||
loadModelToContext("./models/spaceship.obj", shipContext);
|
||||
|
Loading…
Reference in New Issue
Block a user