mirror of
https://github.com/DeMuenu/MoonlightVRC.git
synced 2026-05-06 10:22:20 +00:00
Compare commits
2 Commits
a3f95883be
...
optimisati
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a30f72010 | ||
|
|
79ad33c5f3 |
@@ -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,5 +1,5 @@
|
||||
// Assets/Lighting/Scripts/LightUpdater.Editor.cs
|
||||
#if UNITY_EDITOR
|
||||
#if !COMPILER_UDONSHARP && UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
|
||||
public partial class LightUpdater
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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
Shader/Includes/Moonlight.hlsl.meta
Normal file
7
Shader/Includes/Moonlight.hlsl.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1193ddffee5ac344ea57d621ec8150f6
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user