diff options
Diffstat (limited to 'Third_Party/at.pimaker.ltcgi')
81 files changed, 10635 insertions, 0 deletions
diff --git a/Third_Party/at.pimaker.ltcgi/Adapter Support/LTCGI_AvProBlit.shader b/Third_Party/at.pimaker.ltcgi/Adapter Support/LTCGI_AvProBlit.shader new file mode 100644 index 0000000..f551558 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Adapter Support/LTCGI_AvProBlit.shader @@ -0,0 +1,93 @@ +Shader "LTCGI/AvProBlit" +{ + Properties + { + _MainTex ("Input Texture", 2D) = "white" {} + [ToggleUI] _Gamma ("Apply Gamma", Float) = 0 + [ToggleUI] _FlipUV ("Flip Y UV", Float) = 0 + + _AspectRatio ("Aspect Ratio", Float) = 1.777777 + + _OverlayTexture ("Overlay Texture", 2D) = "" {} + _OverlayOpacity ("Overlay Opacity", Float) = 1 + } + SubShader + { + Tags { "RenderType"="Opaque" } + + Pass + { + CGPROGRAM + #pragma vertex CustomRenderTextureVertexShader + #pragma fragment frag + + #include "UnityCG.cginc" + #include "UnityCustomRenderTexture.cginc" + + sampler2D _MainTex; + float4 _MainTex_TexelSize; + + float _Gamma, _FlipUV; + float _AspectRatio; + + sampler2D _OverlayTexture; + float4 _OverlayTexture_TexelSize; + float _OverlayOpacity; + + // Aspect ratio correction by Merlin from USharpVideo + // taken from AVPro sources + void correctUV(inout float2 uv, inout float visibility, float2 res) + { + float curAspectRatio = res.x / res.y; + if (abs(curAspectRatio - _AspectRatio) > .01) { + float2 normRes = float2(res.x / _AspectRatio, res.y); + float2 correction; + + if (normRes.x > normRes.y) + correction = float2(1, normRes.y / normRes.x); + else + correction = float2(normRes.x / normRes.y, 1); + + uv = ((uv - 0.5) / correction) + 0.5; + + float2 uvPadding = (1 / res) * 0.1; + float2 uvFwidth = fwidth(uv.xy); + float2 maxf = smoothstep(uvFwidth + uvPadding + 1, uvPadding + 1, uv.xy); + float2 minf = smoothstep(-uvFwidth - uvPadding, -uvPadding, uv.xy); + // calculate the min/max of the true size to apply a 0 to anything beyond the ratio value. + // This creates the "Black Bars" around the video when the video doesn't match the texel size. + // If this isn't used, the edge pixels end up getting repeated where the black bars are. + visibility = maxf.x * maxf.y * minf.x * minf.y; + } + } + + half4 frag (v2f_customrendertexture i) : SV_Target + { + float2 mainTexUv = i.globalTexcoord.xy; + float2 overlayTexUv = i.globalTexcoord.xy; + #ifdef UNITY_UV_STARTS_AT_TOP + _FlipUV = !_FlipUV; + #endif + if (_FlipUV) { + mainTexUv.y = 1 - mainTexUv.y; + overlayTexUv.y = 1 - overlayTexUv.y; + } + + float visibility = 1; + correctUV(mainTexUv, visibility, _MainTex_TexelSize.zw); + + half4 color = tex2Dlod(_MainTex, float4(mainTexUv, 0, 0)) * visibility; + if (_OverlayOpacity) + { + visibility = 1; + correctUV(overlayTexUv, visibility, _OverlayTexture_TexelSize.zw); + color = lerp(color, tex2Dlod(_OverlayTexture, float4(overlayTexUv, 0, 0)) * visibility, _OverlayOpacity); + } + + if (_Gamma) return pow(color, 2.2); + return color; + } + ENDCG + } + } +} diff --git a/Third_Party/at.pimaker.ltcgi/Adapter Support/LTCGI_AvProBlit_Material.mat b/Third_Party/at.pimaker.ltcgi/Adapter Support/LTCGI_AvProBlit_Material.mat new file mode 100644 index 0000000..268142d --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Adapter Support/LTCGI_AvProBlit_Material.mat @@ -0,0 +1,35 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: LTCGI_AvProBlit_Material + m_Shader: {fileID: 4800000, guid: a6985171581abd5498cdd2002d64d876, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _MainTex: + m_Texture: {fileID: 2800000, guid: 68718da77206620438ca14e29cefa6fb, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OverlayTexture: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _AspectRatio: 1.777777 + - _FlipUV: 1 + - _Gamma: 0 + - _OverlayOpacity: 0 + m_Colors: [] diff --git a/Third_Party/at.pimaker.ltcgi/Adapter Support/LTCGI_BlitCRT.asset b/Third_Party/at.pimaker.ltcgi/Adapter Support/LTCGI_BlitCRT.asset new file mode 100644 index 0000000..5e0eabc --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Adapter Support/LTCGI_BlitCRT.asset @@ -0,0 +1,52 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!86 &8600000 +CustomRenderTexture: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: LTCGI_BlitCRT + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_ForcedFallbackFormat: 4 + m_DownscaleFallback: 0 + serializedVersion: 3 + m_Width: 1920 + m_Height: 1080 + m_AntiAliasing: 1 + m_MipCount: -1 + m_DepthFormat: 0 + m_ColorFormat: 8 + m_MipMap: 1 + m_GenerateMips: 1 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_BindMS: 0 + m_EnableCompatibleFormat: 1 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 1 + m_Aniso: 0 + m_MipBias: 0 + m_WrapU: 1 + m_WrapV: 1 + m_WrapW: 1 + m_Dimension: 2 + m_VolumeDepth: 1 + m_Material: {fileID: 2100000, guid: 77ef72900fca1b14b867f03b4d1f4ed5, type: 2} + m_InitSource: 0 + m_InitMaterial: {fileID: 0} + m_InitColor: {r: 0, g: 0, b: 0, a: 1} + m_InitTexture: {fileID: 0} + m_UpdateMode: 1 + m_InitializationMode: 0 + m_UpdateZoneSpace: 0 + m_CurrentUpdateZoneSpace: 0 + m_UpdateZones: [] + m_UpdatePeriod: 0 + m_ShaderPass: 0 + m_CubemapFaceMask: 4294967295 + m_DoubleBuffered: 0 + m_WrapUpdateZones: 0 diff --git a/Third_Party/at.pimaker.ltcgi/Adapter Support/black1px.png b/Third_Party/at.pimaker.ltcgi/Adapter Support/black1px.png Binary files differnew file mode 100644 index 0000000..fecec1c --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Adapter Support/black1px.png diff --git a/Third_Party/at.pimaker.ltcgi/Adapters/Editor/LTCGI_ProTvAdapterAutoSetup.cs_disabled b/Third_Party/at.pimaker.ltcgi/Adapters/Editor/LTCGI_ProTvAdapterAutoSetup.cs_disabled new file mode 100644 index 0000000..80ef23e --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Adapters/Editor/LTCGI_ProTvAdapterAutoSetup.cs_disabled @@ -0,0 +1,130 @@ +#if UNITY_EDITOR && UDONSHARP +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEngine; +using UnityEngine.SceneManagement; +using UdonSharpEditor; +using ArchiTech; +using VRC.SDK3.Video.Components; +using VRC.SDK3.Video.Components.AVPro; + +namespace pi.LTCGI +{ + public class LTCGI_ProTvAdapterAutoSetup : ILTCGI_AutoSetup + { + // for modern model + private static readonly Vector2 DefaultScale = new Vector3(2.4875f, 1.38f); + private static readonly Vector3 DefaultPosition = new Vector3(0.0f, 1.151f, -0.121f); + + public LTCGI_ProTvAdapterAutoSetup() + { + } + + public GameObject AutoSetupEditor(LTCGI_Controller controller) + { + #pragma warning disable 618 + var protvPlayers = SceneManager.GetActiveScene().GetRootGameObjects() + .SelectMany(sceneRoot => sceneRoot.GetUdonSharpComponentsInChildren<TVManagerV2>()); + #pragma warning restore 618 + var first = true; + foreach (var player in protvPlayers) + { + if (first) + { + EditorGUILayout.LabelField("Detected Pro TVs in scene:"); + first = false; + } + if (GUILayout.Button($"Auto-Configure '{VRC.Core.ExtensionMethods.GetHierarchyPath(player.gameObject.transform)}'")) + { + var adapter = new GameObject("LTCGI_ProTvAdapter"); + adapter.transform.parent = controller.transform; + adapter.transform.position = player.transform.position; + adapter.transform.rotation = player.transform.rotation; + + var script = adapter.AddUdonSharpComponent<LTCGI_ProTvAdapter>(); + #pragma warning disable 618 + script.UpdateProxy(); + #pragma warning restore 618 + script.Tv = player; + script.SharedMaterial = AssetDatabase.LoadAssetAtPath<Material>(AssetDatabase.GUIDToAssetPath("77ef72900fca1b14b867f03b4d1f4ed5") /* LTCGI_AvProBlit_Material.mat */); + script.BlitCRT = AssetDatabase.LoadAssetAtPath<CustomRenderTexture>(AssetDatabase.GUIDToAssetPath("802e4542fd374664aa4d0858e525b454") /* LTCGI_BlitCRT.asset */); + script.AvProBranding = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/ArchiTechAnon/ProTV/Images/ProTVLogo_16x9.png"); + + controller.VideoTexture = script.BlitCRT; + + var quad = GameObject.CreatePrimitive(PrimitiveType.Quad); + quad.transform.parent = adapter.transform; + quad.transform.localScale = DefaultScale * player.transform.lossyScale; + quad.transform.localEulerAngles = Vector3.zero; + quad.transform.localPosition = DefaultPosition; + quad.transform.GetComponent<MeshRenderer>().enabled = false; + Component.DestroyImmediate(quad.transform.GetComponent<Collider>()); + quad.name = "LTCGI Video Screen"; + + // generate adapter screens + var adapterScreensKey = new List<GameObject>(); + var adapterScreensValue = new List<GameObject>(); + var adapterScreensIsUnity = new List<bool>(); + foreach (var screen in player.videoManagers) + { + var unity = screen.gameObject.GetComponent<VRCUnityVideoPlayer>() != null; + adapterScreensIsUnity.Add(unity); + adapterScreensKey.Add(screen.gameObject); + + if (unity) + { + adapterScreensValue.Add(null); + } + else + { + var capture = new GameObject("LTCGI_ProTvAdapter_" + screen.name); + capture.transform.parent = adapter.transform; + capture.transform.localPosition = Vector3.zero; + + var renderer = capture.AddComponent<MeshRenderer>(); + renderer.sharedMaterials = new [] { script.SharedMaterial }; + renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; + renderer.receiveShadows = false; + renderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; + renderer.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off; + renderer.allowOcclusionWhenDynamic = false; + + var avpro = capture.AddComponent<VRCAVProVideoScreen>(); + var serializedObject = new SerializedObject(avpro); + serializedObject.FindProperty("videoPlayer").objectReferenceValue = screen.GetComponent<VRCAVProVideoPlayer>(); + serializedObject.FindProperty("useSharedMaterial").boolValue = true; + serializedObject.ApplyModifiedProperties(); + + adapterScreensValue.Add(capture); + } + } + + script.AdapterScreensKey = adapterScreensKey.ToArray(); + script.AdapterScreensValue = adapterScreensValue.ToArray(); + script.AdapterScreensIsUnity = adapterScreensIsUnity.ToArray(); + #pragma warning disable 618 + script.ApplyProxyModifications(); + #pragma warning restore 618 + + script._SetOverlayEnabled(); + + var ltcgi = quad.AddComponent<LTCGI_Screen>(); + ltcgi.ColorMode = ColorMode.Texture; + ltcgi.Specular = true; + ltcgi.Diffuse = true; // LTC Diffuse by default + ltcgi.TextureIndex = 0; + + EditorUtility.DisplayDialog("Auto-Configure", "Auto-Configured LTCGI_ProTvAdapter. Please make sure the 'LTCGI Video Screen' object has the same position, rotation and scale in your scene as your actual video screen. (The default transform is configured for the 'Modern Model' prefab!)", "OK"); + EditorGUIUtility.PingObject(quad); + + return adapter; + } + } + + return null; + } + } +} + +#endif
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Adapters/Editor/LTCGI_USharpVideoAdapterAutoSetup.cs_disabled b/Third_Party/at.pimaker.ltcgi/Adapters/Editor/LTCGI_USharpVideoAdapterAutoSetup.cs_disabled new file mode 100644 index 0000000..4a71ca3 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Adapters/Editor/LTCGI_USharpVideoAdapterAutoSetup.cs_disabled @@ -0,0 +1,92 @@ +#if UNITY_EDITOR && UDONSHARP +using System.Linq; +using UnityEditor; +using UnityEngine; +using UnityEngine.SceneManagement; +using UdonSharpEditor; +using UdonSharp.Video; + +namespace pi.LTCGI +{ + public class LTCGI_USharpVideoAdapterAutoSetup : ILTCGI_AutoSetup + { + private static readonly Vector2 DefaultScale = new Vector2(7.63f, 4.2925f); + + public LTCGI_USharpVideoAdapterAutoSetup() + { + } + + public GameObject AutoSetupEditor(LTCGI_Controller controller) + { + #pragma warning disable 618 + var usharpPlayers = SceneManager.GetActiveScene().GetRootGameObjects() + .SelectMany(sceneRoot => sceneRoot.GetUdonSharpComponentsInChildren<USharpVideoPlayer>()); + #pragma warning restore 618 + var first = true; + foreach (var player in usharpPlayers) + { + if (first) + { + EditorGUILayout.LabelField("Detected U# Video Players in scene:"); + first = false; + } + if (GUILayout.Button($"Auto-Configure '{VRC.Core.ExtensionMethods.GetHierarchyPath(player.gameObject.transform)}'")) + { + var adapter = new GameObject("LTCGI_USharpVideoAdapter"); + adapter.transform.parent = controller.transform; + adapter.transform.position = player.transform.position; + adapter.transform.rotation = player.transform.rotation; + + var script = adapter.AddUdonSharpComponent<LTCGI_USharpVideoAdapter>(); + #pragma warning disable 618 + script.UpdateProxy(); + #pragma warning restore 618 + script.VideoPlayer = player; + script.CRT = AssetDatabase.LoadAssetAtPath<CustomRenderTexture>(AssetDatabase.GUIDToAssetPath("802e4542fd374664aa4d0858e525b454") /* LTCGI_BlitCRT.asset */); + + controller.VideoTexture = script.CRT; + + // attempt to read standby texture from player + #pragma warning disable 618 + var handler = player.GetUdonSharpComponentInChildren<VideoScreenHandler>(); + #pragma warning restore 618 + if (handler != null) + { + script.StandbyTexture = handler.standbyTexture; + } + else + { + script.StandbyTexture = AssetDatabase.LoadAssetAtPath<Texture2D>(AssetDatabase.GUIDToAssetPath("68718da77206620438ca14e29cefa6fb") /* black1px.png */); + } + #pragma warning disable 618 + script.ApplyProxyModifications(); + #pragma warning restore 618 + + var quad = GameObject.CreatePrimitive(PrimitiveType.Quad); + quad.transform.parent = adapter.transform; + quad.transform.localScale = DefaultScale * player.transform.lossyScale; + quad.transform.localEulerAngles = Vector3.zero; + quad.transform.localPosition = Vector3.zero; + quad.transform.GetComponent<MeshRenderer>().enabled = false; + Component.DestroyImmediate(quad.transform.GetComponent<Collider>()); + quad.name = "LTCGI Video Screen"; + + var ltcgi = quad.AddComponent<LTCGI_Screen>(); + ltcgi.ColorMode = ColorMode.Texture; + ltcgi.Specular = true; + ltcgi.Diffuse = true; // LTC Diffuse by default + ltcgi.TextureIndex = 0; + + EditorUtility.DisplayDialog("Auto-Configure", "Auto-Configured LTCGI_USharpVideoAdapter. Please make sure the 'LTCGI Video Screen' object has the same position, rotation and scale in your scene as your actual video screen.", "OK"); + EditorGUIUtility.PingObject(quad); + + return adapter; + } + } + + return null; + } + } +} + +#endif
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Adapters/LTCGI_ProTvAdapter.asset_disabled b/Third_Party/at.pimaker.ltcgi/Adapters/LTCGI_ProTvAdapter.asset_disabled new file mode 100644 index 0000000..24eb9da --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Adapters/LTCGI_ProTvAdapter.asset_disabled @@ -0,0 +1,431 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3} + m_Name: LTCGI_ProTvAdapter + m_EditorClassIdentifier: + serializedUdonProgramAsset: {fileID: 11400000, guid: a8561dcd02187e346bdc956f991a4a41, + type: 2} + udonAssembly: + assemblyError: + sourceCsScript: {fileID: 11500000, guid: 3ff10f86136660146bbca694e477adae, type: 3} + scriptVersion: 2 + compiledVersion: 2 + behaviourSyncMode: 1 + hasInteractEvent: 0 + scriptID: -5404763161282593047 + serializationData: + SerializedFormat: 2 + SerializedBytes: + ReferencedUnityObjects: [] + SerializedBytesString: + Prefab: {fileID: 0} + PrefabModificationsReferencedUnityObjects: [] + PrefabModifications: [] + SerializationNodes: + - Name: fieldDefinitions + Entry: 7 + Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UdonSharp.Compiler.FieldDefinition, + UdonSharp.Editor]], mscorlib + - Name: comparer + Entry: 7 + Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String, + mscorlib]], mscorlib + - Name: + Entry: 8 + Data: + - Name: + Entry: 12 + Data: 7 + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: Tv + - Name: $v + Entry: 7 + Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: Tv + - Name: <UserType>k__BackingField + Entry: 7 + Data: 3|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: ArchiTech.TVManagerV2, Assembly-CSharp + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 7 + Data: 4|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: VRC.Udon.UdonBehaviour, VRC.Udon + - Name: + Entry: 8 + Data: + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: SharedMaterial + - Name: $v + Entry: 7 + Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: SharedMaterial + - Name: <UserType>k__BackingField + Entry: 7 + Data: 7|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.Material, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 7 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 8|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: BlitCRT + - Name: $v + Entry: 7 + Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: BlitCRT + - Name: <UserType>k__BackingField + Entry: 7 + Data: 10|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.CustomRenderTexture, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 10 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 11|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: AvProBranding + - Name: $v + Entry: 7 + Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: AvProBranding + - Name: <UserType>k__BackingField + Entry: 7 + Data: 13|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.Texture2D, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 13 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 14|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: AdapterScreensKey + - Name: $v + Entry: 7 + Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: AdapterScreensKey + - Name: <UserType>k__BackingField + Entry: 7 + Data: 16|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.GameObject[], UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 17|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: AdapterScreensValue + - Name: $v + Entry: 7 + Data: 18|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: AdapterScreensValue + - Name: <UserType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 19|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: AdapterScreensIsUnity + - Name: $v + Entry: 7 + Data: 20|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: AdapterScreensIsUnity + - Name: <UserType>k__BackingField + Entry: 7 + Data: 21|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: System.Boolean[], mscorlib + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 21 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 22|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: diff --git a/Third_Party/at.pimaker.ltcgi/Adapters/LTCGI_ProTvAdapter.cs_disabled b/Third_Party/at.pimaker.ltcgi/Adapters/LTCGI_ProTvAdapter.cs_disabled new file mode 100644 index 0000000..570f390 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Adapters/LTCGI_ProTvAdapter.cs_disabled @@ -0,0 +1,83 @@ +#if UDONSHARP +using UdonSharp; +using UnityEngine; +using ArchiTech; + +[UdonBehaviourSyncMode(BehaviourSyncMode.None)] +public class LTCGI_ProTvAdapter : UdonSharpBehaviour +{ + const string MATERIAL_PARAM_OVERLAY_TEX = "_OverlayTexture"; + const string MATERIAL_PARAM_OVERLAY_OPACITY = "_OverlayOpacity"; + const string MATERIAL_PARAM_GAMMA = "_Gamma"; + const string MATERIAL_PARAM_FLIPUV = "_FlipUV"; + + public TVManagerV2 Tv; + + public Material SharedMaterial; + public CustomRenderTexture BlitCRT; + public Texture2D AvProBranding; + + public GameObject[] AdapterScreensKey; + public GameObject[] AdapterScreensValue; + public bool[] AdapterScreensIsUnity; + + void Start() + { + Tv._RegisterUdonSharpEventReceiver(this); + _TvStop(); + } + + public void _TvMediaStart() => changeRenderTexture(Tv.activeManager); + public void _TvPlay() => changeRenderTexture(Tv.activeManager); + //public void _TvMediaEnd() => _TvStop(); + public void _TvStop() + { + _SetOverlayEnabled(); + changeRenderTexture(null); + } + + public void _SetOverlayEnabled() + { + SharedMaterial.SetTexture(MATERIAL_PARAM_OVERLAY_TEX, AvProBranding); + SharedMaterial.SetFloat(MATERIAL_PARAM_OVERLAY_OPACITY, 1.0f); + SharedMaterial.SetFloat(MATERIAL_PARAM_GAMMA, 0.0f); + SharedMaterial.SetFloat(MATERIAL_PARAM_FLIPUV, 1.0f); + } + + private void changeRenderTexture(VideoManagerV2 manager) + { + for (int i = 0; i < AdapterScreensKey.Length; i++) + { + if (manager != null && AdapterScreensKey[i] == manager.gameObject) + { + var unity = AdapterScreensIsUnity[i]; + if (unity) + { + var prop = new MaterialPropertyBlock(); + manager.screens[0].GetComponent<Renderer>().GetPropertyBlock(prop); + var tex = prop.GetTexture("_MainTex"); + SharedMaterial.SetTexture(MATERIAL_PARAM_OVERLAY_TEX, tex); + SharedMaterial.SetFloat(MATERIAL_PARAM_OVERLAY_OPACITY, 1.0f); + SharedMaterial.SetFloat(MATERIAL_PARAM_GAMMA, 0.0f); + SharedMaterial.SetFloat(MATERIAL_PARAM_FLIPUV, 1.0f); + } + else + { + AdapterScreensValue[i].SetActive(true); + SharedMaterial.SetFloat(MATERIAL_PARAM_OVERLAY_OPACITY, 0.0f); + SharedMaterial.SetFloat(MATERIAL_PARAM_GAMMA, 1.0f); + SharedMaterial.SetFloat(MATERIAL_PARAM_FLIPUV, 0.0f); + } + Debug.Log("[LTCGI_ProTvAdapter] switched to " + AdapterScreensKey[i].name + " (unity: " + unity + ")"); + } + else + { + if (!AdapterScreensIsUnity[i]) + { + AdapterScreensValue[i].SetActive(false); + } + } + } + } +} +#endif
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Adapters/LTCGI_USharpVideoAdapter.asset_disabled b/Third_Party/at.pimaker.ltcgi/Adapters/LTCGI_USharpVideoAdapter.asset_disabled new file mode 100644 index 0000000..26df322 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Adapters/LTCGI_USharpVideoAdapter.asset_disabled @@ -0,0 +1,285 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3} + m_Name: LTCGI_USharpVideoAdapter + m_EditorClassIdentifier: + serializedUdonProgramAsset: {fileID: 11400000, guid: bfa29ae67175bf7458e77bb2d4815de3, + type: 2} + udonAssembly: + assemblyError: + sourceCsScript: {fileID: 11500000, guid: 575e63717882ec745b66f846bf615395, type: 3} + scriptVersion: 2 + compiledVersion: 2 + behaviourSyncMode: 1 + hasInteractEvent: 0 + scriptID: -2285610048732670380 + serializationData: + SerializedFormat: 2 + SerializedBytes: + ReferencedUnityObjects: [] + SerializedBytesString: + Prefab: {fileID: 0} + PrefabModificationsReferencedUnityObjects: [] + PrefabModifications: [] + SerializationNodes: + - Name: fieldDefinitions + Entry: 7 + Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UdonSharp.Compiler.FieldDefinition, + UdonSharp.Editor]], mscorlib + - Name: comparer + Entry: 7 + Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String, + mscorlib]], mscorlib + - Name: + Entry: 8 + Data: + - Name: + Entry: 12 + Data: 4 + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: VideoPlayer + - Name: $v + Entry: 7 + Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: VideoPlayer + - Name: <UserType>k__BackingField + Entry: 7 + Data: 3|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UdonSharp.Video.USharpVideoPlayer, Assembly-CSharp + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 7 + Data: 4|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: VRC.Udon.UdonBehaviour, VRC.Udon + - Name: + Entry: 8 + Data: + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: CRT + - Name: $v + Entry: 7 + Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: CRT + - Name: <UserType>k__BackingField + Entry: 7 + Data: 7|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.CustomRenderTexture, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 7 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 8|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: StandbyTexture + - Name: $v + Entry: 7 + Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: StandbyTexture + - Name: <UserType>k__BackingField + Entry: 7 + Data: 10|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.Texture, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 10 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 11|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 1 + - Name: + Entry: 7 + Data: 12|UnityEngine.TooltipAttribute, UnityEngine.CoreModule + - Name: tooltip + Entry: 1 + Data: Place the same Standby Texture as in your VideoScreenHandler here if + you want it to reflect too. Should be black if unset. + - Name: + Entry: 8 + Data: + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: sharedMaterial + - Name: $v + Entry: 7 + Data: 13|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: sharedMaterial + - Name: <UserType>k__BackingField + Entry: 7 + Data: 14|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.Material, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 14 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 15|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: diff --git a/Third_Party/at.pimaker.ltcgi/Adapters/LTCGI_USharpVideoAdapter.cs_disabled b/Third_Party/at.pimaker.ltcgi/Adapters/LTCGI_USharpVideoAdapter.cs_disabled new file mode 100644 index 0000000..0c53fa7 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Adapters/LTCGI_USharpVideoAdapter.cs_disabled @@ -0,0 +1,63 @@ +#if UDONSHARP +using UdonSharp; +using UdonSharp.Video; +using UnityEngine; + +[UdonBehaviourSyncMode(BehaviourSyncMode.None)] +public class LTCGI_USharpVideoAdapter : UdonSharpBehaviour +{ + const string MATERIAL_PARAM_TEX = "_MainTex"; + const string MATERIAL_PARAM_OVERLAY_OPACITY = "_OverlayOpacity"; + const string MATERIAL_PARAM_GAMMA = "_Gamma"; + const string MATERIAL_PARAM_FLIPUV = "_FlipUV"; + + public USharpVideoPlayer VideoPlayer; + public CustomRenderTexture CRT; + + [Tooltip("Place the same Standby Texture as in your VideoScreenHandler here if you want it to reflect too. Should be black if unset.")] + public Texture StandbyTexture; + + private Material sharedMaterial; + + void Start() + { + sharedMaterial = CRT.material; + VideoPlayer.RegisterCallbackReceiver(this); + + sharedMaterial.SetFloat(MATERIAL_PARAM_OVERLAY_OPACITY, 0.0f); + } + + public void OnUSharpVideoModeChange() => OnUSharpVideoRenderTextureChange(); + + public void OnUSharpVideoRenderTextureChange() + { + var manager = VideoPlayer.GetVideoManager(); + var tex = manager.GetVideoTexture(); + var unity = VideoPlayer.IsUsingUnityPlayer(); + + if (tex == null) + { + Debug.Log("[LTCGI_USharpVideoAdapter] set to standby texture"); + sharedMaterial.SetTexture(MATERIAL_PARAM_TEX, StandbyTexture); + sharedMaterial.SetFloat(MATERIAL_PARAM_FLIPUV, 1.0f); + sharedMaterial.SetFloat(MATERIAL_PARAM_GAMMA, 0.0f); + } + else + { + sharedMaterial.SetTexture(MATERIAL_PARAM_TEX, tex); + if (unity) + { + Debug.Log("[LTCGI_USharpVideoAdapter] set to unity player"); + sharedMaterial.SetFloat(MATERIAL_PARAM_FLIPUV, 1.0f); + sharedMaterial.SetFloat(MATERIAL_PARAM_GAMMA, 0.0f); + } + else + { + Debug.Log("[LTCGI_USharpVideoAdapter] set to avpro player"); + sharedMaterial.SetFloat(MATERIAL_PARAM_FLIPUV, 0.0f); + sharedMaterial.SetFloat(MATERIAL_PARAM_GAMMA, 1.0f); + } + } + } +} +#endif
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_Assembly_Editor.asmdef b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_Assembly_Editor.asmdef new file mode 100644 index 0000000..41a61d7 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_Assembly_Editor.asmdef @@ -0,0 +1,26 @@ +{ + "name": "at.pimaker.ltcgi.Editor", + "references": [ + "VRC.SDK3", + "VRC.SDK3.Editor", + "VRC.SDKBase", + "VRC.SDKBase.Editor", + "VRC.Udon", + "VRC.Udon.Editor", + "LTCGI_Assembly", + "UdonSharp.Lib", + "UdonSharp.Editor", + "UdonSharp.Runtime", + "BakeryEditorAssembly", + "BakeryRuntimeAssembly" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +}
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_BakeReset.cs b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_BakeReset.cs new file mode 100644 index 0000000..ad96f32 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_BakeReset.cs @@ -0,0 +1,60 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using UnityEngine.Rendering; +#endif + +namespace pi.LTCGI +{ + #if UNITY_EDITOR + // Serialization helper for lightmap baking primitives. + [ExecuteInEditMode] + public class LTCGI_BakeReset : MonoBehaviour + { + public bool Reenable; + public Renderer[] DisableRendererComponents; + + public bool ResetData; + public Material[] Materials; + public StaticEditorFlags Flags; + public ShadowCastingMode ShadowCastingMode; + + public bool ResetLightMesh; + public Color lightMeshColor; + public float lightMeshIntensity; + + internal void ApplyReset() + { + if (Reenable) + { + this.gameObject.SetActive(true); + } + if (ResetData) + { + var rend = this.GetComponent<Renderer>(); + rend.sharedMaterials = Materials; + rend.shadowCastingMode = ShadowCastingMode; + GameObjectUtility.SetStaticEditorFlags(this.gameObject, Flags); + } + + #if BAKERY_INCLUDED + if (ResetLightMesh) + { + var lm = this.GetComponent<BakeryLightMesh>(); + if (lm != null) + { + lm.color = lightMeshColor; + lm.intensity = lightMeshIntensity; + } + } + #endif + + if (DisableRendererComponents != null) + { + foreach (var r in DisableRendererComponents) + if (r) r.enabled = false; + } + } + } + #endif +}
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_Controller.cs b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_Controller.cs new file mode 100644 index 0000000..7d10357 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_Controller.cs @@ -0,0 +1,763 @@ +// Uncomment for debug messages +//#define DEBUG_LOG + +#if UNITY_EDITOR +using System; +using System.Collections.Generic; +using System.Linq; +using System.IO; +using UnityEditor; +using UnityEngine; +using UnityEditor.SceneManagement; + +#if UDONSHARP +using UdonSharp; +using UdonSharpEditor; +#endif +#endif + +namespace pi.LTCGI +{ + #if UNITY_EDITOR + [ExecuteInEditMode] + [System.Serializable] + public partial class LTCGI_Controller : MonoBehaviour + { + internal const int MAX_SOURCES = 16; + + [Tooltip("Intensity is set for each screen. Can be a RenderTexture for realtime updates (video players).")] + public Texture VideoTexture; + [Tooltip("Static textures are precomputed and *must* all be the same size. Make sure to click 'Precompute Static Textures' after any changes.")] + public Texture2D[] StaticTextures; + [Tooltip("Renderers that may change material during runtime. Otherwise only 'sharedMaterial's are updated for performance reasons.")] + public Renderer[] DynamicRenderers; + + [Header("Expert Settings")] + [Tooltip("Do not automatically set up the blur chain. Use this if you use AVPro to set _MainTex on the LOD1 material for example.")] + public bool CustomBlurChain = false; + + [Tooltip("Apply an intensity multiplier *before* baking the lightmap. Offset with Lightmap Multiplier below.")] + public float LightmapIntensity = 4.0f; + + [Tooltip("Multiply lightmap with this before applying to diffuse. Useful if you have multiple lights next to each other sharing a channel.")] + public Vector3 LightmapMultiplier = new Vector4(0.25f, 0.25f, 0.25f, 0.25f); + + [Header("Internal Settings")] + public Texture2D DefaultLightmap; + public CustomRenderTexture LOD1s, LOD1, LOD2s, LOD2, LOD3s, LOD3; + public Texture2D LUT1, LUT2; + + public static LTCGI_Controller Singleton; + + [NonSerialized] internal Renderer[] cachedMeshRenderers; + [NonSerialized] private Vector4[] _LTCGI_Vertices_0, _LTCGI_Vertices_1, _LTCGI_Vertices_2, _LTCGI_Vertices_3; + [NonSerialized] private Vector4[] _LTCGI_Vertices_0t, _LTCGI_Vertices_1t, _LTCGI_Vertices_2t, _LTCGI_Vertices_3t; + [NonSerialized] internal Transform[] _LTCGI_ScreenTransforms; + [NonSerialized] private Vector4[] _LTCGI_ExtraData; + [NonSerialized] private Vector4 _LTCGI_LightmapMult; + [NonSerialized] private Vector2[][] _LTCGI_UVs; + + private Texture2DArray[] _LTCGI_LOD_arrays; + + public bool HasDynamicScreens = false; + public bool HasCylinders = false; + + public void OnEnable() + { + if (PrefabUtility.IsPartOfPrefabAsset(this.gameObject)) return; + if (Singleton == null || Singleton != this) + { + if (PrefabUtility.IsPartOfPrefabInstance(this.gameObject)) + PrefabUtility.UnpackPrefabInstance(this.gameObject, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction); + Singleton = this; + Undo.undoRedoPerformed += this.UpdateMaterials; + EditorApplication.playModeStateChanged += (change) => { + if (change == PlayModeStateChange.ExitingEditMode) + { + UpdateMaterials(); + } + }; + Debug.Log($"LTCGI Controller Singleton initialized (Mode: {RuntimeMode})"); + + var ctrls = GameObject.FindObjectsOfType<LTCGI_Controller>().Length; + if (ctrls > 1) + { + Debug.LogError("There must only be one LTCGI Controller per scene!"); + } + } + + MigratoryBirdsDontMigrateAsMuchAsWeDoButThisFunctionWillTakeCareOfItNonetheless(); + } + + public static void MigratoryBirdsDontMigrateAsMuchAsWeDoButThisFunctionWillTakeCareOfItNonetheless() + { + var hasChanges = false; + if (!AssetDatabase.IsValidFolder("Assets\\_pi_")) + { + AssetDatabase.CreateFolder("Assets", "_pi_"); + hasChanges = true; + } + if (!AssetDatabase.IsValidFolder("Assets\\_pi_\\_LTCGI")) + { + AssetDatabase.CreateFolder("Assets\\_pi_", "_LTCGI"); + hasChanges = true; + } + if (!AssetDatabase.IsValidFolder("Assets\\_pi_\\_LTCGI\\Shaders")) + { + AssetDatabase.CreateFolder("Assets\\_pi_\\_LTCGI", "Shaders"); + hasChanges = true; + } + if (!File.Exists("Assets\\_pi_\\_LTCGI\\Shaders\\LTCGI.cginc")) + { + File.WriteAllText("Assets\\_pi_\\_LTCGI\\Shaders\\LTCGI.cginc", "#include \"Packages\\at.pimaker.ltcgi\\Shaders\\LTCGI.cginc\""); + hasChanges = true; + } + + // god I hate this part, Unity dumb dumb + if (!AssetDatabase.IsValidFolder("Assets\\Gizmos")) + { + AssetDatabase.CreateFolder("Assets", "Gizmos"); + hasChanges = true; + } + if (!File.Exists("Assets\\Gizmos\\LTCGI_Screen_Gizmo.png")) + { + File.Copy("Packages\\at.pimaker.ltcgi\\LTCGI_Screen_Gizmo.png", "Assets\\Gizmos\\LTCGI_Screen_Gizmo.png", true); + hasChanges = true; + } + + if (hasChanges) + { + Debug.Log("LTCGI Migration took place, refreshing asset database"); + AssetDatabase.Refresh(); + } + } + + public static bool MatLTCGIenabled(Material mat) + { + if (mat == null) return false; + var tag = mat.GetTag("LTCGI", true); + if (tag == null || string.IsNullOrEmpty(tag)) return false; + if (tag == "ALWAYS") return true; + return mat.GetFloat(tag) != 0; + } + + [MenuItem("Tools/LTCGI/Force Material Update")] + public static void UpdateMaterialsMenu() => Singleton?.UpdateMaterials(); + public void UpdateMaterials() => UpdateMaterials(false); + public void UpdateMaterials(bool fast, LTCGI_Screen screen = null) + { + // don't mess with Udon emulation + if (EditorApplication.isPlaying) + return; + if (Lightmapping.isRunning) + return; + if (UnityEngine.SceneManagement.SceneManager.loadedSceneCount == 0) + return; + + #if DEBUG_LOG + Debug.Log($"LTCGI: beginning update ({(fast ? "fast" : "full")})"); + #endif + + MigratoryBirdsDontMigrateAsMuchAsWeDoButThisFunctionWillTakeCareOfItNonetheless(); + + if (_LTCGI_ExtraData == null) + fast = false; + if (_LTCGI_LightmapMult == null) + fast = false; + + if (!fast) + { + _LTCGI_Vertices_0 = new Vector4[MAX_SOURCES]; + _LTCGI_Vertices_1 = new Vector4[MAX_SOURCES]; + _LTCGI_Vertices_2 = new Vector4[MAX_SOURCES]; + _LTCGI_Vertices_3 = new Vector4[MAX_SOURCES]; + _LTCGI_Vertices_0t = new Vector4[MAX_SOURCES]; + _LTCGI_Vertices_1t = new Vector4[MAX_SOURCES]; + _LTCGI_Vertices_2t = new Vector4[MAX_SOURCES]; + _LTCGI_Vertices_3t = new Vector4[MAX_SOURCES]; + _LTCGI_ExtraData = new Vector4[MAX_SOURCES]; + _LTCGI_ScreenTransforms = new Transform[MAX_SOURCES]; + _LTCGI_UVs = new Vector2[MAX_SOURCES][]; + } + + var dynamics = false; + var cylinders = false; + + // construct data + var screens = GameObject + .FindObjectsOfType<LTCGI_Screen>() + .Where(x => x.enabled) + .OrderByDescending(x => x.Dynamic) + .ToArray(); + + if (screens.Length > MAX_SOURCES) + { + if (fast) return; + throw new Exception("Too many screens in the scene!"); + } + + for (int i = 0; i < screens.Length; i++) + { + var s = screens[i]; + if (fast && screen != null && s != screen) continue; + + _LTCGI_ScreenTransforms[i] = s.transform; + LTCGI_Emitter emitter; + if ((emitter = s as LTCGI_Emitter) != null) + { + _LTCGI_Vertices_0[i] = _LTCGI_Vertices_1[i] = _LTCGI_Vertices_2[i] = _LTCGI_Vertices_3[i] = Vector4.zero; + _LTCGI_Vertices_0[i].w = s.SingleUV.x; + _LTCGI_Vertices_1[i].w = s.SingleUV.y; + } + else if (s.Cylinder) + { + // Experimental! + _LTCGI_Vertices_0[i] = new Vector4( + s.CylinderBase.x, + s.CylinderBase.y * 2, + s.CylinderBase.z, + s.CylinderHeight * 2 + ); + _LTCGI_Vertices_1[i] = new Vector4( + s.CylinderBase.x, + s.CylinderBase.y * 2, + s.CylinderBase.z, + s.CylinderRadius + ); + _LTCGI_Vertices_2[i] = new Vector4( + s.CylinderBase.x, + s.CylinderBase.y * 2, + s.CylinderBase.z, + s.CylinderSize + ); + _LTCGI_Vertices_3[i] = new Vector4( + s.CylinderBase.x, + s.CylinderBase.y * 2, + s.CylinderBase.z, + s.CylinderAngle + ); + + cylinders = true; + } + else + { + var mf = s.GetComponent<MeshFilter>(); + if (mf.sharedMesh == null) continue; + if (!fast) + { + SetMeshImporterFormat(mf.sharedMesh, true); + } + var mesh = mf.sharedMesh; + if (mesh.vertexCount != 4 && mesh.vertexCount != 3) + { + if (fast) return; + throw new Exception($"Mesh on '{s.gameObject.name}' does not have 3 or 4 vertices ({mesh.vertexCount})"); + } + + if (mf.sharedMesh.vertexCount == 3) + { + // extend triangle to virtual quad + mesh = Instantiate(mesh); + mesh.vertices = new Vector3[] { + mesh.vertices[0], + mesh.vertices[1], + mesh.vertices[2], + mesh.vertices[2], + }; + mesh.uv = new Vector2[] { + mesh.uv[0], + mesh.uv[1], + mesh.uv[2], + mesh.uv[2], + }; + } + + var verts = mesh.vertices; + _LTCGI_Vertices_0[i] = new Vector4(verts[0].x, verts[0].y, verts[0].z, mesh.uv[0].x); + _LTCGI_Vertices_1[i] = new Vector4(verts[1].x, verts[1].y, verts[1].z, mesh.uv[0].y); + _LTCGI_Vertices_2[i] = new Vector4(verts[2].x, verts[2].y, verts[2].z, mesh.uv[3].x); + _LTCGI_Vertices_3[i] = new Vector4(verts[3].x, verts[3].y, verts[3].z, mesh.uv[3].y); + + var angle = Vector3.Dot( + new Vector3(_LTCGI_Vertices_1[i].x, _LTCGI_Vertices_1[i].y, _LTCGI_Vertices_1[i].z) - + new Vector3(_LTCGI_Vertices_0[i].x, _LTCGI_Vertices_0[i].y, _LTCGI_Vertices_0[i].z), + new Vector3(_LTCGI_Vertices_1[i].x, _LTCGI_Vertices_1[i].y, _LTCGI_Vertices_1[i].z) - + new Vector3(_LTCGI_Vertices_3[i].x, _LTCGI_Vertices_3[i].y, _LTCGI_Vertices_3[i].z) + ); + // workaround for blender imports + if (!Mathf.Approximately(angle, 0.0f)) + { + var flip = s.FlipUV ? 1 : -1; + var v0 = _LTCGI_Vertices_0[i]; + var v1 = _LTCGI_Vertices_1[i]; + var v2 = _LTCGI_Vertices_2[i]; + var v3 = _LTCGI_Vertices_3[i]; + _LTCGI_Vertices_0[i] = v0; + _LTCGI_Vertices_1[i] = v3; + _LTCGI_Vertices_2[i] = v1; + _LTCGI_Vertices_3[i] = v2; + _LTCGI_Vertices_0[i].w = mesh.uv[0].x * flip; + _LTCGI_Vertices_1[i].w = mesh.uv[0].y; + _LTCGI_Vertices_2[i].w = mesh.uv[2].x * flip; + _LTCGI_Vertices_3[i].w = mesh.uv[2].y; + + if (s.FlipUV) + { + _LTCGI_UVs[i] = new Vector2[] + { + // TODO: is this required? if so, implement it. for now, no-op. + mesh.uv[0], + mesh.uv[3], + mesh.uv[1], + mesh.uv[2], + }; + } + else + { + _LTCGI_UVs[i] = new Vector2[] + { + mesh.uv[0], + mesh.uv[3], + mesh.uv[1], + mesh.uv[2], + }; + } + } + else + { + _LTCGI_UVs[i] = new Vector2[] + { + mesh.uv[0], + mesh.uv[1], + mesh.uv[2], + mesh.uv[3], + }; + } + + if (s.ColorMode == ColorMode.SingleUV) + { + _LTCGI_Vertices_0[i].w = s.SingleUV.x; + _LTCGI_Vertices_1[i].w = s.SingleUV.y; + } + + if (mf.sharedMesh.vertexCount == 3) + { + DestroyImmediate(mesh); + } + + if (s.Dynamic) + { + dynamics = true; + } + } + + _LTCGI_Vertices_0t[i] = s.transform.TransformPoint(_LTCGI_Vertices_0[i]); + _LTCGI_Vertices_0t[i].w = _LTCGI_Vertices_0[i].w; + _LTCGI_Vertices_1t[i] = s.transform.TransformPoint(_LTCGI_Vertices_1[i]); + _LTCGI_Vertices_1t[i].w = _LTCGI_Vertices_1[i].w; + _LTCGI_Vertices_2t[i] = s.transform.TransformPoint(_LTCGI_Vertices_2[i]); + _LTCGI_Vertices_2t[i].w = _LTCGI_Vertices_2[i].w; + _LTCGI_Vertices_3t[i] = s.transform.TransformPoint(_LTCGI_Vertices_3[i]); + _LTCGI_Vertices_3t[i].w = _LTCGI_Vertices_3[i].w; + + //Debug.Log($"V0: {_LTCGI_Vertices_0[i]}"); + //Debug.Log($"V1: {_LTCGI_Vertices_1[i]}"); + //Debug.Log($"V2: {_LTCGI_Vertices_2[i]}"); + //Debug.Log($"V3: {_LTCGI_Vertices_3[i]}"); + + uint flags = 0; + if (s.DoubleSided) flags |= 1; + if (s.DiffuseFromLm) flags |= 2; + if (s.Specular) flags |= 4; + if (s.Diffuse) flags |= 8; + flags |= ((uint)s.TextureIndex & 0xf) << 4; + flags |= ((uint)s.ColorMode & 0x3) << 8; + flags |= ((uint)s.LightmapChannel & 0x3) << 10; + if (s.Cylinder) flags |= (1<<12); + flags |= ((uint)s.AudioLinkBand & 0x3) << 13; + if (s is LTCGI_Emitter) flags |= (1<<15); // TODO: can this be set based on other flags? + + var col = s.enabled && s.gameObject.activeInHierarchy ? s.Color : Color.black; + float fflags = BitConverter.ToSingle(BitConverter.GetBytes(flags), 0); + _LTCGI_ExtraData[i] = new Vector4(col.linear.r, col.linear.g, col.linear.b, fflags); + } + + if (!fast) + { + HasCylinders = cylinders; + HasDynamicScreens = dynamics; + } + + /*_LTCGI_LightmapMult = new Vector4( + 1.0f/Mathf.Max(screens.Count(s => s.LightmapChannel == 1), 1.0f), + 1.0f/Mathf.Max(screens.Count(s => s.LightmapChannel == 2), 1.0f), + 1.0f/Mathf.Max(screens.Count(s => s.LightmapChannel == 3), 1.0f), + 0.0f + );*/ + + _LTCGI_LightmapMult = (Vector4)LightmapMultiplier; + + #if DEBUG_LOG + if (!fast) + { + Debug.Log($"LTCGI: updated screens ({screens.Length}, {_LTCGI_LightmapMult})"); + } + #endif + + if (!fast || cachedMeshRenderers == null) + { + // get all affected renderers + var allRenderers = Component.FindObjectsOfType<Renderer>(); + var renderers = new List<Renderer>(); + foreach (var r in allRenderers) + { + foreach (var mat in r.sharedMaterials) + { + if (MatLTCGIenabled(mat)) + { + if (!renderers.Contains(r)) + renderers.Add(r); + break; + } + } + } + cachedMeshRenderers = renderers.ToArray(); + + #if DEBUG_LOG + Debug.Log($"LTCGI: cached renderers ({cachedMeshRenderers.Length})"); + #endif + } + + // start LOD chain + if (VideoTexture != null && !CustomBlurChain) + { + LOD1s?.material?.SetTexture("_MainTex", VideoTexture); + } + + // find precomputed static textures + if (!fast) + { + var curscene = EditorSceneManager.GetActiveScene().name; + _LTCGI_LOD_arrays = new Texture2DArray[4]; + for (int lod = 0; lod < 4; lod++) + { + try + { + _LTCGI_LOD_arrays[lod] = AssetDatabase.LoadAssetAtPath<Texture2DArray>("Assets/LTCGI-Generated/lod-" + curscene + "-" + lod + ".asset"); + if (_LTCGI_LOD_arrays[lod] == null) throw new Exception(); + } + catch + { + _LTCGI_LOD_arrays = null; + break; + } + } + } + + // write out uniforms into data texture + var staticUniformTex = WriteStaticUniform(screens, fast); + var screenCountDynamic = screens.TakeWhile(x => x.Dynamic).Count(); + + for (int i = 0; i < cachedMeshRenderers.Length; i++) + { + var r = cachedMeshRenderers[i]; + if (r == null) { + // explicitly do full update in case the renderers have become invalid + UpdateMaterials(false); + return; + } + } + + Shader.SetGlobalFloat("_Udon_LTCGI_GlobalEnable", screens.Length > 0 ? 1.0f : 0.0f); + + if (this != null && this.gameObject != null) + { + #if UDONSHARP + LTCGI_UdonAdapter adapter; + #pragma warning disable 618 + LTCGI_UdonAdapter[] adapters = this.gameObject.GetUdonSharpComponents<LTCGI_UdonAdapter>(); + #pragma warning restore 618 + #else + LTCGI_RuntimeAdapter adapter; + Component[] adapters = this.gameObject.GetComponents<LTCGI_RuntimeAdapter>(); + #endif + + if (adapters == null || adapters.Length == 0) + { + #if UDONSHARP + adapter = this.gameObject.AddUdonSharpComponent<LTCGI_UdonAdapter>(); + #else + adapter = this.gameObject.AddComponent<LTCGI_RuntimeAdapter>(); + #endif + } + else + { + #if UDONSHARP + adapter = (LTCGI_UdonAdapter)adapters[0]; + #else + adapter = (LTCGI_RuntimeAdapter)adapters[0]; + #endif + if (adapters.Length > 1) + { + for (int i = 1; i < adapters.Length; i++) + { + Debug.LogWarning("LTCGI: WARNING: Deleting extra *Adapter component on " + this.gameObject.name); + DestroyImmediate(adapters[i]); + } + } + } + + // update LTCGI_UdonAdapter proxy with new data + #pragma warning disable 618 + adapter.UpdateProxy(); + #pragma warning restore 618 + adapter._Renderers = cachedMeshRenderers.Where(cm => !IsEditorOnly(cm.gameObject)).ToArray(); + adapter._LTCGI_DefaultLightmap = DefaultLightmap; + adapter._LTCGI_Lightmaps = cachedMeshRenderers + .Select(r => { + if (_LTCGI_Lightmaps == null) return DefaultLightmap; + if (_LTCGI_LightmapData_key == null) return DefaultLightmap; + var lidx2 = Array.IndexOf(_LTCGI_LightmapData_key, r); + if (lidx2 < 0) return DefaultLightmap; + var lidx = _LTCGI_LightmapIndex_val[lidx2]; + return lidx != 0xFFFE && lidx >= 0 && lidx < _LTCGI_Lightmaps.Length ? + _LTCGI_Lightmaps[lidx] : DefaultLightmap; + }) + .ToArray(); + adapter._LTCGI_LightmapMult = _LTCGI_LightmapMult; + adapter._LTCGI_LightmapST = cachedMeshRenderers.Select(r => { + if (_LTCGI_LightmapData_key == null) return Vector4.zero; + var idx = Array.IndexOf(_LTCGI_LightmapData_key, r); + return idx < 0 ? Vector4.zero : _LTCGI_LightmapOffsets_val[idx]; + }).ToArray(); + var mask2d = cachedMeshRenderers.Select(x => GetMaskForRenderer(screens, x)).ToArray(); + // float[][] doesn't serialize in normal Unity, so linearize it + adapter._LTCGI_Mask = + Enumerable.Range(0, adapter._Renderers.Length) + .SelectMany(i => mask2d[i]) + .ToArray(); + // mask is reversed! 1 = not visible, 0 = visible + var avatarMask = screens.Select(x => x.AffectAvatars ? 0.0f : 1.0f); + adapter._LTCGI_MaskAvatars = avatarMask.ToArray(); + adapter._Screens = screens.Select(x => x?.gameObject).ToArray(); + adapter._LTCGI_LODs = new Texture[4]; + adapter._LTCGI_LODs[0] = VideoTexture; + adapter._LTCGI_LODs[1] = LOD1; + adapter._LTCGI_LODs[2] = LOD2; + adapter._LTCGI_LODs[3] = LOD3; + if (_LTCGI_LOD_arrays != null) + { + adapter._LTCGI_Static_LODs_0 = _LTCGI_LOD_arrays[0]; + adapter._LTCGI_Static_LODs_1 = _LTCGI_LOD_arrays[1]; + adapter._LTCGI_Static_LODs_2 = _LTCGI_LOD_arrays[2]; + adapter._LTCGI_Static_LODs_3 = _LTCGI_LOD_arrays[3]; + } + else + { + adapter._LTCGI_Static_LODs_0 = null; + adapter._LTCGI_Static_LODs_1 = null; + adapter._LTCGI_Static_LODs_2 = null; + adapter._LTCGI_Static_LODs_3 = null; + } + adapter._LTCGI_lut1 = LUT1; + adapter._LTCGI_lut2 = LUT2; + adapter._LTCGI_ScreenTransforms = _LTCGI_ScreenTransforms; + adapter._LTCGI_Vertices_0 = _LTCGI_Vertices_0; + adapter._LTCGI_Vertices_1 = _LTCGI_Vertices_1; + adapter._LTCGI_Vertices_2 = _LTCGI_Vertices_2; + adapter._LTCGI_Vertices_3 = _LTCGI_Vertices_3; + adapter._LTCGI_ExtraData = _LTCGI_ExtraData; + adapter._LTCGI_static_uniforms = staticUniformTex; + adapter._LTCGI_ScreenCount = screens.Length; + adapter._LTCGI_ScreenCountDynamic = screenCountDynamic; + // masked counts must include all masked screens up to the last non-masked one! + adapter._LTCGI_ScreenCountMasked = + mask2d.Select(mask => + Math.Max(adapter._LTCGI_ScreenCountDynamic, + Array.FindLastIndex(mask, m => m == 0.0f) + 1)).ToArray(); + adapter._LTCGI_ScreenCountMaskedAvatars = Array.FindLastIndex(screens, x => x.AffectAvatars) + 1; + adapter.BlurCRTInput = LOD1s; + + #pragma warning disable 618 + adapter.ApplyProxyModifications(); + #pragma warning restore 618 + + if (screens.Length > 0) + adapter._Initialize(); + + #if DEBUG_LOG + Debug.Log("LTCGI: updated UdonSharp adapter"); + #endif + } + + #if DEBUG_LOG + Debug.Log("LTCGI: writing auto-config file"); + #endif + LTCGI_ControllerEditor.RecalculateAutoConfig(this); + + #if DEBUG_LOG + Debug.Log("LTCGI: updating video player adapters"); + #endif + LTCGI_Controller.DetectAndEnableAdaptersForAvailableVideoplayers(); + + #if DEBUG_LOG + Debug.Log("LTCGI: update done!"); + #endif + } + + private static Texture2D staticUniformTemp = null; + private Texture2D WriteStaticUniform(LTCGI_Screen[] screens, bool fast, LTCGI_Screen fastScreen = null) + { + var curscene = EditorSceneManager.GetActiveScene().name; + var path = @"Assets\LTCGI-Generated\StaticUniform-" + curscene + ".exr"; + + if (staticUniformTemp == null) + { + staticUniformTemp = new Texture2D(6, MAX_SOURCES, UnityEngine.Experimental.Rendering.GraphicsFormat.R16G16B16A16_SFloat, UnityEngine.Experimental.Rendering.TextureCreationFlags.None); + fast = false; + } + + for (int i = 0; i < MAX_SOURCES; i++) + { + if (fast && fastScreen != null && i < screens.Length && screens[i] != fastScreen) + continue; + if (i >= screens.Length) + { + for (int w = 0; w < staticUniformTemp.width; w++) + { + staticUniformTemp.SetPixel(w, i, Color.black); + } + } + else + { + staticUniformTemp.SetPixel(0, i, (Color)_LTCGI_Vertices_0t[i]); + staticUniformTemp.SetPixel(1, i, (Color)_LTCGI_Vertices_1t[i]); + staticUniformTemp.SetPixel(2, i, (Color)_LTCGI_Vertices_2t[i]); + staticUniformTemp.SetPixel(3, i, (Color)_LTCGI_Vertices_3t[i]); + if (_LTCGI_UVs[i] != null && _LTCGI_UVs[i].Length == 4) + { + staticUniformTemp.SetPixel(4, i, (Color)new Vector4( + _LTCGI_UVs[i][0].x, _LTCGI_UVs[i][0].y, _LTCGI_UVs[i][1].x, _LTCGI_UVs[i][1].y)); + staticUniformTemp.SetPixel(5, i, (Color)new Vector4( + _LTCGI_UVs[i][2].x, _LTCGI_UVs[i][2].y, _LTCGI_UVs[i][3].x, _LTCGI_UVs[i][3].y)); + } + } + } + + staticUniformTemp.Apply(); + + if (fast) + { + return staticUniformTemp; + } + + if (!AssetDatabase.IsValidFolder("Assets/LTCGI-Generated")) + AssetDatabase.CreateFolder("Assets", "LTCGI-Generated"); + var exr = staticUniformTemp.EncodeToEXR(Texture2D.EXRFlags.OutputAsFloat); + + var existed = File.Exists(path); + byte[] prev = new byte[0]; + if (existed) + { + prev = File.ReadAllBytes(path); + } + + File.WriteAllBytes(path, exr); + AssetDatabase.Refresh(); + + var asset = AssetDatabase.LoadAssetAtPath<Texture2D>(path); + string assetPath = AssetDatabase.GetAssetPath(asset); + var importer = AssetImporter.GetAtPath(assetPath) as TextureImporter; + if (importer != null && (!prev.SequenceEqual(exr) || importer.npotScale != TextureImporterNPOTScale.None)) + { + importer.mipmapEnabled = false; + importer.textureCompression = TextureImporterCompression.Uncompressed; + importer.crunchedCompression = false; + importer.sRGBTexture = false; + importer.maxTextureSize = 8192; + importer.alphaSource = TextureImporterAlphaSource.FromInput; + importer.alphaIsTransparency = true; + importer.npotScale = TextureImporterNPOTScale.None; + importer.SaveAndReimport(); + } + + #if DEBUG_LOG + Debug.Log("LTCGI: updated static uniform declarations"); + #endif + + return asset; + } + + + + // Debug stuff, plz ignore... + private static (float[], float[], int) ReadLookupFile() + { + float[] ltc_1, ltc_2; + int n; + + using (var reader = new StreamReader("Packages\\at.pimaker.ltcgi\\Lookup Tables\\ltc_3.inc")) + { + n = int.Parse(reader.ReadLine().Trim()); + ltc_1 = new float[n*n*4]; + ltc_2 = new float[n*n*4]; + + var line = reader.ReadLine().Trim(); + var i = 0; + while (line != "}") + { + var s = line.Split(','); + var a = s[0] == "nan" || s[0] == "-nan" ? float.NaN : float.Parse(s[0]); + var b = s[1] == "nan" || s[1] == "-nan" ? float.NaN : float.Parse(s[1]); + var c = s[2] == "nan" || s[2] == "-nan" ? float.NaN : float.Parse(s[2]); + var d = s[3] == "nan" || s[3] == "-nan" ? float.NaN : float.Parse(s[3]); + ltc_1[i + 0] = a; + ltc_1[i + 1] = b; + ltc_1[i + 2] = c; + ltc_1[i + 3] = d; + i += 4; + line = reader.ReadLine().Trim(); + } + + /*i = 0; + line = reader.ReadLine().Trim(); + while (line != "}") + { + var s = line.Split(','); + var a = float.Parse(s[0]); + var b = float.Parse(s[1]); + var c = float.Parse(s[2]); + var d = float.Parse(s[3]); + ltc_2[i + 0] = a; + ltc_2[i + 1] = b; + ltc_2[i + 2] = c; + ltc_2[i + 3] = d; + i += 4; + line = reader.ReadLine().Trim(); + }*/ + } + + Debug.Log("LTCGI: Read texture with size " + n); + return (ltc_1, ltc_2, n); + } + + [MenuItem("Tools/LTCGI/Encode Lookup Textures into EXR")] + public static void EncodeLookups() + { + var (g_ltc_mat_f, g_ltc_mag_f, n) = ReadLookupFile(); + + var tex = new Texture2D(n, n, UnityEngine.Experimental.Rendering.GraphicsFormat.R32G32B32A32_SFloat, 0); + tex.SetPixelData(g_ltc_mat_f, 0); + System.IO.File.WriteAllBytes("Packages\\at.pimaker.ltcgi\\Lookup Tables\\ltc_mat_hdr_3.exr", tex.EncodeToEXR(Texture2D.EXRFlags.OutputAsFloat)); + + var tex2 = new Texture2D(n, n, UnityEngine.Experimental.Rendering.GraphicsFormat.R32G32B32A32_SFloat, 0); + tex2.SetPixelData(g_ltc_mag_f, 0); + System.IO.File.WriteAllBytes("Packages\\at.pimaker.ltcgi\\Lookup Tables\\ltc_mag_hdr_3.exr", tex2.EncodeToEXR(Texture2D.EXRFlags.OutputAsFloat)); + + GameObject.DestroyImmediate(tex); + GameObject.DestroyImmediate(tex2); + AssetDatabase.Refresh(); + } + } +#endif +} diff --git a/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_ControllerAutoSetup.cs b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_ControllerAutoSetup.cs new file mode 100644 index 0000000..726edbc --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_ControllerAutoSetup.cs @@ -0,0 +1,161 @@ +#if UNITY_EDITOR +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using UnityEditor; +using UnityEngine; +#if UDONSHARP +using UdonSharp; +using UdonSharpEditor; +#endif +#endif + +namespace pi.LTCGI +{ + #if UNITY_EDITOR + public partial class LTCGI_Controller + { + public GameObject ConfiguredAdapter; + + private const string PROTV_ADAPTER_VERSION = "1.0.0"; + private const string UDONSHARP_ADAPTER_VERSION = "1.0.0"; + + internal static List<ILTCGI_AutoSetup> wizards; + internal static List<ILTCGI_AutoSetup> Wizards + { + get + { + if (wizards != null) return wizards; + wizards = new List<ILTCGI_AutoSetup>(); + + var asms = System.AppDomain.CurrentDomain.GetAssemblies(); + Assembly asm = Assembly.GetExecutingAssembly(); + foreach (var a in asms) + { + if (a.FullName.Contains("Assembly-CSharp-Editor")) + { + asm = a; + break; + } + } + + foreach (var wizard in asm.GetTypes() + .Where(x => x.IsClass && !x.IsAbstract && typeof(ILTCGI_AutoSetup).IsAssignableFrom(x))) + { + var instance = Activator.CreateInstance(wizard) as ILTCGI_AutoSetup; + if (instance != null) + { + //Debug.Log("LTCGI: Found AutoSetup wizard: " + wizard.Name); + wizards.Add(instance); + } + } + + return wizards; + } + } + + internal static void DrawAutoSetupEditor(LTCGI_Controller my) + { + // we have one configured, only allow un-setup + if (my.ConfiguredAdapter != null) + { + EditorGUILayout.LabelField("Configured Adapter: " + my.ConfiguredAdapter.name); + if (GUILayout.Button("Un-Configure")) + { + DestroyImmediate(my.ConfiguredAdapter); + my.ConfiguredAdapter = null; + LTCGI_Controller.Singleton.UpdateMaterials(); + } + return; + } + + // try to detect auto-setupable video players + foreach (var wizard in Wizards) + { + var set = wizard.AutoSetupEditor(my); + if (set != null) + { + my.ConfiguredAdapter = set; + LTCGI_Controller.Singleton.UpdateMaterials(); + return; + } + } + } + + internal static void DetectAndEnableAdaptersForAvailableVideoplayers() + { +#if UDONSHARP + if (!AssetDatabase.IsValidFolder("Assets/_pi_")) + AssetDatabase.CreateFolder("Assets", "_pi_"); + if (!AssetDatabase.IsValidFolder("Assets/_pi_/_LTCGI-Adapters")) + AssetDatabase.CreateFolder("Assets/_pi_", "_LTCGI-Adapters"); + if (!AssetDatabase.IsValidFolder("Assets/_pi_/_LTCGI-Adapters/Editor")) + AssetDatabase.CreateFolder("Assets/_pi_/_LTCGI-Adapters", "Editor"); + + var changed = false; + + // ProTv + if (AssetDatabase.IsValidFolder("Assets/ArchiTechAnon/ProTV") && (!System.IO.File.Exists("Assets/_pi_/_LTCGI-Adapters/protv_adapter_version.txt") || System.IO.File.ReadAllText("Assets/_pi_/_LTCGI-Adapters/protv_adapter_version.txt") != PROTV_ADAPTER_VERSION)) + { + EditorUtility.DisplayDialog("LTCGI", "ProTv detected, enabling ProTv adapter.", "OK"); + + System.IO.File.WriteAllText("Assets/_pi_/_LTCGI-Adapters/protv_adapter_version.txt", PROTV_ADAPTER_VERSION); + + System.IO.File.Copy("Packages/at.pimaker.ltcgi/Adapters/LTCGI_ProTvAdapter.cs_disabled", "Assets/_pi_/_LTCGI-Adapters/LTCGI_ProTvAdapter.cs", true); + System.IO.File.Copy("Packages/at.pimaker.ltcgi/Adapters/LTCGI_ProTvAdapter.cs_disabled.meta", "Assets/_pi_/_LTCGI-Adapters/LTCGI_ProTvAdapter.cs.meta", true); + System.IO.File.Copy("Packages/at.pimaker.ltcgi/Adapters/LTCGI_ProTvAdapter.asset_disabled", "Assets/_pi_/_LTCGI-Adapters/LTCGI_ProTvAdapter.asset", true); + System.IO.File.Copy("Packages/at.pimaker.ltcgi/Adapters/LTCGI_ProTvAdapter.asset_disabled.meta", "Assets/_pi_/_LTCGI-Adapters/LTCGI_ProTvAdapter.asset.meta", true); + System.IO.File.Copy("Packages/at.pimaker.ltcgi/Adapters/Editor/LTCGI_ProTvAdapterAutoSetup.cs_disabled", "Assets/_pi_/_LTCGI-Adapters/Editor/LTCGI_ProTvAdapterAutoSetup.cs", true); + + AssetDatabase.ImportAsset("Assets/_pi_/_LTCGI-Adapters/LTCGI_ProTvAdapter.asset", ImportAssetOptions.ForceSynchronousImport); + AssetDatabase.Refresh(); + + UdonSharpProgramAsset adapter = AssetDatabase.LoadAssetAtPath<UdonSharpProgramAsset>("Assets/_pi_/_LTCGI-Adapters/LTCGI_ProTvAdapter.asset"); + adapter.sourceCsScript = AssetDatabase.LoadAssetAtPath<MonoScript>("Assets/_pi_/_LTCGI-Adapters/LTCGI_ProTvAdapter.cs"); + adapter.ApplyProgram(); + EditorUtility.SetDirty(adapter); + + changed = true; + } + + // USharpVideo + if (AssetDatabase.IsValidFolder("Assets/USharpVideo") && (!System.IO.File.Exists("Assets/_pi_/_LTCGI-Adapters/usharpvideo_adapter_version.txt") || System.IO.File.ReadAllText("Assets/_pi_/_LTCGI-Adapters/usharpvideo_adapter_version.txt") != UDONSHARP_ADAPTER_VERSION)) + { + EditorUtility.DisplayDialog("LTCGI", "USharpVideo detected, enabling USharpVideo adapter.", "OK"); + + System.IO.File.WriteAllText("Assets/_pi_/_LTCGI-Adapters/usharpvideo_adapter_version.txt", UDONSHARP_ADAPTER_VERSION); + + System.IO.File.Copy("Packages/at.pimaker.ltcgi/Adapters/LTCGI_USharpVideoAdapter.cs_disabled", "Assets/_pi_/_LTCGI-Adapters/LTCGI_USharpVideoAdapter.cs", true); + System.IO.File.Copy("Packages/at.pimaker.ltcgi/Adapters/LTCGI_USharpVideoAdapter.cs_disabled.meta", "Assets/_pi_/_LTCGI-Adapters/LTCGI_USharpVideoAdapter.cs.meta", true); + System.IO.File.Copy("Packages/at.pimaker.ltcgi/Adapters/LTCGI_USharpVideoAdapter.asset_disabled", "Assets/_pi_/_LTCGI-Adapters/LTCGI_USharpVideoAdapter.asset", true); + System.IO.File.Copy("Packages/at.pimaker.ltcgi/Adapters/LTCGI_USharpVideoAdapter.asset_disabled.meta", "Assets/_pi_/_LTCGI-Adapters/LTCGI_USharpVideoAdapter.asset.meta", true); + System.IO.File.Copy("Packages/at.pimaker.ltcgi/Adapters/Editor/LTCGI_USharpVideoAdapterAutoSetup.cs_disabled", "Assets/_pi_/_LTCGI-Adapters/Editor/LTCGI_USharpVideoAdapterAutoSetup.cs", true); + + AssetDatabase.ImportAsset("Assets/_pi_/_LTCGI-Adapters/LTCGI_USharpVideoAdapter.asset", ImportAssetOptions.ForceSynchronousImport); + AssetDatabase.Refresh(); + + UdonSharpProgramAsset adapter = AssetDatabase.LoadAssetAtPath<UdonSharpProgramAsset>("Assets/_pi_/_LTCGI-Adapters/LTCGI_USharpVideoAdapter.asset"); + adapter.sourceCsScript = AssetDatabase.LoadAssetAtPath<MonoScript>("Assets/_pi_/_LTCGI-Adapters/LTCGI_USharpVideoAdapter.cs"); + adapter.ApplyProgram(); + EditorUtility.SetDirty(adapter); + + changed = true; + } + + if (changed) + { + AssetDatabase.SaveAssets(); + UdonSharp.Compiler.UdonSharpCompilerV1.CompileSync(); + } +#endif + } + } + + public interface ILTCGI_AutoSetup + { + // returns value if set up + GameObject AutoSetupEditor(LTCGI_Controller controller); + } + #endif +}
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_ControllerBake.cs b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_ControllerBake.cs new file mode 100644 index 0000000..11d9eab --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_ControllerBake.cs @@ -0,0 +1,484 @@ +#if UNITY_EDITOR +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEditor.SceneManagement; +using UnityEngine; +using UnityEngine.Rendering; +#endif + +namespace pi.LTCGI +{ + #if UNITY_EDITOR + public partial class LTCGI_Controller + { + [Header("Lightmap Baking Cache (do not edit!)")] + [SerializeField] internal List<Material> bakeMaterialReset_key; + [SerializeField] private List<MaterialGlobalIlluminationFlags> bakeMaterialReset_val; + [SerializeField] public bool bakeInProgress; + [SerializeField] private LightingDataAsset prevLightmapData; + [SerializeField] private Texture2D[] prevLightmaps0; + [SerializeField] private Texture2D[] prevLightmaps1; + [SerializeField] private Texture2D[] prevLightmaps2; + [SerializeField] private Texture2D[] prevLightmaps3; + [SerializeField] private LightmapsMode prevLightmapMode; + + [SerializeField] private Texture2D[] _LTCGI_Lightmaps; + [SerializeField] private Renderer[] _LTCGI_LightmapData_key; + [SerializeField] private Vector4[] _LTCGI_LightmapOffsets_val; + [SerializeField] private int[] _LTCGI_LightmapIndex_val; + + [SerializeField] private bool followupWithRealBake; + [SerializeField] private bool followupBakery; + + public bool HasLightmapData() => _LTCGI_Lightmaps != null && _LTCGI_Lightmaps.Length > 0; + public void ClearLightmapData() + { + _LTCGI_Lightmaps = null; + _LTCGI_LightmapData_key = null; + _LTCGI_LightmapOffsets_val = null; + _LTCGI_LightmapIndex_val = null; + } + + [MenuItem("Tools/LTCGI/Bake Shadowmap")] + public static void BakeLightmap() + { + var bakery = false; + #if BAKERY_INCLUDED + bakery = EditorUtility.DisplayDialog("LTCGI", "Bakery has been detected in your project. Do you want to bake the lightmap with Bakery?", "Yes, use Bakery", "No, use built-in"); + #endif + LTCGI_Controller.Singleton.BakeLightmap(bakery, false); + } + + [MenuItem("Tools/LTCGI/Bake Shadowmap and Normal Lightmap")] + public static void BakeLightmapFollowup() + { + var bakery = false; + #if BAKERY_INCLUDED + bakery = EditorUtility.DisplayDialog("LTCGI", "Bakery has been detected in your project. Do you want to bake the lightmap with Bakery?", "Yes, use Bakery", "No, use built-in"); + #endif + LTCGI_Controller.Singleton.BakeLightmap(bakery, true); + } + + internal void BakeLightmap(bool bakery, bool followup) + { + if (Lightmapping.isRunning + #if BAKERY_INCLUDED + || ftRenderLightmap.bakeInProgress + #endif + ) { + Debug.Log("A lightmapping job is already running. Try again when it is done."); + return; + } + + #if !BAKERY_INCLUDED + bakery = false; + #endif + + followupWithRealBake = followup; + followupBakery = bakery; + + LTCGI_Controller.Singleton.UpdateMaterials(); + Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand; + + EditorUtility.DisplayProgressBar("Preparing LTCGI bake", "Disabling all external GI contributors", 0.0f); + + bakeMaterialReset_key = new List<Material>(); + bakeMaterialReset_val = new List<MaterialGlobalIlluminationFlags>(); + + // disable all other contributors + var allRenderers = GameObject.FindObjectsOfType<Renderer>(); + foreach (var renderer in allRenderers) + { + foreach (var m in renderer.sharedMaterials) + { + if (m != null && !bakeMaterialReset_key.Contains(m)) + { + bakeMaterialReset_key.Add(m); + bakeMaterialReset_val.Add(m.globalIlluminationFlags); + m.globalIlluminationFlags = MaterialGlobalIlluminationFlags.None; + } + } + } + + var bakeResets = new Dictionary<GameObject, LTCGI_BakeReset>(); + LTCGI_BakeReset resetter(GameObject obj) + { + if (bakeResets.ContainsKey(obj)) return bakeResets[obj]; + var bakeReset = obj.gameObject.AddComponent<LTCGI_BakeReset>(); + bakeResets.Add(obj, bakeReset); + return bakeReset; + } + + var allLights = GameObject.FindObjectsOfType<Light>(); + foreach (var light in allLights) + { + if (light.gameObject.activeSelf) + { + light.gameObject.SetActive(false); + var r = resetter(light.gameObject); + r.Reenable = true; + } + } + + #if BAKERY_INCLUDED + var allBakeryLights = + GameObject.FindObjectsOfType<BakerySkyLight>().Select(x => x.gameObject) + .Concat(GameObject.FindObjectsOfType<BakeryPointLight>().Select(x => x.gameObject)) + .Concat(GameObject.FindObjectsOfType<BakeryLightMesh>().Select(x => x.gameObject)) + .Concat(GameObject.FindObjectsOfType<BakeryDirectLight>().Select(x => x.gameObject)); + foreach (var light in allBakeryLights) + { + if (light.activeSelf && (!light.TryGetComponent<BakeryLightMesh>(out _) || !light.TryGetComponent<LTCGI_Screen>(out _))) + { + light.SetActive(false); + var r = resetter(light.gameObject); + r.Reenable = true; + } + } + #endif + + var allReflProbes = GameObject.FindObjectsOfType<ReflectionProbe>(); + foreach (var reflProbe in allReflProbes) + { + if (reflProbe.gameObject.activeSelf) + { + reflProbe.gameObject.SetActive(false); + var r = resetter(reflProbe.gameObject); + r.Reenable = true; + } + } + + EditorUtility.DisplayProgressBar("Preparing LTCGI bake", "Making LTCGI_Screens emissive", 0.5f); + + // make screen emissive + var allScreens = GameObject.FindObjectsOfType<LTCGI_Screen>(); + foreach (var scr in allScreens) + { + if (scr.LightmapChannel == 0 || !scr.enabled) continue; + var intens = LightmapIntensity * scr.LightmapIntensity; + var mat = new Material(Shader.Find("Standard")); + var col = scr.LightmapChannel == 1 ? new Color(intens, 0, 0, 1) : ( + scr.LightmapChannel == 2 ? new Color(0, intens, 0, 1) : ( + scr.LightmapChannel == 3 ? new Color(0, 0, intens, 1) : + new Color(0, 0, 0, 1))); + mat.SetColor("_EmissionColor", col); + mat.EnableKeyword("_EMISSION"); + mat.doubleSidedGI = true; // scr.DoubleSided ?? + mat.globalIlluminationFlags = MaterialGlobalIlluminationFlags.BakedEmissive; + + Action<Renderer> handleRenderer = (rend) => { + var flags = GameObjectUtility.GetStaticEditorFlags(rend.gameObject); + var r = resetter(rend.gameObject); + #if BAKERY_INCLUDED + if (rend.TryGetComponent(out BakeryLightMesh lightMesh)) + { + rend.gameObject.SetActive(true); + r.ResetLightMesh = true; + r.lightMeshColor = lightMesh.color; + r.lightMeshIntensity = lightMesh.intensity; + lightMesh.color = new Color(col.r / intens, col.g / intens, col.b / intens, 1); + lightMesh.intensity = intens; + } + else + #endif + { + r.ResetData = true; + r.Materials = rend.sharedMaterials; + r.Flags = flags; + r.ShadowCastingMode = rend.shadowCastingMode; + if (rend.shadowCastingMode == ShadowCastingMode.Off || rend.shadowCastingMode == ShadowCastingMode.ShadowsOnly) + { + rend.shadowCastingMode = ShadowCastingMode.On; + } + rend.sharedMaterials = new Material[] { mat }; + GameObjectUtility.SetStaticEditorFlags(rend.gameObject, flags | StaticEditorFlags.ContributeGI); + } + + if (!rend.enabled) + { + Debug.LogWarning("LTCGI: An object with an LTCGI_Screen component has a disabled renderer, it will be forcibly enabled for the bake", rend.gameObject); + rend.enabled = true; + r.DisableRendererComponents = new Renderer[] { rend }; + } + }; + + LTCGI_Emitter emitter; + if ((emitter = scr as LTCGI_Emitter) != null) + { + foreach (var rend in emitter.EmissiveRenderers) + { + handleRenderer(rend); + } + } + else + { + if (scr.gameObject.TryGetComponent<MeshRenderer>(out MeshRenderer rend)) + { + handleRenderer(rend); + } + else + { + /* There is no mesh renderer on this object */ + Debug.LogWarning("LTCGI: An object with an LTCGI_Screen component has no mesh renderer, it will not contribute shadows to this bake", scr.gameObject); + } + } + } + + bakeInProgress = true; + EditorSceneManager.MarkSceneDirty(gameObject.scene); + EditorSceneManager.SaveOpenScenes(); + EditorUtility.ClearProgressBar(); + + if (!AssetDatabase.IsValidFolder("Assets/LTCGI-Generated")) + AssetDatabase.CreateFolder("Assets", "LTCGI-Generated"); + + /*prevLightmapData = Lightmapping.lightingDataAsset; + Lightmapping.lightingDataAsset = null; + LightmapSettings.lightmaps = null; + prevLightmapMode = LightmapSettings.lightmapsMode; + prevLightmaps0 = new Texture2D[LightmapSettings.lightmaps.Length]; + prevLightmaps1 = new Texture2D[LightmapSettings.lightmaps.Length]; + prevLightmaps2 = new Texture2D[LightmapSettings.lightmaps.Length]; + prevLightmaps3 = new Texture2D[LightmapSettings.lightmaps.Length]; + for (int i = 0; i < LightmapSettings.lightmaps.Length; i++) + { + prevLightmaps0[i] = LightmapSettings.lightmaps[i].lightmapColor; + prevLightmaps1[i] = LightmapSettings.lightmaps[i].lightmapDir; + #pragma warning disable 0618 + prevLightmaps2[i] = LightmapSettings.lightmaps[i].lightmapLight; + #pragma warning restore 0618 + prevLightmaps3[i] = LightmapSettings.lightmaps[i].shadowMask; + }*/ + + UnityEditor.SceneManagement.EditorSceneManager.SaveOpenScenes(); + + Debug.Log("LTCGI: Shadowmap bake started"); + + //EditorUtility.DisplayDialog("LTCGI bake", "Bake your lightmap now using either the integrated Unity lightmap baking tools or Bakery, and when finished another message should come up. If not, go back to the Controller object and manually click 'Semi-Auto Bake Shadowmap FINISH'.", "OK"); + + if (!bakery) + { + Lightmapping.bakeCompleted += BakeCompleteEvent; + EditorUtility.DisplayDialog("LTCGI", "Please don't touch the scene during async bake.", "I promise!"); + Lightmapping.BakeAsync(); + } + + #if BAKERY_INCLUDED + if (bakery) + { + ftRenderLightmap.OnFinishedFullRender += BakeCompleteEvent; + var b = ftRenderLightmap.instance; + if (b == null) + { + b = ftRenderLightmap.instance = ftRenderLightmap.CreateInstance<ftRenderLightmap>(); + //EditorUtility.DisplayDialog("LTCGI", "Bakery instance not found, please bake lightmaps manually now.", "OK"); + } + //else + { + b.Show(); + b.SaveRenderSettings(); + b.LoadRenderSettings(); + // "Asset UV processing" = "Don't change" + ftBuildGraphics.unwrapUVs = false; + ftBuildGraphics.forceDisableUnwrapUVs = false; + b.SaveRenderSettings(); + EditorApplication.delayCall += () => { + b.RenderButton(false); + }; + } + } + #endif + } + + private static void BakeCompleteEvent() + { + var obj = GameObject.FindObjectOfType<LTCGI_Controller>(); + + if (!obj.bakeInProgress) return; + + Lightmapping.bakeCompleted -= BakeCompleteEvent; + #if BAKERY_INCLUDED + ftRenderLightmap.OnFinishedFullRender -= BakeCompleteEvent; + #endif + + EditorApplication.delayCall += obj.BakeComplete; + } + private static void BakeCompleteEvent(object a, EventArgs b) => BakeCompleteEvent(); + internal void BakeComplete() + { + try + { + BakeCompleteProg(); + } + finally + { + followupWithRealBake = false; + + // avoid stuck progress bar + EditorUtility.ClearProgressBar(); + + // I think this should be safe, and avoid some issues with data not being reset + ResetConfiguration(); + } + } + internal void BakeCompleteProg() + { + //EditorUtility.DisplayDialog("LTCGI bake", "Lightmap baking has finished, LTCGI will now apply the generated configuration.", "OK"); + + EditorUtility.DisplayProgressBar("Finishing LTCGI bake", "Copying calculated lightmaps", 0.0f); + + // move away calculated lightmap assets + var curscene = EditorSceneManager.GetActiveScene().name; + AssetDatabase.DeleteAsset("Assets/LTCGI-Generated/Lightmaps-" + curscene); + AssetDatabase.CreateFolder("Assets/LTCGI-Generated", "Lightmaps-" + curscene); + for (int i = 0; i < LightmapSettings.lightmaps.Length; i++) + { + LightmapData lm = LightmapSettings.lightmaps[i]; + EditorUtility.DisplayProgressBar("Finishing LTCGI bake", "Copying calculated lightmaps", i/((float)LightmapSettings.lightmaps.Length-1.0f)); + var tex = lm.lightmapColor; + var path = AssetDatabase.GetAssetPath(tex); + AssetDatabase.CopyAsset(path, "Assets/LTCGI-Generated/Lightmaps-" + curscene + "/" + System.IO.Path.GetFileName(path)); + } + AssetDatabase.Refresh(); + + EditorUtility.DisplayProgressBar("Finishing LTCGI bake", "Caching lightmaps", 0.0f); + + // Copy data to LTCGI buffer, so that other bakes don't influence it + _LTCGI_Lightmaps = new Texture2D[LightmapSettings.lightmaps.Length]; + for (int i = 0; i < LightmapSettings.lightmaps.Length; i++) + { + EditorUtility.DisplayProgressBar("Finishing LTCGI bake", "Caching lightmaps", i/((float)LightmapSettings.lightmaps.Length-1.0f)); + var tex = LightmapSettings.lightmaps[i].lightmapColor; + var path = AssetDatabase.GetAssetPath(tex); + var tex2 = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/LTCGI-Generated/Lightmaps-" + curscene + "/" + System.IO.Path.GetFileName(path)); + SetTextureImporterToLightmap(tex2); + _LTCGI_Lightmaps[i] = tex2; + } + + EditorUtility.DisplayProgressBar("Finishing LTCGI bake", "Applying indexed lightmaps to renderers", 0.0f); + + var renderers = GameObject.FindObjectsOfType<Renderer>(); + var rkey = new List<Renderer>(); + var rval = new List<Vector4>(); + var rival = new List<int>(); + for (int i = 0; i < renderers.Length; i++) + { + EditorUtility.DisplayProgressBar("Finishing LTCGI bake", "Applying indexed lightmaps to renderers", i/((float)renderers.Length-1.0f)); + var r = renderers[i]; + if (GameObjectUtility.AreStaticEditorFlagsSet(r.gameObject, StaticEditorFlags.ContributeGI)) + { + rkey.Add(r); + rval.Add(r.lightmapScaleOffset); + rival.Add(r.lightmapIndex); + + foreach (var m in r.sharedMaterials) + { + if (MatLTCGIenabled(m)) + { + // Disable static batching for all objects we double-lightmap, as + // otherwise Unity bakes unity_LightmapST into the UV channels and + // breaks our custom offsets. + var flags = GameObjectUtility.GetStaticEditorFlags(r.gameObject); + flags &= ~StaticEditorFlags.BatchingStatic; + GameObjectUtility.SetStaticEditorFlags(r.gameObject, flags); + break; + } + } + } + } + _LTCGI_LightmapData_key = rkey.ToArray(); + _LTCGI_LightmapOffsets_val = rval.ToArray(); + _LTCGI_LightmapIndex_val = rival.ToArray(); + + EditorUtility.DisplayProgressBar("Finishing LTCGI bake", "Resetting configuration", 1.0f); + bakeInProgress = false; + ResetConfiguration(); + + /*Lightmapping.lightingDataAsset = prevLightmapData; + LightmapSettings.lightmapsMode = prevLightmapMode; + LightmapSettings.lightmaps = new LightmapData[prevLightmaps0.Length]; + for (int i = 0; i < LightmapSettings.lightmaps.Length; i++) + { + var data = new LightmapData(); + data.lightmapColor = prevLightmaps0[i]; + data.lightmapDir = prevLightmaps1[i]; + #pragma warning disable 0618 + data.lightmapLight = prevLightmaps2[i]; + #pragma warning restore 0618 + data.shadowMask = prevLightmaps3[i]; + LightmapSettings.lightmaps[i] = data; + }*/ + + EditorUtility.ClearProgressBar(); + LTCGI_Controller.Singleton.UpdateMaterials(); + + Debug.Log("LTCGI: Shadowmap bake complete!"); + + if (followupWithRealBake) + { + followupWithRealBake = false; + + #if BAKERY_INCLUDED + if (followupBakery) + { + EditorApplication.delayCall += () => { + var b = ftRenderLightmap.instance; + b.RenderButton(false); + }; + } + else + #endif + { + EditorApplication.delayCall += () => { + Lightmapping.BakeAsync(); + }; + } + } + } + + // includes ones on hidden/disabled objects + private List<LTCGI_BakeReset> GetAllBakeResets() + { + List<LTCGI_BakeReset> found = new List<LTCGI_BakeReset>(); + foreach (LTCGI_BakeReset br in Resources.FindObjectsOfTypeAll(typeof(LTCGI_BakeReset)) as LTCGI_BakeReset[]) + { + if (!EditorUtility.IsPersistent(br.gameObject.transform.root.gameObject) && + !(br.gameObject.hideFlags == HideFlags.NotEditable || br.gameObject.hideFlags == HideFlags.HideAndDontSave)) + { + found.Add(br); + } + } + return found; + } + + [MenuItem("Tools/LTCGI/Force Settings Reset after Bake")] + public static void ResetConfigurationMenu() => LTCGI_Controller.Singleton.ResetConfiguration(); + public void ResetConfiguration() + { + if (bakeMaterialReset_key != null) + { + for (int i = 0; i < bakeMaterialReset_key.Count; i++) + { + bakeMaterialReset_key[i].globalIlluminationFlags = bakeMaterialReset_val[i]; + } + } + + var resetters = GetAllBakeResets(); + foreach (LTCGI_BakeReset r in resetters) + { + if (r) + { + r.ApplyReset(); + DestroyImmediate(r); + } + } + + AssetDatabase.SaveAssets(); + EditorSceneManager.MarkAllScenesDirty(); + EditorSceneManager.SaveOpenScenes(); + } + } + #endif +}
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_ControllerExternal.cs b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_ControllerExternal.cs new file mode 100644 index 0000000..ce9e07d --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_ControllerExternal.cs @@ -0,0 +1,512 @@ +#if UNITY_EDITOR +using System; +using System.IO; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEngine; +using UnityEditor.Build.Reporting; +#if VRC_SDK_VRCSDK2 || UDONSHARP +using VRC.SDKBase.Editor.BuildPipeline; +#endif +#endif + +namespace pi.LTCGI +{ + #if UNITY_EDITOR + [CustomEditor(typeof(LTCGI_Controller))] + public class LTCGI_ControllerEditor : Editor + { + const string VERSION = "v1.0.2"; + + private static readonly string[] CONFIGURATION_PROPS = new[] { + "StaticTextures", + "DynamicRenderers", + "CustomBlurChain", + "LightmapIntensity", + "LightmapMultiplier" + }; + + private static Texture Logo; + + private bool debugFoldout = false; + + private static string configPath; + + private static Dictionary<string, object> configChangedValues = new Dictionary<string, object>(); + + private enum ConfigType + { + Boolean, + Float, + } + + public void OnEnable() + { + Logo = Resources.Load("LTCGI-LogoController") as Texture; + + if (configChangedValues != null) + { + configChangedValues.Clear(); + } + } + + private bool _configChanged = false; + + public override void OnInspectorGUI() + { + GUIStyle style = new GUIStyle(EditorStyles.label); + style.alignment = TextAnchor.MiddleCenter; + style.fixedHeight = 150; + GUI.Box(GUILayoutUtility.GetRect(300, 150, style), Logo, style); + + var rightAlignedLabel = new GUIStyle(EditorStyles.label); + rightAlignedLabel.alignment = TextAnchor.MiddleRight; + GUILayout.Label(VERSION, rightAlignedLabel); + + + bool applyButtonPressed = false; + bool revertButtonPressed = false; + + var resetCol = GUI.backgroundColor; + + LTCGIDocsHelper.DrawHelpButton("https://ltcgi.dev/Getting%20Started/Setup/Controller"); + + if (PrefabUtility.IsPartOfPrefabAsset(target)) + { + var large = new GUIStyle(EditorStyles.wordWrappedLabel); + large.fontSize = 32; + GUILayout.Label("Please put exactly 1 instance of this prefab into your scene!", large); + return; + } + + #if !UDONSHARP + if (LTCGI_Controller.RuntimeMode == LTCGI_Controller.LTCGIRuntimeMode.VRChatWorld) + { + const string msg = "LTCGI for VRChat requires at least UdonSharp 1.0 to be installed in your project!"; + Debug.LogError(msg); + EditorGUILayout.HelpBox(msg, MessageType.Error); + } + #endif + + serializedObject.Update(); + + if (GUILayout.Button("Force Update")) + { + LTCGI_Controller.Singleton.UpdateMaterials(); + } + + if (GUILayout.Button("Precompute Static Textures")) + { + LTCGI_Controller.Singleton.CreateLODTextureArrays(); + } + EditorGUILayout.PropertyField(serializedObject.FindProperty("PrecomputeOnBuild")); + + EditorGUILayout.Separator(); + + LTCGIDocsHelper.DrawHelpButton("https://ltcgi.dev/Advanced/Shadowmaps", "Shadowmap Baking"); + + if (!LTCGI_Controller.Singleton.bakeInProgress && GUILayout.Button("Bake Shadowmap")) + { + LTCGI_Controller.BakeLightmap(); + } + else if (!LTCGI_Controller.Singleton.bakeInProgress && GUILayout.Button("Bake Shadowmap and Normal Lightmap")) + { + LTCGI_Controller.BakeLightmapFollowup(); + } + if (LTCGI_Controller.Singleton.bakeInProgress && GUILayout.Button("Bake Shadowmap - FORCE FINISH")) + { + LTCGI_Controller.Singleton.BakeComplete(); + } + + GUI.backgroundColor = Color.red; + if (LTCGI_Controller.Singleton.bakeMaterialReset_key != null && GUILayout.Button("DEBUG: Force Settings Reset after Bake")) + { + LTCGI_Controller.Singleton.ResetConfiguration(); + } + + if (!LTCGI_Controller.Singleton.bakeInProgress && LTCGI_Controller.Singleton.HasLightmapData() && + GUILayout.Button("Clear Baked Data")) + { + LTCGI_Controller.Singleton.ResetConfiguration(); + LTCGI_Controller.Singleton.ClearLightmapData(); + LTCGI_Controller.Singleton.UpdateMaterials(); + } + GUI.backgroundColor = resetCol; + + EditorGUILayout.Space(); EditorGUILayout.Space(); + + LTCGI_Controller.DrawAutoSetupEditor(LTCGI_Controller.Singleton); + + EditorGUILayout.Space(); EditorGUILayout.Space(); + + if (LTCGI_Controller.Singleton.cachedMeshRenderers != null && LTCGI_Controller.Singleton._LTCGI_ScreenTransforms != null) + { + EditorGUILayout.HelpBox( +$@"Affected Renderers Total: {LTCGI_Controller.Singleton.cachedMeshRenderers.Length} +LTCGI_Screen Components: {LTCGI_Controller.Singleton._LTCGI_ScreenTransforms.Count(x => x != null)} / {LTCGI_Controller.MAX_SOURCES} +AudioLink: {(LTCGI_Controller.AudioLinkAvailable == LTCGI_Controller.AudioLinkAvailability.Unavailable ? "Not Detected" : (LTCGI_Controller.AudioLinkAvailable == LTCGI_Controller.AudioLinkAvailability.AvailableAsset ? "Detected (Asset)" : "Detected (Package)"))}", + MessageType.Info, true + ); + + if (LTCGI_Controller.AudioLinkAvailable == LTCGI_Controller.AudioLinkAvailability.Unavailable) + { + if (GUILayout.Button("Re-Detect AudioLink")) + { + LTCGI_Controller.audioLinkAvailable = LTCGI_Controller.AudioLinkAvailability.NeedsCheck; + var _ignored = LTCGI_Controller.AudioLinkAvailable; + } + } + } + else + { + EditorGUILayout.HelpBox("Hit \"Force Update\" or CTRL-S to calculate info!", MessageType.Info); + } + + EditorGUILayout.Space(); EditorGUILayout.Space(); + var header = new GUIStyle(EditorStyles.boldLabel); + header.fontSize += 4; + GUILayout.Label("LTCGI Configuration", header); + EditorGUILayout.Space(); + + var vidTex = serializedObject.FindProperty("VideoTexture"); + EditorGUILayout.PropertyField(vidTex, true); + if (vidTex.objectReferenceValue == null) + { + EditorGUILayout.HelpBox("Video Texture is not set! This means video player will not reflect their screen. use Auto-Configure options above or refer to documentation on how to set this up if required.", MessageType.Warning); + } + + foreach (var prop in CONFIGURATION_PROPS) + { + EditorGUILayout.PropertyField(serializedObject.FindProperty(prop), true); + } + + // multiplier clamp, negative light go brrr + var lmm = serializedObject.FindProperty("LightmapMultiplier"); + lmm.vector3Value = new Vector3(Mathf.Max(0.0f, lmm.vector3Value.x), Mathf.Max(0.0f, lmm.vector3Value.y), Mathf.Max(0.0f, lmm.vector3Value.z)); + + EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); + GUILayout.Label("Global Shader Options", header); + EditorGUILayout.Space(); + + if (_configChanged) + { + using (new GUILayout.HorizontalScope()) + { + var bigButton = new GUIStyle(GUI.skin.button); + bigButton.fixedHeight = 40.0f; + bigButton.fontStyle = FontStyle.Bold; + bigButton.fontSize = 18; + bigButton.normal.textColor = Color.white; + bigButton.hover.textColor = Color.white; + resetCol = GUI.backgroundColor; + GUI.backgroundColor = Color.red; + if (GUILayout.Button("Apply", bigButton)) + { + applyButtonPressed = true; + } + GUI.backgroundColor = Color.blue; + if (GUILayout.Button("Revert", bigButton)) + { + revertButtonPressed = true; + } + GUI.backgroundColor = resetCol; + } + } + + RecalculateAutoConfig(target as LTCGI_Controller); + + var config = File.ReadAllLines(configPath); + var description = ""; + var resetDesc = false; + for (int i = 0; i < config.Length; i++) + { + string lineRaw = config[i]; + var line = lineRaw.Trim(); + if (string.IsNullOrEmpty(line)) continue; + + if (line.StartsWith("///")) + { + if (resetDesc) + { + description = ""; + resetDesc = false; + } + else if (!string.IsNullOrEmpty(description)) + { + description += Environment.NewLine; + } + description += line.Substring(3).Trim(); + } + else if (description != "" && (line.StartsWith("//#define") || line.StartsWith("#define"))) + { + var name = line.Substring(line.IndexOf(' ') + 1); + var nextSpace = name.IndexOf(' '); + if (nextSpace < 0) nextSpace = name.Length; + name = name.Substring(0, nextSpace); + + object ccvValue; + var existsInCcv = configChangedValues.TryGetValue(name, out ccvValue); + + var debug = description.StartsWith("[DEBUG]"); + description = description.Replace(Environment.NewLine, " "); + + var type = line.Count(char.IsWhiteSpace) > 1 ? ConfigType.Float : ConfigType.Boolean; + + if (type == ConfigType.Boolean) + { + var enabledInConfig = line.StartsWith("#"); + var enabled = (existsInCcv && (bool)ccvValue) || (!existsInCcv && enabledInConfig); + + var toggleStyle = new GUIStyle(GUI.skin.toggle); + if (debug) + { + toggleStyle.normal.textColor = Color.gray; + toggleStyle.hover.textColor = Color.gray; + } + var set = GUILayout.Toggle(enabled, name, toggleStyle); + + EditorGUILayout.HelpBox(description, MessageType.None, true); + EditorGUILayout.Space(); + + if (set != enabledInConfig) + { + configChangedValues[name] = set; + if (set) + { + config[i] = config[i].Substring(2); + } + else + { + config[i] = "//" + config[i]; + } + } + else + { + configChangedValues.Remove(name); + } + } + else if (type == ConfigType.Float) + { + var valueInConfig = float.Parse(line.Substring(line.LastIndexOf(' ')).Replace('f', ' '), System.Globalization.CultureInfo.InvariantCulture); + var value = existsInCcv ? (float)ccvValue : valueInConfig; + + var labelStyle = new GUIStyle(GUI.skin.label); + if (debug) + { + labelStyle.normal.textColor = Color.gray; + labelStyle.hover.textColor = Color.gray; + } + float set; + using (new GUILayout.HorizontalScope()) + { + GUILayout.Label(name, labelStyle); + set = EditorGUILayout.FloatField(value); + } + + EditorGUILayout.HelpBox(description, MessageType.None, true); + EditorGUILayout.Space(); + + if (set != valueInConfig) + { + configChangedValues[name] = set; + config[i] = $"#define {name} {set}"; + } + else + { + configChangedValues.Remove(name); + } + } + + resetDesc = true; + } + } + + _configChanged = configChangedValues.Count > 0; + + if (applyButtonPressed) + { + File.WriteAllLines(configPath, config); + AssetDatabase.Refresh(); + configChangedValues = new Dictionary<string, object>(); + } + else if (revertButtonPressed) + { + configChangedValues = new Dictionary<string, object>(); + } + + EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); + if ((debugFoldout = EditorGUILayout.Foldout(debugFoldout, "[ Debug Menu (Default Inspector) ]"))) + { + DrawDefaultInspector(); + } + + var update = serializedObject.hasModifiedProperties; + serializedObject.ApplyModifiedProperties(); + + if (update) + { + LTCGI_Controller.Singleton.UpdateMaterials(); + } + } + + public static void RecalculateAutoConfig(LTCGI_Controller controller) + { + if (configPath == null || !File.Exists(configPath)) + { + configPath = AssetDatabase.GUIDToAssetPath("01c8aa443e7001b45b28cfe65d1c6786"); + if (string.IsNullOrEmpty(configPath)) + { + Debug.LogError("LTCGI: Could not find config file! Please don't change the GUID or move the meta file!"); + return; + } + } + + var config = File.ReadAllLines(configPath); + var changed = false; + for (int i = 0; i < config.Length; i++) + { + string lineRaw = config[i]; + var line = lineRaw.Trim(); + if (string.IsNullOrEmpty(line)) continue; + + if (line.EndsWith("#define LTCGI_AUDIOLINK")) + { + var enabledInConfig = !line.StartsWith("//"); + var available = LTCGI_Controller.AudioLinkAvailable != LTCGI_Controller.AudioLinkAvailability.Unavailable; + if (enabledInConfig != available) + { + config[i] = (available ? "" : "//") + "#define LTCGI_AUDIOLINK"; + changed = true; + } + } + if (line.StartsWith("#include")) // cursed, but audiolink is the only include for now + { + var newConfig = (LTCGI_Controller.AudioLinkAvailable != LTCGI_Controller.AudioLinkAvailability.Unavailable ? ( + LTCGI_Controller.AudioLinkAvailable == LTCGI_Controller.AudioLinkAvailability.AvailableAsset ? + "#include \"Assets/AudioLink/Shaders/AudioLink.cginc\"" : + "#include \"Packages/com.llealloo.audiolink/Runtime/Shaders/AudioLink.cginc\"" + ) : "#include \"not-available\""); + if (config[i] != newConfig) + { + config[i] = newConfig; + changed = true; + } + } + + if (controller != null) + { + if (line.EndsWith("#define LTCGI_STATIC_UNIFORMS")) + { + var enabledInConfig = !line.StartsWith("//"); + var available = !controller.HasDynamicScreens; + if (enabledInConfig != available) + { + config[i] = (available ? "" : "//") + "#define LTCGI_STATIC_UNIFORMS"; + changed = true; + } + } + + if (line.EndsWith("#define LTCGI_CYLINDER")) + { + var enabledInConfig = !line.StartsWith("//"); + var available = controller.HasCylinders; + if (enabledInConfig != available) + { + config[i] = (available ? "" : "//") + "#define LTCGI_CYLINDER"; + changed = true; + } + } + } + + if (line.EndsWith("#define LTCGI_AVATAR_MODE")) + { + var enabledInConfig = !line.StartsWith("//"); + var enabledByProject = LTCGI_Controller.RuntimeMode == LTCGI_Controller.LTCGIRuntimeMode.VRChatAvatar; + if (enabledInConfig != enabledByProject) + { + config[i] = (enabledByProject ? "" : "//") + "#define LTCGI_AVATAR_MODE"; + changed = true; + } + } + } + if (changed) + { + File.WriteAllLines(configPath, config); + AssetDatabase.Refresh(); + } + } + } + + public static class LTCGIDocsHelper + { + public static void DrawHelpButton(string url, string name = "Help &") + { + EditorGUILayout.Space(); + var bigButton = new GUIStyle(GUI.skin.button); + bigButton.fixedHeight = 30.0f; + bigButton.fontStyle = FontStyle.Bold; + bigButton.fontSize = 14; + bigButton.normal.textColor = Color.white; + bigButton.hover.textColor = Color.white; + var resetCol = GUI.backgroundColor; + GUI.backgroundColor = Color.blue; + if (GUILayout.Button($"Open {name} Documentation", bigButton)) + { + System.Diagnostics.Process.Start(url); + } + GUI.backgroundColor = resetCol; + EditorGUILayout.Space(); + } + } + + // automatic callbacks + public class ShaderPostprocessLTCGI : AssetPostprocessor + { + static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) + { + if (LTCGI_Controller.Singleton != null) + { + EditorApplication.delayCall += LTCGI_Controller.Singleton.UpdateMaterials; + } + } + } + + #if UDONSHARP + public class VRCSDKHookLTCGI : IVRCSDKBuildRequestedCallback + { + public int callbackOrder => 68; + + public bool OnBuildRequested(VRCSDKRequestedBuildType requestedBuildType) + { + if (LTCGI_Controller.Singleton != null) + { + LTCGI_Controller.Singleton.UpdateMaterials(); + if (LTCGI_Controller.Singleton.PrecomputeOnBuild) + { + LTCGI_Controller.Singleton.CreateLODTextureArrays(); + } + } + return true; + } + } + #else + public class PostBuildCallbackLTCGI : UnityEditor.Build.IPreprocessBuildWithReport + { + public int callbackOrder => 68; + + public void OnPreprocessBuild(BuildReport report) + { + if (LTCGI_Controller.Singleton != null) + { + LTCGI_Controller.Singleton.UpdateMaterials(); + if (LTCGI_Controller.Singleton.PrecomputeOnBuild) + { + LTCGI_Controller.Singleton.CreateLODTextureArrays(); + } + } + } + } + #endif + #endif +} diff --git a/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_ControllerHelpers.cs b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_ControllerHelpers.cs new file mode 100644 index 0000000..26ee25b --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_ControllerHelpers.cs @@ -0,0 +1,146 @@ +#if UNITY_EDITOR +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEngine; +using UnityEngine.Rendering; +#endif + +namespace pi.LTCGI +{ + #if UNITY_EDITOR + public partial class LTCGI_Controller + { + public enum AudioLinkAvailability + { + NeedsCheck, + Unavailable, + AvailableAsset, + AvailablePackage, + } + internal static AudioLinkAvailability audioLinkAvailable = AudioLinkAvailability.NeedsCheck; + public static AudioLinkAvailability AudioLinkAvailable { + get { + if (audioLinkAvailable == AudioLinkAvailability.NeedsCheck) + { + if (System.IO.File.Exists("Packages/com.llealloo.audiolink/Runtime/Shaders/AudioLink.cginc")) + { + audioLinkAvailable = AudioLinkAvailability.AvailablePackage; + } + else if (System.IO.File.Exists("Assets/AudioLink/Shaders/AudioLink.cginc")) + { + audioLinkAvailable = AudioLinkAvailability.AvailableAsset; + } + else + { + audioLinkAvailable = AudioLinkAvailability.Unavailable; + } + } + return audioLinkAvailable; + } + } + + public enum LTCGIRuntimeMode + { + Standalone, + VRChatWorld, + VRChatAvatar, + } + public static LTCGIRuntimeMode RuntimeMode + { + get + { + #if VRC_SDK_VRCSDK3 + if (System.IO.Directory.Exists("Packages\\com.vrchat.avatars")) + return LTCGIRuntimeMode.VRChatAvatar; + else + return LTCGIRuntimeMode.VRChatWorld; + #else + return LTCGIRuntimeMode.Standalone; + #endif + } + } + + private float[] GetMaskForRenderer(LTCGI_Screen[] screens, Renderer r) + { + // mask is reversed! 1 = not visible, 0 = visible + Func<bool, float> b = cond => cond ? 1.0f : 0.0f; + return Enumerable.Range(0, screens.Length) + .Select(si => { + switch (screens[si].RendererMode) + { + case RendererMode.OnlyListed: + return b(!screens[si].RendererList.Contains(r)); + case RendererMode.ExcludeListed: + return b(screens[si].RendererList.Contains(r)); + case RendererMode.Distance: + var screenPos = screens[si].transform.position; + var point = r.bounds.ClosestPoint(screenPos); + var dist = Vector3.Distance(point, screenPos); + return b(dist > screens[si].RendererDistance); + default: // RendererMode.All + return b(false); + } + }) + .ToArray(); + } + + private void SetTextureImporterToLightmap(Texture2D texture) + { + if (null == texture) return; + string assetPath = AssetDatabase.GetAssetPath(texture); + var importer = AssetImporter.GetAtPath(assetPath) as TextureImporter; + if (importer != null && importer.textureType != TextureImporterType.Lightmap) + { + importer.textureType = TextureImporterType.Lightmap; + importer.mipmapEnabled = false; + importer.SaveAndReimport(); + AssetDatabase.Refresh(); + } + } + + private void SetMeshImporterFormat(Mesh mesh, bool readable) + { + if (mesh == null) return; + string assetPath = AssetDatabase.GetAssetPath(mesh); + if (string.IsNullOrEmpty(assetPath)) return; + var importer = AssetImporter.GetAtPath(assetPath) as ModelImporter; + if (importer != null && importer.isReadable != readable) + { + importer.isReadable = readable; + Debug.Log("LTCGI: Read/Write set for Model " + assetPath); + importer.SaveAndReimport(); + } + } + + private void SetTextureImporterFormat(Texture2D texture, bool readable) + { + if (texture == null) return; + string assetPath = AssetDatabase.GetAssetPath(texture); + var importer = AssetImporter.GetAtPath(assetPath) as TextureImporter; + if (importer != null && importer.isReadable != readable) + { + importer.isReadable = readable; + Debug.Log("LTCGI: Read/Write set for Texture " + assetPath); + importer.SaveAndReimport(); + } + } + + private Texture2D ReadIntoTexture2D(RenderTexture renderTex) + { + Texture2D tex = new Texture2D(renderTex.width, renderTex.height, TextureFormat.RGBA32, false, true); + RenderTexture.active = renderTex; + tex.ReadPixels(new Rect(0, 0, renderTex.width, renderTex.height), 0, 0); + tex.Apply(); + RenderTexture.active = null; + return tex; + } + + private bool IsEditorOnly(GameObject obj) + { + return obj.tag == "EditorOnly"; + } + } + #endif +}
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_ControllerLOD.cs b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_ControllerLOD.cs new file mode 100644 index 0000000..f241e72 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_ControllerLOD.cs @@ -0,0 +1,148 @@ +#if UNITY_EDITOR +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEditor.SceneManagement; +using UnityEngine; +using UnityEngine.Rendering; +#endif + +namespace pi.LTCGI +{ + #if UNITY_EDITOR + public partial class LTCGI_Controller + { + public bool PrecomputeOnBuild = true; + private Texture2D[] CreateLODs(Texture2D input, int width, int height) + { + var result = new Texture2D[4]; + + // apply gamma to lod0 too and resize it + var rt0 = new RenderTexture(width, height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB); + rt0.wrapMode = TextureWrapMode.Clamp; + Graphics.Blit(input, rt0); + result[0] = ReadIntoTexture2D(rt0); + RenderTexture.DestroyImmediate(rt0); + + var CustomRenderTextureCenters = new Vector4[1]; + CustomRenderTextureCenters[0] = new Vector4(0.5f, 0.5f, 0, 0); + LOD1.material.SetVectorArray("CustomRenderTextureCenters", CustomRenderTextureCenters); + var CustomRenderTextureSizesAndRotations = new Vector4[1]; + CustomRenderTextureSizesAndRotations[0] = new Vector4(1, 1, 0, 0); + LOD1.material.SetVectorArray("CustomRenderTextureSizesAndRotations", CustomRenderTextureSizesAndRotations); + + for (int i = 0; i < 3; i++) + { + var crt = new CustomRenderTexture[] { LOD1, LOD2, LOD3 } [i]; + var crtS = new CustomRenderTexture[] { LOD1s, LOD2s, LOD3s } [i]; + var origTex = crt.material.GetTexture("_MainTex"); + var origTexS = crtS.material.GetTexture("_MainTex"); + crtS.material.SetTexture("_MainTex", result[i]); + var rt = new RenderTexture(width/Mathf.NextPowerOfTwo((i+1)*2), height/Mathf.NextPowerOfTwo((i+1)*2), 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear); + rt.wrapMode = TextureWrapMode.Clamp; + Graphics.Blit(result[i], rt, crtS.material, 0); + var rt2 = new RenderTexture(rt.width, rt.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear); + rt.wrapMode = TextureWrapMode.Clamp; + crt.material.SetTexture("_MainTex", rt); + Graphics.Blit(rt, rt2, crt.material, 1); + result[i + 1] = ReadIntoTexture2D(rt2); + crt.material.SetTexture("_MainTex", origTex); + crtS.material.SetTexture("_MainTex", origTexS); + RenderTexture.DestroyImmediate(rt); + RenderTexture.DestroyImmediate(rt2); + } + return result; + } + + [MenuItem("Tools/LTCGI/Precompute Static Textures")] + public static void CreateLODTextureArraysMenu() => LTCGI_Controller.Singleton?.CreateLODTextureArrays(); + + public void CreateLODTextureArrays() + { + var curscene = EditorSceneManager.GetActiveScene().name; + + if (StaticTextures == null || StaticTextures.Length == 0) + { + for (int lod = 0; lod < 4; lod++) + { + try + { + AssetDatabase.DeleteAsset("Assets/LTCGI-Generated/lod-" + curscene + "-" + lod + ".asset"); + } + catch {} + } + return; + } + + EditorUtility.DisplayProgressBar("LTCGI: Precomputing Static Textures", "Calculating LODs...", 0.0f); + + try + { + // Create LODs by applying blur shader + var inputLods = new Texture2D[StaticTextures.Length, 4]; + var width = Mathf.ClosestPowerOfTwo(StaticTextures.Max(x => x.width)); + var height = Mathf.ClosestPowerOfTwo(StaticTextures.Max(x => x.height)); + for (int i = 0; i < StaticTextures.Length; i++) + { + var lods = CreateLODs(StaticTextures[i], width, height); + inputLods[i, 0] = lods[0]; + inputLods[i, 1] = lods[1]; + inputLods[i, 2] = lods[2]; + inputLods[i, 3] = lods[3]; + + EditorUtility.DisplayProgressBar("LTCGI: Precomputing Static Textures", "Calculating LODs...", 0.5f * ((float)i / (float)StaticTextures.Length)); + } + + EditorUtility.DisplayProgressBar("LTCGI: Precomputing Static Textures", "Generating Texture Arrays...", 0.5f); + + // Fill into compressed Texture2DArrays + for (int lod = 0; lod < 4; lod++) + { + Texture2DArray texture2DArray = new Texture2DArray( + inputLods[0, lod].width, + inputLods[0, lod].height, + StaticTextures.Length, + TextureFormat.BC7, true, false); + texture2DArray.wrapMode = TextureWrapMode.Clamp; + + for (int i = 0; i < StaticTextures.Length; i++) + { + SetTextureImporterFormat(inputLods[i, lod], true); + Texture2D temp = new Texture2D(texture2DArray.width, texture2DArray.height, TextureFormat.RGBA32, true, true); + temp.wrapMode = TextureWrapMode.Clamp; + temp.SetPixels32(inputLods[i, lod].GetPixels32(0)); + temp.Apply(); + EditorUtility.CompressTexture(temp, TextureFormat.BC7, UnityEditor.TextureCompressionQuality.Best); + temp.Apply(); + for (int mip = 0; mip < temp.mipmapCount; mip++) { + Graphics.CopyTexture(temp, 0, mip, texture2DArray, i, mip); + } + Texture2D.DestroyImmediate(temp); + } + + // Save as asset + if (!AssetDatabase.IsValidFolder("Assets/LTCGI-Generated")) + AssetDatabase.CreateFolder("Assets", "LTCGI-Generated"); + AssetDatabase.CreateAsset(texture2DArray, "Assets/LTCGI-Generated/lod-" + curscene + "-" + lod + ".asset"); + + EditorUtility.DisplayProgressBar("LTCGI: Precomputing Static Textures", "Generating Texture Arrays...", 0.5f + 0.5f * (lod / 3.0f)); + } + + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + } + catch (Exception ex) + { + Debug.LogError(ex); + } + finally + { + EditorUtility.ClearProgressBar(); + } + + UpdateMaterials(); + } + } + #endif +}
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_Emitter.cs b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_Emitter.cs new file mode 100644 index 0000000..9dec710 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_Emitter.cs @@ -0,0 +1,98 @@ +#if UNITY_EDITOR +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEngine; +#endif + +namespace pi.LTCGI +{ + #if UNITY_EDITOR + [ExecuteInEditMode] + public class LTCGI_Emitter : LTCGI_Screen + { + public Renderer[] EmissiveRenderers; + + [HideInInspector] public bool Initialized = false; + + public LTCGI_Emitter() + { + // static values for emitters + this.Cylinder = false; + this.Diffuse = true; + this.DiffuseFromLm = true; + this.DoubleSided = true; + this.Dynamic = false; + this.FlipUV = false; + this.Specular = false; + } + } + + [CustomEditor(typeof(LTCGI_Emitter))] + [CanEditMultipleObjects] + public class LTCGI_EmitterEditor : LTCGI_ScreenEditor + { + public override void OnInspectorGUI() + { + GUIStyle style = new GUIStyle(EditorStyles.label); + style.alignment = TextAnchor.MiddleCenter; + style.fixedHeight = 150; + GUI.Box(GUILayoutUtility.GetRect(300, 150, style), Logo, style); + + var emitter = (LTCGI_Emitter)target; + + if (!emitter.enabled || !emitter.gameObject.activeInHierarchy) + { + EditorGUILayout.Space(); + EditorGUILayout.HelpBox("This component is disabled, or the GameObject not active! This will cause it to not bake a lightmap, and can cause issues at runtime. If you want this renderer to start disabled, set it's color to Black (0,0,0) or visit https://ltcgi.dev/ to see how you can toggle LTCGI globally.", MessageType.Error, true); + LTCGIDocsHelper.DrawHelpButton("https://ltcgi.dev/Getting%20Started/Setup/Basic_Toggle", "LTCGI Toggle"); + EditorGUILayout.Space(); + } + + LTCGIDocsHelper.DrawHelpButton("https://ltcgi.dev/Advanced/LTCGI_Emitter"); + + serializedObject.Update(); + + var emissiveRenderers = serializedObject.FindProperty("EmissiveRenderers"); + + if (!emitter.Initialized) + { + serializedObject.FindProperty("Initialized").boolValue = true; + lmProp.intValue = 1; + emissiveRenderers.InsertArrayElementAtIndex(0); + emissiveRenderers.GetArrayElementAtIndex(0).objectReferenceValue = emitter.GetComponent<Renderer>(); + } + + EditorGUILayout.HelpBox("This is an emitter component. It can only produce diffuse, untextured light. It can however apply to multiple objects and is a lot cheaper to use.", MessageType.Info); + EditorGUILayout.Space(); + + DrawColorSelector(emitter); + EditorGUILayout.Space(); + DrawColorModeSelector(false); + EditorGUILayout.Space(); + DrawRendererModeSelector(); + EditorGUILayout.Space(); + DrawLmChannelSelector(); + + if (lmProp.intValue == 0) + { + EditorGUILayout.HelpBox("This emitter is not using a lightmap channel. It will not look correct.", MessageType.Warning); + } + + EditorGUILayout.Space(); + EditorGUILayout.Space(); + + EditorGUILayout.LabelField("List all emissive renderers below:", EditorStyles.boldLabel); + EditorGUILayout.PropertyField(emissiveRenderers, true); + + if (serializedObject.hasModifiedProperties) + { + serializedObject.ApplyModifiedProperties(); + LTCGI_Controller.Singleton?.UpdateMaterials(); + } + } + } + #endif +}
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_Include.cs b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_Include.cs new file mode 100644 index 0000000..3070a03 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_Include.cs @@ -0,0 +1,42 @@ +#if UNITY_EDITOR + +// based on similar script from Bakery + +using System; +using UnityEngine; +using UnityEditor; +using UnityEditor.Build; + +[InitializeOnLoad] +public class LTCGI_Define : IActiveBuildTargetChanged +{ + public int callbackOrder => 0; + + static void AddDefine() + { + var platform = EditorUserBuildSettings.selectedBuildTargetGroup; + var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(platform); + if (!defines.Contains("LTCGI_INCLUDED")) + { + if (defines.Length > 0) + { + defines += ";"; + } + defines += "LTCGI_INCLUDED"; + PlayerSettings.SetScriptingDefineSymbolsForGroup(platform, defines); + } + } + + static LTCGI_Define() + { + AddDefine(); + pi.LTCGI.LTCGI_Controller.MigratoryBirdsDontMigrateAsMuchAsWeDoButThisFunctionWillTakeCareOfItNonetheless(); + } + + public void OnActiveBuildTargetChanged(BuildTarget prev, BuildTarget cur) + { + AddDefine(); + } +} + +#endif diff --git a/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_Screen.cs b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_Screen.cs new file mode 100644 index 0000000..a8df773 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Editor/LTCGI_Screen.cs @@ -0,0 +1,452 @@ +#if UNITY_EDITOR +using System; +using UnityEditor; +using UnityEngine; +#endif + +namespace pi.LTCGI +{ +#if UNITY_EDITOR + [ExecuteInEditMode] + public class LTCGI_Screen : MonoBehaviour + { + public Color Color = Color.white; + + public bool DoubleSided = false; + + [Tooltip("If enabled, allows moving the screen GameObject during runtime. Has CPU performance overhead (Udon).")] + public bool Dynamic; + + public int TextureIndex; + + [Tooltip("Specular and Diffuse are the two types of lighting that LTCGI calculates. For performance, try disabling Diffuse and see if the result is visually similar, in which case you should leave it off.")] + public bool Diffuse = true, Specular = true; + public bool DiffuseFromLm; + [SerializeField] private int diffMode; + + public int LightmapChannel; + public float LightmapIntensity = 1.0f; + + public ColorMode ColorMode; + + public Vector2 SingleUV; + + [Range(0, 3)] + public int AudioLinkBand; + + [Tooltip("Workaround for some Blender imports. Try to enable it if you notice your reflection is sideways.")] + public bool FlipUV; + + public RendererMode RendererMode = RendererMode.Distance; + public MeshRenderer[] RendererList; + [Min(0.0f)] public float RendererDistance = 15.0f; + + public bool Cylinder; + public Vector3 CylinderBase; + public float CylinderHeight = 1.0f; + public float CylinderRadius = 1.0f; + [Range(0.0f, Mathf.PI*0.5f)] + public float CylinderSize = Mathf.PI*0.5f; + [Range(0.0f, Mathf.PI*2.0f)] + public float CylinderAngle; + + [Tooltip("If this renderer should affect avatars that use a supported LTCGI shader.")] + public bool AffectAvatars = true; + + private Vector3 prevPos, prevScale, prevRot; + + private bool update = false; + + private static readonly Color[] GIZMO_COLORS = new Color[] + { + Color.white, + Color.red, + Color.green, + Color.blue, + }; + + public void Update() + { + // don't mess with Udon emulation + if (EditorApplication.isPlaying) + return; + + if (this.prevPos != this.transform.position || + this.prevRot != this.transform.rotation.eulerAngles || + this.prevScale != this.transform.lossyScale) + { + this.prevPos = this.transform.position; + this.prevRot = this.transform.rotation.eulerAngles; + this.prevScale = this.transform.lossyScale; + update = true; + } + if (update && LTCGI_Controller.Singleton != null) + { + LTCGI_Controller.Singleton.UpdateMaterials(true, this); + update = false; + } + } + + void OnDrawGizmos() + { + Gizmos.color = GIZMO_COLORS[this.LightmapChannel]; + Gizmos.DrawIcon(transform.position, "LTCGI_Screen_Gizmo.png", true, Gizmos.color); + } + + private static Mesh cylMesh = null; + void OnDrawGizmosSelected() + { + if (RendererMode == RendererMode.Distance) + { + Gizmos.color = Color.cyan; + Gizmos.DrawWireSphere(transform.position, RendererDistance); + } + + if (Cylinder) + { + if (cylMesh == null) + { + cylMesh = Resources.GetBuiltinResource<Mesh>("Cylinder.fbx"); + } + + Gizmos.color = new Color(0, 1, 1, 0.2f); + Gizmos.DrawMesh(cylMesh, 0, + transform.position + CylinderBase - Vector3.up * 0.5f + Vector3.up * CylinderHeight, + Quaternion.AngleAxis(Mathf.Rad2Deg * CylinderAngle, Vector3.up), + new Vector3(CylinderRadius, CylinderHeight, CylinderRadius) * 1.01f); + } + } + } + + public enum ColorMode + { + Static = 0, + Texture = 1, + SingleUV = 2, + AudioLink = 3, + } + + public enum RendererMode + { + All = 0, + ExcludeListed = 1, + OnlyListed = 2, + Distance = 3, + } + + [CustomEditor(typeof(LTCGI_Screen))] + [CanEditMultipleObjects] + public class LTCGI_ScreenEditor : Editor + { + protected SerializedProperty colorProp, sidedProp, dynamicProp, indexProp, colormodeProp, specProp, diffProp, lmProp, singleUVProp, rendererModeProp, rendererListProp, rendererDistProp, diffModeProp, diffuseFromLmProp, flipProp, lmIntensProp, alBandProp, affectAvatarsProp; + protected SerializedProperty cylProp, cylBaseProp, cylHeightProp, cylAngleProp, cylRadiusProp, cylSizeProp; + + protected static Texture Logo; + + protected enum LMChannel + { + Off = 0, + Red = 1, + Green = 2, + Blue = 3, + } + + protected enum DiffMode + { + NoDiffuse = 0, + LTCDiffuse = 1, + LightmapDiffuse = 2, + } + + void OnEnable() + { + colorProp = serializedObject.FindProperty("Color"); + sidedProp = serializedObject.FindProperty("DoubleSided"); + dynamicProp = serializedObject.FindProperty("Dynamic"); + indexProp = serializedObject.FindProperty("TextureIndex"); + colormodeProp = serializedObject.FindProperty("ColorMode"); + specProp = serializedObject.FindProperty("Specular"); + diffProp = serializedObject.FindProperty("Diffuse"); + lmProp = serializedObject.FindProperty("LightmapChannel"); + singleUVProp = serializedObject.FindProperty("SingleUV"); + rendererModeProp = serializedObject.FindProperty("RendererMode"); + rendererListProp = serializedObject.FindProperty("RendererList"); + rendererDistProp = serializedObject.FindProperty("RendererDistance"); + diffModeProp = serializedObject.FindProperty("diffMode"); + diffuseFromLmProp = serializedObject.FindProperty("DiffuseFromLm"); + lmIntensProp = serializedObject.FindProperty("LightmapIntensity"); + flipProp = serializedObject.FindProperty("FlipUV"); + alBandProp = serializedObject.FindProperty("AudioLinkBand"); + affectAvatarsProp = serializedObject.FindProperty("AffectAvatars"); + + cylProp = serializedObject.FindProperty("Cylinder"); + cylAngleProp = serializedObject.FindProperty("CylinderAngle"); + cylBaseProp = serializedObject.FindProperty("CylinderBase"); + cylHeightProp = serializedObject.FindProperty("CylinderHeight"); + cylRadiusProp = serializedObject.FindProperty("CylinderRadius"); + cylSizeProp = serializedObject.FindProperty("CylinderSize"); + + Logo = Resources.Load("LTCGI-Logo") as Texture; + } + + public override void OnInspectorGUI() + { + GUIStyle style = new GUIStyle(EditorStyles.label); + style.alignment = TextAnchor.MiddleCenter; + style.fixedHeight = 150; + GUI.Box(GUILayoutUtility.GetRect(300, 150, style), Logo, style); + + var screen = (LTCGI_Screen)target; + + if (!screen.enabled || !screen.gameObject.activeInHierarchy) + { + EditorGUILayout.Space(); + EditorGUILayout.HelpBox("This component is disabled, or the GameObject not active! This will cause it to not bake a lightmap, and can cause issues at runtime. If you want this renderer to start disabled, set it's color to Black (0,0,0) or visit https://ltcgi.dev/ to see how you can toggle LTCGI globally.", MessageType.Error, true); + LTCGIDocsHelper.DrawHelpButton("https://ltcgi.dev/Getting%20Started/Setup/Basic_Toggle", "LTCGI Toggle"); + EditorGUILayout.Space(); + } + + LTCGIDocsHelper.DrawHelpButton("https://ltcgi.dev/Getting%20Started/Setup/LTCGI_Screen"); + + serializedObject.Update(); + + GUILayout.Label("Area light shape:"); + var isCylinder = cylProp.boolValue; + using (var hor = new EditorGUILayout.HorizontalScope()) + { + var leftStyle = EditorStyles.miniButtonLeft; + var midStyle = EditorStyles.miniButtonMid; + var rightStyle = EditorStyles.miniButtonRight; + var toggleMesh = GUILayout.Toggle(!isCylinder, "Quad/Triangle", leftStyle); + var toggleCyl = GUILayout.Toggle(isCylinder, "Cylinder", rightStyle); + + if ((toggleMesh && isCylinder) || (!toggleMesh && !isCylinder)) + { + isCylinder = cylProp.boolValue = !toggleMesh; + } + else if ((toggleCyl && !isCylinder) || (!toggleCyl && isCylinder)) + { + isCylinder = cylProp.boolValue = toggleCyl; + } + } + EditorGUILayout.Space(); + EditorGUILayout.Space(); + + if (!isCylinder) + { + var mesh = screen.gameObject.GetComponent<MeshFilter>()?.sharedMesh; + string error = ""; + if (mesh == null) + { + error = "No mesh or mesh filter assigned!"; + } + else if (!mesh.isReadable) + { + error = "Mesh is not readable!"; + } + else if (mesh.vertexCount != 4 && mesh.vertexCount != 3) + { + error = "Mesh does not have exactly 3 or 4 vertices!"; + } + if (error != "") + { + EditorGUILayout.Space(); + EditorGUILayout.HelpBox(error, MessageType.Error, true); + EditorGUILayout.Space(); + } + } + + if (isCylinder) + { + EditorGUILayout.PropertyField(cylBaseProp); + EditorGUILayout.PropertyField(cylHeightProp); + EditorGUILayout.PropertyField(cylRadiusProp); + EditorGUILayout.PropertyField(cylAngleProp); + EditorGUILayout.PropertyField(cylSizeProp); + if (GUILayout.Button("Try cylinder auto-detect")) + { + var coll = screen.gameObject.GetComponent<Collider>(); + if (coll != null) + { + cylBaseProp.vector3Value = new Vector3(0, -coll.bounds.extents.y / 2.0f, 0); + cylHeightProp.floatValue = coll.bounds.extents.y; + cylRadiusProp.floatValue = Mathf.Max(coll.bounds.extents.x, coll.bounds.extents.z); + } + else + { + cylHeightProp.floatValue = screen.transform.localScale.y; + cylRadiusProp.floatValue = screen.transform.localScale.x / 2.0f; + } + } + + EditorGUILayout.Separator(); + } + + DrawColorSelector(screen); + + EditorGUILayout.Space(); + EditorGUILayout.Separator(); + + var dm = (DiffMode)EditorGUILayout.EnumPopup("Diffuse Mode", (DiffMode)diffModeProp.intValue); + if (diffModeProp.intValue != (int)dm) + { + diffModeProp.intValue = (int)dm; + diffProp.boolValue = dm != DiffMode.NoDiffuse; + diffuseFromLmProp.boolValue = dm == DiffMode.LightmapDiffuse; + } + + if (diffuseFromLmProp.boolValue && lmProp.intValue == 0) + { + EditorGUILayout.HelpBox("You have \"Lightmap Diffuse\" enabled but no lightmap channel selected - this is probably not what you want.", MessageType.Warning, true); + } + + EditorGUILayout.PropertyField(specProp); + EditorGUILayout.PropertyField(dynamicProp); + if (isCylinder) + { + sidedProp.boolValue = false; + } + else + { + EditorGUILayout.PropertyField(sidedProp); + } + EditorGUILayout.PropertyField(flipProp); + EditorGUILayout.PropertyField(affectAvatarsProp); + + EditorGUILayout.Separator(); + DrawColorModeSelector(true); + EditorGUILayout.Separator(); + DrawRendererModeSelector(); + EditorGUILayout.Separator(); + DrawLmChannelSelector(); + + if (serializedObject.hasModifiedProperties) + { + serializedObject.ApplyModifiedProperties(); + LTCGI_Controller.Singleton?.UpdateMaterials(); + } + } + + protected void DrawColorSelector(LTCGI_Screen screen) + { + var newCol = EditorGUILayout.ColorField(new GUIContent("Color"), colorProp.colorValue, true, false, true); + if (colorProp.colorValue != newCol) + { + colorProp.colorValue = newCol; + } + + if (colorProp.colorValue.maxColorComponent == 0.0f) + { + EditorGUILayout.HelpBox("Screen is disabled with color black!", MessageType.Warning, true); + } + + if (GUILayout.Button("Try get Color from Material")) + { + var ren = screen.gameObject.GetComponent<Renderer>(); + if (ren != null) + { + var mat = ren.sharedMaterial; + if (mat != null) + { + var col = mat.GetColor("_Color"); + if (col != null) + { + colorProp.colorValue = col; + } + } + } + } + } + + protected void DrawColorModeSelector(bool allowTextured) + { + var texmode = (ColorMode)EditorGUILayout.EnumPopup("Color Mode", (ColorMode)colormodeProp.intValue); + if (colormodeProp.intValue != (int)texmode) + { + colormodeProp.intValue = (int)texmode; + } + if (targets.Length == 1) + { + Action texSelect = () => + { + EditorGUILayout.IntSlider(indexProp, 0, + LTCGI_Controller.Singleton == null && LTCGI_Controller.Singleton.StaticTextures != null ? 2 : + LTCGI_Controller.Singleton.StaticTextures.Length); + + if (LTCGI_Controller.Singleton != null) + { + if (indexProp.intValue == 0) + { + EditorGUILayout.HelpBox("Texture: [Live Video]", MessageType.None, false); + } + else + { + EditorGUILayout.HelpBox("Texture: " + LTCGI_Controller.Singleton.StaticTextures[indexProp.intValue - 1].name, MessageType.None, false); + } + } + }; + switch (texmode) + { + case ColorMode.Static: + indexProp.intValue = 0; + break; + case ColorMode.Texture: + if (allowTextured) + { + texSelect(); + } + else + { + EditorGUILayout.HelpBox("Texture mode is not allowed for emitters! Falling back to static color.", MessageType.Error, true); + } + break; + case ColorMode.SingleUV: + EditorGUILayout.HelpBox("This will always use LOD0 of the video texture as its input.", MessageType.Info); + singleUVProp.vector2Value = EditorGUILayout.Vector2Field("Texture UV", singleUVProp.vector2Value); + break; + case ColorMode.AudioLink: + EditorGUILayout.PropertyField(alBandProp); + string[] bandNames = new[] {"Bass", "Low Mids", "High Mids", "Treble"}; + EditorGUILayout.HelpBox($"Selected Band: {bandNames[alBandProp.intValue]}", MessageType.None, false); + break; + } + } + else + { + EditorGUILayout.HelpBox("(cannot multi-edit 'Color Mode' settings)", MessageType.None, false); + } + } + + protected void DrawRendererModeSelector() + { + var rendererMode = (RendererMode)EditorGUILayout.EnumPopup("Affected Renderers", (RendererMode)rendererModeProp.intValue); + if (rendererModeProp.intValue != (int)rendererMode) + { + rendererModeProp.intValue = (int)rendererMode; + } + if (rendererMode != RendererMode.All && rendererMode != RendererMode.Distance) + { + EditorGUILayout.PropertyField(rendererListProp, new GUIContent("Renderer List"), true); + } + else if (rendererMode == RendererMode.Distance) + { + EditorGUILayout.PropertyField(rendererDistProp); + } + } + + protected void DrawLmChannelSelector() + { + var lmch = (LMChannel)EditorGUILayout.EnumPopup("Lightmap Channel", (LMChannel)lmProp.intValue); + if (lmProp.intValue != (int)lmch) + { + lmProp.intValue = (int)lmch; + } + + if (lmch != LMChannel.Off) + { + EditorGUILayout.PropertyField(lmIntensProp); + } + } + } +#endif +}
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Editor/Resources/LTCGI-Logo.png b/Third_Party/at.pimaker.ltcgi/Editor/Resources/LTCGI-Logo.png Binary files differnew file mode 100644 index 0000000..1634673 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Editor/Resources/LTCGI-Logo.png diff --git a/Third_Party/at.pimaker.ltcgi/Editor/Resources/LTCGI-LogoController.png b/Third_Party/at.pimaker.ltcgi/Editor/Resources/LTCGI-LogoController.png Binary files differnew file mode 100644 index 0000000..c00aa2e --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Editor/Resources/LTCGI-LogoController.png diff --git a/Third_Party/at.pimaker.ltcgi/LICENSE b/Third_Party/at.pimaker.ltcgi/LICENSE new file mode 100644 index 0000000..6249e15 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/LICENSE @@ -0,0 +1,69 @@ +MIT License + +Copyright (c) 2022 _pi_/pimaker + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +Regarding the files 'Shaders/LTCGI.cginc' and 'Shaders/LTCGI_functions.cginc': +Parts of the code in these file are adapted from the example code found here: + + https://github.com/selfshadow/ltc_code + +Modifications by _pi_ (@pimaker on GitHub), licensed under the terms of the +MIT license as far as applicable. + +Original copyright notice: + +Copyright (c) 2017, Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* If you use (or adapt) the source code in your own work, please include a + reference to the paper: + Real-Time Polygonal-Light Shading with Linearly Transformed Cosines. + Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt. + ACM Transactions on Graphics (Proceedings of ACM SIGGRAPH 2016) 35(4), 2016. + Project page: https://eheitzresearch.wordpress.com/415-2/ +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +The following files are licensed explicitly, and may not be modified or used +in commercial projects, but can be redistributed and displayed otherwise, +provided this license is kept: + + Propaganda/pi_graffiti.png + Propaganda/ltcgi_graffiti.png diff --git a/Third_Party/at.pimaker.ltcgi/LTCGI Attribution.prefab b/Third_Party/at.pimaker.ltcgi/LTCGI Attribution.prefab new file mode 100644 index 0000000..caf4ef4 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/LTCGI Attribution.prefab @@ -0,0 +1,161 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &1189626709141234081 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2002333394265864987} + - component: {fileID: 3199363374308750526} + - component: {fileID: 829395981962412148} + m_Layer: 0 + m_Name: LTCGI Attribution + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 4294967295 + m_IsActive: 1 +--- !u!4 &2002333394265864987 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1189626709141234081} + m_LocalRotation: {x: -5.5477588e-15, y: 1, z: 0.000000021855694, w: -0.0000002533197} + m_LocalPosition: {x: -4.633, y: 3.874, z: -0.04} + m_LocalScale: {x: 57.770077, y: 57.770077, z: 57.770077} + m_Children: + - {fileID: 2036487819123109875} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 179.99998, z: 0} +--- !u!33 &3199363374308750526 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1189626709141234081} + m_Mesh: {fileID: 6686097678407549244, guid: 1dfb4dfd05585474694ce9437e48a15c, type: 3} +--- !u!23 &829395981962412148 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1189626709141234081} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 6f39fb3de5f140d4f91287641e2731fd, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!1 &2036487819123109868 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2036487819123109875} + - component: {fileID: 2036487819123109873} + - component: {fileID: 2036487819123109874} + m_Layer: 0 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2036487819123109875 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2036487819123109868} + m_LocalRotation: {x: -1.7476704e-16, y: 1, z: -1.3226886e-21, w: 0.000000014901161} + m_LocalPosition: {x: -0.00835, y: -0.00519, z: -0.00018} + m_LocalScale: {x: 0.017644485, y: 0.008822243, z: 0.017644485} + m_Children: [] + m_Father: {fileID: 2002333394265864987} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 180.00002, z: 0} +--- !u!33 &2036487819123109873 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2036487819123109868} + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &2036487819123109874 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2036487819123109868} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: c23257f77a61239448c4bd8d0e3f8a00, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 diff --git a/Third_Party/at.pimaker.ltcgi/LTCGI Controller.prefab b/Third_Party/at.pimaker.ltcgi/LTCGI Controller.prefab new file mode 100644 index 0000000..d26781a --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/LTCGI Controller.prefab @@ -0,0 +1,68 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2734466848649962336 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2734466848649962342} + - component: {fileID: 5887517211054864581} + m_Layer: 0 + m_Name: LTCGI Controller + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2734466848649962342 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2734466848649962336} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &5887517211054864581 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2734466848649962336} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fd9495527c548954bb5a54d3f720e6ff, type: 3} + m_Name: + m_EditorClassIdentifier: + VideoTexture: {fileID: 0} + StaticTextures: [] + DynamicRenderers: [] + CustomBlurChain: 0 + DefaultLightmap: {fileID: 2800000, guid: ced397d4068940a48a50f58c19c7b525, type: 3} + LOD1s: {fileID: 8600000, guid: d0b2d88d01fd72d4d9c0284fb8db2d75, type: 2} + LOD1: {fileID: 8600000, guid: b45d5f33e6c08674aba8087be4181198, type: 2} + LOD2s: {fileID: 8600000, guid: eddc1dabcb3508841aeca9aafc39ada6, type: 2} + LOD2: {fileID: 8600000, guid: 4c39822960224e44fa4fc277cb567175, type: 2} + LOD3s: {fileID: 8600000, guid: 37bfeb8e09222654494f0508c0606720, type: 2} + LOD3: {fileID: 8600000, guid: 86d16bb7b86384a439dd7bc187c93cdf, type: 2} + LUT1: {fileID: 2800000, guid: 71f1e923e4125c1428b723489dae83ce, type: 3} + LUT2: {fileID: 2800000, guid: 6a62db263e99e8947ad53e88640b4ae7, type: 3} + bakeMaterialReset_key: [] + bakeMaterialReset_val: + bakeInProgress: 0 + prevLightmapData: {fileID: 0} + prevLightmaps0: [] + prevLightmaps1: [] + prevLightmaps2: [] + prevLightmaps3: [] + prevLightmapMode: 0 + _LTCGI_Lightmaps: [] diff --git a/Third_Party/at.pimaker.ltcgi/LTCGI Global Toggle Example.prefab b/Third_Party/at.pimaker.ltcgi/LTCGI Global Toggle Example.prefab new file mode 100644 index 0000000..b73a6d2 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/LTCGI Global Toggle Example.prefab @@ -0,0 +1,147 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2250205118578830447 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2250205118578830441} + - component: {fileID: 2250205118578830442} + - component: {fileID: 2250205118578830443} + - component: {fileID: 2250205118578830444} + - component: {fileID: 2250205118578830445} + - component: {fileID: 2250205118578830446} + m_Layer: 0 + m_Name: LTCGI Toggle Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2250205118578830441 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2250205118578830447} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -3.417, y: 0.449, z: -0.312} + m_LocalScale: {x: 0.1133, y: 0.1133, z: 0.1133} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &2250205118578830442 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2250205118578830447} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &2250205118578830443 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2250205118578830447} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!65 &2250205118578830444 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2250205118578830447} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &2250205118578830445 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2250205118578830447} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 861eec196aa5ee449a74f3e1d2b4aff7, type: 3} + m_Name: + m_EditorClassIdentifier: + serializationData: + SerializedFormat: 2 + SerializedBytes: + ReferencedUnityObjects: [] + SerializedBytesString: + Prefab: {fileID: 0} + PrefabModificationsReferencedUnityObjects: [] + PrefabModifications: [] + SerializationNodes: [] + _udonSharpBackingUdonBehaviour: {fileID: 2250205118578830446} + LTCGI_Controller: {fileID: 0} + StartingState: 1 +--- !u!114 &2250205118578830446 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2250205118578830447} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 45115577ef41a5b4ca741ed302693907, type: 3} + m_Name: + m_EditorClassIdentifier: + interactTextPlacement: {fileID: 0} + interactText: Toggle LTCGI + interactTextGO: {fileID: 0} + proximity: 2 + SynchronizePosition: 0 + AllowCollisionOwnershipTransfer: 0 + Reliable: 0 + _syncMethod: 1 + serializedProgramAsset: {fileID: 11400000, guid: 249e288d0fd67ea43b1daba53b5cadbc, + type: 2} + programSource: {fileID: 11400000, guid: da85b1522a1aada48afee7e4502ba1c0, type: 2} + serializedPublicVariablesBytesString: Ai8AAAAAATIAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAFQAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AAAAAAAYBAAAAAAAAACcBBAAAAHQAeQBwAGUAAWgAAABTAHkAcwB0AGUAbQAuAEMAbwBsAGwAZQBjAHQAaQBvAG4AcwAuAEcAZQBuAGUAcgBpAGMALgBMAGkAcwB0AGAAMQBbAFsAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4ALgBJAG4AdABlAHIAZgBhAGMAZQBzAC4ASQBVAGQAbwBuAFYAYQByAGkAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AXQBdACwAIABtAHMAYwBvAHIAbABpAGIAAQEJAAAAVgBhAHIAaQBhAGIAbABlAHMALwEAAAABaAAAAFMAeQBzAHQAZQBtAC4AQwBvAGwAbABlAGMAdABpAG8AbgBzAC4ARwBlAG4AZQByAGkAYwAuAEwAaQBzAHQAYAAxAFsAWwBWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAEkAbgB0AGUAcgBmAGEAYwBlAHMALgBJAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlACwAIABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgBdAF0ALAAgAG0AcwBjAG8AcgBsAGkAYgABAAAABgMAAAAAAAAAAi8CAAAAAVMAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAGAAMQBbAFsAVgBSAEMALgBVAGQAbwBuAC4AVQBkAG8AbgBCAGUAaABhAHYAaQBvAHUAcgAsACAAVgBSAEMALgBVAGQAbwBuAF0AXQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AAgAAAAYCAAAAAAAAACcBBAAAAHQAeQBwAGUAARcAAABTAHkAcwB0AGUAbQAuAFMAdAByAGkAbgBnACwAIABtAHMAYwBvAHIAbABpAGIAJwEKAAAAUwB5AG0AYgBvAGwATgBhAG0AZQABBwAAAEEAZABhAHAAdABlAHIAJwEEAAAAdAB5AHAAZQABFwAAAFMAeQBzAHQAZQBtAC4ATwBiAGoAZQBjAHQALAAgAG0AcwBjAG8AcgBsAGkAYgAtAQUAAABWAGEAbAB1AGUABwUCLwMAAAABSwAAAFYAUgBDAC4AVQBkAG8AbgAuAEMAbwBtAG0AbwBuAC4AVQBkAG8AbgBWAGEAcgBpAGEAYgBsAGUAYAAxAFsAWwBTAHkAcwB0AGUAbQAuAEIAbwBvAGwAZQBhAG4ALAAgAG0AcwBjAG8AcgBsAGkAYgBdAF0ALAAgAFYAUgBDAC4AVQBkAG8AbgAuAEMAbwBtAG0AbwBuAAMAAAAGAgAAAAAAAAAnAQQAAAB0AHkAcABlAAEXAAAAUwB5AHMAdABlAG0ALgBTAHQAcgBpAG4AZwAsACAAbQBzAGMAbwByAGwAaQBiACcBCgAAAFMAeQBtAGIAbwBsAE4AYQBtAGUAAQ0AAABTAHQAYQByAHQAaQBuAGcAUwB0AGEAdABlACcBBAAAAHQAeQBwAGUAARgAAABTAHkAcwB0AGUAbQAuAEIAbwBvAGwAZQBhAG4ALAAgAG0AcwBjAG8AcgBsAGkAYgArAQUAAABWAGEAbAB1AGUAAQcFAi8EAAAAAUkAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAGAAMQBbAFsAUwB5AHMAdABlAG0ALgBJAG4AdAAzADIALAAgAG0AcwBjAG8AcgBsAGkAYgBdAF0ALAAgAFYAUgBDAC4AVQBkAG8AbgAuAEMAbwBtAG0AbwBuAAQAAAAGAgAAAAAAAAAnAQQAAAB0AHkAcABlAAEXAAAAUwB5AHMAdABlAG0ALgBTAHQAcgBpAG4AZwAsACAAbQBzAGMAbwByAGwAaQBiACcBCgAAAFMAeQBtAGIAbwBsAE4AYQBtAGUAAR8AAABfAF8AXwBVAGQAbwBuAFMAaABhAHIAcABCAGUAaABhAHYAaQBvAHUAcgBWAGUAcgBzAGkAbwBuAF8AXwBfACcBBAAAAHQAeQBwAGUAARYAAABTAHkAcwB0AGUAbQAuAEkAbgB0ADMAMgAsACAAbQBzAGMAbwByAGwAaQBiABcBBQAAAFYAYQBsAHUAZQACAAAABwUHBQcF + publicVariablesUnityEngineObjects: [] + publicVariablesSerializationDataFormat: 0 diff --git a/Third_Party/at.pimaker.ltcgi/LTCGI_Screen_Gizmo.png b/Third_Party/at.pimaker.ltcgi/LTCGI_Screen_Gizmo.png Binary files differnew file mode 100644 index 0000000..922f8a8 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/LTCGI_Screen_Gizmo.png diff --git a/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mag_hdr.exr b/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mag_hdr.exr Binary files differnew file mode 100644 index 0000000..7a001c1 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mag_hdr.exr diff --git a/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mag_hdr_2.exr b/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mag_hdr_2.exr Binary files differnew file mode 100644 index 0000000..555b572 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mag_hdr_2.exr diff --git a/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mag_hdr_inc.exr b/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mag_hdr_inc.exr Binary files differnew file mode 100644 index 0000000..bd1f7c0 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mag_hdr_inc.exr diff --git a/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mat_hdr.exr b/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mat_hdr.exr Binary files differnew file mode 100644 index 0000000..03b5e07 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mat_hdr.exr diff --git a/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mat_hdr_2.exr b/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mat_hdr_2.exr Binary files differnew file mode 100644 index 0000000..7622f92 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mat_hdr_2.exr diff --git a/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mat_hdr_inc.exr b/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mat_hdr_inc.exr Binary files differnew file mode 100644 index 0000000..f3441fa --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Lookup Tables/ltc_mat_hdr_inc.exr diff --git a/Third_Party/at.pimaker.ltcgi/Lookup Tables/white1px.png b/Third_Party/at.pimaker.ltcgi/Lookup Tables/white1px.png Binary files differnew file mode 100644 index 0000000..818c71d --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Lookup Tables/white1px.png diff --git a/Third_Party/at.pimaker.ltcgi/Prefilter Blur/BlurPrefilter.shader b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/BlurPrefilter.shader new file mode 100644 index 0000000..3f639b6 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/BlurPrefilter.shader @@ -0,0 +1,260 @@ +// See also: https://www.ronja-tutorials.com/post/023-postprocessing-blur/ +Shader "LTCGI/Blur Prefilter" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" {} + _BlurSize ("Blur Size", Range(0, 1.0)) = 0.5 + [PowerSlider(3)] _StandardDeviation ("Standard Deviation", Range(0.0, 0.5)) = 0.05 + _Samples ("Samples", Range(1.0, 100.0)) = 100.0 + _LOD ("Mip Map LOD", Int) = 2 + _OutsideMult ("Outside Blur Multiplier", Float) = 2.0 + _InsetSample ("Inset UV (sample)", Float) = 0.0 + _InsetCalculate ("Inset UV (calculate)", Float) = 0.0 + [ToggleUI] _OutsideBlurOnly ("Outside Blur Only", Float) = 0.0 + } + + SubShader + { + Cull Off + ZWrite Off + ZTest Always + + CGINCLUDE + #include "UnityCG.cginc" + + // CRT blurb (from UnityCustomRenderTexture.cginc) + #define kCustomTextureBatchSize 16 + + struct appdata_customrendertexture + { + uint vertexID : SV_VertexID; + }; + + // User facing vertex to fragment shader structure + struct v2f_customrendertexture + { + float4 vertex : SV_POSITION; + float3 localTexcoord : TEXCOORD0; // Texcoord local to the update zone (== globalTexcoord if no partial update zone is specified) + float3 globalTexcoord : TEXCOORD1; // Texcoord relative to the complete custom texture + uint primitiveID : TEXCOORD2; // Index of the update zone (correspond to the index in the updateZones of the Custom Texture) + }; + + // Internal + float4 CustomRenderTextureCenters[kCustomTextureBatchSize]; + float4 CustomRenderTextureSizesAndRotations[kCustomTextureBatchSize]; + float CustomRenderTexturePrimitiveIDs[kCustomTextureBatchSize]; + + float4 CustomRenderTextureParameters; + #define CustomRenderTextureUpdateSpace CustomRenderTextureParameters.x // Normalized(0)/PixelSpace(1) + #define CustomRenderTexture3DTexcoordW CustomRenderTextureParameters.y + #define CustomRenderTextureIs3D CustomRenderTextureParameters.z + + // User facing uniform variables + float4 _CustomRenderTextureInfo; // x = width, y = height, z = depth, w = face/3DSlice + + // Helpers + #define _CustomRenderTextureWidth _CustomRenderTextureInfo.x + #define _CustomRenderTextureHeight _CustomRenderTextureInfo.y + #define _CustomRenderTextureDepth _CustomRenderTextureInfo.z + + Texture2D<float4> _SelfTexture2D; // NOTE: THIS IS THE IMPORTANT MODIFICATION! + + // standard custom texture vertex shader that should always be used + v2f_customrendertexture CustomRenderTextureVertexShader(appdata_customrendertexture IN) + { + v2f_customrendertexture OUT; + + #if UNITY_UV_STARTS_AT_TOP + const float2 vertexPositions[6] = + { + { -1.0f, 1.0f }, + { -1.0f, -1.0f }, + { 1.0f, -1.0f }, + { 1.0f, 1.0f }, + { -1.0f, 1.0f }, + { 1.0f, -1.0f } + }; + + const float2 texCoords[6] = + { + { 0.0f, 0.0f }, + { 0.0f, 1.0f }, + { 1.0f, 1.0f }, + { 1.0f, 0.0f }, + { 0.0f, 0.0f }, + { 1.0f, 1.0f } + }; + #else + const float2 vertexPositions[6] = + { + { 1.0f, 1.0f }, + { -1.0f, -1.0f }, + { -1.0f, 1.0f }, + { -1.0f, -1.0f }, + { 1.0f, 1.0f }, + { 1.0f, -1.0f } + }; + + const float2 texCoords[6] = + { + { 1.0f, 1.0f }, + { 0.0f, 0.0f }, + { 0.0f, 1.0f }, + { 0.0f, 0.0f }, + { 1.0f, 1.0f }, + { 1.0f, 0.0f } + }; + #endif + + uint primitiveID = IN.vertexID / 6; + uint vertexID = IN.vertexID % 6; + float3 updateZoneCenter = CustomRenderTextureCenters[primitiveID].xyz; + float3 updateZoneSize = CustomRenderTextureSizesAndRotations[primitiveID].xyz; + + // Normalize rect if needed + if (CustomRenderTextureUpdateSpace > 0.0) // Pixel space + { + // Normalize xy because we need it in clip space. + updateZoneCenter.xy /= _CustomRenderTextureInfo.xy; + updateZoneSize.xy /= _CustomRenderTextureInfo.xy; + } + else // normalized space + { + // Un-normalize depth because we need actual slice index for culling + updateZoneCenter.z *= _CustomRenderTextureInfo.z; + updateZoneSize.z *= _CustomRenderTextureInfo.z; + } + + // Compute quad vertex position + float2 clipSpaceCenter = updateZoneCenter.xy * 2.0 - 1.0; + float2 pos = vertexPositions[vertexID] * updateZoneSize.xy; + pos.x += clipSpaceCenter.x; + #if UNITY_UV_STARTS_AT_TOP + pos.y += clipSpaceCenter.y; + #else + pos.y -= clipSpaceCenter.y; + #endif + + OUT.vertex = float4(pos, 0.0, 1.0); + OUT.primitiveID = asuint(CustomRenderTexturePrimitiveIDs[primitiveID]); + OUT.localTexcoord = float3(texCoords[vertexID], CustomRenderTexture3DTexcoordW); + OUT.globalTexcoord = float3(pos.xy * 0.5 + 0.5, CustomRenderTexture3DTexcoordW); + #if UNITY_UV_STARTS_AT_TOP + OUT.globalTexcoord.y = 1.0 - OUT.globalTexcoord.y; + #endif + + return OUT; + } + // END CRT blurb + + #pragma vertex CustomRenderTextureVertexShader + #pragma fragment frag + + float _BlurSize; + float _StandardDeviation; + int _Samples; + int _LOD; + float _OutsideMult, _OutsideBlurOnly; + float _InsetSample, _InsetCalculate; + + #define E 2.718281828f + + uniform SamplerState _blur_trilinear_mirror_sampler; + uniform SamplerState _blur_trilinear_clamp_sampler; + + half3 alpha(half4 i) + { + return i.rgb * i.a; + } + + void frag_blur(Texture2D<float4> tex, float2 iuv_sample, float2 iuv_calc, float2 dir, out half3 result) + { + result = 0; + half3 col = 0; + float sum = 0; + + float2 outside = saturate(abs(iuv_calc - 0.5) - 0.5); + outside = smoothstep(0.0, _InsetCalculate*4, outside); + float2 dirmod = 1 + smoothstep(0.5, 1.0, abs(iuv_calc - 0.5).yx); + + if (!any(outside)) + { + if (_OutsideBlurOnly) + { + result = alpha(tex.SampleLevel(_blur_trilinear_clamp_sampler, iuv_sample, _LOD)); + return; + } + + dirmod = 1; + } + + //return half4(dirmod - 1, 0, 1); + + float olen = length(outside); + float mult = (1 - _OutsideBlurOnly) + olen * _OutsideMult; + float stddev = _StandardDeviation * mult; + dirmod *= mult; + _Samples = clamp(_Samples * mult, 0, 90); + + [loop] + for (float index = 0; index < _Samples; index++) + { + float2 offset = ((index/(_Samples-1) - 0.5) * _BlurSize).xx * dirmod; + float2 uv = iuv_sample + dir*offset; + float sq = stddev * stddev; + float gauss = (1 / sqrt(2*UNITY_PI*sq)) * pow(E, -((offset*offset)/(2*sq))); + sum += gauss; + col += lerp( + alpha(tex.SampleLevel(_blur_trilinear_clamp_sampler, uv, _LOD)), + alpha(tex.SampleLevel(_blur_trilinear_mirror_sampler, uv, _LOD)), + saturate(olen * 3.6 - 0.25) + ) * gauss; + } + + col = col / sum; + result = col; + } + ENDCG + + Pass + { + Name "Vertical" + + CGPROGRAM + Texture2D<float4> _MainTex; + half4 frag(v2f_customrendertexture i) : SV_TARGET + { + const float2 dir = float2(0, 1); + float2 insSample = float2(_InsetSample, _InsetSample) * dir.yx; + float2 insCalc = float2(_InsetCalculate, _InsetCalculate) * dir.yx; + float2 uv_sample = (1 + insSample*2) * i.globalTexcoord.xy - insSample; + float2 uv_calc = (1 + insCalc*2) * i.globalTexcoord.xy - insCalc; + half3 result; + frag_blur(_MainTex, uv_sample, uv_calc, dir, result); + return half4(result, 1); + } + ENDCG + } + + Pass + { + Name "Horizontal" + + CGPROGRAM + Texture2D<float4> _MainTex; + half4 frag(v2f_customrendertexture i) : SV_TARGET + { + const float2 dir = float2(1, 0); + float2 insSample = float2(_InsetSample, _InsetSample) * dir.yx; + float2 insCalc = float2(_InsetCalculate, _InsetCalculate) * dir.yx; + float2 uv_sample = (1 + insSample*2) * i.globalTexcoord.xy - insSample; + float2 uv_calc = (1 + insCalc*2) * i.globalTexcoord.xy - insCalc; + half3 result; + frag_blur(_MainTex, uv_sample, uv_calc, dir, result); + return half4(result, 1); + } + ENDCG + } + } +}
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD1_crt.asset b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD1_crt.asset new file mode 100644 index 0000000..57fe7e9 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD1_crt.asset @@ -0,0 +1,52 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!86 &8600000 +CustomRenderTexture: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: LOD1_crt + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_ForcedFallbackFormat: 4 + m_DownscaleFallback: 0 + serializedVersion: 3 + m_Width: 1024 + m_Height: 512 + m_AntiAliasing: 1 + m_MipCount: -1 + m_DepthFormat: 0 + m_ColorFormat: 24 + m_MipMap: 0 + m_GenerateMips: 0 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_BindMS: 0 + m_EnableCompatibleFormat: 0 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 1 + m_Aniso: 0 + m_MipBias: 0 + m_WrapU: 1 + m_WrapV: 1 + m_WrapW: 1 + m_Dimension: 2 + m_VolumeDepth: 1 + m_Material: {fileID: 2100000, guid: 5da4179a3a16c2a42baf690ff0977bd0, type: 2} + m_InitSource: 0 + m_InitMaterial: {fileID: 2100000, guid: e7d342723f9251d4986a06982dbb29b1, type: 2} + m_InitColor: {r: 1, g: 1, b: 1, a: 1} + m_InitTexture: {fileID: 0} + m_UpdateMode: 1 + m_InitializationMode: 0 + m_UpdateZoneSpace: 0 + m_CurrentUpdateZoneSpace: 0 + m_UpdateZones: [] + m_UpdatePeriod: 0 + m_ShaderPass: 1 + m_CubemapFaceMask: 4294967295 + m_DoubleBuffered: 0 + m_WrapUpdateZones: 0 diff --git a/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD1_mat.mat b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD1_mat.mat new file mode 100644 index 0000000..f4c1bf6 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD1_mat.mat @@ -0,0 +1,86 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: LOD1_mat + m_Shader: {fileID: 4800000, guid: e269adf9197798e4ab05d370a2340890, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 8600000, guid: d0b2d88d01fd72d4d9c0284fb8db2d75, type: 2} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BlurSize: 0.065 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _Debug: 0 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _InsetCalculate: 0.25 + - _InsetSample: 0.175 + - _LOD: 2 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _OutsideBlurOnly: 0 + - _OutsideMult: 16 + - _Parallax: 0.02 + - _Samples: 32 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _StandardDeviation: 0.016 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD1s_crt.asset b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD1s_crt.asset new file mode 100644 index 0000000..d4f07e7 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD1s_crt.asset @@ -0,0 +1,52 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!86 &8600000 +CustomRenderTexture: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: LOD1s_crt + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_ForcedFallbackFormat: 4 + m_DownscaleFallback: 0 + serializedVersion: 3 + m_Width: 1024 + m_Height: 512 + m_AntiAliasing: 1 + m_MipCount: -1 + m_DepthFormat: 0 + m_ColorFormat: 24 + m_MipMap: 0 + m_GenerateMips: 0 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_BindMS: 0 + m_EnableCompatibleFormat: 0 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 1 + m_Aniso: 0 + m_MipBias: 0 + m_WrapU: 1 + m_WrapV: 1 + m_WrapW: 1 + m_Dimension: 2 + m_VolumeDepth: 1 + m_Material: {fileID: 2100000, guid: 1188853f1fbab0048845b4fb990d178a, type: 2} + m_InitSource: 0 + m_InitMaterial: {fileID: 2100000, guid: e7d342723f9251d4986a06982dbb29b1, type: 2} + m_InitColor: {r: 1, g: 1, b: 1, a: 1} + m_InitTexture: {fileID: 0} + m_UpdateMode: 1 + m_InitializationMode: 0 + m_UpdateZoneSpace: 0 + m_CurrentUpdateZoneSpace: 0 + m_UpdateZones: [] + m_UpdatePeriod: 0 + m_ShaderPass: 0 + m_CubemapFaceMask: 4294967295 + m_DoubleBuffered: 0 + m_WrapUpdateZones: 0 diff --git a/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD1s_mat.mat b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD1s_mat.mat new file mode 100644 index 0000000..e32cef6 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD1s_mat.mat @@ -0,0 +1,86 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: LOD1s_mat + m_Shader: {fileID: 4800000, guid: e269adf9197798e4ab05d370a2340890, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 8600000, guid: 4b71bf169350ba842b575577023ab60d, type: 2} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BlurSize: 0.065 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _Debug: 0 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _InsetCalculate: 0.25 + - _InsetSample: 0.175 + - _LOD: 2 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _OutsideBlurOnly: 0 + - _OutsideMult: 16 + - _Parallax: 0.02 + - _Samples: 32 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _StandardDeviation: 0.016 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD2_crt.asset b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD2_crt.asset new file mode 100644 index 0000000..2bf17f1 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD2_crt.asset @@ -0,0 +1,52 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!86 &8600000 +CustomRenderTexture: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: LOD2_crt + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_ForcedFallbackFormat: 4 + m_DownscaleFallback: 0 + serializedVersion: 3 + m_Width: 512 + m_Height: 256 + m_AntiAliasing: 1 + m_MipCount: -1 + m_DepthFormat: 0 + m_ColorFormat: 8 + m_MipMap: 0 + m_GenerateMips: 0 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_BindMS: 0 + m_EnableCompatibleFormat: 0 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 1 + m_Aniso: 0 + m_MipBias: 0 + m_WrapU: 1 + m_WrapV: 1 + m_WrapW: 1 + m_Dimension: 2 + m_VolumeDepth: 1 + m_Material: {fileID: 2100000, guid: c63e63ad4412c2f46a69daac0309eb5f, type: 2} + m_InitSource: 0 + m_InitMaterial: {fileID: 2100000, guid: e7d342723f9251d4986a06982dbb29b1, type: 2} + m_InitColor: {r: 1, g: 1, b: 1, a: 1} + m_InitTexture: {fileID: 0} + m_UpdateMode: 1 + m_InitializationMode: 0 + m_UpdateZoneSpace: 0 + m_CurrentUpdateZoneSpace: 0 + m_UpdateZones: [] + m_UpdatePeriod: 0 + m_ShaderPass: 1 + m_CubemapFaceMask: 4294967295 + m_DoubleBuffered: 0 + m_WrapUpdateZones: 0 diff --git a/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD2_mat.mat b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD2_mat.mat new file mode 100644 index 0000000..975faca --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD2_mat.mat @@ -0,0 +1,86 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: LOD2_mat + m_Shader: {fileID: 4800000, guid: e269adf9197798e4ab05d370a2340890, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 8600000, guid: eddc1dabcb3508841aeca9aafc39ada6, type: 2} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BlurSize: 0.122 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _Debug: 0 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _InsetCalculate: 0.1 + - _InsetSample: 0 + - _LOD: 0 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _OutsideBlurOnly: 0 + - _OutsideMult: 15 + - _Parallax: 0.02 + - _Samples: 18 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _StandardDeviation: 0.045 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD2s_crt.asset b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD2s_crt.asset new file mode 100644 index 0000000..768a54b --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD2s_crt.asset @@ -0,0 +1,52 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!86 &8600000 +CustomRenderTexture: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: LOD2s_crt + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_ForcedFallbackFormat: 4 + m_DownscaleFallback: 0 + serializedVersion: 3 + m_Width: 512 + m_Height: 256 + m_AntiAliasing: 1 + m_MipCount: -1 + m_DepthFormat: 0 + m_ColorFormat: 8 + m_MipMap: 0 + m_GenerateMips: 0 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_BindMS: 0 + m_EnableCompatibleFormat: 0 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 1 + m_Aniso: 0 + m_MipBias: 0 + m_WrapU: 1 + m_WrapV: 1 + m_WrapW: 1 + m_Dimension: 2 + m_VolumeDepth: 1 + m_Material: {fileID: 2100000, guid: cbb08734d3b1a04439e12c6993005495, type: 2} + m_InitSource: 0 + m_InitMaterial: {fileID: 2100000, guid: e7d342723f9251d4986a06982dbb29b1, type: 2} + m_InitColor: {r: 1, g: 1, b: 1, a: 1} + m_InitTexture: {fileID: 0} + m_UpdateMode: 1 + m_InitializationMode: 0 + m_UpdateZoneSpace: 0 + m_CurrentUpdateZoneSpace: 0 + m_UpdateZones: [] + m_UpdatePeriod: 0 + m_ShaderPass: 0 + m_CubemapFaceMask: 4294967295 + m_DoubleBuffered: 0 + m_WrapUpdateZones: 0 diff --git a/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD2s_mat.mat b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD2s_mat.mat new file mode 100644 index 0000000..0c007a5 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD2s_mat.mat @@ -0,0 +1,86 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: LOD2s_mat + m_Shader: {fileID: 4800000, guid: e269adf9197798e4ab05d370a2340890, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 8600000, guid: b45d5f33e6c08674aba8087be4181198, type: 2} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BlurSize: 0.122 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _Debug: 0 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _InsetCalculate: 0.1 + - _InsetSample: 0 + - _LOD: 0 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _OutsideBlurOnly: 0 + - _OutsideMult: 15 + - _Parallax: 0.02 + - _Samples: 18 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _StandardDeviation: 0.045 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD3_crt.asset b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD3_crt.asset new file mode 100644 index 0000000..3621f1a --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD3_crt.asset @@ -0,0 +1,52 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!86 &8600000 +CustomRenderTexture: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: LOD3_crt + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_ForcedFallbackFormat: 4 + m_DownscaleFallback: 0 + serializedVersion: 3 + m_Width: 512 + m_Height: 256 + m_AntiAliasing: 1 + m_MipCount: -1 + m_DepthFormat: 0 + m_ColorFormat: 8 + m_MipMap: 1 + m_GenerateMips: 1 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_BindMS: 0 + m_EnableCompatibleFormat: 0 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 1 + m_Aniso: 0 + m_MipBias: 0 + m_WrapU: 1 + m_WrapV: 1 + m_WrapW: 1 + m_Dimension: 2 + m_VolumeDepth: 1 + m_Material: {fileID: 2100000, guid: f73ca2bad2c8a144b93d03166df47d8d, type: 2} + m_InitSource: 0 + m_InitMaterial: {fileID: 2100000, guid: e7d342723f9251d4986a06982dbb29b1, type: 2} + m_InitColor: {r: 1, g: 1, b: 1, a: 1} + m_InitTexture: {fileID: 0} + m_UpdateMode: 1 + m_InitializationMode: 0 + m_UpdateZoneSpace: 0 + m_CurrentUpdateZoneSpace: 0 + m_UpdateZones: [] + m_UpdatePeriod: 0 + m_ShaderPass: 1 + m_CubemapFaceMask: 4294967295 + m_DoubleBuffered: 0 + m_WrapUpdateZones: 0 diff --git a/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD3_mat.mat b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD3_mat.mat new file mode 100644 index 0000000..97ae8f2 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD3_mat.mat @@ -0,0 +1,86 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: LOD3_mat + m_Shader: {fileID: 4800000, guid: e269adf9197798e4ab05d370a2340890, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 8600000, guid: 37bfeb8e09222654494f0508c0606720, type: 2} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BlurSize: 1 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _Debug: 0 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _InsetCalculate: 0 + - _InsetSample: 0 + - _LOD: 0 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _OutsideBlurOnly: 0 + - _OutsideMult: 2.7 + - _Parallax: 0.02 + - _Samples: 14 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _StandardDeviation: 0.36 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD3s_crt.asset b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD3s_crt.asset new file mode 100644 index 0000000..5028996 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD3s_crt.asset @@ -0,0 +1,52 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!86 &8600000 +CustomRenderTexture: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: LOD3s_crt + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_ForcedFallbackFormat: 4 + m_DownscaleFallback: 0 + serializedVersion: 3 + m_Width: 512 + m_Height: 256 + m_AntiAliasing: 1 + m_MipCount: -1 + m_DepthFormat: 0 + m_ColorFormat: 8 + m_MipMap: 1 + m_GenerateMips: 1 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_BindMS: 0 + m_EnableCompatibleFormat: 0 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 1 + m_Aniso: 0 + m_MipBias: 0 + m_WrapU: 1 + m_WrapV: 1 + m_WrapW: 1 + m_Dimension: 2 + m_VolumeDepth: 1 + m_Material: {fileID: 2100000, guid: 95e37bc446891564e8c2606c7a91481b, type: 2} + m_InitSource: 0 + m_InitMaterial: {fileID: 2100000, guid: e7d342723f9251d4986a06982dbb29b1, type: 2} + m_InitColor: {r: 1, g: 1, b: 1, a: 1} + m_InitTexture: {fileID: 0} + m_UpdateMode: 1 + m_InitializationMode: 0 + m_UpdateZoneSpace: 0 + m_CurrentUpdateZoneSpace: 0 + m_UpdateZones: [] + m_UpdatePeriod: 0 + m_ShaderPass: 0 + m_CubemapFaceMask: 4294967295 + m_DoubleBuffered: 0 + m_WrapUpdateZones: 0 diff --git a/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD3s_mat.mat b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD3s_mat.mat new file mode 100644 index 0000000..46451d0 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Prefilter Blur/LOD3s_mat.mat @@ -0,0 +1,86 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: LOD3s_mat + m_Shader: {fileID: 4800000, guid: e269adf9197798e4ab05d370a2340890, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 8600000, guid: 4c39822960224e44fa4fc277cb567175, type: 2} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BlurSize: 1 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _Debug: 0 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _InsetCalculate: 0 + - _InsetSample: 0 + - _LOD: 0 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _OutsideBlurOnly: 0 + - _OutsideMult: 2.7 + - _Parallax: 0.02 + - _Samples: 14 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _StandardDeviation: 0.36 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Third_Party/at.pimaker.ltcgi/Propaganda/Attribution Material.mat b/Third_Party/at.pimaker.ltcgi/Propaganda/Attribution Material.mat new file mode 100644 index 0000000..8a982a9 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Propaganda/Attribution Material.mat @@ -0,0 +1,78 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Attribution Material + m_Shader: {fileID: 10751, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: _ALPHATEST_ON _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: 801767748289aef48b9e6caf6d0bd96a, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.45 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _EnableEmission: 0 + - _GlossMapScale: 1 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _Metallic: 0 + - _Mode: 1 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 0 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Third_Party/at.pimaker.ltcgi/Propaganda/Attribution.png b/Third_Party/at.pimaker.ltcgi/Propaganda/Attribution.png Binary files differnew file mode 100644 index 0000000..ba1d788 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Propaganda/Attribution.png diff --git a/Third_Party/at.pimaker.ltcgi/Propaganda/AttributionWhite.png b/Third_Party/at.pimaker.ltcgi/Propaganda/AttributionWhite.png Binary files differnew file mode 100644 index 0000000..b2d5298 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Propaganda/AttributionWhite.png diff --git a/Third_Party/at.pimaker.ltcgi/Propaganda/Poster1.png b/Third_Party/at.pimaker.ltcgi/Propaganda/Poster1.png Binary files differnew file mode 100644 index 0000000..004f5e8 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Propaganda/Poster1.png diff --git a/Third_Party/at.pimaker.ltcgi/Propaganda/Poster1_rotated.jpg b/Third_Party/at.pimaker.ltcgi/Propaganda/Poster1_rotated.jpg Binary files differnew file mode 100644 index 0000000..39b75f1 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Propaganda/Poster1_rotated.jpg diff --git a/Third_Party/at.pimaker.ltcgi/Propaganda/ltcgi_graffiti.png b/Third_Party/at.pimaker.ltcgi/Propaganda/ltcgi_graffiti.png Binary files differnew file mode 100644 index 0000000..60c08a2 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Propaganda/ltcgi_graffiti.png diff --git a/Third_Party/at.pimaker.ltcgi/Propaganda/ltcgi_sign.fbx b/Third_Party/at.pimaker.ltcgi/Propaganda/ltcgi_sign.fbx Binary files differnew file mode 100644 index 0000000..7c17d4f --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Propaganda/ltcgi_sign.fbx diff --git a/Third_Party/at.pimaker.ltcgi/Propaganda/ltcgi_sign_mat.mat b/Third_Party/at.pimaker.ltcgi/Propaganda/ltcgi_sign_mat.mat new file mode 100644 index 0000000..c997662 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Propaganda/ltcgi_sign_mat.mat @@ -0,0 +1,77 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: ltcgi_sign_mat + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: _EMISSION _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF + m_LightmapFlags: 2 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.8 + - _GlossyReflections: 0 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 0 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0.9526798, g: 0.41037738, b: 1, a: 1} + - _EmissionColor: {r: 1.8938819, g: 0.8175774, b: 1.9766746, a: 1} diff --git a/Third_Party/at.pimaker.ltcgi/Propaganda/pi_graffiti.png b/Third_Party/at.pimaker.ltcgi/Propaganda/pi_graffiti.png Binary files differnew file mode 100644 index 0000000..8856a09 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Propaganda/pi_graffiti.png diff --git a/Third_Party/at.pimaker.ltcgi/README.md b/Third_Party/at.pimaker.ltcgi/README.md new file mode 100644 index 0000000..3da22c8 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/README.md @@ -0,0 +1,72 @@ +# [LTCGI](https://ltcgi.dev) + +LTCGI is an optimized plug-and-play realtime area light solution using the [linearly transformed cosine algorithm](#LTC) for standalone Unity and VRChat. Free to use with [attribution](#Attribution). It can utilize the Unity build-in lightmapper or [Bakery](https://assetstore.unity.com/packages/tools/level-design/bakery-gpu-lightmapper-122218) for realistic shadows on static objects. + + + +# Check out the [**official website**](https://ltcgi.dev) for documentation and a "Getting Started" guide! (https://ltcgi.dev) + +Consider the [attribution requirements](#Attribution). Check the [Releases](https://github.com/pimaker/ltcgi/releases) tab for downloads. + +You can also [download](https://github.com/PiMaker/ltcgi/raw/main/~DemoApp.zip) the standalone demo app pictured above to try it out for yourself. +Alternatively, join the [demo world](https://vrchat.com/home/launch?worldId=wrld_aa2627ec-c63a-4db2-aa3e-9078d41c6d9c) in VRChat. + +[Read the FAQ](https://ltcgi.dev/FAQ) before asking for help anywhere! Once you've done that, feel free to join my Discord and ask for help: https://discord.gg/r38vJd2DuJ + +## Download + +For VRChat, you can install LTCGI via the [Creator Companion](https://vcc.docs.vrchat.com/) from my VPM repository: + +### ⬇️ **[Creator Companion/VPM Install](https://vpm.pimaker.at/)** + +For **standalone Unity**, you can import LTCGI as a [git package](https://docs.unity3d.com/2019.4/Documentation/Manual/upm-ui-giturl.html) with the URL: `https://github.com/PiMaker/ltcgi.git` + +**Adapters** for various VRChat video players are still distributed as unitypackages from the [Releases tab](https://github.com/pimaker/ltcgi/releases). + +## Supported shaders + +To use LTCGI, all objects that should receive lighting must use a compatible shader. Currently compatible ones are listed below. If you implement LTCGI into your shader, feel free to send a PR to be included. + +* [ORL Shader Family](https://shaders.orels.sh/) by [@orels1](https://github.com/orels1) +* [Silent's Filamented](https://gitlab.com/s-ilent/filamented) +* [Mochie's Unity Shaders](https://github.com/MochiesCode/Mochies-Unity-Shaders) +* [Hekky Shaders](https://github.com/hyblocker/hekky-shaders) +* [z3y's Shaders](https://github.com/z3y/shaders) +* Basic "Unlit" Test Shader (included) +* Surface Shader (included) + +## Attribution + +According to the [License](#License) you are free to use this in your world, but you need to give credit. You are free to do so in whichever way, but you must provide a link to this GitHub repository, such as to fulfill the imported license of the LTC example code used as a base for this project. + +For your convenience, a prefab called `LTCGI Attribution` is provided in the package. + + + +If you don't want to use it, instead display text similar to the following: + +``` +This project/world uses LTCGI by _pi_, see 'github.com/pimaker/ltcgi'. +``` + +# Licensing + +## The LTC algorithm + +Based on this paper: +``` +Real-Time Polygonal-Light Shading with Linearly Transformed Cosines. +Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt. +ACM Transactions on Graphics (Proceedings of ACM SIGGRAPH 2016) 35(4), 2016. +Project page: https://eheitzresearch.wordpress.com/415-2/ +``` +[Read more](https://eheitzresearch.wordpress.com/415-2/) + +## LTCGI + +This project is made available under the terms of the MIT license, unless explicitly marked otherwise in the source files. See `LICENSE` for more. + +The following files are licensed explicitly, and may not be modified or used in commercial projects, but can be redistributed and displayed otherwise, provided this license is kept: + +* Propaganda/pi_graffiti.png +* Propaganda/ltcgi_graffiti.png diff --git a/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_Assembly.asmdef b/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_Assembly.asmdef new file mode 100644 index 0000000..91bce4f --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_Assembly.asmdef @@ -0,0 +1,23 @@ +{ + "name": "LTCGI_Assembly", + "references": [ + "GUID:99835874ee819da44948776e0df4ff1d", + "GUID:f70a94b0bedfa8ec50ed757f72032810", + "GUID:a1653399f63795746b1857281d1e400d" + ], + "includePlatforms": [ + "Android", + "Editor", + "LinuxStandalone64", + "WebGL", + "WindowsStandalone64" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +}
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_AssemblyUdon.asset b/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_AssemblyUdon.asset new file mode 100644 index 0000000..75d2304 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_AssemblyUdon.asset @@ -0,0 +1,16 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5136146375e9a0a498a72a0091b40cc1, type: 3} + m_Name: LTCGI_AssemblyUdon + m_EditorClassIdentifier: + sourceAssembly: {fileID: 5897886265953266890, guid: f16c18940d95fd44a911829bf5e37070, + type: 3} diff --git a/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_ExampleToggle.asset b/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_ExampleToggle.asset new file mode 100644 index 0000000..0999032 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_ExampleToggle.asset @@ -0,0 +1,221 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3} + m_Name: LTCGI_ExampleToggle + m_EditorClassIdentifier: + serializedUdonProgramAsset: {fileID: 11400000, guid: 249e288d0fd67ea43b1daba53b5cadbc, + type: 2} + udonAssembly: + assemblyError: + sourceCsScript: {fileID: 11500000, guid: 861eec196aa5ee449a74f3e1d2b4aff7, type: 3} + scriptVersion: 2 + compiledVersion: 2 + behaviourSyncMode: 1 + hasInteractEvent: 1 + scriptID: 9036805435049282693 + serializationData: + SerializedFormat: 2 + SerializedBytes: + ReferencedUnityObjects: [] + SerializedBytesString: + Prefab: {fileID: 0} + PrefabModificationsReferencedUnityObjects: [] + PrefabModifications: [] + SerializationNodes: + - Name: fieldDefinitions + Entry: 7 + Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UdonSharp.Compiler.FieldDefinition, + UdonSharp.Editor]], mscorlib + - Name: comparer + Entry: 7 + Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String, + mscorlib]], mscorlib + - Name: + Entry: 8 + Data: + - Name: + Entry: 12 + Data: 3 + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: LTCGI_Controller + - Name: $v + Entry: 7 + Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: LTCGI_Controller + - Name: <UserType>k__BackingField + Entry: 7 + Data: 3|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: LTCGI_UdonAdapter, LTCGI_Assembly + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 7 + Data: 4|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: VRC.Udon.UdonBehaviour, VRC.Udon + - Name: + Entry: 8 + Data: + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 1 + - Name: + Entry: 7 + Data: 6|UnityEngine.Serialization.FormerlySerializedAsAttribute, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: StartingState + - Name: $v + Entry: 7 + Data: 7|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: StartingState + - Name: <UserType>k__BackingField + Entry: 7 + Data: 8|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: System.Boolean, mscorlib + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 8 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 9|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: state + - Name: $v + Entry: 7 + Data: 10|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: state + - Name: <UserType>k__BackingField + Entry: 9 + Data: 8 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 8 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 11|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: diff --git a/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_ExampleToggle.cs b/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_ExampleToggle.cs new file mode 100644 index 0000000..290f498 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_ExampleToggle.cs @@ -0,0 +1,32 @@ +#if UDONSHARP +using UdonSharp; +using UnityEngine.Serialization; + +// NOTE: This script has to be in the "_LTCGI/Scripts" folder, *or* reference +// the "LTCGI_AssemblyUdon" to allow it to use the "LTCGI_UdonAdapter" type! + +[UdonBehaviourSyncMode(BehaviourSyncMode.None)] +public class LTCGI_ExampleToggle : UdonSharpBehaviour +{ + // set this to your controller object (specifically the adapter object): + [FormerlySerializedAs("Adapter")] + public LTCGI_UdonAdapter LTCGI_Controller; + + // set this however you want: + public bool StartingState = true; + private bool state; + + void Start() + { + state = StartingState; + LTCGI_Controller._SetGlobalState(state); + } + + // you can make this a UI event as well! + public override void Interact() + { + state = !state; + LTCGI_Controller._SetGlobalState(state); + } +} +#endif
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_UdonAdapter.asset b/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_UdonAdapter.asset new file mode 100644 index 0000000..8a8d8ba --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_UdonAdapter.asset @@ -0,0 +1,1970 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3} + m_Name: LTCGI_UdonAdapter + m_EditorClassIdentifier: + serializedUdonProgramAsset: {fileID: 11400000, guid: 5bd39a6c4bb253e4087c7b2b92d17eb3, + type: 2} + udonAssembly: + assemblyError: + sourceCsScript: {fileID: 11500000, guid: 0007c466735eb8848af37d146d777ba4, type: 3} + scriptVersion: 2 + compiledVersion: 2 + behaviourSyncMode: 1 + hasInteractEvent: 0 + scriptID: 6231842042114027118 + serializationData: + SerializedFormat: 2 + SerializedBytes: + ReferencedUnityObjects: [] + SerializedBytesString: + Prefab: {fileID: 0} + PrefabModificationsReferencedUnityObjects: [] + PrefabModifications: [] + SerializationNodes: + - Name: fieldDefinitions + Entry: 7 + Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UdonSharp.Compiler.FieldDefinition, + UdonSharp.Editor]], mscorlib + - Name: comparer + Entry: 7 + Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String, + mscorlib]], mscorlib + - Name: + Entry: 8 + Data: + - Name: + Entry: 12 + Data: 38 + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: DEBUG_ReverseUnityLightmapST + - Name: $v + Entry: 7 + Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: DEBUG_ReverseUnityLightmapST + - Name: <UserType>k__BackingField + Entry: 7 + Data: 3|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: System.Boolean, mscorlib + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 3 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 4|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _Renderers + - Name: $v + Entry: 7 + Data: 5|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _Renderers + - Name: <UserType>k__BackingField + Entry: 7 + Data: 6|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.Renderer[], UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 6 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 7|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 1 + - Name: + Entry: 7 + Data: 8|UnityEngine.HeaderAttribute, UnityEngine.CoreModule + - Name: header + Entry: 1 + Data: Internal Data (auto-generated, do not edit!) + - Name: + Entry: 8 + Data: + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_DefaultLightmap + - Name: $v + Entry: 7 + Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_DefaultLightmap + - Name: <UserType>k__BackingField + Entry: 7 + Data: 10|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.Texture2D, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 10 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 11|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_Lightmaps + - Name: $v + Entry: 7 + Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_Lightmaps + - Name: <UserType>k__BackingField + Entry: 7 + Data: 13|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.Texture2D[], UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 13 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 14|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_LightmapST + - Name: $v + Entry: 7 + Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_LightmapST + - Name: <UserType>k__BackingField + Entry: 7 + Data: 16|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.Vector4[], UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 17|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_Mask + - Name: $v + Entry: 7 + Data: 18|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_Mask + - Name: <UserType>k__BackingField + Entry: 7 + Data: 19|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: System.Single[], mscorlib + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 19 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 20|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_MaskAvatars + - Name: $v + Entry: 7 + Data: 21|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_MaskAvatars + - Name: <UserType>k__BackingField + Entry: 9 + Data: 19 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 19 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 22|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_LightmapMult + - Name: $v + Entry: 7 + Data: 23|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_LightmapMult + - Name: <UserType>k__BackingField + Entry: 7 + Data: 24|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.Vector4, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 24 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 25|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _Screens + - Name: $v + Entry: 7 + Data: 26|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _Screens + - Name: <UserType>k__BackingField + Entry: 7 + Data: 27|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.GameObject[], UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 27 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 28|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_lut1 + - Name: $v + Entry: 7 + Data: 29|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_lut1 + - Name: <UserType>k__BackingField + Entry: 9 + Data: 10 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 10 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 30|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_lut2 + - Name: $v + Entry: 7 + Data: 31|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_lut2 + - Name: <UserType>k__BackingField + Entry: 9 + Data: 10 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 10 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 32|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_LODs + - Name: $v + Entry: 7 + Data: 33|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_LODs + - Name: <UserType>k__BackingField + Entry: 7 + Data: 34|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.Texture[], UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 34 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 35|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_Static_LODs_0 + - Name: $v + Entry: 7 + Data: 36|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_Static_LODs_0 + - Name: <UserType>k__BackingField + Entry: 7 + Data: 37|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.Texture2DArray, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 37 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 38|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_Static_LODs_1 + - Name: $v + Entry: 7 + Data: 39|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_Static_LODs_1 + - Name: <UserType>k__BackingField + Entry: 9 + Data: 37 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 37 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 40|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_Static_LODs_2 + - Name: $v + Entry: 7 + Data: 41|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_Static_LODs_2 + - Name: <UserType>k__BackingField + Entry: 9 + Data: 37 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 37 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 42|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_Static_LODs_3 + - Name: $v + Entry: 7 + Data: 43|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_Static_LODs_3 + - Name: <UserType>k__BackingField + Entry: 9 + Data: 37 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 37 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 44|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_Vertices_0 + - Name: $v + Entry: 7 + Data: 45|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_Vertices_0 + - Name: <UserType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 46|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_Vertices_1 + - Name: $v + Entry: 7 + Data: 47|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_Vertices_1 + - Name: <UserType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 48|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_Vertices_2 + - Name: $v + Entry: 7 + Data: 49|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_Vertices_2 + - Name: <UserType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 50|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_Vertices_3 + - Name: $v + Entry: 7 + Data: 51|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_Vertices_3 + - Name: <UserType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 52|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_Vertices_0t + - Name: $v + Entry: 7 + Data: 53|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_Vertices_0t + - Name: <UserType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 54|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_Vertices_1t + - Name: $v + Entry: 7 + Data: 55|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_Vertices_1t + - Name: <UserType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 56|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_Vertices_2t + - Name: $v + Entry: 7 + Data: 57|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_Vertices_2t + - Name: <UserType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 58|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_Vertices_3t + - Name: $v + Entry: 7 + Data: 59|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_Vertices_3t + - Name: <UserType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 60|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_ExtraData + - Name: $v + Entry: 7 + Data: 61|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_ExtraData + - Name: <UserType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 16 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 62|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_static_uniforms + - Name: $v + Entry: 7 + Data: 63|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_static_uniforms + - Name: <UserType>k__BackingField + Entry: 9 + Data: 10 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 10 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 64|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_ScreenTransforms + - Name: $v + Entry: 7 + Data: 65|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_ScreenTransforms + - Name: <UserType>k__BackingField + Entry: 7 + Data: 66|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.Transform[], UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 66 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 67|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_ScreenCount + - Name: $v + Entry: 7 + Data: 68|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_ScreenCount + - Name: <UserType>k__BackingField + Entry: 7 + Data: 69|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: System.Int32, mscorlib + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 69 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 70|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_ScreenCountMaskedAvatars + - Name: $v + Entry: 7 + Data: 71|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_ScreenCountMaskedAvatars + - Name: <UserType>k__BackingField + Entry: 9 + Data: 69 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 69 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 72|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_ScreenCountMasked + - Name: $v + Entry: 7 + Data: 73|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_ScreenCountMasked + - Name: <UserType>k__BackingField + Entry: 7 + Data: 74|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: System.Int32[], mscorlib + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 74 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 75|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _LTCGI_ScreenCountDynamic + - Name: $v + Entry: 7 + Data: 76|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _LTCGI_ScreenCountDynamic + - Name: <UserType>k__BackingField + Entry: 9 + Data: 69 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 69 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 77|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: BlurCRTInput + - Name: $v + Entry: 7 + Data: 78|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: BlurCRTInput + - Name: <UserType>k__BackingField + Entry: 7 + Data: 79|System.RuntimeType, mscorlib + - Name: + Entry: 1 + Data: UnityEngine.CustomRenderTexture, UnityEngine.CoreModule + - Name: + Entry: 8 + Data: + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 79 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: true + - Name: _fieldAttributes + Entry: 7 + Data: 80|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: prop_Udon_LTCGI_ExtraData + - Name: $v + Entry: 7 + Data: 81|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: prop_Udon_LTCGI_ExtraData + - Name: <UserType>k__BackingField + Entry: 9 + Data: 69 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 69 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 82|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: prop_Udon_LTCGI_Vertices_0 + - Name: $v + Entry: 7 + Data: 83|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: prop_Udon_LTCGI_Vertices_0 + - Name: <UserType>k__BackingField + Entry: 9 + Data: 69 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 69 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 84|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: prop_Udon_LTCGI_Vertices_1 + - Name: $v + Entry: 7 + Data: 85|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: prop_Udon_LTCGI_Vertices_1 + - Name: <UserType>k__BackingField + Entry: 9 + Data: 69 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 69 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 86|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: prop_Udon_LTCGI_Vertices_2 + - Name: $v + Entry: 7 + Data: 87|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: prop_Udon_LTCGI_Vertices_2 + - Name: <UserType>k__BackingField + Entry: 9 + Data: 69 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 69 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 88|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: prop_Udon_LTCGI_Vertices_3 + - Name: $v + Entry: 7 + Data: 89|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: prop_Udon_LTCGI_Vertices_3 + - Name: <UserType>k__BackingField + Entry: 9 + Data: 69 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 69 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 90|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: _globalState + - Name: $v + Entry: 7 + Data: 91|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: <Name>k__BackingField + Entry: 1 + Data: _globalState + - Name: <UserType>k__BackingField + Entry: 9 + Data: 3 + - Name: <SystemType>k__BackingField + Entry: 9 + Data: 3 + - Name: <SyncMode>k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: <IsSerialized>k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 92|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: diff --git a/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_UdonAdapter.cs b/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_UdonAdapter.cs new file mode 100644 index 0000000..857707e --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Runtime/LTCGI_UdonAdapter.cs @@ -0,0 +1,445 @@ +using System; +using UnityEngine; + +#if UDONSHARP +using UdonSharp; +using VRC.SDKBase; +using VRC.Udon; +#endif + +#if COMPILER_UDONSHARP +using GlobalShader = VRC.SDKBase.VRCShader; +#else +using GlobalShader = UnityEngine.Shader; +#endif + +#if UDONSHARP +[UdonBehaviourSyncMode(BehaviourSyncMode.None)] +public class LTCGI_UdonAdapter : UdonSharpBehaviour +#else +// FIXME: This makes the filename mismatch the class name +// - I think Unity doesn't like that? +public class LTCGI_RuntimeAdapter : MonoBehaviour +#endif + +{ + // perhaps fixes some lightmap issues with static batching? + public bool DEBUG_ReverseUnityLightmapST = false; + + [Header("Internal Data (auto-generated, do not edit!)")] + public Renderer[] _Renderers; + public Texture2D _LTCGI_DefaultLightmap; + public Texture2D[] _LTCGI_Lightmaps; + public Vector4[] _LTCGI_LightmapST; + public float[] _LTCGI_Mask; + public float[] _LTCGI_MaskAvatars; + public Vector4 _LTCGI_LightmapMult; + public GameObject[] _Screens; + public Texture2D _LTCGI_lut1, _LTCGI_lut2; + public Texture[] _LTCGI_LODs; + public Texture2DArray _LTCGI_Static_LODs_0; + public Texture2DArray _LTCGI_Static_LODs_1; + public Texture2DArray _LTCGI_Static_LODs_2; + public Texture2DArray _LTCGI_Static_LODs_3; + public Vector4[] _LTCGI_Vertices_0, _LTCGI_Vertices_1, _LTCGI_Vertices_2, _LTCGI_Vertices_3; + private Vector4[] _LTCGI_Vertices_0t, _LTCGI_Vertices_1t, _LTCGI_Vertices_2t, _LTCGI_Vertices_3t; + public Vector4[] _LTCGI_ExtraData; + public Texture2D _LTCGI_static_uniforms; + public Transform[] _LTCGI_ScreenTransforms; + public int _LTCGI_ScreenCount; + public int _LTCGI_ScreenCountMaskedAvatars; + public int[] _LTCGI_ScreenCountMasked; + public int _LTCGI_ScreenCountDynamic; + public CustomRenderTexture BlurCRTInput; + + private int prop_Udon_LTCGI_ExtraData; + private int prop_Udon_LTCGI_Vertices_0; + private int prop_Udon_LTCGI_Vertices_1; + private int prop_Udon_LTCGI_Vertices_2; + private int prop_Udon_LTCGI_Vertices_3; + + void Start() + { + Debug.Log("LTCGI adapter start"); + + if (DEBUG_ReverseUnityLightmapST) + { + Debug.LogWarning("WARNING: LTCGI DEBUG_ReverseUnityLightmapST is active! This is probably not what you want!"); + } + + if (_LTCGI_ScreenCount == 0) + { + Debug.LogError("LTCGI Adapter: No screens found! Try deleting the LTCGI_UdonAdapter component from the controller object and clicking 'Force Update' on the controller if this is unexpected."); + this.enabled = false; + return; + } + + var stopwatch = new System.Diagnostics.Stopwatch(); + stopwatch.Start(); + _Initialize(); + stopwatch.Stop(); + + var udon = false; +#if UDONSHARP + udon = true; +#endif + Debug.Log($"LTCGI adapter started for {_LTCGI_ScreenCount} ({_LTCGI_ScreenCountDynamic} dynamic) screens (max: {_LTCGI_Vertices_0t.Length}), {_Renderers.Length} renderers, GlobalShader mode, udon: {udon}, took: {stopwatch.ElapsedMilliseconds}ms"); + + if (_LTCGI_ScreenCountDynamic == 0 || _Renderers.Length == 0) + { + Debug.Log("LTCGI adapter going to sleep 😴"); + this.enabled = false; + } + } + + public void _Initialize() + { + // must be full length (16) otherwise Unity will allocate too little GPU memory and this may break between worlds that use different amounts of screens + // pretty cursed, but w/e, keep in mind that this means vrc worlds that adjust the max cap above 16 will most likely not work in-game + var maxScreens = _LTCGI_Vertices_0.Length; + _LTCGI_Vertices_0t = new Vector4[maxScreens]; + _LTCGI_Vertices_1t = new Vector4[maxScreens]; + _LTCGI_Vertices_2t = new Vector4[maxScreens]; + _LTCGI_Vertices_3t = new Vector4[maxScreens]; + + for (int i = 0; i < _LTCGI_ScreenCount; i++) + { + var transform = _LTCGI_ScreenTransforms[i]; + _LTCGI_Vertices_0t[i] = CalcTransform(_LTCGI_Vertices_0[i], transform); + _LTCGI_Vertices_1t[i] = CalcTransform(_LTCGI_Vertices_1[i], transform); + _LTCGI_Vertices_2t[i] = CalcTransform(_LTCGI_Vertices_2[i], transform); + _LTCGI_Vertices_3t[i] = CalcTransform(_LTCGI_Vertices_3[i], transform); + } + + // Set global material properties (anything not overridden below is for avatar support) + for (int j = 0; j < _LTCGI_LODs.Length; j++) + if (_LTCGI_LODs[j] != null) + GlobalShader.SetGlobalTexture(GlobalShader.PropertyToID("_Udon_LTCGI_Texture_LOD" + j), _LTCGI_LODs[j]); + + if (_LTCGI_Static_LODs_0 != null) + { + GlobalShader.SetGlobalTexture(GlobalShader.PropertyToID("_Udon_LTCGI_Texture_LOD0_arr"), _LTCGI_Static_LODs_0); + GlobalShader.SetGlobalTexture(GlobalShader.PropertyToID("_Udon_LTCGI_Texture_LOD1_arr"), _LTCGI_Static_LODs_1); + GlobalShader.SetGlobalTexture(GlobalShader.PropertyToID("_Udon_LTCGI_Texture_LOD2_arr"), _LTCGI_Static_LODs_2); + GlobalShader.SetGlobalTexture(GlobalShader.PropertyToID("_Udon_LTCGI_Texture_LOD3_arr"), _LTCGI_Static_LODs_3); + } + + GlobalShader.SetGlobalTexture(GlobalShader.PropertyToID("_Udon_LTCGI_lut1"), _LTCGI_lut1); + GlobalShader.SetGlobalTexture(GlobalShader.PropertyToID("_Udon_LTCGI_lut2"), _LTCGI_lut2); + + GlobalShader.SetGlobalFloatArray(GlobalShader.PropertyToID("_Udon_LTCGI_Mask"), _LTCGI_MaskAvatars); + #if COMPILER_UDONSHARP + GlobalShader.SetGlobalInteger(GlobalShader.PropertyToID("_Udon_LTCGI_ScreenCount"), _LTCGI_ScreenCountMaskedAvatars); + #else + GlobalShader.SetGlobalInt(GlobalShader.PropertyToID("_Udon_LTCGI_ScreenCount"), _LTCGI_ScreenCountMaskedAvatars); + #endif + + _SetGlobalState(true); + + if (_LTCGI_static_uniforms != null) + GlobalShader.SetGlobalTexture(GlobalShader.PropertyToID("_Udon_LTCGI_static_uniforms"), _LTCGI_static_uniforms); + if (_LTCGI_DefaultLightmap != null) + GlobalShader.SetGlobalTexture(GlobalShader.PropertyToID("_Udon_LTCGI_Lightmap"), _LTCGI_DefaultLightmap); + + // Set per world-renderer overrides + var maskSubset = new float[_LTCGI_ScreenCount]; + for (int i = 0; i < _Renderers.Length; i++) + { + var r = _Renderers[i]; + var block = new MaterialPropertyBlock(); + if (r.HasPropertyBlock()) + r.GetPropertyBlock(block); + + Array.Copy(_LTCGI_Mask, i * _LTCGI_ScreenCount, maskSubset, 0, _LTCGI_ScreenCount); + block.SetFloatArray("_Udon_LTCGI_Mask", maskSubset); + block.SetInt("_Udon_LTCGI_ScreenCount", _LTCGI_ScreenCountMasked[i]); + + if (_LTCGI_Lightmaps[i] != null) + block.SetTexture("_Udon_LTCGI_Lightmap", _LTCGI_Lightmaps[i]); + block.SetVector("_Udon_LTCGI_LightmapMult", _LTCGI_LightmapMult); + var lmst = _LTCGI_LightmapST[i]; + if (DEBUG_ReverseUnityLightmapST) + { + // workaround? + lmst.x /= r.lightmapScaleOffset.x; + lmst.y /= r.lightmapScaleOffset.y; + lmst.z -= r.lightmapScaleOffset.z; + lmst.w -= r.lightmapScaleOffset.w; + } + block.SetVector("_Udon_LTCGI_LightmapST", lmst); + + r.SetPropertyBlock(block); + } + + prop_Udon_LTCGI_ExtraData = GlobalShader.PropertyToID("_Udon_LTCGI_ExtraData"); + prop_Udon_LTCGI_Vertices_0 = GlobalShader.PropertyToID("_Udon_LTCGI_Vertices_0"); + prop_Udon_LTCGI_Vertices_1 = GlobalShader.PropertyToID("_Udon_LTCGI_Vertices_1"); + prop_Udon_LTCGI_Vertices_2 = GlobalShader.PropertyToID("_Udon_LTCGI_Vertices_2"); + prop_Udon_LTCGI_Vertices_3 = GlobalShader.PropertyToID("_Udon_LTCGI_Vertices_3"); + + GlobalShader.SetGlobalVectorArray(prop_Udon_LTCGI_ExtraData, _LTCGI_ExtraData); + GlobalShader.SetGlobalVectorArray(prop_Udon_LTCGI_Vertices_0, _LTCGI_Vertices_0t); + GlobalShader.SetGlobalVectorArray(prop_Udon_LTCGI_Vertices_1, _LTCGI_Vertices_1t); + GlobalShader.SetGlobalVectorArray(prop_Udon_LTCGI_Vertices_2, _LTCGI_Vertices_2t); + GlobalShader.SetGlobalVectorArray(prop_Udon_LTCGI_Vertices_3, _LTCGI_Vertices_3t); + } + + private Vector4 CalcTransform(Vector4 i, Transform t) + { + var ret = (Vector4)t.TransformPoint((Vector3)i); + ret.w = i.w; // keep UV the same + return ret; + } + + void Update() + { + // update vertex data + for (int i = 0; i < _LTCGI_ScreenCountDynamic /* only run for dynamic screens */; i++) + { + var transform = _LTCGI_ScreenTransforms[i]; + _LTCGI_Vertices_0t[i] = CalcTransform(_LTCGI_Vertices_0[i], transform); + _LTCGI_Vertices_1t[i] = CalcTransform(_LTCGI_Vertices_1[i], transform); + _LTCGI_Vertices_2t[i] = CalcTransform(_LTCGI_Vertices_2[i], transform); + _LTCGI_Vertices_3t[i] = CalcTransform(_LTCGI_Vertices_3[i], transform); + } + + GlobalShader.SetGlobalVectorArray(prop_Udon_LTCGI_ExtraData, _LTCGI_ExtraData); + GlobalShader.SetGlobalVectorArray(prop_Udon_LTCGI_Vertices_0, _LTCGI_Vertices_0t); + GlobalShader.SetGlobalVectorArray(prop_Udon_LTCGI_Vertices_1, _LTCGI_Vertices_1t); + GlobalShader.SetGlobalVectorArray(prop_Udon_LTCGI_Vertices_2, _LTCGI_Vertices_2t); + GlobalShader.SetGlobalVectorArray(prop_Udon_LTCGI_Vertices_3, _LTCGI_Vertices_3t); + } + + // See the docs for more info: + // https://github.com/PiMaker/ltcgi/wiki#udonsharp-api + + public int _GetIndex(GameObject screen) + { + var idx = Array.IndexOf(_Screens, screen); + if (idx != -1) + { + // if (idx >= _LTCGI_ScreenCountDynamic) + // { + // Debug.LogError("LTCGI: Cannot index non-dynamic object " + screen.name); + // return -1; + // } + + return idx; + } + else + { + Debug.LogError("LTCGI: Cannot index unregistered object " + (screen == null ? "<null>" : screen.name)); + return -1; + } + } + + public Color _GetColor(int screen) + { + if (screen < 0) return Color.black; + var data = _LTCGI_ExtraData[screen]; + return new Color(data.x, data.y, data.z); + } + + public void _SetColor(int screen, Color color) + { + if (screen < 0) return; + _LTCGI_ExtraData[screen].x = color.r; + _LTCGI_ExtraData[screen].y = color.g; + _LTCGI_ExtraData[screen].z = color.b; + + if (!this.enabled) Update(); + } + + public void _SetVideoTexture(Texture texture) + { + BlurCRTInput.material.SetTexture("_MainTex", texture); + GlobalShader.SetGlobalTexture(GlobalShader.PropertyToID("_Udon_LTCGI_Texture_LOD0"), texture); + } + + private uint getFlags(int screen) + { + var raw = _LTCGI_ExtraData[screen].w; + var buffer = new byte[4]; + WriteSingle(raw, buffer, 0); + return ReadUInt32(buffer, 0); + } + + private void setFlags(int screen, uint flags) + { + var buffer = new byte[4]; + WriteUInt32(flags, buffer, 0); + var raw = ReadSingle(buffer, 0); + _LTCGI_ExtraData[screen].w = raw; + } + + public void _SetTexture(int screen, uint index) + { + if (screen < 0) return; + var flags = getFlags(screen); + flags &= ~(0xfU << 4); + flags |= (index & 0xf) << 4; + setFlags(screen, flags); + + if (!this.enabled) Update(); + } + + private bool _globalState = false; + public void _SetGlobalState(bool enabled) + { + float fstate = enabled ? 1.0f : 0.0f; + GlobalShader.SetGlobalFloat(GlobalShader.PropertyToID("_Udon_LTCGI_GlobalEnable"), fstate); + _globalState = enabled; + } + public bool _GetGlobalState() => _globalState; + + // Below code from: https://github.com/Xytabich/UNet + + private const int BIT8 = 8; + private const int BIT16 = 16; + private const int BIT24 = 24; + private const int BIT32 = 32; + private const int BIT40 = 40; + private const int BIT48 = 48; + private const int BIT56 = 56; + + private const uint FLOAT_SIGN_BIT = 0x80000000; + private const uint FLOAT_EXP_MASK = 0x7F800000; + private const uint FLOAT_FRAC_MASK = 0x007FFFFF; + + /// <summary> + /// Writes unsigned 32-bit integer (<see cref="uint"/>) + /// </summary> + /// <remarks>Takes 4 bytes</remarks> + /// <param name="buffer">Target buffer</param> + /// <param name="index">Index in the buffer at which to start writing data</param> + /// <returns>Size in bytes</returns> + public int WriteUInt32(uint value, byte[] buffer, int index) + { + buffer[index] = (byte)((value >> BIT24) & 255u); + index++; + buffer[index] = (byte)((value >> BIT16) & 255u); + index++; + buffer[index] = (byte)((value >> BIT8) & 255u); + index++; + buffer[index] = (byte)(value & 255u); + return 4; + } + + /// <summary> + /// Reads unsigned 32-bit integer (<see cref="uint"/>) + /// </summary> + /// <remarks>Takes 4 bytes</remarks> + /// <param name="buffer">Target buffer</param> + /// <param name="index">Index in the buffer where to start reading data</param> + public uint ReadUInt32(byte[] buffer, int index) + { + uint value = 0; + value |= (uint)buffer[index] << BIT24; + index++; + value |= (uint)buffer[index] << BIT16; + index++; + value |= (uint)buffer[index] << BIT8; + index++; + value |= (uint)buffer[index]; + return value; + } + + /// <summary> + /// Writes single-precision floating-point number + /// </summary> + /// <remarks>Takes 4 bytes</remarks> + /// <param name="buffer">Target buffer</param> + /// <param name="index">Index in the buffer at which to start writing data</param> + /// <returns>Size in bytes</returns> + public int WriteSingle(float value, byte[] buffer, int index) + { + uint tmp = 0; + if(float.IsNaN(value)) + { + tmp = FLOAT_EXP_MASK | FLOAT_FRAC_MASK; + } + else if(float.IsInfinity(value)) + { + tmp = FLOAT_EXP_MASK; + if(float.IsNegativeInfinity(value)) tmp |= FLOAT_SIGN_BIT; + } + else if(value != 0f) + { + if(value < 0f) + { + value = -value; + tmp |= FLOAT_SIGN_BIT; + } + + int exp = 0; + bool normal = true; + while(value >= 2f) + { + value *= 0.5f; + exp++; + } + while(value < 1f) + { + if(exp == -126) + { + normal = false; + break; + } + value *= 2f; + exp--; + } + + if(normal) + { + value -= 1f; + exp += 127; + } + else exp = 0; + + tmp |= Convert.ToUInt32(exp << 23) & FLOAT_EXP_MASK; + tmp |= Convert.ToUInt32(value * (2 << 22)) & FLOAT_FRAC_MASK; + } + return WriteUInt32(tmp, buffer, index); + } + + /// <summary> + /// Reads single-precision floating-point number + /// </summary> + /// <remarks>Takes 4 bytes</remarks> + /// <param name="buffer">Target buffer</param> + /// <param name="index">Index in the buffer where to start reading data</param> + public float ReadSingle(byte[] buffer, int index) + { + uint value = ReadUInt32(buffer, index); + if(value == 0 || value == FLOAT_SIGN_BIT) return 0f; + + int exp = (int)((value & FLOAT_EXP_MASK) >> 23); + int frac = (int)(value & FLOAT_FRAC_MASK); + bool negate = (value & FLOAT_SIGN_BIT) == FLOAT_SIGN_BIT; + if(exp == 0xFF) + { + if(frac == 0) + { + return negate ? float.NegativeInfinity : float.PositiveInfinity; + } + return float.NaN; + } + + bool normal = exp != 0x00; + if(normal) exp -= 127; + else exp = -126; + + float result = frac / (float)(2 << 22); + if(normal) result += 1f; + + result *= Mathf.Pow(2, exp); + if(negate) result = -result; + return result; + } + + // extremely cursed compat stuff + #if !UDONSHARP + public void UpdateProxy() {} + public void ApplyProxyModifications() {} + #endif +}
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/.LTCGI.cginc.swp b/Third_Party/at.pimaker.ltcgi/Shaders/.LTCGI.cginc.swp Binary files differnew file mode 100644 index 0000000..d7a8805 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Shaders/.LTCGI.cginc.swp diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/Amplify/AmplifyTest.mat b/Third_Party/at.pimaker.ltcgi/Shaders/Amplify/AmplifyTest.mat new file mode 100644 index 0000000..6ba2676 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Shaders/Amplify/AmplifyTest.mat @@ -0,0 +1,87 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: AmplifyTest + m_Shader: {fileID: 4800000, guid: dbf90271d2d7a4946a1e653600c88ca3, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 0 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 2800000, guid: 5f34f31b510450b4b86b7554ea158d12, type: 3} + m_Scale: {x: 0.2, y: 0.2} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: 4ac0d09ca8633a642b5c5b4cc91e02d0, type: 3} + m_Scale: {x: 0.2, y: 0.2} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _texcoord: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _texcoord2: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _Smoothness: 0.925 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + - __dirty: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/Amplify/LTCGI_Amplify.shader b/Third_Party/at.pimaker.ltcgi/Shaders/Amplify/LTCGI_Amplify.shader new file mode 100644 index 0000000..08e2152 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Shaders/Amplify/LTCGI_Amplify.shader @@ -0,0 +1,223 @@ +// Made with Amplify Shader Editor +// Available at the Unity Asset Store - http://u3d.as/y3X +Shader "LTCGI_Amplify" +{ + Properties + { + _MainTex("MainTex", 2D) = "white" {} + [Normal]_BumpMap("BumpMap", 2D) = "bump" {} + _Smoothness("Smoothness", Range( 0 , 1)) = 0.5 + [HideInInspector] _texcoord( "", 2D ) = "white" {} + [HideInInspector] _texcoord2( "", 2D ) = "white" {} + [HideInInspector] __dirty( "", Int ) = 1 + } + + SubShader + { + Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" "LTCGI"="ALWAYS" } + Cull Back + CGINCLUDE + #include "UnityPBSLighting.cginc" + #include "UnityShaderVariables.cginc" + #include "Lighting.cginc" + #pragma target 3.0 + #include "Assets/_pi_/_LTCGI/Shaders/LTCGI.cginc" + #ifdef UNITY_PASS_SHADOWCASTER + #undef INTERNAL_DATA + #undef WorldReflectionVector + #undef WorldNormalVector + #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2; + #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))) + #define WorldNormalVector(data,normal) half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)) + #endif + struct Input + { + float2 uv_texcoord; + float3 worldPos; + float3 worldNormal; + INTERNAL_DATA + float2 uv2_texcoord2; + }; + + struct SurfaceOutputCustomLightingCustom + { + half3 Albedo; + half3 Normal; + half3 Emission; + half Metallic; + half Smoothness; + half Occlusion; + half Alpha; + Input SurfInput; + UnityGIInput GIData; + }; + + uniform sampler2D _MainTex; + uniform float4 _MainTex_ST; + uniform sampler2D _BumpMap; + uniform float4 _BumpMap_ST; + uniform float _Smoothness; + + inline half4 LightingStandardCustomLighting( inout SurfaceOutputCustomLightingCustom s, half3 viewDir, UnityGI gi ) + { + UnityGIInput data = s.GIData; + Input i = s.SurfInput; + half4 c = 0; + float localLTCGI15_g1 = ( 0.0 ); + float3 ase_worldPos = i.worldPos; + float3 worldPos15_g1 = ase_worldPos; + float2 uv_BumpMap = i.uv_texcoord * _BumpMap_ST.xy + _BumpMap_ST.zw; + float3 normalizeResult9_g1 = normalize( (WorldNormalVector( i , UnpackNormal( tex2D( _BumpMap, uv_BumpMap ) ) )) ); + float3 worldNorm15_g1 = normalizeResult9_g1; + float3 normalizeResult12_g1 = normalize( ( _WorldSpaceCameraPos - ase_worldPos ) ); + float3 cameraDir15_g1 = normalizeResult12_g1; + float roughness15_g1 = ( 1.0 - _Smoothness ); + float2 lightmapUV15_g1 = i.uv2_texcoord2; + float3 diffuse15_g1 = float3( 0,0,0 ); + float3 specular15_g1 = float3( 0,0,0 ); + float specularIntensity15_g1 = 0; + { + LTCGI_Contribution(worldPos15_g1, worldNorm15_g1, cameraDir15_g1, roughness15_g1, lightmapUV15_g1, diffuse15_g1, specular15_g1, specularIntensity15_g1); + } + c.rgb = ( ( diffuse15_g1 * 0.05 ) + ( specular15_g1 * 1.0 ) ); + c.a = 1; + return c; + } + + inline void LightingStandardCustomLighting_GI( inout SurfaceOutputCustomLightingCustom s, UnityGIInput data, inout UnityGI gi ) + { + s.GIData = data; + } + + void surf( Input i , inout SurfaceOutputCustomLightingCustom o ) + { + o.SurfInput = i; + o.Normal = float3(0,0,1); + float2 uv_MainTex = i.uv_texcoord * _MainTex_ST.xy + _MainTex_ST.zw; + o.Albedo = tex2D( _MainTex, uv_MainTex ).rgb; + } + + ENDCG + CGPROGRAM + #pragma surface surf StandardCustomLighting keepalpha fullforwardshadows + + ENDCG + Pass + { + Name "ShadowCaster" + Tags{ "LightMode" = "ShadowCaster" } + ZWrite On + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #pragma target 3.0 + #pragma multi_compile_shadowcaster + #pragma multi_compile UNITY_PASS_SHADOWCASTER + #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2 + #include "HLSLSupport.cginc" + #if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN ) + #define CAN_SKIP_VPOS + #endif + #include "UnityCG.cginc" + #include "Lighting.cginc" + #include "UnityPBSLighting.cginc" + struct v2f + { + V2F_SHADOW_CASTER; + float4 customPack1 : TEXCOORD1; + float4 tSpace0 : TEXCOORD2; + float4 tSpace1 : TEXCOORD3; + float4 tSpace2 : TEXCOORD4; + UNITY_VERTEX_INPUT_INSTANCE_ID + UNITY_VERTEX_OUTPUT_STEREO + }; + v2f vert( appdata_full v ) + { + v2f o; + UNITY_SETUP_INSTANCE_ID( v ); + UNITY_INITIALIZE_OUTPUT( v2f, o ); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o ); + UNITY_TRANSFER_INSTANCE_ID( v, o ); + Input customInputData; + float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz; + half3 worldNormal = UnityObjectToWorldNormal( v.normal ); + half3 worldTangent = UnityObjectToWorldDir( v.tangent.xyz ); + half tangentSign = v.tangent.w * unity_WorldTransformParams.w; + half3 worldBinormal = cross( worldNormal, worldTangent ) * tangentSign; + o.tSpace0 = float4( worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x ); + o.tSpace1 = float4( worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y ); + o.tSpace2 = float4( worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z ); + o.customPack1.xy = customInputData.uv_texcoord; + o.customPack1.xy = v.texcoord; + o.customPack1.zw = customInputData.uv2_texcoord2; + o.customPack1.zw = v.texcoord1; + TRANSFER_SHADOW_CASTER_NORMALOFFSET( o ) + return o; + } + half4 frag( v2f IN + #if !defined( CAN_SKIP_VPOS ) + , UNITY_VPOS_TYPE vpos : VPOS + #endif + ) : SV_Target + { + UNITY_SETUP_INSTANCE_ID( IN ); + Input surfIN; + UNITY_INITIALIZE_OUTPUT( Input, surfIN ); + surfIN.uv_texcoord = IN.customPack1.xy; + surfIN.uv2_texcoord2 = IN.customPack1.zw; + float3 worldPos = float3( IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w ); + half3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) ); + surfIN.worldPos = worldPos; + surfIN.worldNormal = float3( IN.tSpace0.z, IN.tSpace1.z, IN.tSpace2.z ); + surfIN.internalSurfaceTtoW0 = IN.tSpace0.xyz; + surfIN.internalSurfaceTtoW1 = IN.tSpace1.xyz; + surfIN.internalSurfaceTtoW2 = IN.tSpace2.xyz; + SurfaceOutputCustomLightingCustom o; + UNITY_INITIALIZE_OUTPUT( SurfaceOutputCustomLightingCustom, o ) + surf( surfIN, o ); + #if defined( CAN_SKIP_VPOS ) + float2 vpos = IN.pos; + #endif + SHADOW_CASTER_FRAGMENT( IN ) + } + ENDCG + } + } + Fallback "Diffuse" + CustomEditor "ASEMaterialInspector" +} +/*ASEBEGIN +Version=18935 +536;73;2067;851;779.8046;162.2598;1;True;True +Node;AmplifyShaderEditor.RangedFloatNode;6;-821.1882,196.0575;Inherit;False;Constant;_Float0;Float 0;3;0;Create;True;0;0;0;False;0;False;1;0;0;0;0;1;FLOAT;0 +Node;AmplifyShaderEditor.RangedFloatNode;2;-934.938,98.16958;Inherit;False;Property;_Smoothness;Smoothness;2;0;Create;True;0;0;0;False;0;False;0.5;0.925;0;1;0;1;FLOAT;0 +Node;AmplifyShaderEditor.SimpleSubtractOpNode;5;-635.8664,186.1211;Inherit;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.TexturePropertyNode;20;-775.5374,331.3456;Inherit;True;Property;_BumpMap;BumpMap;1;1;[Normal];Create;True;0;0;0;False;0;False;None;5f34f31b510450b4b86b7554ea158d12;True;bump;Auto;Texture2D;-1;0;2;SAMPLER2D;0;SAMPLERSTATE;1 +Node;AmplifyShaderEditor.RangedFloatNode;24;-255.1472,222.6049;Inherit;False;Constant;_Float1;Float 1;3;0;Create;True;0;0;0;False;0;False;0.05;0;0;0;0;1;FLOAT;0 +Node;AmplifyShaderEditor.RangedFloatNode;25;-255.1469,448.7357;Inherit;False;Constant;_Float2;Float 2;3;0;Create;True;0;0;0;False;0;False;1;0;0;0;0;1;FLOAT;0 +Node;AmplifyShaderEditor.TexturePropertyNode;15;-478.7493,-90.12699;Inherit;True;Property;_MainTex;MainTex;0;0;Create;True;0;0;0;False;0;False;None;4ac0d09ca8633a642b5c5b4cc91e02d0;False;white;Auto;Texture2D;-1;0;2;SAMPLER2D;0;SAMPLERSTATE;1 +Node;AmplifyShaderEditor.FunctionNode;35;-477.8035,308.7716;Inherit;False;LTCGI_Contribution;-1;;1;d3ea6060590627141a6e856295f0e87c;0;2;18;SAMPLER2D;0;False;21;FLOAT;0;False;3;FLOAT3;16;FLOAT;17;FLOAT3;0 +Node;AmplifyShaderEditor.SimpleMultiplyOpNode;21;-97.38132,256.7875;Inherit;False;2;2;0;FLOAT3;0,0,0;False;1;FLOAT;0;False;1;FLOAT3;0 +Node;AmplifyShaderEditor.SimpleMultiplyOpNode;12;-94.82584,382.3184;Inherit;False;2;2;0;FLOAT3;0,0,0;False;1;FLOAT;0;False;1;FLOAT3;0 +Node;AmplifyShaderEditor.TextureCoordinatesNode;14;-229.4183,-19.4483;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 +Node;AmplifyShaderEditor.SimpleAddOpNode;26;64.32862,318.5789;Inherit;False;2;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT3;0 +Node;AmplifyShaderEditor.SamplerNode;1;4.050852,-87.71029;Inherit;True;Property;_Albedo;Albedo;0;0;Fetch;True;0;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;False;Instance;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 +Node;AmplifyShaderEditor.StandardSurfaceOutputNode;45;387.8991,5.103931;Float;False;True;-1;2;ASEMaterialInspector;0;0;CustomLighting;LTCGI_Amplify;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;False;-1;0;False;-1;False;0;False;-1;0;False;-1;False;0;Opaque;0.5;True;True;0;False;Opaque;;Geometry;All;18;all;True;True;True;True;0;False;-1;False;0;False;-1;255;False;-1;255;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;False;2;15;10;25;False;0.5;True;0;0;False;-1;0;False;-1;0;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;True;Relative;0;;-1;-1;-1;-1;1;LTCGI=ALWAYS;False;0;0;False;-1;-1;0;False;-1;1;Include;Assets/_pi_/_LTCGI/Shaders/LTCGI.cginc;False;;Custom;0;0;False;0.1;False;-1;0;False;-1;False;15;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT3;0,0,0;False;4;FLOAT;0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT;0;False;10;FLOAT;0;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0 +WireConnection;5;0;6;0 +WireConnection;5;1;2;0 +WireConnection;35;18;20;0 +WireConnection;35;21;5;0 +WireConnection;21;0;35;0 +WireConnection;21;1;24;0 +WireConnection;12;0;35;16 +WireConnection;12;1;25;0 +WireConnection;14;2;15;0 +WireConnection;26;0;21;0 +WireConnection;26;1;12;0 +WireConnection;1;0;15;0 +WireConnection;1;1;14;0 +WireConnection;1;7;15;1 +WireConnection;45;0;1;0 +WireConnection;45;13;26;0 +ASEEND*/ +//CHKSM=2F9669BE0F908372CF1438E7300F30E35C6E2269
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/Amplify/LTCGI_Contribution.asset b/Third_Party/at.pimaker.ltcgi/Shaders/Amplify/LTCGI_Contribution.asset new file mode 100644 index 0000000..307676a --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Shaders/Amplify/LTCGI_Contribution.asset @@ -0,0 +1,46 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 78b2425a2284af743826c689403a4924, type: 3} + m_Name: LTCGI_Contribution + m_EditorClassIdentifier: + m_functionInfo: "// Made with Amplify Shader Editor\n// Available at the Unity + Asset Store - http://u3d.as/y3X \n/*ASEBEGIN\nVersion=18935\n536;73;2067;851;3119.343;614.295;1.681782;True;True\nNode;AmplifyShaderEditor.WorldSpaceCameraPos;3;-1572.588,304.9969;Inherit;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3\nNode;AmplifyShaderEditor.FunctionInput;21;-1149.124,1.794816;Inherit;False;Roughness;1;1;False;1;0;FLOAT;0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.FunctionInput;18;-2132.389,-209.6327;Inherit;True;Normal + Map;9;0;True;1;0;SAMPLER2D;0;False;1;SAMPLER2D;0\nNode;AmplifyShaderEditor.TextureCoordinatesNode;19;-1906.188,-105.2091;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4\nNode;AmplifyShaderEditor.SamplerNode;20;-1663.786,-180.0446;Inherit;True;Property;_Albedo;Albedo;0;0;Fetch;True;0;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;True;Instance;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4\nNode;AmplifyShaderEditor.WorldPosInputsNode;11;-1166,-331.4044;Inherit;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3\nNode;AmplifyShaderEditor.CustomExpressionNode;15;-801.2723,-77.17082;Inherit;False;LTCGI_Contribution(worldPos, + worldNorm, cameraDir, roughness, lightmapUV, diffuse, specular, specularIntensity)@$;7;Call;8;False;worldPos;FLOAT3;0,0,0;In;;Float;False;False;worldNorm;FLOAT3;0,0,0;In;;Float;False;False;cameraDir;FLOAT3;0,0,0;In;;Float;False;False;roughness;FLOAT;0;In;;Inherit;False;False;lightmapUV;FLOAT2;0,0;In;;Float;False;False;diffuse;FLOAT3;0,0,0;Out;;Half;False;False;specular;FLOAT3;0,0,0;Out;;Half;False;False;specularIntensity;FLOAT;0;Out;;Inherit;False;LTCGI;False;False;0;;False;9;0;FLOAT;0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT3;0,0,0;False;4;FLOAT;0;False;5;FLOAT2;0,0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;4;FLOAT;0;FLOAT3;7;FLOAT3;8;FLOAT;9\nNode;AmplifyShaderEditor.RangedFloatNode;22;-1407.949,27.19302;Inherit;False;Constant;_DefaultRoughness;Default + Roughness;0;0;Create;True;0;0;0;False;0;False;0.5;0;0;0;0;1;FLOAT;0\nNode;AmplifyShaderEditor.TextureCoordinatesNode;10;-1188.472,117.4048;Inherit;True;1;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4\nNode;AmplifyShaderEditor.NormalizeNode;9;-1135.18,-104.5354;Inherit;False;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.WorldNormalVector;7;-1353.008,-175.4043;Inherit;False;False;1;0;FLOAT3;0,0,1;False;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3\nNode;AmplifyShaderEditor.SimpleSubtractOpNode;6;-1253.479,434.9653;Inherit;False;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.WorldPosInputsNode;4;-1570.679,470.0651;Inherit;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3\nNode;AmplifyShaderEditor.NormalizeNode;12;-1057.422,435.0438;Inherit;False;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.FunctionOutput;16;-382.1458,1.795166;Inherit;False;False;-1;Specular;0;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.FunctionOutput;17;-381.1458,95.79517;Inherit;False;False;-1;Specular + Intensity;1;False;1;0;FLOAT;0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.FunctionOutput;0;-382,-94;Inherit;False;True;-1;Diffuse;2;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nWireConnection;21;0;22;0\nWireConnection;19;2;18;0\nWireConnection;20;0;18;0\nWireConnection;20;1;19;0\nWireConnection;15;1;11;0\nWireConnection;15;2;9;0\nWireConnection;15;3;12;0\nWireConnection;15;4;21;0\nWireConnection;15;5;10;0\nWireConnection;9;0;7;0\nWireConnection;7;0;20;0\nWireConnection;6;0;3;0\nWireConnection;6;1;4;0\nWireConnection;12;0;6;0\nWireConnection;16;0;15;8\nWireConnection;17;0;15;9\nWireConnection;0;0;15;7\nASEEND*/\n//CHKSM=7E6B0A6F8854806C46769C1D40451E18FF4A9344" + m_functionName: + m_description: LTCGI custom contribution function. Make sure to add the custom + Include and Tag directives! + m_additionalIncludes: + m_additionalIncludes: [] + m_outsideIncludes: [] + m_additionalPragmas: + m_additionalPragmas: [] + m_outsidePragmas: [] + m_additionalDirectives: + m_validData: 0 + m_isDirty: 1 + m_moduleName: ' Additional Directives' + m_independentModule: 1 + m_customEdited: 0 + m_additionalDirectives: [] + m_shaderFunctionDirectives: [] + m_nativeDirectives: [] + m_nativeDirectivesIndex: -1 + m_nativeDirectivesFoldout: 0 + m_directivesSaveItems: [] + m_nodeCategory: 3 + m_customNodeCategory: + m_previewPosition: 0 + m_hidden: 0 + m_url: https://github.com/PiMaker/ltcgi/wiki#amplify diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI.cginc b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI.cginc new file mode 100644 index 0000000..ca4cd24 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI.cginc @@ -0,0 +1,408 @@ +#ifndef LTCGI_INCLUDED +#define LTCGI_INCLUDED + +#include "LTCGI_config.cginc" + +#ifdef LTCGI_AVATAR_MODE + #undef LTCGI_STATIC_UNIFORMS + #undef LTCGI_BICUBIC_LIGHTMAP + #define LTCGI_ALWAYS_LTC_DIFFUSE + // for perf and locality don't allow cylinders on avatars for now (it probably would be misdetected anyway) + #undef LTCGI_CYLINDER +#endif + +#ifdef LTCGI_TOGGLEABLE_SPEC_DIFF_OFF + #undef LTCGI_DIFFUSE_OFF + #undef LTCGI_SPECULAR_OFF +#endif + +#if defined(LTCGI_V2_CUSTOM_INPUT) || defined(LTCGI_V2_DIFFUSE_CALLBACK) || defined(LTCGI_V2_SPECULAR_CALLBACK) + #define LTCGI_API_V2 +#endif + +#include "LTCGI_structs.cginc" +#include "LTCGI_uniform.cginc" +#include "LTCGI_functions.cginc" +#include "LTCGI_shadowmap.cginc" + +#ifdef SHADER_TARGET_SURFACE_ANALYSIS +#define const +#endif + +// Main function - this calculates the approximated model for one pixel and one light +void LTCGI_Evaluate(ltcgi_input input, float3 worldNorm, float3 viewDir, float3x3 Minv, float roughness, const bool diffuse, out ltcgi_output output) { + output.input = input; + output.color = input.rawColor; // copy for colormode static + output.intensity = 0; + + // diffuse distance fade + #ifdef LTCGI_DISTANCE_FADE_APPROX + if (diffuse) // static branch, specular does not directly fade with distance + { + if (!input.flags.lmdOnly) { + // very approximate lol + float3 ctr = (input.Lw[0] + input.Lw[1])/2; + float dist = length(ctr); + if (dist > LTCGI_DISTANCE_FADE_APPROX_MULT) + { + return; + } + } + } + #endif + + #define RET1_IF_LMDIFF [branch] if (/*const*/ diffuse && input.flags.diffFromLm) { output.intensity = 1.0f; return; } + + if (input.flags.colormode == LTCGI_COLORMODE_SINGLEUV) { + float2 uv = input.uvStart; + if (uv.x < 0) uv.xy = uv.yx; + // TODO: make more configurable? + #ifdef LTCGI_VISUALIZE_SAMPLE_UV + output.color = float3(uv.xy, 0); + #elif !defined(SHADER_TARGET_SURFACE_ANALYSIS) + // sample video texture directly for accuracy + float3 sampled = _Udon_LTCGI_Texture_LOD0.SampleLevel(LTCGI_SAMPLER, uv.xy, 0).rgb; + output.color *= sampled; + #endif + + RET1_IF_LMDIFF + } + + #ifdef LTCGI_AUDIOLINK + if (input.flags.colormode == LTCGI_COLORMODE_AUDIOLINK) { + float al = AudioLinkData(ALPASS_AUDIOLINK + uint2(0, input.flags.alBand)).r; + output.color *= al; + + RET1_IF_LMDIFF + } + #endif + + // create LTC polygon array + // note the order of source verts (keyword: winding order) + float3 L[5]; + L[0] = mul(Minv, input.Lw[0]); + L[1] = mul(Minv, input.Lw[1]); + L[2] = input.isTri ? L[1] : mul(Minv, input.Lw[3]); + L[3] = mul(Minv, input.Lw[2]); + L[4] = 0; + + // get texture coords (before clipping!) + [branch] + if (input.flags.colormode == LTCGI_COLORMODE_TEXTURE) { + float3 RN; + float2 uv = LTCGI_calculateUV(input.i, input.flags, L, input.isTri, input.uvStart, input.uvEnd, RN); + float planeAreaSquared = dot(RN, RN); + float planeDistxPlaneArea = dot(RN, L[0]); + + float3 sampled; + [branch] + if (diffuse) { // static branch + #ifdef LTCGI_BLENDED_DIFFUSE_SAMPLING + float3 sampled1; + LTCGI_sample(uv, 3, input.flags.texindex, 10, sampled1); + float3 sampled2; + LTCGI_sample(uv, 3, input.flags.texindex, 100, sampled2); + sampled = + sampled1 * 0.75 + + sampled2 * 0.25; + #else + LTCGI_sample(uv, 3, input.flags.texindex, 10, sampled); + #endif + } else { + float d = abs(planeDistxPlaneArea) / planeAreaSquared; + d *= LTCGI_UV_BLUR_DISTANCE; + d = log(d) / log(3.0); + + // a rough material must never show a perfect reflection, + // since our LOD0 texture is not prefiltered (and thus cannot + // depict any blur correctly) - without this there is artifacting + // on the border of LOD0 and LOD1 + d = clamp(d, saturate(roughness * 5.75), 1000); + + LTCGI_trilinear(uv, d, input.flags.texindex, sampled); + } + + // colorize output + output.color *= sampled; + } + + RET1_IF_LMDIFF + #undef RET1_IF_LMDIFF + + int n; + LTCGI_ClipQuadToHorizon(L, n); + + // early out if everything was clipped below horizon + if (n == 0) + return; + + L[0] = normalize(L[0]); + L[1] = normalize(L[1]); + L[2] = normalize(L[2]); + L[3] = normalize(L[3]); + L[4] = normalize(L[4]); + + // integrate (and pray that constant folding works well) + float sum = 0; + [unroll(5)] + for (uint v = 0; v < max(3, (uint)n); v++) { + float3 a = L[v]; + float3 b = L[(v + 1) % 5]; + sum += LTCGI_IntegrateEdge(a, b).z; + } + + // doublesided is accounted for with optimization at the start, so return abs + output.intensity = abs(sum); + return; +} + +// Calculate light contribution for all lights, +// call this from your shader and use the "diffuse" and "specular" outputs +// lmuv is the raw lightmap UV coordinate (e.g. UV1) +void LTCGI_Contribution( +#ifdef LTCGI_API_V2 + inout LTCGI_V2_CUSTOM_INPUT data, +#endif + float3 worldPos, float3 worldNorm, float3 viewDir, float roughness, float2 lmuv +#ifndef LTCGI_API_V2 + , inout half3 diffuse, inout half3 specular, out float totalSpecularIntensity, out float totalDiffuseIntensity +#endif +) { + #ifndef LTCGI_API_V2 + totalSpecularIntensity = 0; + totalDiffuseIntensity = 0; + #endif + if (_Udon_LTCGI_GlobalEnable == 0.0f) { + return; + } + + // sample lookup tables + float theta = LTCGI_acos_fast(dot(worldNorm, viewDir)); + float2 uv = float2(roughness, theta/(0.5*UNITY_PI)); + uv = uv*LUT_SCALE + LUT_BIAS; + + #ifndef UNITY_UV_STARTS_AT_TOP + uv.y = 1 - uv.y; + #endif + + // calculate LTCGI custom lightmap UV and sample + float3 lms = LTCGI_SampleShadowmap(lmuv); + + #ifndef SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER + // sample BDRF approximation from lookup texture + float4 t = _Udon_LTCGI_lut1.SampleLevel(LTCGI_SAMPLER, uv, 0); + #endif + float3x3 Minv = float3x3( + float3( 1, 0, t.w), + float3( 0, t.z, 0), + float3(t.y, 0, t.x) + ); + + // construct orthonormal basis around N + float3 T1, T2; + T1 = normalize(viewDir - worldNorm*dot(viewDir, worldNorm)); + T2 = cross(worldNorm, T1); + + // for diffuse lighting we assume the identity matrix as BDRF, so the + // LTC approximation is directly equivalent to the orthonormal rotation matrix + float3x3 identityBrdf = float3x3(float3(T1), float3(T2), float3(worldNorm)); + // rotate area light in (T1, T2, N) basis for actual BRDF matrix as well + Minv = mul(Minv, identityBrdf); + + // specular brightness + #ifndef LTCGI_SPECULAR_OFF + #ifndef SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER + float spec_amp = _Udon_LTCGI_lut2.SampleLevel(LTCGI_SAMPLER, uv, 0).x; + #endif + #endif + + bool noLm = false; + #ifdef LTCGI_LTC_DIFFUSE_FALLBACK + #ifndef LTCGI_ALWAYS_LTC_DIFFUSE + #ifndef SHADER_TARGET_SURFACE_ANALYSIS + float2 lmSize; + _Udon_LTCGI_Lightmap.GetDimensions(lmSize.x, lmSize.y); + noLm = lmSize.x == 1; + #endif + #endif + #endif + #ifdef LTCGI_ALWAYS_LTC_DIFFUSE + noLm = true; + #endif + + // loop through all lights and add them to the output + uint count = min(_Udon_LTCGI_ScreenCount, MAX_SOURCES); + [loop] + for (uint i = 0; i < count; i++) { + // skip masked and black lights + if (_Udon_LTCGI_Mask[i]) continue; + float4 extra = _Udon_LTCGI_ExtraData[i]; + float3 color = extra.rgb; + if (!any(color)) continue; + + ltcgi_flags flags = ltcgi_parse_flags(asuint(extra.w), noLm); + + #ifdef LTCGI_ALWAYS_LTC_DIFFUSE + // can't honor a lightmap-only light in this mode + if (flags.lmdOnly) continue; + #endif + + #ifdef LTCGI_TOGGLEABLE_SPEC_DIFF_OFF + // compile branches below away statically + flags.diffuse = flags.specular = true; + #endif + + // calculate (shifted) world space positions + float3 Lw[4]; + float4 uvStart = (float4)0, uvEnd = (float4)0; + bool isTri = false; + if (flags.lmdOnly) { + Lw[0] = Lw[1] = Lw[2] = Lw[3] = (float3)0; + } else { + LTCGI_GetLw(i, flags, worldPos, Lw, uvStart, uvEnd, isTri); + } + + // skip single-sided lights that face the other way + float3 screenNorm = cross(Lw[1] - Lw[0], Lw[2] - Lw[0]); + if (!flags.doublesided) { + if (dot(screenNorm, Lw[0]) < 0) + continue; + } + + float lm = 1; + if (flags.lmch) { + lm = lms[flags.lmch - 1]; + if (lm < 0.001) continue; + } + + ltcgi_input input; + input.i = i; + input.Lw = Lw; + input.isTri = isTri; + input.uvStart = uvStart; + input.uvEnd = uvEnd; + input.rawColor = color; + input.flags = flags; + input.screenNormal = screenNorm; + + // diffuse lighting + #ifndef LTCGI_DIFFUSE_OFF + [branch] + if (flags.diffuse) + { + float lmd = lm; + if (flags.lmch) { + if (flags.diffFromLm) + lmd *= _Udon_LTCGI_LightmapMult[flags.lmch - 1]; + else + lmd = smoothstep(0.0, LTCGI_SPECULAR_LIGHTMAP_STEP, saturate(lm - LTCGI_LIGHTMAP_CUTOFF)); + } + ltcgi_output diff; + LTCGI_Evaluate(input, worldNorm, viewDir, identityBrdf, roughness, true, diff); + diff.intensity *= lmd; + + #ifdef LTCGI_API_V2 + LTCGI_V2_DIFFUSE_CALLBACK(data, diff); + #else + // simply accumulate all lights + diffuse += (diff.intensity * diff.color); + totalDiffuseIntensity += diff.intensity; + #endif + } + #endif + + // specular lighting + #ifndef LTCGI_SPECULAR_OFF + [branch] + if (flags.specular) + { + ltcgi_output spec; + LTCGI_Evaluate(input, worldNorm, viewDir, Minv, roughness, false, spec); + spec.intensity *= spec_amp * smoothstep(0.0, LTCGI_SPECULAR_LIGHTMAP_STEP, saturate(lm - LTCGI_LIGHTMAP_CUTOFF)); + + #ifdef LTCGI_API_V2 + LTCGI_V2_SPECULAR_CALLBACK(data, spec); + #else + // simply accumulate all lights + specular += spec.intensity * spec.color; + totalSpecularIntensity += spec.intensity; + #endif + } + #endif + } +} + +// COMPATIBILITY FALLBACKS + +#ifndef LTCGI_API_V2 + +void LTCGI_Contribution( + float3 worldPos, float3 worldNorm, float3 viewDir, float roughness, float2 lmuv, inout half3 diffuse +) { + half3 _u1; + float _u2, _u3; + LTCGI_Contribution(worldPos, worldNorm, viewDir, roughness, lmuv, diffuse, _u1, _u2, _u3); +} + +void LTCGI_Contribution( + float3 worldPos, float3 worldNorm, float3 viewDir, float roughness, float2 lmuv, inout half3 diffuse, inout half3 specular +) { + float _u1, _u2; + LTCGI_Contribution(worldPos, worldNorm, viewDir, roughness, lmuv, diffuse, specular, _u1, _u2); +} + +void LTCGI_Contribution( + float3 worldPos, float3 worldNorm, float3 viewDir, float roughness, float2 lmuv, inout half3 diffuse, inout half3 specular, out float totalSpecularIntensity +) { + float _u1; + LTCGI_Contribution(worldPos, worldNorm, viewDir, roughness, lmuv, diffuse, specular, totalSpecularIntensity, _u1); +} + +#endif + +/* + +Parts of the code in this file are adapted from the example code found here: + + https://github.com/selfshadow/ltc_code + +Modifications by _pi_ (@pimaker on GitHub), licensed under the terms of the +MIT license as far as applicable. + +Original copyright notice: + +Copyright (c) 2017, Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* If you use (or adapt) the source code in your own work, please include a + reference to the paper: + + Real-Time Polygonal-Light Shading with Linearly Transformed Cosines. + Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt. + ACM Transactions on Graphics (Proceedings of ACM SIGGRAPH 2016) 35(4), 2016. + Project page: https://eheitzresearch.wordpress.com/415-2/ + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#endif
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_Simple.shader b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_Simple.shader new file mode 100644 index 0000000..512ca47 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_Simple.shader @@ -0,0 +1,91 @@ +Shader "LTCGI/Simple" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" {} + _Color ("Color", Color) = (1.0, 1.0, 1.0, 1.0) + + _Roughness ("Roughness", Range(0.0, 1.0)) = 0.5 + + //[ToggleUI] _Debug ("Debug Param, does whatever it wants", float) = 0.0 + } + SubShader + { + // "LTCGI" tag defines that any renderer with this material will + // receive data from the LTCGI editor and Udon scripts. + // Can be either "ALWAYS" or the name of a float ("ToggleUI") + // property on which input will depends. + Tags { "RenderType"="Opaque" "LTCGI"="ALWAYS" } + LOD 100 + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #pragma multi_compile_fog + + //#define LTCGI_SPECULAR_OFF + + #include "UnityCG.cginc" + #include "LTCGI.cginc" + + struct v2f + { + float4 uv : TEXCOORD0; + float3 worldPos : TEXCOORD1; + float3 worldNorm : TEXCOORD2; + float4 vertex : SV_POSITION; + }; + + sampler2D _MainTex; + float4 _MainTex_ST; + + float4 _Color; + float _Roughness; + + v2f vert (appdata_full v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.worldPos = mul(unity_ObjectToWorld, float4(v.vertex.xyz, 1.0)).xyz; + o.worldNorm = mul(unity_ObjectToWorld, float4(v.normal.xyz, 0.0)).xyz; + o.uv.xy = TRANSFORM_TEX(v.texcoord, _MainTex); + o.uv.zw = v.texcoord1; + return o; + } + + float3 get_camera_pos() { + float3 worldCam; + worldCam.x = unity_CameraToWorld[0][3]; + worldCam.y = unity_CameraToWorld[1][3]; + worldCam.z = unity_CameraToWorld[2][3]; + return worldCam; + } + static float3 camera_pos = get_camera_pos(); + + half4 frag (v2f i) : SV_Target + { + //return half4(tex2Dlod(_LTCGI_mat, float4(i.uv, 0, 0)).rgb, 1); + + half4 col = tex2D(_MainTex, i.uv) * _Color; + half3 diff = 0; + half3 spec = 0; + + LTCGI_Contribution( + i.worldPos, + normalize(i.worldNorm), + normalize(camera_pos - i.worldPos), + _Roughness, + i.uv.zw, + diff, + spec + ); + col.rgb *= saturate(diff + 0.1); + col.rgb += spec; + return col; + } + ENDCG + } + } +} diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_Surface.shader b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_Surface.shader new file mode 100644 index 0000000..b4ee68e --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_Surface.shader @@ -0,0 +1,87 @@ +Shader "LTCGI/Surface" +{ + Properties + { + _Color ("Color", Color) = (1,1,1,1) + _MainTex ("Albedo (RGB)", 2D) = "white" {} + [HideInInspector] _LightMap ("(for surface ST only)", 2D) = "white" {} + _BumpMap ("Normal Map", 2D) = "bump" {} + _Metallic ("Metallic", Range(0,1)) = 0.0 + _Glossiness ("Smoothness", Range(0,1)) = 0.5 + _GlossinessMap ("Smoothness Map", 2D) = "white" {} + [ToggleUI] _MapIsRoughness ("Invert Smoothness Map", Float) = 0.0 + [ToggleUI] _LTCGI ("LTCGI enabled", Float) = 1.0 + } + SubShader + { + // The LTCGI tag can either be "ALWAYS" or specify a "Toggle"/"ToggleUI" property. + // It is required so that renderers using this material will be updated by the controller. + Tags { "RenderType"="Opaque" "LTCGI"="_LTCGI" } + LOD 200 + + CGPROGRAM + #pragma surface surf Standard fullforwardshadows + #pragma target 3.0 + + #include "LTCGI.cginc" + + sampler2D _MainTex; + sampler2D _BumpMap; + sampler2D _GlossinessMap; + + struct Input + { + float2 uv_MainTex; + float2 uv_BumpMap; + float2 uv2_LightMap; + float3 worldPos; + float3 worldNormal; INTERNAL_DATA + }; + + half _Glossiness; + float _MapIsRoughness; + half _Metallic; + fixed4 _Color; + float _LTCGI; + + float3 get_camera_pos() { + float3 worldCam; + worldCam.x = unity_CameraToWorld[0][3]; + worldCam.y = unity_CameraToWorld[1][3]; + worldCam.z = unity_CameraToWorld[2][3]; + return worldCam; + } + + void surf (Input IN, inout SurfaceOutputStandard o) + { + fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; + o.Albedo = c.rgb; + o.Metallic = _Metallic; + o.Smoothness = tex2D (_GlossinessMap, IN.uv_MainTex); + if (_MapIsRoughness) + o.Smoothness = 1 - o.Smoothness; + o.Smoothness *= _Glossiness; + o.Alpha = c.a; + + o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); + + if (_LTCGI) { + float3 normal = WorldNormalVector(IN, o.Normal); + float3 spec = 0, diff = 0; + LTCGI_Contribution( + IN.worldPos, + normalize(normal), + normalize(get_camera_pos() - IN.worldPos), + 1 - o.Smoothness, + IN.uv2_LightMap, + diff, + spec + ); + o.Emission += spec; + o.Emission += diff * c; + } + } + ENDCG + } + FallBack "Diffuse" +} diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_Surface_v2.shader b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_Surface_v2.shader new file mode 100644 index 0000000..2cba27b --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_Surface_v2.shader @@ -0,0 +1,136 @@ +Shader "LTCGI/Surface (APIv2)" +{ + Properties + { + _Color ("Color", Color) = (1,1,1,1) + _MainTex ("Albedo (RGB)", 2D) = "white" {} + [HideInInspector] _LightMap ("(for surface ST only)", 2D) = "white" {} + _BumpMap ("Normal Map", 2D) = "bump" {} + _Metallic ("Metallic", Range(0,1)) = 0.0 + _Glossiness ("Smoothness", Range(0,1)) = 0.5 + _GlossinessMap ("Smoothness Map", 2D) = "white" {} + [ToggleUI] _MapIsRoughness ("Invert Smoothness Map", Float) = 0.0 + + [ToggleUI] _LTCGI ("LTCGI enabled", Float) = 1.0 + _LTCGI_DiffuseColor ("LTCGI Diffuse Color", Color) = (1,1,1,1) + _LTCGI_SpecularColor ("LTCGI Specular Color", Color) = (1,1,1,1) + } + SubShader + { + // The LTCGI tag can either be "ALWAYS" or specify a "Toggle"/"ToggleUI" property. + // It is required so that renderers using this material will be updated by the controller. + Tags { "RenderType"="Opaque" "LTCGI"="_LTCGI" } + LOD 200 + + CGPROGRAM + #pragma surface surf Standard fullforwardshadows + #pragma target 3.0 + + // This shader demonstrates how to use the APIv2 LTCGI functionality, which has access to per-light callbacks + + // preamble: include this first to get access to required types + #include "Packages/at.pimaker.ltcgi/Shaders/LTCGI_structs.cginc" + + // then define the accumulator type and callback functions (can forward-declare functions to keep things tidy) + // note the function signatures, especially that the accumulator is "inout" so it will keep modifications between calls + struct accumulator_struct { + // let your imagination run wild on what to accumulate here... + float3 diffuse; + float3 specular; + }; + void callback_diffuse(inout accumulator_struct acc, in ltcgi_output output); + void callback_specular(inout accumulator_struct acc, in ltcgi_output output); + + // tell LTCGI that we want the V2 API, and which constructs to use + #define LTCGI_V2_CUSTOM_INPUT accumulator_struct + #define LTCGI_V2_DIFFUSE_CALLBACK callback_diffuse + #define LTCGI_V2_SPECULAR_CALLBACK callback_specular + + // then include this to finish the deal + #include "Packages/at.pimaker.ltcgi/Shaders/LTCGI.cginc" + + // standard shader stuff follows... + sampler2D _MainTex; + sampler2D _BumpMap; + sampler2D _GlossinessMap; + + struct Input + { + float2 uv_MainTex; + float2 uv_BumpMap; + float2 uv2_LightMap; + float3 worldPos; + float3 worldNormal; INTERNAL_DATA + }; + + half _Glossiness; + float _MapIsRoughness; + half _Metallic; + half4 _Color; + float _LTCGI; + half4 _LTCGI_DiffuseColor; + half4 _LTCGI_SpecularColor; + + float3 get_camera_pos() { + float3 worldCam; + worldCam.x = unity_CameraToWorld[0][3]; + worldCam.y = unity_CameraToWorld[1][3]; + worldCam.z = unity_CameraToWorld[2][3]; + return worldCam; + } + + // now we declare LTCGI APIv2 functions for real + void callback_diffuse(inout accumulator_struct acc, in ltcgi_output output) { + // you can do whatever here! check out the ltcgi_output struct in + // "LTCGI_structs.cginc" to see what data you have available + acc.diffuse += output.intensity * output.color * _LTCGI_DiffuseColor; + } + void callback_specular(inout accumulator_struct acc, in ltcgi_output output) { + // same here, this example one is pretty boring though. + // you could accumulate intensity separately for example, + // to emulate total{Specular,Diffuse}Intensity from APIv1 + acc.specular += output.intensity * output.color * _LTCGI_SpecularColor; + } + + void surf (Input IN, inout SurfaceOutputStandard o) + { + // standard surface shader stuff again... + fixed4 mainColor = tex2D (_MainTex, IN.uv_MainTex) * _Color; + o.Albedo = mainColor.rgb; + o.Metallic = _Metallic; + o.Smoothness = tex2D (_GlossinessMap, IN.uv_MainTex); + if (_MapIsRoughness) + o.Smoothness = 1.0f - o.Smoothness; + o.Smoothness *= _Glossiness; + o.Alpha = mainColor.a; + + o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); + float3 worldSpaceNormal = normalize(WorldNormalVector(IN, o.Normal)); + + if (_LTCGI) { + // and lastly, here's how we call the APIv2 version of LTCGI: + + // first, we create the struct that'll be passed through + accumulator_struct acc = (accumulator_struct)0; + + // then we make the LTCGI_Contribution call as usual, but with slightly different params + LTCGI_Contribution( + acc, // our accumulator + IN.worldPos, // world position of the shaded point + worldSpaceNormal, // world space normal + normalize(get_camera_pos() - IN.worldPos), // view vector to shaded point, normalized + 1.0f - o.Smoothness, // roughness + IN.uv2_LightMap // shadowmap coordinates (the normal Unity ones, they should be in sync with LTCGI maps) + ); + + // after the call, our accumulator struct will have been modified by our callbacks + // we can now use it to set the output color + o.Emission += acc.specular; + o.Emission += acc.diffuse * mainColor.rgb; + } + } + ENDCG + } + + FallBack "Diffuse" +}
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_config.cginc b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_config.cginc new file mode 100644 index 0000000..561fe93 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_config.cginc @@ -0,0 +1,87 @@ +#ifndef LTCGI_CONFIG_INCLUDED +#define LTCGI_CONFIG_INCLUDED + +// Feel free to enable or disable (//) the options here. +// They will apply to all LTCGI materials in the project. +// Most of these can be changed in the LTCGI_Controller editor as well. + +/// No specular at all. +//#define LTCGI_SPECULAR_OFF +/// No diffuse at all. +//#define LTCGI_DIFFUSE_OFF +/// Disable the ability to toggle specular/diffuse on or off per screen. +//#define LTCGI_TOGGLEABLE_SPEC_DIFF_OFF + +/// Only use LTC diffuse mode, never lightmapped diffuse. +/// This disables lightmaps entirely. +//#define LTCGI_ALWAYS_LTC_DIFFUSE + +/// Double-sample screen texture for diffuse lighting to smooth resulting lighting +/// a bit more with global screen color data. Slight performance cost. +//#define LTCGI_BLENDED_DIFFUSE_SAMPLING + +/// Slightly simplified and thus faster sampling for reflections at the cost of quality. +/// Consider using this if your scene looks about the same with this enabled. +//#define LTCGI_FAST_SAMPLING + +/// Use bicubic filtering for LTCGI lightmap. Recommended on. +#define LTCGI_BICUBIC_LIGHTMAP + +/// Lightmap values below this will be treated as black for specular/LTC diffuse. +#define LTCGI_LIGHTMAP_CUTOFF 0.1 +/// Lightmap values above this (plus cutoff) will be treated as white. +#define LTCGI_SPECULAR_LIGHTMAP_STEP 0.3 + +/// Distance multiplier for calculating blur amount. +/// Increase to make reflections blurrier faster as distance increases. +#define LTCGI_UV_BLUR_DISTANCE 333 + +/// Fall back to LTC diffuse (from LM diffuse) on objects that are not marked static. +#define LTCGI_LTC_DIFFUSE_FALLBACK + +/// Approximation to ignore diffuse light for far away +/// lights, increase MULT or disable if you notice artifacting +#define LTCGI_DISTANCE_FADE_APPROX +/// Distance at which diffuse from screens will be ignored. +#define LTCGI_DISTANCE_FADE_APPROX_MULT 50 + + +// disabled editor from here on out +/// + + +// Allow statically textured lights. +// (deprecated: doesn't really cause any improvement when disabled...) +#define LTCGI_STATIC_TEXTURES + + +// keep in sync with LTCGI_Controller.cs +#define MAX_SOURCES 16 + +// set according to the LUT specified on CONTROLLER +#define LUT_SIZE 256 +static float LUT_SCALE = (LUT_SIZE - 1.0)/LUT_SIZE; +const float LUT_BIAS = 0.5/LUT_SIZE; + +// will be set automatically if audiolink is available +//#define LTCGI_AUDIOLINK + +#ifdef LTCGI_AUDIOLINK +#ifndef AUDIOLINK_WIDTH +#ifndef AUDIOLINK_CGINC_INCLUDED +#include "Packages/com.llealloo.audiolink/Runtime/Shaders/AudioLink.cginc" +#define AUDIOLINK_CGINC_INCLUDED +#endif +#endif +#endif + +// Bake screen data into texture for better performance. Disables moveable screens. +#define LTCGI_STATIC_UNIFORMS + +// Enable support for cylindrical screens. +#define LTCGI_CYLINDER + +// Activate avatar mode, which overrides certain configs from above. +//#define LTCGI_AVATAR_MODE + +#endif diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_functions.cginc b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_functions.cginc new file mode 100644 index 0000000..ff33c87 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_functions.cginc @@ -0,0 +1,500 @@ +#ifndef LTCGI_FUNCTIONS_INCLUDED +#define LTCGI_FUNCTIONS_INCLUDED + +/* + LTC HELPERS +*/ + +float3 LTCGI_IntegrateEdge(float3 v1, float3 v2) +{ + float x = dot(v1, v2); + float y = abs(x); + + float a = 0.8543985 + (0.4965155 + 0.0145206*y)*y; + float b = 3.4175940 + (4.1616724 + y)*y; + float v = a / b; + float theta_sintheta = (x > 0.0) ? v : 0.5*rsqrt(max(1.0 - x*x, 1e-7)) - v; + + return cross(v1, v2) * theta_sintheta; +} + +void LTCGI_ClipQuadToHorizon(inout float3 L[5], out int n) +{ + // detect clipping config + uint config = 0; + if (L[0].z > 0.0) config += 1; + if (L[1].z > 0.0) config += 2; + if (L[2].z > 0.0) config += 4; + if (L[3].z > 0.0) config += 8; + + n = 0; + + // This [forcecase] only works when the cases are ordered in a specific manner. + // It gives like 10%-20% performance boost, so *make sure to leave it on*! + // If it breaks however, see if [branch] fixes it, and if it does, start + // reordering cases at random until it works again. + // It seems the compiler somehow optimizes away anything but setting 'n' in + // some orderings, including the ascending and descending ones. + // I wish I was joking. + [forcecase] + switch (config) { + case 13: // V1 V3 V4 clip V2 <- tl;dr: this fecker has to be first or shader go boom + n = 5; + L[4] = L[3]; + L[3] = L[2]; + L[2] = -L[1].z * L[2] + L[2].z * L[1]; + L[1] = -L[1].z * L[0] + L[0].z * L[1]; + break; + case 15: // V1 V2 V3 V4 - most common + n = 4; + break; + case 9: // V1 V4 clip V2 V3 + n = 4; + L[1] = -L[1].z * L[0] + L[0].z * L[1]; + L[2] = -L[2].z * L[3] + L[3].z * L[2]; + break; + case 0: // clip all + break; + case 1: // V1 clip V2 V3 V4 + n = 3; + L[1] = -L[1].z * L[0] + L[0].z * L[1]; + L[2] = -L[3].z * L[0] + L[0].z * L[3]; + L[3] = L[0]; + break; + case 2: // V2 clip V1 V3 V4 + n = 3; + L[0] = -L[0].z * L[1] + L[1].z * L[0]; + L[2] = -L[2].z * L[1] + L[1].z * L[2]; + L[3] = L[0]; + break; + case 3: // V1 V2 clip V3 V4 + n = 4; + L[2] = -L[2].z * L[1] + L[1].z * L[2]; + L[3] = -L[3].z * L[0] + L[0].z * L[3]; + break; + case 4: // V3 clip V1 V2 V4 + n = 3; + L[0] = -L[3].z * L[2] + L[2].z * L[3]; + L[1] = -L[1].z * L[2] + L[2].z * L[1]; + L[3] = L[0]; + break; + case 5: // V1 V3 clip V2 V4) impossible + break; + case 6: // V2 V3 clip V1 V4 + n = 4; + L[0] = -L[0].z * L[1] + L[1].z * L[0]; + L[3] = -L[3].z * L[2] + L[2].z * L[3]; + break; + case 7: // V1 V2 V3 clip V4 + n = 5; + L[4] = -L[3].z * L[0] + L[0].z * L[3]; + L[3] = -L[3].z * L[2] + L[2].z * L[3]; + break; + case 8: // V4 clip V1 V2 V3 + n = 3; + L[0] = -L[0].z * L[3] + L[3].z * L[0]; + L[1] = -L[2].z * L[3] + L[3].z * L[2]; + L[2] = L[3]; + break; + case 10: // V2 V4 clip V1 V3) impossible + break; + case 11: // V1 V2 V4 clip V3 + n = 5; + L[4] = L[3]; + L[3] = -L[2].z * L[3] + L[3].z * L[2]; + L[2] = -L[2].z * L[1] + L[1].z * L[2]; + break; + case 12: // V3 V4 clip V1 V2 + n = 4; + L[1] = -L[1].z * L[2] + L[2].z * L[1]; + L[0] = -L[0].z * L[3] + L[3].z * L[0]; + break; + case 14: // V2 V3 V4 clip V1 + n = 5; + L[4] = -L[0].z * L[3] + L[3].z * L[0]; + L[0] = -L[0].z * L[1] + L[1].z * L[0]; + break; + } + + // inlining these branches *unconditionally* breaks the [forcecase] above + // ...yeah I know + if (n == 3) + L[3] = L[0]; + if (n == 4) + L[4] = L[0]; +} + +/* + TEXTURE SAMPLING +*/ + +float2 LTCGI_inset_uv(float2 uv) +{ + return uv * 0.75 + float2(0.125, 0.125); +} + +half3 premul_alpha(half4 i) +{ + return i.rgb * i.a; +} + +void LTCGI_sample(float2 uv, uint lod, uint idx, float blend, out float3 result) +{ +#ifdef LTCGI_FAST_SAMPLING + #ifndef SHADER_TARGET_SURFACE_ANALYSIS + blend *= 2.5f; + [branch] + if (idx == 0) + { + result = premul_alpha(_Udon_LTCGI_Texture_LOD0.SampleLevel(LTCGI_SAMPLER, uv, blend)); + } + else + { + result = UNITY_SAMPLE_TEX2DARRAY_SAMPLER_LOD( + _Udon_LTCGI_Texture_LOD0_arr, + LTCGI_SAMPLER_RAW, + float3(uv, idx - 1), + blend + ).rgb; + } + #else + result = 0; + #endif +#else + result = 0; + #ifndef LTCGI_STATIC_TEXTURES + idx = 0; // optimize away the branches below + #endif + + [branch] + if (lod == 0) + { + // if we're outside of the 0-1 UV space we must sample a prefiltered texture + [branch] + if(any(saturate(abs(uv - 0.5) - 0.5))) + { + lod = 1; + } + else + { + // LOD0 is the original texture itself, so not prefiltered, but we can + // approximate it a bit with trilinear lod + float lod = (1 - blend) * 1.5; + [branch] + if (idx == 0) + { + #ifndef SHADER_TARGET_SURFACE_ANALYSIS + result = premul_alpha(_Udon_LTCGI_Texture_LOD0.SampleLevel(LTCGI_SAMPLER, uv, lod)); + return; + #else + result = 0; + return; + #endif + } + else + { + result = premul_alpha(UNITY_SAMPLE_TEX2DARRAY_SAMPLER_LOD( + _Udon_LTCGI_Texture_LOD0_arr, + LTCGI_SAMPLER_RAW, + float3(uv, idx - 1), + lod + )); + return; + } + } + } + + float2 ruv = LTCGI_inset_uv(uv); + + [branch] + if (idx == 0) + { + #ifndef SHADER_TARGET_SURFACE_ANALYSIS + switch (lod) + { + case 1: + result = _Udon_LTCGI_Texture_LOD1.SampleLevel(LTCGI_SAMPLER, ruv, 0).rgb; + return; + case 2: + result = _Udon_LTCGI_Texture_LOD2.SampleLevel(LTCGI_SAMPLER, ruv, 0).rgb; + return; + default: + result = _Udon_LTCGI_Texture_LOD3.SampleLevel(LTCGI_SAMPLER, ruv, blend*0.72).rgb; + return; + } + #else + result = 0; + return; + #endif + } + else + { + [forcecase] + switch (lod) + { + case 1: + result = UNITY_SAMPLE_TEX2DARRAY_SAMPLER_LOD( + _Udon_LTCGI_Texture_LOD1_arr, + LTCGI_SAMPLER_RAW, + float3(ruv, idx - 1), + 0 + ).rgb; + return; + case 2: + result = UNITY_SAMPLE_TEX2DARRAY_SAMPLER_LOD( + _Udon_LTCGI_Texture_LOD2_arr, + LTCGI_SAMPLER_RAW, + float3(ruv, idx - 1), + 0 + ).rgb; + return; + default: + result = UNITY_SAMPLE_TEX2DARRAY_SAMPLER_LOD( + _Udon_LTCGI_Texture_LOD3_arr, + LTCGI_SAMPLER_RAW, + float3(ruv, idx - 1), + blend + ).rgb; + return; + } + } +#endif +} + +void LTCGI_trilinear(float2 uv, float d, uint idx, out float3 result) +{ +#ifdef LTCGI_FAST_SAMPLING + LTCGI_sample(uv, 0, idx, d, result); +#else + uint low = (uint)d; + uint high = low + 1; + + // DEBUG: colorize d/lod + //return float3(low == 0, low == 1, low == 2); + + if (low >= 3) + { + LTCGI_sample(uv, 3, idx, d - 3, result); + } + else + { + float amount = saturate(high - d); + float3 low_sample; + LTCGI_sample(uv, low, idx, amount, low_sample); + float3 high_sample; + LTCGI_sample(uv, high, idx, 0, high_sample); + + result = lerp(high_sample, low_sample, amount); + } +#endif +} + +/* + GENERIC HELPERS +*/ + +// from: https://seblagarde.wordpress.com/2014/12/01/inverse-trigonometric-functions-gpu-optimization-for-amd-gcn-architecture/ +// max absolute error 9.0x10^-3 +// Eberly's polynomial degree 1 - respect bounds +// 4 VGPR, 12 FR (8 FR, 1 QR), 1 scalar +// input [-1, 1] and output [0, PI] +float LTCGI_acos_fast(float inX) +{ + float x = abs(inX); + float res = -0.156583f * x + UNITY_HALF_PI; + res *= sqrt(1.0f - x); + return (inX >= 0) ? res : UNITY_PI - res; +} + +bool LTCGI_tri_ray(float3 orig, float3 dir, float3 v0, float3 v1, float3 v2, out float2 bary) { + float3 v0v1 = v1 - v0; + float3 v0v2 = v2 - v0; + float3 pvec = cross(dir, v0v2); + float det = dot(v0v1, pvec); + float invDet = 1 / det; + + float3 tvec = orig - v0; + bary.x = dot(tvec, pvec) * invDet; + + float3 qvec = cross(tvec, v0v1); + bary.y = dot(dir, qvec) * invDet; + + // return false when other triangle of quad should be sampled, + // i.e. we went over the diagonal line + return bary.x >= 0; +} + +float2 LTCGI_rotateVector(float2 x, float angle) +{ + float c = cos(angle); + float s = sin(angle); + return mul(float2x2(c,s,-s,c), x); +} + +/*float LTCGI_remap(float3 from, float3 to, float2 targetFrom, float2 targetTo, float3 value) +{ + float rel = (value - from) / (to - from); + return lerp(targetFrom, targetTo, rel); +}*/ + +float2 LTCGI_calculateUV(uint i, ltcgi_flags flags, float3 L[5], bool isTri, float4 uvStart, float4 uvEnd, out float3 ray) +{ + // calculate perpendicular vector to plane defined by area light + float3 E1 = L[1] - L[0]; + float3 E2 = L[3] - L[0]; + ray = cross(E1, E2); + + // raycast it against the two triangles formed by the quad + float2 bary; + bool hit0 = LTCGI_tri_ray(0, ray, L[0], L[2], L[3], bary) || isTri; + if (!hit0) { + LTCGI_tri_ray(0, ray, L[0], L[1], L[2], bary); + } + + float3 bary3 = float3(bary, 1 - bary.x - bary.y); + float2 uv; + if (hit0) + uv = uvEnd.zw * bary3.x + uvEnd.xy * bary3.y; + else + uv = uvStart.zw * bary3.x + uvEnd.zw * bary3.y; + return uv + uvStart.xy * bary3.z; +} + +/* + EXPERIMENTAL: CYLINDER HELPER +*/ + +void LTCGI_GetLw(uint i, ltcgi_flags flags, float3 worldPos, out float3 Lw[4], out float4 uvStart, out float4 uvEnd, out bool isTri) { + bool cylinder = false; + #ifdef LTCGI_CYLINDER + // statically optimize out branch below in case disabled + cylinder = flags.cylinder; + #endif + + float4 v0 = _Udon_LTCGI_Vertices_0_get(i); + float4 v1 = _Udon_LTCGI_Vertices_1_get(i); + float4 v2 = _Udon_LTCGI_Vertices_2_get(i); + float4 v3 = _Udon_LTCGI_Vertices_3_get(i); + + [branch] + if (cylinder) { + // construct data according to worldPos to create aligned + // rectangle tangent to the cylinder + + float3 in_base = v0.xyz; + float in_height = v0.w; + float in_radius = v1.w; + float in_size = v2.w; + float in_angle = v3.w; + + // get angle between 2D unit plane and vector pointing from cylinder to shade point + float2 towardsCylinder = LTCGI_rotateVector((in_base - worldPos).xz, -in_angle); + float angle = atan2(towardsCylinder.x, towardsCylinder.y); + // clamp angle to size parameter, i.e. "width" of lit surface area + float angleClamped = clamp(angle, -in_size, in_size) + in_angle; + // construct vector that *most* faces shade point + float2 facing = float2(sin(angleClamped), cos(angleClamped)); + // tangent of rectangular screen on cylinder surface used for calculating lighting for shade point + float2 tangent = float2(facing.y, -facing.x); + float2 onCylinderFacing = facing * in_radius; + + // clip ends, approximately + float rclip = saturate(lerp(1, 0, (angleClamped - in_angle) - (in_size - UNITY_HALF_PI*0.5f))); + float lclip = saturate(lerp(1, 0, -(angleClamped - in_angle) - (in_size - UNITY_HALF_PI*0.5f))); + + float2 p1 = in_base.xz - onCylinderFacing + tangent * in_radius * lclip; + float2 p2 = in_base.xz - onCylinderFacing - tangent * in_radius * rclip; + + Lw[0] = float3(p1.x, in_base.y, p1.y) - worldPos; + Lw[1] = float3(p1.x, in_base.y + in_height, p1.y) - worldPos; + Lw[2] = float3(p2.x, in_base.y, p2.y) - worldPos; + Lw[3] = float3(p2.x, in_base.y + in_height, p2.y) - worldPos; + + isTri = false; + + // UV depends on "viewing" angle of the shade point towards the cylinder + float2 viewDir = normalize((in_base - worldPos).xz); + // forwardAngle == atan2(cos(in_angle), sin(in_angle)); but only negative + float forwardAngle = -in_angle + UNITY_HALF_PI; + // offset from center of screen forward to the side ends, positive goes left/ccw fpv top, + // sine to account for the fact we're rotating around a cylinder which has depth + float viewAngle = forwardAngle - atan2(viewDir.y, viewDir.x); + // prevent rollover, since we need to clamp we must stay withing [-pi, pi] + if (viewAngle < -UNITY_PI) + viewAngle += UNITY_TWO_PI; + if (viewAngle > UNITY_PI) + viewAngle -= UNITY_TWO_PI; + viewAngle = clamp(viewAngle * 0.5f, -in_size, in_size); + viewAngle = sin(viewAngle); + // full view UVs, but shifted left/right depending on view angle + float2 uvStart2 = float2(1 - saturate(viewAngle), 0); + float2 uvEnd2 = float2(1 - saturate(viewAngle + 1), 1); + uvStart = float4(uvStart2.x, uvStart2.y, uvStart2.x, uvEnd2.y); + uvEnd = float4(uvEnd2.x, uvStart2.y, uvEnd2.x, uvEnd2.y); + + } else { + // use passed in data, offset around worldPos + Lw[0] = v0.xyz - worldPos; + Lw[1] = v1.xyz - worldPos; + Lw[2] = v2.xyz - worldPos; + Lw[3] = v3.xyz - worldPos; + #ifndef SHADER_TARGET_SURFACE_ANALYSIS + uvStart = _Udon_LTCGI_static_uniforms[uint2(4, i)]; + uvEnd = _Udon_LTCGI_static_uniforms[uint2(5, i)]; + #else + uvStart = float4(0, 0, 1, 0); + uvEnd = float4(1, 1, 0, 1); + #endif + + // we only detect triangles for "blender" import configuration, as those are the only + // ones that can actually be triangles (I think?) + isTri = /*distance(Lw[2], Lw[3]) < 0.001 || */distance(Lw[1], Lw[3]) < 0.001; + } +} + +#endif + +/* + +Parts of the code in this file are adapted from the example code found here: + + https://github.com/selfshadow/ltc_code + +Modifications by _pi_ (@pimaker on GitHub), licensed under the terms of the +MIT license as far as applicable. + +Original copyright notice: + +Copyright (c) 2017, Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* If you use (or adapt) the source code in your own work, please include a + reference to the paper: + + Real-Time Polygonal-Light Shading with Linearly Transformed Cosines. + Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt. + ACM Transactions on Graphics (Proceedings of ACM SIGGRAPH 2016) 35(4), 2016. + Project page: https://eheitzresearch.wordpress.com/415-2/ + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_shadowmap.cginc b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_shadowmap.cginc new file mode 100644 index 0000000..922c567 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_shadowmap.cginc @@ -0,0 +1,84 @@ +#ifndef LTCGI_SHADOWMAP_INCLUDED +#define LTCGI_SHADOWMAP_INCLUDED + +// Adapted from: https://gitlab.com/s-ilent/filamented +// Licensed under the terms of the Apache License 2.0 +// Full text: https://gitlab.com/s-ilent/filamented/-/blob/master/LICENSE +// +// Conforming to the terms of the above license, this file is redistributed +// under the terms of the MIT license as part of the LTCGI shader package, +// provided this notice is kept. + +#ifndef SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER + +float4 LTCGI_cubic(float v) +{ + float4 n = float4(1.0, 2.0, 3.0, 4.0) - v; + float4 s = n * n * n; + float x = s.x; + float y = s.y - 4.0 * s.x; + float z = s.z - 4.0 * s.y + 6.0 * s.x; + float w = 6.0 - x - y - z; + return float4(x, y, z, w); +} + +// Unity's SampleTexture2DBicubic doesn't exist in 2018, which is our target here. +// So this is a similar function with tweaks to have similar semantics. + +float4 LTCGI_SampleTexture2DBicubicFilter(Texture2D tex, SamplerState smp, float2 coord, float4 texSize) +{ + coord = coord * texSize.xy - 0.5; + float fx = frac(coord.x); + float fy = frac(coord.y); + coord.x -= fx; + coord.y -= fy; + + float4 xcubic = LTCGI_cubic(fx); + float4 ycubic = LTCGI_cubic(fy); + + float4 c = float4(coord.x - 0.5, coord.x + 1.5, coord.y - 0.5, coord.y + 1.5); + float4 s = float4(xcubic.x + xcubic.y, xcubic.z + xcubic.w, ycubic.x + ycubic.y, ycubic.z + ycubic.w); + float4 offset = c + float4(xcubic.y, xcubic.w, ycubic.y, ycubic.w) / s; + + float4 sample0 = tex.Sample(smp, float2(offset.x, offset.z) * texSize.zw); + float4 sample1 = tex.Sample(smp, float2(offset.y, offset.z) * texSize.zw); + float4 sample2 = tex.Sample(smp, float2(offset.x, offset.w) * texSize.zw); + float4 sample3 = tex.Sample(smp, float2(offset.y, offset.w) * texSize.zw); + + float sx = s.x / (s.x + s.y); + float sy = s.z / (s.z + s.w); + + return lerp( + lerp(sample3, sample2, sx), + lerp(sample1, sample0, sx), sy); +} + +float4 LTCGI_SampleShadowmap(float2 lmuv) +{ + #ifdef LTCGI_ALWAYS_LTC_DIFFUSE + return 1; + #else + lmuv = lmuv * _Udon_LTCGI_LightmapST.xy + _Udon_LTCGI_LightmapST.zw; + + #ifdef LTCGI_BICUBIC_LIGHTMAP + float width, height; + _Udon_LTCGI_Lightmap.GetDimensions(width, height); + + float4 _Udon_LTCGI_Lightmap_TexelSize = float4(width, height, 1.0/width, 1.0/height); + + return LTCGI_SampleTexture2DBicubicFilter( + _Udon_LTCGI_Lightmap, LTCGI_SAMPLER, + lmuv, _Udon_LTCGI_Lightmap_TexelSize + ); + #else + return _Udon_LTCGI_Lightmap.Sample(LTCGI_SAMPLER, lmuv); + #endif + #endif +} + +#else +// surface shader analysis stub +float4 LTCGI_SampleShadowmap(float2 lmuv) { return 1; } +#endif + +#endif
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_structs.cginc b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_structs.cginc new file mode 100644 index 0000000..164887f --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_structs.cginc @@ -0,0 +1,43 @@ +#ifndef LTCGI_STRUCTS_INCLUDED +#define LTCGI_STRUCTS_INCLUDED + +#define LTCGI_COLORMODE_STATIC 0 +#define LTCGI_COLORMODE_TEXTURE 1 +#define LTCGI_COLORMODE_SINGLEUV 2 +#define LTCGI_COLORMODE_AUDIOLINK 3 + +struct ltcgi_flags +{ + bool doublesided; // if the light is doublesided or only illuminates the front face + bool diffFromLm; // diffuse lighting intensity will not be calculated via LTC but taken directly from the lightmap + bool specular; // if the light has a specular component + bool diffuse; // if the light has a diffuse component + uint colormode; // colormode, see above + uint texindex; // index of the texture to shade with, if colormode == LTCGI_COLORMODE_TEXTURE + uint lmch, lmidx; // lightmap channel and index + bool cylinder; // is this light a cylinder + uint alBand; // audiolink band if colormode == LTCGI_COLORMODE_AUDIOLINK + bool lmdOnly; // if this light is lightmap-diffuse _only_, that is, no LTC will be run (Lw will be all 0 in that case) - this will never be true on avatars (with LTCGI_ALWAYS_LTC_DIFFUSE) +}; + +struct ltcgi_input +{ + uint i; // light number + float3 Lw[4]; // world space area light vertices, Lw[1] == Lw[3] for triangle lights, shifted by input worldPos (i.e. world space position as seen from (0, 0, 0)) + bool isTri; // if this is a triangle light, quad if false + float4 uvStart; // defines the UV layout of the area (xy = top-left, zw=top-right) + float4 uvEnd; // defines the UV layout of the area (xy = bottom-left, zw=bottom-right), different use for cylinders + float3 rawColor; // the raw light color, unaffected by any colormode calculations (i.e. exactly what's given as "color" in editor) + float3 screenNormal; // world space normal direction of area light + ltcgi_flags flags; // flags, see above +}; + +struct ltcgi_output +{ + ltcgi_input input; // input data that resulted in this output + + float intensity; // intensity output by LTC calculation + float3 color; // color output by LTCGI colormode calculation +}; + +#endif
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_uniform.cginc b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_uniform.cginc new file mode 100644 index 0000000..116cedd --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_uniform.cginc @@ -0,0 +1,142 @@ +#ifndef LTCGI_UNIFORM_INCLUDED +#define LTCGI_UNIFORM_INCLUDED + +// global sampler (trilinear) +#ifndef LTCGI_SAMPLER +SamplerState sampler_LTCGI_trilinear_clamp_sampler; +#define LTCGI_SAMPLER sampler_LTCGI_trilinear_clamp_sampler +#define LTCGI_SAMPLER_RAW _LTCGI_trilinear_clamp_sampler +#endif + +// LUTs +#ifndef SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER +uniform Texture2D<float4> _Udon_LTCGI_lut2; +uniform Texture2D<float4> _Udon_LTCGI_lut1; +#endif + +#ifndef SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER +uniform Texture2D<float4> _Udon_LTCGI_static_uniforms; +#endif + +#ifdef LTCGI_STATIC_UNIFORMS + +float4 _Udon_LTCGI_Vertices_0_get(uint i) { + return _Udon_LTCGI_static_uniforms[uint2(0, i)]; +} +float4 _Udon_LTCGI_Vertices_1_get(uint i) { + return _Udon_LTCGI_static_uniforms[uint2(1, i)]; +} +float4 _Udon_LTCGI_Vertices_2_get(uint i) { + return _Udon_LTCGI_static_uniforms[uint2(2, i)]; +} +float4 _Udon_LTCGI_Vertices_3_get(uint i) { + return _Udon_LTCGI_static_uniforms[uint2(3, i)]; +} + +#else + +// vertices in object space; w component is UV (legacy) +uniform float4 _Udon_LTCGI_Vertices_0[MAX_SOURCES]; +uniform float4 _Udon_LTCGI_Vertices_1[MAX_SOURCES]; +uniform float4 _Udon_LTCGI_Vertices_2[MAX_SOURCES]; +uniform float4 _Udon_LTCGI_Vertices_3[MAX_SOURCES]; + +float4 _Udon_LTCGI_Vertices_0_get(uint i) { + return _Udon_LTCGI_Vertices_0[i]; +} +float4 _Udon_LTCGI_Vertices_1_get(uint i) { + return _Udon_LTCGI_Vertices_1[i]; +} +float4 _Udon_LTCGI_Vertices_2_get(uint i) { + return _Udon_LTCGI_Vertices_2[i]; +} +float4 _Udon_LTCGI_Vertices_3_get(uint i) { + return _Udon_LTCGI_Vertices_3[i]; +} + +#endif + +// light source count, maximum is MAX_SOURCES +uniform uint _Udon_LTCGI_ScreenCount; + +// per-renderer mask to select sources, +// for max perf update _Udon_LTCGI_ScreenCount too +uniform bool _Udon_LTCGI_Mask[MAX_SOURCES]; + +// extra data per light source, layout: +// color.r color.g color.b flags* +// * b0=double-sided, b1=diffuse-from-lightmap, b2=specular, b3=diffuse, +// b4-b7=texture index (0=video, (n>0)=n-1) +// b8-b9=color mode +// b10-b11=lightmap channel (0=disabled, 1=r, 2=g, 3=b) +// b12=cylinder +// b13-14=audio link band +// b15=lightmap diffuse only +// (color black = fully disabled) +uniform float4 _Udon_LTCGI_ExtraData[MAX_SOURCES]; + +ltcgi_flags ltcgi_parse_flags(uint val, bool noLmDiff) +{ + ltcgi_flags ret = (ltcgi_flags)0; + ret.doublesided = (val & 1) == 1; + + #ifdef LTCGI_ALWAYS_LTC_DIFFUSE + ret.diffFromLm = false; + #else + ret.diffFromLm = !noLmDiff && (val & 2) == 2; + #endif + + ret.diffuse = (val & 8) == 8; + + ret.specular = (val & 4) == 4; + ret.texindex = (val & 0xf0) >> 4; + ret.colormode = (val & 0x300) >> 8; + + #ifdef LTCGI_ALWAYS_LTC_DIFFUSE + ret.lmch = 0; + #else + ret.lmch = (val & 0xC00) >> 10; + #endif + + ret.cylinder = (val & (1 << 12)) == (1 << 12); + + #ifdef LTCGI_AUDIOLINK + ret.alBand = (val & 0x6000) >> 13; + #endif + + ret.lmdOnly = (val & (1 << 15)) == (1 << 15); + + return ret; +} + +// video input +#ifndef SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER +uniform Texture2D<float4> _Udon_LTCGI_Texture_LOD0; +#ifndef LTCGI_FAST_SAMPLING +uniform Texture2D<float4> _Udon_LTCGI_Texture_LOD1; +uniform Texture2D<float4> _Udon_LTCGI_Texture_LOD2; +uniform Texture2D<float4> _Udon_LTCGI_Texture_LOD3; +#endif +#endif + +// static textures +UNITY_DECLARE_TEX2DARRAY_NOSAMPLER(_Udon_LTCGI_Texture_LOD0_arr); +#ifndef LTCGI_FAST_SAMPLING +UNITY_DECLARE_TEX2DARRAY_NOSAMPLER(_Udon_LTCGI_Texture_LOD1_arr); +UNITY_DECLARE_TEX2DARRAY_NOSAMPLER(_Udon_LTCGI_Texture_LOD2_arr); +UNITY_DECLARE_TEX2DARRAY_NOSAMPLER(_Udon_LTCGI_Texture_LOD3_arr); +#endif + +// lightmap +#ifndef SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER +#ifndef LTCGI_ALWAYS_LTC_DIFFUSE +uniform Texture2D<float4> _Udon_LTCGI_Lightmap; +#endif +#endif +uniform float3 _Udon_LTCGI_LightmapMult; +uniform float4 _Udon_LTCGI_LightmapST; + +// global toggle +uniform float _Udon_LTCGI_GlobalEnable; + +#endif
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/package.json b/Third_Party/at.pimaker.ltcgi/package.json new file mode 100644 index 0000000..3242370 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/package.json @@ -0,0 +1,14 @@ +{ + "name": "at.pimaker.ltcgi", + "displayName": "LTCGI", + "version": "1.4.1", + "description": "Optimized plug-and-play realtime area lighting using the linearly transformed cosine algorithm for Unity/VRChat. ", + "dependencies": {}, + "gitDependencies": {}, + "vpmDependencies": { + }, + "legacyFolders": { + "Assets\\_pi_\\_LTCGI": "" + }, + "legacyFiles": {} +}
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/unitypackage-adapter-protv.list b/Third_Party/at.pimaker.ltcgi/unitypackage-adapter-protv.list new file mode 100644 index 0000000..cc55657 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/unitypackage-adapter-protv.list @@ -0,0 +1,3 @@ +Assets/_pi_/_LTCGI-Adapters/LTCGI_ProTvAdapter.cs.meta +Assets/_pi_/_LTCGI-Adapters/LTCGI_ProTvAdapter.asset.meta +Assets/_pi_/_LTCGI-Adapters/Editor/LTCGI_ProTvAdapterAutoSetup.cs.meta
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/unitypackage-adapter-usharp.list b/Third_Party/at.pimaker.ltcgi/unitypackage-adapter-usharp.list new file mode 100644 index 0000000..d680bc8 --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/unitypackage-adapter-usharp.list @@ -0,0 +1,3 @@ +Assets/_pi_/_LTCGI-Adapters/LTCGI_USharpVideoAdapter.cs.meta +Assets/_pi_/_LTCGI-Adapters/LTCGI_USharpVideoAdapter.asset.meta +Assets/_pi_/_LTCGI-Adapters/Editor/LTCGI_USharpVideoAdapterAutoSetup.cs.meta
\ No newline at end of file diff --git a/Third_Party/at.pimaker.ltcgi/unitypackage.list b/Third_Party/at.pimaker.ltcgi/unitypackage.list new file mode 100644 index 0000000..ed5820a --- /dev/null +++ b/Third_Party/at.pimaker.ltcgi/unitypackage.list @@ -0,0 +1,58 @@ +Assets/_pi_/_LTCGI/LICENSE.meta +Assets/_pi_/_LTCGI/README.md.meta +Assets/_pi_/_LTCGI/LTCGI Attribution.prefab.meta +Assets/_pi_/_LTCGI/LTCGI Controller.prefab.meta +Assets/_pi_/_LTCGI/Lookup Tables/ltc_mat_hdr_inc.exr.meta +Assets/_pi_/_LTCGI/Lookup Tables/ltc_mag_hdr_inc.exr.meta +Assets/_pi_/_LTCGI/Lookup Tables/white1px.png.meta +Assets/_pi_/_LTCGI/Prefilter Blur/BlurPrefilter.shader.meta +Assets/_pi_/_LTCGI/Prefilter Blur/LOD1_crt.asset.meta +Assets/_pi_/_LTCGI/Prefilter Blur/LOD1_mat.mat.meta +Assets/_pi_/_LTCGI/Prefilter Blur/LOD1s_crt.asset.meta +Assets/_pi_/_LTCGI/Prefilter Blur/LOD1s_mat.mat.meta +Assets/_pi_/_LTCGI/Prefilter Blur/LOD2_crt.asset.meta +Assets/_pi_/_LTCGI/Prefilter Blur/LOD2_mat.mat.meta +Assets/_pi_/_LTCGI/Prefilter Blur/LOD2s_crt.asset.meta +Assets/_pi_/_LTCGI/Prefilter Blur/LOD2s_mat.mat.meta +Assets/_pi_/_LTCGI/Prefilter Blur/LOD3_crt.asset.meta +Assets/_pi_/_LTCGI/Prefilter Blur/LOD3_mat.mat.meta +Assets/_pi_/_LTCGI/Prefilter Blur/LOD3s_crt.asset.meta +Assets/_pi_/_LTCGI/Prefilter Blur/LOD3s_mat.mat.meta +Assets/_pi_/_LTCGI/Propaganda/Attribution Material.mat.meta +Assets/_pi_/_LTCGI/Propaganda/Attribution.png.meta +Assets/_pi_/_LTCGI/Propaganda/AttributionWhite.png.meta +Assets/_pi_/_LTCGI/Propaganda/ltcgi_graffiti.png.meta +Assets/_pi_/_LTCGI/Propaganda/ltcgi_sign.fbx.meta +Assets/_pi_/_LTCGI/Propaganda/ltcgi_sign_mat.mat.meta +Assets/_pi_/_LTCGI/Propaganda/pi_graffiti.png.meta +Assets/_pi_/_LTCGI/Scripts/LTCGI_UdonAdapter.asset.meta +Assets/_pi_/_LTCGI/Scripts/LTCGI_UdonAdapter.cs.meta +Assets/_pi_/_LTCGI/Scripts/LTCGI_Assembly.asmdef.meta +Assets/_pi_/_LTCGI/Scripts/LTCGI_AssemblyUdon.asset.meta +Assets/_pi_/_LTCGI/Scripts/Editor/LTCGI_BakeReset.cs.meta +Assets/_pi_/_LTCGI/Scripts/Editor/LTCGI_Controller.cs.meta +Assets/_pi_/_LTCGI/Scripts/Editor/LTCGI_ControllerAutoSetup.cs.meta +Assets/_pi_/_LTCGI/Scripts/Editor/LTCGI_ControllerBake.cs.meta +Assets/_pi_/_LTCGI/Scripts/Editor/LTCGI_ControllerExternal.cs.meta +Assets/_pi_/_LTCGI/Scripts/Editor/LTCGI_ControllerHelpers.cs.meta +Assets/_pi_/_LTCGI/Scripts/Editor/LTCGI_ControllerLOD.cs.meta +Assets/_pi_/_LTCGI/Scripts/Editor/LTCGI_Include.cs.meta +Assets/_pi_/_LTCGI/Scripts/Editor/LTCGI_Screen.cs.meta +Assets/_pi_/_LTCGI/Scripts/Editor/LTCGI_Emitter.cs.meta +Assets/_pi_/_LTCGI/Scripts/Editor/Resources/LTCGI-Logo.png.meta +Assets/_pi_/_LTCGI/Scripts/Editor/Resources/LTCGI-LogoController.png.meta +Assets/_pi_/_LTCGI/Shaders/Amplify/AmplifyTest.mat.meta +Assets/_pi_/_LTCGI/Shaders/Amplify/LTCGI_Amplify.shader.meta +Assets/_pi_/_LTCGI/Shaders/Amplify/LTCGI_Contribution.asset.meta +Assets/_pi_/_LTCGI/Shaders/LTCGI.cginc.meta +Assets/_pi_/_LTCGI/Shaders/LTCGI_config.cginc.meta +Assets/_pi_/_LTCGI/Shaders/LTCGI_functions.cginc.meta +Assets/_pi_/_LTCGI/Shaders/LTCGI_shadowmap.cginc.meta +Assets/_pi_/_LTCGI/Shaders/LTCGI_uniform.cginc.meta +Assets/_pi_/_LTCGI/Shaders/LTCGI_Simple.shader.meta +Assets/_pi_/_LTCGI/Shaders/LTCGI_Surface.shader.meta +Assets/_pi_/_LTCGI/Adapters/black1px.png.meta +Assets/_pi_/_LTCGI/Adapters/LTCGI_AvProBlit.shader.meta +Assets/_pi_/_LTCGI/Adapters/LTCGI_AvProBlit_Material.mat.meta +Assets/_pi_/_LTCGI/Adapters/LTCGI_BlitCRT.asset.meta +Assets/Gizmos/LTCGI_Screen_Gizmo.png.meta |
