duizeligheidsimulator

This commit is contained in:
2024-06-16 17:42:02 +02:00
parent dc2e10db3a
commit 43d66884fe
6 changed files with 88 additions and 34 deletions
+12 -27
View File
@@ -1,35 +1,20 @@
shader_type sky;
uniform sampler2D base;
uniform vec3 base_color : source_color;
uniform float base_speed : hint_range(0,1) = 0.1;
uniform float speed : hint_range(0, 0.1) = 0.05;
uniform float brightness : hint_range(0, 1) = 0.1;
uniform sampler2D layers[10];
uniform sampler2D layer;
uniform sampler2D layer_two;
const vec2 speeds[10] = { vec2(-0.9, 0.8), vec2(-0.4, -0.1), vec2(3.03, 2.0), vec2(2.1, 0.2), vec2(0, 0), vec2(0.1, 0), vec2(-0.1, 0), vec2(0.03, 0), vec2(-0.01, 0), vec2(0, 0) };
uniform float NOISE : hint_range(0,1) = 0.5;
float random(vec2 coords) {
return fract(sin(dot(coords.xy, vec2(12.9898,78.233))) * 43758.5453);
vec3 layer(sampler2D layer, vec2 direction, vec2 sky_coords) {
vec2 coords = vec2(sky_coords.x + TIME*speed*direction.x, sky_coords.y + TIME*speed*direction.y);
vec4 pixel = texture(layer, coords);
return pixel.rgb * pixel.a * pixel.a * brightness;
}
void sky() {
float NOISE_GRANULARITY = NOISE / 100.0;
vec2 base_coords = vec2(SKY_COORDS.x+TIME*base_speed*0.05, SKY_COORDS.y);
vec4 base_pix = texture(base, base_coords);
float noise = mix(-NOISE_GRANULARITY, NOISE_GRANULARITY, random(base_coords));
float base_alpha = base_pix.a;
//if (base_alpha < 0.01 && base_alpha > 0.0) {
//base_alpha += noise;
//}
vec2 star_coords = vec2(SKY_COORDS.x-TIME*base_speed*0.05, SKY_COORDS.y);
vec4 star_pix = texture(layer_two, star_coords)*0.5;
vec2 galaxy_coords = vec2(SKY_COORDS.x-TIME*base_speed*0.01, SKY_COORDS.y);
vec4 galaxy_pix = max(vec4(0,0,0,0),texture(layer, galaxy_coords));
COLOR = vec3(0,0,0) + star_pix.rgb * star_pix.a + base_pix.rgb * base_alpha + + galaxy_pix.rgb * galaxy_pix.a;
// Called for every visible pixel in the sky background, as well as all pixels
// in the radiance cubemap.
COLOR = vec3(0,0,0);
for (int i = 0; i < layers.length(); i++) {
COLOR += layer(layers[i], speeds[i], SKY_COORDS);
}
}