Nigel
4355a12b9a
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
38 lines
914 B
GLSL
38 lines
914 B
GLSL
#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);
|
|
} |