浏览代码

merged master

/main
Filip Iliescu 8 年前
当前提交
8eef028b
共有 75 个文件被更改,包括 1524 次插入204 次删除
  1. 1
      .gitmodules
  2. 14
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/Resources/DebugDisplayShadowMap.shader
  3. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/Resources/DebugViewTiles.shader
  4. 65
      Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  5. 7
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop.cs
  6. 59
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  7. 7
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.hlsl
  8. 12
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Utilities.cs
  9. 6
      Assets/ScriptableRenderPipeline/LowEndMobilePipeline/LowEndMobilePipelineAsset.cs
  10. 2
      Assets/ScriptableRenderPipeline/ShaderLibrary/Shadow/Shadow.hlsl
  11. 5
      Assets/ScriptableRenderPipeline/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl
  12. 2
      Assets/ScriptableRenderPipeline/fptl/LightingConvexHullUtils.hlsl
  13. 2
      Assets/ScriptableRenderPipeline/fptl/LightingUtils.hlsl
  14. 16
      Assets/ScriptableRenderPipeline/fptl/lightlistbuild-bigtile.compute
  15. 22
      Assets/ScriptableRenderPipeline/fptl/lightlistbuild-clustered.compute
  16. 23
      Assets/ScriptableRenderPipeline/fptl/lightlistbuild.compute
  17. 44
      Assets/ScriptableRenderPipeline/fptl/scrbound.compute
  18. 32
      Assets/TestScenes/Common/Scripts/MiniProfiler.cs
  19. 145
      Assets/TestScenes/HDTest/HDRenderLoopTest.unity
  20. 4
      Assets/TestScenes/HDTest/NewBatcherTest.meta
  21. 4
      Assets/TestScenes/HDTest/NewBatcherTest/Prefabs/Capsule.prefab
  22. 4
      Assets/TestScenes/HDTest/NewBatcherTest/Prefabs/Cube.prefab
  23. 4
      Assets/TestScenes/HDTest/NewBatcherTest/Prefabs/Cylinder.prefab
  24. 4
      Assets/TestScenes/HDTest/NewBatcherTest/Prefabs/Sphere.prefab
  25. 6
      Assets/TestScenes/HDTest/NewBatcherTest/matbench_2.mat
  26. 10
      ProjectSettings/EditorBuildSettings.asset
  27. 9
      ProjectSettings/ProjectSettings.asset
  28. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources/BlitCubemap.shader
  29. 2
      Assets/ScriptableRenderPipeline/Core/Debugging/DebugItemDrawer.cs
  30. 8
      Assets/ScriptableRenderPipeline/Core/Shadow/VectorArray.cs
  31. 13
      Assets/ScriptableRenderPipeline/Core/Shadow/ShadowBase.cs
  32. 63
      Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs
  33. 1001
      Assets/TestScenes/HDTest/MultipleShadowsTest.unity
  34. 8
      Assets/TestScenes/HDTest/MultipleShadowsTest.unity.meta
  35. 8
      Assets/TestScenes/HDTest/NewBatcherBench2.unity.meta
  36. 41
      Assets/TestScenes/HDTest/NewBatcherTest/Mover.cs
  37. 12
      Assets/TestScenes/HDTest/NewBatcherTest/Mover.cs.meta
  38. 9
      Assets/TestScenes/HDTest/PostProcess Profiles.meta
  39. 9
      Assets/ScriptableRenderPipeline/Core/Resources.meta
  40. 14
      Assets/TestScenes/HDTest/PostProcess Profiles/Main Camera Profile.asset
  41. 9
      Assets/TestScenes/HDTest/PostProcess Profiles/Main Camera Profile.asset.meta
  42. 9
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Shadow.meta
  43. 9
      Assets/ScriptableRenderPipeline/common.meta
  44. 0
      /Assets/ScriptableRenderPipeline/BasicRenderPipeline
  45. 0
      /Assets/ScriptableRenderPipeline/BasicRenderPipeline.meta
  46. 0
      /Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/SSSProfile.meta
  47. 0
      /Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/SSSProfile
  48. 0
      /Assets/ScriptableRenderPipeline/Core/AdditionalLightData.cs.meta
  49. 0
      /Assets/ScriptableRenderPipeline/Core/AdditionalLightData.cs
  50. 0
      /Assets/ScriptableRenderPipeline/Fptl/ShaderBase.h.meta
  51. 0
      /Assets/ScriptableRenderPipeline/Core/TextureCache.cs.meta
  52. 0
      /Assets/ScriptableRenderPipeline/Fptl/SkyboxHelper.cs.meta
  53. 0
      /Assets/ScriptableRenderPipeline/Core/TextureSettings.cs.meta
  54. 0
      /Assets/ScriptableRenderPipeline/Core/Resources/CubeToPano.shader.meta
  55. 0
      /Assets/ScriptableRenderPipeline/Core/TextureSettings.cs
  56. 0
      /Assets/ScriptableRenderPipeline/Core/Camera.meta
  57. 0
      /Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources/BlitCubemap.shader.meta
  58. 0
      /Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources/BlitCubemap.shader
  59. 0
      /Assets/ScriptableRenderPipeline/Fptl/ShaderBase.h
  60. 0
      /Assets/ScriptableRenderPipeline/Fptl/SkyboxHelper.cs
  61. 0
      /Assets/ScriptableRenderPipeline/Core/Camera
  62. 0
      /Assets/ScriptableRenderPipeline/Core/Resources/CubeToPano.shader
  63. 0
      /Assets/ScriptableRenderPipeline/Core/Debugging.meta
  64. 0
      /Assets/ScriptableRenderPipeline/Core/Debugging
  65. 0
      /Assets/ScriptableRenderPipeline/Core/Shadow.meta
  66. 0
      /Assets/ScriptableRenderPipeline/Core/Shadow
  67. 0
      /Assets/ScriptableRenderPipeline/Core/TextureCache.cs

1
.gitmodules


[submodule "Assets/TestScenes/Big"]
path = Assets/TestScenes/Big
url = https://github.com/Unity-Technologies/ScriptableRenderLoopScenes
[submodule "Assets/ScriptableRenderPipeline/PostProcessing"]
path = Assets/ScriptableRenderPipeline/PostProcessing
url = https://github.com/Unity-Technologies/PostProcessing

14
Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/Resources/DebugDisplayShadowMap.shader


#include "../../../ShaderLibrary/Common.hlsl"
TEXTURE2D_FLOAT(g_tShadowBuffer);
#define SHADOW_TILEPASS // TODO: Not sure it must be define, ask uygar
#include "../../../ShaderLibrary/Shadow/Shadow.hlsl"
#undef SHADOW_TILEPASS
TEXTURE2D(_DummyTexture);
SAMPLER2D(sampler_DummyTexture);
SamplerState ltc_linear_clamp_sampler;
float4 _TextureScaleBias;

float4 Frag(Varyings input) : SV_Target
{
// We need the dummy texture for the sampler, but we also need to sample it in order not to get a compile error.
float4 dummy = SAMPLE_TEXTURE2D(_DummyTexture, sampler_DummyTexture, input.texcoord) * 0.00001;
return SAMPLE_TEXTURE2D(g_tShadowBuffer, sampler_DummyTexture, input.texcoord).xxxx + dummy;
ShadowContext shadowContext = InitShadowContext();
// Caution: ShadowContext is define in Shadowcontext.hlsl for current render pipeline. This shader must be in sync with its content else it doesn't work.
return SAMPLE_TEXTURE2D_ARRAY(_ShadowmapExp_PCF, ltc_linear_clamp_sampler, input.texcoord, 0).xxxx;
}
ENDHLSL

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/Resources/DebugViewTiles.shader


// Highlight selected tile
if (all(mouseTileCoord == tileCoord))
{
bool border = any(offsetInTile == 0 || offsetInTile == GetTileSize() - 1);
bool border = any(offsetInTile == 0 || offsetInTile == (int)GetTileSize() - 1);
float4 result2 = float4(1.0, 1.0, 1.0, border ? 1.0 : 0.5);
result = AlphaBlend(result, result2);
}

65
Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


get { return m_DefaultDiffuseMaterial; }
private set { m_DefaultDiffuseMaterial = value; }
}
public Shader DefaultShader
{
get { return m_DefaultShader; }
private set { m_DefaultShader = value; }
}
public override Shader GetDefaultShader()
{
return m_DefaultShader;

readonly Material m_FilterSubsurfaceScattering;
readonly Material m_FilterAndCombineSubsurfaceScattering;
private Material m_DebugDisplayShadowMap;
private Material m_DebugViewMaterialGBuffer;
private Material m_DebugDisplayLatlong;

void InitializeDebugMaterials()
{
m_DebugDisplayShadowMap = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugDisplayShadowMap");
m_DebugViewMaterialGBuffer = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugViewMaterialGBuffer");
m_DebugDisplayLatlong = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugDisplayLatlong");
}

m_LitRenderLoop.Cleanup();
Utilities.Destroy(m_DebugDisplayShadowMap);
Utilities.Destroy(m_DebugViewMaterialGBuffer);
Utilities.Destroy(m_DebugDisplayLatlong);

// Forward opaque with deferred/cluster tile require that we fill the depth buffer
// correctly to build the light list.
// TODO: avoid double lighting by tagging stencil or gbuffer that we must not lit.
RenderForwardOnlyOpaqueDepthPrepass(cullResults, camera, renderContext);
RenderGBuffer(cullResults, camera, renderContext);

{
if (m_LightLoop != null)
{
using (new Utilities.ProfilingSample("Build Light list", renderContext))
using (new Utilities.ProfilingSample("Build Light list and render shadows", renderContext))
{
m_LightLoop.PrepareLightsForGPU(m_Owner.shadowSettings, cullResults, camera);
m_LightLoop.RenderShadows(renderContext, cullResults);

}
}
void NextOverlayCoord(ref float x, ref float y, float overlaySize, float width)
{
x += overlaySize;
// Go to next line if it goes outside the screen.
if (x + overlaySize > width)
{
x = 0;
y -= overlaySize;
}
}
void RenderDebugOverlay(Camera camera, ScriptableRenderContext renderContext)
{

LightingDebugSettings lightingDebug = debugDisplaySettings.lightingDebugSettings;
if (lightingDebug.shadowDebugMode != ShadowMapDebugMode.None)
{
if (lightingDebug.shadowDebugMode == ShadowMapDebugMode.VisualizeShadowMap)
{
#if SHADOWS_OLD
uint visualizeShadowIndex = Math.Min(lightingDebug.shadowMapIndex, (uint)(GetCurrentShadowCount() - 1));
ShadowLight shadowLight = m_ShadowsResult.shadowLights[visualizeShadowIndex];
for (int slice = 0; slice < shadowLight.shadowSliceCount; ++slice)
{
ShadowSliceData sliceData = m_ShadowsResult.shadowSlices[shadowLight.shadowSliceIndex + slice];
Vector4 texcoordScaleBias = new Vector4((float)sliceData.shadowResolution / m_Owner.shadowSettings.shadowAtlasWidth,
(float)sliceData.shadowResolution / m_Owner.shadowSettings.shadowAtlasHeight,
(float)sliceData.atlasX / m_Owner.shadowSettings.shadowAtlasWidth,
(float)sliceData.atlasY / m_Owner.shadowSettings.shadowAtlasHeight);
propertyBlock.SetVector("_TextureScaleBias", texcoordScaleBias);
debugCB.SetViewport(new Rect(x, y, overlaySize, overlaySize));
debugCB.DrawProcedural(Matrix4x4.identity, m_DebugDisplayShadowMap, 0, MeshTopology.Triangles, 3, 1, propertyBlock);
NextOverlayCoord(ref x, ref y, overlaySize, camera.pixelWidth);
}
#endif
}
else if (lightingDebug.shadowDebugMode == ShadowMapDebugMode.VisualizeAtlas)
{
propertyBlock.SetVector("_TextureScaleBias", new Vector4(1.0f, 1.0f, 0.0f, 0.0f));
debugCB.SetViewport(new Rect(x, y, overlaySize, overlaySize));
debugCB.DrawProcedural(Matrix4x4.identity, m_DebugDisplayShadowMap, 0, MeshTopology.Triangles, 3, 1, propertyBlock);
NextOverlayCoord(ref x, ref y, overlaySize, camera.pixelWidth);
}
}
if (lightingDebug.displaySkyReflection)
{
Texture skyReflection = m_SkyManager.skyReflection;

debugCB.DrawProcedural(Matrix4x4.identity, m_DebugDisplayLatlong, 0, MeshTopology.Triangles, 3, 1, propertyBlock);
NextOverlayCoord(ref x, ref y, overlaySize, camera.pixelWidth);
Utilities.NextOverlayCoord(ref x, ref y, overlaySize, camera.pixelWidth);
if (m_LightLoop != null)
m_LightLoop.RenderDebugOverlay(camera, renderContext, debugDisplaySettings, ref x, ref y, overlaySize, camera.pixelWidth);
}
void InitAndClearBuffer(Camera camera, ScriptableRenderContext renderContext)

7
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop.cs


using UnityEngine;
using UnityEngine;
using UnityEngine.Rendering;
namespace UnityEngine.Experimental.Rendering.HDPipeline

public virtual void NewFrame() {}
public virtual int GetCurrentShadowCount() { return 0; }
public virtual void BuildGPULightLists(Camera camera, ScriptableRenderContext loop, RenderTargetIdentifier cameraDepthBufferRT) {}
public virtual void BuildGPULightLists(Camera camera, ScriptableRenderContext renderContext, RenderTargetIdentifier cameraDepthBufferRT) {}
public virtual void RenderDeferredLighting( HDCamera hdCamera, ScriptableRenderContext renderContext,
DebugDisplaySettings debugDisplaySettings,

public virtual void RenderLightingDebug(HDCamera hdCamera, ScriptableRenderContext renderContext, RenderTargetIdentifier colorBuffer) {}
public Light GetCurrentSunLight() { return m_CurrentSunLight; }
public virtual void RenderDebugOverlay(Camera camera, ScriptableRenderContext renderContext, DebugDisplaySettings debugDisplaySettings, ref float x, ref float y, float overlaySize, float width) { }
}
}

59
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


using UnityEngine.Rendering;
using UnityEngine.Rendering;
using System.Collections.Generic;
using System;

Material m_SingleDeferredMaterialSRT = null;
Material m_SingleDeferredMaterialMRT = null;
// For displaying shadow map
private Material m_DebugDisplayShadowMap;
// shadow related stuff
FrameId m_FrameId = new FrameId();
ShadowSetup m_ShadowSetup; // doesn't actually have to reside here, it would be enough to pass the IShadowManager in from the outside

m_SingleDeferredMaterialMRT.SetInt("_SrcBlend", (int)BlendMode.One);
m_SingleDeferredMaterialMRT.SetInt("_DstBlend", (int)BlendMode.Zero);
m_DebugDisplayShadowMap = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugDisplayShadowMap");
m_DefaultTexture2DArray = new Texture2DArray(1, 1, 1, TextureFormat.ARGB32, false);
m_DefaultTexture2DArray.SetPixels32(new Color32[1] { new Color32(128, 128, 128, 128) }, 0);
m_DefaultTexture2DArray.Apply();

Utilities.Destroy(m_SingleDeferredMaterialSRT);
Utilities.Destroy(m_SingleDeferredMaterialMRT);
Utilities.Destroy(m_DebugDisplayShadowMap);
Utilities.Destroy(s_DefaultAdditionalLightDataGameObject);
s_DefaultAdditionalLightDataGameObject = null;
s_DefaultAdditionalLightData = null;

float ComputeLinearDistanceFade(float distanceToCamera, float fadeDistance)
{
// Fade with distance calculation is just a linear fade from 90% of fade distance to fade distance. 90% arbitrarly chosen but should work well enough.
// Fade with distance calculation is just a linear fade from 90% of fade distance to fade distance. 90% arbitrarily chosen but should work well enough.
float distanceFadeNear = 0.9f * fadeDistance;
return 1.0f - Mathf.Clamp01((distanceToCamera - distanceFadeNear) / (fadeDistance - distanceFadeNear));
}

}
float oldSpecularGlobalDimmer = m_PassSettings.specularGlobalDimmer;
// Change some parameters in case of "special" rendering (can be preview, reflection, etc.
// Change some parameters in case of "special" rendering (can be preview, reflection, etc.)
// 1. Count the number of lights and sort all light by category, type and volume
// 1. Count the number of lights and sort all lights by category, type and volume - This is required for the fptl/cluster shader code
// If we reach maximum of lights available on screen, then we discard the light.
// Lights are processed in order, so we don't discards light based on their importance but based on their ordering in visible lights list.
int directionalLightcount = 0;
int punctualLightcount = 0;
int areaLightCount = 0;

// For now we will still apply the maximum of shadow here but we don't apply the sorting by priority + slot allocation yet
m_CurrentSunLight = null;
// 2. Go thought all lights, convert them to GPU format.
// 2. Go through all lights, convert them to GPU format.
// Create simultaneously data for culling (LigthVolumeData and rendering)
var worldToView = WorldToCamera(camera);

cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_GBufferTexture1", Shader.PropertyToID("_GBufferTexture1"));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_GBufferTexture2", Shader.PropertyToID("_GBufferTexture2"));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_GBufferTexture3", Shader.PropertyToID("_GBufferTexture3"));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "g_tShadowBuffer", Shader.PropertyToID("g_tShadowBuffer"));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_LtcData", Shader.GetGlobalTexture(Shader.PropertyToID("_LtcData")));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_PreIntegratedFGD", Shader.GetGlobalTexture("_PreIntegratedFGD"));

renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
public override void RenderDebugOverlay(Camera camera, ScriptableRenderContext renderContext, DebugDisplaySettings debugDisplaySettings, ref float x, ref float y, float overlaySize, float width)
{
LightingDebugSettings lightingDebug = debugDisplaySettings.lightingDebugSettings;
if (lightingDebug.shadowDebugMode != ShadowMapDebugMode.None)
{
if (lightingDebug.shadowDebugMode == ShadowMapDebugMode.VisualizeShadowMap)
{
m_ShadowMgr.DisplayShadows(renderContext, m_DebugDisplayShadowMap, (int)lightingDebug.shadowMapIndex, x, y, overlaySize, overlaySize);
Utilities.NextOverlayCoord(ref x, ref y, overlaySize, camera.pixelWidth);
// TODO: @Julien exchange shadowmapIndex by lightIndex and draw all slide like below
/*
for (int slice = 0; slice < shadowLight.shadowSliceCount; ++slice)
{
ShadowSliceData sliceData = m_ShadowsResult.shadowSlices[shadowLight.shadowSliceIndex + slice];
Vector4 texcoordScaleBias = new Vector4((float)sliceData.shadowResolution / m_Owner.shadowSettings.shadowAtlasWidth,
(float)sliceData.shadowResolution / m_Owner.shadowSettings.shadowAtlasHeight,
(float)sliceData.atlasX / m_Owner.shadowSettings.shadowAtlasWidth,
(float)sliceData.atlasY / m_Owner.shadowSettings.shadowAtlasHeight);
propertyBlock.SetVector("_TextureScaleBias", texcoordScaleBias);
debugCB.SetViewport(new Rect(x, y, overlaySize, overlaySize));
debugCB.DrawProcedural(Matrix4x4.identity, m_DebugDisplayShadowMap, 0, MeshTopology.Triangles, 3, 1, propertyBlock);
Utilities.NextOverlayCoord(ref x, ref y, overlaySize, camera.pixelWidth);
}
*/
}
else if (lightingDebug.shadowDebugMode == ShadowMapDebugMode.VisualizeAtlas)
{
m_ShadowMgr.DisplayShadows(renderContext, m_DebugDisplayShadowMap, -1, x, y, overlaySize, overlaySize);
Utilities.NextOverlayCoord(ref x, ref y, overlaySize, camera.pixelWidth);
}
}
}
}
}

7
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.hlsl


StructuredBuffer<EnvLightData> _EnvLightDatas;
StructuredBuffer<ShadowData> _ShadowDatas;
// Use texture atlas for shadow map
//TEXTURE2D(_ShadowAtlas);
//SAMPLER2D_SHADOW(sampler_ShadowAtlas);
//SAMPLER2D(sampler_ManualShadowAtlas); // TODO: settings sampler individually is not supported in shader yet...
TEXTURE2D(g_tShadowBuffer); // TODO: No choice, the name is hardcoded in ShadowrenderPass.cs for now. Need to change this!
SAMPLER2D_SHADOW(samplerg_tShadowBuffer);
// Use texture array for IES
//TEXTURE2D_ARRAY(_IESArray);
//SAMPLER2D(sampler_IESArray);

12
Assets/ScriptableRenderPipeline/HDRenderPipeline/Utilities.cs


// no depth target ends up being bound.
DrawFullScreen(commandBuffer, material, camera, colorBuffers, colorBuffers[0], properties, shaderPassID);
}
// Helper to help to display debug info on screen
public static void NextOverlayCoord(ref float x, ref float y, float overlaySize, float width)
{
x += overlaySize;
// Go to next line if it goes outside the screen.
if (x + overlaySize > width)
{
x = 0;
y -= overlaySize;
}
}
}
}

6
Assets/ScriptableRenderPipeline/LowEndMobilePipeline/LowEndMobilePipelineAsset.cs


private set { m_DefaultDiffuseMaterial = value; }
}
public Shader DefaultShader
{
get { return m_DefaultShader; }
private set { m_DefaultShader = value; }
}
#endregion
public override Material GetDefaultMaterial()
{

2
Assets/ScriptableRenderPipeline/ShaderLibrary/Shadow/Shadow.hlsl


#define SHADOW_SUPPORTS_DYNAMIC_INDEXING 0 // only on >= sm 5.1
#include "../../common/Shadow/ShadowBase.cs.hlsl" // ShadowData definition, auto generated (don't modify)
#include "../../Core/Shadow/ShadowBase.cs.hlsl" // ShadowData definition, auto generated (don't modify)
#include "ShadowTexFetch.hlsl" // Resource sampling definitions (don't modify)
// Declares a shadow context struct with members and sampling code based on whether _...Slots > 0

5
Assets/ScriptableRenderPipeline/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl


/* load the right shadow data for the current face */ \
float4 dirShadowSplitSpheres[4]; \
uint payloadOffset = EvalShadow_LoadSplitSpheres( shadowContext, index, dirShadowSplitSpheres ); \
uint shadowSplitIndex = EvalShadow_GetSplitSphereIndexForDirshadows( positionWS, dirShadowSplitSpheres ); \
int shadowSplitIndex = EvalShadow_GetSplitSphereIndexForDirshadows( positionWS, dirShadowSplitSpheres ); \
if( shadowSplitIndex < 0 ) \
return 1.0; \
\
ShadowData sd = shadowContext.shadowDatas[index + 1 + shadowSplitIndex]; \
/* normal based bias */ \
positionWS += EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), sd.texelSizeRcp.zw, sd.normalBias ); \

2
Assets/ScriptableRenderPipeline/fptl/LightingConvexHullUtils.hlsl


#define __LIGHTINGCONVEXHULLUTILS_H__
#include "..\common\ShaderBase.h"
#include "ShaderBase.h"
#include "LightDefinitions.cs.hlsl"

2
Assets/ScriptableRenderPipeline/fptl/LightingUtils.hlsl


