From 4db995c2f01ed71691383051abba55a33a6cd76a Mon Sep 17 00:00:00 2001 From: Shane Liesegang Date: Fri, 20 Nov 2020 16:01:43 +0200 Subject: [PATCH] controlling time from game loop instead of shader --- GUI.gd | 5 +++ GUI.tscn | 32 +++++++++---------- Planets/GasPlanet/GasPlanet.gd | 6 ++++ Planets/GasPlanet/GasPlanet.shader | 23 +++++++------- Planets/GasPlanet/GasPlanet.tscn | 27 +++++++++------- Planets/LandMasses/Clouds.shader | 25 ++++++++------- Planets/LandMasses/LandMasses.gd | 9 +++++- Planets/LandMasses/LandMasses.tscn | 3 ++ Planets/LandMasses/PlanetLandmass.shader | 25 ++++++++------- Planets/LandMasses/PlanetUnder.shader | 13 ++++---- Planets/NoAtmosphere/Craters.shader | 17 +++++----- Planets/NoAtmosphere/NoAtmosphere.gd | 6 ++++ Planets/NoAtmosphere/NoAtmosphere.shader | 13 ++++---- Planets/Rivers/Rivers.gd | 6 ++++ Planets/Rivers/Rivers.shader | 27 ++++++++-------- Planets/Rivers/Rivers.tscn | 2 ++ Theme.tres | 40 ++++++++++++------------ 17 files changed, 162 insertions(+), 117 deletions(-) diff --git a/GUI.gd b/GUI.gd index a6aab8e..d1ec666 100644 --- a/GUI.gd +++ b/GUI.gd @@ -45,3 +45,8 @@ func _seed_random(): func _on_Button_pressed(): _seed_random() + +func _process(_delta): + var time = OS.get_ticks_msec() * 0.001 + $Light.material.set_shader_param("time_elapsed", time) + diff --git a/GUI.tscn b/GUI.tscn index f95c2f1..fbe9a01 100644 --- a/GUI.tscn +++ b/GUI.tscn @@ -10,7 +10,7 @@ code = "shader_type canvas_item; render_mode blend_mix; uniform vec2 offset = vec2(0.0); - +uniform float time_elapsed; float rand(vec2 coord) { return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 43758.5453); @@ -22,14 +22,14 @@ vec2 rotate(vec2 coord, float angle){ } void fragment() { - vec2 uv = rotate(UV, TIME * 0.2); + vec2 uv = rotate(UV, time_elapsed * 0.2); + + vec4 col = vec4(1.0) + rand(UV + vec2(time_elapsed*0.0000001,0.0)) * 0.03; - vec4 col = vec4(1.0) + rand(UV + vec2(TIME*0.0000001,0.0)) * 0.03; - col = col* vec4( - abs(sin(uv.x * cos(offset.x)+ TIME * 0.105)), - abs(sin((cos(uv.x + uv.y) + cos(offset.x + offset.y) + TIME * 0.059))) , - abs(cos(uv.y * sin(offset.y) + TIME * 0.0253)) , + abs(sin(uv.x * cos(offset.x)+ time_elapsed * 0.105)), + abs(sin((cos(uv.x + uv.y) + cos(offset.x + offset.y) + time_elapsed * 0.059))) , + abs(cos(uv.y * sin(offset.y) + time_elapsed * 0.0253)) , 1.0); COLOR = col; @@ -38,6 +38,7 @@ void fragment() { [sub_resource type="ShaderMaterial" id=2] shader = SubResource( 1 ) shader_param/offset = Vector2( 0, 0 ) +shader_param/time_elapsed = null [sub_resource type="CanvasItemMaterial" id=3] particles_animation = true @@ -65,7 +66,7 @@ hue_variation_random = 1.0 anim_offset = 1.0 anim_offset_random = 1.0 -[sub_resource type="Shader" id=10] +[sub_resource type="Shader" id=7] code = "shader_type canvas_item; render_mode unshaded; @@ -84,8 +85,8 @@ void fragment () { COLOR = color; }" -[sub_resource type="ShaderMaterial" id=11] -shader = SubResource( 10 ) +[sub_resource type="ShaderMaterial" id=8] +shader = SubResource( 7 ) shader_param/abberation = 0.001 [node name="GUI" type="Control"] @@ -139,10 +140,10 @@ rect_pivot_offset = Vector2( 150, 150 ) [node name="Control" parent="HBoxContainer/PlanetHolder" instance=ExtResource( 3 )] anchor_right = 0.0 anchor_bottom = 0.0 -margin_left = 49.0 -margin_top = 49.0 -margin_right = 249.0 -margin_bottom = 249.0 +margin_left = 50.0 +margin_top = 50.0 +margin_right = 250.0 +margin_bottom = 250.0 [node name="Settings" type="Control" parent="HBoxContainer"] margin_left = 304.0 @@ -243,11 +244,10 @@ margin_right = 203.0 margin_bottom = 155.0 theme = ExtResource( 2 ) min_value = 30.0 -max_value = 100.0 value = 70.0 [node name="Abberation" type="ColorRect" parent="."] -material = SubResource( 11 ) +material = SubResource( 8 ) anchor_right = 1.0 anchor_bottom = 1.0 mouse_filter = 2 diff --git a/Planets/GasPlanet/GasPlanet.gd b/Planets/GasPlanet/GasPlanet.gd index 85e9f43..87fbf55 100644 --- a/Planets/GasPlanet/GasPlanet.gd +++ b/Planets/GasPlanet/GasPlanet.gd @@ -13,3 +13,9 @@ func set_seed(sd): $Cloud.material.set_shader_param("seed", converted_seed) $Cloud2.material.set_shader_param("seed", converted_seed) $Cloud2.material.set_shader_param("cloud_cover", rand_range(0.28, 0.5)) + +func _process(_delta): + var time = OS.get_ticks_msec() * 0.001 + $Cloud.material.set_shader_param("time_elapsed", time) + $Cloud2.material.set_shader_param("time_elapsed", time) + diff --git a/Planets/GasPlanet/GasPlanet.shader b/Planets/GasPlanet/GasPlanet.shader index c06e0a9..927fc49 100644 --- a/Planets/GasPlanet/GasPlanet.shader +++ b/Planets/GasPlanet/GasPlanet.shader @@ -15,6 +15,7 @@ uniform vec4 outline_color : hint_color; uniform vec4 shadow_base_color : hint_color; uniform vec4 shadow_outline_color : hint_color; +uniform float time_elapsed; uniform float size = 50.0; uniform int OCTAVES : hint_range(0, 20, 1); uniform float seed: hint_range(1, 10); @@ -26,7 +27,7 @@ float rand(vec2 coord) { float noise(vec2 coord){ vec2 i = floor(coord); vec2 f = fract(coord); - + float a = rand(i); float b = rand(i + vec2(1.0, 0.0)); float c = rand(i + vec2(0.0, 1.0)); @@ -66,14 +67,14 @@ float circleNoise(vec2 uv) { float cloud_alpha(vec2 uv, float time) { float c_noise = 0.0; - - + + // more iterations for more turbulence for (int i = 0; i < 15; i++) { c_noise += circleNoise((uv * size *0.3) + (float(i+1)*10.) + (vec2(time*0.1, 0.0))); } float fbm = fbm(uv*size+c_noise + vec2(time*0.5, 0.0)); - + return fbm;//step(a_cutoff, fbm); } @@ -91,18 +92,18 @@ vec2 spherify(vec2 uv) { void fragment() { // pixelize uv vec2 uv = floor(UV*pixels)/pixels; - + // distance to light source float d_light = distance(uv , light_origin); - + // map to sphere uv = spherify(uv); // slightly make uv go down on the right, and up in the left uv.y += smoothstep(0.0, cloud_curve, abs(uv.x-0.4)); - - - float c = cloud_alpha(uv*vec2(1.0, stretch), TIME*time_speed); - + + + float c = cloud_alpha(uv*vec2(1.0, stretch), time_elapsed*time_speed); + // assign some colors based on cloud depth & distance from light vec3 col = base_color.rgb; if (c < cloud_cover + 0.1) { @@ -115,6 +116,6 @@ void fragment() { if (d_light + c*0.2 > light_border_2) { col = shadow_outline_color.rgb; } - + COLOR = vec4(col, step(cloud_cover, c)); } diff --git a/Planets/GasPlanet/GasPlanet.tscn b/Planets/GasPlanet/GasPlanet.tscn index 2675a2c..7474743 100644 --- a/Planets/GasPlanet/GasPlanet.tscn +++ b/Planets/GasPlanet/GasPlanet.tscn @@ -21,6 +21,7 @@ uniform vec4 outline_color : hint_color; uniform vec4 shadow_base_color : hint_color; uniform vec4 shadow_outline_color : hint_color; +uniform float time_elapsed; uniform float size = 50.0; uniform int OCTAVES : hint_range(0, 20, 1); uniform float seed: hint_range(1, 10); @@ -32,7 +33,7 @@ float rand(vec2 coord) { float noise(vec2 coord){ vec2 i = floor(coord); vec2 f = fract(coord); - + float a = rand(i); float b = rand(i + vec2(1.0, 0.0)); float c = rand(i + vec2(0.0, 1.0)); @@ -72,14 +73,14 @@ float circleNoise(vec2 uv) { float cloud_alpha(vec2 uv, float time) { float c_noise = 0.0; - - + + // more iterations for more turbulence for (int i = 0; i < 15; i++) { c_noise += circleNoise((uv * size *0.3) + (float(i+1)*10.) + (vec2(time*0.1, 0.0))); } float fbm = fbm(uv*size+c_noise + vec2(time*0.5, 0.0)); - + return fbm;//step(a_cutoff, fbm); } @@ -97,18 +98,18 @@ vec2 spherify(vec2 uv) { void fragment() { // pixelize uv vec2 uv = floor(UV*pixels)/pixels; - + // distance to light source float d_light = distance(uv , light_origin); - + // map to sphere uv = spherify(uv); // slightly make uv go down on the right, and up in the left uv.y += smoothstep(0.0, cloud_curve, abs(uv.x-0.4)); - - - float c = cloud_alpha(uv*vec2(1.0, stretch), TIME*time_speed); - + + + float c = cloud_alpha(uv*vec2(1.0, stretch), time_elapsed*time_speed); + // assign some colors based on cloud depth & distance from light vec3 col = base_color.rgb; if (c < cloud_cover + 0.03) { @@ -121,9 +122,9 @@ void fragment() { if (d_light + c*0.2 > light_border_2) { col = shadow_outline_color.rgb; } - - + + COLOR = vec4(col, step(cloud_cover, c)); } " @@ -142,6 +143,7 @@ shader_param/base_color = Color( 0.231373, 0.12549, 0.152941, 1 ) shader_param/outline_color = Color( 0.231373, 0.12549, 0.152941, 1 ) shader_param/shadow_base_color = Color( 0.129412, 0.0941176, 0.105882, 1 ) shader_param/shadow_outline_color = Color( 0.129412, 0.0941176, 0.105882, 1 ) +shader_param/time_elapsed = null shader_param/size = 9.0 shader_param/OCTAVES = 5 shader_param/seed = 5.939 @@ -160,6 +162,7 @@ shader_param/base_color = Color( 0.941176, 0.709804, 0.254902, 1 ) shader_param/outline_color = Color( 0.811765, 0.458824, 0.168627, 1 ) shader_param/shadow_base_color = Color( 0.670588, 0.317647, 0.188235, 1 ) shader_param/shadow_outline_color = Color( 0.490196, 0.219608, 0.2, 1 ) +shader_param/time_elapsed = null shader_param/size = 9.0 shader_param/OCTAVES = 5 shader_param/seed = 5.939 diff --git a/Planets/LandMasses/Clouds.shader b/Planets/LandMasses/Clouds.shader index c5387c4..2e9589a 100644 --- a/Planets/LandMasses/Clouds.shader +++ b/Planets/LandMasses/Clouds.shader @@ -15,6 +15,7 @@ uniform vec4 outline_color : hint_color; uniform vec4 shadow_base_color : hint_color; uniform vec4 shadow_outline_color : hint_color; +uniform float time_elapsed; uniform float size = 50.0; uniform int OCTAVES : hint_range(0, 20, 1); uniform float seed: hint_range(1, 10); @@ -26,7 +27,7 @@ float rand(vec2 coord) { float noise(vec2 coord){ vec2 i = floor(coord); vec2 f = fract(coord); - + float a = rand(i); float b = rand(i + vec2(1.0, 0.0)); float c = rand(i + vec2(0.0, 1.0)); @@ -66,14 +67,14 @@ float circleNoise(vec2 uv) { float cloud_alpha(vec2 uv, float time) { float c_noise = 0.0; - - + + // more iterations for more turbulence for (int i = 0; i < 9; i++) { c_noise += circleNoise((uv * size *0.3) + (float(i+1)*10.) + (vec2(time*0.1, 0.0))); } float fbm = fbm(uv*size+c_noise + vec2(time*0.5, 0.0)); - + return fbm;//step(a_cutoff, fbm); } @@ -91,18 +92,18 @@ vec2 spherify(vec2 uv) { void fragment() { // pixelize uv vec2 uv = floor(UV*pixels)/pixels; - + // distance to light source float d_light = distance(uv , light_origin); - + // map to sphere uv = spherify(uv); // slightly make uv go down on the right, and up in the left uv.y += smoothstep(0.0, cloud_curve, abs(uv.x-0.4)); - - - float c = cloud_alpha(uv*vec2(1.0, stretch), TIME*time_speed); - + + + float c = cloud_alpha(uv*vec2(1.0, stretch), time_elapsed*time_speed); + // assign some colors based on cloud depth & distance from light vec3 col = base_color.rgb; if (c < cloud_cover + 0.03) { @@ -115,8 +116,8 @@ void fragment() { if (d_light + c*0.2 > light_border_2) { col = shadow_outline_color.rgb; } - - + + COLOR = vec4(col, step(cloud_cover, c)); } diff --git a/Planets/LandMasses/LandMasses.gd b/Planets/LandMasses/LandMasses.gd index 074070c..738d0ab 100644 --- a/Planets/LandMasses/LandMasses.gd +++ b/Planets/LandMasses/LandMasses.gd @@ -1,6 +1,6 @@ extends "res://Planets/Planet.gd" -func set_pixels(amount): +func set_pixels(amount): $Water.material.set_shader_param("pixels", amount) $Land.material.set_shader_param("pixels", amount) $Cloud.material.set_shader_param("pixels", amount) @@ -16,3 +16,10 @@ func set_seed(sd): $Water.material.set_shader_param("seed", converted_seed) $Land.material.set_shader_param("seed", converted_seed) $Cloud.material.set_shader_param("cloud_cover", rand_range(0.35, 0.6)) + +func _process(_delta): + var time = OS.get_ticks_msec() * 0.001 + $Cloud.material.set_shader_param("time_elapsed", time) + $Water.material.set_shader_param("time_elapsed", time) + $Land.material.set_shader_param("time_elapsed", time) + diff --git a/Planets/LandMasses/LandMasses.tscn b/Planets/LandMasses/LandMasses.tscn index 622b005..982c4a0 100644 --- a/Planets/LandMasses/LandMasses.tscn +++ b/Planets/LandMasses/LandMasses.tscn @@ -16,6 +16,7 @@ shader_param/light_border_2 = 0.6 shader_param/color1 = Color( 0.572549, 0.909804, 0.752941, 1 ) shader_param/color2 = Color( 0.309804, 0.643137, 0.721569, 1 ) shader_param/color3 = Color( 0.172549, 0.207843, 0.301961, 1 ) +shader_param/time_elapsed = null shader_param/size = 5.228 shader_param/OCTAVES = 3 shader_param/seed = 10.0 @@ -33,6 +34,7 @@ shader_param/col1 = Color( 0.784314, 0.831373, 0.364706, 1 ) shader_param/col2 = Color( 0.388235, 0.670588, 0.247059, 1 ) shader_param/col3 = Color( 0.184314, 0.341176, 0.32549, 1 ) shader_param/col4 = Color( 0.156863, 0.207843, 0.25098, 1 ) +shader_param/time_elapsed = null shader_param/size = 4.292 shader_param/OCTAVES = 6 shader_param/seed = 7.947 @@ -51,6 +53,7 @@ shader_param/base_color = Color( 0.87451, 0.878431, 0.909804, 1 ) shader_param/outline_color = Color( 0.639216, 0.654902, 0.760784, 1 ) shader_param/shadow_base_color = Color( 0.407843, 0.435294, 0.6, 1 ) shader_param/shadow_outline_color = Color( 0.25098, 0.286275, 0.45098, 1 ) +shader_param/time_elapsed = null shader_param/size = 7.745 shader_param/OCTAVES = 2 shader_param/seed = 5.939 diff --git a/Planets/LandMasses/PlanetLandmass.shader b/Planets/LandMasses/PlanetLandmass.shader index 47309e9..a907c9c 100644 --- a/Planets/LandMasses/PlanetLandmass.shader +++ b/Planets/LandMasses/PlanetLandmass.shader @@ -14,6 +14,7 @@ uniform vec4 col2 : hint_color; uniform vec4 col3 : hint_color; uniform vec4 col4 : hint_color; +uniform float time_elapsed; uniform float size = 50.0; uniform int OCTAVES : hint_range(0, 20, 1); uniform float seed: hint_range(1, 10); @@ -33,7 +34,7 @@ float rand(vec2 coord) { float noise(vec2 coord){ vec2 i = floor(coord); vec2 f = fract(coord); - + float a = rand(i); float b = rand(i + vec2(1.0, 0.0)); float c = rand(i + vec2(0.0, 1.0)); @@ -72,24 +73,24 @@ vec2 rotate(vec2 coord, float angle){ void fragment() { // pixelize uv vec2 uv = floor(UV*pixels)/pixels; - + float d_light = distance(uv , light_origin); - + // give planet a tilt uv = rotate(uv, 0.2); - + // map to sphere uv = spherify(uv); - + // some scrolling noise for landmasses - vec2 base_fbm_uv = (uv)*size+vec2(TIME*time_speed,0.0); - + vec2 base_fbm_uv = (uv)*size+vec2(time_elapsed*time_speed,0.0); + // use multiple fbm's at different places so we can determine what color land gets float fbm1 = fbm(base_fbm_uv); float fbm2 = fbm(base_fbm_uv - light_origin*fbm1); float fbm3 = fbm(base_fbm_uv - light_origin*1.5*fbm1); float fbm4 = fbm(base_fbm_uv - light_origin*2.0*fbm1); - + // lots of magic numbers here // you can mess with them, it changes the color distribution if (d_light < light_border_1) { @@ -99,13 +100,13 @@ void fragment() { fbm2 *= 1.05; fbm3 *= 1.05; fbm4 *= 1.05; - } + } if (d_light > light_border_2) { fbm2 *= 1.3; fbm3 *= 1.4; fbm4 *= 1.8; - } - + } + // increase contrast on d_light d_light = pow(d_light, 2.0)*0.1; vec3 col = col4.rgb; @@ -120,6 +121,6 @@ void fragment() { if (fbm2 + d_light < fbm1) { col = col1.rgb; } - + COLOR = vec4(col, step(land_cutoff, fbm1)); } diff --git a/Planets/LandMasses/PlanetUnder.shader b/Planets/LandMasses/PlanetUnder.shader index 4eb6728..f7bd7f2 100644 --- a/Planets/LandMasses/PlanetUnder.shader +++ b/Planets/LandMasses/PlanetUnder.shader @@ -10,6 +10,7 @@ uniform float light_border_2 : hint_range(0.0, 1.0) = 0.6; uniform vec4 color1 : hint_color; uniform vec4 color2 : hint_color; uniform vec4 color3 : hint_color; +uniform float time_elapsed; uniform float size = 50.0; uniform int OCTAVES : hint_range(0, 20, 1); uniform float seed: hint_range(1, 10); @@ -26,7 +27,7 @@ float rand(vec2 coord) { float noise(vec2 coord){ vec2 i = floor(coord); vec2 f = fract(coord); - + float a = rand(i); float b = rand(i + vec2(1.0, 0.0)); float c = rand(i + vec2(0.0, 1.0)); @@ -59,13 +60,13 @@ void fragment() { // check distance from center & distance to light float d_circle = distance(uv, vec2(0.5)); float d_light = distance(uv , vec2(light_origin)); - + // cut out a circle float a = step(d_circle, 0.5); - + // get a noise value with light distance added - d_light += fbm(uv*size+vec2(TIME*time_speed, 0.0))*0.3; // change the magic 0.3 here for different light strengths - + d_light += fbm(uv*size+vec2(time_elapsed*time_speed, 0.0))*0.3; // change the magic 0.3 here for different light strengths + // size of edge in which colors should be dithered float dither_border = (1.0/pixels)*dither_size; @@ -83,6 +84,6 @@ void fragment() { col = color2.rgb; } } - + COLOR = vec4(col, a); } diff --git a/Planets/NoAtmosphere/Craters.shader b/Planets/NoAtmosphere/Craters.shader index 31eb163..b681ecd 100644 --- a/Planets/NoAtmosphere/Craters.shader +++ b/Planets/NoAtmosphere/Craters.shader @@ -7,6 +7,7 @@ uniform float time_speed : hint_range(0.0, 1.0) = 0.2; uniform float light_border : hint_range(0.0, 1.0) = 0.4; uniform vec4 color1 : hint_color; uniform vec4 color2 : hint_color; +uniform float time_elapsed; uniform float size = 50.0; uniform float seed: hint_range(1, 10); @@ -49,26 +50,26 @@ vec2 rotate(vec2 coord, float angle){ void fragment() { //pixelize uv vec2 uv = floor(UV*pixels)/pixels; - + uv = rotate(uv, 0.4); - + // check distance from center & distance to light float d_circle = distance(uv, vec2(0.5)); float d_light = distance(uv , vec2(light_origin)); - + uv = spherify(uv); - - float c1 = crater(uv + vec2(TIME*time_speed, 0.0)); - float c2 = crater(uv + vec2(TIME*time_speed, 0.0) +(light_origin-0.5)*0.03); + + float c1 = crater(uv + vec2(time_elapsed*time_speed, 0.0)); + float c2 = crater(uv + vec2(time_elapsed*time_speed, 0.0) +(light_origin-0.5)*0.03); vec3 col = color1.rgb; - + float a = step(0.5, c1); if (c2 light_border) { col = color2.rgb; - } + } // cut out a circle a*= step(d_circle, 0.5); diff --git a/Planets/NoAtmosphere/NoAtmosphere.gd b/Planets/NoAtmosphere/NoAtmosphere.gd index 87b50ac..475c663 100644 --- a/Planets/NoAtmosphere/NoAtmosphere.gd +++ b/Planets/NoAtmosphere/NoAtmosphere.gd @@ -11,3 +11,9 @@ func set_seed(sd): var converted_seed = sd%1000/100.0 $PlanetUnder.material.set_shader_param("seed", converted_seed) $Craters.material.set_shader_param("seed", converted_seed) + +func _process(_delta): + var time = OS.get_ticks_msec() * 0.001 + $PlanetUnder.material.set_shader_param("time_elapsed", time) + $Craters.material.set_shader_param("time_elapsed", time) + diff --git a/Planets/NoAtmosphere/NoAtmosphere.shader b/Planets/NoAtmosphere/NoAtmosphere.shader index ca6d60f..00635b1 100644 --- a/Planets/NoAtmosphere/NoAtmosphere.shader +++ b/Planets/NoAtmosphere/NoAtmosphere.shader @@ -10,6 +10,7 @@ uniform float light_border_2 : hint_range(0.0, 1.0) = 0.6; uniform vec4 color1 : hint_color; uniform vec4 color2 : hint_color; uniform vec4 color3 : hint_color; +uniform float time_elapsed; uniform float size = 50.0; uniform int OCTAVES : hint_range(0, 20, 1); uniform float seed: hint_range(1, 10); @@ -21,7 +22,7 @@ float rand(vec2 coord) { float noise(vec2 coord){ vec2 i = floor(coord); vec2 f = fract(coord); - + float a = rand(i); float b = rand(i + vec2(1.0, 0.0)); float c = rand(i + vec2(0.0, 1.0)); @@ -55,15 +56,15 @@ void fragment() { // check distance from center & distance to light float d_circle = distance(uv, vec2(0.5)); float d_light = distance(uv , vec2(light_origin)); - + // cut out a circle float a = step(d_circle, 0.5); - + // get a noise value with light distance added // this creates a moving dynamic shape float fbm1 = fbm(uv); - d_light += fbm(uv*size+fbm1+vec2(TIME*time_speed, 0.0))*0.3; // change the magic 0.3 here for different light strengths - + d_light += fbm(uv*size+fbm1+vec2(time_elapsed*time_speed, 0.0))*0.3; // change the magic 0.3 here for different light strengths + // size of edge in which colors should be dithered float dither_border = (1.0/pixels)*dither_size; @@ -81,6 +82,6 @@ void fragment() { col = color2.rgb; } } - + COLOR = vec4(col, a); } diff --git a/Planets/Rivers/Rivers.gd b/Planets/Rivers/Rivers.gd index d3d0e6d..aec28c9 100644 --- a/Planets/Rivers/Rivers.gd +++ b/Planets/Rivers/Rivers.gd @@ -13,3 +13,9 @@ func set_seed(sd): $Cloud.material.set_shader_param("seed", converted_seed) $Cloud.material.set_shader_param("cloud_cover", rand_range(0.35, 0.6)) $Land.material.set_shader_param("seed", converted_seed) + +func _process(_delta): + var time = OS.get_ticks_msec() * 0.001 + $Land.material.set_shader_param("time_elapsed", time) + $Cloud.material.set_shader_param("time_elapsed", time) + diff --git a/Planets/Rivers/Rivers.shader b/Planets/Rivers/Rivers.shader index ff42262..35faeeb 100644 --- a/Planets/Rivers/Rivers.shader +++ b/Planets/Rivers/Rivers.shader @@ -16,6 +16,7 @@ uniform vec4 col4 : hint_color; uniform vec4 river_col : hint_color; uniform vec4 river_col_dark : hint_color; +uniform float time_elapsed; uniform float size = 50.0; uniform int OCTAVES : hint_range(0, 20, 1); uniform float seed: hint_range(1, 10); @@ -34,7 +35,7 @@ float rand(vec2 coord) { float noise(vec2 coord){ vec2 i = floor(coord); vec2 f = fract(coord); - + float a = rand(i); float b = rand(i + vec2(1.0, 0.0)); float c = rand(i + vec2(0.0, 1.0)); @@ -77,27 +78,27 @@ bool dither(vec2 uv1, vec2 uv2) { void fragment() { // pixelize uv vec2 uv = floor(UV*pixels)/pixels; - + float d_light = distance(uv , light_origin); - + // give planet a tilt uv = rotate(uv, 0.2); // // // map to sphere uv = spherify(uv); - + // some scrolling noise for landmasses - vec2 base_fbm_uv = (uv)*size+vec2(TIME*time_speed,0.0); - + vec2 base_fbm_uv = (uv)*size+vec2(time_elapsed*time_speed,0.0); + // use multiple fbm's at different places so we can determine what color land gets float fbm1 = fbm(base_fbm_uv); float fbm2 = fbm(base_fbm_uv - light_origin*fbm1); float fbm3 = fbm(base_fbm_uv - light_origin*1.5*fbm1); float fbm4 = fbm(base_fbm_uv - light_origin*2.0*fbm1); - + float river_fbm = fbm(base_fbm_uv+fbm1*6.0); river_fbm = step(river_cutoff, river_fbm); - + // size of edge in which colors should be dithered float dither_border = (1.0/pixels)*dither_size; // lots of magic numbers here @@ -109,7 +110,7 @@ void fragment() { fbm2 *= 1.05; fbm3 *= 1.05; fbm4 *= 1.05; - } + } if (d_light > light_border_2) { fbm2 *= 1.3; fbm3 *= 1.4; @@ -117,12 +118,12 @@ void fragment() { if (d_light < light_border_2 +dither_border && dither(uv, uv)) { fbm4 *= 0.5; } - } + } // if (d_light < light_border_1) { // fbm4 *= 0.9; // } - - + + // increase contrast on d_light d_light = pow(d_light, 2.0)*0.4; vec3 col = col4.rgb; @@ -141,6 +142,6 @@ void fragment() { col = river_col.rgb; } } - + COLOR = vec4(col, step(distance(vec2(0.5), uv), 0.5)); } diff --git a/Planets/Rivers/Rivers.tscn b/Planets/Rivers/Rivers.tscn index c03237e..20bf8ac 100644 --- a/Planets/Rivers/Rivers.tscn +++ b/Planets/Rivers/Rivers.tscn @@ -19,6 +19,7 @@ shader_param/col3 = Color( 0.184314, 0.341176, 0.32549, 1 ) shader_param/col4 = Color( 0.156863, 0.207843, 0.25098, 1 ) shader_param/river_col = Color( 0.309804, 0.643137, 0.721569, 1 ) shader_param/river_col_dark = Color( 0.25098, 0.286275, 0.45098, 1 ) +shader_param/time_elapsed = null shader_param/size = 4.658 shader_param/OCTAVES = 6 shader_param/seed = 8.98 @@ -37,6 +38,7 @@ shader_param/base_color = Color( 0.960784, 1, 0.909804, 1 ) shader_param/outline_color = Color( 0.87451, 0.878431, 0.909804, 1 ) shader_param/shadow_base_color = Color( 0.407843, 0.435294, 0.6, 1 ) shader_param/shadow_outline_color = Color( 0.25098, 0.286275, 0.45098, 1 ) +shader_param/time_elapsed = null shader_param/size = 7.745 shader_param/OCTAVES = 2 shader_param/seed = 5.939 diff --git a/Theme.tres b/Theme.tres index 1520dca..4f720b9 100644 --- a/Theme.tres +++ b/Theme.tres @@ -4,23 +4,23 @@ [ext_resource path="res://grabber-highlight.png" type="Texture" id=2] [ext_resource path="res://grabber.png" type="Texture" id=3] -[sub_resource type="StyleBoxFlat" id=16] +[sub_resource type="StyleBoxFlat" id=1] bg_color = Color( 0.811765, 0.811765, 0.811765, 1 ) -[sub_resource type="StyleBoxFlat" id=17] +[sub_resource type="StyleBoxFlat" id=2] bg_color = Color( 0, 0, 0, 1 ) -[sub_resource type="StyleBoxFlat" id=18] +[sub_resource type="StyleBoxFlat" id=3] bg_color = Color( 0, 0, 0, 1 ) -[sub_resource type="StyleBoxFlat" id=9] +[sub_resource type="StyleBoxFlat" id=4] bg_color = Color( 0.811765, 0.811765, 0.811765, 1 ) border_width_bottom = 16 -[sub_resource type="StyleBoxFlat" id=12] +[sub_resource type="StyleBoxFlat" id=5] border_width_bottom = 16 -[sub_resource type="StyleBoxFlat" id=11] +[sub_resource type="StyleBoxFlat" id=6] bg_color = Color( 0, 0, 0, 1 ) border_width_bottom = 16 border_color = Color( 0, 0, 0, 1 ) @@ -31,20 +31,20 @@ font_data = ExtResource( 1 ) [sub_resource type="StyleBoxFlat" id=8] bg_color = Color( 0, 0, 0, 1 ) -[sub_resource type="DynamicFont" id=13] +[sub_resource type="DynamicFont" id=9] font_data = ExtResource( 1 ) -[sub_resource type="StyleBoxFlat" id=15] +[sub_resource type="StyleBoxFlat" id=10] bg_color = Color( 0, 0, 0, 1 ) -[sub_resource type="StyleBoxFlat" id=14] +[sub_resource type="StyleBoxFlat" id=11] bg_color = Color( 0, 0, 0, 1 ) -[sub_resource type="DynamicFont" id=19] +[sub_resource type="DynamicFont" id=12] font_data = ExtResource( 1 ) [resource] -default_font = SubResource( 19 ) +default_font = SubResource( 12 ) Button/colors/font_color = Color( 0.811765, 0.811765, 0.811765, 1 ) Button/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 ) Button/colors/font_color_hover = Color( 0, 0, 0, 1 ) @@ -53,16 +53,16 @@ Button/constants/hseparation = 2 Button/fonts/font = null Button/styles/disabled = null Button/styles/focus = null -Button/styles/hover = SubResource( 16 ) -Button/styles/normal = SubResource( 17 ) -Button/styles/pressed = SubResource( 18 ) +Button/styles/hover = SubResource( 1 ) +Button/styles/normal = SubResource( 2 ) +Button/styles/pressed = SubResource( 3 ) HSlider/icons/grabber = ExtResource( 3 ) HSlider/icons/grabber_disabled = null HSlider/icons/grabber_highlight = ExtResource( 2 ) HSlider/icons/tick = null -HSlider/styles/grabber_area = SubResource( 9 ) -HSlider/styles/grabber_area_highlight = SubResource( 12 ) -HSlider/styles/slider = SubResource( 11 ) +HSlider/styles/grabber_area = SubResource( 4 ) +HSlider/styles/grabber_area_highlight = SubResource( 5 ) +HSlider/styles/slider = SubResource( 6 ) Label/colors/font_color = Color( 0.741176, 0.741176, 0.741176, 1 ) Label/colors/font_color_shadow = Color( 0, 0, 0, 0 ) Label/colors/font_outline_modulate = Color( 1, 1, 1, 1 ) @@ -80,8 +80,8 @@ LineEdit/colors/font_color_selected = Color( 0, 0, 0, 1 ) LineEdit/colors/font_color_uneditable = Color( 0.88, 0.88, 0.88, 0.5 ) LineEdit/colors/selection_color = Color( 0.49, 0.49, 0.49, 1 ) LineEdit/constants/minimum_spaces = 12 -LineEdit/fonts/font = SubResource( 13 ) +LineEdit/fonts/font = SubResource( 9 ) LineEdit/icons/clear = null -LineEdit/styles/focus = SubResource( 15 ) -LineEdit/styles/normal = SubResource( 14 ) +LineEdit/styles/focus = SubResource( 10 ) +LineEdit/styles/normal = SubResource( 11 ) LineEdit/styles/read_only = null