Skip to content

Reinstate clouds shadow#1921

Merged
wjt merged 5 commits intomainfrom
reinstate-clouds-shadow
Feb 17, 2026
Merged

Reinstate clouds shadow#1921
wjt merged 5 commits intomainfrom
reinstate-clouds-shadow

Conversation

@manuq
Copy link
Collaborator

@manuq manuq commented Feb 17, 2026

Replace the clouds overlay effect with a new implementation, and reinstate it in Fray's End.

See node editor descriptions or script comments for implementation details.

Fix #380

@manuq manuq requested a review from a team as a code owner February 17, 2026 13:33
@manuq
Copy link
Collaborator Author

manuq commented Feb 17, 2026

This is extracted from the time-of-day / weather prototype #1913

@github-actions
Copy link

Play this branch at https://play.threadbare.game/branches/endlessm/reinstate-clouds-shadow.

(This launches the game from the start, not directly at the change(s) in this pull request.)

Replace the clouds overlay effect with a new implementation.

See node editor descriptions or script comments for
implementation details.
@manuq manuq force-pushed the reinstate-clouds-shadow branch from e82c4ff to db79216 Compare February 17, 2026 13:59
@tool
extends Parallax2D

@export_tool_button("Random Clouds") var randomize_button: Callable = randomize
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite follow how this button is supposed to be used.

Suppose that I have res://scenes/world_map/frays_end.tscn open in my editor. If I click this button, the clouds in the editor change, but when I run the scene they are back to the seed=0 clouds.

However, if I have both res://scenes/world_map/frays_end.tscn and res://scenes/game_elements/fx/clouds_shadow/clouds_shadow.tscn open. Then:

  1. Switch to the frays end tab
  2. Click Random Clouds
  3. Save Fray's End - no change on disk
  4. Switch back to the clouds_shadow.tscn scene; observe that the clouds have changed to match Fray's End
  5. Save that scene; observe that the seed has been persisted here.

If I set all of the ShaderMaterial, NoiseTexture2D and FastNoiseLite as resource_local_to_scene = true (I don't understand why all three have to be) then this doesn't happen: changing the seed in Fray's End does not persist. But then it does nothing in the editor.

I think it's fine either way - the worst that happens is that the random clouds are inadvertently changed occasionally - but maybe we want to do the NOTIFICATION_EDITOR_PRE_SAVE trick in clouds_shadow.gd to reset the seed? Or we can just leave it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, since in my prototype branch I was calling to the randomize() function directly, and testing the button only in the clouds_shadow.tscn scene, I didn't notice. I guess there is no other way than exporting a proxy "seed" property and then the noise resource is set to this value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wjt I appended a fixup commit. Let me know what do you think. If we want the seed hidden we could change the export to be @export_storage, but I think is good to expose it. I had something similar in my townies exploration #1801

Comment on lines +34 to +37
editor_description = "Start with a small noise texture that is then upscaled to a square. The size of this ColorRect.

The texture width is about 2/3 of its height to look flattened, matching the game perspective. This way the shadow seems to be projected on the ground.
"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this use of editor description!

manuq and others added 2 commits February 17, 2026 13:10
….gdshader

Co-authored-by: Will Thompson <wjt@endlessaccess.org>
….gdshader

Co-authored-by: Will Thompson <wjt@endlessaccess.org>

// Apply contrast to define the shadow silhouette.
// The result may be outside of the 0-1 range.
shadow = shadow * contrast + 0.5;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wjt very good point, I was keeping the contrast operation separate so I can comment it out, but is better to simplify and not add 0.5 and then immediately substract it. My reference for the contrast operation was https://github.com/patriciogonzalezvivo/lygia/blob/main/color/contrast.glsl

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah OK! Sorry, If you think it's better as it was, that's fine. That reference is useful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at all, shader code should be optimized. The same happens when doing brightness + contrast operation, is preferred to do them both at once https://github.com/patriciogonzalezvivo/lygia/blob/main/color/brightnessContrast.glsl

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I'm sure the shader compiler is smart enough to optimise out the + 0.5 - 0.5; I was more concerned about the shader interpreter in my mind :)

@wjt wjt merged commit c5d9be6 into main Feb 17, 2026
5 checks passed
@wjt wjt deleted the reinstate-clouds-shadow branch February 17, 2026 17:54
@manuq
Copy link
Collaborator Author

manuq commented Feb 17, 2026

The texture may feel too repetitive in the horizontal axis. If this bothers too much, it can be improved in the future by enlarging the ColorRect.

Captura desde 2026-02-17 14-32-23

Also it would be interesting to find an alternative to the Parallax2D for repeating the texture and scrolling it with the camera. Can the canvas shader calculate the camera offset directly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reinstate clouds, fixing performance issues

2 participants