Add Pbr Correct mode.

This commit is contained in:
Masataka SUMI
2021-07-15 19:47:22 +09:00
parent 3cb5d97c44
commit eb532c4aa6
2 changed files with 17 additions and 0 deletions

View File

@@ -18,6 +18,12 @@
#define MTOON_IS_FRONT_VFACE(VAL, FRONT, BACK) ((VAL > 0.0) ? (FRONT) : (BACK))
#endif
// Compile-time constant
inline bool MToon_IsPbrCorrectOn()
{
return false;
}
// Compile-time constant
inline bool MToon_IsForwardBasePass()
{

View File

@@ -38,6 +38,12 @@ inline half GetMToonLighting_Shade(const UnityLighting lighting, const MToonInpu
const half shadeShift = GetMToonLighting_Reflectance_ShadingShift(input);
const half shadeToony = _ShadingToonyFactor;
if (MToon_IsPbrCorrectOn())
{
const half shadeInput = dotNL;
return mtoon_linearstep(-1.0 + shadeToony, +1.0 - shadeToony, shadeInput + shadeShift);
}
if (MToon_IsForwardBasePass())
{
const half shadeInput = lerp(-1, 1, mtoon_linearstep(-1, 1, dotNL) * lighting.directLightAttenuation);
@@ -52,6 +58,11 @@ inline half GetMToonLighting_Shade(const UnityLighting lighting, const MToonInpu
inline half GetMToonLighting_Shadow(const UnityLighting lighting, const half dotNL)
{
if (MToon_IsPbrCorrectOn())
{
return lighting.directLightAttenuation * (min(0, dotNL) + 1);
}
if (MToon_IsForwardBasePass())
{
return 1;