summaryrefslogtreecommitdiff
path: root/assets/final/shaders/mesh_render.wgsl
AgeCommit message (Collapse)Author
11 hoursfix(shaders): Correct mesh normal transformation - remove double transposeskal
Fixed critical bug in normal matrix transformation causing mesh stretching and incorrect scaling during rotation. ROOT CAUSE: In WGSL, mat3x3(v0, v1, v2) creates a matrix where v0, v1, v2 are COLUMNS. When extracting rows from inv_model, the constructor already produces the transpose. Applying transpose() again cancels out, giving incorrect normals. ISSUE: let normal_matrix = mat3x3(inv_model[0].xyz, inv_model[1].xyz, inv_model[2].xyz); // This gives transpose(inv_model) already! out.normal = normalize(transpose(normal_matrix) * in.normal); // Double transpose = identity, wrong result FIX: let normal_matrix = mat3x3(inv_model[0].xyz, inv_model[1].xyz, inv_model[2].xyz); // Already transpose(inv_model), which is the correct normal matrix out.normal = normalize(normal_matrix * in.normal); // Correct transformation FILES FIXED: - assets/final/shaders/mesh_render.wgsl:38 (mesh vertex normals) - assets/final/shaders/renderer_3d.wgsl:185 (SDF bump-mapped normals) RESULT: Mesh normals now transform correctly under rotation and non-uniform scaling. Fixes Task A (test_mesh visualization stretching bug). handoff(Claude): Normal transformation bug fixed. Mesh should now render correctly without stretching. Shadow bug on floor plane still remains (separate WGSL shader issue for later investigation).
11 hoursfix: Correct mesh normal transformation and floor shadow renderingskal
13 hoursfeat(3d): Implement basic OBJ mesh asset pipelineskal
Added support for loading and rendering OBJ meshes. - Updated asset_packer to parse .obj files into a binary format. - Added MeshAsset and GetMeshAsset helper to asset_manager. - Extended Object3D with mesh_asset_id and ObjectType::MESH. - Implemented mesh rasterization pipeline in Renderer3D. - Added a sample cube mesh and verified in test_3d_render.