浏览代码

Merge branch 'master' of https://github.com/Unity-Technologies/ScriptableRenderLoop into Branch_DebugMenu2

/RenderPassXR_Sandbox
Julien Ignace 8 年前
当前提交
c7e7065b
共有 36 个文件被更改,包括 2168 次插入316 次删除
  1. 12
      Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.asset
  2. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.asset.meta
  3. 7
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightDefinition.cs.hlsl
  4. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/ClusteredUtils.hlsl
  5. 30
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/FeatureFlags.hlsl
  6. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/LightingConvexHullUtils.hlsl
  7. 84
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  8. 20
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs.hlsl
  9. 14
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePassLoop.hlsl
  10. 14
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/lightlistbuild-bigtile.compute
  11. 12
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/lightlistbuild-clustered.compute
  12. 12
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/lightlistbuild.compute
  13. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/scrbound.compute
  14. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/shadeopaque.compute
  15. 8
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Builtin/BuiltinData.cs.hlsl
  16. 10
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs
  17. 24
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs.hlsl
  18. 14
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  19. 20
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl
  20. 8
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
  21. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/CombineSubsurfaceScattering.shader
  22. 5
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/MaterialUtilities.hlsl
  23. 8
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Unlit.cs.hlsl
  24. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/HDRenderPipelineResources.asset
  25. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/HDRenderPipelineResources.asset.meta
  26. 129
      Assets/ScriptableRenderPipeline/LightweightPipeline/LightweightPipeline.cs
  27. 2
      Assets/ScriptableRenderPipeline/LightweightPipeline/LightweightPipelineAsset.asset
  28. 15
      Assets/ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPipeline.shader
  29. 16
      Assets/ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPipelineCore.cginc
  30. 20
      Assets/ScriptableRenderPipeline/ShaderGenerator/Editor/CSharpToHLSL.cs
  31. 30
      Assets/ScriptableRenderPipeline/ShaderGenerator/Editor/ShaderTypeGeneration.cs
  32. 38
      ProjectSettings/ProjectSettings.asset
  33. 2
      ProjectSettings/ProjectVersion.txt
  34. 1001
      Assets/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/MultiplePointLights.unity
  35. 8
      Assets/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/MultiplePointLights.unity.meta
  36. 897
      ImageTemplates/LightweightPipeline/Scenes/MultiplePointLights.unity.png

12
Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.asset


useForwardRenderingOnly: 0
useDepthPrepass: 0
sssSettings:
numProfiles: 2
numProfiles: 1
- {fileID: 11400000, guid: d6ee4403015766f4093158d69216c0bf, type: 2}
- {fileID: 11400000, guid: 906339bac2066fc4aa22a3652e1283ef, type: 2}
- {fileID: 0}
enableTileAndCluster: 0
enableTileAndCluster: 1
enableSplitLightEvaluation: 1
enableComputeLightEvaluation: 0
enableComputeFeatureVariants: 0

spotCookieSize: 128
pointCookieSize: 512
reflectionCubemapSize: 128
m_DefaultDiffuseMaterial: {fileID: 2100000, guid: 73c176f402d2c2f4d929aa5da7585d17,
type: 2}
m_DefaultShader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}
m_DefaultDiffuseMaterial: {fileID: 0}
m_DefaultShader: {fileID: 0}

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.asset.meta


fileFormatVersion: 2
guid: 449281dd2b4fbee49b8397de0541ea3c
timeCreated: 1496162200
timeCreated: 1496931629
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 11400000

7
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightDefinition.cs.hlsl


//
#define ENVCONSTANTS_SPEC_CUBE_LOD_STEP (6)
//
// UnityEngine.Experimental.Rendering.HDPipeline.StencilLightingUsage: static fields
//
#define STENCILLIGHTINGUSAGE_NO_LIGHTING (0)
#define STENCILLIGHTINGUSAGE_SPLIT_LIGHTING (1)
#define STENCILLIGHTINGUSAGE_REGULAR_LIGHTING (2)
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.LightData
// PackingRules = Exact
struct LightData

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/ClusteredUtils.hlsl


int SnapToClusterIdxFlex(float z_in, float suggestedBase, bool logBasePerTile)
{
#if USE_LEFTHAND_CAMERASPACE
#if USE_LEFT_HAND_CAMERA_SPACE
float z = z_in;
#else
float z = -z_in;

float dist = (PositivePow(suggestedBase, (float)k) - 1.0) / (userscale * (suggestedBase - 1.0f));
res = dist + g_fNearPlane;
#if USE_LEFTHAND_CAMERASPACE
#if USE_LEFT_HAND_CAMERA_SPACE
return res;
#else
return -res;

30
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/FeatureFlags.hlsl


#ifndef __FEATURE_FLAGS_H__
#define __FEATURE_FLAGS_H__
static const uint FEATURE_FLAG_ALL_MATERIALS = FEATURE_FLAG_MATERIAL_LIT_STANDARD | FEATURE_FLAG_MATERIAL_LIT_SSS | FEATURE_FLAG_MATERIAL_LIT_SPECULAR | FEATURE_FLAG_MATERIAL_LIT_ANISO;
static const uint FEATURE_FLAG_ALL_MATERIALS = MATERIALFEATUREFLAGS_LIT_STANDARD | MATERIALFEATUREFLAGS_LIT_SSS | MATERIALFEATUREFLAGS_LIT_SPECULAR | MATERIALFEATUREFLAGS_LIT_ANISO;
/* 1 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_MATERIAL_LIT_STANDARD,
/* 2 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_ENV | FEATURE_FLAG_MATERIAL_LIT_STANDARD,
/* 3 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_PUNCTUAL | FEATURE_FLAG_MATERIAL_LIT_STANDARD,
/* 3 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_PUNCTUAL | FEATURE_FLAG_LIGHT_ENV | FEATURE_FLAG_MATERIAL_LIT_STANDARD,
/* 5 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_AREA | FEATURE_FLAG_MATERIAL_LIT_STANDARD,
/* 6 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_AREA | FEATURE_FLAG_LIGHT_PUNCTUAL | FEATURE_FLAG_LIGHT_ENV | FEATURE_FLAG_MATERIAL_LIT_STANDARD,
/* 7 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_AREA | FEATURE_FLAG_LIGHT_PUNCTUAL | FEATURE_FLAG_LIGHT_ENV | FEATURE_FLAG_LIGHT_PROJECTOR | FEATURE_FLAG_MATERIAL_LIT_STANDARD,
/* 8 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_ALL_MATERIALS,
/* 9 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_ENV | FEATURE_FLAG_ALL_MATERIALS,
/* 10 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_PUNCTUAL | FEATURE_FLAG_ALL_MATERIALS,
/* 11 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_PUNCTUAL | FEATURE_FLAG_LIGHT_ENV | FEATURE_FLAG_ALL_MATERIALS,
/* 12 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_AREA | FEATURE_FLAG_ALL_MATERIALS,
/* 13 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_AREA | FEATURE_FLAG_LIGHT_PUNCTUAL | FEATURE_FLAG_LIGHT_ENV | FEATURE_FLAG_ALL_MATERIALS,
/* 14 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_AREA | FEATURE_FLAG_LIGHT_PUNCTUAL | FEATURE_FLAG_LIGHT_ENV | FEATURE_FLAG_LIGHT_PROJECTOR | FEATURE_FLAG_ALL_MATERIALS,
/* 1 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 2 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 3 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 3 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 5 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 6 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 7 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | LIGHTFEATUREFLAGS_PROJECTOR | MATERIALFEATUREFLAGS_LIT_STANDARD,
/* 8 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | FEATURE_FLAG_ALL_MATERIALS,
/* 9 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_ENV | FEATURE_FLAG_ALL_MATERIALS,
/* 10 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | FEATURE_FLAG_ALL_MATERIALS,
/* 11 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | FEATURE_FLAG_ALL_MATERIALS,
/* 12 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | FEATURE_FLAG_ALL_MATERIALS,
/* 13 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | FEATURE_FLAG_ALL_MATERIALS,
/* 14 */ LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_AREA | LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_ENV | LIGHTFEATUREFLAGS_PROJECTOR | FEATURE_FLAG_ALL_MATERIALS,
/* 15 */ 0xFFFFFFFF
};

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/LightingConvexHullUtils.hlsl


p0 = center + (vA + vB - vC); // center + vA is center of face when scaleXY is 1.0
float3 vNout = cross( vB2, 0.5*(vA-vA2) - vC );
#if USE_LEFTHAND_CAMERASPACE
#if USE_LEFT_HAND_CAMERA_SPACE
vNout = -vNout;
#endif

