1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【VRChat】アバターで Depth テクスチャを使う場合の注意点

Posted at

概要

アバターのシェーダーで Depth テクスチャを使用する場合,VRChat で動作させるために追加のセットアップが必要だったので,そのメモです.

シェーダー

シェーダー内で Depth テクスチャの宣言とサンプリングをする際に,Unity のマクロを使用します.VRChat での Single Pass Stereo Rendering への対応のようです.

// Depth テクスチャの宣言
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);

// Depth テクスチャのサンプリング
SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, uv);

Directional Light

リアルタイムの影がないワールドでは Depth テクスチャが生成されないので,アバターの中に Directional Light 仕込みます.ワールドのライティングに影響しないよう,Color や Intensity をなるべく小さい値にしておきます.Shadow Type が None だと Depth テクスチャが生成されないので,Soft Shadows とかにしておきます.Culling Mask には,Depth を取りたいレイヤーを設定します.ここから除いたレイヤーは Depth に書き込まれなくなります(ワールド側の設定よってはこの限りではありません).
特に,アバターギミックのカメラの Depth テクスチャを取りたい場合はアバター内部に Light が必須のようです.

image.png

雑記

Unity で調整して,いざ持っていったら動かず焦りましたが,やり方があってよかったです.
「vrchat avatar _CameraDepthTexture」とかで検索すると,たくさん情報が出てきます.

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?