#define __LIGHTINGUTILS_H__
#include "..\common\ShaderBase.h"
#include "ShaderBase.h"
#include "LightDefinitions.cs.hlsl"

16
Assets/ScriptableRenderPipeline/fptl/lightlistbuild-bigtile.compute


#pragma kernel BigTileLightListGen
#include "..\common\ShaderBase.h"
#include "ShaderBase.h"
#include "LightDefinitions.cs.hlsl"
#include "LightingConvexHullUtils.hlsl"

float onePixDiagDist = GetOnePixDiagWorldDistAtDepthOne();
float halfTileSizeAtZDistOne = 32*onePixDiagDist; // scale by half a tile
if( !DoesSphereOverlapTile(V, halfTileSizeAtZDistOne, lgtDat.center.xyz, lgtDat.radius) )
lightsListLDS[l]=0xffffffff;
}

[branch]if(canEnter)
{
SFiniteLightBound lgtDat = g_data[idxCoarse];
const float3 boxX = lgtDat.boxAxisX.xyz;
const float3 boxY = lgtDat.boxAxisY.xyz;
const float3 boxZ = -lgtDat.boxAxisZ.xyz; // flip axis (so it points away from the light direction for a spot-light)

int idx_cur=0, idx_twin=0;
float3 vP0, vE0;
GetHullEdge(idx_cur, idx_twin, vP0, vE0, e0, boxX, boxY, boxZ, center, scaleXY);
int positive=0, negative=0;
for(int k=1; k<8; k++) // only need to test 7 verts (technically just 6).
{

22
Assets/ScriptableRenderPipeline/fptl/lightlistbuild-clustered.compute


#pragma kernel TileLightListGen_DepthRT_MSAA_SrcBigTile LIGHTLISTGEN=TileLightListGen_DepthRT_MSAA_SrcBigTile ENABLE_DEPTH_TEXTURE_BACKPLANE MSAA_ENABLED USE_TWO_PASS_TILED_LIGHTING
#pragma kernel ClearAtomic
#include "..\common\ShaderBase.h"
#include "ShaderBase.h"
#include "LightDefinitions.cs.hlsl"
#include "LightingConvexHullUtils.hlsl"

for(int p=0; p<6; p++)
{
float4 plane = lightPlanes[6*(l&3)+p];
bool bAllInvisib = true;
for(int i=0; i<8; i++)

#endif
int iNrCoarseLights = min(lightOffs,MAX_NR_COARSE_ENTRIES);
#ifdef PERFORM_SPHERICAL_INTERSECTION_TESTS
iNrCoarseLights = SphericalIntersectionTests( t, iNrCoarseLights, float2(min(viTilLL.xy+uint2(TILE_SIZE_CLUSTERED/2,TILE_SIZE_CLUSTERED/2), uint2(iWidth-1, iHeight-1))) );
#endif

//////////////////////////////////////////////////////////
uint start = 0;
int i=(int) t;
int iSpaceAvail = 0;

float4 FetchPlane(int l, int p)
{
SFiniteLightBound lgtDat = g_data[coarseList[l]];
const float3 boxX = lgtDat.boxAxisX.xyz;
const float3 boxY = lgtDat.boxAxisY.xyz;
const float3 boxZ = -lgtDat.boxAxisZ.xyz; // flip axis (so it points away from the light direction for a spot-light)

float onePixDiagDist = GetOnePixDiagWorldDistAtDepthOne();
float halfTileSizeAtZDistOne = (TILE_SIZE_CLUSTERED/2)*onePixDiagDist; // scale by half a tile
for(int l=threadID; l<iNrCoarseLights; l+=NR_THREADS)
{
SFiniteLightBound lgtDat = g_data[coarseList[l]];

[branch]if(g_vLightData[idxCoarse].lightType!=SPHERE_LIGHT) // don't bother doing edge tests for sphere lights since these have camera aligned bboxes.
{
SFiniteLightBound lgtDat = g_data[idxCoarse];
const float3 boxX = lgtDat.boxAxisX.xyz;
const float3 boxY = lgtDat.boxAxisY.xyz;
const float3 boxZ = -lgtDat.boxAxisZ.xyz; // flip axis (so it points away from the light direction for a spot-light)

int idx_cur=0, idx_twin=0;
float3 vP0, vE0;
GetHullEdge(idx_cur, idx_twin, vP0, vE0, e0, boxX, boxY, boxZ, center, scaleXY);
int positive=0, negative=0;
for(int k=1; k<8; k++) // only need to test 7 verts (technically just 6).
{

23
Assets/ScriptableRenderPipeline/fptl/lightlistbuild.compute


#pragma kernel TileLightListGen LIGHTLISTGEN=TileLightListGen
#pragma kernel TileLightListGen_SrcBigTile LIGHTLISTGEN=TileLightListGen_SrcBigTile USE_TWO_PASS_TILED_LIGHTING
#include "..\common\ShaderBase.h"
#include "ShaderBase.h"
#include "LightDefinitions.cs.hlsl"
#include "LightingConvexHullUtils.hlsl"

float3 vTileLL = float3(viTilLL.x/(float) iWidth, viTilLL.y/(float) iHeight, asfloat(ldsZMin));
float3 vTileUR = float3((viTilLL.x+16)/(float) iWidth, (viTilLL.y+16)/(float) iHeight, asfloat(ldsZMax));
vTileUR.xy = min(vTileUR.xy,float2(1.0,1.0)).xy;
// build coarse list using AABB
#ifdef USE_TWO_PASS_TILED_LIGHTING

#endif
}
#ifdef FINE_PRUNING_ENABLED
#ifdef FINE_PRUNING_ENABLED
if(t<2) ldsDoesLightIntersect[t] = 0;
#endif

iNrCoarseLights = SphericalIntersectionTests( t, iNrCoarseLights, float2(min(viTilLL.xy+uint2(16/2,16/2), uint2(iWidth-1, iHeight-1))) );
#endif
#ifndef FINE_PRUNING_ENABLED
#ifndef FINE_PRUNING_ENABLED
{
#ifndef NARROW_MOBILE_ENABLED
if((int)t<iNrCoarseLights) prunedList[t] = coarseList[t];

GroupMemoryBarrierWithGroupSync();
#endif
int nrLightsCombinedList = min(ldsNrLightsFinal,MAX_NR_COARSE_ENTRIES);
for(int i=t; i<nrLightsCombinedList; i+=NR_THREADS)
{

float onePixDiagDist = GetOnePixDiagWorldDistAtDepthOne();
float halfTileSizeAtZDistOne = 8*onePixDiagDist; // scale by half a tile
for(l=threadID; l<iNrCoarseLights; l+=NR_THREADS)
{
SFiniteLightBound lightData = g_data[prunedList[l]];

{
SFiniteLightData lightData = g_vLightData[idxCoarse];
const bool bIsSpotDisc = (lightData.flags&IS_CIRCULAR_SPOT_SHAPE)!=0;
uint2 uPixLoc = min(uint2(viTilLL.x+(idx&0xf), viTilLL.y+(idx>>4)), uint2(iWidth-1, iHeight-1));
#ifdef NARROW_MOBILE_ENABLED
float4 vLinDepths = i<4 ? vLinDepths1 : vLinDepths2;

for(int i=0; i<numPixSerial; i++)
{
int idx = t + i*NR_THREADS;
uint2 uPixLoc = min(uint2(viTilLL.x+(idx&0xf), viTilLL.y+(idx>>4)), uint2(iWidth-1, iHeight-1));
#ifdef NARROW_MOBILE_ENABLED
float4 vLinDepths = i<4 ? vLinDepths1 : vLinDepths2;

// check pixel
float3 vLp = lightData.lightPos.xyz;
float3 toLight = vLp - vVPos;
float3 toLight = vLp - vVPos;
if(lightData.radiusSq>distSq) uVal = 1;
}

for(int i=0; i<numPixSerial; i++)
{
int idx = t + i*NR_THREADS;
uint2 uPixLoc = min(uint2(viTilLL.x+(idx&0xf), viTilLL.y+(idx>>4)), uint2(iWidth-1, iHeight-1));
#ifdef NARROW_MOBILE_ENABLED
float4 vLinDepths = i<4 ? vLinDepths1 : vLinDepths2;

44
Assets/ScriptableRenderPipeline/fptl/scrbound.compute


#pragma kernel ScreenBoundsAABB
#include "..\common\ShaderBase.h"
#include "ShaderBase.h"
#include "LightDefinitions.cs.hlsl"
uniform int g_iNrVisibLights;

void ScreenBoundsAABB(uint threadID : SV_GroupIndex, uint3 u3GroupID : SV_GroupID)
{
uint groupID = u3GroupID.x;
//uint vindex = groupID * NR_THREADS + threadID;
unsigned int g = groupID;
unsigned int t = threadID;

const int sideIndex = (int) (t%8);
const float3 boxX = lgtDat.boxAxisX.xyz;
const float3 boxY = lgtDat.boxAxisY.xyz;
const float3 boxZ = -lgtDat.boxAxisZ.xyz; // flip axis (so it points away from the light direction for a spot-light)

const unsigned int uFlag3 = GetClip(vP3);
const float4 vPnts[] = {vP0, vP1, vP2, vP3};
// screen-space AABB of one quad (assuming no intersection)
float3 vMin, vMax;
for(int k=0; k<4; k++)

fW = fS * (fWabs<FLT_EPSILON ? FLT_EPSILON : fWabs);
float3 vP = float3(vPnts[k].x/fW, vPnts[k].y/fW, vPnts[k].z/fW);
if(k==0) { vMin=vP; vMax=vP; }
vMax = max(vMax, vP); vMin = min(vMin, vP);
}

float3 vFaceMi = float3(posX[subLigt*MAX_PNTS*2 + sideIndex + 0], posY[subLigt*MAX_PNTS*2 + sideIndex + 0], posZ[subLigt*MAX_PNTS*2 + sideIndex + 0]);
float3 vFaceMa = float3(posX[subLigt*MAX_PNTS*2 + sideIndex + 6], posY[subLigt*MAX_PNTS*2 + sideIndex + 6], posZ[subLigt*MAX_PNTS*2 + sideIndex + 6]);
vMax = max(vMax, vP); vMin = min(vMin, vP);
}
}

else // :( need true clipping
{
// 4 vertices to a quad of the convex hull in post projection space
const float4 vP0 = mul(g_mProjection, float4(q0, 1));
const float4 vP1 = mul(g_mProjection, float4(q1, 1));

int iSrcIndex = 0;
int offs = iSrcIndex*MAX_PNTS+subLigt*MAX_PNTS*2;

for(int k=0; k<iNrSrcVerts; k++)
{
float4 vCur = float4(posX[offs_src+k], posY[offs_src+k], posZ[offs_src+k], posW[offs_src+k]);
}
////////////////////// look for camera frustum verts that need to be included. That is frustum vertices inside the convex hull for the light

float3 vVertPSpace = float3((i&1)!=0 ? 1 : (-1), (i&2)!=0 ? 1 : (-1), (i&4)!=0 ? 1 : 0);
float4 v4ViewSpace = mul(g_mInvProjection, float4(vVertPSpace,1));
float3 vViewSpace = float3(v4ViewSpace.x/v4ViewSpace.w, v4ViewSpace.y/v4ViewSpace.w, v4ViewSpace.z/v4ViewSpace.w);

float3 vP = float3((i&1)!=0 ? 1 : (-1), (i&2)!=0 ? 1 : (-1), (i&4)!=0 ? 1 : 0);
if(!bSetBoundYet) { vMin=vP; vMax=vP; bSetBoundYet=true; }
vMax = max(vMax, vP); vMin = min(vMin, vP);
}
}

// determine AABB bound in [-1;1]x[-1;1] screen space using bounding sphere.
// Use the result to make our already established AABB from the convex hull
// potentially tighter.

float2 vMi, vMa;
bool2 bMi, bMa;
CalcBound(bMi, bMa, vMi, vMa, g_mInvProjection, center, radius);
vMin.xy = bMi ? max(vMin.xy, vMi) : vMin.xy;
vMax.xy = bMa ? min(vMax.xy, vMa) : vMax.xy;
}

// to see if the light is occluded: vMin.z*VIEWPORT_SCALE_Z > MipTexelMaxDepth
//g_vBoundsBuffer[lgtIndex+0] = float3(0.5*vMin.x+0.5, -0.5*vMax.y+0.5, vMin.z*VIEWPORT_SCALE_Z);
//g_vBoundsBuffer[lgtIndex+g_iNrVisibLights] = float3(0.5*vMax.x+0.5, -0.5*vMin.y+0.5, vMax.z*VIEWPORT_SCALE_Z);
// changed for unity
g_vBoundsBuffer[lgtIndex+0] = float3(0.5*vMin.x+0.5, 0.5*vMin.y+0.5, vMin.z*VIEWPORT_SCALE_Z);
g_vBoundsBuffer[lgtIndex+(int) g_iNrVisibLights] = float3(0.5*vMax.x+0.5, 0.5*vMax.y+0.5, vMax.z*VIEWPORT_SCALE_Z);

++nrVertsDst;
}
}
if(bIsCurVisib)
{
//assert(nrVertsDst<MAX_PNTS);

const int index = ((uint) p)/2;
float x1 = index==0 ? vVisib.x : (index==1 ? vVisib.y : vVisib.z);
float x0 = index==0 ? vInvisib.x : (index==1 ? vInvisib.y : vInvisib.z);
//fS*((vVisib.w-vInvisib.w)*t + vInvisib.w) = (x1-x0)*t + x0;
const float fT = (fS*vInvisib.w-x0)/((x1-x0) - fS*(vVisib.w-vInvisib.w));

float4 planeY0 = TransformPlaneToPostSpace(InvProjection, float4(0, planeY.x, planeY.y, 0));
float4 planeY1 = TransformPlaneToPostSpace(InvProjection, float4(0, planeY.z, planeY.w, 0));
// convert planes to the forms (1,0,0,D) and (0,1,0,D)
// 2D bound is given by -D components
float2 A = -float2(planeX0.w / planeX0.x, planeY0.w / planeY0.y);

32
Assets/TestScenes/Common/Scripts/MiniProfiler.cs


public class MiniProfiler : MonoBehaviour {
public bool m_Enable = false;
public bool m_Enable = true;
// private bool m_UseNewBatcher = false;
internal class RecorderEntry
{

new RecorderEntry() { name="RenderLoop.Draw" },
// new RecorderEntry() { name="BatchRenderer.Flush" },
new RecorderEntry() { name="Shadows.Draw" },
new RecorderEntry() { name="BatchRenderer.ApplyShaderPass" },
// new RecorderEntry() { name="BatchRenderer.ApplyShaderPass" },
// new RecorderEntry() { name="Batch.DrawStatic" },
// new RecorderEntry() { name="DrawBuffersBatchMode" },
/*
new RecorderEntry() { name="NewBatch.Instances" },
new RecorderEntry() { name="NewBatch.Elements" },
new RecorderEntry() { name="NewBatch.DrawRanges" },
new RecorderEntry() { name="NewBatch.S-Instances" },
new RecorderEntry() { name="NewBatch.S-Elements" },
new RecorderEntry() { name="NewBatch.S-DrawRanges" },
*/
/*
new RecorderEntry() { name="gBatchGBufferObj" },

/*
new RecorderEntry() { name="Camera.Render" },
new RecorderEntry() { name="GUI.Repaint" },
new RecorderEntry() { name="PrepareValues" },
new RecorderEntry() { name="ApplyGpuProgram" },

if (m_Enable)
{
/*
GUI.changed = false;
if ( !Application.isEditor )
{
m_UseNewBatcher = GUI.Toggle(new Rect(10, 30, 200, 20), m_UseNewBatcher, "Use new render batch");
if (GUI.changed)
{
UnityEngine.Experimental.Rendering.ScriptableRenderContext.UseNewBatchRenderer(m_UseNewBatcher);
}
}
*/
float w = 500, h = 204;
float w = 500, h = 24 + (recordersList.Length+1) * 16 + 8;
GUILayout.BeginArea(new Rect(10, 150, w, h), "Mini Profiler", GUI.skin.window);
GUILayout.BeginArea(new Rect(10, 50, w, h), "Mini Profiler", GUI.skin.window);
string sLabel = System.String.Format("<b>{0:F2} FPS ({1:F2}ms)</b>\n", 1.0f / m_AvgDeltaTime, Time.deltaTime * 1000.0f);
for (int i = 0; i < recordersList.Length; i++)
{

145
Assets/TestScenes/HDTest/HDRenderLoopTest.unity


m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1001 &1159917811
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 500408927}
m_Modifications:
- target: {fileID: 400026, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_LocalPosition.x
value: 2.68
objectReference: {fileID: 0}
- target: {fileID: 400026, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_LocalPosition.y
value: 2.267
objectReference: {fileID: 0}
- target: {fileID: 400026, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_LocalPosition.z
value: 1.17
objectReference: {fileID: 0}
- target: {fileID: 400026, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 400026, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 400026, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 400026, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 400026, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2300020, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 70d048a3453cc5b4183269db4555c8e7, type: 2}
- target: {fileID: 2300006, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 70d048a3453cc5b4183269db4555c8e7, type: 2}
- target: {fileID: 2300022, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 70d048a3453cc5b4183269db4555c8e7, type: 2}
- target: {fileID: 2300024, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 70d048a3453cc5b4183269db4555c8e7, type: 2}
- target: {fileID: 2300000, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 70d048a3453cc5b4183269db4555c8e7, type: 2}
- target: {fileID: 2300002, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 70d048a3453cc5b4183269db4555c8e7, type: 2}
- target: {fileID: 2300004, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 70d048a3453cc5b4183269db4555c8e7, type: 2}
- target: {fileID: 2300008, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 70d048a3453cc5b4183269db4555c8e7, type: 2}
- target: {fileID: 2300010, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 70d048a3453cc5b4183269db4555c8e7, type: 2}
- target: {fileID: 2300012, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 70d048a3453cc5b4183269db4555c8e7, type: 2}
- target: {fileID: 2300014, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 70d048a3453cc5b4183269db4555c8e7, type: 2}
- target: {fileID: 2300016, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 70d048a3453cc5b4183269db4555c8e7, type: 2}
- target: {fileID: 2300018, guid: 2b46db496f27398459cf881becf5763a, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 70d048a3453cc5b4183269db4555c8e7, type: 2}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 2b46db496f27398459cf881becf5763a, type: 3}
m_IsPrefabParent: 0
--- !u!4 &1159917812 stripped
Transform:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 1159917811}
--- !u!1 &1161056796
GameObject:
m_ObjectHideFlags: 0

- component: {fileID: 1828470161}
- component: {fileID: 1828470160}
- component: {fileID: 1828470166}
- component: {fileID: 1828470167}
- component: {fileID: 1828470165}
m_Layer: 0
m_Name: Main Camera

m_GameObject: {fileID: 1828470159}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 948f4100a11a5c24981795d21301da5c, type: 3}
m_Script: {fileID: 11500000, guid: 8b9a305e18de0c04dbd257a21cd47087, type: 3}
volumeTrigger: {fileID: 1828470164}
volumeLayer:
serializedVersion: 2
m_Bits: 1
antialiasingMode: 0
temporalAntialiasing:
jitterSpread: 0.75
sharpen: 0.25
stationaryBlending: 0.95
motionBlending: 0.85
showDebugUI: 0
debugView:
monitor: 1
sharedProfile: {fileID: 11400000, guid: 2139b7e52a6c6c74bb94f65be9294325, type: 2}
isGlobal: 1
blendDistance: 0
priority: 0
--- !u!114 &1828470166
MonoBehaviour:
m_ObjectHideFlags: 0

m_LookSpeedMouse: 10
m_MoveSpeed: 50
m_Turbo: 10
--- !u!114 &1828470167
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1828470159}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 948f4100a11a5c24981795d21301da5c, type: 3}
m_Name:
m_EditorClassIdentifier:
volumeTrigger: {fileID: 1828470164}
volumeLayer:
serializedVersion: 2
m_Bits: 1
antialiasingMode: 0
temporalAntialiasing:
jitterSpread: 0.75
sharpen: 0.25
stationaryBlending: 0.95
motionBlending: 0.85
fastApproximateAntialiasing:
mobileOptimized: 0
showDebugUI: 0
debugView:
monitor: 1
m_Resources: {fileID: 11400000, guid: d82512f9c8e5d4a4d938b575d47f88d4, type: 2}
--- !u!1 &1828745839
GameObject:
m_ObjectHideFlags: 0

4
Assets/TestScenes/HDTest/NewBatcherTest.meta


fileFormatVersion: 2
guid: 01a0eae0646089f489a0047dc8afb564
guid: 0ce05dc93eb4c90438b867f03422566b
timeCreated: 1493224766
timeCreated: 1493135841
licenseType: Pro
DefaultImporter:
userData:

4
Assets/TestScenes/HDTest/NewBatcherTest/Prefabs/Capsule.prefab


m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1121459876145138}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1

4
Assets/TestScenes/HDTest/NewBatcherTest/Prefabs/Cube.prefab


m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1998597619220778}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1

4
Assets/TestScenes/HDTest/NewBatcherTest/Prefabs/Cylinder.prefab


m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1152223544549600}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1

4
Assets/TestScenes/HDTest/NewBatcherTest/Prefabs/Sphere.prefab


m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1452448021178366}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1

6
Assets/TestScenes/HDTest/NewBatcherTest/matbench_2.mat


m_Shader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DEPTHOFFSETENABLE_OFF _DISTORTIONDEPTHTEST_OFF
_DISTORTIONENABLE_OFF _DISTORTIONONLY_OFF _DOUBLESIDEDENABLE_OFF _ENABLEPERPIXELDISPLACEMENT_OFF
_ENABLEWIND_OFF _NORMALMAP_TANGENT_SPACE
_ENABLEWIND_OFF _NORMALMAP _NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMap:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 3f3b8bdf3ccd30c4fb97b62bd26ef1f6, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:

- _Metallic: 0
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale: 1
- _NormalScale: 0.703
- _OcclusionStrength: 1
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15

10
ProjectSettings/EditorBuildSettings.asset


serializedVersion: 2
m_Scenes:
- enabled: 0
path: Assets/TestScenes/FPTL/FPTL.unity
guid: ac502c5271c0a254b8a18fbe4b8a3bf1
- enabled: 1
path: Assets/TestScenes/Big/BenchRenderVikingVillageStatic/renderloopTest.unity
guid: 97926ffe68fa77947be0d1979ec2fc73
- enabled: 0
- enabled: 1
- enabled: 0
path: Assets/TestScenes/HDTest/NewBatcherBench2.unity
guid: 1816611d7c1a9bc41bbe1ae56076f699

9
ProjectSettings/ProjectSettings.asset


useMacAppStoreValidation: 0
macAppStoreCategory: public.app-category.games
gpuSkinning: 0
graphicsJobs: 1
graphicsJobs: 0
xboxPIXTextureCapture: 0
xboxEnableAvatar: 0
xboxEnableKinect: 0

Android: com.Company.ProductName
Standalone: unity.DefaultCompany.dev
Tizen: com.Company.ProductName
iOS: com.Unity.VV
iOS: com.Company.ProductName
tvOS: com.Company.ProductName
buildNumber:
iOS: 0

iOSBackgroundModes: 0
iOSMetalForceHardShadows: 0
metalEditorSupport: 1
metalAPIValidation: 0
metalAPIValidation: 1
iOSRenderExtraFrameOnPause: 1
appleDeveloperTeamID:
iOSManualSigningProvisioningProfileID:
tvOSManualSigningProvisioningProfileID:

switchSocketMemoryPoolSize: 6144
switchSocketAllocatorPoolSize: 128
switchSocketConcurrencyLimit: 14
switchScreenResolutionBehavior: 2
switchUseCPUProfiler: 0
switchApplicationID: 0x0005000C10000001
switchNSODependencies:

switchParentalControl: 0
switchAllowsScreenshot: 1
switchDataLossConfirmation: 0
switchSupportedNpadStyles: 3
ps4NPAgeRating: 12
ps4NPTitleSecret:
ps4NPTrophyPackPath:

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources/BlitCubemap.shader


#pragma fragment frag
#pragma target 4.5
#include "../../ShaderLibrary/Common.hlsl"
#include "../../../ShaderLibrary/Common.hlsl"
TEXTURECUBE(_MainTex);
SAMPLERCUBE(sampler_MainTex);

2
Assets/ScriptableRenderPipeline/Core/Debugging/DebugItemDrawer.cs


#endif
}
}
}

