copy from thegates-jam repo

This commit is contained in:
Nordup 2024-03-31 09:25:42 +04:00
parent c1a7ad74e1
commit 1a335de566
523 changed files with 22408 additions and 0 deletions

View file

@ -0,0 +1,21 @@
[gd_resource type="Sky" load_steps=5 format=3 uid="uid://jonn5eom7asv"]
[ext_resource type="Shader" path="res://defaults/sky/sky.gdshader" id="1_nntdr"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_p7i03"]
noise_type = 0
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_bkjhb"]
seamless = true
noise = SubResource("FastNoiseLite_p7i03")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gu028"]
shader = ExtResource("1_nntdr")
shader_parameter/top_color = Color(0.164706, 0.541176, 0.823529, 1)
shader_parameter/bottom_color = Color(0.215686, 0.109804, 0.623529, 1)
shader_parameter/sun_scatter = Color(0.529412, 0.8, 1, 1)
shader_parameter/star_stength = 0.0
shader_parameter/clouds_sampler = SubResource("NoiseTexture2D_bkjhb")
[resource]
sky_material = SubResource("ShaderMaterial_gu028")

69
defaults/sky/sky.gdshader Normal file
View file

@ -0,0 +1,69 @@
shader_type sky;
uniform sampler2D clouds_sampler : filter_linear_mipmap;
uniform vec3 top_color : source_color = vec3(1.0);
uniform vec3 bottom_color : source_color = vec3(1.0);
const float sun_radius = 0.08;
uniform vec3 sun_scatter : source_color = vec3(1.0);
uniform float star_stength : hint_range(0.0, 5.0, 0.1) = 0.0;
// Voronoi method credit:
// The MIT License
// Copyright © 2013 Inigo Quilez
// https://www.shadertoy.com/view/ldl3Dl
vec3 hash( vec3 x ){
x = vec3( dot(x,vec3(127.1,311.7, 74.7)),
dot(x,vec3(269.5,183.3,246.1)),
dot(x,vec3(113.5,271.9,124.6)));
return fract(sin(x)*43758.5453123);
}
vec3 voronoi( in vec3 x ){
vec3 p = floor( x );
vec3 f = fract( x );
float id = 0.0;
vec2 res = vec2( 100.0 );
for( int k=-1; k<=1; k++ )
for( int j=-1; j<=1; j++ )
for( int i=-1; i<=1; i++ ) {
vec3 b = vec3( float(i), float(j), float(k) );
vec3 r = vec3( b ) - f + hash( p + b );
float d = dot( r, r );
if( d < res.x ) {
id = dot( p+b, vec3(1.0,57.0,113.0 ) );
res = vec2( d, res.x );
} else if( d < res.y ) {
res.y = d;
}
}
return vec3( sqrt( res ), abs(id) );
}
void sky() {
float clamped_light_y = clamp(LIGHT0_DIRECTION.y, 0.0, 1.0);
vec3 sky_gradient = mix(bottom_color.rgb, top_color.rgb, clamp(EYEDIR.y, 0.0, 1.0));
float sun_position = distance(EYEDIR.xyz, LIGHT0_DIRECTION);
float sun_mask_edge = smoothstep(sun_radius, sun_radius * 0.9, sun_position) * 0.2;
float sun_mask = smoothstep(sun_radius * 0.7, sun_radius * 0.65, sun_position) * 0.8;
float sun_color = (sun_mask_edge + sun_mask) * LIGHT0_ENERGY;
float horizon_mask = abs(EYEDIR.y * 1.0);
vec3 sunset_color = sun_scatter * (1.0 - horizon_mask);
COLOR = sky_gradient + sunset_color + (sun_color * clamp(EYEDIR.y * 4.0, 0.0, 1.0));
// Stars
if(star_stength > 0.0){
vec2 stars = voronoi(EYEDIR * 25.0).xz;
COLOR.rgb += smoothstep(0.025 + ((1.0 + sin(TIME + stars.y)) / 2.0) * 0.05, 0.0, stars.x) * star_stength;
}
// Clouds
vec2 cloud_uv = EYEDIR.xz / EYEDIR.y;
float cloud_mask = texture(clouds_sampler, cloud_uv * 0.05 + TIME * 0.001).x;
cloud_mask *= step(SKY_COORDS.y, 0.5);
COLOR.rgb = mix(
COLOR.rgb,
vec3(1.0),
smoothstep(0.75, 0.85, cloud_mask)
);
}