mirror of
https://github.com/DeMuenu/MoonlightVRC.git
synced 2025-12-12 19:13:56 +00:00
Rename shader light variables to Udon-prefixed versions
Updated all relevant shader files and C# script to use Udon-prefixed light and player variables (e.g., _Udon_LightPositions, _Udon_LightColors, _Udon_PlayerCount) for consistency and to avoid naming conflicts. This change affects variable declarations, macro definitions, and all usages in BlendinShader, LitParticles, Water shaders, and included HLSL files.
This commit is contained in:
@@ -67,11 +67,11 @@ public partial class PlayerPositionsToShader : UdonSharpBehaviour
|
||||
|
||||
private float _nextUpdate = 0f;
|
||||
|
||||
private static readonly int UdonID_PlayerPositions;
|
||||
private static readonly int UdonID_LightCount;
|
||||
private static readonly int UdonID_LightColors;
|
||||
private static readonly int UdonID_LightDirections;
|
||||
private static readonly int UdonID_LightType;
|
||||
private int UdonID_PlayerPositions;
|
||||
private int UdonID_LightCount;
|
||||
private int UdonID_LightColors;
|
||||
private int UdonID_LightDirections;
|
||||
private int UdonID_LightType;
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
@@ -112,18 +112,18 @@ Shader "DeMuenu/World/Hoppou/RevealStandart"
|
||||
//Moonlight
|
||||
float3 N = normalize(i.worldNormal); /*for lambertian diffuse*/
|
||||
|
||||
OutLoopSetup(i, _PlayerCount) //defines count, N, dmax, dIntensity
|
||||
OutLoopSetup(i, _Udon_PlayerCount) //defines count, N, dmax, dIntensity
|
||||
|
||||
[loop]
|
||||
for (int LightCounter = 0; LightCounter < MAX_LIGHTS; LightCounter++)
|
||||
{
|
||||
InLoopSetup(_LightPositions, LightCounter, count, i); //defines distanceFromLight, contrib
|
||||
InLoopSetup(_Udon_LightPositions, LightCounter, count, i); //defines distanceFromLight, contrib
|
||||
|
||||
|
||||
//Lambertian diffuse
|
||||
Lambert(_LightPositions[LightCounter].xyz ,i, N); //defines NdotL
|
||||
Lambert(_Udon_LightPositions[LightCounter].xyz ,i, N); //defines NdotL
|
||||
|
||||
LightTypeCalculations(_LightColors, LightCounter, i, NdotL, dIntensity, _LightPositions[LightCounter].a, _LightPositions[LightCounter].xyz);
|
||||
LightTypeCalculations(_Udon_LightColors, LightCounter, i, NdotL, dIntensity, _Udon_LightPositions[LightCounter].a, _Udon_LightPositions[LightCounter].xyz);
|
||||
|
||||
dmax = dmax + contrib * float4(LightColor, 1) * NdotL; // accumulate light contributions
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef InLoopSetup
|
||||
#define InLoopSetup(_LightPositions, LightCounter, count, i) \
|
||||
#define InLoopSetup(_Udon_LightPositions, LightCounter, count, i) \
|
||||
if (LightCounter >= count) break; \
|
||||
\
|
||||
float distanceFromLight = length(i.worldPos - _LightPositions[LightCounter].xyz); \
|
||||
float distanceFromLight = length(i.worldPos - _Udon_LightPositions[LightCounter].xyz); \
|
||||
if (distanceFromLight > _LightCutoffDistance) continue; \
|
||||
\
|
||||
float contrib = 0.0;
|
||||
@@ -10,8 +10,8 @@
|
||||
#endif
|
||||
|
||||
#ifndef OutLoopSetup
|
||||
#define OutLoopSetup(i, _PlayerCount) \
|
||||
int count = (int)_PlayerCount; \
|
||||
#define OutLoopSetup(i, _Udon_PlayerCount) \
|
||||
int count = (int)_Udon_PlayerCount; \
|
||||
\
|
||||
float4 dmax = float4(0,0,0,1); \
|
||||
float dIntensity = 0;
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
#ifndef LightTypeCalculations
|
||||
#define LightTypeCalculations(_LightColors ,LightCounter, i, NdotL, dIntensity, radius, Lightposition) \
|
||||
#define LightTypeCalculations(_Udon_LightColors ,LightCounter, i, NdotL, dIntensity, radius, Lightposition) \
|
||||
float invSqMul = max(1e-4, _InverseSqareMultiplier); \
|
||||
\
|
||||
if(_LightType[LightCounter] == 0) \
|
||||
if(_Udon_LightType[LightCounter] == 0) \
|
||||
{ \
|
||||
contrib = _LightColors[LightCounter].a / max(1e-4, max(0, max(1, distanceFromLight - radius) * invSqMul) * max(0, max(1, distanceFromLight - radius) * invSqMul)); \
|
||||
contrib = _Udon_LightColors[LightCounter].a / max(1e-4, max(0, max(1, distanceFromLight - radius) * invSqMul) * max(0, max(1, distanceFromLight - radius) * invSqMul)); \
|
||||
\
|
||||
dIntensity += contrib * NdotL; \
|
||||
} \
|
||||
else if (_LightType[LightCounter] == 1) \
|
||||
else if (_Udon_LightType[LightCounter] == 1) \
|
||||
{ \
|
||||
float invSq = _LightColors[LightCounter].a / max(1e-4, (distanceFromLight * invSqMul) * (distanceFromLight * invSqMul)); \
|
||||
float threshold = (-1 + _LightDirections[LightCounter].w / 180); \
|
||||
float invSq = _Udon_LightColors[LightCounter].a / max(1e-4, (distanceFromLight * invSqMul) * (distanceFromLight * invSqMul)); \
|
||||
float threshold = (-1 + _Udon_LightDirections[LightCounter].w / 180); \
|
||||
\
|
||||
contrib = min(dot(normalize(i.worldPos - Lightposition), -normalize(_LightDirections[LightCounter].xyz)), 0); \
|
||||
contrib = min(dot(normalize(i.worldPos - Lightposition), -normalize(_Udon_LightDirections[LightCounter].xyz)), 0); \
|
||||
contrib= 1 - step(threshold, contrib); \
|
||||
\
|
||||
contrib = contrib * invSq; \
|
||||
dIntensity += contrib * NdotL; \
|
||||
} \
|
||||
float3 LightColor = _LightColors[LightCounter].xyz; \
|
||||
float3 LightColor = _Udon_LightColors[LightCounter].xyz; \
|
||||
|
||||
|
||||
#endif
|
||||
@@ -2,13 +2,12 @@
|
||||
#define MoonlightGlobalVariables \
|
||||
\
|
||||
float _InverseSqareMultiplier; \
|
||||
float _LightCutoffDistance; \
|
||||
float _LightCutoffDistance; \
|
||||
\
|
||||
float4 _LightPositions[MAX_LIGHTS]; /* xyz = position */ \
|
||||
float4 _LightColors[MAX_LIGHTS]; /* xyz = position */ \
|
||||
float4 _LightDirections[MAX_LIGHTS]; /* xyz = direction, w = cos(halfAngle) */ \
|
||||
float _LightType[MAX_LIGHTS]; /* 0 = sphere, 1 = cone */ \
|
||||
float _PlayerCount; /* set via SetFloat */ \
|
||||
\
|
||||
|
||||
float4 _Udon_LightPositions[MAX_LIGHTS]; /* xyz = position */ \
|
||||
float4 _Udon_LightColors[MAX_LIGHTS]; /* xyz = position */ \
|
||||
float4 _Udon_LightDirections[MAX_LIGHTS]; /* xyz = direction, w = cos(halfAngle) */ \
|
||||
float _Udon_LightType[MAX_LIGHTS]; /* 0 = sphere, 1 = cone */ \
|
||||
float _Udon_PlayerCount; /* set via SetFloat */ \
|
||||
|
||||
#endif
|
||||
@@ -106,17 +106,17 @@ Shader "DeMuenu/World/Hoppou/Particles/LitParticles"
|
||||
//Moonlight
|
||||
float3 N = normalize(i.worldNormal); /*for lambertian diffuse*/
|
||||
|
||||
OutLoopSetup(i, _PlayerCount) //defines count, N, dmax, dIntensity
|
||||
OutLoopSetup(i, _Udon_PlayerCount) //defines count, N, dmax, dIntensity
|
||||
|
||||
[loop]
|
||||
for (int LightCounter = 0; LightCounter < MAX_LIGHTS; LightCounter++)
|
||||
{
|
||||
|
||||
InLoopSetup(_LightPositions, LightCounter, count, i); //defines distanceFromLight, contrib
|
||||
InLoopSetup(_Udon_LightPositions, LightCounter, count, i); //defines distanceFromLight, contrib
|
||||
|
||||
Lambert(_LightPositions[LightCounter].xyz ,i, N); //defines NdotL
|
||||
Lambert(_Udon_LightPositions[LightCounter].xyz ,i, N); //defines NdotL
|
||||
|
||||
LightTypeCalculations(_LightColors, LightCounter, i, NdotL, dIntensity, _LightPositions[LightCounter].a, _LightPositions[LightCounter].xyz);
|
||||
LightTypeCalculations(_Udon_LightColors, LightCounter, i, NdotL, dIntensity, _Udon_LightPositions[LightCounter].a, _Udon_LightPositions[LightCounter].xyz);
|
||||
|
||||
dmax = dmax + contrib * float4(LightColor, 1) * NdotL; // accumulate light contributions
|
||||
|
||||
|
||||
@@ -153,16 +153,16 @@ Shader "DeMuenu/World/Hoppou/Water"
|
||||
float3 R = reflect(-V, N); //for reflection vector
|
||||
//Waterspecific END
|
||||
|
||||
OutLoopSetup(i, _PlayerCount) //defines count, N, dmax, dIntensity
|
||||
OutLoopSetup(i, _Udon_PlayerCount) //defines count, N, dmax, dIntensity
|
||||
|
||||
[loop]
|
||||
for (int LightCounter = 0; LightCounter < MAX_LIGHTS; LightCounter++)
|
||||
{
|
||||
InLoopSetup(_LightPositions, LightCounter, count, i); //defines distanceFromLight, contrib
|
||||
InLoopSetup(_Udon_LightPositions, LightCounter, count, i); //defines distanceFromLight, contrib
|
||||
|
||||
Lambert(_LightPositions[LightCounter].xyz ,i, N);
|
||||
Lambert(_Udon_LightPositions[LightCounter].xyz ,i, N);
|
||||
|
||||
LightTypeCalculations(_LightColors, LightCounter, i, 1, dIntensity, _LightPositions[LightCounter].a, _LightPositions[LightCounter].xyz);
|
||||
LightTypeCalculations(_Udon_LightColors, LightCounter, i, 1, dIntensity, _Udon_LightPositions[LightCounter].a, _Udon_LightPositions[LightCounter].xyz);
|
||||
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ Shader "DeMuenu/World/Hoppou/Water"
|
||||
float3 R = reflect(-V, N);
|
||||
float spec = pow(saturate(dot(R, L)), _SpecPower);
|
||||
//return float4(spec, spec, spec,1);
|
||||
dmax.rgb += _LightColors[LightCounter].rgb * contrib + _LightColors[LightCounter].rgb * _SpecIntensity * spec * contrib;
|
||||
dmax.rgb += _Udon_LightColors[LightCounter].rgb * contrib + _Udon_LightColors[LightCounter].rgb * _SpecIntensity * spec * contrib;
|
||||
dmax.a -= _SpecIntensity * spec;
|
||||
//dmax = dmax + contrib * float4(LightColor, 1); // accumulate light contributions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user