8
Assets/ScriptableRenderPipeline/Core/Shadow/VectorArray.cs


Array.Sort(m_array, (int)m_offset, (int)m_count);
}
// Sort according to some comparer
public void Sort(System.Collections.Generic.IComparer<T> comparer)
{
Debug.Assert(m_count <= int.MaxValue && m_offset <= int.MaxValue);
Array.Sort(m_array, (int)m_offset, (int)m_count, comparer);
}
// Returns true if the element matches the designator according to the comparator. idx will hold the index to the first matched object in the array.
public delegate bool Comparator<U>(ref U designator, ref T obj);
public bool FindFirst<U>(out uint idx, ref U designator, Comparator<U> compareDelegate)

13
Assets/ScriptableRenderPipeline/Core/Shadow/ShadowBase.cs


void ProcessShadowRequests( FrameId frameId, CullResults cullResults, Camera camera, VisibleLight[] lights, ref uint shadowRequestsCount, int[] shadowRequests, out int[] shadowDataIndices );
// Renders all shadows for lights the were deemed shadow casters after the last call to ProcessShadowRequests
void RenderShadows( FrameId frameId, ScriptableRenderContext renderContext, CullResults cullResults, VisibleLight[] lights );
// Debug function to display a shadow at the screen coordinate with the provided material.
void DisplayShadows(ScriptableRenderContext renderContext, Material displayMaterial, int shadowMapIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
// Synchronize data with GPU buffers
void SyncData();
// Binds resources to shader stages just before rendering the lighting pass

abstract public class ShadowManagerBase : ShadowRegistry, IShadowManager
{
public abstract void ProcessShadowRequests( FrameId frameId, CullResults cullResults, Camera camera, VisibleLight[] lights, ref uint shadowRequestsCount, int[] shadowRequests, out int[] shadowDataIndices );
public abstract void RenderShadows( FrameId frameId, ScriptableRenderContext renderContext, CullResults cullResults, VisibleLight[] lights );
public abstract void SyncData();
public abstract void BindResources( ScriptableRenderContext renderContext );
public abstract void UpdateCullingParameters( ref CullingParameters cullingParams );
public abstract void ProcessShadowRequests( FrameId frameId, CullResults cullResults, Camera camera, VisibleLight[] lights, ref uint shadowRequestsCount, int[] shadowRequests, out int[] shadowDataIndices );
public abstract void RenderShadows( FrameId frameId, ScriptableRenderContext renderContext, CullResults cullResults, VisibleLight[] lights );
public abstract void DisplayShadows(ScriptableRenderContext renderContext, Material displayMaterial, int shadowMapIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
public abstract void SyncData();
public abstract void BindResources( ScriptableRenderContext renderContext );
public abstract void UpdateCullingParameters( ref CullingParameters cullingParams );
// sort the shadow requests in descending priority - may only modify shadowRequests
protected abstract void PrioritizeShadowCasters( Camera camera, VisibleLight[] lights, uint shadowRequestsCount, int[] shadowRequests );
// prune the shadow requests - may modify shadowRequests and shadowsCountshadowRequestsCount

63
Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs


{
vp = ShadowUtils.ExtractDirectionalLightMatrix( lights[sr.index], key.faceIdx, m_CascadeCount, m_CascadeRatios, nearPlaneOffset, width, height, out ce.current.view, out ce.current.proj, out ce.current.lightDir, out ce.current.splitData, m_CullResults, (int) sr.index );
m_TmpSplits[key.faceIdx] = ce.current.splitData.cullingSphere;
m_TmpSplits[key.faceIdx].w *= ce.current.splitData.cullingSphere.w;
if( ce.current.splitData.cullingSphere.w != float.NegativeInfinity )
m_TmpSplits[key.faceIdx].w *= ce.current.splitData.cullingSphere.w;
}
else
vp = Matrix4x4.identity; // should never happen, though

shadowDataIndices = m_ShadowIndices.AsArray( out offset, out shadowRequestsCount );
}
public class SortReverter : System.Collections.Generic.IComparer<long>
{
public int Compare(long lhs, long rhs)
{
return rhs.CompareTo(lhs);
}
}
protected override void PrioritizeShadowCasters( Camera camera, VisibleLight[] lights, uint shadowRequestsCount, int[] shadowRequests )
{

val |= (uint)vlidx;
m_TmpSortKeys.AddUnchecked( val );
}
m_TmpSortKeys.Sort();
m_TmpSortKeys.Sort( new SortReverter() );
m_TmpSortKeys.ExtractTo( shadowRequests, 0, out shadowRequestsCount, delegate(long key) { return (int) (key & 0xffffffff); } );
}

GPUShadowType shadowType = GPUShadowType.Point;
AdditionalLightData ald = vl.light.GetComponent<AdditionalLightData>();
Vector3 lpos = new Vector3( vl.localToWorld.GetColumn( 3 ).x, vl.localToWorld.GetColumn( 3 ).y, vl.localToWorld.GetColumn( 3 ).z );
Vector3 lpos = vl.light.transform.position;
bool add = distToCam < ald.shadowFadeDistance;
bool add = (distToCam < ald.shadowFadeDistance || vl.lightType == LightType.Directional) && m_ShadowSettings.enabled;
case LightType.Directional : add = --m_MaxShadows[(int)GPUShadowType.Directional , 0] >= 0; shadowType = GPUShadowType.Directional; facecount = m_ShadowSettings.directionalLightCascadeCount; break;
case LightType.Point : add = --m_MaxShadows[(int)GPUShadowType.Point , 0] >= 0; shadowType = GPUShadowType.Point ; facecount = 6; break;
case LightType.Spot : add = --m_MaxShadows[(int)GPUShadowType.Spot , 0] >= 0; shadowType = GPUShadowType.Spot ; facecount = 1; break;
case LightType.Directional:
add = --m_MaxShadows[(int)GPUShadowType.Directional, 0] >= 0;
shadowType = GPUShadowType.Directional;
facecount = m_ShadowSettings.directionalLightCascadeCount;
break;
case LightType.Point:
add = --m_MaxShadows[(int)GPUShadowType.Point, 0] >= 0;
shadowType = GPUShadowType.Point;
facecount = 6;
break;
case LightType.Spot:
add = --m_MaxShadows[(int)GPUShadowType.Spot, 0] >= 0;
shadowType = GPUShadowType.Spot;
facecount = 1;
break;
}
}

