0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

unityでshaderに動的に数値を設定しても動かなかった話

Posted at

先に結論

materialがinstanceされてて
数値指定は非instanceのマテリアルに当たってた。

症状

・unityからuniformでshaderにsetfloatで数値を渡していた
・挙動が切り替わる変数と切り替わらない変数があった
・getfloatで数値が切り替わってることは確認していた

原因(ポカ)

・数値を切り替えるスクリプトが複数あり、
 起動後にマテリアルを取得するものと、手動でアタッチしているものがあった。
 前者はうまく動き、後者がうまく行っていなかった
・glslだったため、実機でテストしていてinstance化に気付いていなかった

対応

・スタートでマテリアルを取得するようにした

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?