Logarithmic camera#189
Merged
dominik-zeglen merged 4 commits intomainfrom Jun 19, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a logarithmic depth buffer to support astronomic distances and more robust background mesh rendering without relying on vertex shader hacks. Key changes include updates to the shader code (adding vFragDepth and recalculating gl_FragDepth), migration of legacy shader imports to a new PBR-based shader, and adjustments to camera parameters and scene scaling in several engine and builder modules.
Reviewed Changes
Copilot reviewed 20 out of 61 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| ogl-engine/materials/asteroidDust/shader.vert.glsl | Added vFragDepth output and a modified depth computation in the vertex shader for logarithmic depth support. |
| ogl-engine/materials/asteroidDust/shader.frag.glsl | Updated fragment shader to compute gl_FragDepth using logarithmic depth. |
| ogl-engine/materials/AsteroidRock/* | Removal of legacy asteroid rock shaders and update of shader import to use new PBR shader. |
| ogl-engine/materials/AsteroidNew/* | Removal of legacy new asteroid shaders and update of shader import to use new PBR shader. |
| ogl-engine/engine/engine3d.ts | Introduced a new uniform for camera scale to support logarithmic depth functionality. |
| ogl-engine/builders/Star.ts & Asteroids.ts | Adjusted distance and scale parameters to extend the usable range consistent with logarithmic depth. |
| ogl-engine/MapControl.ts | Increased min/max distance settings and removed near plane update logic to support larger viewing distances. |
| devtools/* & core/settings.ts | Updated UI layout/styling and camera near/far settings to align with the new depth buffer configuration. |
Comments suppressed due to low confidence (3)
ogl-engine/materials/asteroidDust/shader.vert.glsl:28
- Consider adding a comment explaining why 1.f is added to gl_Position.w for the logarithmic depth computation to clarify the intent for future maintainers.
vFragDepth = 1.f + gl_Position.w;
ogl-engine/engine/engine3d.ts:52
- Ensure that the camera.scale uniform is updated dynamically during runtime if the camera's zoom or scaling factors change, so that the logarithmic depth computations remain valid.
scale: { value: number };
core/settings.ts:7
- Verify that lowering the near plane from 1e-1 to 1e-2 works as expected with the logarithmic depth buffer, ensuring that potential z-fighting issues are mitigated.
near: 1e-2,
9891f9d to
826ba97
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces logarithmic depth buffer, allowing usage of astronomic distances and background meshes without frustum tricks and cheats in vertex shaders.