Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_MainTex_ST の参照を修正 #2573

Merged
merged 6 commits into from
Feb 4, 2025
Merged

Conversation

ousttrue
Copy link
Contributor

@ousttrue ousttrue commented Feb 3, 2025

PreviewMaterialItem に残存していた "_MainTex_ST" 参照を修正しました。

また、 VRM10Viewer サンプルで ShaderGraph Material の動確をしました。
Expose した Texture2D プロパティに対する Set as Main Texture が必要です。

set_as_main_texture

_MainTex ではなく _BaseMap 名で動作しました。

MainTexture flag が無いと出るエラーメッセージ

hook.js:608 Material 'robo_face' with Shader 'Shader Graphs/CustomMToonOpaque' doesn't have a texture property '_MainTex'

Copy link
Contributor

@Santarh Santarh left a comment

Choose a reason for hiding this comment

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

いくつか命名面でのポイントが気になりました

@@ -9,6 +10,8 @@ public class VRM10VisualPrimitive : MonoBehaviour
{
[SerializeField] private PrimitiveType _primitiveType;

[SerializeField] private Material _urpMaterial;
Copy link
Contributor

Choose a reason for hiding this comment

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

できれば「WebGL 用マテリアル」の意味合いの名称の方が良いと思います。
URP 自体への対応はこのクラスは元からできています。
そのうえで WebGL でのみ例外的処理を行うという意味合いだと思うので。

未来にコードを読んだときに、混乱しそうです。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WebGL に限らずビルドした場合に要るような気がしてきた。
実験します。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

build すると desktop でも要るようです。

Copy link
Contributor

Choose a reason for hiding this comment

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

現状だとたしかにそうですね!


namespace UniVRM10.VRM10Viewer
{
public class CustomMaterialContext
Copy link
Contributor

Choose a reason for hiding this comment

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

この名称だと汎用的すぎて、特別な意味を感じません。
未来にコードを読んだときに混乱しそうです。

このクラスは、ある一意なシェーダに対応する操作コンテキストになると思うので、シェーダ名を一意なものに決めるべきだなと感じます。

たとえばシェーダ名を TinyPbr などと命名したと仮定して
CustomMaterialContextTinyPbrContext
CustomMaterialDescriptorGeneratorForcedTinyPbrMaterialDescriptorGenerator
等の命名がふさわしく感じます。

Copy link
Contributor

Choose a reason for hiding this comment

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

もしくはこのクラスが「カスタムな任意のシェーダを割り当てる用の便利クラスなんだ」という定義なのであれば
このクラスの summary コメントに「このコンテキストに与えるマテリアルのシェーダは以下の命名規則に従っていることを期待する」等のコメントが欲しいです。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

命名規則のガイドラインを考えます。
ユニーク(namespaceに頼らない)なシェーダー名を最初に決める。

@ousttrue
Copy link
Contributor Author

ousttrue commented Feb 4, 2025

TinyPbr に改名しました。
このPRは _MainTex_ST の修正が主です。

WebGL 環境での動確に伴って ShaderGrfaph 製カスタムシェーダーの導入を兼ねました。
カスタムシェーダーはのちのPRで整備する予定です。

https://vrm.dev/api/material/make_custom_material/

@ousttrue ousttrue requested a review from Santarh February 4, 2025 07:43
[Header("UI")]
[SerializeField]
Toggle m_useCustomMaterial = default;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

VRM10Viewer の CustomMaterial として TinyPbr を使う感じ

using UnityEngine;

namespace UniVRM10.VRM10Viewer
{
/// <summary>
/// GLTF の MaterialImporter
/// </summary>
public sealed class CustomMaterialDescriptorGenerator : IMaterialDescriptorGenerator
public sealed class TinyPbrDescriptorGenerator : IMaterialDescriptorGenerator
Copy link
Contributor

Choose a reason for hiding this comment

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

あ、すみません。
あくまで MaterialDescriptorGenerator なので TinyPbrMaterialDescriptorGenerator が正しいと思います

Copy link
Contributor Author

Choose a reason for hiding this comment

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

次でなおしま 🙏

@ousttrue ousttrue merged commit 71e4a71 into vrm-c:master Feb 4, 2025
1 check passed
@ousttrue ousttrue deleted the fix/custom_material branch February 4, 2025 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants