frame-of-mind/src/base-environments/youth_room/shaders/starlight_shader.gdshader

38 lines
1.5 KiB
Plaintext
Raw Normal View History

2023-07-01 17:51:17 +00:00
shader_type spatial;
2023-07-05 21:18:06 +00:00
render_mode blend_add, specular_disabled;
2023-07-01 17:51:17 +00:00
2023-07-05 21:18:06 +00:00
uniform float nebula_brightness = 4;
uniform vec2 nebula_scale = vec2(1.5);
2023-07-01 17:51:17 +00:00
uniform sampler2D starlight_noise;
uniform sampler2D starlight_textures;
2023-07-05 21:18:06 +00:00
uniform float rotation_speed = 0.05;
uniform vec2 rotation_pivot = vec2(.8);
uniform vec2 drift_compensation = vec2(0.1, -0.2);
uniform float noise_strength = 0.2;
// https://gist.github.com/ayamflow/c06bc0c8a64f985dd431bd0ac5b557cd
vec2 rotateUV(vec2 uv, vec2 pivot, float rotation)
{
return vec2(
cos(rotation) * (uv.x - pivot.x) + sin(rotation) * (uv.y - pivot.y) + pivot.x,
cos(rotation) * (uv.y - pivot.y) - sin(rotation) * (uv.x - pivot.x) + pivot.y
);
}
//clamp(, .0, 1.0
2023-07-01 17:51:17 +00:00
void fragment() {
2023-07-05 21:18:06 +00:00
ALBEDO = vec3(.0,
texture(starlight_textures,UV).x * max(sin(TIME + 10.0 * texture(starlight_textures,UV).y), .0),
texture(starlight_textures,
clamp(
UV / nebula_scale + drift_compensation + 1.0 *
texture(starlight_noise, rotateUV(
UV / nebula_scale + noise_strength * texture(starlight_noise, rotateUV(UV, -rotation_pivot, TIME*rotation_speed)).yx,
rotation_pivot, TIME*rotation_speed)
).xz,
.0, 1.0))
.z * nebula_brightness);
SPECULAR = 0.0;
2023-07-01 17:51:17 +00:00
}