mirror of
https://github.com/DeMuenu/MoonlightVRC.git
synced 2026-05-06 10:22:20 +00:00
optimisations from gemini (not tested)
This commit is contained in:
@@ -1,24 +1,26 @@
|
||||
#ifndef LightTypeCalculations
|
||||
#define LightTypeCalculations(_Udon_LightColors ,LightCounter, i, NdotL, dIntensity, radius, Lightposition) \
|
||||
float invSqMul = max(1e-4, _InverseSqareMultiplier); \
|
||||
half typeId = _Udon_LightType[LightCounter]; \
|
||||
\
|
||||
if(_Udon_LightType[LightCounter] == 0) \
|
||||
if(typeId == 0) \
|
||||
{ \
|
||||
contrib = _Udon_LightColors[LightCounter].a / max(1e-4, max(0, max(1, distanceFromLight - radius) * invSqMul) * max(0, max(1, distanceFromLight - radius) * invSqMul)); \
|
||||
float distAtten = max(1.0, distanceFromLight - radius) * invSqMul; \
|
||||
contrib = _Udon_LightColors[LightCounter].a / max(1e-4, distAtten * distAtten); \
|
||||
\
|
||||
dIntensity += contrib; \
|
||||
} \
|
||||
else if (_Udon_LightType[LightCounter] == 1) \
|
||||
else if (typeId == 1) \
|
||||
{ \
|
||||
float invSq = _Udon_LightColors[LightCounter].a / max(1e-4, (distanceFromLight * invSqMul) * (distanceFromLight * invSqMul)); \
|
||||
float distAtten = distanceFromLight * invSqMul; \
|
||||
float invSq = _Udon_LightColors[LightCounter].a / max(1e-4, distAtten * distAtten); \
|
||||
\
|
||||
contrib = dot(normalize(i.worldPos - Lightposition), normalize(_Udon_LightDirections[LightCounter].xyz)); \
|
||||
contrib = dot(-L, normalize(_Udon_LightDirections[LightCounter].xyz)); \
|
||||
contrib = smoothstep(radius,_Udon_LightDirections[LightCounter].w, contrib); \
|
||||
\
|
||||
contrib = contrib * invSq; \
|
||||
dIntensity += contrib; \
|
||||
} \
|
||||
float3 LightColor = _Udon_LightColors[LightCounter].xyz; \
|
||||
half3 LightColor = _Udon_LightColors[LightCounter].xyz; \
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user