Compare commits

..

5 Commits

Author SHA1 Message Date
DeMuenu 21bb6193a2 Merge branch 'main' into optimisations-from-gemini 2026-05-27 11:45:12 +02:00
DeMuenu 1a30f72010 optimisations skipping empty for loops 2026-03-28 17:15:19 +01:00
DeMuenu 79ad33c5f3 Fix Gemini stuff 2026-03-26 23:01:38 +01:00
DeMuenu a412ae2dc6 Merge branch 'main' of https://github.com/DeMuenu/MoonlightVRC 2026-03-26 22:04:56 +01:00
DeMuenu 9401c47631 Klammer fix oder so 2026-03-26 22:04:52 +01:00
9 changed files with 38 additions and 18 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ public static class LightUpdaterPreview
static void PushFromBehaviour(LightUpdater src)
{
int max = Mathf.Max(1, src.maxLights);
int max = Mathf.Max(1, LightUpdater.maxLights);
EnsureArrays(src, max);
var c = _cache[src];
+1 -1
View File
@@ -1,5 +1,5 @@
// Assets/Lighting/Scripts/LightUpdater.Editor.cs
#if UNITY_EDITOR
#if !COMPILER_UDONSHARP && UNITY_EDITOR
using UnityEngine;
public partial class LightUpdater
+4 -6
View File
@@ -47,9 +47,9 @@ public partial class LightUpdater : UdonSharpBehaviour
[Tooltip("float array: shadow map index (0=none, 1-4=shadow map index)")]
public string shadowMapIndexProperty = "_Udon_ShadowMapIndex";
[Header("Max Lights (advanced users)")]
[Header("Max Lighetts (advanced users)")]
[Tooltip("Hard cap / array size. 80 = default cap")]
public int maxLights = 80;
public const int maxLights = 80;
@@ -66,7 +66,7 @@ public partial class LightUpdater : UdonSharpBehaviour
private float[] _ShadowMapArray;
private bool _ShadowMap_isDirty = false;
private LightdataStorage[] _sceneLights;
private LightdataStorage[] _sceneLights = new LightdataStorage[maxLights];
private int _sceneLightCount = 0;
private VRCPlayerApi[] _players;
@@ -85,14 +85,12 @@ public partial class LightUpdater : UdonSharpBehaviour
void Start()
{
if (maxLights < 1) maxLights = 1;
_positions = new Vector4[maxLights];
_lightColors = new Vector4[maxLights];
_directions = new Vector4[maxLights];
_TypeArray = new float[maxLights];
_ShadowMapArray = new float[maxLights];
_sceneLights = new LightdataStorage[maxLights];
_players = new VRCPlayerApi[maxLights];
@@ -370,7 +368,7 @@ public partial class LightUpdater : UdonSharpBehaviour
if (pushShadowMap) VRCShader.SetGlobalFloatArray(UdonID_ShadowMapIndex, _ShadowMapArray);
VRCShader.SetGlobalFloat(UdonID_LightCount, currentCount);
Debug.Log($"[MoonlightVRC] Pushed {currentCount} lights to shader.");
//Debug.Log($"[MoonlightVRC] Pushed {currentCount} lights to shader.");
// Only now mark them clean
if (pushPositions) { _positons_isDirty = false; }
+2 -1
View File
@@ -6,7 +6,7 @@
{ \
float distAtten = max(1.0, distanceFromLight - radius) * invSqMul; \
contrib = _Udon_LightColors[LightCounter].a / max(1e-4, distAtten * distAtten); \
\
if (contrib == 0.0) continue;\
dIntensity += contrib; \
} \
else if (typeId == 1) \
@@ -18,6 +18,7 @@
contrib = smoothstep(radius,_Udon_LightDirections[LightCounter].w, contrib); \
\
contrib = contrib * invSq; \
if (contrib == 0.0) continue;\
dIntensity += contrib; \
} \
half3 LightColor = _Udon_LightColors[LightCounter].xyz; \
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1193ddffee5ac344ea57d621ec8150f6
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+2 -2
View File
@@ -105,7 +105,7 @@ Shader "DeMuenu/World/Hoppou/Particles/LitParticles_2SP"
OutLoopSetup(i, _Udon_PlayerCount) //defines count, N, dmax, dIntensity
[loop]
for (int LightCounter = 0; LightCounter < MAX_LIGHTS; LightCounter++)
for (int LightCounter = 0; LightCounter < count; LightCounter++)
{
InLoopSetup(_Udon_LightPositions, LightCounter, count, i); //defines distanceFromLight, contrib
@@ -116,7 +116,7 @@ Shader "DeMuenu/World/Hoppou/Particles/LitParticles_2SP"
float4 ShadowCasterMult_1 = 1;
float4 ShadowCasterMult_2 = 1;
if (shadowCastingEnabled)
if ((((_Udon_ShadowMapIndex[LightCounter] > 0.5) && (_Udon_ShadowMapIndex[LightCounter] < 1.5) && (_EnableShadowCasting > 0.5)) || (_Udon_ShadowMapIndex[LightCounter] > 2.5)) && _EnableShadowCasting)
{
half smIndex = _Udon_ShadowMapIndex[LightCounter];
if ((smIndex > 0.5 && smIndex < 1.5) || smIndex > 2.5)
+9 -2
View File
@@ -130,7 +130,7 @@ Shader "DeMuenu/World/Hoppou/Standard_2SP"
OutLoopSetup(i, _Udon_PlayerCount) //defines count, N, dmax, dIntensity
[loop]
for (int LightCounter = 0; LightCounter < MAX_LIGHTS; LightCounter++)
for (int LightCounter = 0; LightCounter < count; LightCounter++)
{
InLoopSetup(_Udon_LightPositions, LightCounter, count, i); //defines distanceFromLight, contrib
@@ -143,7 +143,14 @@ Shader "DeMuenu/World/Hoppou/Standard_2SP"
float4 ShadowCasterMult_1 = 1;
float4 ShadowCasterMult_2 = 1;
if (shadowCastingEnabled)
if ((((_Udon_ShadowMapIndex[LightCounter] > 0.5) && (_Udon_ShadowMapIndex[LightCounter] < 1.5) && (_EnableShadowCasting > 0.5)) || (_Udon_ShadowMapIndex[LightCounter] > 2.5)) && _EnableShadowCasting) {
float4 sc1 = SampleShadowcasterPlaneWS_Basis(
_Udon_LightPositions[LightCounter].xyz, i.worldPos,
_Udon_Plane_Origin_1.xyz, _Udon_Plane_Uinv_1.xyz, _Udon_Plane_Vinv_1.xyz, _Udon_Plane_Normal_1.xyz,
_Udon_shadowCasterTex_1, _Udon_OutSideColor_1, _Udon_shadowCasterColor_1, _BlurPixels, _Udon_shadowCasterTex_1_TexelSize.xy);
ShadowCasterMult_1 = max(sc1, _Udon_MinBrightnessShadow_1);
}
if (_Udon_ShadowMapIndex[LightCounter] > 1.5 && (_EnableShadowCasting > 0.5))
{
half smIndex = _Udon_ShadowMapIndex[LightCounter];
if ((smIndex > 0.5 && smIndex < 1.5) || smIndex > 2.5)
+10 -2
View File
@@ -142,7 +142,7 @@ Shader "DeMuenu/World/Hoppou/Standard_Lightmap_2SP"
OutLoopSetup(i, _Udon_PlayerCount) //defines count, N, dmax, dIntensity
[loop]
for (int LightCounter = 0; LightCounter < MAX_LIGHTS; LightCounter++)
for (int LightCounter = 0; LightCounter < count; LightCounter++)
{
InLoopSetup(_Udon_LightPositions, LightCounter, count, i); //defines distanceFromLight, contrib
@@ -155,7 +155,15 @@ Shader "DeMuenu/World/Hoppou/Standard_Lightmap_2SP"
float4 ShadowCasterMult_1 = 1;
float4 ShadowCasterMult_2 = 1;
if (shadowCastingEnabled)
if ((((_Udon_ShadowMapIndex[LightCounter] > 0.5) && (_Udon_ShadowMapIndex[LightCounter] < 1.5) && (_EnableShadowCasting > 0.5)) || (_Udon_ShadowMapIndex[LightCounter] > 2.5)) && _EnableShadowCasting)
{
float4 sc1 = SampleShadowcasterPlaneWS_Basis(
_Udon_LightPositions[LightCounter].xyz, i.worldPos,
_Udon_Plane_Origin_1.xyz, _Udon_Plane_Uinv_1.xyz, _Udon_Plane_Vinv_1.xyz, _Udon_Plane_Normal_1.xyz,
_Udon_shadowCasterTex_1, _Udon_OutSideColor_1, _Udon_shadowCasterColor_1, _BlurPixels, _Udon_shadowCasterTex_1_TexelSize.xy);
ShadowCasterMult_1 = max(sc1, _Udon_MinBrightnessShadow_1);
}
if (_Udon_ShadowMapIndex[LightCounter] > 1.5 && (_EnableShadowCasting > 0.5))
{
half smIndex = _Udon_ShadowMapIndex[LightCounter];
if ((smIndex > 0.5 && smIndex < 1.5) || smIndex > 2.5)
+2 -3
View File
@@ -175,7 +175,7 @@ Shader "DeMuenu/World/Hoppou/WaterFlat_2SP"
OutLoopSetup(i, _Udon_PlayerCount) //defines count, N, dmax, dIntensity
[loop]
for (int LightCounter = 0; LightCounter < MAX_LIGHTS; LightCounter++)
for (int LightCounter = 0; LightCounter < count; LightCounter++)
{
InLoopSetup(_Udon_LightPositions, LightCounter, count, i); //defines distanceFromLight, contrib
@@ -186,7 +186,7 @@ Shader "DeMuenu/World/Hoppou/WaterFlat_2SP"
float4 ShadowCasterMult_1 = 1;
float4 ShadowCasterMult_2 = 1;
if (shadowCastingEnabled)
if ((((_Udon_ShadowMapIndex[LightCounter] > 0.5) && (_Udon_ShadowMapIndex[LightCounter] < 1.5) && (_EnableShadowCasting > 0.5)) || (_Udon_ShadowMapIndex[LightCounter] > 2.5)) && _EnableShadowCasting)
{
half smIndex = _Udon_ShadowMapIndex[LightCounter];
if ((smIndex > 0.5 && smIndex < 1.5) || smIndex > 2.5)
@@ -216,7 +216,6 @@ Shader "DeMuenu/World/Hoppou/WaterFlat_2SP"
//dmax = dmax + contrib * float4(LightColor, 1); // accumulate light contributions
}
//dmax.xyz = min(dmax * dIntensity, 1.0);