Skip to content

Commit

Permalink
add cbirp reflection probes separate toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
z3y committed Jan 22, 2025
1 parent ed258a9 commit 8f3bdac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Editor/Targets/Lit/FragmentForward.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,16 @@ half4 frag(Varyings varyings) : SV_Target

ComputeCBIRPLights(cluster, shadowmask, fragData, giInput, surf, giOutput);

giOutput.indirectSpecular = CBIRP::SampleProbes(cluster, giInput.reflectVector, fragData.positionWS, surf.Roughness).xyz;
#ifdef _CBIRP_REFLECTIONS
giOutput.indirectSpecular = CBIRP::SampleProbes(cluster, giInput.reflectVector, fragData.positionWS, surf.Roughness).xyz;
#endif
#endif

#if !defined(QUALITY_LOW)
float horizon = min(1.0 + dot(giInput.reflectVector, giInput.normalWS), 1.0);
giOutput.indirectSpecular *= horizon * horizon;
#endif


float3 ltcgiSpecular = 0;
#ifdef _LTCGI
float2 untransformedLightmapUV = 0;
Expand Down
9 changes: 9 additions & 0 deletions Editor/Targets/Lit/LitTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public override void Initialize()


[SerializeField] bool _cbirp = false;
[SerializeField] bool _cbirpReflections = false;
[SerializeField] bool _specular = true;
[SerializeField] bool _fwdAddBlendOpMax = false;

Expand Down Expand Up @@ -132,6 +133,10 @@ public override void AdditionalElements(VisualElement root)
var cbirp = new Toggle("CBIRP") { value = _cbirp };
cbirp.RegisterValueChangedCallback(x => _cbirp = x.newValue);
root.Add(cbirp);

var cbirpReflections = new Toggle("CBIRP Reflections") { value = _cbirpReflections };
cbirpReflections.RegisterValueChangedCallback(x => _cbirpReflections = x.newValue);
root.Add(cbirpReflections);
}
var spec = new Toggle("Specular") { value = _specular };
spec.RegisterValueChangedCallback(x => _specular = x.newValue);
Expand Down Expand Up @@ -238,6 +243,10 @@ public override void OnBeforeBuild(ShaderBuilder builder)
if (_cbirpExists && _cbirp)
{
pass.pragmas.Add("#define _CBIRP");
if (_cbirpReflections)
{
pass.pragmas.Add("#define _CBIRP_REFLECTIONS");
}
}

pass.pragmas.Add(NormalDropoffDefine());
Expand Down

0 comments on commit 8f3bdac

Please sign in to comment.