Fix Poiyomi UV tiling not preserved during conversion#222
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix Poiyomi UV tiling not preserved during conversion
Fix Poiyomi UV tiling not preserved during conversion
Mar 14, 2026
- Add virtual MainTextureScale/MainTextureOffset properties to MaterialBase - Override in PoiyomiMaterial to read from _MainTex_ST Vector4 property - Update ConvertToToonLit() to use virtual properties - Explicitly set UV tiling on baker material after shader swap in GenerateToonLitImage() - Add PoiyomiMaterialTests for UV tiling extraction - Fix PoiyomiMaterial doc comment and add copyright header Co-authored-by: kurotu <74851548+kurotu@users.noreply.github.com>
Fix MaterialBase.GenerateToonLitImage() to reset _MainTex UV tiling to (1,1,0,0) before baking instead of applying MainTextureScale/MainTextureOffset. This prevents the baked texture from embedding UV tiling while the output Toon Lit material already carries it via mainTextureScale/mainTextureOffset (set by ConvertToToonLit), which would cause double-tiling at runtime. Add ConvertToToonLit_PreservesDefaultUVTiling to PoiyomiMaterialTests to cover the default-UV case. Add PoiyomiToonLitGeneratorTests with four test cases mirroring the equivalent lilToon tests: - ConvertToToonLit_NonBake_PreservesMainTextureScaleAndOffset - ConvertToToonLit_NonBake_PreservesDefaultMainTextureST - ConvertToToonLit_WithBake_PreservesMainTextureScaleAndOffset - ConvertToToonLit_WithBake_BakedTextureDoesNotEmbedUVTiling All 8 Poiyomi tests pass (no failures, 0 skipped). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Install com.poiyomi.toon 9.3.64 via vrc-get and rewrite Poiyomi tests to use the actual '.poiyomi/Poiyomi Toon' shader instead of the internal proxy. - Add AssetUtility.IsPoiyomiImported() (shader + Poi.Tools.PoiImportExportChecker) - Rewrite PoiyomiMaterialTests to use real shader with IsPoiyomiImported() guard - Rewrite PoiyomiToonLitGeneratorTests to use real shader with IsPoiyomiImported() guard - Add com.poiyomi.toon 9.3.64 to vpm-manifest.json Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
f0c5fae to
87afdca
Compare
87afdca to
f772b05
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Toon Lit material conversion for Poiyomi materials by correctly preserving main texture UV tiling (including Poiyomi’s _MainTex_ST storage) and avoiding double-tiling when baking textures. It also extends CI to install Poiyomi so the new tests can run.
Changes:
- Add Poiyomi import detection and Poiyomi-specific UV tiling extraction from
_MainTex_ST. - Update Toon Lit conversion/baking flow to apply UV tiling on the output material while baking with identity tiling (prevents double-tiling).
- Add Poiyomi-focused editor tests and update CI workflow to include the Poiyomi VPM repo/package.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Packages/com.github.kurotu.vrc-quest-tools/Editor/Utils/AssetUtility.cs | Adds IsPoiyomiImported() helper for conditional Poiyomi behavior/tests. |
| Packages/com.github.kurotu.vrc-quest-tools/Editor/Models/Unity/PoiyomiMaterial.cs | Reads UV tiling from _MainTex_ST and exposes it via overrides. |
| Packages/com.github.kurotu.vrc-quest-tools/Editor/Models/Unity/MaterialBase.cs | Introduces virtual UV tiling accessors; resets bake-time tiling to avoid embedding. |
| Assets/VRCQuestTools-Tests/Editor/Models/Unity/PoiyomiMaterialTests.cs (+ .meta) | Adds unit tests for _MainTex_ST tiling extraction and Toon Lit conversion preservation. |
| Assets/VRCQuestTools-Tests/Editor/Models/MaterialGenerators/PoiyomiToonLitGeneratorTests.cs (+ .meta) | Adds generator-level tests ensuring baking preserves scale/offset but doesn’t embed tiling into pixels. |
| .github/workflows/build.yml | Adds Poiyomi VPM repo and includes com.poiyomi.toon in the “latest deps” test matrix entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Packages/com.github.kurotu.vrc-quest-tools/Editor/Models/Unity/MaterialBase.cs
Show resolved
Hide resolved
… fix member hiding Co-authored-by: kurotu <74851548+kurotu@users.noreply.github.com>
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.
Poiyomi shaders store UV tiling as a
_MainTex_STVector4 property rather than Unity's standard texture scale/offset metadata. This causesMaterial.mainTextureScale/mainTextureOffsetto return(1,1)/(0,0), losing UV tiling when converting to Toon Lit or Toon Standard.Changes
MaterialBase.cs: Added virtualMainTextureScale/MainTextureOffsetproperties so shader-specific subclasses can override UV tiling extraction.ConvertToToonLit()andGenerateToonLitImage()now use these instead ofMaterial.mainTextureScaledirectly. Baker material explicitly sets UV tiling after shader swap.PoiyomiMaterial.cs: OverridesMainTextureScale/MainTextureOffsetto read fromMaterial.GetVector("_MainTex_ST")with fallback to standard API. Fixed stale doc comment.LilToonMaterial.cs: Updated existingMainTextureScale/MainTextureOffsetproperties to useoverridekeyword, fixing CS0114/CS0108 member hiding warnings caused by the new virtual members onMaterialBase.PoiyomiMaterialTests.cs: Tests for scale/offset extraction from_MainTex_ST, preservation throughConvertToToonLit(), and non-uniform tiling values.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.