PS1/RSD: smooth vertex colours and MAT lit/unlit support#500
Conversation
Psy-Q MAT G/H encode per-corner RGB; Ogre interpolates VES_DIFFUSE across triangles. A lit FFP pass modulates by N·L and can make gradients look flat on simple shapes compared to Blender's vertex-colour viewport. - PS1PLY: centralize pass setup (lighting off, TVC_DIFFUSE) for coloured PLY. - MeshImporterExporter: match for RSD texture rebinding when submesh has VES_DIFFUSE. Fix Pass::setAmbient/setEmissive to 3-float overloads for Ogre 14. Co-authored-by: Cursor <cursoragent@cursor.com>
Previously importPsyqPlyWithFaceMaterials ran only when at least one MAT entry was textured with a valid TIM. Untextured G rows (per-corner RGB) were sent through importPsyqPlyWithFaceColors using only me.rgb — the first corner — so the Example Project cube looked flat despite F G MAT. Now any non-empty parsed MAT list drives the face-material importer so G/H corner colours reach the mesh; TIM binding still keys off the existing textured-MAT detection. Co-authored-by: Cursor <cursoragent@cursor.com>
📝 WalkthroughWalkthroughAdds a per-face "unlit" MAT flag and tests; centralizes Ogre pass setup via PS1PLY::configurePsyqRsdMaterialPass; propagates unlit state through PLY import/export, textured submesh rebinds, and buckets textured faces by texture+unlit. ChangesPS1 PLY unlit flag, pass helper, import/export wiring
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/PS1/PS1MAT.cpp`:
- Around line 345-346: The code currently collapses both 'G' and 'S'
smooth-shading tokens into 'S', breaking round-trip fidelity; change the shading
calculation to preserve e.shadingChar when it is 'G' or 'S' (e.g. set shading =
e.shadingChar for valid tokens, otherwise 'F') so the output written by the ts
<< ... line emits the original 'G' or 'S' token instead of always 'S'.
In `@src/PS1/PS1PLY.cpp`:
- Around line 544-545: The call in PS1PLY.cpp hard-codes matUnlit=true when
invoking PS1PLY::configurePsyqRsdMaterialPass(p0, haveColors, true), which
invents an unlit/MAT bit for MAT-less PLY imports; change the third argument so
we do not synthesize unlit: compute the unlit flag from the actual pass lighting
state (e.g. use !p0->getLightingEnabled() or otherwise preserve the source
lighting) or simply pass false for MAT-less/face-colour imports, rather than
hard-coding true, so configurePsyqRsdMaterialPass only marks unlit when the
original material/pass indicates it.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e105d4db-a7d8-46ad-8bed-37de79b30c0c
📒 Files selected for processing (6)
src/MeshImporterExporter.cppsrc/PS1/PS1MAT.cppsrc/PS1/PS1MAT.hsrc/PS1/PS1MAT_test.cppsrc/PS1/PS1PLY.cppsrc/PS1/PS1PLY.h
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/PS1/PS1MAT_test.cpp (1)
112-132: ⚡ Quick winAdd explicit
unlitassertions for textured parse fixtures.Line 112 and Line 143 now encode
flag=0, but these tests don’t asserte.unlit == false. Adding that check in both tests will lock the textured parse path to the new flag semantics.Proposed test additions
@@ TEST(PS1MAT, ParseTexturedQuadEntry_HType) ASSERT_EQ(e.vertColors.size(), 4); EXPECT_EQ(e.vertColors[0], QColor(72, 72, 72)); EXPECT_EQ(e.vertColors[3], QColor(80, 80, 80)); + EXPECT_FALSE(e.unlit); @@ TEST(PS1MAT, ParseTexturedTriEntry_TType) EXPECT_EQ(e.uvs[2].u, 50); EXPECT_EQ(e.uvs[2].v, 60); EXPECT_TRUE(e.vertColors.isEmpty()); + EXPECT_FALSE(e.unlit);Also applies to: 143-160
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/PS1/PS1MAT_test.cpp` around lines 112 - 132, The textured-parse tests that call PS1MAT::parseMatFile and inspect the first MatEntry (e) must also assert the new flag semantics by verifying the unlit flag is false; update both relevant test cases (the one that checks e.textured == true and the other similar textured fixture) to include EXPECT_FALSE(e.unlit) or EXPECT_EQ(e.unlit, false) after obtaining const auto& e so the textured parse path is locked to the new flag behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/PS1/PS1MAT_test.cpp`:
- Around line 112-132: The textured-parse tests that call PS1MAT::parseMatFile
and inspect the first MatEntry (e) must also assert the new flag semantics by
verifying the unlit flag is false; update both relevant test cases (the one that
checks e.textured == true and the other similar textured fixture) to include
EXPECT_FALSE(e.unlit) or EXPECT_EQ(e.unlit, false) after obtaining const auto& e
so the textured parse path is locked to the new flag behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a4406dbd-9714-42da-b7f9-557ca1a2b706
📒 Files selected for processing (3)
src/PS1/PS1MAT.cppsrc/PS1/PS1MAT_test.cppsrc/PS1/PS1PLY.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
- src/PS1/PS1MAT.cpp
- src/PS1/PS1PLY.cpp
|



Summary
Fixes PlayStation RSD/PLY imports where Psy-Q
G/ per-corner colours looked flat in QtMeshEditor while Blender showed smooth blending, and preserves the Blender/Psy-Q MAT lit vs unlit flag through RSD import/export.Root cause
N·L, which could make corner colour gradients read almost flat on simple shapes.importPsyqPlyWithFaceMaterialspreviously only ran when a MAT sidecar referenced at least one valid texture.NTEX=0assets fell back to face-colour import and dropped extra Gouraud corner colours.What changed
MatEntry::unlit.unlitintoFaceMaterial, splits textured/untextured Psy-Q submeshes by both texture slot and lighting mode, and names unlit material buckets with_nl._texN_nlmaterials and configures Ogre passes from both vertex-colour presence and the MAT unlit flag.Files
src/MeshImporterExporter.cppsrc/PS1/PS1MAT.cppsrc/PS1/PS1MAT.hsrc/PS1/PS1MAT_test.cppsrc/PS1/PS1PLY.cppsrc/PS1/PS1PLY.hTesting
QT_QPA_PLATFORM=offscreen ./bin/UnitTests --gtest_filter='PS1*'UnitTestsbinary was stale and matched 0 tests.QT_QPA_PLATFORM=offscreen ./bin/UnitTests --gtest_list_testsPS1MATsuite yet.cmake --build . --target UnitTests -j2Made with Cursor
Summary by CodeRabbit
New Features
Bug Fixes
Tests