#endif
// enlarge sphere so it overlaps the center of the tile assuming it overlaps the tile to begin with.
#if USE_LEFTHAND_CAMERASPACE
#if USE_LEFT_HAND_CAMERA_SPACE
float sphRadius = sphRadiusIn + (sphCen.z+offs)*halfTileSizeAtZDistOne;
#else
float sphRadius = sphRadiusIn - (sphCen.z-offs)*halfTileSizeAtZDistOne;

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


}
[GenerateHLSL]
public class LightFeatureFlags
public enum LightFeatureFlags
public static uint FEATURE_FLAG_LIGHT_PUNCTUAL = 1 << 0;
public static uint FEATURE_FLAG_LIGHT_AREA = 1 << 1;
public static uint FEATURE_FLAG_LIGHT_DIRECTIONAL = 1 << 2;
public static uint FEATURE_FLAG_LIGHT_PROJECTOR = 1 << 3;
public static uint FEATURE_FLAG_LIGHT_ENV = 1 << 4;
public static uint FEATURE_FLAG_LIGHT_SKY = 1 << 5;
Punctual = 1 << 0,
Area = 1 << 1,
Directional = 1 << 2,
Projector = 1 << 3,
Env = 1 << 4,
Sky = 1 << 5
public static int MAX_NR_LIGHTS_PER_CAMERA = 1024;
public static int MAX_NR_BIGTILE_LIGHTS_PLUSONE = 512; // may be overkill but the footprint is 2 bits per pixel using uint16.
public static float VIEWPORT_SCALE_Z = 1.0f;
public static int s_MaxNrLightsPerCamera = 1024;
public static int s_MaxNrBigTileLightsPlusOne = 512; // may be overkill but the footprint is 2 bits per pixel using uint16.
public static float s_ViewportScaleZ = 1.0f;
public static int USE_LEFTHAND_CAMERASPACE = 1;
public static int s_UseLeftHandCameraSpace = 1;
public static int TILE_SIZE_FPTL = 16;
public static int TILE_SIZE_CLUSTERED = 32;
// flags
public static int IS_CIRCULAR_SPOT_SHAPE = 1;
public static int HAS_COOKIE_TEXTURE = 2;
public static int IS_BOX_PROJECTED = 4;
public static int HAS_SHADOW = 8;
public static int s_TileSizeFptl = 16;
public static int s_TileSizeClustered = 32;
public static int NUM_FEATURE_VARIANTS = 16;
public static int s_NumFeatureVariants = 16;
}
[GenerateHLSL]

static int s_shadeOpaqueDirectFptlKernel;
static int s_shadeOpaqueDirectClusteredDebugDisplayKernel;
static int s_shadeOpaqueDirectFptlDebugDisplayKernel;
static int[] s_shadeOpaqueIndirectClusteredKernels = new int[LightDefinitions.NUM_FEATURE_VARIANTS];
static int[] s_shadeOpaqueIndirectFptlKernels = new int[LightDefinitions.NUM_FEATURE_VARIANTS];
static int[] s_shadeOpaqueIndirectClusteredKernels = new int[LightDefinitions.s_NumFeatureVariants];
static int[] s_shadeOpaqueIndirectFptlKernels = new int[LightDefinitions.s_NumFeatureVariants];
static ComputeBuffer s_LightVolumeDataBuffer = null;
static ComputeBuffer s_ConvexBoundsBuffer = null;

int GetNumTileFtplX(Camera camera)
{
return (camera.pixelWidth + (LightDefinitions.TILE_SIZE_FPTL - 1)) / LightDefinitions.TILE_SIZE_FPTL;
return (camera.pixelWidth + (LightDefinitions.s_TileSizeFptl - 1)) / LightDefinitions.s_TileSizeFptl;
return (camera.pixelHeight + (LightDefinitions.TILE_SIZE_FPTL - 1)) / LightDefinitions.TILE_SIZE_FPTL;
return (camera.pixelHeight + (LightDefinitions.s_TileSizeFptl - 1)) / LightDefinitions.s_TileSizeFptl;
return (camera.pixelWidth + (LightDefinitions.TILE_SIZE_CLUSTERED - 1)) / LightDefinitions.TILE_SIZE_CLUSTERED;
return (camera.pixelWidth + (LightDefinitions.s_TileSizeClustered - 1)) / LightDefinitions.s_TileSizeClustered;
return (camera.pixelHeight + (LightDefinitions.TILE_SIZE_CLUSTERED - 1)) / LightDefinitions.TILE_SIZE_CLUSTERED;
return (camera.pixelHeight + (LightDefinitions.s_TileSizeClustered - 1)) / LightDefinitions.s_TileSizeClustered;
}
bool GetFeatureVariantsEnabled()

s_AABBBoundsBuffer = new ComputeBuffer(2 * k_MaxLightsOnScreen, 3 * sizeof(float));
s_ConvexBoundsBuffer = new ComputeBuffer(k_MaxLightsOnScreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(SFiniteLightBound)));
s_LightVolumeDataBuffer = new ComputeBuffer(k_MaxLightsOnScreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(LightVolumeData)));
s_DispatchIndirectBuffer = new ComputeBuffer(LightDefinitions.NUM_FEATURE_VARIANTS * 3, sizeof(uint), ComputeBufferType.IndirectArguments);
s_DispatchIndirectBuffer = new ComputeBuffer(LightDefinitions.s_NumFeatureVariants * 3, sizeof(uint), ComputeBufferType.IndirectArguments);
if (m_TileSettings.enableClustered)
{

s_shadeOpaqueDirectClusteredDebugDisplayKernel = shadeOpaqueShader.FindKernel("ShadeOpaque_Direct_Clustered_DebugDisplay");
s_shadeOpaqueDirectFptlDebugDisplayKernel = shadeOpaqueShader.FindKernel("ShadeOpaque_Direct_Fptl_DebugDisplay");
for (int variant = 0; variant < LightDefinitions.NUM_FEATURE_VARIANTS; variant++)
for (int variant = 0; variant < LightDefinitions.s_NumFeatureVariants; variant++)
{
s_shadeOpaqueIndirectClusteredKernels[variant] = shadeOpaqueShader.FindKernel("ShadeOpaque_Indirect_Clustered_Variant" + variant);
s_shadeOpaqueIndirectFptlKernels[variant] = shadeOpaqueShader.FindKernel("ShadeOpaque_Indirect_Fptl_Variant" + variant);

public void AllocResolutionDependentBuffers(int width, int height)
{
var nrTilesX = (width + LightDefinitions.TILE_SIZE_FPTL - 1) / LightDefinitions.TILE_SIZE_FPTL;
var nrTilesY = (height + LightDefinitions.TILE_SIZE_FPTL - 1) / LightDefinitions.TILE_SIZE_FPTL;
var nrTilesX = (width + LightDefinitions.s_TileSizeFptl - 1) / LightDefinitions.s_TileSizeFptl;
var nrTilesY = (height + LightDefinitions.s_TileSizeFptl - 1) / LightDefinitions.s_TileSizeFptl;
s_TileList = new ComputeBuffer((int)LightDefinitions.NUM_FEATURE_VARIANTS * nrTiles, sizeof(uint));
s_TileList = new ComputeBuffer((int)LightDefinitions.s_NumFeatureVariants * nrTiles, sizeof(uint));
var nrClustersX = (width + LightDefinitions.TILE_SIZE_CLUSTERED - 1) / LightDefinitions.TILE_SIZE_CLUSTERED;
var nrClustersY = (height + LightDefinitions.TILE_SIZE_CLUSTERED - 1) / LightDefinitions.TILE_SIZE_CLUSTERED;
var nrClustersX = (width + LightDefinitions.s_TileSizeClustered - 1) / LightDefinitions.s_TileSizeClustered;
var nrClustersY = (height + LightDefinitions.s_TileSizeClustered - 1) / LightDefinitions.s_TileSizeClustered;
var nrClusterTiles = nrClustersX * nrClustersY;
s_PerVoxelOffset = new ComputeBuffer((int)LightCategory.Count * (1 << k_Log2NumClusters) * nrClusterTiles, sizeof(uint));

var nrBigTilesX = (width + 63) / 64;
var nrBigTilesY = (height + 63) / 64;
var nrBigTiles = nrBigTilesX * nrBigTilesY;
s_BigTileLightList = new ComputeBuffer(LightDefinitions.MAX_NR_BIGTILE_LIGHTS_PLUSONE * nrBigTiles, sizeof(uint));
s_BigTileLightList = new ComputeBuffer(LightDefinitions.s_MaxNrBigTileLightsPlusOne * nrBigTiles, sizeof(uint));
}
}

bool isLeftHand = ((int)LightDefinitions.USE_LEFTHAND_CAMERASPACE) != 0;
bool isLeftHand = ((int)LightDefinitions.s_UseLeftHandCameraSpace) != 0;
if (isLeftHand) flip.SetColumn(2, new Vector4(0.0f, 0.0f, -1.0f, 0.0f));
return flip;
}

