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

鏡の世界の描画など通常でないカメラレンダリングにおいて陰影が反転する #16

Closed
Santarh opened this issue Oct 14, 2018 · 6 comments
Labels
bug Something isn't working

Comments

@Santarh
Copy link
Owner

Santarh commented Oct 14, 2018

  • カメラの1軸を反転する
  • GL.invertCulling を有効にする

という状況で起こる、らしい。

おそらく後者の inverse が VFACE に反映されず法線が反転しているのではないか

@Santarh
Copy link
Owner Author

Santarh commented Nov 2, 2018

@Santarh
Copy link
Owner Author

Santarh commented Nov 2, 2018

Surface shader の Input 構造体に VFACE セマンティクスを用いたものを書いて Generate したところ (Unity 2018.2) 下記の記述が出力された。
これを適用する。

  #if UNITY_VFACE_FLIPPED
     vface = -vface;
  #endif

@Santarh
Copy link
Owner Author

Santarh commented Nov 2, 2018

適用しても、想定する状況でこのマクロが define されないので働かない。

@Santarh
Copy link
Owner Author

Santarh commented Nov 2, 2018

Surface Shader でも働いてない。

@Santarh
Copy link
Owner Author

Santarh commented Nov 2, 2018

描画される面の法線 N はカメラ方向ベクトル V に対して必ず dot(N, V) > 0 であると仮定できるのでそれを用いて法線を必ずカメラ側に向かせる。

@Santarh Santarh closed this as completed in 79be871 Nov 2, 2018
@Santarh Santarh added the bug Something isn't working label Nov 4, 2018
@Santarh
Copy link
Owner Author

Santarh commented Jun 14, 2021

Unity 2019.4.14f1 では、主旨の状況での VFACE の値は期待通りになっており、直っている

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant