浏览代码

Merge remote-tracking branch 'origin/master' into scriptablerenderloop-materialgraph

# Conflicts:
#	.gitmodules
/scriptablerenderloop-materialgraph
Paul Demeulenaere 8 年前
当前提交
f68e8b7c
共有 85 个文件被更改,包括 1103 次插入1209 次删除
  1. 7
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset
  2. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset.meta
  3. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
  4. 5
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugViewMaterialGBuffer.shader
  5. 19
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Deferred.shader
  6. 3
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Forward.hlsl
  7. 7
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightDefinition.cs
  8. 3
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightDefinition.cs.hlsl
  9. 29
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Lighting.hlsl
  10. 7
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePass.cs
  11. 85
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePass.hlsl
  12. 16
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePassLoop.hlsl
  13. 3
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Builtin/BuiltinData.cs.hlsl
  14. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/LayeredLit/LayeredLit.shader
  15. 5
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.cs
  16. 3
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.cs.hlsl
  17. 18
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.hlsl
  18. 47
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitDefault.shader
  19. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/PreIntegratedFGD.shader
  20. 47
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Material.hlsl
  21. 3
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/Unlit.cs.hlsl
  22. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/UnlitDefault.shader
  23. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/PostProcess/FinalPass.shader
  24. 3
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPass.cs.hlsl
  25. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPassForward.hlsl
  26. 2
      Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs
  27. 62
      Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl
  28. 1
      Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl
  29. 4
      Assets/ScriptableRenderLoop/common/SkyboxHelper.cs
  30. 7
      Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs.hlsl
  31. 29
      Assets/ScriptableRenderLoop/fptl/LightingConvexHullUtils.hlsl
  32. 12
      Assets/ScriptableRenderLoop/fptl/LightingUtils.hlsl
  33. 86
      Assets/ScriptableRenderLoop/fptl/lightlistbuild-bigtile.compute
  34. 87
      Assets/ScriptableRenderLoop/fptl/lightlistbuild-clustered.compute
  35. 165
      Assets/ScriptableRenderLoop/fptl/lightlistbuild.compute
  36. 2
      Assets/ScriptableRenderLoop/fptl/renderloopfptl.asset
  37. 205
      Assets/TestScenes/HDTest/HDRenderLoopTest.unity
  38. 226
      Assets/TestScenes/HDTest/Leaf/GroundLeaf/Materials/GroundLeaf_Albedo.mat
  39. 226
      Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/CubeTransparent.mat
  40. 294
      Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/test-transparent.mat
  41. 5
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs.hlsl
  42. 8
      Assets/ShaderGenerator/Editor/CSharpToHLSL.cs
  43. 32
      Assets/ShaderGenerator/Editor/ShaderTypeGeneration.cs
  44. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow.meta
  45. 63
      Assets/ScriptableRenderLoop/ShaderLibrary/CommonMaterial.hlsl
  46. 9
      Assets/ScriptableRenderLoop/ShaderLibrary/CommonMaterial.hlsl.meta
  47. 14
      Assets/ScriptableRenderLoop/ShaderLibrary/CommonShadow.hlsl
  48. 9
      Assets/ScriptableRenderLoop/ShaderLibrary/CommonShadow.hlsl.meta
  49. 9
      Assets/ScriptableRenderLoop/fptl/LightingConvexHullUtils.hlsl.meta
  50. 117
      Assets/ScriptableRenderLoop/fptl/SortingComputeUtils.hlsl
  51. 9
      Assets/ScriptableRenderLoop/fptl/lightlistbuild-bigtile.compute.meta
  52. 9
      Assets/ShaderGenerator/Editor.meta
  53. 38
      Assets/ShaderGenerator/ShaderGeneratorAttributes.cs
  54. 12
      Assets/ShaderGenerator/ShaderGeneratorAttributes.cs.meta
  55. 9
      Assets/TestScenes/Big.meta
  56. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/EVSM.meta
  57. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/FixedSizePCF.meta
  58. 17
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/FixedSizePCF/FixedSizePCF.cs
  59. 12
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/FixedSizePCF/FixedSizePCF.cs.meta
  60. 17
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/FixedSizePCF/FixedSizePCF.hlsl
  61. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/FixedSizePCF/FixedSizePCF.hlsl.meta
  62. 22
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/Shadow.hlsl
  63. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/Shadow.hlsl.meta
  64. 30
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs
  65. 25
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Shadow.hlsl
  66. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Shadow.hlsl.meta
  67. 28
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/ShadowDefinition.cs
  68. 9
      Assets/ScriptableRenderLoop/ForwardRenderLoop.meta
  69. 9
      Assets/TestScenes/ForwardRenderLoop.meta
  70. 0
      /Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs.hlsl
  71. 0
      /Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs.hlsl.meta
  72. 0
      /Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs.meta
  73. 0
      /Assets/ShaderGenerator/Editor/CSharpToHLSL.cs.meta
  74. 0
      /Assets/ShaderGenerator/Editor/ICSharpCode.NRefactory.dll.meta
  75. 0
      /Assets/ShaderGenerator/Editor/ShaderGeneratorMenu.cs.meta
  76. 0
      /Assets/ShaderGenerator/Editor/ShaderTypeGeneration.cs.meta
  77. 0
      /Assets/ShaderGenerator/Editor/ICSharpCode.NRefactory.dll
  78. 0
      /Assets/ShaderGenerator/Editor/CSharpToHLSL.cs
  79. 0
      /Assets/ShaderGenerator/Editor/ShaderGeneratorMenu.cs
  80. 0
      /Assets/ShaderGenerator/Editor/ShaderTypeGeneration.cs

7
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset


m_Script: {fileID: 11500000, guid: 558064ecdbf6b6742892d699acb39aed, type: 3}
m_Name: HDRenderLoop
m_EditorClassIdentifier:
m_ShadowSettings:
enabled: 1
shadowAtlasWidth: 4096
shadowAtlasHeight: 4096
maxShadowDistance: 1000
directionalLightCascadeCount: 4
directionalLightCascades: {x: 0.05, y: 0.2, z: 0.3}
m_TextureSettings:
spotCookieSize: 128
pointCookieSize: 512

2
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset.meta


fileFormatVersion: 2
guid: 2400b74f5ce370c4481e5dc417d03703
timeCreated: 1476885643
timeCreated: 1477406009
licenseType: Pro
NativeFormatImporter:
userData:

9
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs


s_envLightList = new ComputeBuffer(MaxLights, System.Runtime.InteropServices.Marshal.SizeOf(typeof(EnvLightData)));
s_punctualShadowList = new ComputeBuffer(MaxShadows, System.Runtime.InteropServices.Marshal.SizeOf(typeof(PunctualShadowData)));
m_DeferredMaterial = CreateEngineMaterial("Hidden/Unity/Deferred");
m_FinalPassMaterial = CreateEngineMaterial("Hidden/Unity/FinalPass");
m_DeferredMaterial = CreateEngineMaterial("Hidden/HDRenderLoop/Deferred");
m_FinalPassMaterial = CreateEngineMaterial("Hidden/HDRenderLoop/FinalPass");
m_DebugViewMaterialGBuffer = CreateEngineMaterial("Hidden/Unity/DebugViewMaterialGBuffer");
m_DebugViewMaterialGBuffer = CreateEngineMaterial("Hidden/HDRenderLoop/DebugViewMaterialGBuffer");
m_ShadowPass = new ShadowRenderPass (m_ShadowSettings);

{
ShadowOutput shadows;
m_ShadowPass.Render(renderLoop, cullResults, out shadows);
renderLoop.SetupCameraProperties(camera); // Need to recall SetupCameraProperties after m_ShadowPass.Render
UpdatePunctualLights(cullResults.visibleLights, ref shadows);
UpdateReflectionProbes(cullResults.visibleReflectionProbes);

5
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugViewMaterialGBuffer.shader


Shader "Hidden/Unity/DebugViewMaterialGBuffer"
Shader "Hidden/HDRenderLoop/DebugViewMaterialGBuffer"
{
SubShader
{

#pragma vertex VertDeferred
#pragma fragment FragDeferred
#include "Common.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderConfig.cs"
// CAUTION: In case deferred lighting need to support various lighting model statically, we will require to do multicompile with different define like UNITY_MATERIAL_LIT
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Material.hlsl"

19
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Deferred.shader


Shader "Hidden/Unity/Deferred"
Shader "Hidden/HDRenderLoop/Deferred"
{
Properties
{

#pragma vertex VertDeferred
#pragma fragment FragDeferred
// Chose supported lighting architecture in case of deferred rendering
#pragma multi_compile LIGHTLOOP_SINGLE_PASS
#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF
//-------------------------------------------------------------------------------------
// Include
//-------------------------------------------------------------------------------------
// Chose supported lighting architecture in case of deferred rendering
#pragma multi_compile SINGLE_PASS
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderConfig.cs"
// CAUTION: In case deferred lighting need to support various lighting model statically, we will require to do multicompile with different define like UNITY_MATERIAL_DISNEYGXX
// TODO: Currently a users that add a new deferred material must also add it manually here... Need to think about it. Maybe add a multicompile inside a file in Material directory to include here ?

//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
DECLARE_GBUFFER_TEXTURE(_CameraGBufferTexture);
DECLARE_GBUFFER_BAKE_LIGHTING(_CameraGBufferTexture);

float4 specularLighting;
FETCH_BAKE_LIGHTING_GBUFFER(gbuffer, _CameraGBufferTexture, coord.unPositionSS);
float3 bakeDiffuseLighting = DECODE_BAKE_LIGHTING_FROM_GBUFFER(gbuffer);
LightingLoop(V, positionWS, preLightData, bsdfData, bakeDiffuseLighting, diffuseLighting, specularLighting);
LightLoop(V, positionWS, preLightData, bsdfData, bakeDiffuseLighting, diffuseLighting, specularLighting);
return float4(diffuseLighting.rgb + specularLighting.rgb, 1.0);
}

3
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Forward.hlsl


// If only one keyword is present it mean that only one type of forward lighting architecture is supported.
// Must match name in GetKeyword() method of forward lighting architecture .cs file
// #pragma multi_compile SINGLE_PASS -> can't use a pragma from include... (for now)
// #pragma multi_compile LIGHTLOOP_SINGLE_PASS -> can't use a pragma from include... (for now)
// #pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF -> can't use a pragma from include... (for now)

7
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightDefinition.cs


using UnityEngine;
//-----------------------------------------------------------------------------
// structure definition
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// structure definition
//-----------------------------------------------------------------------------
[GenerateHLSL]
// Power of two value as they are flag
public enum LightFlags

3
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightDefinition.cs.hlsl


// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightDefinition.cs. Please don't edit by hand.
//
#ifndef LIGHTDEFINITION_CS_HLSL
#define LIGHTDEFINITION_CS_HLSL
//
// UnityEngine.Experimental.ScriptableRenderLoop.LightFlags: static fields
//

}
#endif

29
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Lighting.hlsl


#ifndef UNITY_LIGHTING_INCLUDED
#define UNITY_LIGHTING_INCLUDED
// The lighting architecture is in charge to define the light loop
// It is also in charge to define the sampling function for shadowmap, ies, cookie and reflection
// as only the lighting architecture is aware of the usage of texture atlas, array and format (latlong, 2D, cube)
#include "CommonLighting.hlsl"
#include "CommonShadow.hlsl"
#include "Sampling.hlsl"
#include "AreaLighting.hlsl"
#include "ImageBasedLighting.hlsl"
// The light loop (or lighting architecture) is in charge to:
// - Define light list
// - Define the light loop
// - Setup the constant/data
// - Do the reflection hierarchy
// - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong))
#define LIGHTING // This define is used to know that we have include lighting when compiling material, else it will generate "default" function that are neutral to use Material.hlsl alone.
#define HAS_LIGHTLOOP // Allow to not define LightLoop related function in Material.hlsl
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/ShadowDefinition.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightDefinition.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs.hlsl"
#ifdef SINGLE_PASS
#ifdef LIGHTLOOP_SINGLE_PASS
//#elif ...
// Shadow use samling function define in header above and must be include before Material.hlsl
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/Shadow.hlsl"
#ifdef SINGLE_PASS
// LightLoop use evaluation BSDF function for light type define in Material.hlsl
#ifdef LIGHTLOOP_SINGLE_PASS
//#elif ...
#endif

7
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePass.cs


using UnityEngine.Experimental.Rendering;
using System;
//-----------------------------------------------------------------------------
// structure definition
//-----------------------------------------------------------------------------
public class SinglePass
public class LightLoopSinglePass
return "SINGLE_PASS";
return "LIGHTLOOP_SINGLE_PASS";
}
};
}