lightVolumeData.lightPos = worldToView.MultiplyPoint(lightPos);
lightVolumeData.radiusSq = range * range;
lightVolumeData.cotan = cota;
lightVolumeData.featureFlags = (gpuLightType == GPULightType.Spot) ? LightFeatureFlags.FEATURE_FLAG_LIGHT_PUNCTUAL
: LightFeatureFlags.FEATURE_FLAG_LIGHT_PROJECTOR;
lightVolumeData.featureFlags = (gpuLightType == GPULightType.Spot) ? (uint)LightFeatureFlags.Punctual
: (uint)LightFeatureFlags.Projector;
}
else if (gpuLightType == GPULightType.Point)
{

lightVolumeData.lightAxisZ = vz;
lightVolumeData.lightPos = bound.center;
lightVolumeData.radiusSq = range * range;
lightVolumeData.featureFlags = LightFeatureFlags.FEATURE_FLAG_LIGHT_PUNCTUAL;
lightVolumeData.featureFlags = (uint)LightFeatureFlags.Punctual;
}
else if (gpuLightType == GPULightType.Rectangle)
{

lightVolumeData.lightAxisZ = zAxisVS;
lightVolumeData.boxInnerDist = dimensions;
lightVolumeData.boxInvRange.Set(1e5f, 1e5f, 1e5f);
lightVolumeData.featureFlags = LightFeatureFlags.FEATURE_FLAG_LIGHT_AREA;
lightVolumeData.featureFlags = (uint)LightFeatureFlags.Area;
}
else if (gpuLightType == GPULightType.Line)
{

lightVolumeData.lightAxisZ = zAxisVS;
lightVolumeData.boxInnerDist = new Vector3(lightData.size.x * 0.5f, 0.01f, 0.01f);
lightVolumeData.boxInvRange.Set(1.0f / radius, 1.0f / radius, 1.0f / radius);
lightVolumeData.featureFlags = LightFeatureFlags.FEATURE_FLAG_LIGHT_AREA;
lightVolumeData.featureFlags = (uint)LightFeatureFlags.Area;
}
else if (gpuLightType == GPULightType.ProjectorOrtho)
{

lightVolumeData.lightAxisZ = zAxisVS;
lightVolumeData.boxInnerDist = halfDims; // No idea what this is. Document your code
lightVolumeData.boxInvRange.Set(1.0f / halfDims.x, 1.0f / halfDims.y, 1.0f / halfDims.z); // No idea what this is. Document your code
lightVolumeData.featureFlags = LightFeatureFlags.FEATURE_FLAG_LIGHT_PROJECTOR;
lightVolumeData.featureFlags = (uint)LightFeatureFlags.Projector;
}
else
{

lightVolumeData.lightCategory = (uint)LightCategory.Env;
lightVolumeData.lightVolume = (uint)lightVolumeType;
lightVolumeData.featureFlags = LightFeatureFlags.FEATURE_FLAG_LIGHT_ENV;
lightVolumeData.featureFlags = (uint)LightFeatureFlags.Env;
lightVolumeData.lightPos = Cw;
lightVolumeData.lightAxisX = vx;

uint baseFeatureFlags = 0;
if (m_lightList.directionalLights.Count > 0)
{
baseFeatureFlags |= LightFeatureFlags.FEATURE_FLAG_LIGHT_DIRECTIONAL;
baseFeatureFlags |= (uint)LightFeatureFlags.Directional;
baseFeatureFlags |= LightFeatureFlags.FEATURE_FLAG_LIGHT_SKY;
baseFeatureFlags |= (uint)LightFeatureFlags.Sky;
}
cmd.SetComputeBufferParam(buildPerTileLightListShader, s_GenListPerTileKernel, "g_DispatchIndirectBuffer", s_DispatchIndirectBuffer);
cmd.SetComputeBufferParam(buildPerTileLightListShader, s_GenListPerTileKernel, "g_TileList", s_TileList);

int numVariants = 1;
if (enableFeatureVariants)
numVariants = LightDefinitions.NUM_FEATURE_VARIANTS;
numVariants = LightDefinitions.s_NumFeatureVariants;
for (int variant = 0; variant < numVariants; variant++)
{

20
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs.hlsl


//
// UnityEngine.Experimental.Rendering.HDPipeline.TilePass.LightFeatureFlags: static fields
//
#define FEATURE_FLAG_LIGHT_PUNCTUAL (1)
#define FEATURE_FLAG_LIGHT_AREA (2)
#define FEATURE_FLAG_LIGHT_DIRECTIONAL (4)
#define FEATURE_FLAG_LIGHT_PROJECTOR (8)
#define FEATURE_FLAG_LIGHT_ENV (16)
#define FEATURE_FLAG_LIGHT_SKY (32)
#define LIGHTFEATUREFLAGS_PUNCTUAL (1)
#define LIGHTFEATUREFLAGS_AREA (2)
#define LIGHTFEATUREFLAGS_DIRECTIONAL (4)
#define LIGHTFEATUREFLAGS_PROJECTOR (8)
#define LIGHTFEATUREFLAGS_ENV (16)
#define LIGHTFEATUREFLAGS_SKY (32)
#define MAX_NR_BIGTILE_LIGHTS_PLUSONE (512)
#define MAX_NR_BIG_TILE_LIGHTS_PLUS_ONE (512)
#define USE_LEFTHAND_CAMERASPACE (1)
#define USE_LEFT_HAND_CAMERA_SPACE (1)
#define IS_CIRCULAR_SPOT_SHAPE (1)
#define HAS_COOKIE_TEXTURE (2)
#define IS_BOX_PROJECTED (4)
#define HAS_SHADOW (8)
#define NUM_FEATURE_VARIANTS (16)
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.TilePass.SFiniteLightBound

14
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePassLoop.hlsl


uint i = 0; // Declare once to avoid the D3D11 compiler warning.
#ifdef PROCESS_DIRECTIONAL_LIGHT
if(featureFlags & FEATURE_FLAG_LIGHT_DIRECTIONAL)
if(featureFlags & LIGHTFEATUREFLAGS_DIRECTIONAL)
{
for(i = 0; i < _DirectionalLightCount; ++i)
{

#endif
#ifdef PROCESS_PUNCTUAL_LIGHT
if(featureFlags & FEATURE_FLAG_LIGHT_PUNCTUAL)
if(featureFlags & LIGHTFEATUREFLAGS_PUNCTUAL)
{
// TODO: Convert the for loop below to a while on each type as we know we are sorted!
uint punctualLightStart;

#endif
#ifdef PROCESS_AREA_LIGHT
if(featureFlags & FEATURE_FLAG_LIGHT_AREA)
if(featureFlags & LIGHTFEATUREFLAGS_AREA)
{
// TODO: Convert the for loop below to a while on each type as we know we are sorted!
uint areaLightStart;

#endif
#ifdef PROCESS_PROJECTOR_LIGHT
if(featureFlags & FEATURE_FLAG_LIGHT_PROJECTOR)
if(featureFlags & LIGHTFEATUREFLAGS_PROJECTOR)
{
// TODO: Convert the for loop below to a while on each type as we know we are sorted!
uint projectorLightStart;

float3 iblSpecularLighting = float3(0.0, 0.0, 0.0);
// Only apply sky IBL if the sky texture is available.
if(featureFlags & FEATURE_FLAG_LIGHT_SKY)
if(featureFlags & LIGHTFEATUREFLAGS_SKY)
{
if(_EnvLightSkyEnabled)
{

}
if(featureFlags & FEATURE_FLAG_LIGHT_ENV)
if(featureFlags & LIGHTFEATUREFLAGS_ENV)
{
uint envLightStart;
uint envLightCount;

out float3 diffuseLighting,
out float3 specularLighting)
{
LightLoopContext context;
LightLoopContext context;
// Note: When we ImageLoad outside of texture size, the value returned by Load is 0 (Note: On Metal maybe it clamp to value of texture which is also fine)
// We use this property to have a neutral value for AO that doesn't consume a sampler and work also with compute shader (i.e use ImageLoad)
// We store inverse AO so neutral is black. So either we sample inside or outside the texture it return 0 in case of neutral

14
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/lightlistbuild-bigtile.compute


#define EXACT_EDGE_TESTS
#define PERFORM_SPHERICAL_INTERSECTION_TESTS
#define MAX_NR_BIGTILE_LIGHTS (MAX_NR_BIGTILE_LIGHTS_PLUSONE-1)
#define MAX_NR_BIGTILE_LIGHTS (MAX_NR_BIG_TILE_LIGHTS_PLUS_ONE-1)
uniform int g_iNrVisibLights;

// 2kB (room for roughly 30 wavefronts)
groupshared unsigned int lightsListLDS[MAX_NR_BIGTILE_LIGHTS_PLUSONE];
groupshared unsigned int lightsListLDS[MAX_NR_BIG_TILE_LIGHTS_PLUS_ONE];
groupshared uint lightOffs;

float fSy = g_mScrProjection[1].y;
float fCy = g_mScrProjection[1].z;
#if USE_LEFTHAND_CAMERASPACE
#if USE_LEFT_HAND_CAMERA_SPACE
return fLinDepth*float3( ((v2ScrPos.x-fCx)/fSx), ((v2ScrPos.y-fCy)/fSy), 1.0 );
#else
return fLinDepth*float3( -((v2ScrPos.x+fCx)/fSx), -((v2ScrPos.y+fCy)/fSy), 1.0 );

// sort lights
SORTLIST(lightsListLDS, iNrCoarseLights, MAX_NR_BIGTILE_LIGHTS_PLUSONE, t, NR_THREADS);
SORTLIST(lightsListLDS, iNrCoarseLights, MAX_NR_BIG_TILE_LIGHTS_PLUS_ONE, t, NR_THREADS);
if(t==0) lightOffs = 0;
GroupMemoryBarrierWithGroupSync();

int offs = tileIDX.y*nrBigTilesX + tileIDX.x;
for(i=t; i<(iNrCoarseLights+1); i+=NR_THREADS)
g_vLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*offs + i] = i==0 ? iNrCoarseLights : lightsListLDS[max(i-1, 0)];
g_vLightList[MAX_NR_BIG_TILE_LIGHTS_PLUS_ONE*offs + i] = i==0 ? iNrCoarseLights : lightsListLDS[max(i-1, 0)];
}

#if USE_LEFTHAND_CAMERASPACE
#if USE_LEFT_HAND_CAMERA_SPACE
float3 V = GetViewPosFromLinDepth( screenCoordinate, 1.0);
#else
float3 V = GetViewPosFromLinDepth( screenCoordinate, -1.0);

float x = (i&1)==0 ? viTilLL.x : viTilUR.x;
float y = (i&2)==0 ? viTilLL.y : viTilUR.y;
float z = (i&4)==0 ? g_fNearPlane : fTileFarPlane;
#if !USE_LEFTHAND_CAMERASPACE
#if !USE_LEFT_HAND_CAMERA_SPACE
z = -z;
#endif
return GetViewPosFromLinDepth( float2(x, y), z);

12
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/lightlistbuild-clustered.compute


float fSy = g_mScrProjection[1].y;
float fCy = g_mScrProjection[1].z;
#if USE_LEFTHAND_CAMERASPACE
#if USE_LEFT_HAND_CAMERA_SPACE
return fLinDepth*float3( ((v2ScrPos.x-fCx)/fSx), ((v2ScrPos.y-fCy)/fSy), 1.0 );
#else
return fLinDepth*float3( -((v2ScrPos.x+fCx)/fSx), -((v2ScrPos.y+fCy)/fSy), 1.0 );

int NrBigTilesX = (nrTilesX+((1<<log2BigTileToClustTileRatio)-1))>>log2BigTileToClustTileRatio;
const int bigTileIdx = (tileIDX.y>>log2BigTileToClustTileRatio)*NrBigTilesX + (tileIDX.x>>log2BigTileToClustTileRatio); // map the idx to 64x64 tiles
int nrBigTileLights = g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+0];
int nrBigTileLights = g_vBigTileLightList[MAX_NR_BIG_TILE_LIGHTS_PLUS_ONE*bigTileIdx+0];
int l = g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1];
int l = g_vBigTileLightList[MAX_NR_BIG_TILE_LIGHTS_PLUS_ONE*bigTileIdx+l0+1];
#else
for(int l=(int) t; l<(int) g_iNrVisibLights; l += NR_THREADS)
{

#ifdef ENABLE_DEPTH_TEXTURE_BACKPLANE
#if USE_LEFTHAND_CAMERASPACE
#if USE_LEFT_HAND_CAMERA_SPACE
float fTileFarPlane = GetLinearDepth(dpt_ma);
#else
float fTileFarPlane = -GetLinearDepth(dpt_ma);

#ifdef PERFORM_SPHERICAL_INTERSECTION_TESTS
int SphericalIntersectionTests(uint threadID, int iNrCoarseLights, float2 screenCoordinate)
{
#if USE_LEFTHAND_CAMERASPACE
#if USE_LEFT_HAND_CAMERA_SPACE
float3 V = GetViewPosFromLinDepth( screenCoordinate, 1.0);
#else
float3 V = GetViewPosFromLinDepth( screenCoordinate, -1.0);

float x = (i&1)==0 ? viTilLL.x : viTilUR.x;
float y = (i&2)==0 ? viTilLL.y : viTilUR.y;
float z = (i&4)==0 ? g_fNearPlane : fTileFarPlane;
#if !USE_LEFTHAND_CAMERASPACE
#if !USE_LEFT_HAND_CAMERA_SPACE
z = -z;
#endif
return GetViewPosFromLinDepth( float2(x, y), z);

12
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/lightlistbuild.compute


#pragma kernel TileLightListGen_FeatureFlags LIGHTLISTGEN=TileLightListGen_FeatureFlags USE_FEATURE_FLAGS
#pragma kernel TileLightListGen_SrcBigTile_FeatureFlags LIGHTLISTGEN=TileLightListGen_SrcBigTile_FeatureFlags USE_TWO_PASS_TILED_LIGHTING USE_FEATURE_FLAGS
#pragma #pragma enable_d3d11_debug_symbols
//#pragma #pragma enable_d3d11_debug_symbols
#include "../../../ShaderLibrary/common.hlsl"
#include "ShaderBase.hlsl"

float fSy = g_mScrProjection[1].y;
float fCy = g_mScrProjection[1].z;
#if USE_LEFTHAND_CAMERASPACE
#if USE_LEFT_HAND_CAMERA_SPACE
return fLinDepth*float3( ((v2ScrPos.x-fCx)/fSx), ((v2ScrPos.y-fCy)/fSy), 1.0 );
#else
return fLinDepth*float3( -((v2ScrPos.x+fCx)/fSx), -((v2ScrPos.y+fCy)/fSy), 1.0 );

int NrBigTilesX = (nrTilesX+((1<<log2BigTileToTileRatio)-1))>>log2BigTileToTileRatio;
const int bigTileIdx = (tileIDX.y>>log2BigTileToTileRatio)*NrBigTilesX + (tileIDX.x>>log2BigTileToTileRatio); // map the idx to 64x64 tiles
int nrBigTileLights = g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+0];
int nrBigTileLights = g_vBigTileLightList[MAX_NR_BIG_TILE_LIGHTS_PLUS_ONE*bigTileIdx+0];
int l = g_vBigTileLightList[MAX_NR_BIGTILE_LIGHTS_PLUSONE*bigTileIdx+l0+1];
int l = g_vBigTileLightList[MAX_NR_BIG_TILE_LIGHTS_PLUS_ONE*bigTileIdx+l0+1];
#else
for(int l=(int) t; l<(int) g_iNrVisibLights; l += NR_THREADS)
{

uint featureFlags = g_BaseFeatureFlags | ldsFeatureFlags;
if(ldsZMax < ldsZMin) // is background pixel
{
featureFlags &= ~(FEATURE_FLAG_LIGHT_PUNCTUAL | FEATURE_FLAG_LIGHT_AREA | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_ENV | 0xFFFFF); // list of features that are not enabled on background
featureFlags &= ~(LIGHTFEATUREFLAGS_PUNCTUAL | LIGHTFEATUREFLAGS_AREA | LIGHTFEATUREFLAGS_DIRECTIONAL | LIGHTFEATUREFLAGS_ENV | 0xFFFFF); // list of features that are not enabled on background
}
uint variant = FeatureFlagsToTileVariant(featureFlags);

GroupMemoryBarrierWithGroupSync();
#endif
#if USE_LEFTHAND_CAMERASPACE
#if USE_LEFT_HAND_CAMERA_SPACE
float3 V = GetViewPosFromLinDepth( screenCoordinate, 1.0);
#else
float3 V = GetViewPosFromLinDepth( screenCoordinate, -1.0);

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/scrbound.compute


vMax.xy = bMa ? min(vMax.xy, vMa) : vMax.xy;
}
#if USE_LEFTHAND_CAMERASPACE
#if USE_LEFT_HAND_CAMERA_SPACE
if((center.z-radius)>0.0)
{
float4 vPosF = mul(g_mProjection, float4(0,0,center.z-radius,1));

float4 planeY = EvalPlanePair(validY, float2(pos_view_space.y, pos_view_space.z), r);
#if USE_LEFTHAND_CAMERASPACE
#if USE_LEFT_HAND_CAMERA_SPACE
planeX = planeX.zwxy; // need to swap left/right and top/bottom planes when using left hand system
planeY = planeY.zwxy;
#endif

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/shadeopaque.compute


#pragma kernel ShadeOpaque_Indirect_Clustered_Variant14 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant14 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=14
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant15 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant15 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=15
#pragma #pragma enable_d3d11_debug_symbols
//#pragma #pragma enable_d3d11_debug_symbols
// Split lighting is required for the SSS pass.
// Not currently possible since we need to access the stencil buffer from the compute shader.

8
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Builtin/BuiltinData.cs.hlsl


#ifndef BUILTINDATA_CS_HLSL
#define BUILTINDATA_CS_HLSL
//
// UnityEngine.Experimental.Rendering.HDPipeline.Builtin.BuiltinData: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Builtin+BuiltinData: static fields
//
#define DEBUGVIEW_BUILTIN_BUILTINDATA_OPACITY (100)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_BAKE_DIFFUSE_LIGHTING (101)

#define DEBUGVIEW_BUILTIN_BUILTINDATA_DEPTH_OFFSET (107)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Builtin.LightTransportData: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Builtin+LightTransportData: static fields
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Builtin.BuiltinData
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Builtin+BuiltinData
// PackingRules = Exact
struct BuiltinData
{

float depthOffset;
};
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Builtin.LightTransportData
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Builtin+LightTransportData
// PackingRules = Exact
struct LightTransportData
{

10
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs


};
[GenerateHLSL]
public class MaterialFeatureFlags
public enum MaterialFeatureFlags
public static uint FEATURE_FLAG_MATERIAL_LIT_SSS = 1 << 12;
public static uint FEATURE_FLAG_MATERIAL_LIT_STANDARD = 1 << 13;
public static uint FEATURE_FLAG_MATERIAL_LIT_SPECULAR = 1 << 14;
public static uint FEATURE_FLAG_MATERIAL_LIT_ANISO = 1 << 15;
LitSSS = 1 << 12,
LitStandard = 1 << 13,
LitSpecular = 1 << 14,
LitAniso = 1 << 15
}
//-----------------------------------------------------------------------------

24
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs.hlsl


#ifndef LIT_CS_HLSL
#define LIT_CS_HLSL
//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit.MaterialId: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+MaterialId: static fields
//
#define MATERIALID_LIT_SSS (0)
#define MATERIALID_LIT_STANDARD (1)

//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit.MaterialFeatureFlags: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+MaterialFeatureFlags: static fields
#define FEATURE_FLAG_MATERIAL_LIT_SSS (4096)
#define FEATURE_FLAG_MATERIAL_LIT_STANDARD (8192)
#define FEATURE_FLAG_MATERIAL_LIT_SPECULAR (16384)
#define FEATURE_FLAG_MATERIAL_LIT_ANISO (32768)
#define MATERIALFEATUREFLAGS_LIT_SSS (4096)
#define MATERIALFEATUREFLAGS_LIT_STANDARD (8192)
#define MATERIALFEATUREFLAGS_LIT_SPECULAR (16384)
#define MATERIALFEATUREFLAGS_LIT_ANISO (32768)
// UnityEngine.Experimental.Rendering.HDPipeline.Lit.SurfaceData: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+SurfaceData: static fields
//
#define DEBUGVIEW_LIT_SURFACEDATA_BASE_COLOR (1000)
#define DEBUGVIEW_LIT_SURFACEDATA_SPECULAR_OCCLUSION (1001)

#define DEBUGVIEW_LIT_SURFACEDATA_SPECULAR_COLOR (1013)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit.TransmissionType: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+TransmissionType: static fields
//
#define TRANSMISSIONTYPE_NONE (0)
#define TRANSMISSIONTYPE_REGULAR (1)

// UnityEngine.Experimental.Rendering.HDPipeline.Lit.BSDFData: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+BSDFData: static fields
//
#define DEBUGVIEW_LIT_BSDFDATA_DIFFUSE_COLOR (1030)
#define DEBUGVIEW_LIT_BSDFDATA_FRESNEL0 (1031)

#define DEBUGVIEW_LIT_BSDFDATA_TRANSMITTANCE (1047)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit.GBufferMaterial: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+GBufferMaterial: static fields
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Lit.SurfaceData
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Lit+SurfaceData
// PackingRules = Exact
struct SurfaceData
{

float3 specularColor;
};
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Lit.BSDFData
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Lit+BSDFData
// PackingRules = Exact
struct BSDFData
{

14
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


bsdfData.roughness = PerceptualRoughnessToRoughness(bsdfData.perceptualRoughness);
int supportsStandard = (featureFlags & (FEATURE_FLAG_MATERIAL_LIT_STANDARD | FEATURE_FLAG_MATERIAL_LIT_ANISO)) != 0;
int supportsSSS = (featureFlags & (FEATURE_FLAG_MATERIAL_LIT_SSS)) != 0;
int supportsSpecular = (featureFlags & (FEATURE_FLAG_MATERIAL_LIT_SPECULAR)) != 0;
int supportsStandard = (featureFlags & (MATERIALFEATUREFLAGS_LIT_STANDARD | MATERIALFEATUREFLAGS_LIT_ANISO)) != 0;
int supportsSSS = (featureFlags & (MATERIALFEATUREFLAGS_LIT_SSS)) != 0;
int supportsSpecular = (featureFlags & (MATERIALFEATUREFLAGS_LIT_SPECULAR)) != 0;
if(supportsStandard + supportsSSS + supportsSpecular > 1)
{

float3 tangentWS = UnpackNormalOctEncode(float2(inGBuffer2.rg * 2.0 - 1.0));
FillMaterialIdStandardData(baseColor, specular, metallic, bsdfData.roughness, bsdfData.normalWS, tangentWS, anisotropy, bsdfData);
if ((featureFlags & FEATURE_FLAG_MATERIAL_LIT_ANISO) && (featureFlags & FEATURE_FLAG_MATERIAL_LIT_STANDARD) == 0 || anisotropy > 0)
if ((featureFlags & MATERIALFEATUREFLAGS_LIT_ANISO) && (featureFlags & MATERIALFEATUREFLAGS_LIT_STANDARD) == 0 || anisotropy > 0)
{
bsdfData.materialId = MATERIALID_LIT_ANISO;
}

uint featureFlags = 0;
if (materialId == MATERIALID_LIT_STANDARD)
{
featureFlags |= (anisotropy > 0) ? FEATURE_FLAG_MATERIAL_LIT_ANISO : FEATURE_FLAG_MATERIAL_LIT_STANDARD;
featureFlags |= (anisotropy > 0) ? MATERIALFEATUREFLAGS_LIT_ANISO : MATERIALFEATUREFLAGS_LIT_STANDARD;
featureFlags |= FEATURE_FLAG_MATERIAL_LIT_SSS;
featureFlags |= MATERIALFEATUREFLAGS_LIT_SSS;
featureFlags |= FEATURE_FLAG_MATERIAL_LIT_SPECULAR;
featureFlags |= MATERIALFEATUREFLAGS_LIT_SPECULAR;
}
return featureFlags;
}

20
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl


float3x3 worldToTangent = input.worldToTangent;
#ifdef SURFACE_GRADIENT
// The TBN is not normalize, normalize it to do per pixel displacement
worldToTangent[1] = normalize(worldToTangent[1]);
worldToTangent[2] = normalize(worldToTangent[2]);
#endif
// Note: The TBN is not normalize as it is based on mikkt. We should normalize it, but POM is always use on simple enough surfarce that mean it is not required (save 2 normalize). Tag: SURFACE_GRADIENT
float3 viewDirTS = isPlanar ? float3(uvXZ, V.y) : TransformWorldToTangent(V, worldToTangent);
NdotV = viewDirTS.z;

float3x3 worldToTangent = input.worldToTangent;
#ifdef SURFACE_GRADIENT
// The TBN is not normalize, normalize it to do per pixel displacement
worldToTangent[1] = normalize(worldToTangent[1]);
worldToTangent[2] = normalize(worldToTangent[2]);
#endif
// Note: The TBN is not normalize as it is based on mikkt. We should normalize it, but POM is always use on simple enough surfarce that mean it is not required (save 2 normalize). Tag: SURFACE_GRADIENT
// For planar the view vector is the world view vector (unless we want to support object triplanar ? and in this case used TransformWorldToObject)
// TODO: do we support object triplanar ? See ComputeLayerTexCoord
float3 viewDirTS = isPlanar ? float3(-V.xz, V.y) : TransformWorldToTangent(V, worldToTangent);

surfaceData.perceptualSmoothness = SURFACEDATA_BLEND_SCALAR(surfaceData, perceptualSmoothness, weights);
surfaceData.ambientOcclusion = SURFACEDATA_BLEND_SCALAR(surfaceData, ambientOcclusion, weights);
surfaceData.metallic = SURFACEDATA_BLEND_SCALAR(surfaceData, metallic, weights);
#ifdef SURFACE_GRADIENT
surfaceData.tangentWS = normalize(input.worldToTangent[0].xyz); // The tangent is not normalize in worldToTangent when using surface gradient
#else
surfaceData.tangentWS = input.worldToTangent[0].xyz;
#endif
surfaceData.tangentWS = normalize(input.worldToTangent[0].xyz); // The tangent is not normalize in worldToTangent for mikkt. Tag: SURFACE_GRADIENT
// Init other parameters
surfaceData.materialId = 1; // MaterialId.LitStandard
surfaceData.anisotropy = 0;

8
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl


surfaceData.tangentWS = TransformObjectToWorldDir(tangentOS);
#endif
#else
#ifdef SURFACE_GRADIENT
surfaceData.tangentWS = normalize(input.worldToTangent[0].xyz); // The tangent is not normalize in worldToTangent when using surface gradient
#else
surfaceData.tangentWS = input.worldToTangent[0].xyz;
#endif
surfaceData.tangentWS = normalize(input.worldToTangent[0].xyz); // The tangent is not normalize in worldToTangent for mikkt. TODO: Check if it expected that we normalize with Morten. Tag: SURFACE_GRADIENT
#endif
#ifdef _ANISOTROPYMAP

#ifdef _THICKNESSMAP
surfaceData.thickness *= SAMPLE_UVMAPPING_TEXTURE2D(_ThicknessMap, sampler_ThicknessMap, layerTexCoord.base).r;
#endif
surfaceData.thickness = 1 - surfaceData.thickness; // Reverse for artists
surfaceData.specularColor = _SpecularColor.rgb;
#ifdef _SPECULARCOLORMAP

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/CombineSubsurfaceScattering.shader


HLSLPROGRAM
#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go further in dev
#pragma enable_d3d11_debug_symbols
// #pragma enable_d3d11_debug_symbols
#pragma vertex Vert
#pragma fragment Frag

5
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/MaterialUtilities.hlsl


#ifdef SURFACE_GRADIENT
// TOCHECK: seems that we don't need to invert any genBasisTB(), sign cancel. Which is expected as we deal with surface gradient.
// TODO: For surface gradient we must invert or mirror the normal just after the interpolation. It will allow to work with layered with all basis. Currently it is not the case
#endif
#endif
}

#ifdef SURFACE_GRADIENT
normalWS = SurfaceGradientResolveNormal(input.worldToTangent[2], normalTS);
#else
normalWS = TransformTangentToWorld(normalTS, input.worldToTangent);
// We need to normalize as we use mikkt tangent space and this is expected (tangent space is not normalize)
normalWS = normalize(TransformTangentToWorld(normalTS, input.worldToTangent));
#endif
// Orthonormalize the basis vectors using the Gram-Schmidt process.

8
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Unlit.cs.hlsl


#ifndef UNLIT_CS_HLSL
#define UNLIT_CS_HLSL
//
// UnityEngine.Experimental.Rendering.HDPipeline.Unlit.SurfaceData: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Unlit+SurfaceData: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Unlit.BSDFData: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Unlit+BSDFData: static fields
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Unlit.SurfaceData
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Unlit+SurfaceData
// PackingRules = Exact
struct SurfaceData
{

// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Unlit.BSDFData
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Unlit+BSDFData
// PackingRules = Exact
struct BSDFData
{

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/HDRenderPipelineResources.asset


buildPerVoxelLightListShader: {fileID: 7200000, guid: 0bb1b7e0ddcd5c44baf3ddc7456eb196,
type: 3}
shadeOpaqueShader: {fileID: 7200000, guid: 0b64f79746d2daf4198eaf6eab9af259, type: 3}
drawGaussianProfileShader: {fileID: 4800000, guid: 2e8a76823cb2af944b4b45169f2649f9,
type: 3}
drawTransmittanceGraphShader: {fileID: 4800000, guid: 4517edda0467bb14489d5eccc9973ba2,
type: 3}
blitCubemap: {fileID: 4800000, guid: d05913e251bed7a4992c921c62e1b647, type: 3}
buildProbabilityTables: {fileID: 7200000, guid: b9f26cf340afe9145a699753531b2a4c,
type: 3}

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/HDRenderPipelineResources.asset.meta


fileFormatVersion: 2
guid: 42086e81f4f0c724f96f7f09cc995354
timeCreated: 1496162188
timeCreated: 1496931626
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 11400000

129
Assets/ScriptableRenderPipeline/LightweightPipeline/LightweightPipeline.cs


public int shadowResolution;
}
public class LightweightPipeline : RenderPipeline, IComparer<VisibleLight>
public class LightweightPipeline : RenderPipeline
// Max amount of visible lights. This controls the lights constant buffers in shader but not the max shaded lights.
// Lights are set per-object and the max shaded lights for each object are controlled by the max pixel lights in pipeline asset and kMaxVertexLights.
private static readonly int kMaxVisibleLights = 16;
private static readonly int kMaxVertexLights = 4;
private Vector4[] m_LightPositions = new Vector4[kMaxVisibleLights];
private Vector4[] m_LightColors = new Vector4[kMaxVisibleLights];
private Vector4[] m_LightAttenuations = new Vector4[kMaxVisibleLights];
private Vector4[] m_LightSpotDirections = new Vector4[kMaxVisibleLights];
// Amount of light indices buffer set per object.
// TODO: Change cullresults to return amount of renderers so we can allocate/reallocate enough buffer data
// As off now allocating a enough buffer to hold a scene that should enough for a small demo/game
private static readonly int kMaxLightIndices = 1024 * kMaxVisibleLights;
private ComputeBuffer m_LightIndexListBuffer;
private static readonly int kMaxLights = 8;
private static readonly int kMaxVertexLights = 4;
private int m_ShadowLightIndex = -1;
private readonly int[] m_LightTypePriority = new int[4] {2, 1, 2, 0}; // Spot and Point lights have max priority
private int m_ShadowLightIndex = -1;
private static readonly ShaderPassName m_ForwardBasePassName = new ShaderPassName("LightweightForward");
private Vector4[] m_LightPositions = new Vector4[kMaxLights];
private Vector4[] m_LightColors = new Vector4[kMaxLights];
private Vector4[] m_LightAttenuations = new Vector4[kMaxLights];
private Vector4[] m_LightSpotDirections = new Vector4[kMaxLights];
private static readonly ShaderPassName m_ForwardBasePassName = new ShaderPassName("LightweightForward") ;
public LightweightPipeline(LightweightPipelineAsset asset)
{
m_Asset = asset;

m_ShadowMapRTID = new RenderTargetIdentifier(m_ShadowMapProperty);
Shader.globalRenderPipeline = "LightweightPipeline";
// TODO: Change cullresults to return amount of renderers so we can allocate/reallocate enough buffer data
m_LightIndexListBuffer = new ComputeBuffer(kMaxLightIndices, sizeof(uint));
m_LightIndexListBuffer.Dispose();
base.Render(context, cameras);
base.Render(context, cameras);
foreach (Camera camera in cameras)
{

int pixelLightsCount, vertexLightsCount;
GetMaxSupportedLights(visibleLights.Length, out pixelLightsCount, out vertexLightsCount);
SortLights(ref visibleLights, pixelLightsCount);
InitializeMainShadowLightIndex(visibleLights);
if (m_ShadowLightIndex > -1)
shadowsRendered = RenderShadows(cull, visibleLights[m_ShadowLightIndex], context);

cmd.Dispose();
// Setup light and shadow shader constants
cull.FillLightIndices(m_LightIndexListBuffer);
SetupLightShaderVariables(visibleLights, pixelLightsCount, vertexLightsCount, context);
if (shadowsRendered)
SetupShadowShaderVariables(context, m_ShadowCasterCascadesCount);

if (m_Asset.EnableAmbientProbe)
settings.rendererConfiguration |= RendererConfiguration.PerObjectLightProbe;
settings.rendererConfiguration |= RendererConfiguration.ProvideLightIndices;
context.DrawRenderers(ref settings);

private void InitializeLightData()
{
for (int i = 0; i < kMaxLights; ++i)
for (int i = 0; i < kMaxVisibleLights; ++i)
{
m_LightPositions[i] = Vector4.zero;
m_LightColors[i] = Vector4.zero;

private void SetupLightShaderVariables(VisibleLight[] lights, int pixelLightCount, int vertexLightCount, ScriptableRenderContext context)
{
int totalLightCount = pixelLightCount + vertexLightCount;
for (int i = 0; i < totalLightCount; ++i)
int maxLights = Math.Min(kMaxVisibleLights, lights.Length);
for (int i = 0; i < maxLights; ++i)
{
VisibleLight currLight = lights[i];
if (currLight.lightType == LightType.Directional)

}
else
{
m_LightSpotDirections[i] = new Vector4(0.0f, 0.0f, 1.0f, 0.0f);
m_LightSpotDirections[i] = new Vector4(0.0f, 0.0f, 1.0f, 0.0f) ;
m_LightAttenuations[i] = new Vector4(-1.0f, 1.0f, quadAtten, rangeSq);
}
}

cmd.SetGlobalVectorArray("globalLightColor", m_LightColors);
cmd.SetGlobalVectorArray("globalLightAtten", m_LightAttenuations);
cmd.SetGlobalVectorArray("globalLightSpotDir", m_LightSpotDirections);
float shadowMinNormalBias = m_Asset.ShadowMinNormalBias;
float shadowNormalBias = m_Asset.ShadowNormalBias;
cmd.SetGlobalVector("globalLightData", new Vector4(pixelLightCount, totalLightCount, shadowMinNormalBias, shadowNormalBias));
cmd.SetGlobalBuffer("globalLightIndexList", m_LightIndexListBuffer);
cmd.SetGlobalVector("globalLightData", new Vector4(pixelLightCount, m_ShadowLightIndex, m_Asset.ShadowMinNormalBias, m_Asset.ShadowNormalBias));
SetShaderKeywords(cmd, vertexLightCount > 0);
context.ExecuteCommandBuffer(cmd);
cmd.Dispose();

return resolution;
}
void SetupShadowShaderVariables(ScriptableRenderContext context, int cascadeCount)
private void SetupShadowShaderVariables(ScriptableRenderContext context, int cascadeCount)
{
float shadowResolution = m_ShadowSlices[0].shadowResolution;

setupShadow.Dispose();
}
void SetShaderKeywords(CommandBuffer cmd, bool vertexLightSupport)
private void SetShaderKeywords(CommandBuffer cmd, bool vertexLightSupport)
{
if (vertexLightSupport)
cmd.EnableShaderKeyword("_VERTEX_LIGHTS");

cmd.DisableShaderKeyword("_LIGHT_PROBES_ON");
}
// Finds main light and main shadow casters and places them in the beginning of array.
// Sort the remaining array based on custom IComparer criteria.
private void SortLights(ref VisibleLight[] lights, int pixelLightsCount)
private void InitializeMainShadowLightIndex(VisibleLight[] lights)
if (lights.Length == 0)
return;
bool shadowsSupported = m_Asset.CurrShadowType != ShadowType.NO_SHADOW && pixelLightsCount > 0;
int mainLightIndex = -1;
float maxIntensity = -1;
VisibleLight currLight = lights[i];
if (currLight.lightType == LightType.Directional)
if (mainLightIndex == -1 || currLight.light.intensity > lights[mainLightIndex].light.intensity)
mainLightIndex = i;
if (shadowsSupported && (currLight.light.shadows != LightShadows.None) && IsSupportedShadowType(currLight.lightType))
// Prefer directional shadows, if not sort by intensity
if (m_ShadowLightIndex == -1 || currLight.lightType > lights[m_ShadowLightIndex].lightType)
m_ShadowLightIndex = i;
}
// If supports a single directional light only, main light is main shadow light.
if (pixelLightsCount == 1 && m_ShadowLightIndex > -1)
mainLightIndex = m_ShadowLightIndex;
int startIndex = 0;
if (mainLightIndex > -1)
{
SwapLights(ref lights, 0, mainLightIndex);
startIndex++;
}
if (mainLightIndex != m_ShadowLightIndex && m_ShadowLightIndex > 0)
{
SwapLights(ref lights, 1, m_ShadowLightIndex);
m_ShadowLightIndex = 1;
startIndex++;
Light light = lights[i].light;
if (light.shadows != LightShadows.None && IsSupportedShadowType(light.type) && light.intensity > maxIntensity)
{
m_ShadowLightIndex = i;
maxIntensity = light.intensity;
}
Array.Sort(lights, startIndex, lights.Length - startIndex, this);
}
private bool IsSupportedShadowType(LightType type)

private void SwapLights(ref VisibleLight[] lights, int lhsIndex, int rhsIndex)
{
if (lhsIndex == rhsIndex)
return;
VisibleLight temp = lights[lhsIndex];
lights[lhsIndex] = lights[rhsIndex];
lights[rhsIndex] = temp;
}
// Prioritizes Spot and Point lights by intensity. If any directional light, it will be the main
// light and will not be considered in the computation.
// TODO: Move to a better sorting solution, e.g, prioritize lights per object.
public int Compare(VisibleLight lhs, VisibleLight rhs)
{
int lhsLightTypePriority = m_LightTypePriority[(int)lhs.lightType];
int rhsLightTypePriority = m_LightTypePriority[(int)rhs.lightType];
if (lhsLightTypePriority != rhsLightTypePriority)
return rhsLightTypePriority - lhsLightTypePriority;
return (int)(rhs.light.intensity - lhs.light.intensity);
}
}
}

2
Assets/ScriptableRenderPipeline/LightweightPipeline/LightweightPipelineAsset.asset


m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3}
m_Name: LightweightPipelineAsset
m_EditorClassIdentifier:
m_MaxPixelLights: 1
m_MaxPixelLights: 4
m_SupportsVertexLight: 1
m_EnableLightmaps: 1
m_EnableAmbientProbe: 1

15
Assets/ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPipeline.shader


#if defined(_VERTEX_LIGHTS)
half4 diffuseAndSpecular = half4(1.0, 1.0, 1.0, 1.0);
for (int lightIndex = globalLightData.x; lightIndex < globalLightData.y; ++lightIndex)
int vertexLightStart = unity_LightIndicesOffsetAndCount.x + globalLightData.x;
int vertexLightEnd = vertexLightStart + (unity_LightIndicesOffsetAndCount.y - globalLightData.x);
for (int lightIter = vertexLightStart; lightIter < vertexLightEnd; ++lightIter)
int lightIndex = globalLightIndexList[lightIter];
LightInput lightInput;
half NdotL;
INITIALIZE_LIGHT(lightInput, lightIndex);

half3 viewDir = i.viewDir.xyz;
// TODO: Restrict pixel lights by 4. This way we can keep moderate constrain for most LD project
// and can benefit from better data layout/avoid branching by doing vec math.
for (int lightIndex = 0; lightIndex < globalLightData.x; ++lightIndex)
int pixelLightEnd = unity_LightIndicesOffsetAndCount.x + min(globalLightData.x, unity_LightIndicesOffsetAndCount.y);
for (int lightIter = unity_LightIndicesOffsetAndCount.x; lightIter < pixelLightEnd; ++lightIter)
LightInput lightData;
int lightIndex = globalLightIndexList[lightIter];
LightInput lightData;
if (lightIndex == 0)
if (lightIndex == globalLightData.y)
{
#if _NORMALMAP
float3 vertexNormal = float3(i.tangentToWorld0.z, i.tangentToWorld1.z, i.tangentToWorld2.z);

16
Assets/ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPipelineCore.cginc


#define MAX_LIGHTS 8
#define MAX_VISIBLE_LIGHTS 16
#define INITIALIZE_LIGHT(light, lightIndex) \
light.pos = globalLightPos[lightIndex]; \

// The variables are very similar to built-in unity_LightColor, unity_LightPosition,
// unity_LightAtten, unity_SpotDirection as used by the VertexLit shaders, except here
// we use world space positions instead of view space.
half4 globalLightColor[MAX_LIGHTS];
float4 globalLightPos[MAX_LIGHTS];
half4 globalLightSpotDir[MAX_LIGHTS];
half4 globalLightAtten[MAX_LIGHTS];
float4 globalLightData; // x: pixelLightCount, y = totalLightCount (pixel + vert), z = minShadowNormalBiasOffset, w = shadowNormalBiasOffset
half4 globalLightColor[MAX_VISIBLE_LIGHTS];
float4 globalLightPos[MAX_VISIBLE_LIGHTS];
half4 globalLightSpotDir[MAX_VISIBLE_LIGHTS];
half4 globalLightAtten[MAX_VISIBLE_LIGHTS];
float4 globalLightData; // x: pixelLightCount, y = shadowLightIndex, z = minShadowNormalBiasOffset, w = shadowNormalBiasOffset
// Per object light list data
half4 unity_LightIndicesOffsetAndCount;
StructuredBuffer<uint> globalLightIndexList;
half _Shininess;
samplerCUBE _Cube;

20
Assets/ScriptableRenderPipeline/ShaderGenerator/Editor/CSharpToHLSL.cs


{
if (attr is GenerateHLSL)
{
var parent = type.DeclaringType;
if (parent != null)
ShaderTypeGenerator gen;
if (s_TypeName.TryGetValue(type.FullName, out gen))
Debug.LogError("The GenerateHLSL attribute not supported on nested classes (" + type.FullName + "), skipping.");
}
else
{
ShaderTypeGenerator gen;
if (s_TypeName.TryGetValue(type.FullName, out gen))
{
Debug.LogError("Duplicate typename with the GenerateHLSL attribute detected: " + type.FullName +
" declared in both " + gen.type.Assembly.FullName + " and " + type.Assembly.FullName + ". Skipping the second instance.");
}
s_TypeName[type.FullName] = new ShaderTypeGenerator(type, attr as GenerateHLSL);
Debug.LogError( "Duplicate typename with the GenerateHLSL attribute detected: " + type.FullName +
" declared in both " + gen.type.Assembly.FullName + " and " + type.Assembly.FullName + ". Skipping the second instance.");
s_TypeName[type.FullName] = new ShaderTypeGenerator(type, attr as GenerateHLSL);
}
}
}

{
writer.Write(gen.EmitFunctions() + "\n");
}
}
}
writer.Write("\n#endif\n");

30
Assets/ScriptableRenderPipeline/ShaderGenerator/Editor/ShaderTypeGeneration.cs


public string fieldName;
public Type fieldType;
public bool isDirection;
public bool isSRGB;
public bool isSRGB;
}
void Error(string error)

if (!attr.needParamDebug)
return shaderText;
// Specific to HDRenderPipeline
// Specific to HDRenderPipeline
string lowerStructName = type.Name.ToLower();
shaderText += "//\n";

{
shaderText += " result = " + lowerStructName + "." + debugField.fieldName + ".xxx * 0.5 + 0.5;\n";
}
else
else
{
shaderText += " result = " + lowerStructName + "." + debugField.fieldName + ".xxx;\n";
}

{
shaderText += " result = " + lowerStructName + "." + debugField.fieldName + " * 0.5 + 0.5;\n";
}
else
else
}
}
}
else if (debugField.fieldType == typeof(Vector4))
{

}
else // This case left is suppose to be a complex structure. Either we don't support it or it is an enum. Consider it is an enum with GetIndexColor, user can override it if he want.
{
shaderText += " result = GetIndexColor(" + lowerStructName + "." + debugField.fieldName + ");\n";
shaderText += " result = GetIndexColor(" + lowerStructName + "." + debugField.fieldName + ");\n";
if (debugField.isSRGB)
{
shaderText += " needLinearToSRGB = true;\n";

}
shaderText += " }\n";
shaderText += "}\n";
shaderText += "}\n";
return shaderText;
}

{
if (field.FieldType.IsPrimitive)
{
m_Statics[field.Name] = field.GetValue(null).ToString();
// Unity convention is to start static of constant with k_ or s_, remove this part
string name = InsertUnderscore(field.Name);
if (name.StartsWith("k_") || name.StartsWith("s_"))
{
name = name.Substring(2);
}
string defineName = name.ToUpper();
m_Statics[defineName] = field.GetValue(null).ToString();
}
continue;
}

string subNamespace = type.Namespace.Substring(type.Namespace.LastIndexOf((".")) + 1);
string className = type.FullName.Substring(type.FullName.LastIndexOf((".")) + 1); // ClassName include nested class
className = className.Replace('+', '_'); // FullName is Class+NestedClass replace by Class_NestedClass
string defineName = ("DEBUGVIEW_" + subNamespace + "_" + type.Name + "_" + name).ToUpper();
string defineName = ("DEBUGVIEW_" + className + "_" + name).ToUpper();
m_Statics[defineName] = Convert.ToString(attr.paramDefinesStart + debugCounter++);
bool isDirection = false;

38
ProjectSettings/ProjectSettings.asset


--- !u!129 &1
PlayerSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
serializedVersion: 12
productGUID: 900e9e40d20cd3e44ad40e5b00239dcc
AndroidProfiler: 0
defaultScreenOrientation: 4

m_StereoRenderingPath: 0
m_ActiveColorSpace: 1
m_MTRendering: 1
m_MobileMTRendering: 0
m_StackTraceTypes: 010000000100000001000000010000000100000001000000
iosShowActivityIndicatorOnLoading: -1
androidShowActivityIndicatorOnLoading: -1

xboxOneResolution: 0
xboxOneMonoLoggingLevel: 0
xboxOneLoggingLevel: 1
xboxOneDisableEsram: 0
xboxOnePresentImmediateThreshold: 0
videoMemoryForVertexBuffers: 0
psp2PowerMode: 0
psp2AcquireBGM: 1

daydream:
depthFormat: 0
useSustainedPerformanceMode: 0
enableVideoLayer: 0
useProtectedVideoMemory: 0
m_ColorGamuts: 00000000
targetPixelDensity: 0
resolutionScalingMode: 0
applicationIdentifier:

AndroidKeyaliasName:
AndroidTVCompatibility: 1
AndroidIsGame: 1
AndroidEnableTango: 0
androidEnableBanner: 1
m_AndroidBanners:
- width: 320

m_DynamicBatching: 0
m_BuildTargetGraphicsAPIs:
- m_BuildTarget: WindowsStandaloneSupport
m_APIs: 0200000001000000
m_Automatic: 1
m_APIs: 02000000
m_Automatic: 0
- m_BuildTarget: MacStandaloneSupport
m_APIs: 1000000011000000
m_Automatic: 1

openGLRequireES31AEP: 0
webPlayerTemplate: APPLICATION:Default
m_TemplateCustomTags: {}
mobileMTRendering:
iPhone: 1
tvOS: 1
wiiUTitleID: 0005000011000000
wiiUGroupID: 00010000
wiiUCommonSaveSize: 4096

switchTitleNames_9:
switchTitleNames_10:
switchTitleNames_11:
switchTitleNames_12:
switchTitleNames_13:
switchTitleNames_14:
switchPublisherNames_0:
switchPublisherNames_1:
switchPublisherNames_2:

switchPublisherNames_9:
switchPublisherNames_10:
switchPublisherNames_11:
switchPublisherNames_12:
switchPublisherNames_13:
switchPublisherNames_14:
switchIcons_0: {fileID: 0}
switchIcons_1: {fileID: 0}
switchIcons_2: {fileID: 0}

switchIcons_9: {fileID: 0}
switchIcons_10: {fileID: 0}
switchIcons_11: {fileID: 0}
switchIcons_12: {fileID: 0}
switchIcons_13: {fileID: 0}
switchIcons_14: {fileID: 0}
switchSmallIcons_0: {fileID: 0}
switchSmallIcons_1: {fileID: 0}
switchSmallIcons_2: {fileID: 0}

switchSmallIcons_9: {fileID: 0}
switchSmallIcons_10: {fileID: 0}
switchSmallIcons_11: {fileID: 0}
switchSmallIcons_12: {fileID: 0}
switchSmallIcons_13: {fileID: 0}
switchSmallIcons_14: {fileID: 0}
switchManualHTML:
switchAccessibleURLs:
switchLegalInformation:

switchApplicationErrorCodeCategory:
switchUserAccountSaveDataSize: 0
switchUserAccountSaveDataJournalSize: 0
switchAttribute: 0
switchApplicationAttribute: 0
switchCardSpecSize: 4
switchCardSpecClock: 25
switchRatingsMask: 0

switchAllowsScreenshot: 1
switchDataLossConfirmation: 0
switchSupportedNpadStyles: 3
switchSocketConfigEnabled: 0
switchTcpInitialSendBufferSize: 32
switchTcpInitialReceiveBufferSize: 64
switchTcpAutoSendBufferSizeMax: 256
switchTcpAutoReceiveBufferSizeMax: 256
switchUdpSendBufferSize: 9
switchUdpReceiveBufferSize: 42
switchSocketBufferEfficiency: 4
ps4NPAgeRating: 12
ps4NPTitleSecret:
ps4NPTrophyPackPath:

2
ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2017.2.0a2
m_EditorVersion: 2017.2.0a3

1001
Assets/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/MultiplePointLights.unity
文件差异内容过多而无法显示
查看文件

8
Assets/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/MultiplePointLights.unity.meta


fileFormatVersion: 2
guid: 6a5fa7fc4cfca8b46bec48a8d2ff1ce5
timeCreated: 1496824103
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

897
ImageTemplates/LightweightPipeline/Scenes/MultiplePointLights.unity.png

之前 之后
宽度: 1280  |  高度: 720  |  大小: 304 KiB
正在加载...
取消
保存