-
Notifications
You must be signed in to change notification settings - Fork 18
Add Posterize option to LTCGI Diffuse #85
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
Conversation
Hmm, I'm not really sure I want to add a branch just for this 🤔 The v2 of the toon shader (which is what I assume this is meant to be used with) could probably support an extra spot where you posterize the LTCGI results in its own module. However, thinking about it some more it feels like doing something like using the Toon Ramp and other shading settings might be what you actually want? Then instead of just pure posterization with discrete steps - you could have full ramp-based control over how the diffuse shading from LTCGI is applied? 🤔 |
In a separate LTCGI module, or using a compiler directive in the current one? I hadn't really considered a Toon Ramp, though that could be useful and easier to customize. And yes this effect is primarily for LTCGI on Toon, aiming to make it look more "Toony" to fit with the aesthetic. |
Probably a separate module So for this kinda thing i could imagine LTCGI putting data into something like |
Gave Toon it's own LTCGI module with Texture Ramp support. |
oh I meant that I could set up something like that for the 2.0 version, not the current one |
The |
the |
Ah ok |
The This is also supported by the Toon shader now.
|
Updated the Toon LTCGI and CustomGI Ramp modules, thought having it as a separate module would become useful for providing Toon Ramping for other CustomGI FX (perhaps AreaLit and VRSLGI). Also should I remove the LTCGI Toon module from V1? |
Have you tested it in Toon v1? As I'm pretty sure toon v1 doesn't have any hook points for |
I have not tested the V2 LTCGI Toon Module with V1 Toon, |
The V1 LTCGI Toon Module still functions with V1 Toon, using |
yeah, ok, that's about what I expected, as Toon v1 doesnt have %CustomGI hooks |
if (_LTCGIClampBrightness) { | ||
half3 hsv = RGB2HSV(ltcgiData.specular); | ||
hsv.z = tanh(hsv.z) * max(0, _LTCGIMaxBrightness); | ||
indirectSpecular += HSV2RGB(hsv) * _LTCGISpecularIntensity; | ||
} else { | ||
indirectSpecular += ltcgiData.specular * _LTCGISpecularIntensity; | ||
} | ||
indirectDiffuse += ltcgiData.diffuse * _LTCGIDiffuseIntensity; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just getting back to this. Shouldn't this also include all the ramp stuff like you did in the %%Color block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe that is ever used in Toon V1? but I'll include it anyways.
%Color("LTCGIColor") | ||
{ | ||
void LTCGIColor(MeshData d, FragmentData i, inout half4 FinalColor, bool facing) | ||
{ | ||
#if defined(ORL_LIGHTING_MODEL_VFX) | ||
{ | ||
#if defined(PLAT_QUEST) | ||
if (!_LTCGIEnableOnMobile) return; | ||
#endif | ||
|
||
#if defined(INTEGRATE_LTCGI) | ||
LTCGIAccumulatorStruct ltcgiData = (LTCGIAccumulatorStruct) 0; | ||
|
||
float3 viewDir = d.worldSpaceViewDir; | ||
if (!facing) | ||
{ | ||
viewDir = -d.worldSpaceViewDir; | ||
} | ||
|
||
LTCGI_Contribution( | ||
ltcgiData, | ||
d.worldSpacePosition.xyz, | ||
d.worldNormal.xyz, | ||
viewDir, | ||
saturate(0.5 + _LTCGIRoughnessModifier), | ||
d.uv1.xy | ||
); | ||
|
||
if (_LTCGIClampBrightness) { | ||
half3 hsv = RGB2HSV(ltcgiData.specular); | ||
hsv.z = tanh(hsv.z) * max(0, _LTCGIMaxBrightness); | ||
FinalColor.rgb += HSV2RGB(hsv) * _LTCGISpecularIntensity; | ||
} else { | ||
FinalColor.rgb += ltcgiData.specular * _LTCGISpecularIntensity; | ||
} | ||
FinalColor.rgb += ltcgiData.diffuse * _LTCGIDiffuseIntensity; | ||
if (_LTCGIAlphaPremultiply) | ||
{ | ||
FinalColor.rgb *= FinalColor.a; | ||
} | ||
#endif | ||
} | ||
#endif | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this needed? 🤔
wouldn't the main LTCGI module (non-toon) already handle that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main LTCGI module could with a compiler directive,
Toon needs "d.worldNormal.xyz" and has no "o.Smoothness",
Other than that it's pretty much the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does Toon V2 provide a directive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, as of a couple dev releases ago, its the same as TOON, but with V2 at the end
ORL_LIGHTING_MODEL_TOON_V2
However, my point here was that this part is limited to ORL_LIGHTING_MODEL_VFX
and im not sure why do we need a separate VFX-only block in a toon version of LTCGI, when the main LTCGI already works with VFX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need a Toon V2 specific variant of LTCGI, that is an oversight on my part.
I was referring to having a slightly different function call in the existing LTCGI (removing the LTCGI Toon V2), that would use d.worldNormal
instead of d.normal
and skip o.Smoothness
as it is currently not defined in the Toon V2 base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't see that, will look into that then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's from the original LTCGI module for PBR, I didn't realize it wasn't being used anymore.
Also why does the PBR LTCGI Module use NORMAL instead of WORLDNORMAL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the "PBR" module is meant to be used for both PBR and VFX, only Toon needed special treatment. So you dont need to add a Color
block for just VFX in the Toon v2. As it is only meant to be used in the Toon v2 lighting model.
As for Normal vs WorldNormal
Both of them are World Normals inside the FragmentBase
function, the "correct" move there would be to do what I did in toon v2 and have Normal
be Tangent Normal and then WorldNormal
be the.. well world normal.
But due to lack of foresight - i just converted o.Normal
to world space up-top in the PBR Fragment Base, as for the longest time - there was no way to extend the actual FragmentBase function from an outside module. And then i saved the original o.Normal
(which is what the individual modules interact with) into tangentNormal
at the top of FragmentBase
as well
Then when I wrote Toon v2, since the whole lighting function is modularized - i ended up adding another surface struct property - WorldNormal
and left Normal
untouched, so its very clear which is which.
But that in turn created conflicts with CustomGI modules. Which are unfortunate, but I generally think that it was the better choice (and I might just change the PBR to use the new naming as well? but im still thinking about it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I've removed the %Color
from Toon V2 and %CustomGI
from Toon V1,
And model compiler directive checks for both seeing as they should be unused now.
No description provided.