{
sm.Update( frameId, renderContext, cullResults, lights );
}
}
}
public override void DisplayShadows(ScriptableRenderContext renderContext, Material displayMaterial, int shadowMapIndex, float screenX, float screenY, float screenSizeX, float screenSizeY)
{
using (new HDPipeline.Utilities.ProfilingSample("Display Shadows", renderContext))
{
// This code is specific to shadow atlas implementation
MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock();
CommandBuffer debugCB = new CommandBuffer();
debugCB.name = "Display shadow Overlay";
if (shadowMapIndex == -1) // Display the Atlas
{
propertyBlock.SetVector("_TextureScaleBias", new Vector4(1.0f, 1.0f, 0.0f, 0.0f));
}
else // Display particular index
{
VectorArray<ShadowData> shadowDatas = m_ShadowCtxt.shadowDatas;
uint shadowIdx = Math.Min((uint)shadowMapIndex, shadowDatas.Count());
propertyBlock.SetVector("_TextureScaleBias", shadowDatas[shadowIdx].scaleOffset);
}
debugCB.SetViewport(new Rect(screenX, screenY, screenSizeX, screenSizeY));
debugCB.DrawProcedural(Matrix4x4.identity, displayMaterial, 0, MeshTopology.Triangles, 3, 1, propertyBlock);
renderContext.ExecuteCommandBuffer(debugCB);
}
}

