Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 0ff546a

Browse files
committed
LTCGI
1 parent e176f80 commit 0ff546a

4 files changed

Lines changed: 49 additions & 3 deletions

File tree

Editor/ShaderGUI/SimpleLitGUI.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public class SimpleLitGUI : ShaderGUI
7272
private MaterialProperty _QueueOffset = null;
7373
private MaterialProperty _AudioLinkEmission = null;
7474
private MaterialProperty _TextureIndex;
75+
private MaterialProperty _LTCGI = null;
76+
private MaterialProperty _LTCGI_DIFFUSE_OFF = null;
7577
#endregion
7678

7779
private void DrawProperties(Material material, MaterialEditor me)
@@ -101,6 +103,17 @@ private void DrawRenderingOptions(Material material, MaterialEditor me)
101103
Prop(_SpecularOcclusion);
102104
EditorGUILayout.Space();
103105

106+
107+
#if LTCGI_INCLUDED
108+
EditorGUILayout.Space();
109+
Prop(_LTCGI);
110+
Prop(_LTCGI_DIFFUSE_OFF);
111+
#else
112+
_LTCGI.floatValue = 0.0f;
113+
material.DisableKeyword("LTCGI");
114+
#endif
115+
116+
104117
#if BAKERY_INCLUDED
105118
Prop(Bakery);
106119
if (Bakery.floatValue != 0)
@@ -384,7 +397,6 @@ private void ApplyChanges(MaterialEditor materialEditor, Material mat)
384397
var samplingMode = _Texture.floatValue;
385398
mat.ToggleKeyword("_TEXTURE_ARRAY", samplingMode == 1 || samplingMode == 2);
386399

387-
388400
mat.ToggleKeyword("AUDIOLINK", _AudioLinkEmission.floatValue != 1000);
389401

390402

Shaders/Simple Lit/CoreCGI.cginc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,21 @@ half4 frag (v2f i, uint facing : SV_IsFrontFace) : SV_Target
311311

312312
#endif
313313

314+
#ifdef LTCGI
315+
float2 ltcgi_lmuv;
316+
#if defined(LIGHTMAP_ON)
317+
ltcgi_lmuv = i.coord0.zw;
318+
indirectDiffuse = max(0, indirectDiffuse);
319+
#else
320+
ltcgi_lmuv = float2(0, 0);
321+
#endif
322+
LTCGI_Contribution(i.worldPos, worldNormal, viewDir, surf.perceptualRoughness, ltcgi_lmuv, indirectDiffuse
323+
#ifndef SPECULAR_HIGHLIGHTS_OFF
324+
, directSpecular
325+
#endif
326+
);
327+
#endif
328+
314329

315330
#if defined(UNITY_PASS_FORWARDBASE)
316331
#if !defined(REFLECTIONS_OFF)
@@ -373,6 +388,8 @@ half4 frag (v2f i, uint facing : SV_IsFrontFace) : SV_Target
373388
return float4(UnityMetaFragment(metaInput).rgb, surf.alpha);
374389
#endif
375390

391+
392+
376393
UNITY_APPLY_FOG(i.fogCoord, finalColor);
377394

378395
return finalColor;

Shaders/Simple Lit/Defines.cginc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#undef HEMIOCTAHEDRON_DECODING
1313
#undef BICUBIC_LIGHTMAP
1414
#undef BAKERY_BICUBIC
15+
#undef LTCGI
1516
#endif
1617

1718
#ifdef UNITY_PASS_META
@@ -29,6 +30,13 @@
2930
#endif
3031
#endif
3132

33+
#ifdef LTCGI
34+
#ifdef SPECULAR_HIGHLIGHTS_OFF
35+
#define LTCGI_SPECULAR_OFF
36+
#endif
37+
#include "Assets/_pi_/_LTCGI/Shaders/LTCGI.cginc"
38+
#endif
39+
3240

3341
#if defined(BAKERY_SH) || defined(BAKERY_RNM) || defined(BAKERY_VOLUME)
3442

Shaders/Simple Lit/Simple Lit.shader

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@
7373
[Toggle(BAKEDSPECULAR)] _BakedSpecular ("Baked Specular ", Int) = 0
7474
[Toggle(NONLINEAR_LIGHTPROBESH)] _NonLinearLightProbeSH("Non-linear Light Probe SH", Int) = 0
7575

76+
[Toggle(LTCGI)] _LTCGI("LTCGI", Int) = 0
77+
[Toggle(LTCGI_DIFFUSE_OFF)] _LTCGI_DIFFUSE_OFF("LTCGI Disable Diffuse", Int) = 0
78+
_LTCGI_mat("LTC Mat", 2D) = "black" {}
79+
_LTCGI_amp("LTC Amp", 2D) = "black" {}
80+
7681
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("Source Blend", Int) = 1
7782
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend ("Destination Blend", Int) = 0
7883
[Enum(Off, 0, On, 1)] _ZWrite ("ZWrite", Int) = 1
@@ -112,7 +117,7 @@
112117
#pragma skip_variants LOD_FADE_CROSSFADE
113118
ENDCG
114119

115-
Tags { "RenderType"="Opaque" "Queue"="Geometry" }
120+
Tags { "RenderType"="Opaque" "Queue"="Geometry" "LTCGI" = "_LTCGI" }
116121

117122
Pass
118123
{
@@ -136,7 +141,6 @@
136141
#pragma shader_feature_local SPECULAR_HIGHLIGHTS_OFF
137142
#pragma shader_feature_local REFLECTIONS_OFF
138143
#pragma shader_feature_local EMISSION
139-
#pragma shader_feature_local AUDIOLINK
140144
#pragma shader_feature_local BAKEDSPECULAR
141145
#pragma shader_feature_local PARALLAX
142146
#pragma shader_feature_local GEOMETRIC_SPECULAR_AA
@@ -148,6 +152,10 @@
148152
#pragma shader_feature_local _DETAILALBEDO_MAP
149153
#pragma shader_feature_local _DETAILNORMAL_MAP
150154

155+
#pragma shader_feature_local AUDIOLINK
156+
#pragma shader_feature_local LTCGI
157+
#pragma shader_feature_local LTCGI_DIFFUSE_OFF
158+
151159
#include "PassCGI.cginc"
152160
ENDCG
153161
}
@@ -181,6 +189,7 @@
181189
#pragma shader_feature_local _NORMAL_MAP
182190
#pragma shader_feature_local _DETAILALBEDO_MAP
183191
#pragma shader_feature_local _DETAILNORMAL_MAP
192+
184193

185194

186195
#include "PassCGI.cginc"

0 commit comments

Comments
 (0)