Architecture redesign
PART 1: - Added a Renderer class - Added a Application interface - Added a RenderPass interface - Added multiple RenderPass classes - Added a Window class - Moved Shaders into a Shader folder The idea behind this redesign is to make more abstractions. These abstraction are then supposedly going to make it easier to focus on the next couple tutorials main elements
This commit is contained in:
11
Shaders/Cubemap.fs
Normal file
11
Shaders/Cubemap.fs
Normal file
@ -0,0 +1,11 @@
|
||||
#version 460 core
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec3 TexCoords;
|
||||
uniform samplerCube cubemap;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = texture(cubemap, TexCoords);
|
||||
}
|
75
Shaders/Framebuffers.fs
Normal file
75
Shaders/Framebuffers.fs
Normal file
@ -0,0 +1,75 @@
|
||||
#version 460 core
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec2 TexCoords;
|
||||
|
||||
uniform sampler2D screenTexure;
|
||||
const float offset = 1.0/ 300.0;
|
||||
|
||||
void main(){
|
||||
FragColor = texture(screenTexure, TexCoords);
|
||||
|
||||
// Inversion filter
|
||||
//FragColor = vec4( vec3 (1.0 - texture(screenTexure, TexCoords) ), 1.0) ;
|
||||
|
||||
|
||||
//grayscale
|
||||
/*
|
||||
FragColor = texture(screenTexure, TexCoords);
|
||||
float average = (FragColor.r + FragColor.g + FragColor.b) / 3.0;
|
||||
FragColor = vec4(average, average, average, 1.0);
|
||||
*/
|
||||
|
||||
// physically accurate grayscale
|
||||
/* FragColor = texture(screenTexure, TexCoords);
|
||||
float average = 0.2126 * FragColor.r + 0.7152 * FragColor.g + 0.0722 * FragColor.b;
|
||||
FragColor = vec4(average,average,average, 1.0);*/
|
||||
|
||||
vec2 offset[9] = vec2[] (
|
||||
vec2(-offset, offset), // top-left
|
||||
vec2(0.0f, offset), // top-center
|
||||
vec2(offset, offset), // top-right
|
||||
vec2(-offset, 0.0f), // center-left
|
||||
vec2(0.0f, 0.0f), // center-center
|
||||
vec2(offset, 0.0f), // center-right
|
||||
vec2(-offset, -offset), // bottom-left
|
||||
vec2(0.0f, -offset), // bottom-center
|
||||
vec2(offset, -offset) // bottom-right
|
||||
);
|
||||
|
||||
// sharpen
|
||||
/*float kernel[9] = float[](
|
||||
-1, -1, -1,
|
||||
-1, 9, -1,
|
||||
-1, -1, -1
|
||||
);*/
|
||||
|
||||
// blur
|
||||
/* float kernel[9] = float[](
|
||||
1.0 /16, 2.0 /16, 1.0 /16,
|
||||
2.0 /16, 4.0 /16, 2.0 /16,
|
||||
1.0 /16, 2.0 /16, 1.0 /16
|
||||
);*/
|
||||
|
||||
// Edge-detection
|
||||
/* float kernel[9] = float[] (
|
||||
1, 1, 1,
|
||||
1, -8, 1,
|
||||
1, 1, 1
|
||||
);
|
||||
|
||||
vec3 sampleTex[9];
|
||||
for (int i= 0; i < 9; i++) {
|
||||
sampleTex[i] = vec3(texture(screenTexure, TexCoords.st + offset[i]));
|
||||
}
|
||||
|
||||
vec3 col = vec3(0.0);
|
||||
for (int i = 0; i < 9; i++) {
|
||||
col += sampleTex[i] * kernel[i];
|
||||
}
|
||||
|
||||
FragColor = vec4(col, 1.0);
|
||||
*/
|
||||
|
||||
|
||||
}
|
12
Shaders/Framebuffers.vs
Normal file
12
Shaders/Framebuffers.vs
Normal file
@ -0,0 +1,12 @@
|
||||
#version 460 core
|
||||
layout (location = 0) in vec2 aPos;
|
||||
layout (location = 1) in vec2 aTexCoords;
|
||||
|
||||
|
||||
out vec2 TexCoords;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(aPos, 0.0f, 1.0f);
|
||||
TexCoords = aTexCoords;
|
||||
}
|
7
Shaders/lightsource.fs
Normal file
7
Shaders/lightsource.fs
Normal file
@ -0,0 +1,7 @@
|
||||
#version 460 core
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = vec4(1.0);
|
||||
}
|
14
Shaders/lightsource.vs
Normal file
14
Shaders/lightsource.vs
Normal file
@ -0,0 +1,14 @@
|
||||
#version 460 core
|
||||
layout (location=0) in vec3 aPos;
|
||||
|
||||
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
|
||||
|
||||
void main(){
|
||||
|
||||
gl_Position = projection * view * model * vec4(aPos , 1.0);
|
||||
|
||||
}
|
13
Shaders/outlineshader.fs
Normal file
13
Shaders/outlineshader.fs
Normal file
@ -0,0 +1,13 @@
|
||||
#version 460 core
|
||||
uniform vec3 outlineColor;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
|
||||
in vec2 texCoords;
|
||||
uniform sampler2D texture_diffuse1;
|
||||
|
||||
|
||||
void main(){
|
||||
FragColor = vec4(outlineColor, 1.0);
|
||||
}
|
38
Shaders/shader.fs
Normal file
38
Shaders/shader.fs
Normal file
@ -0,0 +1,38 @@
|
||||
#version 460 core
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec3 Normal;
|
||||
in vec3 Position;
|
||||
|
||||
uniform vec3 cameraPos;
|
||||
uniform samplerCube skybox;
|
||||
|
||||
in vec2 TexCoords;
|
||||
uniform sampler2D texture_diffuse1;
|
||||
|
||||
const float air_ri = 1.00;
|
||||
const float water_ri = 1.33;
|
||||
const float Ice_ri = 1.309;
|
||||
const float glass_ri = 1.52;
|
||||
const float diamond_ri = 2.42;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Regular shading
|
||||
vec4 albeno = texture( texture_diffuse1, TexCoords) ;
|
||||
|
||||
|
||||
// Reflective shading
|
||||
vec3 I = normalize(Position - cameraPos);
|
||||
vec3 R = reflect(I, normalize(Normal));
|
||||
|
||||
vec4 reflections = vec4(texture(skybox,R).rgb, 1.0);
|
||||
|
||||
// Refractive shading
|
||||
float ratio = air_ri/diamond_ri;
|
||||
vec3 I2 = normalize(Position-cameraPos);
|
||||
vec3 R2 = refract(I2, normalize(Normal), ratio);
|
||||
vec4 refractions = vec4(texture(skybox, R2).rgb, 1.0);
|
||||
|
||||
FragColor = vec4(albeno.rgb + (refractions.rgb * 0.5) + (reflections.rgb * 0.8), 1.0);
|
||||
}
|
22
Shaders/shader.vs
Normal file
22
Shaders/shader.vs
Normal file
@ -0,0 +1,22 @@
|
||||
#version 460 core
|
||||
layout (location=0) in vec3 aPos;
|
||||
layout (location=1) in vec3 aNormal;
|
||||
layout (location=2) in vec2 aTexCoords;
|
||||
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
|
||||
out vec2 TexCoords;
|
||||
out vec3 Normal;
|
||||
out vec3 Position;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
Normal = mat3(transpose(inverse(model))) * aNormal;
|
||||
Position = vec3(model* vec4(aPos, 1.0));
|
||||
|
||||
TexCoords = aTexCoords;
|
||||
gl_Position = projection * view * model * vec4(aPos , 1.0);
|
||||
}
|
13
Shaders/skybox.vs
Normal file
13
Shaders/skybox.vs
Normal file
@ -0,0 +1,13 @@
|
||||
#version 460 core
|
||||
layout (location = 0) in vec3 aPos;
|
||||
|
||||
out vec3 TexCoords;
|
||||
|
||||
uniform mat4 projection;
|
||||
uniform mat4 view;
|
||||
|
||||
void main()
|
||||
{
|
||||
TexCoords = aPos;
|
||||
gl_Position = projection * view * vec4(aPos ,1.0);
|
||||
}
|
Reference in New Issue
Block a user