Skip to content

Logarithmic camera#189

Merged
dominik-zeglen merged 4 commits intomainfrom
logarythmic-camera
Jun 19, 2025
Merged

Logarithmic camera#189
dominik-zeglen merged 4 commits intomainfrom
logarythmic-camera

Conversation

@dominik-zeglen
Copy link
Copy Markdown
Collaborator

This PR introduces logarithmic depth buffer, allowing usage of astronomic distances and background meshes without frustum tricks and cheats in vertex shaders.

@dominik-zeglen dominik-zeglen requested a review from Copilot June 19, 2025 18:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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,

@dominik-zeglen dominik-zeglen changed the title Logarythmic camera Logarithmic camera Jun 19, 2025
@dominik-zeglen dominik-zeglen merged commit 4b77460 into main Jun 19, 2025
1 check passed
@dominik-zeglen dominik-zeglen deleted the logarythmic-camera branch June 19, 2025 19:42
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.

2 participants