1001
Assets/TestScenes/HDTest/MultipleShadowsTest.unity
文件差异内容过多而无法显示
查看文件

8
Assets/TestScenes/HDTest/MultipleShadowsTest.unity.meta


fileFormatVersion: 2
guid: 7d00c9cbd8cb54a4e86bd699995c8beb
timeCreated: 1483527925
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

8
Assets/TestScenes/HDTest/NewBatcherBench2.unity.meta


fileFormatVersion: 2
guid: 1816611d7c1a9bc41bbe1ae56076f699
timeCreated: 1493136714
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

41
Assets/TestScenes/HDTest/NewBatcherTest/Mover.cs


using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Object = UnityEngine.Object;
public class Mover : MonoBehaviour {
Transform[] m_Transforms;
float m_Phase0;
private bool m_Pause = false;
// Use this for initialization
void Start ()
{
m_Transforms = (Object.FindObjectsOfType(typeof(GameObject)) as GameObject[]).Where(o => o.name.Contains("Cube") || o.name.Contains("Capsule") || o.name.Contains("Cylinder") || o.name.Contains("Sphere")).Select(g=>g.transform).ToArray();
}
// Update is called once per frame
void Update ()
{
if ( !m_Pause )
{
float innerPhase = m_Phase0;
foreach (Transform t in m_Transforms)
{
float yd = 2.0f * Mathf.Sin(innerPhase);
t.localPosition = new Vector3(t.localPosition.x, Mathf.Abs(yd), t.localPosition.z);
innerPhase += 0.01f;
}
m_Phase0 += Time.deltaTime * 2.0f;
}
}
void OnGUI()
{
m_Pause = GUI.Toggle(new Rect(10, 10, 200, 20), m_Pause, "Pause");
}
}