85
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePass.hlsl


// It use maxed list of lights of the scene - use just as proof of concept - do not used in regular game
//-----------------------------------------------------------------------------
struct LightLoopContext
{
int sampleShadow;
int sampleReflection;
};
// Shadow
// Constant and structure declaration
#define SINGLE_PASS_CONTEXT_SAMPLE_SHADOWATLAS 0
#define SINGLE_PASS_CONTEXT_SAMPLE_SHADOWARRAY 1
StructuredBuffer<PunctualLightData> _PunctualLightList;
StructuredBuffer<EnvLightData> _EnvLightList;
StructuredBuffer<PunctualShadowData> _PunctualShadowList;
// Use texture atlas for shadow map
// Use texture atlas for shadow map
StructuredBuffer<PunctualShadowData> _PunctualShadowList;
// Use texture array for IES
TEXTURE2D_ARRAY(_IESArray);
SAMPLER2D(sampler_IESArray);
// Use texture array for reflection
TEXTURECUBE_ARRAY(_EnvTextures);
SAMPLERCUBE(sampler_EnvTextures);
TEXTURECUBE(_SkyTexture);
SAMPLERCUBE(sampler_SkyTexture); // NOTE: Sampler could be share here with _EnvTextures. Don't know if the shader compiler will complain...
CBUFFER_START(UnityPerLightLoop)
int _PunctualLightCount;
int _EnvLightCount;
EnvLightData _EnvLightSky;
CBUFFER_END
struct LightLoopContext
{
int sampleShadow;
int sampleReflection;
};
//-----------------------------------------------------------------------------
// Shadow sampling function
// ----------------------------------------------------------------------------
#define SINGLE_PASS_CONTEXT_SAMPLE_SHADOWATLAS 0
#define SINGLE_PASS_CONTEXT_SAMPLE_SHADOWARRAY 1
float3 GetShadowTextureCoordinate(LightLoopContext lightLoopContext, int index, float3 positionWS, float3 L)
PunctualShadowData GetPunctualShadowData(LightLoopContext lightLoopContext, int index, float3 L)
int faceIndex;
int faceIndex = 0;
{
{
// Note: scale and bias of shadow atlas are included in ShadowTransform
float4x4 shadowTransform = _PunctualShadowList[index + faceIndex].worldToShadow;
float4 positionTXS = mul(float4(positionWS, 1.0), shadowTransform);
return _PunctualShadowList[index + faceIndex];
}
float3 GetShadowTextureCoordinate(LightLoopContext lightLoopContext, PunctualShadowData shadowData, float3 positionWS)
{
// Note: scale and bias of shadow atlas are included in ShadowTransform but could be apply here.
float4 positionTXS = mul(float4(positionWS, 1.0), shadowData.worldToShadow);
float SampleShadowCompare(LightLoopContext lightLoopContext, int index, float3 texCoord)
float4 SampleShadowCompare(LightLoopContext lightLoopContext, int index, float3 texCoord)
float objDepth = saturate(257.0 / 256.0 - texCoord.z);
return SAMPLE_TEXTURE2D_SHADOW(g_tShadowBuffer, samplerg_tShadowBuffer, texCoord);
return SAMPLE_TEXTURE2D_SHADOW(g_tShadowBuffer, samplerg_tShadowBuffer, float3(texCoord.xy, objDepth)).xxxx;
}
/*
else // SINGLE_PASS_CONTEXT_SAMPLE_SHADOWARRAY

}
/*
float SampleShadow(LightLoopContext lightLoopContext, int index, float2 texCoord)
float4 SampleShadow(LightLoopContext lightLoopContext, int index, float2 texCoord)
{
if (lightLoopContext.sampleShadow == SINGLE_PASS_CONTEXT_SAMPLE_SHADOWATLAS)
{

*/
//-----------------------------------------------------------------------------
// IES
// IES sampling function
TEXTURE2D_ARRAY(_IESArray);
SAMPLER2D(sampler_IESArray);
// sphericalTexCoord is theta and phi spherical coordinate
float4 SampleIES(LightLoopContext lightLoopContext, int index, float2 sphericalTexCoord, float lod)
{

//-----------------------------------------------------------------------------
// Reflection proble / Sky
// Reflection proble / Sky sampling function
// Use texture array for reflection
TEXTURECUBE_ARRAY(_EnvTextures);
SAMPLERCUBE(sampler_EnvTextures);
TEXTURECUBE(_SkyTexture);
SAMPLERCUBE(sampler_SkyTexture); // NOTE: Sampler could be share here with _EnvTextures. Don't know if the shader compiler will complain...
#define SINGLE_PASS_CONTEXT_SAMPLE_REFLECTION_PROBES 0
#define SINGLE_PASS_CONTEXT_SAMPLE_SKY 1

16
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePassLoop.hlsl


StructuredBuffer<PunctualLightData> _PunctualLightList;
int _PunctualLightCount;
StructuredBuffer<EnvLightData> _EnvLightList;
int _EnvLightCount;
EnvLightData _EnvLightSky;
//-----------------------------------------------------------------------------
// LightLoop
// ----------------------------------------------------------------------------
void LightingLoop( float3 V, float3 positionWS, PreLightData prelightData, BSDFData bsdfData, float3 bakeDiffuseLighting,
out float4 diffuseLighting,
out float4 specularLighting)
void LightLoop( float3 V, float3 positionWS, PreLightData prelightData, BSDFData bsdfData, float3 bakeDiffuseLighting,
out float4 diffuseLighting,
out float4 specularLighting)
{
LightLoopContext context;
ZERO_INITIALIZE(LightLoopContext, context);

3
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Builtin/BuiltinData.cs.hlsl


// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Builtin/BuiltinData.cs. Please don't edit by hand.
//
#ifndef BUILTINDATA_CS_HLSL
#define BUILTINDATA_CS_HLSL
//
// UnityEngine.Experimental.ScriptableRenderLoop.Builtin.BuiltinData: static fields
//

};
#endif

2
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/LayeredLit/LayeredLit.shader


Shader "Unity/LayeredLit"
Shader "HDRenderLoop/LayeredLit"
{
Properties
{

5
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.cs


using UnityEngine.Rendering;
using System;
//-----------------------------------------------------------------------------
// structure definition
//-----------------------------------------------------------------------------
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
namespace Lit

public void Rebuild()
{
m_InitPreFGD = CreateEngineMaterial("Hidden/Unity/PreIntegratedFGD");
m_InitPreFGD = CreateEngineMaterial("Hidden/HDRenderLoop/PreIntegratedFGD");
m_PreIntegratedFGD = new RenderTexture(128, 128, 0, RenderTextureFormat.ARGBHalf);
m_LtcGGXMatrix = LoadLUT(TextureFormat.RGBAHalf, s_LtcGGXMatrixData);

3
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.cs.hlsl


// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.cs. Please don't edit by hand.
//
#ifndef LIT_CS_HLSL
#define LIT_CS_HLSL
//
// UnityEngine.Experimental.ScriptableRenderLoop.Lit.MaterialId: static fields
//

};
#endif

18
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.hlsl


// f0 * Gv * (1 - Fc) + Gv * Fc
specularFGD = fresnel0 * preFGD.x + preFGD.y;
#if DIFFUSE_LAMBERT_BRDF
diffuseFGD = 1.0;
#else

}
//-----------------------------------------------------------------------------
// LightLoop related function (Only include if required)
// HAS_LIGHTLOOP is define in Lighting.hlsl
//-----------------------------------------------------------------------------
#ifdef HAS_LIGHTLOOP
//-----------------------------------------------------------------------------
// BSDF share between area light (reference) and punctual light
//-----------------------------------------------------------------------------

const bool hasShadow = (lightData.flags & LIGHTFLAGS_HAS_SHADOW) != 0;
[branch] if (hasShadow && illuminance > 0.0f)
{
PunctualShadowData shadowData = GetPunctualShadowData(lightLoopContext, lightData.shadowIndex, L);
float3 shadowCoord = GetShadowTextureCoordinate(lightLoopContext, shadowData, positionWS + offset);
float3 shadowCoord = GetShadowTextureCoordinate(lightLoopContext, lightData.shadowIndex, positionWS + offset, L);
// Caution: formula doesn't work as we are texture atlas...
// if (max3(abs(NDC.x), abs(NDC.y), 1.0f - texCoordXYZ.z) <= 1.0f) return 1.0;
float shadowAttenuation = GetShadowAttenuation(lightLoopContext, lightData.shadowIndex, shadowCoord, shadowPosDX, shadowPosDY, preLightData.unPositionSS);
float shadowAttenuation = GetPunctualShadowAttenuation(lightLoopContext, lightData.shadowIndex, shadowData, shadowCoord, shadowPosDX, shadowPosDY, preLightData.unPositionSS);
shadowAttenuation = lerp(1.0, shadowAttenuation, lightData.shadowDimmer);
illuminance *= shadowAttenuation;
}

#endif
}
#endif // #ifdef HAS_LIGHTLOOP

47
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitDefault.shader


Shader "Unity/Lit"
Shader "HDRenderLoop/Lit"
{
Properties
{

//-------------------------------------------------------------------------------------
// Include
//-------------------------------------------------------------------------------------
#include "../../ShaderPass/ShaderPass.cs.hlsl"
#include "../../ShaderVariables.hlsl"
#include "../../Debug/DebugViewMaterial.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderConfig.cs"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderVariables.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPass.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugViewMaterial.hlsl"
//-------------------------------------------------------------------------------------
// variable declaration

// ------------------------------------------------------------------
// Deferred pass
// ------------------------------------------------------------------
Pass
{
Name "GBuffer" // Name is not used

// ------------------------------------------------------------------
// Debug pass
// ------------------------------------------------------------------
Pass
{
Name "Debug"

// ------------------------------------------------------------------
// Extracts information for lightmapping, GI (emission, albedo, ...)
// This pass it not used during regular rendering.
// ------------------------------------------------------------------
Pass
{
Name "META"

// ------------------------------------------------------------------
// Depth only
// ------------------------------------------------------------------
Pass
{
Name "DepthOnly" // Name is not used

#include "../../Material/Material.hlsl"
#include "LitData.hlsl"
#define NEED_TANGENT_TO_WORLD (defined(_HEIGHTMAP) && !defined (_HEIGHTMAP_AS_DISPLACEMENT))
#define NEED_TEXCOORD0 defined(_ALPHATEST_ON) || NEED_TANGENT_TO_WORLD
#if NEED_TEXCOORD0
#if defined(_HEIGHTMAP) && !defined (_HEIGHTMAP_AS_DISPLACEMENT)
#endif
#if NEED_TANGENT_TO_WORLD
float4 tangentOS : TANGENT;
#endif
};

float4 positionHS;
#if NEED_TEXCOORD0
#if defined(_HEIGHTMAP) && !defined (_HEIGHTMAP_AS_DISPLACEMENT)
#endif
#if NEED_TANGENT_TO_WORLD
float3 positionWS;
float3 tangentToWorld[3];
#endif

{
float4 positionHS : SV_Position;
#if defined(_HEIGHTMAP) && !defined (_HEIGHTMAP_AS_DISPLACEMENT)
#if NEED_TANGENT_TO_WORLD
#else
#elif NEED_TEXCOORD0
float4 interpolators[1] : TEXCOORD0;
#endif
};

{
PackedVaryings output;
output.positionHS = input.positionHS;
#if defined(_HEIGHTMAP) && !defined (_HEIGHTMAP_AS_DISPLACEMENT)
#if NEED_TANGENT_TO_WORLD
output.interpolators[0].xyz = input.positionWS.xyz;
output.interpolators[1].xyz = input.tangentToWorld[0];
output.interpolators[2].xyz = input.tangentToWorld[1];

output.interpolators[1].w = input.texCoord0.y;
#else
#elif NEED_TEXCOORD0
output.interpolators[0] = float4(input.texCoord0, 0.0, 0.0);
#endif

ZERO_INITIALIZE(FragInput, output);
output.positionHS = input.positionHS;
#if defined(_HEIGHTMAP) && !defined (_HEIGHTMAP_AS_DISPLACEMENT)
#if NEED_TANGENT_TO_WORLD
output.positionWS.xyz = input.interpolators[0].xyz;
output.tangentToWorld[0] = input.interpolators[1].xyz;
output.tangentToWorld[1] = input.interpolators[2].xyz;

#else
#elif NEED_TEXCOORD0
output.texCoord0.xy = input.interpolators[0].xy;
#endif

float3 positionWS = TransformObjectToWorld(input.positionOS);
output.positionHS = TransformWorldToHClip(positionWS);
#if NEED_TEXCOORD0
#endif
#if defined(_HEIGHTMAP) && !defined (_HEIGHTMAP_AS_DISPLACEMENT)
#if NEED_TANGENT_TO_WORLD
output.positionWS = positionWS;
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);

// ------------------------------------------------------------------
// forward pass
// ------------------------------------------------------------------
Pass
{
Name "Forward" // Name is not used

#define SHADERPASS SHADERPASS_FORWARD
// TEMP until pragma work in include
// #include "../../Lighting/Forward.hlsl"
#pragma multi_compile SINGLE_PASS
#pragma multi_compile LIGHTLOOP_SINGLE_PASS
#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF
#include "../../Lighting/Lighting.hlsl"
#include "LitData.hlsl"
#include "LitShare.hlsl"

2
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/PreIntegratedFGD.shader


Shader "Hidden/Unity/PreIntegratedFGD"
Shader "Hidden/HDRenderLoop/PreIntegratedFGD"
{
SubShader {
Pass {

47
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Material.hlsl


#ifndef UNITY_MATERIAL_INCLUDED
#define UNITY_MATERIAL_INCLUDED
#include "Common.hlsl"
#include "CommonLighting.hlsl"
#include "Sampling.hlsl"
#include "AreaLighting.hlsl"
#include "ImageBasedLighting.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderConfig.cs"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightDefinition.cs.hlsl"
//-----------------------------------------------------------------------------
// Lighting part that required to be define to compile without lighting.hlsl
//-----------------------------------------------------------------------------
// In case lighting.hlsl is not include before including material.hlsl, define some neutral function, so it doesn't complain
#ifndef LIGHTING
struct LightLoopContext
{
int unused;
};
float3 GetShadowTextureCoordinate(LightLoopContext lightLoopContext, int index, float3 positionWS, float3 L)
{
return float3(0.0, 0.0, 0.0);
}
float SampleShadowCompare(LightLoopContext lightLoopContext, int index, float3 texCoord)
{
return 0.0;
}
float4 SampleIES(LightLoopContext lightLoopContext, int index, float2 sphericalTexCoord, float lod)
{
return float4(0.0, 0.0, 0.0, 0.0);
}
float4 SampleEnv(LightLoopContext lightLoopContext, int index, float3 texCoord, float lod)
{
return float4(0.0, 0.0, 0.0, 0.0);
}
#endif
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Shadow.hlsl"
#include "CommonMaterial.hlsl"
//-----------------------------------------------------------------------------
// common Encode/Decode functions

#endif
//-----------------------------------------------------------------------------
// Define for GBuffer
// Define for GBuffer management
//-----------------------------------------------------------------------------
#ifdef GBUFFERMATERIAL_COUNT

3
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/Unlit.cs.hlsl


// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/Unlit.cs. Please don't edit by hand.
//
#ifndef UNLIT_CS_HLSL
#define UNLIT_CS_HLSL
//
// UnityEngine.Experimental.ScriptableRenderLoop.Unlit.SurfaceData: static fields
//

};
#endif

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/UnlitDefault.shader


Shader "Unity/Unlit"
Shader "HDRenderLoop/Unlit"
{
Properties
{

//-------------------------------------------------------------------------------------
#include "common.hlsl"
#include "../../ShaderPass/ShaderPass.cs.hlsl"
#include "../../ShaderVariables.hlsl"
#include "../../Debug/DebugViewMaterial.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderConfig.cs"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderVariables.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPass.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugViewMaterial.hlsl"
//-------------------------------------------------------------------------------------
// variable declaration

2
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/PostProcess/FinalPass.shader


// Final compositing pass, just does gamma correction for now.
Shader "Hidden/Unity/FinalPass"
Shader "Hidden/HDRenderLoop/FinalPass"
{
Properties
{

3
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPass.cs.hlsl


// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPass.cs. Please don't edit by hand.
//
#ifndef SHADERPASS_CS_HLSL
#define SHADERPASS_CS_HLSL
//
// UnityEngine.Experimental.ScriptableRenderLoop.ShaderPass: static fields
//

#define SHADERPASS_DEBUG_VIEW_MATERIAL (7)
#endif

2
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPassForward.hlsl


float4 diffuseLighting;
float4 specularLighting;
float3 bakeDiffuseLighting = GetBakedDiffuseLigthing(preLightData, surfaceData, builtinData, bsdfData);
LightingLoop(V, positionWS, preLightData, bsdfData, bakeDiffuseLighting, diffuseLighting, specularLighting);
LightLoop(V, positionWS, preLightData, bsdfData, bakeDiffuseLighting, diffuseLighting, specularLighting);
return float4(diffuseLighting.rgb + specularLighting.rgb, builtinData.opacity);
}

2
Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs


commandBuffer.SetViewport(new Rect(slice.atlasX, slice.atlasY, slice.shadowResolution, slice.shadowResolution));
//commandBuffer.ClearRenderTarget (true, true, Color.green);
commandBuffer.SetGlobalVector("g_vLightDirWs", new Vector4(lightDirection.x, lightDirection.y, lightDirection.z));
commandBuffer.SetProjectionAndViewMatrices(proj, view);
commandBuffer.SetViewProjectionMatrices(view, proj);
// commandBuffer.SetGlobalDepthBias (1.0F, 1.0F);
loop.ExecuteCommandBuffer(commandBuffer);
commandBuffer.Dispose();

62
Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl


#define UNITY_COMMON_LIGHTING_INCLUDED
// Ligthing convention
// Light direction is oriented backward (-Z). i.e in shader code, light direction is - lightData.forward
// Light direction is oriented backward (-Z). i.e in shader code, light direction is -lightData.forward
//-----------------------------------------------------------------------------
// Attenuation functions

}
//-----------------------------------------------------------------------------
// Helper function for anisotropy
//-----------------------------------------------------------------------------
// Ref: http://blog.selfshadow.com/publications/s2012-shading-course/burley/s2012_pbs_disney_brdf_notes_v3.pdf (in addenda)
// Convert anisotropic ratio (0->no isotropic; 1->full anisotropy in tangent direction) to roughness
void ConvertAnisotropyToRoughness(float roughness, float anisotropy, out float roughnessT, out float roughnessB)
{
float anisoAspect = sqrt(1.0 - 0.9 * anisotropy);
roughnessT = roughness * anisoAspect;
roughnessB = roughness / anisoAspect;
}
// Fake anisotropic by distorting the normal as suggested by:
// Ref: Donald Revie - Implementing Fur Using Deferred Shading (GPU Pro 2)
// anisotropic ratio (0->no isotropic; 1->full anisotropy in tangent direction)
float3 GetAnisotropicModifiedNormal(float3 N, float3 T, float3 V, float anisotropy)
{
float3 anisoT = cross(-V, T);
float3 anisoN = cross(anisoT, T);
return normalize(lerp(N, anisoN, anisotropy));
}
//-----------------------------------------------------------------------------
// Helper function for perceptual roughness
//-----------------------------------------------------------------------------
float PerceptualRoughnessToRoughness(float perceptualRoughness)
{
return perceptualRoughness * perceptualRoughness;
}
float RoughnessToPerceptualRoughness(float roughness)
{
return sqrt(roughness);
}
float PerceptualSmoothnessToRoughness(float perceptualSmoothness)
{
return (1 - perceptualSmoothness) * (1 - perceptualSmoothness);
}
float PerceptualSmoothnessToPerceptualRoughness(float perceptualSmoothness)
{
return (1 - perceptualSmoothness);
}
//-----------------------------------------------------------------------------
// Get local frame
//-----------------------------------------------------------------------------

tangentY = float3(b, 1.0f - N.y * N.y * a, -N.y);
}
*/
// ----------------------------------------------------------------------------
// Parallax mapping
// ----------------------------------------------------------------------------
float2 ParallaxOffset(float3 viewDirTS, float height)
{
// Parallax mapping with offset limiting to reduce weird artifcat (i.e do not divide by z), also save performance
return viewDirTS.xy * height;
}
#endif // UNITY_COMMON_LIGHTING_INCLUDED

1
Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl


#define UNITY_IMAGE_BASED_LIGHTING_INCLUDED
#include "CommonLighting.hlsl"
#include "CommonMaterial.hlsl"
#include "BSDF.hlsl"
#include "Sampling.hlsl"

4
Assets/ScriptableRenderLoop/common/SkyboxHelper.cs


var world = Matrix4x4.TRS(camera.transform.position, Quaternion.identity, new Vector3(dist, dist, dist));
var skyboxProj = SkyboxHelper.GetProjectionMatrix(camera);
cmd.SetProjectionAndViewMatrices(skyboxProj, camera.worldToCameraMatrix);
cmd.SetViewProjectionMatrices (camera.worldToCameraMatrix, skyboxProj);
cmd.SetProjectionAndViewMatrices(camera.projectionMatrix, camera.worldToCameraMatrix);
cmd.SetViewProjectionMatrices (camera.worldToCameraMatrix, camera.projectionMatrix);
}
loop.ExecuteCommandBuffer(cmd);

7
Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs.hlsl


#ifndef SOMETHINGSOMETHING
#define SOMETHINGSOMETHING
#ifndef LIGHTDEFINITIONS_CS_HLSL
#define LIGHTDEFINITIONS_CS_HLSL
//
// LightDefinitions: static fields
//

}
#endif
#endif

29
Assets/ScriptableRenderLoop/fptl/LightingConvexHullUtils.hlsl


return float4(vN, -dot(vN,p0));
}
bool DoesSphereOverlapTile(float3 dir, float halfTileSizeAtZDistOne, float3 sphCen, float sphRadiusIn)
{
float3 V = dir; // ray direction down center of tile (does not need to be normalized).
#if 1
float3 maxZdir = float3(-sphCen.z*sphCen.x, -sphCen.z*sphCen.y, sphCen.x*sphCen.x + sphCen.y*sphCen.y); // cross(sphCen,cross(Zaxis,sphCen))
float len = length(maxZdir);
float scalarProj = len>0.0001 ? (maxZdir.z/len) : len; // since len>=(maxZdir.z/len) we can use len as an approximate value when len<=epsilon
float offs = scalarProj*sphRadiusIn;
#else
float offs = sphRadiusIn; // more false positives due to larger radius but works too
#endif
// enlarge sphere so it overlaps the center of the tile assuming it overlaps the tile to begin with.
#ifdef LEFT_HAND_COORDINATES
float sphRadius = sphRadiusIn + (sphCen.z+offs)*halfTileSizeAtZDistOne;
#else
float sphRadius = sphRadiusIn - (sphCen.z-offs)*halfTileSizeAtZDistOne;
#endif
float a = dot(V,V);
float CdotV = dot(sphCen,V);
float c = dot(sphCen,sphCen) - sphRadius*sphRadius;
float fDescDivFour = CdotV*CdotV - a*c;
return c<0 || (fDescDivFour>0 && CdotV>0); // if ray hits bounding sphere
}
#endif

12
Assets/ScriptableRenderLoop/fptl/LightingUtils.hlsl


int2 coord = pixCoord - int2(1, 1);
float3 color = lerp(c, pow(col.xyz, 2.2), 0.3*col.w);
if (SampleDebugFontNumber(coord, numLights)) // Shadow
color = 0.0f;
if (SampleDebugFontNumber(coord + 1, numLights)) // Text
color = 1.0f;
if(numLights > 0)
{
if (SampleDebugFontNumber(coord, numLights)) // Shadow
color = 0.0f;
if (SampleDebugFontNumber(coord + 1, numLights)) // Text
color = 1.0f;
}
return color;
}

86
Assets/ScriptableRenderLoop/fptl/lightlistbuild-bigtile.compute


#include "LightDefinitions.cs.hlsl"
#include "LightingConvexHullUtils.hlsl"
#include "SortingComputeUtils.hlsl"
#define EXACT_EDGE_TESTS
#define PERFORM_SPHERICAL_INTERSECTION_TESTS

return length( float2(1.0/fSx,1.0/fSy) );
}
void sortLightList(int localThreadID, int n);
#ifdef PERFORM_SPHERICAL_INTERSECTION_TESTS
void SphericalIntersectionTests(uint threadID, int iNrCoarseLights, float2 screenCoordinate);

// sort lights
sortLightList((int) t, iNrCoarseLights); // sorting on GCN as well for now since we need the culled lights weeded out.
SORTLIST(lightsListLDS, iNrCoarseLights, MAX_NR_BIGTILE_LIGHTS_PLUSONE, t, NR_THREADS);
lightOffs = 0;
GroupMemoryBarrierWithGroupSync();

}
// NOTE! returns 1 when value_in==0
unsigned int LimitPow2AndClamp(unsigned int value_in, unsigned int maxValue)
{
unsigned int value = 1;
while(value<value_in && (value<<1)<=maxValue)
value<<=1;
return value;
}
void sortLightList(int localThreadID, int length)
{
// closest pow2 integer greater than or equal to length
const int N = (const int) LimitPow2AndClamp((unsigned int) length, MAX_NR_BIGTILE_LIGHTS_PLUSONE); // N is 1 when length is zero but will still not enter first for-loop
// bitonic sort can only handle arrays with a power of two length. Fill remaining entries with greater than possible index.
for(int t=length+localThreadID; t<N; t+=NR_THREADS) { lightsListLDS[t]=0xffffffff; } // impossible index
GroupMemoryBarrierWithGroupSync();
for(int k=2; k<=N; k=2*k)
{
for(int j=k>>1; j>0; j=j>>1)
{
for(int i=localThreadID; i<N; i+=NR_THREADS)
{
int ixj=i^j;
if((ixj)>i)
{
const unsigned int Avalue = lightsListLDS[i];
const unsigned int Bvalue = lightsListLDS[ixj];
const bool mustSwap = ((i&k)!=0^(Avalue>Bvalue)) && Avalue!=Bvalue;
if(mustSwap)
{
lightsListLDS[i]=Bvalue;
lightsListLDS[ixj]=Avalue;
}
}
}
GroupMemoryBarrierWithGroupSync();
}
}
}
#ifdef PERFORM_SPHERICAL_INTERSECTION_TESTS
void SphericalIntersectionTests(uint threadID, int iNrCoarseLights, float2 screenCoordinate)
{

#endif
float onePixDiagDist = GetOnePixDiagWorldDistAtDepthOne();
float worldDistAtDepthOne = 32*onePixDiagDist; // scale by half a tile
float halfTileSizeAtZDistOne = 32*onePixDiagDist; // scale by half a tile
int iNrVisib = 0;
const float3 center = lgtDat.center.xyz;
float fRad = lgtDat.radius;
#if 1
float3 maxZdir = float3(-center.z*center.x, -center.z*center.y, center.x*center.x + center.y*center.y); // cross(center,cross(Zaxis,center))
float len = length(maxZdir);
float scalarProj = len>0.0001 ? (maxZdir.z/len) : len; // since len>=(maxZdir.z/len) we can use len as an approximate value when len<=epsilon
float fOffs = scalarProj*fRad;
#else
float fOffs = fRad; // more false positives due to larger radius but works too
#endif
#ifdef LEFT_HAND_COORDINATES
fRad = fRad + (center.z+fOffs)*worldDistAtDepthOne;
#else
fRad = fRad - (center.z-fOffs)*worldDistAtDepthOne;
#endif
float a = dot(V,V);
float CdotV = dot(center,V);
float c = dot(center,center) - fRad*fRad;
float fDescDivFour = CdotV*CdotV - a*c;
if(!(c<0 || (fDescDivFour>0 && CdotV>0))) // if ray misses bounding sphere
if( !DoesSphereOverlapTile(V, halfTileSizeAtZDistOne, lgtDat.center.xyz, lgtDat.radius) )
lightsListLDS[l]=0xffffffff;
}

87
Assets/ScriptableRenderLoop/fptl/lightlistbuild-clustered.compute


#include "LightingConvexHullUtils.hlsl"
#if !defined(XBONE) && !defined(PLAYSTATION4)
#include "SortingComputeUtils.hlsl"
#endif
//#define EXACT_EDGE_TESTS
#define PERFORM_SPHERICAL_INTERSECTION_TESTS
#define CONV_HULL_TEST_ENABLED

return length( float2(1.0/fSx,1.0/fSy) );
}
void sortLightList(int localThreadID, int n);
#ifdef EXACT_EDGE_TESTS
int CullByExactEdgeTests(uint threadID, int iNrCoarseLights, uint2 viTilLL, uint2 viTilUR, float fTileFarPlane);

// sort lights
#if !defined(XBONE) && !defined(PLAYSTATION4)
sortLightList((int) t, iNrCoarseLights);
SORTLIST(coarseList, iNrCoarseLights, MAX_NR_COARSE_ENTRIES, t, NR_THREADS);
#endif
//////////// cell specific code

}
// NOTE! returns 1 when value_in==0
unsigned int LimitPow2AndClamp(unsigned int value_in, unsigned int maxValue)
{
unsigned int value = 1;
while(value<value_in && (value<<1)<=maxValue)
value<<=1;
return value;
}
void sortLightList(int localThreadID, int length)
{
// closest pow2 integer greater than or equal to length
const int N = (const int) LimitPow2AndClamp((unsigned int) length, MAX_NR_COARSE_ENTRIES); // N is 1 when length is zero but will still not enter first for-loop
// bitonic sort can only handle arrays with a power of two length. Fill remaining entries with greater than possible index.
for(int t=length+localThreadID; t<N; t+=NR_THREADS) { coarseList[t]=0xffffffff; } // impossible index
GroupMemoryBarrierWithGroupSync();
for(int k=2; k<=N; k=2*k)
{
for(int j=k>>1; j>0; j=j>>1)
{
for(int i=localThreadID; i<N; i+=NR_THREADS)
{
int ixj=i^j;
if((ixj)>i)
{
const unsigned int Avalue = coarseList[i];
const unsigned int Bvalue = coarseList[ixj];
const bool mustSwap = ((i&k)!=0^(Avalue>Bvalue)) && Avalue!=Bvalue;
if(mustSwap)
{
coarseList[i]=Bvalue;
coarseList[ixj]=Avalue;
}
}
}
GroupMemoryBarrierWithGroupSync();
}
}
}
float4 FetchPlane(int l, int p)
{
SFiniteLightBound lgtDat = g_data[coarseList[l]];

#endif
float onePixDiagDist = GetOnePixDiagWorldDistAtDepthOne();
float worldDistAtDepthOne = 8*onePixDiagDist; // scale by half a tile
float halfTileSizeAtZDistOne = 8*onePixDiagDist; // scale by half a tile
int iNrVisib = 0;
const float3 center = lgtDat.center.xyz;
float fRad = lgtDat.radius;
#if 1
float3 maxZdir = float3(-center.z*center.x, -center.z*center.y, center.x*center.x + center.y*center.y); // cross(center,cross(Zaxis,center))
float len = length(maxZdir);
float scalarProj = len>0.0001 ? (maxZdir.z/len) : len; // since len>=(maxZdir.z/len) we can use len as an approximate value when len<=epsilon
float fOffs = scalarProj*fRad;
#else
float fOffs = fRad; // more false positives due to larger radius but works too
#endif
#ifdef LEFT_HAND_COORDINATES
fRad = fRad + (center.z+fOffs)*worldDistAtDepthOne;
#else
fRad = fRad - (center.z-fOffs)*worldDistAtDepthOne;
#endif
float a = dot(V,V);
float CdotV = dot(center,V);
float c = dot(center,center) - fRad*fRad;
float fDescDivFour = CdotV*CdotV - a*c;
if(!(c<0 || (fDescDivFour>0 && CdotV>0))) // if ray misses bounding sphere
if( !DoesSphereOverlapTile(V, halfTileSizeAtZDistOne, lgtDat.center.xyz, lgtDat.radius) )
coarseList[l]=0xffffffff;
}

165
Assets/ScriptableRenderLoop/fptl/lightlistbuild.compute


#include "..\common\ShaderBase.h"
#include "LightDefinitions.cs.hlsl"
#include "LightingConvexHullUtils.hlsl"
#if !defined(XBONE) && !defined(PLAYSTATION4)
#include "SortingComputeUtils.hlsl"
#endif
#define FINE_PRUNING_ENABLED
#define PERFORM_SPHERICAL_INTERSECTION_TESTS

return length( float2(1.0/fSx,1.0/fSy) );
}
void sortLightList(int localThreadID, int n);
#ifdef PERFORM_SPHERICAL_INTERSECTION_TESTS
int SphericalIntersectionTests(uint threadID, int iNrCoarseLights, float2 screenCoordinate);

// sort lights
#if !defined(XBONE) && !defined(PLAYSTATION4)
sortLightList((int) t, nrLightsCombinedList);
SORTLIST(prunedList, nrLightsCombinedList, MAX_NR_COARSE_ENTRIES, t, NR_THREADS);
//MERGESORTLIST(prunedList, coarseList, nrLightsCombinedList, t, NR_THREADS);
#endif
// write lights to global buffers

}
// original version
//float2 vRay2D = float2(max(V.x,V.y), fSclProj);
//float distSqB = bIsSpotDisc ? distSq : dot(vRay2D,vRay2D);
//if( all( float3(lightData.radiusSq, fSclProj, fSclProj) > float3(distSq, sqrt(distSqB)*lightData.fPenumbra, 0.0) ) ) uVal = 1;
// previous new version
//float fDist2DSqr = bIsSpotDisc ? dot(V,V) : (maC*maC);
//if( all( float3(lightData.radiusSq, (fSclProj*fSclProj), fSclProj) > float3(distSq, fDist2DSqr*cotaSqr, fSpotNearPlane) ) ) uVal = 1;
#if 0
void merge(int l, int m, int r);
void sortLightList(int localThreadID, int n)
{
for(int curr_size=1; curr_size<=n-1; curr_size = 2*curr_size)
{
for(int left_start=localThreadID*(2*curr_size); left_start<(n-1); left_start+=NR_THREADS*(2*curr_size))
{
int mid = left_start + curr_size - 1;
int right_end = min(left_start + 2*curr_size - 1, n-1);
merge(left_start, mid, right_end);
}
GroupMemoryBarrierWithGroupSync();
}
}
//groupshared unsigned int tmpBuffer[MAX_NR_COARSE_ENTRIES];
void merge(int l, int m, int r)
{
int i, j, k;
int ol = l;
int or = m+1;
int sl = m - l + 1; // capacity is size of left list = m - l + 1;
int sr = r - m; // capacity is size of right list = r - m
unsigned int tmpBuffer[] = coarseList; // re use coarse list buffer as temp buffer.
// could do this copy more efficiently before the if-statement
// in sortLightList() but this requires another GroupMemoryBarrierWithGroupSync()
for(int i=l; i<=r; i++) tmpBuffer[i] = prunedList[i];
i = 0;
j = 0;
k = l;
while (i < sl && j < sr)
{
const uint lVal = tmpBuffer[ol+i];
const uint rVal = tmpBuffer[or+j];
bool pickLeft = lVal <= rVal;
i = pickLeft ? (i+1) : i;
j = pickLeft ? j : (j+1);
prunedList[k] = pickLeft ? lVal : rVal;
k++;
}
while (i < sl)
{
prunedList[k] = tmpBuffer[ol+i];
i++; k++;
}
while (j < sr)
{
prunedList[k] = tmpBuffer[or+j];
j++; k++;
}
}
#else
// NOTE! returns 1 when value_in==0
unsigned int LimitPow2AndClamp(unsigned int value_in, unsigned int maxValue)
{
unsigned int value = 1;
while(value<value_in && (value<<1)<=maxValue)
value<<=1;
return value;
}
void sortLightList(int localThreadID, int length)
{
// closest pow2 integer greater than or equal to length
const int N = (const int) LimitPow2AndClamp((unsigned int) length, MAX_NR_COARSE_ENTRIES); // N is 1 when length is zero but will still not enter first for-loop
// bitonic sort can only handle arrays with a power of two length. Fill remaining entries with greater than possible index.
for(int t=length+localThreadID; t<N; t+=NR_THREADS) { prunedList[t]=0xffffffff; } // impossible index
GroupMemoryBarrierWithGroupSync();
for(int k=2; k<=N; k=2*k)
{
for(int j=k>>1; j>0; j=j>>1)
{
for(int i=localThreadID; i<N; i+=NR_THREADS)
{
int ixj=i^j;
if((ixj)>i)
{
const unsigned int Avalue = prunedList[i];
const unsigned int Bvalue = prunedList[ixj];
const bool mustSwap = ((i&k)!=0^(Avalue>Bvalue)) && Avalue!=Bvalue;
if(mustSwap)
{
prunedList[i]=Bvalue;
prunedList[ixj]=Avalue;
}
}
}
GroupMemoryBarrierWithGroupSync();
}
}
}
#endif
#ifdef PERFORM_SPHERICAL_INTERSECTION_TESTS
int SphericalIntersectionTests(uint threadID, int iNrCoarseLights, float2 screenCoordinate)

#endif
float onePixDiagDist = GetOnePixDiagWorldDistAtDepthOne();
float worldDistAtDepthOne = 8*onePixDiagDist; // scale by half a tile
float halfTileSizeAtZDistOne = 8*onePixDiagDist; // scale by half a tile
int iNrVisib = 0;
const float3 center = lightData.center.xyz;
float fRad = lightData.radius;
#if 1
float3 maxZdir = float3(-center.z*center.x, -center.z*center.y, center.x*center.x + center.y*center.y); // cross(center,cross(Zaxis,center))
float len = length(maxZdir);
float scalarProj = len>0.0001 ? (maxZdir.z/len) : len; // since len>=(maxZdir.z/len) we can use len as an approximate value when len<=epsilon
float fOffs = scalarProj*fRad;
#else
float fOffs = fRad; // more false positives due to larger radius but works too
#endif
#ifdef LEFT_HAND_COORDINATES
fRad = fRad + (center.z+fOffs)*worldDistAtDepthOne;
#else
fRad = fRad - (center.z-fOffs)*worldDistAtDepthOne;
#endif
float a = dot(V,V);
float CdotV = dot(center,V);
float c = dot(center,center) - fRad*fRad;
float fDescDivFour = CdotV*CdotV - a*c;
if(c<0 || (fDescDivFour>0 && CdotV>0)) // if ray hit bounding sphere
if( DoesSphereOverlapTile(V, halfTileSizeAtZDistOne, lightData.center.xyz, lightData.radius) )
{
unsigned int uIndex;
InterlockedAdd(lightOffsSph, 1, uIndex);

2
Assets/ScriptableRenderLoop/fptl/renderloopfptl.asset


type: 3}
buildPerTileLightListShader: {fileID: 7200000, guid: f54ef7cb596a714488693ef9cdaf63fb,
type: 3}
buildPerBigTileLightListShader: {fileID: 7200000, guid: 5e4803ac37c1def45bde7c3f69a8df7a,
buildPerBigTileLightListShader: {fileID: 7200000, guid: b5507a2ffdae8a84f94211c10d428920,
type: 3}
buildPerVoxelLightListShader: {fileID: 7200000, guid: 4c2d6eb0553e2514bba3ea9a85d8c53c,
type: 3}

205
Assets/TestScenes/HDTest/HDRenderLoopTest.unity


m_EditorClassIdentifier:
shadowResolution: 512
innerSpotPercent: 49
shadowDimmer: 1
affectDiffuse: 1
affectSpecular: 1
--- !u!108 &580932149
Light:
m_ObjectHideFlags: 0

m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: e641a36bceddbf24a89656e94dafb3e5, type: 2}
m_IsPrefabParent: 0
--- !u!1 &733865593
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 733865594}
- component: {fileID: 733865595}
m_Layer: 0
m_Name: Spotlight
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &733865594
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 733865593}
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: -0.471, y: 7.317, z: 0.97}
m_LocalScale: {x: 0.5, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 2070887976}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!108 &733865595
Light:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 733865593}
m_Enabled: 1
serializedVersion: 7
m_Type: 0
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 8
m_Range: 13.18
m_SpotAngle: 79.1
m_CookieSize: 10
m_Shadows:
m_Type: 1
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1001 &744696321
Prefab:
m_ObjectHideFlags: 0

