Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ Shader "Toon" {

#endif
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile _ _LIGHT_LAYERS

#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
// -------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ Shader "Toon(Tessellation)" {

#endif
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile _ _LIGHT_LAYERS

#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
// -------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@
half4 distanceAndSpotAttenuation = _AdditionalLightsBuffer[perObjectLightIndex].attenuation;
half4 spotDirection = _AdditionalLightsBuffer[perObjectLightIndex].spotDirection;
#ifdef _LIGHT_LAYERS
uint lightLayerMask = _AdditionalLightsBuffer[perObjectLightIndex].layerMask;
uint lightLayerMask = asuint(_AdditionalLightsBuffer[perObjectLightIndex].layerMask);
#endif
half4 lightOcclusionProbeInfo = _AdditionalLightsBuffer[perObjectLightIndex].occlusionProbeChannels;
#else
Expand Down Expand Up @@ -429,12 +429,19 @@
}


#ifdef _LIGHT_LAYERS
#define INIT_LIGHT_LAYER(utslight) utslight.layerMask = 0
#else
#define INIT_LIGHT_LAYER(utslight)
#endif

#define INIT_UTSLIGHT(utslight) \
utslight.direction = 0; \
utslight.color = 0; \
utslight.distanceAttenuation = 0; \
utslight.shadowAttenuation = 0; \
utslight.type = 0
utslight.type = 0; \
INIT_LIGHT_LAYER(utslight);


int DetermineUTS_MainLightIndex(float3 posW, float4 shadowCoord, float4 positionCS)
Expand All @@ -444,6 +451,27 @@

int mainLightIndex = MAINLIGHT_NOT_FOUND;
UtsLight nextLight = GetUrpMainUtsLight(shadowCoord, positionCS);

#ifdef _LIGHT_LAYERS
if (IsMatchingLightLayer(nextLight.layerMask, GetMeshRenderingLayer()) && !IsMatchingLightLayer(mainLight.layerMask, GetMeshRenderingLayer()) )
{
mainLight = nextLight;
mainLightIndex = MAINLIGHT_IS_MAINLIGHT;
}
int lightCount = _AdditionalLightsCount.x;

for (int ii = 0; ii < lightCount; ++ii)
{
nextLight = GetAdditionalUtsLight(ii, posW, positionCS);
if (IsMatchingLightLayer(nextLight.layerMask, GetMeshRenderingLayer()) && !IsMatchingLightLayer(mainLight.layerMask, GetMeshRenderingLayer()) )
{

mainLight = nextLight;
mainLightIndex = ii;
break;
}
}
#else
if (nextLight.distanceAttenuation > mainLight.distanceAttenuation && nextLight.type == 0)
{
mainLight = nextLight;
Expand All @@ -453,13 +481,14 @@
for (int ii = 0; ii < lightCount; ++ii)
{
nextLight = GetAdditionalUtsLight(ii, posW, positionCS);
if (nextLight.distanceAttenuation > mainLight.distanceAttenuation && nextLight.type == 0)
if (mainLightIndex == MAINLIGHT_NOT_FOUND ? 1: nextLight.distanceAttenuation > mainLight.distanceAttenuation && nextLight.type == 0 )
{

mainLight = nextLight;
mainLightIndex = ii;
}
}

#endif
return mainLightIndex;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
UtsLight mainLight = GetMainUtsLightByID(i.mainLightID, i.posWorld.xyz, inputData.shadowCoord, i.positionCS);

#if defined(_LIGHT_LAYERS)
uint meshRenderingLayers = GetMeshRenderingLayer();
const uint meshRenderingLayers = GetMeshRenderingLayer();
#endif

half3 mainLightColor = GetLightColor(
Expand Down Expand Up @@ -281,7 +281,9 @@
{
FORWARD_PLUS_SUBTRACTIVE_LIGHT_CHECK
int iLight = lightIndex;
// if (iLight != i.mainLightID)
#if _LIGHT_LAYERS
if (iLight != i.mainLightID)
#endif
{
float notDirectional = 1.0f; //_WorldSpaceLightPos0.w of the legacy code.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@
for (uint loopCounter = 0; loopCounter < min(URP_FP_DIRECTIONAL_LIGHTS_COUNT, MAX_VISIBLE_LIGHTS); loopCounter++)
{
int iLight = loopCounter;
// if (iLight != i.mainLightID)
#if _LIGHT_LAYERS
if (iLight != i.mainLightID)
#endif
{
float notDirectional = 1.0f; //_WorldSpaceLightPos0.w of the legacy code.
UtsLight additionalLight = GetUrpMainUtsLight(0,0);
Expand Down