浏览代码

Merge remote-tracking branch 'origin/master' into HDRP_GraphicTests

/main
Remy 7 年前
当前提交
dd1d4224
共有 40 个文件被更改,包括 375 次插入175 次删除
  1. 1
      ScriptableRenderPipeline/Core/CoreRP/CoreUtils.cs
  2. 2
      ScriptableRenderPipeline/Core/CoreRP/Editor/Debugging/DebugMenuEditor.cs
  3. 2
      ScriptableRenderPipeline/Core/CoreRP/Editor/ShaderGenerator/ShaderGeneratorMenu.cs
  4. 14
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Color.hlsl
  5. 5
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Common.hlsl
  6. 48
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/CommonLighting.hlsl
  7. 22
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Debug.hlsl
  8. 21
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.hlsl
  9. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalProjectorComponent.cs
  10. 66
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalSystem.cs
  11. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Decal/DecalMenuItems.cs
  12. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDAssetFactory.cs
  13. 13
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDRenderPipelineMenuItems.cs
  14. 20
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Handles.cs
  15. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Decal/DecalProjectorComponentEditor.cs
  16. 10
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/RenderPipelineSettingsUI.cs
  17. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedRenderPipelineSettings.cs
  18. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/UpgradeStandardShaderMaterials.cs
  19. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipelineAsset.asset
  20. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/DeferredDirectionalShadow.compute
  21. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs
  22. 20
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoopDef.hlsl
  23. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.cs
  24. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.cs.hlsl
  25. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.hlsl
  26. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DecalData.hlsl
  27. 41
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl
  28. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipeline/RenderPipelineSettings.cs
  29. 14
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderPass/ShaderPassDBuffer.hlsl
  30. 10
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineAsset.cs
  31. 4
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/LightweightMaterialUpgrader.cs
  32. 2
      TestbedPipelines/BasicRenderPipeline/BasicRenderPipeline.cs
  33. 3
      TestbedPipelines/Fptl/FptlLighting.cs
  34. 68
      TestbedPipelines/OnTileDeferredPipeline/OnTileDeferredRenderPipeline.cs
  35. 17
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/GlobalDecalSettings.cs
  36. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/GlobalDecalSettings.cs.meta
  37. 32
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/GlobalDecalSettingsUI.cs
  38. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/GlobalDecalSettingsUI.cs.meta
  39. 20
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedGlobalDecalSettings.cs
  40. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedGlobalDecalSettings.cs.meta

1
ScriptableRenderPipeline/Core/CoreRP/CoreUtils.cs


public const int editMenuPriority1 = 320;
public const int editMenuPriority2 = 331;
public const int editMenuPriority3 = 342;
public const int assetCreateMenuPriority1 = 230;
public const int assetCreateMenuPriority2 = 241;
public const int gameObjectMenuPriority = 10;

2
ScriptableRenderPipeline/Core/CoreRP/Editor/Debugging/DebugMenuEditor.cs


