From 9900ffe840ee0e9f914b0e7956a4e80ffb553e9e Mon Sep 17 00:00:00 2001 From: talha Date: Tue, 16 Apr 2024 02:04:23 +0500 Subject: Added refraction, albeit slightly limited --- source/shaders/refr.fs.glsl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 source/shaders/refr.fs.glsl (limited to 'source/shaders/refr.fs.glsl') diff --git a/source/shaders/refr.fs.glsl b/source/shaders/refr.fs.glsl new file mode 100644 index 0000000..6747ded --- /dev/null +++ b/source/shaders/refr.fs.glsl @@ -0,0 +1,15 @@ +#version 330 core + +in vec3 Normal; +in vec3 Position; + +uniform samplerCube skybox; +uniform vec3 cameraPos; +out vec4 FragColor; + +void main() { + float refr_ratio = 1.0/1.52; + vec3 I = normalize(Position - cameraPos); + vec3 R = refract(I, normalize(Normal), refr_ratio); + FragColor = vec4(texture(skybox, R).rgb, 1.0); +}; -- cgit v1.2.3