m_EditorClassIdentifier:
shadowResolution: 512
innerSpotPercent: 49
shadowDimmer: 1
affectDiffuse: 1
affectSpecular: 1
--- !u!108 &970745599
Light:
m_ObjectHideFlags: 0

m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!1 &2070887972
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 2070887976}
- component: {fileID: 2070887975}
- component: {fileID: 2070887974}
- component: {fileID: 2070887973}
m_Layer: 0
m_Name: Test - Spot light shadow
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!23 &2070887973
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2070887972}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 9d65ced14251eb743ba9702a6f3c2ce8, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
--- !u!64 &2070887974
MeshCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2070887972}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Convex: 0
m_InflateMesh: 0
m_SkinWidth: 0.01
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &2070887975
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2070887972}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &2070887976
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2070887972}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -40.34, y: -0.99, z: -3.09}
m_LocalScale: {x: 2, y: 1, z: 1}
m_Children:
- {fileID: 2082383796}
- {fileID: 733865594}
m_Father: {fileID: 0}
m_RootOrder: 22
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &2082383795
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 2070887976}
m_Modifications:
- target: {fileID: 4000010760374938, guid: 1faa212e4ad88f04a81c5ed019001de5, type: 2}
propertyPath: m_LocalPosition.x
value: 0.059999466
objectReference: {fileID: 0}
- target: {fileID: 4000010760374938, guid: 1faa212e4ad88f04a81c5ed019001de5, type: 2}
propertyPath: m_LocalPosition.y
value: 2.33
objectReference: {fileID: 0}
- target: {fileID: 4000010760374938, guid: 1faa212e4ad88f04a81c5ed019001de5, type: 2}
propertyPath: m_LocalPosition.z
value: 1.7599999
objectReference: {fileID: 0}
- target: {fileID: 4000010760374938, guid: 1faa212e4ad88f04a81c5ed019001de5, type: 2}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4000010760374938, guid: 1faa212e4ad88f04a81c5ed019001de5, type: 2}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4000010760374938, guid: 1faa212e4ad88f04a81c5ed019001de5, type: 2}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4000010760374938, guid: 1faa212e4ad88f04a81c5ed019001de5, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4000010760374938, guid: 1faa212e4ad88f04a81c5ed019001de5, type: 2}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4000010760374938, guid: 1faa212e4ad88f04a81c5ed019001de5, type: 2}
propertyPath: m_LocalScale.x
value: 0.5
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 1faa212e4ad88f04a81c5ed019001de5, type: 2}
m_IsPrefabParent: 0
--- !u!4 &2082383796 stripped
Transform:
m_PrefabParentObject: {fileID: 4000010760374938, guid: 1faa212e4ad88f04a81c5ed019001de5,
type: 2}
m_PrefabInternal: {fileID: 2082383795}
--- !u!1 &2102536477
GameObject:
m_ObjectHideFlags: 0

226
Assets/TestScenes/HDTest/Leaf/GroundLeaf/Materials/GroundLeaf_Albedo.mat


m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
serializedVersion: 3
- first:
name: _BaseColorMap
second:
- _BaseColorMap:
- first:
name: _BumpMap
second:
- _BumpMap:
- first:
name: _DetailAlbedoMap
second:
- _DetailAlbedoMap:
- first:
name: _DetailMask
second:
- _DetailMask:
- first:
name: _DetailNormalMap
second:
- _DetailNormalMap:
- first:
name: _DiffuseLightingMap
second:
- _DiffuseLightingMap:
- first:
name: _EmissionMap
second:
- _EmissionMap:
- first:
name: _EmissiveColorMap
second:
- _EmissiveColorMap:
- first:
name: _HeightMap
second:
- _HeightMap:
- first:
name: _MainTex
second:
- _MainTex:
- first:
name: _MaskMap
second:
- _MaskMap:
- first:
name: _MetallicGlossMap
second:
- _MetallicGlossMap:
- first:
name: _NormalMap
second:
- _NormalMap:
- first:
name: _OcclusionMap
second:
- _OcclusionMap:
- first:
name: _ParallaxMap
second:
- _ParallaxMap:
- first:
name: _SpecularOcclusionMap
second:
- _SpecularOcclusionMap:
- first:
name: _SubSurfaceRadiusMap
second:
- _SubSurfaceRadiusMap:
- first:
name: _AlphaCutoff
second: 0.5
- first:
name: _AlphaCutoffEnable
second: 0
- first:
name: _BlendMode
second: 0
- first:
name: _BumpScale
second: 1
- first:
name: _CullMode
second: 0
- first:
name: _Cutoff
second: 0.5
- first:
name: _DetailNormalMapScale
second: 1
- first:
name: _DistortionDepthTest
second: 0
- first:
name: _DistortionOnly
second: 0
- first:
name: _DoubleSidedMode
second: 2
- first:
name: _DstBlend
second: 0
- first:
name: _EmissiveColorMode
second: 1
- first:
name: _EmissiveIntensity
second: 0
- first:
name: _GlossMapScale
second: 0.892
- first:
name: _Glossiness
second: 0.507
- first:
name: _GlossyReflections
second: 1
- first:
name: _HeightBias
second: 0
- first:
name: _HeightMapMode
second: 0
- first:
name: _HeightScale
second: 1
- first:
name: _MaterialId
second: 0
- first:
name: _Metalic
second: 0
- first:
name: _Metallic
second: 0
- first:
name: _Mettalic
second: 0
- first:
name: _Mode
second: 1
- first:
name: _NormalMapSpace
second: 0
- first:
name: _OcclusionStrength
second: 1
- first:
name: _Parallax
second: 0.02
- first:
name: _Smoothness
second: 0.5
- first:
name: _SmoothnessTextureChannel
second: 0
- first:
name: _SpecularHighlights
second: 1
- first:
name: _SrcBlend
second: 1
- first:
name: _SubSurfaceRadius
second: 0
- first:
name: _SurfaceType
second: 0
- first:
name: _UVSec
second: 0
- first:
name: _ZWrite
second: 1
- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BumpScale: 1
- _CullMode: 0
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DistortionDepthTest: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 2
- _DstBlend: 0
- _EmissiveColorMode: 1
- _EmissiveIntensity: 0
- _GlossMapScale: 0.892
- _Glossiness: 0.507
- _GlossyReflections: 1
- _HeightBias: 0
- _HeightMapMode: 0
- _HeightScale: 1
- _MaterialId: 0
- _Metalic: 0
- _Metallic: 0
- _Mettalic: 0
- _Mode: 1
- _NormalMapSpace: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SubSurfaceRadius: 0
- _SurfaceType: 0
- _UVSec: 0
- _ZWrite: 1
- first:
name: _BaseColor
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _Color
second: {r: 0.5882353, g: 0.5882353, b: 0.5882353, a: 1}
- first:
name: _EmissionColor
second: {r: 0, g: 0, b: 0, a: 1}
- first:
name: _EmissiveColor
second: {r: 0, g: 0, b: 0, a: 1}
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 0.5882353, g: 0.5882353, b: 0.5882353, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}

226
Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/CubeTransparent.mat


stringTagMap:
RenderType: Transparent
m_SavedProperties:
serializedVersion: 2
serializedVersion: 3
- first:
name: _BaseColorMap
second:
- _BaseColorMap:
- first:
name: _BumpMap
second:
- _BumpMap:
- first:
name: _DetailAlbedoMap
second:
- _DetailAlbedoMap:
- first:
name: _DetailMask
second:
- _DetailMask:
- first:
name: _DetailNormalMap
second:
- _DetailNormalMap:
- first:
name: _DiffuseLightingMap
second:
- _DiffuseLightingMap:
- first:
name: _EmissionMap
second:
- _EmissionMap:
- first:
name: _EmissiveColorMap
second:
- _EmissiveColorMap:
- first:
name: _HeightMap
second:
- _HeightMap:
- first:
name: _MainTex
second:
- _MainTex:
- first:
name: _MaskMap
second:
- _MaskMap:
- first:
name: _MetallicGlossMap
second:
- _MetallicGlossMap:
- first:
name: _NormalMap
second:
- _NormalMap:
- first:
name: _OcclusionMap
second:
- _OcclusionMap:
- first:
name: _ParallaxMap
second:
- _ParallaxMap:
- first:
name: _SpecularOcclusionMap
second:
- _SpecularOcclusionMap:
- first:
name: _SubSurfaceRadiusMap
second:
- _SubSurfaceRadiusMap:
- first:
name: _AlphaCutoff
second: 0.5
- first:
name: _AlphaCutoffEnable
second: 0
- first:
name: _BlendMode
second: 0
- first:
name: _BumpScale
second: 1
- first:
name: _CullMode
second: 2
- first:
name: _Cutoff
second: 0.5
- first:
name: _DetailNormalMapScale
second: 1
- first:
name: _DistortionDepthTest
second: 0
- first:
name: _DistortionOnly
second: 0
- first:
name: _DoubleSidedMode
second: 0
- first:
name: _DstBlend
second: 10
- first:
name: _EmissiveColorMode
second: 1
- first:
name: _EmissiveIntensity
second: 0
- first:
name: _GlossMapScale
second: 1
- first:
name: _Glossiness
second: 0.5
- first:
name: _GlossyReflections
second: 1
- first:
name: _HeightBias
second: 0
- first:
name: _HeightMapMode
second: 0
- first:
name: _HeightScale
second: 1
- first:
name: _MaterialId
second: 0
- first:
name: _Metalic
second: 0
- first:
name: _Metallic
second: 0
- first:
name: _Mettalic
second: 0
- first:
name: _Mode
second: 0
- first:
name: _NormalMapSpace
second: 0
- first:
name: _OcclusionStrength
second: 1
- first:
name: _Parallax
second: 0.02
- first:
name: _Smoothness
second: 0.5
- first:
name: _SmoothnessTextureChannel
second: 0
- first:
name: _SpecularHighlights
second: 1
- first:
name: _SrcBlend
second: 5
- first:
name: _SubSurfaceRadius
second: 0
- first:
name: _SurfaceType
second: 1
- first:
name: _UVSec
second: 0
- first:
name: _ZWrite
second: 0
- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BumpScale: 1
- _CullMode: 2
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DistortionDepthTest: 0
- _DistortionOnly: 0
- _DoubleSidedMode: 0
- _DstBlend: 10
- _EmissiveColorMode: 1
- _EmissiveIntensity: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _HeightBias: 0
- _HeightMapMode: 0
- _HeightScale: 1
- _MaterialId: 0
- _Metalic: 0
- _Metallic: 0
- _Mettalic: 0
- _Mode: 0
- _NormalMapSpace: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 5
- _SubSurfaceRadius: 0
- _SurfaceType: 1
- _UVSec: 0
- _ZWrite: 0
- first:
name: _BaseColor
second: {r: 0.9117647, g: 0.1273789, b: 0.1273789, a: 0.566}
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _EmissionColor
second: {r: 0, g: 0, b: 0, a: 1}
- first:
name: _EmissiveColor
second: {r: 0, g: 0, b: 0, a: 1}
- _BaseColor: {r: 0.9117647, g: 0.1273789, b: 0.1273789, a: 0.566}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}

294
Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/test-transparent.mat


stringTagMap:
RenderType: Transparent
m_SavedProperties:
serializedVersion: 2
serializedVersion: 3
- first:
name: _AmbientOcclusionMap
second:
- _AmbientOcclusionMap:
- first:
name: _BaseColorMap
second:
- _BaseColorMap:
- first:
name: _BumpMap
second:
- _BumpMap:
- first:
name: _CoatCoverageMap
second:
- _CoatCoverageMap:
- first:
name: _CoatRoughnessMap
second:
- _CoatRoughnessMap:
- first:
name: _DetailAlbedoMap
second:
- _DetailAlbedoMap:
- first:
name: _DetailMask
second:
- _DetailMask:
- first:
name: _DetailNormalMap
second:
- _DetailNormalMap:
- first:
name: _DiffuseLightingMap
second:
- _DiffuseLightingMap:
- first:
name: _DiffuseMap
second:
- _DiffuseMap:
- first:
name: _EmissionMap
second:
- _EmissionMap:
- first:
name: _EmissiveColorMap
second:
- _EmissiveColorMap:
- first:
name: _HeightMap
second:
- _HeightMap:
- first:
name: _MainTex
second:
- _MainTex:
- first:
name: _MaskMap
second:
- _MaskMap:
- first:
name: _MetallicGlossMap
second:
- _MetallicGlossMap:
- first:
name: _MettalicMap
second:
- _MettalicMap:
- first:
name: _NormalMap
second:
- _NormalMap:
- first:
name: _OcclusionMap
second:
- _OcclusionMap:
- first:
name: _ParallaxMap
second:
- _ParallaxMap:
- first:
name: _SmoothnessMap
second:
- _SmoothnessMap:
- first:
name: _SpecMap
second:
- _SpecMap:
- first:
name: _SpecularOcclusionMap
second:
- _SpecularOcclusionMap:
- first:
name: _SubSurfaceRadiusMap
second:
- _SubSurfaceRadiusMap:
- first:
name: _ThicknessMap
second:
- _ThicknessMap:
- first:
name: _AlphaCutoff
second: 0.5
- first:
name: _AlphaCutoffEnable
second: 0
- first:
name: _BlendMode
second: 0
- first:
name: _BumpScale
second: 1
- first:
name: _CoatCoverage
second: 0
- first:
name: _CoatRoughness
second: 0
- first:
name: _CullMode
second: 2
- first:
name: _Cutoff
second: 0.5
- first:
name: _DetailNormalMapScale
second: 1
- first:
name: _DistortionDepthTest
second: 0
- first:
name: _DistortionOnly
second: 0
- first:
name: _DoubleSided
second: 1
- first:
name: _DoubleSidedLigthing
second: 1
- first:
name: _DoubleSidedMode
second: 0
- first:
name: _DstBlend
second: 10
- first:
name: _EmissiveColorMode
second: 1
- first:
name: _EmissiveIntensity
second: 0
- first:
name: _GlossMapScale
second: 1
- first:
name: _Glossiness
second: 0.5
- first:
name: _GlossyReflections
second: 1
- first:
name: _HeightBias
second: 0
- first:
name: _HeightMapMode
second: 0
- first:
name: _HeightScale
second: 1
- first:
name: _MaterialID
second: 0
- first:
name: _MaterialId
second: 0
- first:
name: _Metalic
second: 0
- first:
name: _Metallic
second: 0
- first:
name: _Mettalic
second: 0
- first:
name: _Mode
second: 0
- first:
name: _NormalMapSpace
second: 0
- first:
name: _OcclusionStrength
second: 1
- first:
name: _Parallax
second: 0.02
- first:
name: _Smoothness
second: 0.524
- first:
name: _SmoothnessTextureChannel
second: 0
- first:
name: _SpecularHighlights
second: 1
- first:
name: _SrcBlend
second: 5
- first:
name: _SubSurfaceProfile
second: 0
- first:
name: _SubSurfaceRadius
second: 0
- first:
name: _SurfaceType
second: 1
- first:
name: _Thickness
second: 0
- first:
name: _UVSec
second: 0
- first:
name: _ZWrite
second: 0
- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BumpScale: 1
- _CoatCoverage: 0
- _CoatRoughness: 0
- _CullMode: 2
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DistortionDepthTest: 0
- _DistortionOnly: 0
- _DoubleSided: 1
- _DoubleSidedLigthing: 1
- _DoubleSidedMode: 0
- _DstBlend: 10
- _EmissiveColorMode: 1
- _EmissiveIntensity: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _HeightBias: 0
- _HeightMapMode: 0
- _HeightScale: 1
- _MaterialID: 0
- _MaterialId: 0
- _Metalic: 0
- _Metallic: 0
- _Mettalic: 0
- _Mode: 0
- _NormalMapSpace: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Smoothness: 0.524
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 5
- _SubSurfaceProfile: 0
- _SubSurfaceRadius: 0
- _SurfaceType: 1
- _Thickness: 0
- _UVSec: 0
- _ZWrite: 0
- first:
name: _BaseColor
second: {r: 1, g: 1, b: 1, a: 0.397}
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _DiffuseColor
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _EmissionColor
second: {r: 0, g: 0, b: 0, a: 1}
- first:
name: _EmissiveColor
second: {r: 0, g: 0, b: 0, a: 1}
- first:
name: _SpecColor
second: {r: 0.04, g: 0.04, b: 0.04, a: 1}
- _BaseColor: {r: 1, g: 1, b: 1, a: 0.397}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DiffuseColor: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.04, g: 0.04, b: 0.04, a: 1}

5
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs.hlsl


//
// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/ShadowDefinition.cs. Please don't edit by hand.
// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs. Please don't edit by hand.
#ifndef SHADOWDEFINITION_CS_HLSL
#define SHADOWDEFINITION_CS_HLSL
//
// UnityEngine.Experimental.ScriptableRenderLoop.ShadowType: static fields
//

}
#endif

8
Assets/ShaderGenerator/Editor/CSharpToHLSL.cs


using (var writer = File.CreateText(fileName))
{
var guard = Path.GetFileName(fileName).Replace(".", "_").ToUpper();
if (!char.IsLetter(guard[0]))
guard = "_" + guard;
writer.Write("#ifndef " + guard + "\n");
writer.Write("#define " + guard + "\n");
foreach (var gen in it.Value)
{

}
}
writer.Write("\n");
writer.Write("\n#endif\n");
}
}
}

32
Assets/ShaderGenerator/Editor/ShaderTypeGeneration.cs


namespace UnityEngine.Experimental.ScriptableRenderLoop
{
public enum PackingRules
{
Exact,
Aggressive
};
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Enum)]
public class GenerateHLSL : System.Attribute
{
public PackingRules packingRules;
public bool needAccessors; // Whether or not to generate the accessors
public bool needParamDefines; // Wheter or not to generate define for each parameters of the struc
public int paramDefinesStart; // Start of the generated define
public GenerateHLSL(PackingRules rules = PackingRules.Exact, bool needAccessors = true, bool needParamDefines = false, int paramDefinesStart = 1)
{
packingRules = rules;
this.needAccessors = needAccessors;
this.needParamDefines = needParamDefines;
this.paramDefinesStart = paramDefinesStart;
}
}
[AttributeUsage(AttributeTargets.Field)]
public class SurfaceDataAttributes : System.Attribute
{
public string displayName;
public SurfaceDataAttributes(string displayName = "")
{
this.displayName = displayName;
}
}
internal class ShaderTypeGenerator
{
public ShaderTypeGenerator(Type type, GenerateHLSL attr)

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow.meta


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

63
Assets/ScriptableRenderLoop/ShaderLibrary/CommonMaterial.hlsl


#ifndef UNITY_COMMON_MATERIAL_INCLUDED
#define UNITY_COMMON_MATERIAL_INCLUDED
//-----------------------------------------------------------------------------
// Helper function for anisotropy
//-----------------------------------------------------------------------------
// Ref: http://blog.selfshadow.com/publications/s2012-shading-course/burley/s2012_pbs_disney_brdf_notes_v3.pdf (in addenda)
// Convert anisotropic ratio (0->no isotropic; 1->full anisotropy in tangent direction) to roughness
void ConvertAnisotropyToRoughness(float roughness, float anisotropy, out float roughnessT, out float roughnessB)
{
float anisoAspect = sqrt(1.0 - 0.9 * anisotropy);
roughnessT = roughness * anisoAspect;
roughnessB = roughness / anisoAspect;
}
// Fake anisotropic by distorting the normal as suggested by:
// Ref: Donald Revie - Implementing Fur Using Deferred Shading (GPU Pro 2)
// anisotropic ratio (0->no isotropic; 1->full anisotropy in tangent direction)
float3 GetAnisotropicModifiedNormal(float3 N, float3 T, float3 V, float anisotropy)
{
float3 anisoT = cross(-V, T);
float3 anisoN = cross(anisoT, T);
return normalize(lerp(N, anisoN, anisotropy));
}
//-----------------------------------------------------------------------------
// Helper function for perceptual roughness
//-----------------------------------------------------------------------------
float PerceptualRoughnessToRoughness(float perceptualRoughness)
{
return perceptualRoughness * perceptualRoughness;
}
float RoughnessToPerceptualRoughness(float roughness)
{
return sqrt(roughness);
}
float PerceptualSmoothnessToRoughness(float perceptualSmoothness)
{
return (1 - perceptualSmoothness) * (1 - perceptualSmoothness);
}
float PerceptualSmoothnessToPerceptualRoughness(float perceptualSmoothness)
{
return (1 - perceptualSmoothness);
}
// ----------------------------------------------------------------------------
// Parallax mapping
// ----------------------------------------------------------------------------
float2 ParallaxOffset(float3 viewDirTS, float height)
{
// Parallax mapping with offset limiting to reduce weird artifcat (i.e do not divide by z), also save performance
return viewDirTS.xy * height;
}
#endif // UNITY_COMMON_MATERIAL_INCLUDED

9
Assets/ScriptableRenderLoop/ShaderLibrary/CommonMaterial.hlsl.meta


fileFormatVersion: 2
guid: 540178d5ddc29e74da771e38536aee22
timeCreated: 1477404191
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

14
Assets/ScriptableRenderLoop/ShaderLibrary/CommonShadow.hlsl


#ifndef UNITY_COMMON_SHADOW_INCLUDED
#define UNITY_COMMON_SHADOW_INCLUDED
// Ref: https://mynameismjp.wordpress.com/2015/02/18/shadow-sample-update/
// Calculates the offset to use for sampling the shadow map, based on the surface normal
float3 GetShadowPosOffset(float NdotL, float3 normalWS, float2 invShadowMapSize)
{
float texelSize = 2.0 * invShadowMapSize.x;
float offsetScaleNormalize = saturate(1.0 - NdotL);
// return texelSize * OffsetScale * offsetScaleNormalize * normalWS;
return texelSize * offsetScaleNormalize * normalWS;
}
#endif // UNITY_COMMON_SHADOW_INCLUDED

9
Assets/ScriptableRenderLoop/ShaderLibrary/CommonShadow.hlsl.meta


fileFormatVersion: 2
guid: a85db80be6def144e938df4cbf0d1aa6
timeCreated: 1477397630
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Assets/ScriptableRenderLoop/fptl/LightingConvexHullUtils.hlsl.meta


fileFormatVersion: 2
guid: 97c18f9b04997a34aa7a246dbc1b2fac
timeCreated: 1477394758
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

117
Assets/ScriptableRenderLoop/fptl/SortingComputeUtils.hlsl


#ifndef __SORTINGCOMPUTEUTILS_H__
#define __SORTINGCOMPUTEUTILS_H__
unsigned int LimitPow2AndClamp(unsigned int value_in, unsigned int maxValue)
{
#if 0
unsigned int value = 1;
while(value<value_in && (value<<1)<=maxValue)
value<<=1;
return value_in==0 ? 0 : value;
#else
uint valpw2 = value_in==0 ? 0 : (1<<firstbithigh(value_in)); // firstbithigh(0) returns -1
valpw2 = max(valpw2, valpw2<<(valpw2!=value_in ? 1 : 0)); // max() just in case of overflow
return min(valpw2, maxValue);
#endif
}
// have to make this sort routine a macro unfortunately because hlsl doesn't take
// groupshared memory of unspecified length as an input parameter to a function.
// maxcapacity_in must be a power of two.
// all data from length_in and up to closest power of two will be filled with 0xffffffff
#define SORTLIST(data, length_in, maxcapacity_in, localThreadID_in, nrthreads_in) \
{ \
int length=(int) length_in, maxcapacity=(int) maxcapacity_in, localThreadID=(int) localThreadID_in, nrthreads=(int) nrthreads_in; \
\
const int N = (const int) LimitPow2AndClamp((unsigned int) length, (uint) maxcapacity); \
for(int t=length+localThreadID; t<N; t+=nrthreads) { data[t]=0xffffffff; } \
GroupMemoryBarrierWithGroupSync(); \
\
for(int k=2; k<=N; k=2*k) \
{ \
for(int j=k>>1; j>0; j=j>>1) \
{ \
for(int i=localThreadID; i<N; i+=nrthreads) \
{ \
int ixj=i^j; \
if((ixj)>i) \
{ \
const unsigned int Avalue = data[i]; \
const unsigned int Bvalue = data[ixj]; \
\
const bool mustSwap = ((i&k)!=0^(Avalue>Bvalue)) && Avalue!=Bvalue; \
if(mustSwap) \
{ \
data[i]=Bvalue; \
data[ixj]=Avalue; \
} \
} \
} \
\
GroupMemoryBarrierWithGroupSync(); \
} \
} \
}
// have to make this sort routine a macro unfortunately because hlsl doesn't take
// groupshared memory of unspecified length as an input parameter to a function.
// merge-sort is not in-place so two buffers are required: data and tmpdata.
// These must both have a capacity of at least length_in entries and initial
// input is assumed to be in data and results will be delivered in data.
#define MERGESORTLIST(data, tmpdata, length_in, localThreadID_in, nrthreads_in) \
{ \
int length=(int) length_in, localThreadID=(int) localThreadID_in, nrthreads=(int) nrthreads_in; \
\
for(int curr_size=1; curr_size<=length-1; curr_size = 2*curr_size) \
{ \
for(int left_start=localThreadID*(2*curr_size); left_start<(length-1); left_start+=nrthreads*(2*curr_size)) \
{ \
int mid = left_start + curr_size - 1; \
int right_end = min(left_start + 2*curr_size - 1, length-1); \
{ \
int l=left_start, m=mid, r=right_end; \
\
int i, j, k; \
\
int ol = l; \
int or = m+1; \
int sl = m - l + 1; \
int sr = r - m; \
\
for(int i=l; i<=r; i++) tmpdata[i] = data[i]; \
\
i = 0; j = 0; k = l; \
while (i < sl && j < sr) \
{ \
const uint lVal = tmpdata[ol+i]; \
const uint rVal = tmpdata[or+j]; \
bool pickLeft = lVal <= rVal; \
i = pickLeft ? (i+1) : i; \
j = pickLeft ? j : (j+1); \
data[k] = pickLeft ? lVal : rVal; \
k++; \
} \
\
while (i < sl) \
{ \
data[k] = tmpdata[ol+i]; \
i++; k++; \
} \
\
while (j < sr) \
{ \
data[k] = tmpdata[or+j]; \
j++; k++; \
} \
} \
} \
\
GroupMemoryBarrierWithGroupSync(); \
} \
}
#endif

9
Assets/ScriptableRenderLoop/fptl/lightlistbuild-bigtile.compute.meta


fileFormatVersion: 2
guid: b5507a2ffdae8a84f94211c10d428920
timeCreated: 1477394781
licenseType: Pro
ComputeShaderImporter:
currentAPIMask: 4
userData:
assetBundleName:
assetBundleVariant:

9
Assets/ShaderGenerator/Editor.meta


fileFormatVersion: 2
guid: a7ecca2f74946b44494f07937e31b793
folderAsset: yes
timeCreated: 1477487246
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

38
Assets/ShaderGenerator/ShaderGeneratorAttributes.cs


using System;
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
public enum PackingRules
{
Exact,
Aggressive
};
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Enum)]
public class GenerateHLSL : System.Attribute
{
public PackingRules packingRules;
public bool needAccessors; // Whether or not to generate the accessors
public bool needParamDefines; // Wheter or not to generate define for each parameters of the struc
public int paramDefinesStart; // Start of the generated define
public GenerateHLSL(PackingRules rules = PackingRules.Exact, bool needAccessors = true, bool needParamDefines = false, int paramDefinesStart = 1)
{
packingRules = rules;
this.needAccessors = needAccessors;
this.needParamDefines = needParamDefines;
this.paramDefinesStart = paramDefinesStart;
}
}
[AttributeUsage(AttributeTargets.Field)]
public class SurfaceDataAttributes : System.Attribute
{
public string displayName;
public SurfaceDataAttributes(string displayName = "")
{
this.displayName = displayName;
}
}
}

12
Assets/ShaderGenerator/ShaderGeneratorAttributes.cs.meta


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

9
Assets/TestScenes/Big.meta


fileFormatVersion: 2
guid: ca7cab07164223b41b386440cf25cdca
folderAsset: yes
timeCreated: 1477402341
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/EVSM.meta


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

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/FixedSizePCF.meta


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

17
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/FixedSizePCF/FixedSizePCF.cs


using UnityEngine;
using UnityEngine.Experimental.Rendering;
using System;
//-----------------------------------------------------------------------------
// structure definition
//-----------------------------------------------------------------------------
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
public class ShadowFilteringFixedSizePCF
{
string GetKeyword()
{
return "SHADOWFILTERING_FIXED_SIZE_PCF";
}
};
}

12
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/FixedSizePCF/FixedSizePCF.cs.meta


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

17
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/FixedSizePCF/FixedSizePCF.hlsl


//-----------------------------------------------------------------------------
// Fixed size Kernel PCF filtering
// Ref: https://mynameismjp.wordpress.com/2015/02/18/shadow-sample-update/
// ----------------------------------------------------------------------------
// Here we define specific constant use by this shadow filtering algorithm
CBUFFER_START(UnityShadowPerLightLoop)
float4 _ShadowMapSize; // xy size, zw inv size
CBUFFER_END
// GetPunctualShadowAttenuation is the "default" algorithm use for punctual light, material can call explicitely a particular algorithm if required (in this case users must ensure that the algorithm is present in the project).
// TODO: how this work related to shadow format ?
float GetShadowAttenuationFixedSizePCF(LightLoopContext lightLoopContext, int index, PunctualShadowData shadowData, float3 shadowCoord, float3 shadowPosDX, float3 shadowPosDY, float2 unPositionSS)
{
return SampleShadowCompare(lightLoopContext, index, shadowCoord).x;
}

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/FixedSizePCF/FixedSizePCF.hlsl.meta


fileFormatVersion: 2
guid: 1a0e3eff5288ddd409f3fb0bef8f9de9
timeCreated: 1477395058
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

22
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/Shadow.hlsl


// TODO:
// - How to support a Gather sampling with such abstraction ?
// - What's belong to shadow and what's belong to renderloop ? (shadowmap size depends on the usage of atlas or not)
// - Is PunctualShadowData fixed or customizable ? Who is the owner ? Should it be pass to GetPunctualShadowAttenuation ? Sure it should...
// - Could be return by GetShadowTextureCoordinate() and pass to GetPunctualShadowAttenuation(). But in this case, who control the atlas application ?
// TODO:
// Caution: formula doesn't work as we are texture atlas...
// if (max3(abs(NDC.x), abs(NDC.y), 1.0f - texCoordXYZ.z) <= 1.0f) return 1.0;
#ifdef SHADOWFILTERING_FIXED_SIZE_PCF
#include "FixedSizePCF/FixedSizePCF.hlsl"
#endif
// GetPunctualShadowAttenuation is the "default" algorithm use for punctual light, material can call explicitely a particular algorithm if required (in this case users must ensure that the algorithm is present in the project).
float GetPunctualShadowAttenuation(LightLoopContext lightLoopContext, int index, PunctualShadowData shadowData, float3 shadowCoord, float3 shadowPosDX, float3 shadowPosDY, float2 unPositionSS)
{
#ifdef SHADOWFILTERING_FIXED_SIZE_PCF
return GetShadowAttenuationFixedSizePCF(lightLoopContext, index, shadowData, shadowCoord, shadowPosDX, shadowPosDY, unPositionSS);
#else
return 1.0;
#endif
}

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/Shadow.hlsl.meta


fileFormatVersion: 2
guid: 1c64d27a91e935140a9f402077f52fa0
timeCreated: 1477395059
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

30
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs


using UnityEngine;
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
//-----------------------------------------------------------------------------
// structure definition
//-----------------------------------------------------------------------------
[GenerateHLSL]
public enum ShadowType
{
Spot,
Directional,
Point
};
// TODO: we may have to add various parameters here for shadow
// A point light is 6x PunctualShadowData
[GenerateHLSL]
public struct PunctualShadowData
{
// World to ShadowMap matrix
// Include scale and bias for shadow atlas if any
public Matrix4x4 worldToShadow;
public ShadowType shadowType;
public Vector3 unused;
};
} // namespace UnityEngine.Experimental.ScriptableRenderLoop

25
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Shadow.hlsl


//-----------------------------------------------------------------------------
// Shadow
// Ref: https://mynameismjp.wordpress.com/2015/02/18/shadow-sample-update/
// ----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
// Calculates the offset to use for sampling the shadow map, based on the surface normal
//-------------------------------------------------------------------------------------------------
float3 GetShadowPosOffset(float NdotL, float3 normalWS, float2 invShadowMapSize)
{
float texelSize = 2.0 * invShadowMapSize.x;
float offsetScaleNormalize = saturate(1.0 - NdotL);
// return texelSize * OffsetScale * offsetScaleNormalize * normalWS;
return texelSize * offsetScaleNormalize * normalWS;
}
// TODO: implement various algorithm
// GetShadowAttenuation is the "default" algorithm use, material can code explicitely a particular algorithm if required.
// TODO: how this work related to shadow format ?
float GetShadowAttenuation(LightLoopContext lightLoopContext, int index, float3 shadowCoord, float3 shadowPosDX, float3 shadowPosDY, float2 unPositionSS)
{
// TODO: How to support a Gather sampling with such abstraction...
return SampleShadowCompare(lightLoopContext, index, shadowCoord);
}

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Shadow.hlsl.meta


fileFormatVersion: 2
guid: 272a43c3c23646a4e8bc73faebaf0ee5
timeCreated: 1477313383
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

28
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/ShadowDefinition.cs


using UnityEngine;
//-----------------------------------------------------------------------------
// structure definition
//-----------------------------------------------------------------------------
namespace UnityEngine.Experimental.ScriptableRenderLoop
{
[GenerateHLSL]
public enum ShadowType
{
Spot,
Directional,
Point
};
// A point light is 6x PunctualShadowData
[GenerateHLSL]
public struct PunctualShadowData
{
// World to ShadowMap matrix
// Include scale and bias for shadow atlas if any
public Matrix4x4 worldToShadow;
public ShadowType shadowType;
public float bias;
public Vector2 unused;
};
} // namespace UnityEngine.Experimental.ScriptableRenderLoop

9
Assets/ScriptableRenderLoop/ForwardRenderLoop.meta


fileFormatVersion: 2
guid: 87cf696b5a0ce42438ce41ddcd5022c2
folderAsset: yes
timeCreated: 1467034984
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
Assets/TestScenes/ForwardRenderLoop.meta


fileFormatVersion: 2
guid: 29953ebbc2b204bb6be8f121555f7029
folderAsset: yes
timeCreated: 1467146873
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

/Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/ShadowDefinition.cs.hlsl → /Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs.hlsl

/Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/ShadowDefinition.cs.hlsl.meta → /Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs.hlsl.meta

/Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/ShadowDefinition.cs.meta → /Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs.meta

/Assets/ShaderGenerator/CSharpToHLSL.cs.meta → /Assets/ShaderGenerator/Editor/CSharpToHLSL.cs.meta

/Assets/ShaderGenerator/ICSharpCode.NRefactory.dll.meta → /Assets/ShaderGenerator/Editor/ICSharpCode.NRefactory.dll.meta

/Assets/ShaderGenerator/ShaderGeneratorMenu.cs.meta → /Assets/ShaderGenerator/Editor/ShaderGeneratorMenu.cs.meta

/Assets/ShaderGenerator/ShaderTypeGeneration.cs.meta → /Assets/ShaderGenerator/Editor/ShaderTypeGeneration.cs.meta

/Assets/ShaderGenerator/ICSharpCode.NRefactory.dll → /Assets/ShaderGenerator/Editor/ICSharpCode.NRefactory.dll

/Assets/ShaderGenerator/CSharpToHLSL.cs → /Assets/ShaderGenerator/Editor/CSharpToHLSL.cs

/Assets/ShaderGenerator/ShaderGeneratorMenu.cs → /Assets/ShaderGenerator/Editor/ShaderGeneratorMenu.cs

/Assets/ShaderGenerator/ShaderTypeGeneration.cs → /Assets/ShaderGenerator/Editor/ShaderTypeGeneration.cs

正在加载...
取消
保存