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

MToonで発生するNaNを条件演算子でシンプルに回避出来そう #2243

Open
FujiSunflower opened this issue Feb 8, 2024 · 0 comments
Milestone

Comments

@FujiSunflower
Copy link
Contributor

FujiSunflower commented Feb 8, 2024

該当箇所

EPS_COLは値のソフトニング目的らしい

const half3 parametricRimFactor = pow(saturate(1.0 - dot(input.normalWS, input.viewDirWS) + _RimLift), max(_RimFresnelPower, EPS_COL)) * _RimColor.rgb;

提案

条件演算子で1度の計算がやや長くなるが、シェーダモデル3以上なら動きそう
const half3 parametricRimFactor = _RimFresnelPower == 0.0 ? _RimColor.rgb : pow(saturate(1.0 - dot(input.normalWS, input.viewDirWS) + _RimLift), _RimFresnelPower) * _RimColor.rgb;

補足

シェーダのif節は有名な通り処理がその分増えますが、条件演算子は結構シンプルでどっちの値を選ぶかという処理になったはずです。
参考ページ https://light11.hatenadiary.com/entry/2018/07/08/134440

@ousttrue ousttrue added this to the v0.122 milestone Mar 19, 2024
@ousttrue ousttrue modified the milestones: v0.122 ktx2 y-flip, v0.123 May 10, 2024
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

No branches or pull requests

2 participants