Skip to content

Fix Poiyomi UV tiling not preserved during conversion#222

Merged
kurotu merged 7 commits intomasterfrom
copilot/fix-poiyomi-uv-tiling-issue
Mar 16, 2026
Merged

Fix Poiyomi UV tiling not preserved during conversion#222
kurotu merged 7 commits intomasterfrom
copilot/fix-poiyomi-uv-tiling-issue

Conversation

Copy link
Contributor

Copilot AI commented Mar 14, 2026

Poiyomi shaders store UV tiling as a _MainTex_ST Vector4 property rather than Unity's standard texture scale/offset metadata. This causes Material.mainTextureScale/mainTextureOffset to return (1,1)/(0,0), losing UV tiling when converting to Toon Lit or Toon Standard.

Changes

  • MaterialBase.cs: Added virtual MainTextureScale/MainTextureOffset properties so shader-specific subclasses can override UV tiling extraction. ConvertToToonLit() and GenerateToonLitImage() now use these instead of Material.mainTextureScale directly. Baker material explicitly sets UV tiling after shader swap.

  • PoiyomiMaterial.cs: Overrides MainTextureScale/MainTextureOffset to read from Material.GetVector("_MainTex_ST") with fallback to standard API. Fixed stale doc comment.

  • LilToonMaterial.cs: Updated existing MainTextureScale/MainTextureOffset properties to use override keyword, fixing CS0114/CS0108 member hiding warnings caused by the new virtual members on MaterialBase.

  • PoiyomiMaterialTests.cs: Tests for scale/offset extraction from _MainTex_ST, preservation through ConvertToToonLit(), and non-uniform tiling values.

// PoiyomiMaterial reads UV tiling from the Vector4 property
private Vector4 GetMainTexST()
{
    if (Material.HasProperty("_MainTex_ST"))
    {
        return Material.GetVector("_MainTex_ST");
    }
    var scale = Material.mainTextureScale;
    var offset = Material.mainTextureOffset;
    return new Vector4(scale.x, scale.y, offset.x, offset.y);
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix: Poiyomi UV Tiling not preserved during conversion</issue_title>
<issue_description>### タスク概要

PoiyomiマテリアルをToon LitやToon Standardへ変換した際に、UVタイル(mainTextureScaleおよびmainTextureOffsetなど)が正しく引き継がれない問題の修正。

背景・目的

PoiyomiシェーダでmainTextureScale/mainTextureOffsetがデフォルト(1,1)に戻されてしまい、アバターやメッシュの見た目が損なわれる。Poiyomiの独自プロパティから正しいタイル値を取得し、変換マテリアルに反映する必要がある。

技術要件

  • Poiyomiのメインテクスチャのスケール・オフセットが変換後も維持されていること
  • lilToonと同様にMaterialWrapper等を抽象化・リファクタして汎用的なUVタイル抽出処理を追加
  • PoiyomiのUVタイルを格納するプロパティ(例: _MainTex_STや独自パラメータ)から正確に取得
  • 自動テスト追加:X:1, Y:1以外のタイル値を含むケース
  • Bake処理にも正しいスケール/オフセットが反映されること

補足情報

  • 親Issue: UV Tiling Not Translated #217
  • パス: Editor/Models/Unity/PoiyomiMaterial.cs, Editor/Models/Unity/MaterialBase.cs, Shader/vqt_poiyomi.shader
  • アセット例: Mitsumame(https://booth.pm/en/items/5748454), Poiyomi(9.3.64)
  • Poiyomi独自のUVタイル取得方法に注意
  • Poiyomi インストール方法
    vrc-get repo add https://poiyomi.github.io/vpm/index.json
    vrc-get install com.poiyomi.toon
  • Packages/packages-lock.json, Packages/vpm-manifest.json, ProjectSettings/* をコミットしないこと

完了条件

  • Poiyomiマテリアル変換時に、UVタイル(スケール・オフセット)が正しく反映されていることを手動・自動テストで確認
  • 親Issueの再現手順例で問題が再発しないこと</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 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.

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
Copilot AI requested a review from kurotu March 14, 2026 00:47
Copilot AI and others added 5 commits March 15, 2026 12:37
- 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>
@kurotu kurotu force-pushed the copilot/fix-poiyomi-uv-tiling-issue branch from f0c5fae to 87afdca Compare March 15, 2026 05:04
@kurotu kurotu force-pushed the copilot/fix-poiyomi-uv-tiling-issue branch from 87afdca to f772b05 Compare March 15, 2026 12:02
@kurotu kurotu marked this pull request as ready for review March 15, 2026 12:04
Copilot AI review requested due to automatic review settings March 15, 2026 12:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

… fix member hiding

Co-authored-by: kurotu <74851548+kurotu@users.noreply.github.com>
@kurotu kurotu merged commit def770d into master Mar 16, 2026
35 checks passed
@kurotu kurotu deleted the copilot/fix-poiyomi-uv-tiling-issue branch March 16, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: Poiyomi UV Tiling not preserved during conversion

3 participants