Inspect the relationship#
Move model transforms independently of camera distance and projection.
Move the world. Move the camera. This illustration uses canvas. The explanation below describes the same process.
Try these experiments#
- Reset, then change rotation while leaving translation and scale alone. The object rotates around its local origin.
- Translate X and compare the object against the world axes. Translation changes placement, not the camera lens.
- Change camera distance, then field of view. Both change apparent size, with different perspective relationships.
- Focus the canvas and use arrow keys, or drag to orbit the illustration.
What the illustration calculates#
Each vertex is transformed in model space, rotated into the view, shifted to positive camera depth, and projected with a perspective divide. The software renderer tests triangle coverage and uses a depth buffer. Axes and the ground grid are explanatory overlays. A real backend produces clip-space coordinates in the vertex shader and lets the GPU rasterizer handle clipping and projection. The lab omits general near-plane clipping; its permitted camera range keeps this scene in front of the camera. It is not a substitute for a complete clipping implementation.
Connect the numbers to the engine#
Scene owns the object’s local transform and computes its world transform. CameraData owns viewing/projection parameters. RenderWorld carries the values into a frame-safe binding. Changing scale in the editor should never mutate shared MeshAsset vertices for every instance.
Read the shared native convention
// Row-vector convention; matrix storage is explicitly row-major.
float4 clip = mul(float4(localPosition, 1), worldViewProjection);The complete shader declares the matrix and entry points in samples/dx12/Shaders/Scene.hlsl. DirectXMath composes world × view × projection in main.cpp. The Vulkan backend keeps the engine convention but handles its framebuffer-Y policy deliberately.
What to inspect when it is wrong#
A reversed axis suggests a convention mismatch. A stale aspect ratio stretches the result after resize. A rotation around the wrong point suggests operation order or origin. Inspect one known point in each coordinate space before adding matrix transposes. Read transforms and cameras and scene hierarchy.