[SerializeField]
private DebugMenuState m_DebugMenuState;
[MenuItem("Edit/Render Pipeline/Tools/High Definition/Debug Window", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Window/Render Pipeline/Debug Window", priority = CoreUtils.editMenuPriority2)]
static void DisplayDebugMenu()
{
var window = EditorWindow.GetWindow<DebugMenuEditor>("Debug Window");

2
ScriptableRenderPipeline/Core/CoreRP/Editor/ShaderGenerator/ShaderGeneratorMenu.cs


{
public class ShaderGeneratorMenu
{
[UnityEditor.MenuItem("Edit/Render Pipeline/Tools/Generate Shader Includes", priority = CoreUtils.editMenuPriority1)]
[UnityEditor.MenuItem("Edit/Render Pipeline/Generate Shader Includes", priority = CoreUtils.editMenuPriority1)]
static void GenerateShaderIncludes()
{
CSharpToHLSL.GenerateAll();

14
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Color.hlsl


// Gamma22
real Gamma22ToLinear(real c)
{
return pow(c, 2.2);
return PositivePow(c, 2.2);
return pow(c.rgb, real3(2.2, 2.2, 2.2));
return PositivePow(c.rgb, real3(2.2, 2.2, 2.2));
}
real4 Gamma22ToLinear(real4 c)

real LinearToGamma22(real c)
{
return pow(c, 0.454545454545455);
return PositivePow(c, 0.454545454545455);
return pow(c.rgb, real3(0.454545454545455, 0.454545454545455, 0.454545454545455));
return PositivePow(c.rgb, real3(0.454545454545455, 0.454545454545455, 0.454545454545455));
}
real4 LinearToGamma22(real4 c)

real3 SRGBToLinear(real3 c)
{
real3 linearRGBLo = c / 12.92;
real3 linearRGBHi = pow((c + 0.055) / 1.055, real3(2.4, 2.4, 2.4));
real3 linearRGBHi = PositivePow((c + 0.055) / 1.055, real3(2.4, 2.4, 2.4));
real3 linearRGB = (c <= 0.04045) ? linearRGBLo : linearRGBHi;
return linearRGB;
}

real3 LinearToSRGB(real3 c)
{
real3 sRGBLo = c * 12.92;
real3 sRGBHi = (pow(c, real3(1.0/2.4, 1.0/2.4, 1.0/2.4)) * 1.055) - 0.055;
real3 sRGBHi = (PositivePow(c, real3(1.0/2.4, 1.0/2.4, 1.0/2.4)) * 1.055) - 0.055;
real3 sRGB = (c <= 0.0031308) ? sRGBLo : sRGBHi;
return sRGB;
}

real3 FastLinearToSRGB(real3 c)
{
return saturate(1.055 * pow(abs(c), 0.416666667) - 0.055);
return saturate(1.055 * PositivePow(c, 0.416666667) - 0.055);
}
real4 FastLinearToSRGB(real4 c)

5
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Common.hlsl


// Using pow often result to a warning like this
// "pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them"
// PositivePow remove this warning when you know the value is positive and avoid inf/NAN.
TEMPLATE_2_REAL(PositivePow, base, power, return pow(max(abs(base), FLT_EPS), power))
// PositivePow remove this warning when you know the value is positive or 0 and avoid inf/NAN.
// Note: https://msdn.microsoft.com/en-us/library/windows/desktop/bb509636(v=vs.85).aspx pow(0, >0) == 0
TEMPLATE_2_REAL(PositivePow, base, power, return pow(abs(base), power))
// Composes a floating point value with the magnitude of 'x' and the sign of 's'.
// See the comment about FastSign() below.

48
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/CommonLighting.hlsl


//-----------------------------------------------------------------------------
// Ref: Moving Frostbite to PBR.
real QuadraticAttenuation(real attenuation)
{
return attenuation * attenuation;
}
real DistanceAttenuation(real squaredDistance, real invSqrAttenuationRadius)
// SmoothInfluenceAttenuation must be use, InfluenceAttenuation is just for optimization with SmoothQuadraticDistanceAttenuation
real InfluenceAttenuation(real distSquare, real invSqrAttenuationRadius)
real factor = squaredDistance * invSqrAttenuationRadius;
real factor = distSquare * invSqrAttenuationRadius;
real SmoothDistanceAttenuation(real squaredDistance, real invSqrAttenuationRadius)
real SmoothInfluenceAttenuation(real distSquare, real invSqrAttenuationRadius)
real smoothFactor = DistanceAttenuation(squaredDistance, invSqrAttenuationRadius);
return QuadraticAttenuation(smoothFactor);
real smoothFactor = InfluenceAttenuation(distSquare, invSqrAttenuationRadius);
return Sq(smoothFactor);
real SmoothQuadraticDistanceAttenuation(real distSq, real distRcp, real invSqrAttenuationRadius)
// Return physically based quadratic attenuation + influence limit to reach 0 at attenuationRadius
real SmoothQuadraticDistanceAttenuation(real distSquare, real distRcp, real invSqrAttenuationRadius)
// Becomes quadratic after the call to QuadraticAttenuation().
// Becomes quadratic after the call to Sq().
attenuation *= DistanceAttenuation(distSq, invSqrAttenuationRadius);
return QuadraticAttenuation(attenuation);
attenuation *= InfluenceAttenuation(distSquare, invSqrAttenuationRadius);
return Sq(attenuation);
real distSq = dot(unL, unL);
real distRcp = rsqrt(distSq);
return SmoothQuadraticDistanceAttenuation(distSq, distRcp, invSqrAttenuationRadius);
real distSquare = dot(unL, unL);
real distRcp = rsqrt(distSquare);
return SmoothQuadraticDistanceAttenuation(distSquare, distRcp, invSqrAttenuationRadius);
}
real AngleAttenuation(real cosFwd, real lightAngleScale, real lightAngleOffset)

real SmoothAngleAttenuation(real cosFwd, real lightAngleScale, real lightAngleOffset)
{
real attenuation = AngleAttenuation(cosFwd, lightAngleScale, lightAngleOffset);
return QuadraticAttenuation(attenuation);
return Sq(attenuation);
}
real SmoothAngleAttenuation(real3 L, real3 lightFwdDir, real lightAngleScale, real lightAngleOffset)

real cosFwd = distProj * distRcp;
real attenuation = min(distRcp, 1.0 / PUNCTUAL_LIGHT_THRESHOLD);
attenuation *= DistanceAttenuation(distSq, invSqrAttenuationRadius);
attenuation *= InfluenceAttenuation(distSq, invSqrAttenuationRadius);
return QuadraticAttenuation(attenuation);
return Sq(attenuation);
// Applies SmoothDistanceAttenuation() after transforming the attenuation ellipsoid into a sphere.
// Applies SmoothInfluenceAttenuation() after transforming the attenuation ellipsoid into a sphere.
// If r = rsqrt(invSqRadius), then the ellipsoid is defined s.t. r1 = r / invAspectRatio, r2 = r3 = r.
// The transformation is performed along the major axis of the ellipsoid (corresponding to 'r1').
// Both the ellipsoid (e.i. 'axis') and 'unL' should be in the same coordinate system.

unL -= diff * axis;
real sqDist = dot(unL, unL);
return SmoothDistanceAttenuation(sqDist, invSqRadius);
return SmoothInfluenceAttenuation(sqDist, invSqRadius);
// Applies SmoothDistanceAttenuation() using the axis-aligned ellipsoid of the given dimensions.
// Applies SmoothInfluenceAttenuation() using the axis-aligned ellipsoid of the given dimensions.
// Both the ellipsoid and 'unL' should be in the same coordinate system.
// 'unL' should be computed from the center of the ellipsoid.
real EllipsoidalDistanceAttenuation(real3 unL, real3 invHalfDim)

unL *= invHalfDim;
real sqDist = dot(unL, unL);
return SmoothDistanceAttenuation(sqDist, 1.0);
return SmoothInfluenceAttenuation(sqDist, 1.0);
// Applies SmoothDistanceAttenuation() after mapping the axis-aligned box to a sphere.
// Applies SmoothInfluenceAttenuation() after mapping the axis-aligned box to a sphere.
// If the diagonal of the box is 'd', invHalfDim = rcp(0.5 * d).
// Both the box and 'unL' should be in the same coordinate system.
// 'unL' should be computed from the center of the box.

if (Max3(abs(unL.x), abs(unL.y), abs(unL.z)) > 1.0) return 0.0;
real sqDist = ComputeCubeToSphereMapSqMagnitude(unL);
return SmoothDistanceAttenuation(sqDist, 1.0);
return SmoothInfluenceAttenuation(sqDist, 1.0);
}
//-----------------------------------------------------------------------------

22
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Debug.hlsl


}
return GetDebugMipColor(originalColor, tex, texelSize, uv);
}
// mipInfo :
// x = quality setings minStreamingMipLevel
// y = original mip count for texture
// z = desired on screen mip level
// w = 0
float3 GetDebugMipReductionColor(Texture2D tex, float4 mipInfo)
{
float3 outColor = float3(1.0, 0.0, 1.0); // Can't calculate without original mip count - return magenta
float3 GetDebugMipReductionColor(Texture2D tex, float4 mipInfo)
{
// mipInfo :
// x = quality setings minStreamingMipLevel
// y = original mip count for texture
// z = desired on screen mip level
// w = 0
return float3(0, mipCol, 0);
outColor = float3(0, mipCol, 0);
// Can't calculate without original mip count - return magenta
return float3(1.0, 0.0, 1.0);
return outColor;
}
// Convert an arbitrary range to color base on threshold provide to the function, threshold must be in growing order

21
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.hlsl


float3 GetTextureDataDebug(uint paramId, float2 uv, Texture2D tex, float4 texelSize, float4 mipInfo, float3 originalColor)
{
float3 outColor = originalColor;
return GetDebugMipColorIncludingMipReduction(originalColor, tex, texelSize, uv, mipInfo);
outColor = GetDebugMipColorIncludingMipReduction(originalColor, tex, texelSize, uv, mipInfo);
break;
return GetDebugMipCountColor(originalColor, tex);
outColor = GetDebugMipCountColor(originalColor, tex);
break;
return GetDebugMipReductionColor(tex, mipInfo);
outColor = GetDebugMipReductionColor(tex, mipInfo);
break;
return GetDebugStreamingMipColor(tex, mipInfo);
outColor = GetDebugStreamingMipColor(tex, mipInfo);
break;
return GetDebugStreamingMipColorBlended(originalColor, tex, mipInfo);
outColor = GetDebugStreamingMipColorBlended(originalColor, tex, mipInfo);
break;
return originalColor;
return outColor;
}
// DebugFont code assume black and white font with texture size 256x128 with bloc of 16x16

{
const uint maxStringSize = 16;
int absIntValue = abs(intValue);
uint absIntValue = abs(intValue);
// 1. Get size of the number of display
int numEntries = min((intValue == 0 ? 0 : log10(absIntValue)) + (intValue < 0 ? 1 : 0), maxStringSize);

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalProjectorComponent.cs


public class DecalProjectorComponent : MonoBehaviour
{
public Material m_Material = null;
public float m_DrawDistance = 1000.0f;
public float m_FadeScale = 0.9f;
private Material m_OldMaterial = null;
public const int kInvalidIndex = -1;
private int m_CullIndex = kInvalidIndex;

{
DrawGizmo(true);
// if this object is selected there is a chance the transform was changed so update culling info
DecalSystem.instance.UpdateBoundingSphere(this);
DecalSystem.instance.UpdateCachedData(this);
}
public void OnDrawGizmos()

66
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalSystem.cs


}
}
private const int kDefaultDrawDistance = 1000;
static public int DrawDistance
{
get
{
HDRenderPipelineAsset hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;
if (hdrp != null)
{
return hdrp.renderPipelineSettings.decalSettings.drawDistance;
}
return kDefaultDrawDistance;
}
}
private static readonly int m_NormalToWorldID = Shader.PropertyToID("normalToWorld");
private static MaterialPropertyBlock m_PropertyBlock = new MaterialPropertyBlock();

static public Mesh m_DecalMesh = null;
static public Matrix4x4[] m_InstanceMatrices = new Matrix4x4[kDrawIndexedBatchSize];
static public Matrix4x4[] m_InstanceNormalToWorld = new Matrix4x4[kDrawIndexedBatchSize];
static public float[] m_BoundingDistances = new float[1];
private Dictionary<int, DecalSet> m_DecalSets = new Dictionary<int, DecalSet>();

return res;
}
public void UpdateBoundingSphere(DecalProjectorComponent decal)
public void UpdateCachedData(DecalProjectorComponent decal)
{
m_CachedTransforms[decal.CullIndex] = decal.transform.localToWorldMatrix;

decalRotation.m22 = y2;
m_CachedNormalToWorld[decal.CullIndex] = decalRotation;
// draw distance can't be more than global draw distance
m_CachedDrawDistances[decal.CullIndex].x = decal.m_DrawDistance < DrawDistance ? decal.m_DrawDistance : DrawDistance;
m_CachedDrawDistances[decal.CullIndex].y = decal.m_FadeScale;
m_BoundingSpheres[decal.CullIndex] = GetDecalProjectBoundingSphere(m_CachedTransforms[decal.CullIndex]);
}

BoundingSphere[] newSpheres = new BoundingSphere[m_DecalsCount + kDecalBlockSize];
Matrix4x4[] newCachedTransforms = new Matrix4x4[m_DecalsCount + kDecalBlockSize];
Matrix4x4[] newCachedNormalToWorld = new Matrix4x4[m_DecalsCount + kDecalBlockSize];
Vector2[] newCachedDrawDistances = new Vector2[m_DecalsCount + kDecalBlockSize];
m_ResultIndices = new int[m_DecalsCount + kDecalBlockSize];
m_Decals.CopyTo(newDecals, 0);

m_CachedDrawDistances.CopyTo(newCachedDrawDistances, 0);
m_CachedDrawDistances = newCachedDrawDistances;
UpdateBoundingSphere(m_Decals[m_DecalsCount]);
UpdateCachedData(m_Decals[m_DecalsCount]);
m_DecalsCount++;
}

m_BoundingSpheres[removeAtIndex] = m_BoundingSpheres[m_DecalsCount - 1];
m_CachedTransforms[removeAtIndex] = m_CachedTransforms[m_DecalsCount - 1];
m_CachedNormalToWorld[removeAtIndex] = m_CachedNormalToWorld[m_DecalsCount - 1];
m_CachedDrawDistances[removeAtIndex] = m_CachedDrawDistances[m_DecalsCount - 1];
m_DecalsCount--;
decal.CullIndex = DecalProjectorComponent.kInvalidIndex;
}

