Skip to content

Calculate star opacity with ambientLight instead of dayCycle - #3045

Merged
IntegratedQuantum merged 10 commits into
PixelGuys:masterfrom
AfmanS:starOpacity
Jun 20, 2026
Merged

IntegratedQuantum merged 10 commits into
PixelGuys:masterfrom
AfmanS:starOpacity

Conversation

@AfmanS

@AfmanS AfmanS commented May 6, 2026

Copy link
Copy Markdown
Contributor

In preparation for an asymmetric day-night cycle (#1211), I think it makes more sense, is simpler and faster for star opacity to be based on ambient light. This way it's not coupled to the very specific transitions between times of day. I tested and it looks fine.
I checked and the if (starOpacity != 0) { block is not entered during the day and at night starOpacity is 1. I used std.debug.print("{d}\n", .{starOpacity }); (in case {d} does some FP rounding magic I should know).

@codemob-dev codemob-dev moved this to Easy to Review in PRs to review May 6, 2026

@IntegratedQuantum IntegratedQuantum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't like that this creates a dependence between the brightness of the blocks and the brightness of the stars (and you already feel the problems of it here, with the magic constant 0.9).
I think it would be better to have some struct that stores the time of day and has functions to query the brightness as well as other properties.

@IntegratedQuantum IntegratedQuantum moved this from Easy to Review to In review in PRs to review May 11, 2026
@AfmanS

AfmanS commented May 11, 2026

Copy link
Copy Markdown
Contributor Author

I think it would be better to have some struct that stores the time of day and has functions to query the brightness as well as other properties.

You mean something like removing dayNightLightFactor from World and placing it in another struct dedicated to day length, day cycle transitions and star opacity?

fn dayNightLightFactor(gameTime: i64) struct { f32, Vec3f } {

@IntegratedQuantum

Copy link
Copy Markdown
Member

Yeah, basically all functions that relate to the day-night cycle should be in one place.

@AfmanS

AfmanS commented May 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Quite some changes... The change to the star rotation makes it realistic, with a full rotation per day. But it does look faster.

@AfmanS
AfmanS requested a review from IntegratedQuantum May 14, 2026 19:20
Comment thread src/gui/windows/debug.zig Outdated
Comment thread src/gui/windows/multiplayer.zig Outdated
Comment thread src/server/world.zig Outdated
@AfmanS
AfmanS requested a review from IntegratedQuantum May 17, 2026 08:57
Comment thread src/game.zig Outdated
Comment thread src/game.zig Outdated
ambientLight: f32 = 0,
dayTime: i64 = 0,

pub fn getNightStart() u63 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could be a constant.

Also, following the previous code, I think this should be midnight.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'd argue it's more useful for it to be the start of each day phase, someone who sets night probably wants it longer rather than shorter, name for day

@IntegratedQuantum IntegratedQuantum Jun 19, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then please introduce a dayStart constant that is used in the other case to make the /time command consistant.

(and also adjust the nightStart constant to actually be at night start)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread src/game.zig Outdated
Comment thread src/game.zig Outdated
Comment thread src/game.zig Outdated
@AfmanS
AfmanS requested a review from IntegratedQuantum June 18, 2026 15:34

@IntegratedQuantum IntegratedQuantum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please solve the night start/midnight inconsistency.

@AfmanS
AfmanS requested a review from IntegratedQuantum June 20, 2026 10:19
@IntegratedQuantum
IntegratedQuantum merged commit 2d3a019 into PixelGuys:master Jun 20, 2026
1 check passed
@AfmanS
AfmanS deleted the starOpacity branch June 20, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants