浏览代码

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

/scriptablerenderloop-materialgraph
Paul Demeulenaere 8 年前
当前提交
2c436ffd
共有 42 个文件被更改,包括 465 次插入477 次删除
  1. 31
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
  2. 19
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugViewMaterial.hlsl
  3. 7
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugViewMaterialGBuffer.shader
  4. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Deferred.shader
  5. 17
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightDefinition.cs
  6. 16
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightDefinition.cs.hlsl
  7. 1
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/Lighting.hlsl
  8. 27
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePass.cs
  9. 63
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePass.hlsl
  10. 15
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/LayeredLit/LayeredLitCommon.hlsl
  11. 22
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.hlsl
  12. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitData.hlsl
  13. 44
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitDefault.shader
  14. 10
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitShare.hlsl
  15. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/UnlitData.hlsl
  16. 5
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/UnlitDefault.shader
  17. 10
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/UnlitShare.hlsl
  18. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPassForward.hlsl
  19. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderPass/ShaderPassGBuffer.hlsl
  20. 10
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderVariables.hlsl
  21. 12
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/FixedSizePCF/FixedSizePCF.hlsl
  22. 13
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/Shadow.hlsl
  23. 16
      Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl
  24. 2
      Assets/ScriptableRenderLoop/ShaderLibrary/Packing.hlsl
  25. 16
      Assets/ScriptableRenderLoop/common/ShaderBase.h
  26. 4
      Assets/ScriptableRenderLoop/fptl/Internal-DeferredReflections.shader
  27. 4
      Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader
  28. 18
      Assets/ScriptableRenderLoop/fptl/LightingUtils.hlsl
  29. 2
      Assets/ScriptableRenderLoop/fptl/RegularForwardLightingUtils.hlsl
  30. 2
      Assets/ScriptableRenderLoop/fptl/TiledLightingUtils.hlsl
  31. 12
      Assets/ScriptableRenderLoop/fptl/lightlistbuild-bigtile.compute
  32. 43
      Assets/ScriptableRenderLoop/fptl/lightlistbuild-clustered.compute
  33. 280
      Assets/ScriptableRenderLoop/fptl/lightlistbuild.compute
  34. 36
      Assets/TestScenes/HDTest/HDRenderLoopTest.unity
  35. 50
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePass.cs.hlsl
  36. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePass.cs.hlsl.meta
  37. 9
      Assets/ScriptableRenderLoop/fptl/SortingComputeUtils.hlsl.meta
  38. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/EVSM.meta
  39. 30
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs
  40. 12
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs.meta
  41. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs.hlsl.meta
  42. 40
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs.hlsl

31
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs


// Must be in sync with DebugViewMaterial.hlsl
public enum DebugViewVaryingMode
{
Depth = 1,
TexCoord0 = 2,
TexCoord1 = 3,
TexCoord2 = 4,
VertexTangentWS = 5,
VertexBitangentWS = 6,
VertexNormalWS = 7,
VertexColor = 8,
TexCoord0 = 1,
TexCoord1 = 2,
TexCoord2 = 3,
VertexTangentWS = 4,
VertexBitangentWS = 5,
VertexNormalWS = 6,
VertexColor = 7,
Depth = 9,
BakeDiffuseLighting = 10,
Depth = 10,
BakeDiffuseLighting = 11,
}
public class DebugParameters

l.specularScale = AdditionalLightData.GetAffectSpecular(additionalLightData) ? 1.0f : 0.0f;
l.shadowDimmer = AdditionalLightData.GetShadowDimmer(additionalLightData);
l.flags = 0;
l.IESIndex = 0;
l.cookieIndex = 0;
l.shadowIndex = 0;
l.IESIndex = -1;
l.cookieIndex = -1;
l.shadowIndex = -1;
// Setup shadow data arrays
bool hasShadows = shadowOutput.GetShadowSliceCountLightIndex(lightIndex) != 0;

{
// When we have a point light, we assumed that there is 6 consecutive PunctualShadowData
l.shadowIndex = shadows.Count;
l.flags |= LightFlags.HasShadow;
for (int sliceIndex = 0; sliceIndex < shadowOutput.GetShadowSliceCountLightIndex(lightIndex); ++sliceIndex)
{

s.worldToShadow = shadowOutput.shadowSlices[shadowSliceIndex].shadowTransform.transpose; // Transpose to go from ShadowToWorld to WorldToShadow
s.worldToShadow = shadowOutput.shadowSlices[shadowSliceIndex].shadowTransform.transpose; // Transpose for hlsl reading ?
if (light.lightType == LightType.Spot)
{

{
s.shadowType = ShadowType.Directional;
}
s.bias = light.light.shadowBias;
shadows.Add(s);
}

19
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Debug/DebugViewMaterial.hlsl


// All number below folow each others!
// Must be in sync with DebugViewVaryingMode
#define DEBUGVIEW_VARYING_DEPTH 1
#define DEBUGVIEW_VARYING_TEXCOORD0 2
#define DEBUGVIEW_VARYING_TEXCOORD1 3
#define DEBUGVIEW_VARYING_TEXCOORD2 4
#define DEBUGVIEW_VARYING_VERTEXTANGENTWS 5
#define DEBUGVIEW_VARYING_VERTEXBITANGENTWS 6
#define DEBUGVIEW_VARYING_VERTEXNORMALWS 7
#define DEBUGVIEW_VARYING_VERTEXCOLOR 8
#define DEBUGVIEW_VARYING_TEXCOORD0 1
#define DEBUGVIEW_VARYING_TEXCOORD1 2
#define DEBUGVIEW_VARYING_TEXCOORD2 3
#define DEBUGVIEW_VARYING_VERTEXTANGENTWS 4
#define DEBUGVIEW_VARYING_VERTEXBITANGENTWS 5
#define DEBUGVIEW_VARYING_VERTEXNORMALWS 6
#define DEBUGVIEW_VARYING_VERTEXCOLOR 7
#define DEBUGVIEW_GBUFFER_DEPTH 9
#define DEBUGVIEW_GBUFFER_BAKEDIFFUSELIGHTING 10
#define DEBUGVIEW_GBUFFER_DEPTH 10
#define DEBUGVIEW_GBUFFER_BAKEDIFFUSELIGHTING 11

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


struct Varyings
{
float4 positionHS : SV_POSITION;
float4 positionCS : SV_POSITION;
};
Varyings VertDeferred(Attributes input)

float3 positionWS = TransformObjectToWorld(input.positionOS);
output.positionHS = TransformWorldToHClip(positionWS);
output.positionCS = TransformWorldToHClip(positionWS);
return output;
}

Coordinate coord = GetCoordinate(input.positionHS.xy, _ScreenSize.zw);
float4 unPositionSS = input.positionCS; // as input we have the vpos
Coordinate coord = GetCoordinate(unPositionSS.xy, _ScreenSize.zw);
float depth = _CameraDepthTexture.Load(uint3(coord.unPositionSS, 0)).x;

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


// Chose supported lighting architecture in case of deferred rendering
#pragma multi_compile LIGHTLOOP_SINGLE_PASS
#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF
//#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF
//-------------------------------------------------------------------------------------
// Include

struct Varyings
{
float4 positionHS : SV_POSITION;
float4 positionCS : SV_POSITION;
};
Varyings VertDeferred(Attributes input)

Varyings output;
float3 positionWS = TransformObjectToWorld(input.positionOS);
output.positionHS = TransformWorldToHClip(positionWS);
output.positionCS = TransformWorldToHClip(positionWS);
return output;
}

Coordinate coord = GetCoordinate(input.positionHS.xy, _ScreenSize.zw);
float4 unPositionSS = input.positionCS; // as input we have the vpos
Coordinate coord = GetCoordinate(unPositionSS.xy, _ScreenSize.zw);
// No need to manage inverse depth, this is handled by the projection matrix
float depth = _CameraDepthTexture.Load(uint3(coord.unPositionSS, 0)).x;

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


// structure definition
//-----------------------------------------------------------------------------
[GenerateHLSL]
// Power of two value as they are flag
public enum LightFlags
{
HasShadow = (1 << 0),
HasCookie = (1 << 1),
HasIES = (1 << 2)
}
// These structures share between C# and hlsl need to be align on float4, so we pad them.
[GenerateHLSL]
public struct PunctualLightData

public float angleOffset;
public Vector3 right;
public LightFlags flags;
// index are -1 if not used
public Vector2 unused;
public Vector3 unused;
};
[GenerateHLSL]

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


#ifndef LIGHTDEFINITION_CS_HLSL
#define LIGHTDEFINITION_CS_HLSL
//
// UnityEngine.Experimental.ScriptableRenderLoop.LightFlags: static fields
//
#define LIGHTFLAGS_HAS_SHADOW (1)
#define LIGHTFLAGS_HAS_COOKIE (2)
#define LIGHTFLAGS_HAS_IES (4)
//
// UnityEngine.Experimental.ScriptableRenderLoop.AreaShapeType: static fields
//
#define AREASHAPETYPE_RECTANGLE (0)

float3 up;
float angleOffset;
float3 right;
int flags;
float diffuseScale;
float specularScale;
float shadowDimmer;

float2 unused;
float3 unused;
};
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.AreaLightData

{
return value.right;
}
int GetFlags(PunctualLightData value)
{
return value.flags;
}
float GetDiffuseScale(PunctualLightData value)
{
return value.diffuseScale;

{
return value.cookieIndex;
}
float2 GetUnused(PunctualLightData value)
float3 GetUnused(PunctualLightData value)
{
return value.unused;
}

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


#define HAS_LIGHTLOOP // Allow to not define LightLoop related function in Material.hlsl
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/LightDefinition.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Shadow/ShadowDefinition.cs.hlsl"
#ifdef LIGHTLOOP_SINGLE_PASS
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePass.hlsl"

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


return "LIGHTLOOP_SINGLE_PASS";
}
};
//-----------------------------------------------------------------------------
// 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 float bias;
public float quality;
public Vector2 unused;
};
}

63
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
//-----------------------------------------------------------------------------
#include "SinglePass.cs.hlsl"
//-----------------------------------------------------------------------------
// Constant and structure declaration
// ----------------------------------------------------------------------------

int _PunctualLightCount;
int _EnvLightCount;
EnvLightData _EnvLightSky;
float4 _ShadowMapSize;
CBUFFER_END
struct LightLoopContext

#define SINGLE_PASS_CONTEXT_SAMPLE_SHADOWATLAS 0
#define SINGLE_PASS_CONTEXT_SAMPLE_SHADOWARRAY 1
PunctualShadowData GetPunctualShadowData(LightLoopContext lightLoopContext, int index, float3 L)
float GetPunctualShadowAttenuation(LightLoopContext lightLoopContext, float3 positionWS, int index, float3 L, float2 unPositionSS)
int faceIndex = 0;
if (_PunctualShadowList[index].shadowType == SHADOWTYPE_POINT)
{
GetCubeFaceID(L, faceIndex);
}
int faceIndex = 0;
if (_PunctualShadowList[index].shadowType == SHADOWTYPE_POINT)
{
GetCubeFaceID(L, faceIndex);
}
return _PunctualShadowList[index + faceIndex];
}
PunctualShadowData shadowData = _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);
return positionTXS.xyz / positionTXS.w;
}
// 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);
positionTXS.xyz /= positionTXS.w;
// positionTXS.z -= shadowData.bias; // Apply a linear bias
positionTXS.z -= 0.001;
float4 SampleShadowCompare(LightLoopContext lightLoopContext, int index, float3 texCoord)
{
// if (lightLoopContext.sampleShadow == SINGLE_PASS_CONTEXT_SAMPLE_SHADOWATLAS)
{
float objDepth = saturate(257.0 / 256.0 - texCoord.z);
#if UNITY_REVERSED_Z
positionTXS.z = 1.0 - positionTXS.z;
#endif
// Index could be use to get scale bias for uv but this is already merged into the shadow matrix
return SAMPLE_TEXTURE2D_SHADOW(g_tShadowBuffer, samplerg_tShadowBuffer, float3(texCoord.xy, objDepth)).xxxx;
}
/*
else // SINGLE_PASS_CONTEXT_SAMPLE_SHADOWARRAY
{
return SAMPLE_TEXTURE2D_ARRAY_SHADOW(_ShadowArray, sampler_ShadowArray, texCoord, index);
}
*/
}
// float3 shadowPosDX = ddx_fine(positionTXS);
// float3 shadowPosDY = ddy_fine(positionTXS);
/*
float4 SampleShadow(LightLoopContext lightLoopContext, int index, float2 texCoord)
{
if (lightLoopContext.sampleShadow == SINGLE_PASS_CONTEXT_SAMPLE_SHADOWATLAS)
{
// Index could be use to get scale bias for uv but this is already merged into the shadow matrix
return SAMPLE_TEXTURE2D(_ShadowAtlas, sampler_ManualShadowArray, texCoord);
}
else // SINGLE_PASS_CONTEXT_SAMPLE_SHADOWARRAY
{
return SAMPLE_TEXTURE2D_ARRAY(_ShadowArray, sampler_ManualShadowAtlas, texCoord, index);
}
return SAMPLE_TEXTURE2D_SHADOW(g_tShadowBuffer, samplerg_tShadowBuffer, positionTXS);
*/
//-----------------------------------------------------------------------------
// IES sampling function

15
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/LayeredLit/LayeredLitCommon.hlsl


struct Varyings
{
float4 positionHS;
float4 positionCS;
float3 positionWS;
float2 texCoord0;
float3 tangentToWorld[3];

struct PackedVaryings
{
float4 positionHS : SV_Position;
float4 positionCS : SV_Position;
float4 interpolators[6] : TEXCOORD0;
#ifdef SHADER_STAGE_FRAGMENT

PackedVaryings PackVaryings(Varyings input)
{
PackedVaryings output;
output.positionHS = input.positionHS;
output.positionCS = input.positionCS;
output.interpolators[0].xyz = input.positionWS.xyz;
output.interpolators[0].w = input.texCoord0.x;
output.interpolators[1].xyz = input.tangentToWorld[0];

Varyings UnpackVaryings(PackedVaryings input)
{
Varyings output;
output.positionHS = input.positionHS;
output.positionCS = input.positionCS;
output.positionWS.xyz = input.interpolators[0].xyz;
output.texCoord0.x = input.interpolators[0].w;
output.texCoord0.y = input.interpolators[4].x;

output.positionWS = TransformObjectToWorld(input.positionOS);
// TODO deal with camera center rendering and instancing (This is the reason why we always perform tow steps transform to clip space + instancing matrix)
output.positionHS = TransformWorldToHClip(output.positionWS);
output.positionCS = TransformWorldToHClip(output.positionWS);
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);

{
switch (paramId)
{
case DEBUGVIEW_VARYING_DEPTH:
// TODO: provide a customize parameter (like a slider)
float linearDepth = frac(LinearEyeDepth(input.positionHS.z, _ZBufferParams) * 0.1);
result = linearDepth.xxx;
break;
case DEBUGVIEW_VARYING_TEXCOORD0:
// TODO: require a remap
result = float3(input.texCoord0, 0.0);

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


// TODO: measure impact of having all these dynamic branch here and the gain (or not) of testing illuminace > 0
/*
const bool hasCookie = (lightData.flags & LIGHTFLAGS_HAS_COOKIE)!= 0;
[branch] if (hasCookie && illuminance > 0.0f)
[branch] if (lightData.cookieIndex && illuminance > 0.0f)
{
float3x3 lightToWorld = float3x3(lightData.right, lightData.up, lightData.forward);
illuminance *= SampleCookie(lightData.cookieIndex, lightToWorld, L);

const bool hasIES = (lightData.flags & LIGHTFLAGS_HAS_IES) != 0;
[branch] if (hasIES && illuminance > 0.0f)
[branch] if (lightData.IESIndex >= 0 && illuminance > 0.0f)
{
float3x3 lightToWorld = float3x3(lightData.right, lightData.up, lightData.forward);
float2 sphericalCoord = GetIESTextureCoordinate(lightToWorld, L);

const bool hasShadow = (lightData.flags & LIGHTFLAGS_HAS_SHADOW) != 0;
[branch] if (hasShadow && illuminance > 0.0f)
[branch] if (lightData.shadowIndex >= 0 && illuminance > 0.0f)
PunctualShadowData shadowData = GetPunctualShadowData(lightLoopContext, lightData.shadowIndex, L);
// Apply offset
float3 offset = float3(0.0, 0.0, 0.0); // GetShadowPosOffset(nDotL, normal);
float3 shadowCoord = GetShadowTextureCoordinate(lightLoopContext, shadowData, positionWS + offset);
float3 offset = float3(0.0, 0.0, 0.0); // GetShadowPosOffset(nDotL, normal);
float shadowAttenuation = GetPunctualShadowAttenuation(lightLoopContext, positionWS + offset, lightData.shadowIndex, L, preLightData.unPositionSS);
shadowAttenuation = lerp(1.0, shadowAttenuation, lightData.shadowDimmer);
float3 shadowPosDX = ddx_fine(shadowCoord);
float3 shadowPosDY = ddy_fine(shadowCoord);
float shadowAttenuation = GetPunctualShadowAttenuation(lightLoopContext, lightData.shadowIndex, shadowData, shadowCoord, shadowPosDX, shadowPosDY, preLightData.unPositionSS);
shadowAttenuation = lerp(1.0, shadowAttenuation, lightData.shadowDimmer);
illuminance *= shadowAttenuation;
}

2
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitData.hlsl


struct FragInput
{
float4 positionHS;
float4 unPositionSS; // This is the position return by VPOS, only xy is use
float3 positionWS;
float2 texCoord0;
float2 texCoord1;

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


#pragma shader_feature _HEIGHTMAP
#pragma shader_feature _HEIGHTMAP_AS_DISPLACEMENT
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
//-------------------------------------------------------------------------------------
// Define

{
switch (paramId)
{
case DEBUGVIEW_VARYING_DEPTH:
// TODO: provide a customize parameter (like a slider)
float linearDepth = frac(LinearEyeDepth(input.positionHS.z, _ZBufferParams) * 0.1);
result = linearDepth.xxx;
break;
case DEBUGVIEW_VARYING_TEXCOORD0:
result = float3(input.texCoord0 * 0.5 + 0.5, 0.0);
break;

struct Varyings
{
float4 positionHS;
float4 positionCS;
float2 texCoord0;
float2 texCoord1;
};

float4 positionHS : SV_Position;
float4 positionCS : SV_Position;
float4 interpolators[1] : TEXCOORD0;
};

PackedVaryings output;
output.positionHS = input.positionHS;
output.positionCS = input.positionCS;
output.interpolators[0].xy = input.texCoord0;
output.interpolators[0].zw = input.texCoord1;

FragInput output;
ZERO_INITIALIZE(FragInput, output);
output.positionHS = input.positionHS;
output.unPositionSS = input.positionCS;
output.texCoord0 = input.interpolators[0].xy;
output.texCoord1 = input.interpolators[0].zw;

}
float3 positionWS = TransformObjectToWorld(input.positionOS);
output.positionHS = TransformWorldToHClip(positionWS);
output.positionCS = TransformWorldToHClip(positionWS);
output.texCoord0 = input.uv0;
output.texCoord1 = input.uv1;

// ------------------------------------------------------------------
Pass
{
Name "DepthOnly" // Name is not used
Tags { "LightMode" = "ShadowCaster" } // This will be only for transparent object based on the RenderQueue index
Name "ShadowCaster"
Tags{ "LightMode" = "ShadowCaster" }
Cull[_CullMode]
Blend [_SrcBlend] [_DstBlend]
ZWrite [_ZWrite]
Cull [_CullMode]
ZWrite On ZTest LEqual
HLSLPROGRAM

struct Varyings
{
float4 positionHS;
float4 positionCS;
#if NEED_TEXCOORD0
float2 texCoord0;
#endif

struct PackedVaryings
{
float4 positionHS : SV_Position;
float4 positionCS : SV_Position;
#if NEED_TANGENT_TO_WORLD
float4 interpolators[4] : TEXCOORD0;
#elif NEED_TEXCOORD0

PackedVaryings PackVaryings(Varyings input)
{
PackedVaryings output;
output.positionHS = input.positionHS;
output.positionCS = input.positionCS;
#if NEED_TANGENT_TO_WORLD
output.interpolators[0].xyz = input.positionWS.xyz;
output.interpolators[1].xyz = input.tangentToWorld[0];

FragInput output;
ZERO_INITIALIZE(FragInput, output);
output.positionHS = input.positionHS;
output.unPositionSS = input.positionCS;
#if NEED_TANGENT_TO_WORLD
output.positionWS.xyz = input.interpolators[0].xyz;
output.tangentToWorld[0] = input.interpolators[1].xyz;

Varyings output;
float3 positionWS = TransformObjectToWorld(input.positionOS);
output.positionHS = TransformWorldToHClip(positionWS);
output.positionCS = TransformWorldToHClip(positionWS);
#if NEED_TEXCOORD0
output.texCoord0 = input.uv0;

// TEMP until pragma work in include
// #include "../../Lighting/Forward.hlsl"
#pragma multi_compile LIGHTLOOP_SINGLE_PASS
#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF
//#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF
#include "../../Lighting/Lighting.hlsl"
#include "LitData.hlsl"

10
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/LitShare.hlsl


struct Varyings
{
float4 positionHS;
float4 positionCS;
float3 positionWS;
float2 texCoord0;
float2 texCoord1;

struct PackedVaryings
{
float4 positionHS : SV_Position;
float4 positionCS : SV_Position;
#if (DYNAMICLIGHTMAP_ON) || (SHADERPASS == SHADERPASS_DEBUG_VIEW_MATERIAL)
float4 interpolators[5] : TEXCOORD0;
#else

PackedVaryings PackVaryings(Varyings input)
{
PackedVaryings output;
output.positionHS = input.positionHS;
output.positionCS = input.positionCS;
output.interpolators[0].xyz = input.positionWS.xyz;
output.interpolators[1].xyz = input.tangentToWorld[0];
output.interpolators[2].xyz = input.tangentToWorld[1];

FragInput output;
ZERO_INITIALIZE(FragInput, output);
output.positionHS = input.positionHS;
output.unPositionSS = input.positionCS;
output.positionWS.xyz = input.interpolators[0].xyz;
output.tangentToWorld[0] = input.interpolators[1].xyz;
output.tangentToWorld[1] = input.interpolators[2].xyz;

output.positionWS = TransformObjectToWorld(input.positionOS);
// TODO deal with camera center rendering and instancing (This is the reason why we always perform tow steps transform to clip space + instancing matrix)
output.positionHS = TransformWorldToHClip(output.positionWS);
output.positionCS = TransformWorldToHClip(output.positionWS);
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);

2
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/UnlitData.hlsl


struct FragInput
{
float4 positionHS;
float4 positionCS;
float2 texCoord0;
};

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


{
switch (paramId)
{
case DEBUGVIEW_VARYING_DEPTH:
// TODO: provide a customize parameter (like a slider)
float linearDepth = frac(LinearEyeDepth(input.positionHS.z, _ZBufferParams) * 0.1);
result = linearDepth.xxx;
break;
case DEBUGVIEW_VARYING_TEXCOORD0:
result = float3(input.texCoord0 * 0.5 + 0.5, 0.0);
break;

10
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Unlit/UnlitShare.hlsl


struct Varyings
{
float4 positionHS;
float4 positionCS;
float4 positionHS : SV_Position;
float4 positionCS : SV_Position;
float4 interpolators[1] : TEXCOORD0;
};

output.positionHS = input.positionHS;
output.positionCS = input.positionCS;
output.interpolators[0] = float4(input.texCoord0.xy, 0.0, 0.0);
return output;

FragInput output;
ZERO_INITIALIZE(FragInput, output);
output.positionHS = input.positionHS;
output.positionCS = input.positionCS;
output.texCoord0.xy = input.interpolators[0].xy;
return output;

Varyings output;
float3 positionWS = TransformObjectToWorld(input.positionOS);
output.positionHS = TransformWorldToHClip(positionWS);
output.positionCS = TransformWorldToHClip(positionWS);
output.texCoord0 = input.uv0;

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


GetSurfaceAndBuiltinData(input, surfaceData, builtinData);
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(surfaceData);
Coordinate coord = GetCoordinate(input.positionHS.xy, _ScreenSize.zw);
Coordinate coord = GetCoordinate(input.unPositionSS.xy, _ScreenSize.zw);
PreLightData preLightData = GetPreLightData(V, positionWS, coord, bsdfData);
float4 diffuseLighting;

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


GetSurfaceAndBuiltinData(input, surfaceData, builtinData);
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(surfaceData);
Coordinate coord = GetCoordinate(input.positionHS.xy, _ScreenSize.zw);
Coordinate coord = GetCoordinate(input.unPositionSS, _ScreenSize.zw);
PreLightData preLightData = GetPreLightData(V, positionWS, coord, bsdfData);
ENCODE_INTO_GBUFFER(surfaceData, outGBuffer);

10
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/ShaderVariables.hlsl


CBUFFER_END
// Main lightmap
UNITY_DECLARE_TEX2D_HALF(unity_Lightmap);
// Dual or directional lightmap (always used with unity_Lightmap, so can share sampler)
UNITY_DECLARE_TEX2D_NOSAMPLER_HALF(unity_LightmapInd);
// Dynamic GI lightmap
UNITY_DECLARE_TEX2D(unity_DynamicLightmap);
UNITY_DECLARE_TEX2D_NOSAMPLER(unity_DynamicDirectionality);
UNITY_DECLARE_TEX2D_NOSAMPLER(unity_DynamicNormal);
CBUFFER_START(UnityLightmaps)
float4 unity_LightmapST;
float4 unity_DynamicLightmapST;

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


// 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;
}

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


// 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
}

16
Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl


// WS: world space
// VS: view space
// OS: object space
// HS: Homogenous clip space
// CS: clips space
// CS: Homogenous clip spaces
// TS: tangent space
// TXS: texture space
// Example: NormalWS

// This function is use to provide an easy way to sample into a screen texture, either from a pixel or a compute shaders.
// This allow to easily share code.
// If a compute shader call this function inPositionSS is an integer usually calculate like: uint2 inPositionSS = groupId.xy * BLOCK_SIZE + groupThreadId.xy
// If a compute shader call this function unPositionSS is an integer usually calculate like: uint2 unPositionSS = groupId.xy * BLOCK_SIZE + groupThreadId.xy
Coordinate GetCoordinate(float2 inPositionSS, float2 invScreenSize)
Coordinate GetCoordinate(float2 unPositionSS, float2 invScreenSize)
coord.positionSS = inPositionSS;
// TODO: How to detect automatically that we are a compute shader ?
coord.positionSS = unPositionSS;
#if SHADER_STAGE_COMPUTE
// In case of compute shader an extra half offset is added to the screenPos to shift the integer position to pixel center.
coord.positionSS.xy += float2(0.5, 0.5);

coord.unPositionSS = int2(inPositionSS);
coord.unPositionSS = int2(unPositionSS);
return coord;
}

// For information. In Unity Depth is always in range 0..1 (even on OpenGL) but can be reversed.
float3 UnprojectToWorld(float depth, float2 screenPos, float4x4 invViewProjectionMatrix)
{
float4 positionHS = float4(screenPos.xy * 2.0 - 1.0, depth, 1.0);
float4 hpositionWS = mul(invViewProjectionMatrix, positionHS);
float4 positionCS = float4(screenPos.xy * 2.0 - 1.0, depth, 1.0);
float4 hpositionWS = mul(invViewProjectionMatrix, positionCS);
return hpositionWS.xyz / hpositionWS.w;
}

2
Assets/ScriptableRenderLoop/ShaderLibrary/Packing.hlsl


// return float between [-1, 1]
float2 PackNormalOctEncode(float3 n)
{
float l1norm = abs(n.x) + abs(n.y) + abs(n.z);
float l1norm = dot(abs(n), 1.0);
float2 res0 = n.xy * (1.0 / l1norm);
float2 val = 1.0 - abs(res0.yx);

16
Assets/ScriptableRenderLoop/common/ShaderBase.h


#ifndef __SHADERBASE_H__
#define __SHADERBASE_H__
#ifdef SHADER_API_PSSL
#ifndef Texture2DMS
#define Texture2DMS MS_Texture2D
#endif
#ifndef SampleCmpLevelZero
#define SampleCmpLevelZero SampleCmpLOD0
#endif
#ifndef firstbithigh
#define firstbithigh FirstSetBit_Hi_MSB
#endif
#endif
#define __HLSL 1
#define public

4
Assets/ScriptableRenderLoop/fptl/Internal-DeferredReflections.shader


static LocalDataBRDF g_localParams;
StandardData UnityStandardDataFromGbuffer(float4 gbuffer0, float4 gbuffer1, float4 gbuffer2)
StandardData UnityStandardDataFromGbufferAux(float4 gbuffer0, float4 gbuffer1, float4 gbuffer2)
{
StandardData data;

float4 gbuffer1 = _CameraGBufferTexture1.Load( uint3(pixCoord.xy, 0) );
float4 gbuffer2 = _CameraGBufferTexture2.Load( uint3(pixCoord.xy, 0) );
StandardData data = UnityStandardDataFromGbuffer(gbuffer0, gbuffer1, gbuffer2);
StandardData data = UnityStandardDataFromGbufferAux(gbuffer0, gbuffer1, gbuffer2);
g_localParams.gbuf = data;
g_localParams.oneMinusReflectivity = 1.0 - SpecularStrength(data.specularColor.rgb);

4
Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader


static LocalDataBRDF g_localParams;
StandardData UnityStandardDataFromGbuffer(float4 gbuffer0, float4 gbuffer1, float4 gbuffer2, float4 gbuffer3)
StandardData UnityStandardDataFromGbufferAux(float4 gbuffer0, float4 gbuffer1, float4 gbuffer2, float4 gbuffer3)
{
StandardData data;

float4 gbuffer2 = _CameraGBufferTexture2.Load( uint3(pixCoord.xy, 0) );
float4 gbuffer3 = _CameraGBufferTexture3.Load( uint3(pixCoord.xy, 0) );
StandardData data = UnityStandardDataFromGbuffer(gbuffer0, gbuffer1, gbuffer2, gbuffer3);
StandardData data = UnityStandardDataFromGbufferAux(gbuffer0, gbuffer1, gbuffer2, gbuffer3);
g_localParams.gbuf = data;
g_localParams.oneMinusReflectivity = 1.0 - SpecularStrength(data.specularColor.rgb);

18
Assets/ScriptableRenderLoop/fptl/LightingUtils.hlsl


#define _ 0
#define x 1
uint fontData[9][2] = {
PACK_BITS25(_,_,x,_,_, _,_,x,_,_, _,x,x,x,_, x,x,x,x,x, _,_,_,x,_), PACK_BITS25(x,x,x,x,x, _,x,x,x,_, x,x,x,x,x, _,x,x,x,_, _,x,x,x,_),
PACK_BITS25(_,x,_,x,_, _,x,x,_,_, x,_,_,_,x, _,_,_,_,x, _,_,_,x,_), PACK_BITS25(x,_,_,_,_, x,_,_,_,x, _,_,_,_,x, x,_,_,_,x, x,_,_,_,x),
PACK_BITS25(x,_,_,_,x, x,_,x,_,_, x,_,_,_,x, _,_,_,x,_, _,_,x,x,_), PACK_BITS25(x,_,_,_,_, x,_,_,_,_, _,_,_,x,_, x,_,_,_,x, x,_,_,_,x),
PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,_,_,x, _,_,x,_,_, _,x,_,x,_), PACK_BITS25(x,_,x,x,_, x,_,_,_,_, _,_,_,x,_, x,_,_,_,x, x,_,_,_,x),
PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,_,x,_, _,x,x,x,_, _,x,_,x,_), PACK_BITS25(x,x,_,_,x, x,x,x,x,_, _,_,x,_,_, _,x,x,x,_, _,x,x,x,x),
PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,x,_,_, _,_,_,_,x, x,_,_,x,_), PACK_BITS25(_,_,_,_,x, x,_,_,_,x, _,_,x,_,_, x,_,_,_,x, _,_,_,_,x),
PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,x,_,_,_, _,_,_,_,x, x,x,x,x,x), PACK_BITS25(_,_,_,_,x, x,_,_,_,x, _,x,_,_,_, x,_,_,_,x, _,_,_,_,x),
PACK_BITS25(_,x,_,x,_, _,_,x,_,_, x,_,_,_,_, x,_,_,_,x, _,_,_,x,_), PACK_BITS25(x,_,_,_,x, x,_,_,_,x, _,x,_,_,_, x,_,_,_,x, x,_,_,_,x),
PACK_BITS25(_,_,x,_,_, x,x,x,x,x, x,x,x,x,x, _,x,x,x,_, _,_,_,x,_), PACK_BITS25(_,x,x,x,_, _,x,x,x,_, _,x,_,_,_, _,x,x,x,_, _,x,x,x,_)
{ PACK_BITS25(_,_,x,_,_, _,_,x,_,_, _,x,x,x,_, x,x,x,x,x, _,_,_,x,_), PACK_BITS25(x,x,x,x,x, _,x,x,x,_, x,x,x,x,x, _,x,x,x,_, _,x,x,x,_) },
{ PACK_BITS25(_,x,_,x,_, _,x,x,_,_, x,_,_,_,x, _,_,_,_,x, _,_,_,x,_), PACK_BITS25(x,_,_,_,_, x,_,_,_,x, _,_,_,_,x, x,_,_,_,x, x,_,_,_,x) },
{ PACK_BITS25(x,_,_,_,x, x,_,x,_,_, x,_,_,_,x, _,_,_,x,_, _,_,x,x,_), PACK_BITS25(x,_,_,_,_, x,_,_,_,_, _,_,_,x,_, x,_,_,_,x, x,_,_,_,x) },
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,_,_,x, _,_,x,_,_, _,x,_,x,_), PACK_BITS25(x,_,x,x,_, x,_,_,_,_, _,_,_,x,_, x,_,_,_,x, x,_,_,_,x) },
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,_,x,_, _,x,x,x,_, _,x,_,x,_), PACK_BITS25(x,x,_,_,x, x,x,x,x,_, _,_,x,_,_, _,x,x,x,_, _,x,x,x,x) },
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,x,_,_, _,_,_,_,x, x,_,_,x,_), PACK_BITS25(_,_,_,_,x, x,_,_,_,x, _,_,x,_,_, x,_,_,_,x, _,_,_,_,x) },
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,x,_,_,_, _,_,_,_,x, x,x,x,x,x), PACK_BITS25(_,_,_,_,x, x,_,_,_,x, _,x,_,_,_, x,_,_,_,x, _,_,_,_,x) },
{ PACK_BITS25(_,x,_,x,_, _,_,x,_,_, x,_,_,_,_, x,_,_,_,x, _,_,_,x,_), PACK_BITS25(x,_,_,_,x, x,_,_,_,x, _,x,_,_,_, x,_,_,_,x, x,_,_,_,x) },
{ PACK_BITS25(_,_,x,_,_, x,x,x,x,x, x,x,x,x,x, _,x,x,x,_, _,_,_,x,_), PACK_BITS25(_,x,x,x,_, _,x,x,x,_, _,x,_,_,_, _,x,x,x,_, _,x,x,x,_) }
};
#undef _
#undef x

2
Assets/ScriptableRenderLoop/fptl/RegularForwardLightingUtils.hlsl


StructuredBuffer<SFiniteLightData> g_vLightData;
StructuredBuffer<uint> g_vLightListMeshInst; // build on CPU if in use. direct lights first, then reflection probes.
Buffer<uint> g_vLightListMeshInst; // build on CPU if in use. direct lights first, then reflection probes.
uniform int g_numLights;
uniform int g_numReflectionProbes;

2
Assets/ScriptableRenderLoop/fptl/TiledLightingUtils.hlsl


StructuredBuffer<SFiniteLightData> g_vLightData;
StructuredBuffer<uint> g_vLightListGlobal;
Buffer<uint> g_vLightListGlobal;
void GetCountAndStartOpaque(out uint uStart, out uint uNrLights, uint2 tileIDX, int nrTilesX, int nrTilesY, float linDepth, uint model)
{

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


#define NR_THREADS 64
// output buffer
RWStructuredBuffer<uint> g_vLightList : register( u0 );
RWBuffer<uint> g_vLightList : register( u0 );
// 2kB (room for roughly 30 wavefronts)

if(t==0) lightOffs = 0;
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif

}
}
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
int iNrCoarseLights = lightOffs<MAX_NR_BIGTILE_LIGHTS ? lightOffs : MAX_NR_BIGTILE_LIGHTS;
int iNrCoarseLights = min(lightOffs,MAX_NR_BIGTILE_LIGHTS);
#ifdef PERFORM_SPHERICAL_INTERSECTION_TESTS
SphericalIntersectionTests( t, iNrCoarseLights, float2(min(viTilLL.xy+uint2(64/2,64/2), uint2(iWidth-1, iHeight-1))) );

lightsListLDS[l]=0xffffffff;
}
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif
}

}
}
}
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif
}

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


#include "LightingConvexHullUtils.hlsl"
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
#include "SortingComputeUtils.hlsl"
#endif

StructuredBuffer<SFiniteLightBound> g_data : register( t3 );
#ifdef USE_TWO_PASS_TILED_LIGHTING
StructuredBuffer<uint> g_vBigTileLightList : register( t4 );
Buffer<uint> g_vBigTileLightList : register( t4 );
#endif

#endif
}
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif

InterlockedMax(ldsZMax, asuint(dpt_ma) );
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif
dpt_ma = asfloat(ldsZMax);

// build coarse list using AABB
#ifdef USE_TWO_PASS_TILED_LIGHTING
int NrBigTilesX = (nrTilesX+3)>>2;
const int bigTileIdx = (tileIDX.y>>2)*NrBigTilesX + (tileIDX.x>>2); // map the idx to 64x64 tiles
int nrBigTileLights = g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+0];
for(int l0=(int) t; l0<(int) nrBigTileLights; l0 += NR_THREADS)
{
int l = g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1];
#else
#endif
const float3 vMi = g_vBoundsBuffer[l];
const float3 vMa = g_vBoundsBuffer[l+g_iNrVisibLights];

}
}
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
int iNrCoarseLights = lightOffs<MAX_NR_COARSE_ENTRIES ? lightOffs : MAX_NR_COARSE_ENTRIES;
int iNrCoarseLights = min(lightOffs,MAX_NR_COARSE_ENTRIES);
#ifdef PERFORM_SPHERICAL_INTERSECTION_TESTS
iNrCoarseLights = SphericalIntersectionTests( t, iNrCoarseLights, float2(min(viTilLL.xy+uint2(16/2,16/2), uint2(iWidth-1, iHeight-1))) );

iNrCoarseLights = CullByExactEdgeTests(t, iNrCoarseLights, viTilLL.xy, viTilUR.xy, fTileFarPlane);
#endif
// sort lights
#if !defined(XBONE) && !defined(PLAYSTATION4)
// sort lights (gives a more efficient execution in both deferred and tiled forward lighting).
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
SORTLIST(coarseList, iNrCoarseLights, MAX_NR_COARSE_ENTRIES, t, NR_THREADS);
#endif

}
}
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif

}
iSpaceAvail = min(iSum,MAX_NR_COARSE_ENTRIES); // combined storage for both direct lights and reflection
InterlockedAdd(g_LayeredSingleIdxBuffer[0], iSpaceAvail, start); // alloc list memory
InterlockedAdd(g_LayeredSingleIdxBuffer[0], (uint) iSpaceAvail, start); // alloc list memory
}
int modelListCount[NR_LIGHT_MODELS]={0,0}; // direct light count and reflection lights

int p = i>>2;
int m = i&3;
if(i<24) lightPlanes[6*m+p] = FetchPlane(min(iNrCoarseLights-1,ll+m), p);
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif

}
}
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif
}

coarseList[l]=0xffffffff;
}
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif

lightOffsSph = offs;
}
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif

{
if(threadID==0) ldsIsLightInvisible=0;
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif
const int idxCoarse = coarseList[l];

if(bFoundSepPlane) InterlockedOr(ldsIsLightInvisible, 1);
}
}
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif
if(threadID==0 && ldsIsLightInvisible==0)

}
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif
return lightOffs2;

280
Assets/ScriptableRenderLoop/fptl/lightlistbuild.compute


#include "LightingConvexHullUtils.hlsl"
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
#include "SortingComputeUtils.hlsl"
#endif

StructuredBuffer<SFiniteLightBound> g_data : register( t3 );
#ifdef USE_TWO_PASS_TILED_LIGHTING
StructuredBuffer<uint> g_vBigTileLightList : register( t4 );
Buffer<uint> g_vBigTileLightList : register( t4 );
//RWBuffer<uint4> g_vLightList : register( u0 );
RWStructuredBuffer<uint> g_vLightList : register( u0 );
RWBuffer<uint> g_vLightList : register( u0 );
#define MAX_NR_COARSE_ENTRIES 64

int SphericalIntersectionTests(uint threadID, int iNrCoarseLights, float2 screenCoordinate);
#endif
#ifdef FINE_PRUNING_ENABLED
void FinePruneLights(uint threadID, int iNrCoarseLights, uint2 viTilLL, float4 vLinDepths);
#endif
[numthreads(NR_THREADS, 1, 1)]
void LIGHTLISTGEN(uint threadID : SV_GroupIndex, uint3 u3GroupID : SV_GroupID)

lightOffs = 0;
}
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif

InterlockedMin(ldsZMin, asuint(dpt_mi));
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif
}

if(t<2) ldsDoesLightIntersect[t] = 0;
#endif
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
int iNrCoarseLights = lightOffs<MAX_NR_COARSE_ENTRIES ? lightOffs : MAX_NR_COARSE_ENTRIES;
int iNrCoarseLights = min(lightOffs,MAX_NR_COARSE_ENTRIES);
#ifdef PERFORM_SPHERICAL_INTERSECTION_TESTS
iNrCoarseLights = SphericalIntersectionTests( t, iNrCoarseLights, float2(min(viTilLL.xy+uint2(16/2,16/2), uint2(iWidth-1, iHeight-1))) );

{
int iNrLightsOut = iNrCoarseLights<MAX_NR_PRUNED_ENTRIES ? iNrCoarseLights : MAX_NR_PRUNED_ENTRIES;
if((int)t<iNrLightsOut) prunedList[t] = coarseList[t];
if(t==0) ldsNrLightsFinal=iNrLightsOut;
if((int)t<iNrCoarseLights) prunedList[t] = coarseList[t];
if(t==0) ldsNrLightsFinal=iNrCoarseLights;
uint uLightsFlags[2] = {0,0};
int l=0;
// need this outer loop even on xb1 and ps4 since direct lights and
// reflection lights are kept in separate regions.
while(l<iNrCoarseLights)
{
// fetch light
int idxCoarse = l<iNrCoarseLights ? coarseList[l] : 0;
uint uLgtType = l<iNrCoarseLights ? g_vLightData[idxCoarse].lightType : 0;
// spot
while(l<iNrCoarseLights && uLgtType==SPOT_LIGHT)
{
SFiniteLightData lightData = g_vLightData[idxCoarse];
const bool bIsSpotDisc = (lightData.flags&IS_CIRCULAR_SPOT_SHAPE)!=0;
// serially check 4 pixels
uint uVal = 0;
for(int i=0; i<4; i++)
{
int idx = t + i*NR_THREADS;
uint2 uPixLoc = min(uint2(viTilLL.x+(idx&0xf), viTilLL.y+(idx>>4)), uint2(iWidth-1, iHeight-1));
float3 vVPos = GetViewPosFromLinDepth(uPixLoc + float2(0.5,0.5), vLinDepths[i]);
// check pixel
float3 fromLight = vVPos-lightData.lightPos.xyz;
float distSq = dot(fromLight,fromLight);
const float fSclProj = dot(fromLight, lightData.lightAxisZ.xyz); // spotDir = lightData.lightAxisZ.xyz
float2 V = abs( float2( dot(fromLight, lightData.lightAxisX.xyz), dot(fromLight, lightData.lightAxisY.xyz) ) );
float fDist2D = bIsSpotDisc ? length(V) : max(V.x,V.y);
if( all( float2(lightData.radiusSq, fSclProj) > float2(distSq, fDist2D*lightData.cotan) ) ) uVal = 1;
}
uLightsFlags[l<32 ? 0 : 1] |= (uVal<<(l&31));
++l; idxCoarse = l<iNrCoarseLights ? coarseList[l] : 0;
uLgtType = l<iNrCoarseLights ? g_vLightData[idxCoarse].lightType : 0;
}
// sphere
while(l<iNrCoarseLights && uLgtType==SPHERE_LIGHT)
{
SFiniteLightData lightData = g_vLightData[idxCoarse];
// serially check 4 pixels
uint uVal = 0;
for(int i=0; i<4; i++)
{
int idx = t + i*NR_THREADS;
uint2 uPixLoc = min(uint2(viTilLL.x+(idx&0xf), viTilLL.y+(idx>>4)), uint2(iWidth-1, iHeight-1));
float3 vVPos = GetViewPosFromLinDepth(uPixLoc + float2(0.5,0.5), vLinDepths[i]);
// check pixel
float3 vLp = lightData.lightPos.xyz;
float3 toLight = vLp - vVPos;
float distSq = dot(toLight,toLight);
if(lightData.radiusSq>distSq) uVal = 1;
}
uLightsFlags[l<32 ? 0 : 1] |= (uVal<<(l&31));
++l; idxCoarse = l<iNrCoarseLights ? coarseList[l] : 0;
uLgtType = l<iNrCoarseLights ? g_vLightData[idxCoarse].lightType : 0;
}
// Box
while(l<iNrCoarseLights && uLgtType==BOX_LIGHT)
{
SFiniteLightData lightData = g_vLightData[idxCoarse];
// serially check 4 pixels
uint uVal = 0;
for(int i=0; i<4; i++)
{
int idx = t + i*NR_THREADS;
uint2 uPixLoc = min(uint2(viTilLL.x+(idx&0xf), viTilLL.y+(idx>>4)), uint2(iWidth-1, iHeight-1));
float3 vVPos = GetViewPosFromLinDepth(uPixLoc + float2(0.5,0.5), vLinDepths[i]);
// check pixel
float3 toLight = lightData.lightPos.xyz - vVPos;
float3 dist = float3( dot(toLight, lightData.lightAxisX), dot(toLight, lightData.lightAxisY), dot(toLight, lightData.lightAxisZ) );
dist = (abs(dist) - lightData.boxInnerDist) * lightData.boxInvRange; // not as efficient as it could be
if( max(max(dist.x, dist.y), dist.z)<1 ) uVal = 1; // but allows us to not write out OuterDists
}
uLightsFlags[l<32 ? 0 : 1] |= (uVal<<(l&31));
++l; idxCoarse = l<iNrCoarseLights ? coarseList[l] : 0;
uLgtType = l<iNrCoarseLights ? g_vLightData[idxCoarse].lightType : 0;
}
// in case we have some corrupt data make sure we terminate
if(uLgtType>=MAX_TYPES) ++l;
}
InterlockedOr(ldsDoesLightIntersect[0], uLightsFlags[0]);
InterlockedOr(ldsDoesLightIntersect[1], uLightsFlags[1]);
if(t==0) ldsNrLightsFinal = 0;
#if !defined(XBONE) && !defined(PLAYSTATION4)
GroupMemoryBarrierWithGroupSync();
#endif
if(t<(uint) iNrCoarseLights && (ldsDoesLightIntersect[t<32 ? 0 : 1]&(1<<(t&31)))!=0 )
{
unsigned int uInc = 1;
unsigned int uIndex;
InterlockedAdd(ldsNrLightsFinal, uInc, uIndex);
if(uIndex<MAX_NR_COARSE_ENTRIES) prunedList[uIndex] = coarseList[t]; // we allow up to 64 pruned lights while stored in LDS.
}
// initializes ldsNrLightsFinal with the number of accepted lights.
// all accepted entries delivered in prunedList[].
FinePruneLights(t, iNrCoarseLights, viTilLL, vLinDepths);
}
#endif

#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
int nrLightsCombinedList = ldsNrLightsFinal<MAX_NR_COARSE_ENTRIES ? ldsNrLightsFinal : MAX_NR_COARSE_ENTRIES;
int nrLightsCombinedList = min(ldsNrLightsFinal,MAX_NR_COARSE_ENTRIES);
for(int i=t; i<nrLightsCombinedList; i+=NR_THREADS)
{
InterlockedAdd(ldsModelListCount[ g_vLightData[ prunedList[i] ].lightModel ], 1);

// sort lights
#if !defined(XBONE) && !defined(PLAYSTATION4)
// sort lights (gives a more efficient execution in both deferred and tiled forward lighting).
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
SORTLIST(prunedList, nrLightsCombinedList, MAX_NR_COARSE_ENTRIES, t, NR_THREADS);
//MERGESORTLIST(prunedList, coarseList, nrLightsCombinedList, t, NR_THREADS);
#endif

for(int l=threadID; l<iNrCoarseLights; l+=NR_THREADS)
prunedList[l]=coarseList[l];
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif

}
}
#if !defined(XBONE) && !defined(PLAYSTATION4)
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
}
#endif
#ifdef FINE_PRUNING_ENABLED
// initializes ldsNrLightsFinal with the number of accepted lights.
// all accepted entries delivered in prunedList[].
void FinePruneLights(uint threadID, int iNrCoarseLights, uint2 viTilLL, float4 vLinDepths)
{
uint t = threadID;
uint iWidth = g_viDimensions.x;
uint iHeight = g_viDimensions.y;
uint uLightsFlags[2] = {0,0};
int l=0;
// need this outer loop even on xb1 and ps4 since direct lights and
// reflection lights are kept in separate regions.
while(l<iNrCoarseLights)
{
// fetch light
int idxCoarse = l<iNrCoarseLights ? coarseList[l] : 0;
uint uLgtType = l<iNrCoarseLights ? g_vLightData[idxCoarse].lightType : 0;
// spot
while(l<iNrCoarseLights && uLgtType==SPOT_LIGHT)
{
SFiniteLightData lightData = g_vLightData[idxCoarse];
const bool bIsSpotDisc = (lightData.flags&IS_CIRCULAR_SPOT_SHAPE)!=0;
// serially check 4 pixels
uint uVal = 0;
for(int i=0; i<4; i++)
{
int idx = t + i*NR_THREADS;
uint2 uPixLoc = min(uint2(viTilLL.x+(idx&0xf), viTilLL.y+(idx>>4)), uint2(iWidth-1, iHeight-1));
float3 vVPos = GetViewPosFromLinDepth(uPixLoc + float2(0.5,0.5), vLinDepths[i]);
// check pixel
float3 fromLight = vVPos-lightData.lightPos.xyz;
float distSq = dot(fromLight,fromLight);
const float fSclProj = dot(fromLight, lightData.lightAxisZ.xyz); // spotDir = lightData.lightAxisZ.xyz
float2 V = abs( float2( dot(fromLight, lightData.lightAxisX.xyz), dot(fromLight, lightData.lightAxisY.xyz) ) );
float fDist2D = bIsSpotDisc ? length(V) : max(V.x,V.y);
if( all( float2(lightData.radiusSq, fSclProj) > float2(distSq, fDist2D*lightData.cotan) ) ) uVal = 1;
}
uLightsFlags[l<32 ? 0 : 1] |= (uVal<<(l&31));
++l; idxCoarse = l<iNrCoarseLights ? coarseList[l] : 0;
uLgtType = l<iNrCoarseLights ? g_vLightData[idxCoarse].lightType : 0;
}
// sphere
while(l<iNrCoarseLights && uLgtType==SPHERE_LIGHT)
{
SFiniteLightData lightData = g_vLightData[idxCoarse];
// serially check 4 pixels
uint uVal = 0;
for(int i=0; i<4; i++)
{
int idx = t + i*NR_THREADS;
uint2 uPixLoc = min(uint2(viTilLL.x+(idx&0xf), viTilLL.y+(idx>>4)), uint2(iWidth-1, iHeight-1));
float3 vVPos = GetViewPosFromLinDepth(uPixLoc + float2(0.5,0.5), vLinDepths[i]);
// check pixel
float3 vLp = lightData.lightPos.xyz;
float3 toLight = vLp - vVPos;
float distSq = dot(toLight,toLight);
if(lightData.radiusSq>distSq) uVal = 1;
}
uLightsFlags[l<32 ? 0 : 1] |= (uVal<<(l&31));
++l; idxCoarse = l<iNrCoarseLights ? coarseList[l] : 0;
uLgtType = l<iNrCoarseLights ? g_vLightData[idxCoarse].lightType : 0;
}
// Box
while(l<iNrCoarseLights && uLgtType==BOX_LIGHT)
{
SFiniteLightData lightData = g_vLightData[idxCoarse];
// serially check 4 pixels
uint uVal = 0;
for(int i=0; i<4; i++)
{
int idx = t + i*NR_THREADS;
uint2 uPixLoc = min(uint2(viTilLL.x+(idx&0xf), viTilLL.y+(idx>>4)), uint2(iWidth-1, iHeight-1));
float3 vVPos = GetViewPosFromLinDepth(uPixLoc + float2(0.5,0.5), vLinDepths[i]);
// check pixel
float3 toLight = lightData.lightPos.xyz - vVPos;
float3 dist = float3( dot(toLight, lightData.lightAxisX), dot(toLight, lightData.lightAxisY), dot(toLight, lightData.lightAxisZ) );
dist = (abs(dist) - lightData.boxInnerDist) * lightData.boxInvRange; // not as efficient as it could be
if( max(max(dist.x, dist.y), dist.z)<1 ) uVal = 1; // but allows us to not write out OuterDists
}
uLightsFlags[l<32 ? 0 : 1] |= (uVal<<(l&31));
++l; idxCoarse = l<iNrCoarseLights ? coarseList[l] : 0;
uLgtType = l<iNrCoarseLights ? g_vLightData[idxCoarse].lightType : 0;
}
// in case we have some corrupt data make sure we terminate
if(uLgtType>=MAX_TYPES) ++l;
}
InterlockedOr(ldsDoesLightIntersect[0], uLightsFlags[0]);
InterlockedOr(ldsDoesLightIntersect[1], uLightsFlags[1]);
if(t==0) ldsNrLightsFinal = 0;
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
GroupMemoryBarrierWithGroupSync();
#endif
if(t<(uint) iNrCoarseLights && (ldsDoesLightIntersect[t<32 ? 0 : 1]&(1<<(t&31)))!=0 )
{
unsigned int uInc = 1;
unsigned int uIndex;
InterlockedAdd(ldsNrLightsFinal, uInc, uIndex);
if(uIndex<MAX_NR_COARSE_ENTRIES) prunedList[uIndex] = coarseList[t]; // we allow up to 64 pruned lights while stored in LDS.
}
}
#endif

36
Assets/TestScenes/HDTest/HDRenderLoopTest.unity


m_Component:
- component: {fileID: 733865594}
- component: {fileID: 733865595}
- component: {fileID: 733865596}
m_Layer: 0
m_Name: Spotlight
m_TagString: Untagged

m_Type: 0
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 8
m_Range: 13.18
m_Range: 12.92
m_SpotAngle: 79.1
m_CookieSize: 10
m_Shadows:

m_BounceIntensity: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!114 &733865596
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 733865593}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a68c43fe1f2a47cfa234b5eeaa98012, type: 3}
m_Name:
m_EditorClassIdentifier:
shadowResolution: 512
innerSpotPercent: 0
shadowDimmer: 1
affectDiffuse: 1
affectSpecular: 1
--- !u!1001 &744696321
Prefab:
m_ObjectHideFlags: 0

m_Component:
- component: {fileID: 1854618466}
- component: {fileID: 1854618465}
- component: {fileID: 1854618467}
m_Layer: 0
m_Name: Point light (1)
m_TagString: Untagged

m_Father: {fileID: 0}
m_RootOrder: 17
m_LocalEulerAnglesHint: {x: -0.39200002, y: 1.033, z: -0.92}
--- !u!114 &1854618467
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1854618464}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a68c43fe1f2a47cfa234b5eeaa98012, type: 3}
m_Name:
m_EditorClassIdentifier:
shadowResolution: 512
innerSpotPercent: 0
shadowDimmer: 1
affectDiffuse: 1
affectSpecular: 1
--- !u!4 &1860830036 stripped
Transform:
m_PrefabParentObject: {fileID: 4000010760374938, guid: 1faa212e4ad88f04a81c5ed019001de5,

50
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePass.cs.hlsl


//
// This file was automatically generated from Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePass.cs. Please don't edit by hand.
//
#ifndef SINGLEPASS_CS_HLSL
#define SINGLEPASS_CS_HLSL
//
// UnityEngine.Experimental.ScriptableRenderLoop.ShadowType: static fields
//
#define SHADOWTYPE_SPOT (0)
#define SHADOWTYPE_DIRECTIONAL (1)
#define SHADOWTYPE_POINT (2)
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.PunctualShadowData
// PackingRules = Exact
struct PunctualShadowData
{
float4x4 worldToShadow;
int shadowType;
float bias;
float quality;
float2 unused;
};
//
// Accessors for UnityEngine.Experimental.ScriptableRenderLoop.PunctualShadowData
//
float4x4 GetWorldToShadow(PunctualShadowData value)
{
return value.worldToShadow;
}
int GetShadowType(PunctualShadowData value)
{
return value.shadowType;
}
float GetBias(PunctualShadowData value)
{
return value.bias;
}
float GetQuality(PunctualShadowData value)
{
return value.quality;
}
float2 GetUnused(PunctualShadowData value)
{
return value.unused;
}
#endif

9
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Lighting/SinglePass/SinglePass.cs.hlsl.meta


fileFormatVersion: 2
guid: 353b54fe916c28f41b202e2d9396e4cf
timeCreated: 1477611341
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

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


fileFormatVersion: 2
guid: 5c0b30845c471c449967253c8cdf5bc2
timeCreated: 1477583748
licenseType: Pro
ShaderImporter:
defaultTextures: []
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:

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

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


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

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


fileFormatVersion: 2
guid: f22956c3631d5f64388bdb93e12ec747
timeCreated: 1477268655
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

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


//
// 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
//
#define SHADOWTYPE_SPOT (0)
#define SHADOWTYPE_DIRECTIONAL (1)
#define SHADOWTYPE_POINT (2)
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.PunctualShadowData
// PackingRules = Exact
struct PunctualShadowData
{
float4x4 worldToShadow;
int shadowType;
float3 unused;
};
//
// Accessors for UnityEngine.Experimental.ScriptableRenderLoop.PunctualShadowData
//
float4x4 GetWorldToShadow(PunctualShadowData value)
{
return value.worldToShadow;
}
int GetShadowType(PunctualShadowData value)
{
return value.shadowType;
}
float3 GetUnused(PunctualShadowData value)
{
return value.unused;
}
#endif
正在加载...
取消
保存