From ba7ea27ddee4398afa98a0e45b9e227bbcfae906 Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 8 Mar 2026 11:36:04 +0100 Subject: fix: negate Y in perspective() to correct rasterized 3D orientation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fullscreen post-process VS uses Y-up UVs (uv.y=0 = bottom), so textureSample() Y-flips any rasterized offscreen texture. SDF effects author their content Y-down and look correct after the flip. Rasterized effects (RotatingCube, Hybrid3D) must pre-flip their geometry: - mat4::perspective(): m[5] = -t (negated Y scale) - Pipelines with cullMode=Back: frontFace = WGPUFrontFace_CW (Y-flip reverses winding, so CW becomes the visible face) - Remove incorrect transposes from GlobalUniforms::make(), ObjectData::make(), and Uniforms::make() — mini_math is column-major, no transpose needed for GPU upload - Document the convention in doc/3D.md under "Rasterized 3D and the Y-flip rule" handoff(Gemini): Y-flip rule now documented; all rasterized 3D pipelines must follow it. Co-Authored-By: Claude Sonnet 4.6 --- src/effects/rotating_cube_effect.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/effects/rotating_cube_effect.h') diff --git a/src/effects/rotating_cube_effect.h b/src/effects/rotating_cube_effect.h index 920be5c..fb321fa 100644 --- a/src/effects/rotating_cube_effect.h +++ b/src/effects/rotating_cube_effect.h @@ -29,12 +29,9 @@ class RotatingCube : public Effect { float aspect_ratio; float _pad; - // Transpose matrices: mini_math is row-major, WGSL expects column-major. static Uniforms make(const mat4& vp, const vec4& cam_pos_time, const vec4& p, const vec2& res, float asp) { - return {mat4::transpose(vp), mat4::transpose(vp.inverse()), - cam_pos_time, p, - res, asp}; + return {vp, vp.inverse(), cam_pos_time, p, res, asp}; } }; static_assert(sizeof(Uniforms) == 176, "Uniforms size mismatch"); -- cgit v1.2.3