Repository navigation
Mandelbulb: free camera with mouse look and WASD in the camera mode - #37
Merged
Merged
Conversation
The camera mode (key C) was an orbit camera moved by the arrows and A/Z. It is now a free camera: the mouse and the arrows turn the view, WASD moves, Space/Left Shift move up and down. The speed is the distance to the surface per second, computed by a CPU copy of the shader DE, so the camera slows down near the surface and a step never jumps over it. The camera position reaches the shader as the translation of Rot, the Dist uniform is removed. The orthographic mode is unchanged.
resetius
force-pushed
the
mandelbulb-fly-camera
branch
from
November 14, 2026 16:24
54ba3a7 to
f3bc8d3
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.
The camera mode of mandelbulb (key C) was an orbit camera: the arrows orbited the fractal and A/Z moved the camera closer or farther. This PR turns it into a free, shooter-like camera that can fly around and into the fractal.
Controls in the camera mode:
The mouse turns the view while the cursor is over the window; the existing
--input:grab_mouse=onoption captures the cursor for unlimited turning. Outside the camera mode nothing changes: the arrows pan and A/Z zoom.What changed:
models/mandelbulb.c: free camera state (position, yaw, pitch, held keys). Movement runs every frame from the key mask of the input events. The speed is the distance to the surface per second, taken fromdistance_estimate, a CPU copy of the shaderDE(). The camera slows down near the surface, and a step is never longer than the distance to the surface, so it does not jump through it. A floor of 1e-3 on the distance keeps the camera movable if it still ends up inside the set, where DE is 0. The distance from the center is limited to 8 because the rays march at most 10 units.Rot; theDistuniform is removed from the uniform block (C struct, vertex and fragment shaders).models/mandelbulb.frag: the camera origin is read fromRot, and a comment asks to keepDE()and its CPU copy in sync.Behavior change: only the camera mode, as described above.
Verification (macOS, AppleClang, CMake + Ninja):
ctest: 3/3 passed.mandelbulb.cand calls the handlers directly:VK_LAYER_KHRONOS_validation(load confirmed withVK_LOADER_DEBUG): 0 messages in the normal and in the camera mode. OpenGL runs without errors in both modes.