Created
January 26, 2021 02:26
-
-
Save antoineMoPa/57166b4928c2952b874cd7e87d6a6aa0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 130 | |
// Some dead code for future reference. | |
uniform samplerCube p3d_Texture0; | |
uniform float time; | |
uniform vec3 camera_position; | |
// Input from vertex shader | |
in vec2 texcoord; | |
in vec4 screen_position; | |
in vec4 position; | |
in vec3 normal; | |
void main() { | |
vec4 col = vec4(0.0); | |
const float s = 8.0; | |
// Define some shortcuts | |
// Unused variable not cleaned up because this is dead code | |
vec3 p = position.xyz; // Position in 3D world | |
vec3 n = normal; // Normal vector | |
vec3 up = vec3(0.0,0.0,1.0); // Up vector | |
vec3 c = camera_position; | |
vec3 ws = (vec3(1.0)-abs(n)); // Window surface | |
vec3 wc = floor(p / s - 0.5) * s + s; // Window center position in 3D world | |
vec3 wr = -ws * (vec3(1.0) - up); // Window right vector | |
vec3 r = normalize(p-c); | |
col += textureCube(p3d_Texture0, cubeClamp(r/length(r)) + (p - wc)); | |
float windows = 1.0; | |
const float TAU = 6.2832; | |
const float f = TAU / s; | |
const float offset = 0; | |
windows *= mix(clamp(cos(position.x * f + offset)/0.1, 0.0,1.0), 1.0, abs(n.x)); | |
windows *= mix(clamp(cos(position.y * f + offset)/0.1, 0.0,1.0), 1.0, abs(n.y)); | |
windows *= clamp(cos(position.z * f + offset)/0.1, 0.0,1.0); | |
windows *= 1.0-abs(n.z); | |
col *= windows; | |
gl_FragColor = col; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment