Skip to content

Lighting element shader#6507

Open
ljm862 wants to merge 3 commits intoRevolutionary-Games:masterfrom
ljm862:lighting_element_shader
Open

Lighting element shader#6507
ljm862 wants to merge 3 commits intoRevolutionary-Games:masterfrom
ljm862:lighting_element_shader

Conversation

@ljm862
Copy link
Contributor

@ljm862 ljm862 commented Nov 25, 2025

Brief Description of What This PR Does

Slightly reworks how lighting works, both for the background and the sunlight coming from the sky.
Not only should this be more performant but also should prevent things slipping into HDR and causing everything to be white and pale. Clamping the cloud brightness as well to aid in this.

Changes the colour of the water depending on what compounds are available:

  • Green - Iron
  • Red - Iron & Oxygen
    Can easily be extended to others that may have an impact in certain mixtures.
    I'd like feedback before merging on these colours so I can adjust the colour formula as I've tried so many tweaks that colours just all look the same now.

Inspired by this thread
Related Issues

Progress Checklist

Note: before starting this checklist the PR should be marked as non-draft.

  • PR author has checked that this PR works as intended and doesn't
    break existing features:
    https://wiki.revolutionarygamesstudio.com/wiki/Testing_Checklist
    (this is important as to not waste the time of Thrive team
    members reviewing this PR)
  • Initial code review passed (this and further items should not be checked by the PR author)
  • Functionality is confirmed working by another person (see above checklist link)
  • Final code review is passed and code conforms to the
    styleguide.

Before merging all CI jobs should finish on this PR without errors, if
there are automatically detected style issues they should be fixed by
the PR author. Merging must follow our
styleguide.


float adjustedAlpha = min(cloud1 + cloud2 + cloud3 + cloud4, 1.0) *
clamp(min(cloud1 + cloud2 + cloud3 + cloud4, 1.0) * 0.5, 0.5, 0.9);
clamp(min(cloud1 + cloud2 + cloud3 + cloud4, 1.0) * 0.5, 0.5, 0.9);
Copy link
Member

Choose a reason for hiding this comment

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

If I counted right this indent is now 3 spaces which is incorrect?


private Vector2 previousWindowSize = new(1280, 720);

private Color previousColor;
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be initialized to the same value as in the shader (1, 1, 1, 1)?

@hhyyrylainen
Copy link
Member

I don't have much time to review this yet, but I have one general question: how does this compile? The microbe editor also sets the light level but I saw no changes to the microbe editor in this PR. So how can it work when the previous light level variable was removed?

@ljm862
Copy link
Contributor Author

ljm862 commented Nov 26, 2025

I don't have much time to review this yet, but I have one general question: how does this compile? The microbe editor also sets the light level but I saw no changes to the microbe editor in this PR. So how can it work when the previous light level variable was removed?

So I'm on my phone so this is all from memory and conjecture because github on mobile is not a fun experience BUT,
light level got set in a few places and we still allow for light level to be set, but not the light level is taken into account for the sky shader only as the sunlight lights up the water. I'll sort out the editor one when I'm back!
I also noticed that trying to set uniforms that don't exist just seems to not throw any sort of error or warning anywhere so if it tried to directly change the shader parameter then it just gets ignored (though it might actually throw an error somewhere which gets hidden and so would have a performance decrease, hmmm I'll have to check that too)

@hhyyrylainen
Copy link
Member

hhyyrylainen commented Nov 27, 2025

if it tried to directly change the shader parameter then it just gets ignored (though it might actually throw an error somewhere which gets hidden and so would have a performance decrease, hmmm I'll have to check that too)

That's quite likely the case then... as you removed the light level parameter (in the shader file) and I'm pretty sure the microbe editor will still try to use that. So the time of day buttons in the microbe editor should not work correctly.

Overall I think you should move the background colour logic into the microbe camera class because the reason why the light level calculation was there originally is that so that the same logic can be shared by the stage and the editor as both want to use it. Without putting the logic there it would need a separate helper method that the editor could also use.

@Deus-Codes
Copy link
Contributor

Playtested this a while ago for only a few minutes I could spare, but great work visually!

One thing I will comment is that the tint effect is really strong, so it can look like an explicit filter applied to an image instead of a dilution or compounds. Perhaps if the tint can be made to look more "muddy" or "diluted", that could be a good balance - maybe retaining a bit of the original color of the background. I trust that you'll find a good balance.

I will also note that in my brief playtest, I didn't get to a point of seeing the oxygen-iron effect, or to see if the red filter disappears eventually to reveal the "actual" color of the waters. That's something we should make sure works well before merging this.

Great start overall however!

@ljm862
Copy link
Contributor Author

ljm862 commented Dec 3, 2025

I've restructured the lighting system a bit with regards to the whole atmosphere colouring and how lighting is affecting the shaders. I've also slightly tweaked the formula a bit for calculating the colour but still not sure if it's really good yet. If anyone has some colour suggestions of what they'd like, it would help a lot! Otherwise I'll keep trying until I get something we're all happy with

@Deus-Codes
Copy link
Contributor

image

I appear to get this error when testing this branch. The color filters also don't appear to be applied unless they are very subtle, so there might be an error here

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

Labels

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

3 participants