{
Debug.LogError("Begin/EndCull() called out of sequence for decal projectors.");
}
// let the culling group code do some of the heavy lifting for global draw distance
m_BoundingDistances[0] = DrawDistance;
m_CullingGroup.SetDistanceReferencePoint(camera.transform.position);
m_CullingGroup.SetBoundingDistances(m_BoundingDistances);
m_CullingGroup.SetBoundingSpheres(m_BoundingSpheres);
m_CullingGroup.SetBoundingSphereCount(m_DecalsCount);
}

public void Render(ScriptableRenderContext renderContext, HDCamera camera, CommandBuffer cmd)
{
int instanceCount = 0;
Vector3 cameraPos = camera.cameraPos;
m_InstanceMatrices[instanceCount] = m_CachedTransforms[decalIndex];
m_InstanceNormalToWorld[instanceCount] = m_CachedNormalToWorld[decalIndex];
instanceCount++;
if (instanceCount == kDrawIndexedBatchSize)
{
m_PropertyBlock.SetMatrixArray(m_NormalToWorldID, m_InstanceNormalToWorld);
cmd.DrawMeshInstanced(m_DecalMesh, 0, KeyMaterial, 0, m_InstanceMatrices, kDrawIndexedBatchSize, m_PropertyBlock);
instanceCount = 0;
}
// do additional culling based on individual decal draw distances
float distanceToDecal = (cameraPos - m_BoundingSpheres[decalIndex].position).magnitude;
float cullDistance = m_CachedDrawDistances[decalIndex].x + m_BoundingSpheres[decalIndex].radius;
if (distanceToDecal < cullDistance)
{
m_InstanceMatrices[instanceCount] = m_CachedTransforms[decalIndex];
m_InstanceNormalToWorld[instanceCount] = m_CachedNormalToWorld[decalIndex];
float fadeFactor = (cullDistance - distanceToDecal) / (cullDistance * (1.0f - m_CachedDrawDistances[decalIndex].y));
m_InstanceNormalToWorld[instanceCount].m03 = fadeFactor; // rotation only matrix so 3rd column can be used to pass some values
instanceCount++;
if (instanceCount == kDrawIndexedBatchSize)
{
m_PropertyBlock.SetMatrixArray(m_NormalToWorldID, m_InstanceNormalToWorld);
cmd.DrawMeshInstanced(m_DecalMesh, 0, KeyMaterial, 0, m_InstanceMatrices, kDrawIndexedBatchSize, m_PropertyBlock);
instanceCount = 0;
}
}
}
if (instanceCount > 0)
{

private int m_DecalsCount = 0;
private Matrix4x4[] m_CachedTransforms = new Matrix4x4[kDecalBlockSize];
private Matrix4x4[] m_CachedNormalToWorld = new Matrix4x4[kDecalBlockSize];
private Vector2[] m_CachedDrawDistances = new Vector2[kDecalBlockSize]; // x - draw distance, y - fade scale
private Material m_Material;
}

}
}
public void UpdateBoundingSphere(DecalProjectorComponent decal)
public void UpdateCachedData(DecalProjectorComponent decal)
{
if (decal.CullIndex == DecalProjectorComponent.kInvalidIndex) // check if we have this decal
return;

if (m_DecalSets.TryGetValue(key, out decalSet))
{
decalSet.UpdateBoundingSphere(decal);
decalSet.UpdateCachedData(decal);
}
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Decal/DecalMenuItems.cs


{
public class DecalMenuItems
{
[MenuItem("GameObject/Render Pipeline/High Definition/DecalProjector", priority = CoreUtils.gameObjectMenuPriority)]
[MenuItem("GameObject/Graphics/DecalProjector", priority = CoreUtils.gameObjectMenuPriority)]
static void CreateDecal(MenuCommand menuCommand)
{
// Create a custom game object

5
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDAssetFactory.cs


}
}
[MenuItem("Assets/Create/Render Pipeline/High Definition/Render Pipeline", priority = CoreUtils.assetCreateMenuPriority1)]
[MenuItem("Assets/Create/Graphics/High Definition Render Pipeline Asset", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateHDRenderPipeline()
{
var icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");

// Load default renderPipelineResources / Material / Shader
string HDRenderPipelinePath = HDEditorUtils.GetHDRenderPipelinePath();
string PostProcessingPath = HDEditorUtils.GetPostProcessingPath();
string CorePath = HDEditorUtils.GetCorePath();
newAsset.defaultDiffuseMaterial = Load<Material>(HDRenderPipelinePath + "RenderPipelineResources/DefaultHDMaterial.mat");

}
}
[MenuItem("Assets/Create/Render Pipeline/High Definition/Render Pipeline Resources", priority = CoreUtils.assetCreateMenuPriority1)]
[MenuItem("Assets/Create/Graphics/High Definition Render Pipeline Resources", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateRenderPipelineResources()
{
var icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");

13
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDRenderPipelineMenuItems.cs


// In case the shader code have change and the inspector have been update with new kind of keywords we need to regenerate the set of keywords use by the material.
// This script will remove all keyword of a material and trigger the inspector that will re-setup all the used keywords.
// It require that the inspector of the material have a static function call that update all keyword based on material properties.
[MenuItem("Edit/Render Pipeline/Upgrade/High Definition/Reset All Materials Keywords (Loaded Materials)", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Reset All Loaded High Definition Materials Keywords", priority = CoreUtils.editMenuPriority3)]
static void ResetAllMaterialKeywords()
{
try

}
}
[MenuItem("Edit/Render Pipeline/Upgrade/High Definition/Reset All Material Asset's Keywords (Materials in Project)", priority = CoreUtils.editMenuPriority2)]
// Don't expose, ResetAllMaterialKeywordsInProjectAndScenes include it anyway
//[MenuItem("Edit/Render Pipeline/Reset All Material Asset's Keywords (Materials in Project)", priority = CoreUtils.editMenuPriority3)]
static void ResetAllMaterialAssetsKeywords()
{
try

}
}
[MenuItem("Edit/Render Pipeline/Upgrade/High Definition/Reset All Materials Keywords (Materials in Project and scenes)", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Reset All Project and Scene High Definition Materials Keywords", priority = CoreUtils.editMenuPriority3)]
static void ResetAllMaterialKeywordsInProjectAndScenes()
{
var openedScenes = new string[EditorSceneManager.loadedSceneCount];

}
}
[MenuItem("Edit/Render Pipeline/Tools/High Definition/Export Sky to Image", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Export Sky to Image", priority = CoreUtils.editMenuPriority3)]
static void ExportSkyToImage()
{
var renderpipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline;

}
}
[MenuItem("GameObject/Render Pipeline/High Definition/Scene Settings", priority = CoreUtils.gameObjectMenuPriority)]
[MenuItem("GameObject/Graphics/Scene Settings", priority = CoreUtils.gameObjectMenuPriority)]
static void CreateCustomGameObject(MenuCommand menuCommand)
{
var sceneSettings = new GameObject("Scene Settings");

class DoCreateNewAssetDiffusionProfileSettings : DoCreateNewAsset<DiffusionProfileSettings> {}
[MenuItem("Assets/Create/Render Pipeline/High Definition/Diffusion profile Settings", priority = CoreUtils.assetCreateMenuPriority2)]
[MenuItem("Assets/Create/Graphics/Diffusion profile Settings", priority = CoreUtils.assetCreateMenuPriority2)]
static void MenuCreateDiffusionProfile()
{
var icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");

20
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Handles.cs


{
partial class PlanarReflectionProbeUI
{
#if false
#endif
static readonly Color k_GizmoMirrorPlaneCamera = new Color(128f / 255f, 128f / 255f, 233f / 255f, 128f / 255f);
public static void DrawHandles(PlanarReflectionProbeUI s, PlanarReflectionProbe d, Editor o)

{
case EditBaseShape:
InfluenceVolumeUI.DrawGizmos(
s.influenceVolume,
d.influenceVolume,
mat,
InfluenceVolumeUI.HandleType.Base,
s.influenceVolume,
d.influenceVolume,
mat,
InfluenceVolumeUI.HandleType.Base,
s.influenceVolume,
d.influenceVolume,
s.influenceVolume,
d.influenceVolume,
InfluenceVolumeUI.HandleType.Influence,
InfluenceVolumeUI.HandleType.Influence,
s.influenceVolume,
s.influenceVolume,
InfluenceVolumeUI.HandleType.InfluenceNormal,
InfluenceVolumeUI.HandleType.InfluenceNormal,
InfluenceVolumeUI.HandleType.All);
break;
default:

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Decal/DecalProjectorComponentEditor.cs


{
private MaterialEditor m_MaterialEditor = null;
private DecalProjectorComponent m_DecalProjectorComponent = null;
private SerializedProperty m_MaterialProperty;
private SerializedProperty m_DrawDistanceProperty;
private SerializedProperty m_FadeScaleProperty;
private void OnEnable()
{

m_DecalProjectorComponent.OnMaterialChange += OnMaterialChange;
m_MaterialProperty = serializedObject.FindProperty("m_Material");
m_DrawDistanceProperty = serializedObject.FindProperty("m_DrawDistance");
m_FadeScaleProperty = serializedObject.FindProperty("m_FadeScale");
}
private void OnDisable()

{
EditorGUI.BeginChangeCheck();
base.OnInspectorGUI();
EditorGUILayout.PropertyField(m_MaterialProperty);
EditorGUILayout.PropertyField(m_DrawDistanceProperty);
EditorGUILayout.Slider(m_FadeScaleProperty, 0.0f, 1.0f, new GUIContent("Fade scale"));
if (EditorGUI.EndChangeCheck())
{
serializedObject.ApplyModifiedProperties();

10
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/RenderPipelineSettingsUI.cs


(s, d, o) => s.shadowInitParams,
(s, d, o) => d.shadowInitParams,
ShadowInitParametersUI.SectionAtlas
),
CED.space,
CED.Select(
(s, d, o) => s.decalSettings,
(s, d, o) => d.decalSettings,
GlobalDecalSettingsUI.Inspector
);
}

);
GlobalLightLoopSettingsUI lightLoopSettings = new GlobalLightLoopSettingsUI();
GlobalDecalSettingsUI decalSettings = new GlobalDecalSettingsUI();
ShadowInitParametersUI shadowInitParams = new ShadowInitParametersUI();
public RenderPipelineSettingsUI()

{
lightLoopSettings.Reset(data.lightLoopSettings, repaint);
shadowInitParams.Reset(data.shadowInitParams, repaint);
decalSettings.Reset(data.decalSettings, repaint);
base.Reset(data, repaint);
}

shadowInitParams.Update();
decalSettings.Update();
base.Update();
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedRenderPipelineSettings.cs


public SerializedGlobalLightLoopSettings lightLoopSettings;
public SerializedShadowInitParameters shadowInitParams;
public SerializedGlobalDecalSettings decalSettings;
public SerializedRenderPipelineSettings(SerializedProperty root)
{

lightLoopSettings = new SerializedGlobalLightLoopSettings(root.Find((RenderPipelineSettings s) => s.lightLoopSettings));
shadowInitParams = new SerializedShadowInitParameters(root.Find((RenderPipelineSettings s) => s.shadowInitParams));
decalSettings = new SerializedGlobalDecalSettings(root.Find((RenderPipelineSettings s) => s.decalSettings));
}
}
}

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/UpgradeStandardShaderMaterials.cs


return upgraders;
}
[MenuItem("Edit/Render Pipeline/Upgrade/High Definition/Upgrade Standard Materials to Lit Materials (Project)", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Upgrade Project Materials to High Definition Materials", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Upgrade/High Definition/Upgrade Standard Materials to Lit Materials (Selection)", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Upgrade Selected Materials to High Definition Materials", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Upgrade/High Definition/Modify Light Intensity for Upgrade (Scene Only)", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Upgrade Scene Light Intensity for High Definition", priority = CoreUtils.editMenuPriority2)]
static void UpgradeLights()
{
Light[] lights = Light.GetLights(LightType.Directional, 0);

5
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipelineAsset.asset


--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1

shadowInitParams:
shadowAtlasWidth: 4096
shadowAtlasHeight: 4096
decalSettings:
drawDistance: 1000
atlasSize: 8192
diffusionProfileSettings: {fileID: 11400000, guid: 404820c4cf36ad944862fa59c56064f0,
type: 2}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/DeferredDirectionalShadow.compute


float _DirectionalShadowIndex;
float3 _LightDirection;
float4 _ScreenSpaceShadowsParameters;
uint _SampleCount;
int _SampleCount;
CBUFFER_END
#define _ContactShadowLength _ScreenSpaceShadowsParameters.x

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs


[GenerateHLSL]
public class LightDefinitions
{
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;

20
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoopDef.hlsl


uint cacheType = index & 1;
index = index >> 1;
float4 color = float4(0.0, 0.0, 0.0, 1.0);
// This code will be inlined as lightLoopContext is hardcoded in the light loop
if (lightLoopContext.sampleReflection == SINGLE_PASS_CONTEXT_SAMPLE_REFLECTION_PROBES)
{

ndc *= rcp(ndc.w);
ndc.xy = ndc.xy * 0.5 + 0.5;
float4 color = SAMPLE_TEXTURE2D_ARRAY_LOD(_Env2DTextures, s_trilinear_clamp_sampler, ndc.xy, index, 0);
color.a = any(ndc.xyz < 0) || any(ndc.xyz > 1) ? 0 : 1;
color.rgb = SAMPLE_TEXTURE2D_ARRAY_LOD(_Env2DTextures, s_trilinear_clamp_sampler, ndc.xy, index, 0).rgb;
color.a = any(ndc.xyz < 0) || any(ndc.xyz > 1) ? 0.0 : 1.0;
return float4(ndc.xy, 0, color.a);
color = float4(ndc.xy, 0, color.a);
return color;
float4 color = SAMPLE_TEXTURECUBE_ARRAY_LOD_ABSTRACT(_EnvCubemapTextures, s_trilinear_clamp_sampler, texCoord, index, lod);
color.a = 1;
color.rgb = SAMPLE_TEXTURECUBE_ARRAY_LOD_ABSTRACT(_EnvCubemapTextures, s_trilinear_clamp_sampler, texCoord, index, lod).rgb;
return float4(texCoord.xyz * 0.5 + 0.5, color.a);
color = float4(texCoord.xyz * 0.5 + 0.5, color.a);
return color;
return float4(0, 0, 0, 0);
return SampleSkyTexture(texCoord, lod);
color.rgb = SampleSkyTexture(texCoord, lod).rgb;
return color;
}
//-----------------------------------------------------------------------------

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.cs


[SurfaceDataAttributes("Normal", true)]
public Vector4 normalWS;
[SurfaceDataAttributes("Mask", true)]
public Vector4 mask;
public Vector4 mask;
[SurfaceDataAttributes("HTileMask")]
public uint HTileMask;
};
[GenerateHLSL(PackingRules.Exact)]

5
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.cs.hlsl


#define DEBUGVIEW_DECAL_DECALSURFACEDATA_BASE_COLOR (10000)
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_NORMAL_WS (10001)
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_MASK (10002)
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_HTILE_MASK (10003)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Decal+DBufferMaterial: static fields

float4 baseColor;
float4 normalWS;
float4 mask;
int HTileMask;
};
//

break;
case DEBUGVIEW_DECAL_DECALSURFACEDATA_MASK:
result = decalsurfacedata.mask.xyz;
break;
case DEBUGVIEW_DECAL_DECALSURFACEDATA_HTILE_MASK:
result = GetIndexColor(decalsurfacedata.HTileMask);
break;
}
}

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.hlsl


#include "Decal.cs.hlsl"
#include "CoreRP/ShaderLibrary/Debug.hlsl"
#include "Decal.cs.hlsl"
#define DBufferType0 float4
#define DBufferType1 float4

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DecalData.hlsl


#include "CoreRP/ShaderLibrary/Packing.hlsl"
#include "CoreRP/ShaderLibrary/Sampling/SampleUVMapping.hlsl"
void GetSurfaceData(float2 texCoordDS, float3x3 decalToWorld, out DecalSurfaceData surfaceData)
void GetSurfaceData(float2 texCoordDS, float4x4 decalToWorld, out DecalSurfaceData surfaceData)
float totalBlend = _DecalBlend;
surfaceData.HTileMask = 0;
float totalBlend = _DecalBlend * clamp(decalToWorld[0][3], 0.0f, 1.0f);
surfaceData.HTileMask |= DBUFFERHTILEBIT_DIFFUSE;
surfaceData.normalWS.xyz = mul(decalToWorld, SAMPLE_UVMAPPING_NORMALMAP(_NormalMap, sampler_NormalMap, texCoord, 1)) * 0.5f + 0.5f;
surfaceData.normalWS.xyz = mul((float3x3)decalToWorld, SAMPLE_UVMAPPING_NORMALMAP(_NormalMap, sampler_NormalMap, texCoord, 1)) * 0.5f + 0.5f;
surfaceData.HTileMask |= DBUFFERHTILEBIT_NORMAL;
surfaceData.HTileMask |= DBUFFERHTILEBIT_MASK;
}

41
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl


}
// This function is use to help with debugging and must be implemented by any lit material
// Implementer must take into account what are the current override component and
// Implementer must take into account what are the current override component and
// adjust SurfaceData properties accordingdly
void ApplyDebugToSurfaceData(float3x3 worldToTangent, inout SurfaceData surfaceData)
{

if (overrideNormal)
{
float overrideNormalValue = _DebugLightingNormal.yzw;
surfaceData.normalWS = worldToTangent[2];
}
#endif

// GBuffer2 and GBuffer0.a interpretation depends on material feature enabled
//GBuffer0 RGBA8 sRGB Gbuffer0 encode baseColor and so is sRGB to save precision. Alpha is not affected.
//GBuffer1 R10B10G10A2
//GBuffer1 RGBA8
//GBuffer2 RGBA8
//GBuffer3 RGBA8

//GBuffer1 perceptualRoughness, normal.x, normal.y, normal.sign
//GBuffer1 normal.xy (1212), perceptualRoughness
//GBuffer1 perceptualRoughness, normal.x, normal.y, normal.sign
//GBuffer1 normal.xy (1212), perceptualRoughness
//GBuffer1 perceptualRoughness, normal.x, normal.y, normal.sign
//GBuffer1 normal.xy (1212), perceptualRoughness
//GBuffer1 perceptualRoughness, normal.x, normal.y, normal.sign
//GBuffer1 normal.xy (1212), perceptualRoughness
//GBuffer2 IOR, thickness, unused(3bit) / metallic(5), featureID(3) / coatMask(5)
//GBuffer3 bakedDiffuseLighting.rgb

// Isolate material features.
tileFeatureFlags &= MATERIAL_FEATURE_MASK_FLAGS;
bsdfData.materialFeatures = tileFeatureFlags; // Only tile-uniform feature evaluation
GBufferType0 inGBuffer0 = LOAD_TEXTURE2D(_GBufferTexture0, positionSS);
GBufferType1 inGBuffer1 = LOAD_TEXTURE2D(_GBufferTexture1, positionSS);
GBufferType2 inGBuffer2 = LOAD_TEXTURE2D(_GBufferTexture2, positionSS);

pixelFeatureFlags |= tileFeatureFlags & (pixelHasAnisotropy ? MATERIALFEATUREFLAGS_LIT_ANISOTROPY : 0);
pixelFeatureFlags |= tileFeatureFlags & (pixelHasIridescence ? MATERIALFEATUREFLAGS_LIT_IRIDESCENCE : 0);
pixelFeatureFlags |= tileFeatureFlags & (pixelHasClearCoat ? MATERIALFEATUREFLAGS_LIT_CLEAR_COAT : 0);
// In the case of material classification we assign tileFeatureFlags to bsdfData.materialFeatures
// This mean that the branch inside the tile will be the same (coherency). Remember that a divergent branch
// on AMD GCN mean we will execute both branch for all fragement. We setup at pixel level values
// such that a particular branch will not have effect if it shouldn't. For example if SSS is enabled,
// setup a sssMask of 0 don't have any effect and we can safely take the SSS branch for the tile.
// Note that in the catch all variant of material classification we get the value from the structure buffer done
// in the classification pass. Mean even in catch all, we it is high likely that we don't have tileFeatureFlags == MATERIAL_FEATURE_MASK_FLAGS case.
// tileFeatureFlags == MATERIAL_FEATURE_MASK_FLAGS can appear in following situation
// call from deferred.shader or other shader that doesn't peform material classification
// call from last catch all variant in material classification, which mean we have all possible material inside a same tile (very rare)
// call from a specific case in material classification (currently we have variant 0)
// When this happen, we prefer to use the pixelFeatureFlags rather than the tileFeatureFlags as bsdfData.materialFeatures
// because there is more likelihood to save performance (excep in the very rare case of catch all of material classification).
// We can indeed have divergence inside a tile (like having aniso and not aniso)
// but it is more likely that the whole time is convergent (like everything have SSS and clear coat).
if (tileFeatureFlags == MATERIAL_FEATURE_MASK_FLAGS)
{
bsdfData.materialFeatures = pixelFeatureFlags;
tileFeatureFlags = pixelFeatureFlags; // Required for the aniso test (see below)
}
else
{
bsdfData.materialFeatures = tileFeatureFlags;
}
// Decompress feature-agnostic data from the G-Buffer.
float3 baseColor = inGBuffer0.rgb;

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipeline/RenderPipelineSettings.cs


public GlobalLightLoopSettings lightLoopSettings = new GlobalLightLoopSettings();
public ShadowInitParameters shadowInitParams = new ShadowInitParameters();
public GlobalDecalSettings decalSettings = new GlobalDecalSettings();
}
}

14
ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderPass/ShaderPassDBuffer.hlsl


clip(1.0 - positionDS); // Clip value above one
DecalSurfaceData surfaceData;
float3x3 decalToWorld = (float3x3)UNITY_ACCESS_INSTANCED_PROP(matrix, normalToWorld);
float4x4 decalToWorld = UNITY_ACCESS_INSTANCED_PROP(matrix, normalToWorld);
uint mask = 0;
#if _COLORMAP
mask |= DBUFFERHTILEBIT_DIFFUSE;
#endif
#if _NORMALMAP
mask |= DBUFFERHTILEBIT_NORMAL;
#endif
#if _MASKMAP
mask |= DBUFFERHTILEBIT_MASK;
#endif
oldVal |= mask;
oldVal |= surfaceData.HTileMask;
_DecalHTile[posInput.positionSS.xy / 8] = PackByte(oldVal);
}
ENCODE_INTO_DBUFFER(surfaceData, outDBuffer);

10
ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineAsset.cs


[SerializeField] private ShadowCascades m_ShadowCascades = ShadowCascades.FOUR_CASCADES;
[SerializeField] private float m_Cascade2Split = 0.25f;
[SerializeField] private Vector3 m_Cascade4Split = new Vector3(0.067f, 0.2f, 0.467f);
[SerializeField]
private LightweightPipelineResources m_ResourcesAsset;

[MenuItem("Assets/Create/Render Pipeline/Lightweight/Pipeline Asset", priority = CoreUtils.assetCreateMenuPriority1)]
[MenuItem("Assets/Create/Graphics/Lightweight Pipeline Asset", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateLightweightPipeline()
{
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, CreateInstance<CreateLightweightPipelineAsset>(),

//[MenuItem("Assets/Create/Render Pipeline/Lightweight/Pipeline Resources", priority = CoreUtils.assetCreateMenuPriority1)]
//[MenuItem("Assets/Create/Graphics/Lightweight Pipeline Resources", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateLightweightPipelineResources()
{
var instance = CreateInstance<LightweightPipelineResources>();

//[MenuItem("Assets/Create/Render Pipeline/Lightweight/Pipeline Editor Resources", priority = CoreUtils.assetCreateMenuPriority1)]
//[MenuItem("Assets/Create/Graphics/Lightweight Pipeline Editor Resources", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateLightweightPipelineEditorResources()
{
var instance = CreateInstance<LightweightPipelineEditorResources>();

private Material GetMaterial(DefaultMaterialType materialType)
{
#if UNITY_EDITOR
switch (materialType)
{
case DefaultMaterialType.Standard:

4
ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/LightweightMaterialUpgrader.cs


{
public class LightweightMaterialUpgrader
{
[MenuItem("Edit/Render Pipeline/Upgrade/Lightweight/Upgrade Project Materials", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Upgrade Project Materials to LightWeight Materials", priority = CoreUtils.editMenuPriority2)]
private static void UpgradeProjectMaterials()
{
List<MaterialUpgrader> upgraders = new List<MaterialUpgrader>();

}
[MenuItem("Edit/Render Pipeline/Upgrade/Lightweight/Upgrade Selected Materials", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Upgrade Selected Materials to LightWeight Materials", priority = CoreUtils.editMenuPriority2)]
private static void UpgradeSelectedMaterials()
{
List<MaterialUpgrader> upgraders = new List<MaterialUpgrader>();

2
TestbedPipelines/BasicRenderPipeline/BasicRenderPipeline.cs


public bool UseIntermediateRenderTargetBlit;
#if UNITY_EDITOR
[UnityEditor.MenuItem("Assets/Create/Render Pipeline/Basic/Render Pipeline", priority = CoreUtils.assetCreateMenuPriority1)]
[UnityEditor.MenuItem("Assets/Create/Graphics/Basic Render Pipeline", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateBasicRenderPipeline()
{
var instance = ScriptableObject.CreateInstance<BasicRenderPipeline>();

3
TestbedPipelines/Fptl/FptlLighting.cs


public class FptlLighting : RenderPipelineAsset
{
#if UNITY_EDITOR
[UnityEditor.MenuItem("Assets/Create/Render Pipeline/FPTL/Render Pipeline", priority = CoreUtils.assetCreateMenuPriority1)]
// Hide as not an official pipeline
// [UnityEditor.MenuItem("Assets/Create/Render Pipeline/FPTL/Render Pipeline", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateRenderLoopFPTL()
{
var instance = ScriptableObject.CreateInstance<FptlLighting>();

68
TestbedPipelines/OnTileDeferredPipeline/OnTileDeferredRenderPipeline.cs


[ExecuteInEditMode]
public class OnTileDeferredRenderPipeline : RenderPipelineAsset {
#if UNITY_EDITOR
[UnityEditor.MenuItem("Assets/Create/Render Pipeline/On Tile Deferred/Render Pipeline", priority = CoreUtils.assetCreateMenuPriority1)]
#if UNITY_EDITOR
// Hide as not an official pipeline
// [UnityEditor.MenuItem("Assets/Create/Render Pipeline/On Tile Deferred/Render Pipeline", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateDeferredRenderPipeline()
{
var instance = ScriptableObject.CreateInstance<OnTileDeferredRenderPipeline> ();

[UnityEditor.MenuItem("Edit/Render Pipeline/Upgrade/On Tile Deferred/Upgrade Standard Shader Materials", priority = CoreUtils.editMenuPriority2)]
// Hide as not an official pipeline
//[UnityEditor.MenuItem("Edit/Render Pipeline/Upgrade/On Tile Deferred/Upgrade Standard Shader Materials", priority = CoreUtils.editMenuPriority2)]
static void SetupDeferredRenderPipelineMaterials()
{
Renderer[] _renderers = Component.FindObjectsOfType<Renderer> ();

if (_material == null)
continue;
if (_material.shader.name.Contains ("Standard (Specular setup)")) {
_material.shader = Shader.Find("Standard-SRP (Specular setup)");
} else if (_material.shader.name.Contains ("Standard")) {

{
return new OnTileDeferredRenderPipelineInstance(this);
}
[SerializeField] ShadowSettings m_ShadowSettings = new ShadowSettings();
ShadowSetup m_ShadowSetup;

// TODO: When graphics/renderpass lands, replace code that uses boolean below with SystemInfo.supportsReadOnlyDepth
#if UNITY_EDITOR || UNITY_STANDALONE
static bool s_SupportsReadOnlyDepth = true;
#else
#else
static bool s_SupportsReadOnlyDepth = false;
#endif

s_GBufferEmission = new RenderPassAttachment(RenderTextureFormat.ARGBHalf) { hideFlags = HideFlags.HideAndDontSave };
s_Depth = new RenderPassAttachment(RenderTextureFormat.Depth) { hideFlags = HideFlags.HideAndDontSave };
s_CameraTarget = s_GBufferAlbedo;
s_GBufferEmission.Clear(new Color(0.0f, 0.0f, 0.0f, 0.0f), 1.0f, 0);
s_Depth.Clear(new Color(), 1.0f, 0);

m_ReflectionNearAndFarClipMaterial.SetInt("_DstABlend", (int)BlendMode.Zero);
m_ReflectionNearAndFarClipMaterial.SetInt("_CullMode", (int)CullMode.Off);
m_ReflectionNearAndFarClipMaterial.SetInt("_CompareFunc", (int)CompareFunction.Always);
m_CookieTexArray = new TextureCache2D();
m_CubeCookieTexArray = new TextureCacheCubemap();
m_CubeReflTexArray = new TextureCacheCubemap();

void ExecuteRenderLoop(Camera camera, CullResults cullResults, ScriptableRenderContext loop)
{
using (RenderPass rp = new RenderPass (loop, camera.pixelWidth, camera.pixelHeight, 1, s_SupportsReadOnlyDepth ?
using (RenderPass rp = new RenderPass (loop, camera.pixelWidth, camera.pixelHeight, 1, s_SupportsReadOnlyDepth ?
using (new RenderPass.SubPass (rp, s_SupportsReadOnlyDepth ?
using (new RenderPass.SubPass (rp, s_SupportsReadOnlyDepth ?
new[] { s_GBufferAlbedo, s_GBufferSpecRough, s_GBufferNormal, s_GBufferEmission } :
new[] { s_GBufferAlbedo, s_GBufferSpecRough, s_GBufferNormal, s_GBufferEmission, s_GBufferRedF32 }, null)) {
using (var cmd = new CommandBuffer { name = "Create G-Buffer" }) {

loop.ExecuteCommandBuffer (cmd);
// render opaque objects using Deferred pass
var drawSettings = new DrawRendererSettings (camera, new ShaderPassName ("Deferred")) {
sorting = { flags = SortFlags.CommonOpaque },

}
//Lighting Pass
using (new RenderPass.SubPass(rp, new[] { s_GBufferEmission },
using (new RenderPass.SubPass(rp, new[] { s_GBufferEmission },
new[] { s_GBufferAlbedo, s_GBufferSpecRough, s_GBufferNormal, s_SupportsReadOnlyDepth ? s_Depth : s_GBufferRedF32 }, true))
{
using (var cmd = new CommandBuffer { name = "Deferred Lighting and Reflections Pass"} )

}
}
}
// Utilites
static Matrix4x4 GetFlipMatrix()
{

{
return camera.projectionMatrix * GetFlipMatrix();
}
Matrix4x4 PerspectiveCotanMatrix(float cotangent, float zNear, float zFar )
{
float deltaZ = zNear - zFar;

Matrix4x4 scaled = Matrix4x4.Scale (combinedExtent * 2.0f);
mat = mat * Matrix4x4.Translate (boxOffset) * scaled;
var probeRadius = combinedExtent.magnitude;
var viewDistance = eyePlane.GetDistanceToPoint(boxOffset);
bool intersectsNear = viewDistance - probeRadius <= nearDistanceFudged;

// draw the base probe
// TODO: (cleanup) dont use builtins like unity_SpecCube0
{
{
var props = new MaterialPropertyBlock ();
props.SetFloat ("_LightAsQuad", 1.0f);

Matrix4x4 temp3 = PerspectiveCotanMatrix (chsa, 0.0f, range);
return temp2 * temp1 * temp3 * worldToLight;
}
void RenderSpotlight(VisibleLight light, CommandBuffer cmd, MaterialPropertyBlock properties, bool renderAsQuad, bool intersectsNear, bool deferred)
{
float range = light.range;

// Setup Spot Rendering mesh matrix
float sideLength = range / chsa;
// scalingFactor corrosoponds to the scale factor setting (and wether file scale is used) of mesh in Unity mesh inspector.
// A scale factor setting in Unity of 0.01 would require this to be set to 100. A scale factor setting of 1, is just 1 here.
// scalingFactor corrosoponds to the scale factor setting (and wether file scale is used) of mesh in Unity mesh inspector.
// A scale factor setting in Unity of 0.01 would require this to be set to 100. A scale factor setting of 1, is just 1 here.
lightToWorld = lightToWorld * Matrix4x4.Scale (new Vector3(sideLength*SpotLightMeshScaleFactor, sideLength*SpotLightMeshScaleFactor, range*SpotLightMeshScaleFactor));
//set default cookie for spot light if there wasnt one added to the light manually

Vector3 lightPos = light.localToWorld.GetColumn (3); //position
float range = light.range;
// scalingFactor corrosoponds to the scale factor setting (and wether file scale is used) of mesh in Unity mesh inspector.
// A scale factor setting in Unity of 0.01 would require this to be set to 100. A scale factor setting of 1, is just 1 here.
// scalingFactor corrosoponds to the scale factor setting (and wether file scale is used) of mesh in Unity mesh inspector.
// A scale factor setting in Unity of 0.01 would require this to be set to 100. A scale factor setting of 1, is just 1 here.
if (cookie != null)
if (cookie != null)
else
else
if (renderAsQuad)
if (renderAsQuad)
else if (intersectsNear)
else if (intersectsNear)
else
else
cmd.DrawMesh (m_PointLightMesh, matrix, m_FiniteDeferredLightingMaterial, 0, 0, properties);
}

void RenderLightsDeferred (Camera camera, CullResults inputs, CommandBuffer cmd, ScriptableRenderContext loop)
{
int lightCount = inputs.visibleLights.Count;
for (int lightNum = 0; lightNum < lightCount; lightNum++)
for (int lightNum = 0; lightNum < lightCount; lightNum++)
{
VisibleLight light = inputs.visibleLights[lightNum];

Vector3 lightPos = light.localToWorld.GetColumn (3); //position
Vector3 lightDir = light.localToWorld.GetColumn (2); //z axis
float range = light.range;

float chsa = GetCotanHalfSpotAngle (light.spotAngle);
// Setup Light Matrix
m_LightMatrix[i] = SpotlightMatrix (light, worldToLight, range, chsa);
m_LightMatrix[i] = SpotlightMatrix (light, worldToLight, range, chsa);
} else if (light.lightType == LightType.Directional) {
m_LightData[i].x = LightDefinitions.DIRECTIONAL_LIGHT;

var decodeVals = rl.hdr;
// C is reflection volume center in world space (NOT same as cube map capture point)
var e = bnds.extents;
var C = mat.MultiplyPoint(boxOffset);
var e = bnds.extents;
var C = mat.MultiplyPoint(boxOffset);
var combinedExtent = e + new Vector3(blendDistance, blendDistance, blendDistance);
Vector3 vx = mat.GetColumn(0);

cmd.SetGlobalFloat ("_useLegacyCookies", UseLegacyCookies?1.0f:0.0f);
cmd.SetGlobalFloat ("_transparencyShadows", TransparencyShadows ? 1.0f : 0.0f);
}
}
}

17
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/GlobalDecalSettings.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
// RenderRenderPipelineSettings represent settings that are immutable at runtime.
// There is a dedicated RenderRenderPipelineSettings for each platform
[Serializable]
public class GlobalDecalSettings
{
public int drawDistance = 1000;
public int atlasSize = 8192;
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/GlobalDecalSettings.cs.meta


fileFormatVersion: 2
guid: 485a401e826e66d4fb7bc37f9562ad93
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

32
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/GlobalDecalSettingsUI.cs


using UnityEngine;
namespace UnityEditor.Experimental.Rendering
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<GlobalDecalSettingsUI, SerializedGlobalDecalSettings>;
class GlobalDecalSettingsUI : BaseUI<SerializedGlobalDecalSettings>
{
static GlobalDecalSettingsUI()
{
Inspector = CED.Group(SectionDecalSettings);
}
public static readonly CED.IDrawer Inspector;
public static readonly CED.IDrawer SectionDecalSettings = CED.Action(Drawer_SectionDecalSettings);
public GlobalDecalSettingsUI()
: base(0)
{
}
static void Drawer_SectionDecalSettings(GlobalDecalSettingsUI s, SerializedGlobalDecalSettings d, Editor o)
{
EditorGUILayout.LabelField(_.GetContent("Decals"), EditorStyles.boldLabel);
++EditorGUI.indentLevel;
EditorGUILayout.PropertyField(d.drawDistance, _.GetContent("Draw Distance"));
EditorGUILayout.PropertyField(d.atlasSize, _.GetContent("Atlas Size"));
--EditorGUI.indentLevel;
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/GlobalDecalSettingsUI.cs.meta


fileFormatVersion: 2
guid: cd7279651d591ea499d14ea8d77384ef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

20
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedGlobalDecalSettings.cs


using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering
{
class SerializedGlobalDecalSettings
{
public SerializedProperty root;
public SerializedProperty drawDistance;
public SerializedProperty atlasSize;
public SerializedGlobalDecalSettings(SerializedProperty root)
{
this.root = root;
drawDistance = root.Find((GlobalDecalSettings s) => s.drawDistance);
atlasSize = root.Find((GlobalDecalSettings s) => s.atlasSize);
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedGlobalDecalSettings.cs.meta


fileFormatVersion: 2
guid: dadcbfde34013be40a7e1162307cc677
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存