Created a testing skybox and got the reflection and refraction working.

This commit is contained in:
Zed A. Shaw 2026-09-04 15:17:42 -04:00
parent 4ee5058e82
commit 29f1606085
20 changed files with 56 additions and 28 deletions

View file

@ -0,0 +1,17 @@
#version 330 core
out vec4 FragColor;
in vec3 Normal;
in vec3 FragPos;
in vec2 TexCoords;
uniform vec3 cameraPos;
uniform samplerCube skybox;
void main()
{
float ratio = 1.0/1.52;
vec3 I = normalize(FragPos - cameraPos);
vec3 R = refract(I, normalize(Normal), ratio);
FragColor = vec4(texture(skybox, R).rgb, 1.0);
}

View file

@ -0,0 +1,21 @@
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aNormal;
layout (location = 2) in vec2 aTexCoords;
out vec3 FragPos;
out vec3 Normal;
out vec2 TexCoords;
out vec3 Position;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main()
{
Normal = mat3(transpose(inverse(model))) * aNormal;
FragPos = vec3(model * vec4(aPos, 1.0));
gl_Position = projection * view * vec4(FragPos, 1.0);
TexCoords = aTexCoords;
}