sky prototyping

This commit is contained in:
betalars 2023-12-03 16:07:08 +01:00
parent 89f44e2f3f
commit 5d48c3325d
7 changed files with 176 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,53 @@
shader_type sky;
uniform float star_size: hint_range(50.0, 500.0) = 120.0;
uniform sampler2D star_colors: hint_default_white;
uniform sampler2D sky_gradient: hint_default_black, repeat_disable;
uniform sampler2D nebula_gradient: hint_default_black, repeat_disable;
uniform float nebula_offset;
uniform sampler2D universe_background: hint_default_black;
// https://github.com/Norrox/GodotShaders/blob/master/Shaders/Voronoi-Worley/Voronoi.shader
vec3 RNGV3(vec3 p) {
vec3 a = fract(vec3(p.x, p.y, p.z) * vec3(111.11,333.33,444.44));
a += dot(a, a+33.51);
return fract(vec3(a.x*a.y, a.y*a.z, a.z*a.x)); //outputs a random vec2 between 0 and 1
}
vec4 voronoy(vec3 loc, float scale){
loc = loc*scale;
vec4 output = vec4(0., 0., 0., 10.);
for(float y=-1.; y<=1.; y++){
for(float x=-1.; x<=1.; x++){
for(float z=-1.; z<=1.; z++){
vec3 offs = vec3(x,y,z);
vec3 n = RNGV3(floor(loc)+offs)*2.0-1.0;
vec3 p = offs+sin(n) * .5;
float d = length((fract(loc)-0.5)-p);
if(d<output.q){
vec3 rng = RNGV3(floor(loc)+offs);
output = vec4(rng.x, rng.y, rng.z, d);
}
}
}
}
return output;
}
void sky() {
vec4 star_noise = voronoy(EYEDIR, star_size);
vec3 stars = pow(max((0.25-star_noise.q)*4.0, 0), 0.3) * texture(star_colors, vec2(star_noise.x)).xyz * pow(star_noise.z, 2.2);
stars *= float(star_noise.y*4.0 < pow(texture(universe_background, SKY_COORDS).z, 2.0));
stars *= (0.7 + sin(TIME*(star_noise.z*1.5+0.2)) * 0.5);
vec2 moving_noise = (texture(universe_background, SKY_COORDS + TIME * vec2(0.001, .0)).xy - 0.5) * 0.1;
COLOR = pow(texture(sky_gradient, pow(moving_noise + EYEDIR.yy, vec2(0.8))).xyz, vec3(2.2));
vec4 nebula = texture(nebula_gradient, //selecting the correct color
pow(vec2(texture(universe_background, SKY_COORDS).z), vec2(0.8+nebula_offset)) * nebula_offset //setting the base gradient
* 1.5 * texture(universe_background, -SKY_COORDS + TIME * vec2(0.001, 0) + moving_noise).xy // adding distortion
);
//COLOR += pow(texture(nebula_gradient, vec2(texture(universe_background, SKY_COORDS).z + nebula_offset * texture(universe_background, -SKY_COORDS + TIME * vec2(0.0005, 0) + moving_noise).z + 0.1)).xyz, vec3(2.0));
COLOR = COLOR * (1.0-nebula.q) + nebula.xyz + stars;
//COLOR = texture(universe_background, SKY_COORDS).zzz;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cfwa5dq3flk4b"
path="res://.godot/imported/sky_textures.png-1bc387632f79299cfe768a08f95b36df.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://base-environments/intro_scene/textures/sky_textures.png"
dest_files=["res://.godot/imported/sky_textures.png-1bc387632f79299cfe768a08f95b36df.ctex"]
[params]
compress/mode=3
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=1
compress/channel_pack=1
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=1
roughness/src_normal=""
process/fix_alpha_border=false
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dabnlcnuticww"
path="res://.godot/imported/sky_textures_2.png-a1913291aa98549785b8c12dd6aa67b9.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://base-environments/intro_scene/textures/sky_textures_2.png"
dest_files=["res://.godot/imported/sky_textures_2.png-a1913291aa98549785b8c12dd6aa67b9.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=1
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=false
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@ -0,0 +1,55 @@
[gd_scene load_steps=12 format=3 uid="uid://d0qqluenght6a"]
[ext_resource type="Shader" path="res://base-environments/intro_scene/shaders/stars.gdshader" id="1_8nej7"]
[ext_resource type="Texture2D" uid="uid://dabnlcnuticww" path="res://base-environments/intro_scene/textures/sky_textures_2.png" id="2_qoi7m"]
[sub_resource type="Gradient" id="Gradient_d5lk6"]
interpolation_mode = 2
offsets = PackedFloat32Array(0, 0.175337, 0.414258, 0.593449, 0.700565, 0.770713, 0.798493, 0.809793, 0.954802)
colors = PackedColorArray(0, 0, 0, 0, 0.0175207, 0.016833, 0.0606262, 0.584314, 0.0258333, 0.021, 0.05, 0, 0.06228, 0.0312, 0.12, 1, 0.22, 0.055, 0.1815, 0, 0.816757, 0.155467, 0.208686, 0.819608, 0.0136439, 0.0237636, 0.0955315, 1, 0.0120242, 0.0120251, 0.0360567, 0.356863, 0.00319355, 0.00476964, 0.0186391, 0.313726)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_apxml"]
gradient = SubResource("Gradient_d5lk6")
use_hdr = true
[sub_resource type="Gradient" id="Gradient_liqu7"]
interpolation_mode = 2
interpolation_color_space = 1
offsets = PackedFloat32Array(0, 0.137476, 0.46516, 0.851224)
colors = PackedColorArray(0.127188, 0.325303, 0.352533, 1, 0.21, 0.2975, 0.42, 1, 0.1189, 0.127455, 0.29, 1, 0.106137, 0.0034, 0.17, 1)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_vetqo"]
gradient = SubResource("Gradient_liqu7")
use_hdr = true
[sub_resource type="Gradient" id="Gradient_87cdb"]
colors = PackedColorArray(0.85, 0.46325, 0.0765, 1, 0.825717, 0.47559, 0.983214, 1)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_8fou6"]
gradient = SubResource("Gradient_87cdb")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_s2c5b"]
shader = ExtResource("1_8nej7")
shader_parameter/star_size = 120.0
shader_parameter/nebula_offset = 0.5
shader_parameter/star_colors = SubResource("GradientTexture1D_8fou6")
shader_parameter/sky_gradient = SubResource("GradientTexture1D_vetqo")
shader_parameter/nebula_gradient = SubResource("GradientTexture1D_apxml")
shader_parameter/universe_background = ExtResource("2_qoi7m")
[sub_resource type="Sky" id="Sky_6q4bd"]
sky_material = SubResource("ShaderMaterial_s2c5b")
[sub_resource type="Environment" id="Environment_bebqi"]
background_mode = 2
sky = SubResource("Sky_6q4bd")
reflected_light_source = 2
tonemap_mode = 3
[node name="Node3D" type="Node3D"]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_bebqi")
[node name="Camera3D" type="Camera3D" parent="WorldEnvironment"]
transform = Transform3D(0.864275, 0.310381, 0.395844, 0, 0.786935, -0.617036, -0.50302, 0.533288, 0.680128, 0, 0, 2.95787)