Skip to content

Commit

Permalink
Merge pull request #7957 from Unity-Technologies/internal/2023.1/staging
Browse files Browse the repository at this point in the history
Internal/2023.1/staging
  • Loading branch information
UnityAljosha authored Sep 5, 2023
2 parents 88fab8a + bf592bb commit 24c2b65
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ public void BindAPVRuntimeResources(CommandBuffer cmdBuffer, bool isProbeVolumeE

if (needToBindNeutral)
{
// Lazy init the empty buffer
// Lazy init the empty buffer. We use sizeof(uint3) so that this buffer can be
// used with uint and uint3 bindings without triggering validation errors.
if (m_EmptyIndexBuffer == null)
{
// Size doesn't really matter here, anything can be bound as long is a valid compute buffer.
m_EmptyIndexBuffer = new ComputeBuffer(1, sizeof(uint), ComputeBufferType.Structured);
}
m_EmptyIndexBuffer = new ComputeBuffer(1, sizeof(uint) * 3, ComputeBufferType.Structured);

cmdBuffer.SetGlobalBuffer(ShaderIDs._APVResIndex, m_EmptyIndexBuffer);
cmdBuffer.SetGlobalBuffer(ShaderIDs._APVResCellIndices, m_EmptyIndexBuffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ private unsafe void BuildVisibleLightEntities(in CullingResults cullResults)
m_Size = cullResults.visibleLights.Length;

//TODO: this should be accelerated by a c++ API
var defaultEntity = HDLightRenderDatabase.instance.GetDefaultLightEntity();
for (int i = 0; i < cullResults.visibleLights.Length; ++i)
{
Light light = cullResults.visibleLights[i].light;
Expand All @@ -69,7 +68,7 @@ private unsafe void BuildVisibleLightEntities(in CullingResults cullResults)
}
// This can happen if a scene is created via new asset creation vs proper scene creation dialog. In this situation we create a default additional light data.
// This is bad, but should happen *extremely* rarely and all the entities will 99.9% of the time end up in the branch above.
else if (light != null && light.type == LightType.Directional)
else
{
var hdLightData = light.gameObject.AddComponent<HDAdditionalLightData>();
if (hdLightData)
Expand All @@ -78,9 +77,10 @@ private unsafe void BuildVisibleLightEntities(in CullingResults cullResults)
}
if (!hdLightData.lightEntity.valid)
hdLightData.CreateHDLightRenderEntity(autoDestroy: true);

// Make sure we have a valid data index
dataIndex = HDLightRenderDatabase.instance.GetEntityDataIndex(hdLightData.lightEntity);
}
else
dataIndex = HDLightRenderDatabase.instance.GetEntityDataIndex(defaultEntity);
}

m_VisibleLightEntityDataIndices[i] = dataIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ ${VFXBegin:VFXPassForwardLitAdditionalPragma}
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
#pragma multi_compile_fragment _ _SHADOWS_SOFT
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile _ _FORWARD_PLUS
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
#pragma multi_compile_fog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,19 @@ half3 VertexLighting(float3 positionWS, half3 normalWS)

#ifdef _ADDITIONAL_LIGHTS_VERTEX
uint lightsCount = GetAdditionalLightsCount();
uint meshRenderingLayers = GetMeshRenderingLayer();

LIGHT_LOOP_BEGIN(lightsCount)
Light light = GetAdditionalLight(lightIndex, positionWS);

#ifdef _LIGHT_LAYERS
if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
#endif
{
half3 lightColor = light.color * light.distanceAttenuation;
vertexLightColor += LightingLambert(lightColor, light.direction, normalWS);
}

LIGHT_LOOP_END
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ Shader "Universal Render Pipeline/Complex Lit"
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile _ _FORWARD_PLUS
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
#pragma multi_compile_fragment _ _SHADOWS_SOFT
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _FORWARD_PLUS
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ Shader "Universal Render Pipeline/Lit"
#pragma multi_compile_fragment _ _SHADOWS_SOFT
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile _ _FORWARD_PLUS
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ Shader "Universal Render Pipeline/Nature/SpeedTree7"
#pragma multi_compile_fragment _ _SHADOWS_SOFT
#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile_vertex LOD_FADE_PERCENTAGE
#pragma multi_compile_fragment _ DEBUG_DISPLAY
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile _ _FORWARD_PLUS
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ Shader "Universal Render Pipeline/Nature/SpeedTree8"

#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile _ _FORWARD_PLUS
#pragma multi_compile_vertex LOD_FADE_PERCENTAGE
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
#pragma multi_compile_fragment _ _SHADOWS_SOFT
#pragma multi_compile _ _FORWARD_PLUS
#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile_vertex LOD_FADE_PERCENTAGE
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ Shader "Universal Render Pipeline/Simple Lit"
#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile _ _FORWARD_PLUS
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _SHADOWS_SOFT
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _FORWARD_PLUS
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ Shader "Universal Render Pipeline/Terrain/Lit"
// Universal Pipeline keywords
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile _ _FORWARD_PLUS
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
#pragma multi_compile_fragment _ _SHADOWS_SOFT
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _FORWARD_PLUS
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"

// -------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ Shader "Hidden/Universal Render Pipeline/Terrain/Lit (Add Pass)"
// Universal Pipeline keywords
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile _ _FORWARD_PLUS
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
#pragma multi_compile_fragment _ _SHADOWS_SOFT
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _FORWARD_PLUS

// -------------------------------------
// Unity defined keywords
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ Shader "Hidden/Universal Render Pipeline/Terrain/Lit (Base Pass)"
// Universal Pipeline keywords
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile _ _FORWARD_PLUS
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
#pragma multi_compile_fragment _ _SHADOWS_SOFT
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _FORWARD_PLUS

// -------------------------------------
// Unity defined keywords
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ Shader "Hidden/TerrainEngine/Details/UniversalPipeline/WavingDoublePass"
// Universal Pipeline keywords
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _SHADOWS_SOFT
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile _ _FORWARD_PLUS
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _SHADOWS_SOFT
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _FORWARD_PLUS
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"

// -------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ Shader "Hidden/Universal Render Pipeline/StencilDeferred"
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
#pragma multi_compile_fragment _ _DEFERRED_MIXED_LIGHTING
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile_fragment _ _FOVEATED_RENDERING_NON_UNIFORM_RASTER
#pragma multi_compile _ _LIGHT_LAYERS

// -------------------------------------
// Includes
Expand Down Expand Up @@ -198,10 +198,10 @@ Shader "Hidden/Universal Render Pipeline/StencilDeferred"
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
#pragma multi_compile_fragment _ _DEFERRED_MIXED_LIGHTING
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile_fragment _ _FOVEATED_RENDERING_NON_UNIFORM_RASTER
#pragma multi_compile _ _LIGHT_LAYERS

// -------------------------------------
// Includes
Expand Down Expand Up @@ -265,10 +265,10 @@ Shader "Hidden/Universal Render Pipeline/StencilDeferred"
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
#pragma multi_compile_fragment _ _DEFERRED_MIXED_LIGHTING
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile_fragment _ _FOVEATED_RENDERING_NON_UNIFORM_RASTER
#pragma multi_compile _ _LIGHT_LAYERS

// -------------------------------------
// Includes
Expand Down Expand Up @@ -322,6 +322,7 @@ Shader "Hidden/Universal Render Pipeline/StencilDeferred"

// -------------------------------------
// Universal Pipeline keywords
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile_fragment _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile_fragment _ _DEFERRED_MAIN_LIGHT
#pragma multi_compile_fragment _ _DEFERRED_FIRST_LIGHT
Expand All @@ -332,7 +333,6 @@ Shader "Hidden/Universal Render Pipeline/StencilDeferred"
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
#pragma multi_compile_fragment _ _DEFERRED_MIXED_LIGHTING
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile_fragment _ _FOVEATED_RENDERING_NON_UNIFORM_RASTER
Expand Down

0 comments on commit 24c2b65

Please sign in to comment.