-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weather and Environment Improvements #326
Conversation
The old rain system showed unflexibilities and had room for visual improvements, hence it was replaced The new rain system is a fixed node that has rather clear parameters that dynamically change the rains behaviour Refs: #312
… value is changed
WIP: lighting is part of World scene; lightning is randomly created somewhere around center node WIP: adjust code such that it can be enabled from code (still buggy as of now) Refs: #312
Lightning effects are visually polished and many options are exposed as export variables (color and albedo gradient, distance, spawn-interval). Lightnings are now more "grouped" and arent just randomly spawned around the player; can be adjusted via rotation degrees Refs: #312
Clear sky, few clouds, overcast, drizzle rain, gusts, thunderstorm, foggy can now be applied via dropdown Refs: #312
…; disable rain and lightning by default Before, volumetric fog was permanently applied which led to too dark sceneries when the sky is clear/no rain Refs: #312
…or "weather lights" Adds a texture that makes the clouds appear lit once a lightning strikes Instead of always having a thunder, only by a certain change a true strike will be emitted otherwise "weather lights" Refs: #312
This avoids weird movement when strong winds are applied
The weather category has to be set after the WeatherManager was instanced
SSAO and skylight are affected by cloud-coverage. Clouds are not as strongly affected by a bright skylight (change in shader), therefore lights are stronger in general (bluer sky). Refs: #312
Setting rotation is required via radians instead of degrees since Godot4 Refs: #315
Set color_alpha to 0, such that the effect still works once used (as opposed to setting visibility)
Exposed in UI and in weathermanager, preconfigurations adjusted accordingly Refs: #312
Changes in the cloud shader were necessary; texture reads are multiplied with a wind-direction Refs: #312
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks great and the implementation looks very clean too! just some nitpicks on documentation and performance
World/WeatherManager.gd
Outdated
emit_signal("rain_drop_size_changed", new_rain_drop_size) | ||
rain_drop_size_changed.emit(new_rain_drop_size) | ||
|
||
var lightning_enabled := false : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could expose the frequency of lightnings rather than a bool? we'll probably use the Thunderstorm preset most of the time anyway, but could be practical
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, i changed this with commit 33386e4. A frequency of 0 automatically means lightnings are disabled.
|
||
var rain_density := 100.0 : | ||
var rain_density := 1 : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add documentation for sensible range of values here; also, maybe a rain_density of 0 is enough to imply that rain is disabled, and we can therefore remove rain_enabled
above? (would avoid ambiguity/confusion when setting the rain_density but forgetting to set rain_enabled)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the range, however I am not sure if I would want to remove rain_enabled. The Rain
node is - to a large extent - just a group of GPUParticles
. GPUParticles
in Godot are closely resembled by and enabled
and a density
via their properties emitting
and amount
. That is why I personally designed it this way. Do you think the avoidance of ambiguity has higher priority?
World/WeatherManager.gd
Outdated
lightning_enabled_changed.emit(lightning_enabled) | ||
|
||
|
||
var lightning_rotation := 0 : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really intuitive what this means (rotation relative to what? what's being rotated? deg or rad?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I hope 3911177 clarifies appropriately.
@@ -167,7 +167,7 @@ vec4 march(vec3 pos, vec3 end, vec3 dir, int depth) { | |||
vec3 p = pos + hash(pos * 10.0) * ss; | |||
const float t_dist = sky_t_radius-sky_b_radius; | |||
float lss = (t_dist / 36.0); | |||
vec3 ldir = normalize(LIGHT0_DIRECTION); | |||
vec3 ldir = normalize(LIGHT0_DIRECTION) * 0.6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a description of why we did this so we recognize it in the future, e.g. // Multiply by 0.6 to make the sun appear darker behind the clouds instead of creating a large purely white area in the sky (trick to simulate that the sun is always at a larger angle to the viewer than it actually is)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
World/Environment/Lightning.gdshader
Outdated
@@ -0,0 +1,5 @@ | |||
shader_type canvas_item; | |||
|
|||
void fragment() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file seems unneeded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Removed via b78ea31
World/Environment/Lightning.tscn
Outdated
material_override = SubResource("StandardMaterial3D_x464h") | ||
mesh = SubResource("QuadMesh_jseao") | ||
|
||
[node name="SubViewport" type="SubViewport" parent="LightningMesh"] | ||
disable_3d = true | ||
transparent_bg = true | ||
handle_input_locally = false | ||
msaa_2d = 3 | ||
use_taa = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does temporal anti-aliasing make sense for this viewport?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
distance_radius = val | ||
if get_child_count(): set_extents(detailed_radius, coarse_radius, val) | ||
|
||
var heavy_rain_threshold := 0.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add a comment describing what this means
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…andscapelab into weather-improvements
Instead of a plain enabled, the frequency can now be altered using a value from 0 to 100 (0 no lightning, 100 extremely frequent lightning) Refs: #326
…andscapelab into weather-improvements
… rename _time_scale to wind_speed We previously "lowered" the light direction to make the sun appear darker behind clouds. New comment should avoid confusion. _time_scale was no longer a fitting variable-name as it clearly now correlates with the how the wind interacts with the movement of the clouds.
Previously the render mode was set to always regardless of whether an actual lightning was visible. Now we set it to visible once animating then set visibility to false again.
Previously only the albedo of the cloudmesh was changes instead of albedo and emission.
A prior commit set the rendermode of the subviewport to VISIBLE
Thanks for the changes, looks great! ready to merge imo |
Weather and Environment Improvements (Refs: #312)
New rain system
A new rain system was implemented to replace the old one which had certain limitations (e.g. wind-direction). The new rain-system consists of:
Also has clear parameters for dynamic configurations.
New Lightning Scene
Creates Lightnings in a certain cardinal direction around the player. Lightning effect has also a alpha texture as a cloud to make the clouds appear lit. Not every lightning strike truly produces a lightning "chain", but only uses the cloud texture (aka weather-lights).
Preconfigured Weather
The UI exposes preconfigured weather scenarios (Clear Sky, Few Clouds, Overcast Drizzle Rain, Heavy Rain, Gusts, Thunderstorm, Foggy).
Environment Effects
Environment effects are polished and have more options (e.g. ambient occlusion, cloud density) and mutual effects on each other.
Cloud Wind
Clouds are properly affected by wind-direction and speed again.