This repository has been archived on 2020-09-30. You can view files and clone it, but cannot push or open issues or pull requests.
odyssey-old/Graphics/IngameSpace.shader

46 lines
1.7 KiB
GLSL

shader_type canvas_item;
uniform sampler2D noise_sparse;
uniform sampler2D noise_fine;
uniform float scroll_speed = 0.0;
uniform float warp_boost: hint_range(1, 10) = 1.0;
uniform float warp_opacity : hint_range(0, 1) = 0.0;
const float noise_sparse_scale = 0.0007;
const float noise_fine_scale = 0.003;
const float warp_clouds_scale = 0.0003;
const vec2 scroll_dir = vec2(1,0);
const vec2 blink_scroll = vec2(50.0, 0);
const float PI = 3.1415;
render_mode unshaded;
void fragment() {
float scroll = scroll_speed * TIME;
float sparse = texture(noise_sparse, (FRAGCOORD.xy + scroll_dir * scroll)*noise_sparse_scale).r;
sparse = ((sparse * sparse) - 0.2) * 1.2;
float fine = texture(noise_fine, (FRAGCOORD.xy + scroll_dir * scroll)*noise_fine_scale).r;
fine = fine - 0.6;
if (fine > 0.) {
fine = fine * 10.0;
}
if (fine > 0.3) {
float fine_blink_fade = texture(noise_sparse, (FRAGCOORD.xy + blink_scroll*TIME)*noise_sparse_scale).r;
fine = fine - ((fine_blink_fade * fine_blink_fade) - 0.2) * 1.2;
}
vec4 clouds = vec4(vec3(0.3, 0.5, 0.7) * sparse, 1.0);
vec4 stars = vec4(fine);
vec2 warp_scroll = scroll_dir * scroll;
vec2 warp_uv = (FRAGCOORD.xy * sin(SCREEN_UV.y * PI) + warp_scroll)*warp_clouds_scale;
vec2 warp_uv_inv = (FRAGCOORD.xy * sin((abs(SCREEN_UV.y-0.5)) * SCREEN_UV.x * PI) + warp_scroll*0.5)*warp_clouds_scale;
float warp_clouds_sparse = texture(noise_sparse, vec2(0.5,1) * warp_uv).r;
float warp_clouds_fine = texture(noise_sparse, vec2(2,1) * warp_uv_inv).r;
vec4 warp = vec4(vec3(0), 1);
warp += vec4(vec3(0.3,0.2,0.9)*warp_clouds_sparse, 0);
warp += vec4(vec3(0.5,0.0,0.5)*(warp_clouds_fine*0.5+warp_clouds_sparse)*abs(SCREEN_UV.y-0.5), 0);
COLOR = mix(clouds + stars, warp*warp_boost, warp_opacity);
}