12
Assets/TestScenes/HDTest/NewBatcherTest/Mover.cs.meta


fileFormatVersion: 2
guid: 107ec621874e21b40905bbc627cccb7d
timeCreated: 1493207732
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
Assets/TestScenes/HDTest/PostProcess Profiles.meta


fileFormatVersion: 2
guid: 166af886efad2c04d85456798ab7f285
folderAsset: yes
timeCreated: 1494503371
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
Assets/ScriptableRenderPipeline/Core/Resources.meta


fileFormatVersion: 2
guid: 059214a704804ae4490357c01c763f42
folderAsset: yes
timeCreated: 1494862081
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

14
Assets/TestScenes/HDTest/PostProcess Profiles/Main Camera Profile.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8e6292b2c06870d4495f009f912b9600, type: 3}
m_Name: Main Camera Profile
m_EditorClassIdentifier:
settings: []

9
Assets/TestScenes/HDTest/PostProcess Profiles/Main Camera Profile.asset.meta


fileFormatVersion: 2
guid: 2139b7e52a6c6c74bb94f65be9294325
timeCreated: 1494503371
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

9
Assets/ScriptableRenderPipeline/HDRenderPipeline/Shadow.meta


fileFormatVersion: 2
guid: f4cebcdbc19874c46ab4194e5ce59c67
folderAsset: yes
timeCreated: 1477395055
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
Assets/ScriptableRenderPipeline/common.meta


fileFormatVersion: 2
guid: 88c7531cefb4c7043bcfda092215f20c
folderAsset: yes
timeCreated: 1467917164
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

/Assets/ScriptableRenderPipeline/BasicRenderPipelineTutorial → /Assets/ScriptableRenderPipeline/BasicRenderPipeline

/Assets/ScriptableRenderPipeline/BasicRenderPipelineTutorial.meta → /Assets/ScriptableRenderPipeline/BasicRenderPipeline.meta

/Assets/ScriptableRenderPipeline/HDRenderPipeline/SSSProfile.meta → /Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/SSSProfile.meta

/Assets/ScriptableRenderPipeline/HDRenderPipeline/SSSProfile → /Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/SSSProfile

/Assets/ScriptableRenderPipeline/AdditionalLightData.cs.meta → /Assets/ScriptableRenderPipeline/Core/AdditionalLightData.cs.meta

/Assets/ScriptableRenderPipeline/AdditionalLightData.cs → /Assets/ScriptableRenderPipeline/Core/AdditionalLightData.cs

/Assets/ScriptableRenderPipeline/common/ShaderBase.h.meta → /Assets/ScriptableRenderPipeline/Fptl/ShaderBase.h.meta

/Assets/ScriptableRenderPipeline/common/TextureCache.cs.meta → /Assets/ScriptableRenderPipeline/Core/TextureCache.cs.meta

/Assets/ScriptableRenderPipeline/common/SkyboxHelper.cs.meta → /Assets/ScriptableRenderPipeline/Fptl/SkyboxHelper.cs.meta

/Assets/ScriptableRenderPipeline/common/TextureSettings.cs.meta → /Assets/ScriptableRenderPipeline/Core/TextureSettings.cs.meta

/Assets/ScriptableRenderPipeline/common/CubeToSpherical.shader.meta → /Assets/ScriptableRenderPipeline/Core/Resources/CubeToPano.shader.meta

/Assets/ScriptableRenderPipeline/common/TextureSettings.cs → /Assets/ScriptableRenderPipeline/Core/TextureSettings.cs

/Assets/ScriptableRenderPipeline/common/Camera.meta → /Assets/ScriptableRenderPipeline/Core/Camera.meta

/Assets/ScriptableRenderPipeline/common/Resources/BlitCubemap.shader.meta → /Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources/BlitCubemap.shader.meta

/Assets/ScriptableRenderPipeline/common/Resources/BlitCubemap.shader → /Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources/BlitCubemap.shader

/Assets/ScriptableRenderPipeline/common/ShaderBase.h → /Assets/ScriptableRenderPipeline/Fptl/ShaderBase.h

/Assets/ScriptableRenderPipeline/common/SkyboxHelper.cs → /Assets/ScriptableRenderPipeline/Fptl/SkyboxHelper.cs

/Assets/ScriptableRenderPipeline/common/Camera → /Assets/ScriptableRenderPipeline/Core/Camera

/Assets/ScriptableRenderPipeline/common/CubeToSpherical.shader → /Assets/ScriptableRenderPipeline/Core/Resources/CubeToPano.shader

/Assets/ScriptableRenderPipeline/common/Debugging.meta → /Assets/ScriptableRenderPipeline/Core/Debugging.meta

/Assets/ScriptableRenderPipeline/common/Debugging → /Assets/ScriptableRenderPipeline/Core/Debugging

/Assets/ScriptableRenderPipeline/common/Shadow.meta → /Assets/ScriptableRenderPipeline/Core/Shadow.meta

/Assets/ScriptableRenderPipeline/common/Shadow → /Assets/ScriptableRenderPipeline/Core/Shadow

/Assets/ScriptableRenderPipeline/common/TextureCache.cs → /Assets/ScriptableRenderPipeline/Core/TextureCache.cs

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存