Skip to content

Add direct sun transmittance for physically correct surface lighting#71

Merged
samcake merged 1 commit into
mainfrom
claudio
Apr 17, 2026
Merged

Add direct sun transmittance for physically correct surface lighting#71
samcake merged 1 commit into
mainfrom
claudio

Conversation

@samcake
Copy link
Copy Markdown
Owner

@samcake samcake commented Apr 17, 2026

Introduce sky_sunTransmittance() in Sky_inc.hlsl: marches from a given point to the top of atmosphere along the sun direction and returns exp(-tau), the fraction of sunlight not scattered away. getSunDirLight() uses it to compute the direct solar beam color inline in the shader.

Mirror the same transmittance march on the CPU (computeSunDirLight) so SkyData._sunDirLight stays in sync with sun direction and intensity changes, keeping the GPU buffer consistent.

Fix ModelPart and Heightmap shaders: separate ambient (SH irradiance * albedo) from direct (getSunDirLight() through the PBR BRDF), replacing the previous SkyColor(sunDir) which was returning scattered glow rather than the direct beam.

Introduce sky_sunTransmittance() in Sky_inc.hlsl: marches from a given
point to the top of atmosphere along the sun direction and returns
exp(-tau), the fraction of sunlight not scattered away. getSunDirLight()
uses it to compute the direct solar beam color inline in the shader.

Mirror the same transmittance march on the CPU (computeSunDirLight) so
SkyData._sunDirLight stays in sync with sun direction and intensity
changes, keeping the GPU buffer consistent.

Fix ModelPart and Heightmap shaders: separate ambient (SH irradiance *
albedo) from direct (getSunDirLight() through the PBR BRDF), replacing
the previous SkyColor(sunDir) which was returning scattered glow rather
than the direct beam.
@samcake samcake merged commit 4e753b5 into main Apr 17, 2026
2 checks passed
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.

1 participant