浏览代码

Merge remote-tracking branch 'refs/remotes/origin/master' into Add-physical-Light-unit-2

/main
Sebastien Lagarde 7 年前
当前提交
128f5158
共有 30 个文件被更改,包括 393 次插入105 次删除
  1. 99
      SampleScenes/HDTest/ShadowsTest.unity
  2. 4
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Random.hlsl
  3. 14
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Shadow/Shadow.hlsl
  4. 44
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl
  5. 12
      ScriptableRenderPipeline/Core/CoreRP/Shadow/AdditionalShadowData.cs
  6. 2
      ScriptableRenderPipeline/Core/package.json
  7. 16
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugColorPicker.shader
  8. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.hlsl
  9. 7
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDLightEditor.Styles.cs
  10. 33
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDLightEditor.cs
  11. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/FrameSettingsUI.cs
  12. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedFrameSettings.cs
  13. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
  14. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipelineAsset.asset
  15. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
  16. 122
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/DeferredDirectionalShadow.compute
  17. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightEvaluation.hlsl
  18. 30
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs
  19. 12
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/Shadow.hlsl
  20. 7
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipeline/FrameSettings.cs
  21. 23
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderVariablesFunctions.hlsl
  22. 4
      ScriptableRenderPipeline/HDRenderPipeline/package.json
  23. 2
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/LightweightShaderIncludePaths.cs
  24. 8
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Input.hlsl
  25. 13
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/InputBuiltin.hlsl
  26. 2
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/InputSurface.hlsl
  27. 6
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Lighting.hlsl
  28. 3
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassMeta.hlsl
  29. 4
      ScriptableRenderPipeline/LightweightPipeline/package.json
  30. 2
      ScriptableRenderPipeline/master-package.json

99
SampleScenes/HDTest/ShadowsTest.unity


- component: {fileID: 240603310}
- component: {fileID: 240603309}
- component: {fileID: 240603308}
- component: {fileID: 240603312}
m_Layer: 0
m_Name: Camera_FullScreen
m_TagString: Untagged

m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_HDR: 0
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0

m_Father: {fileID: 0}
m_RootOrder: 15
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &240603312
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 240603307}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 23c1ce4fb46143f46bc5cb5224c934f6, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Version: 1
renderingPath: 0
volumeLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_FrameSettings:
enableShadow: 1
enableContactShadows: 1
enableSSR: 1
enableSSAO: 1
enableSubsurfaceScattering: 1
enableTransmission: 1
diffuseGlobalDimmer: 1
specularGlobalDimmer: 1
enableForwardRenderingOnly: 0
enableDepthPrepassWithDeferredRendering: 0
enableAlphaTestOnlyInDeferredPrepass: 0
enableTransparentPrepass: 1
enableMotionVectors: 1
enableObjectMotionVectors: 1
enableDBuffer: 1
enableAtmosphericScattering: 1
enableRoughRefraction: 1
enableTransparentPostpass: 1
enableDistortion: 1
enablePostprocess: 1
enableStereo: 1
enableAsyncCompute: 0
enableOpaqueObjects: 1
enableTransparentObjects: 1
enableMSAA: 0
enableShadowMask: 0
lightLoopSettings:
enableTileAndCluster: 1
enableComputeLightEvaluation: 1
enableComputeLightVariants: 1
enableComputeMaterialVariants: 1
enableFptlForForwardOpaque: 1
enableBigTilePrepass: 1
isFptlEnabled: 1
--- !u!1001 &241568988
Prefab:
m_ObjectHideFlags: 0

m_IsActive: 1
--- !u!114 &367594606
MonoBehaviour:
m_ObjectHideFlags: 0
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 367594605}

shadowResolution: 1024
shadowDimmer: 1
shadowFadeDistance: 10000
enableContactShadows: 1
contactShadowLength: 0.15
contactShadowDistanceScaleFactor: 0.5
contactShadowMaxDistance: 25
contactShadowFadeDistance: 5
contactShadowSampleCount: 8
shadowCascadeCount: 4
shadowCascadeRatios:
- 0.007

- 0.272
- 0.356
shadowAlgorithm: 0
shadowVariant: 4
shadowVariant: 3
format: 4
data: d044583b0000803f
format: 3
data: 0bd7a33b0000803f
shadowDatas:
- format: 4
data: d044583b0000803f

data: 000000006f12833a0000803f0000803f02000000
- format: 25
data: ec51383da48cb83652499d3903000000
- format: 3
data: 0bd7a33b0000803f
m_ObjectHideFlags: 0
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 367594605}

m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Type: 1
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1

shadowResolution: 1024
shadowDimmer: 1
shadowFadeDistance: 10000
enableContactShadows: 0
contactShadowLength: 0
contactShadowDistanceScaleFactor: 0.5
contactShadowMaxDistance: 50
contactShadowFadeDistance: 5
contactShadowSampleCount: 8
shadowCascadeCount: 4
shadowCascadeRatios:
- 0.05

shadowResolution: 512
shadowDimmer: 1
shadowFadeDistance: 10000
enableContactShadows: 0
contactShadowLength: 0
contactShadowDistanceScaleFactor: 0.5
contactShadowMaxDistance: 50
contactShadowFadeDistance: 5
contactShadowSampleCount: 8
shadowCascadeCount: 4
shadowCascadeRatios:
- 0.05

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1769631028}
m_LocalRotation: {x: 0.13403411, y: 0.23704425, z: -0.03813498, w: 0.96145236}
m_LocalPosition: {x: 220.65787, y: 2.113377, z: -21.421303}
m_LocalRotation: {x: -0.13522926, y: -0.09046717, z: 0.0123988725, w: -0.9865977}
m_LocalPosition: {x: 223.73988, y: 0.35222065, z: -16.362116}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}

m_Name:
m_EditorClassIdentifier:
m_Version: 1
renderingPath: 0
renderingPath: 1
enableContactShadows: 1
enableSSR: 1
enableSSAO: 1
enableSubsurfaceScattering: 1

shadowResolution: 512
shadowDimmer: 1
shadowFadeDistance: 10000
enableContactShadows: 0
contactShadowLength: 0
contactShadowDistanceScaleFactor: 0.5
contactShadowMaxDistance: 50
contactShadowFadeDistance: 5
contactShadowSampleCount: 8
shadowCascadeCount: 4
shadowCascadeRatios:
- 0.05

4
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Random.hlsl


uint JenkinsHash(uint3 v)
{
return JenkinsHash(v.x ^ JenkinsHash(v.y) ^ JenkinsHash(v.z));
return JenkinsHash(v.x ^ JenkinsHash(v.yz));
return JenkinsHash(v.x ^ JenkinsHash(v.y) ^ JenkinsHash(v.z) ^ JenkinsHash(v.w));
return JenkinsHash(v.x ^ JenkinsHash(v.yzw));
}
// Construct a float with half-open range [0, 1) using low 23 bits.

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


}
// shadow sampling prototypes
real GetPunctualShadowAttenuation( ShadowContext shadowContext, real3 positionWS, real3 normalWS, int shadowDataIndex, real3 lightPositionWS, real3 L );
real GetPunctualShadowAttenuation( ShadowContext shadowContext, real3 positionWS, real3 normalWS, int shadowDataIndex, real3 lightPositionWS, real3 L, real2 positionSS );
real GetPunctualShadowAttenuation( ShadowContext shadowContext, real3 positionWS, real3 normalWS, int shadowDataIndex, real4 L );
real GetPunctualShadowAttenuation( ShadowContext shadowContext, real3 positionWS, real3 normalWS, int shadowDataIndex, real4 L, real2 positionSS );
// shadow sampling prototypes with screenspace info
real GetDirectionalShadowAttenuation( ShadowContext shadowContext, real3 positionWS, real3 normalWS, int shadowDataIndex, real3 L );

#include "ShadowAlgorithms.hlsl" // engine default algorithms (don't modify)
#ifndef SHADOW_DISPATCH_USE_CUSTOM_PUNCTUAL
real GetPunctualShadowAttenuation( ShadowContext shadowContext, real3 positionWS, real3 normalWS, int shadowDataIndex, real3 lightPositionWS, real3 L )
real GetPunctualShadowAttenuation( ShadowContext shadowContext, real3 positionWS, real3 normalWS, int shadowDataIndex, real4 L )
return EvalShadow_PunctualDepth(shadowContext, positionWS, normalWS, shadowDataIndex, lightPositionWS, L);
return EvalShadow_PunctualDepth(shadowContext, positionWS, normalWS, shadowDataIndex, L);
real GetPunctualShadowAttenuation( ShadowContext shadowContext, real3 positionWS, real3 normalWS, int shadowDataIndex, real3 lightPositionWS, real3 L, real2 positionSS )
real GetPunctualShadowAttenuation( ShadowContext shadowContext, real3 positionWS, real3 normalWS, int shadowDataIndex, real4 L, real2 positionSS )
return GetPunctualShadowAttenuation( shadowContext, positionWS, normalWS, shadowDataIndex, lightPositionWS, L );
return GetPunctualShadowAttenuation( shadowContext, positionWS, normalWS, shadowDataIndex, L );
}
#endif

real GetDirectionalShadowAttenuation( ShadowContext shadowContext, real3 positionWS, real3 normalWS, int shadowDataIndex, real3 L, real2 positionSS )
{
return GetDirectionalShadowAttenuation( shadowContext, positionWS, normalWS, shadowDataIndex, lightPositionWS, L );
return GetDirectionalShadowAttenuation( shadowContext, positionWS, normalWS, shadowDataIndex, L );
}
#endif

44
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl


//
// Point shadows
//
real EvalShadow_PointDepth( ShadowContext shadowContext, real3 positionWS, real3 normalWS, int index, real3 lightPositionWS, real3 L )
real EvalShadow_PointDepth( ShadowContext shadowContext, real3 positionWS, real3 normalWS, int index, real4 L )
real3 biased_posWS = positionWS + EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), sd.texelSizeRcp.zw, sd.normalBias );
real3 lpos = lightPositionWS;
real3 biased_posWS = positionWS + EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L.xyz ) ), sd.texelSizeRcp.zw, sd.normalBias );
real3 lpos = positionWS + L.xyz * L.w;
positionWS = biased_posWS;
int faceIndex = EvalShadow_GetCubeFaceID( lpos - biased_posWS ) + 1;
// load the right shadow data for the current face

positionWS += EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), sd.texelSizeRcp.zw, sd.normalBias );
positionWS += EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L.xyz ) ), sd.texelSizeRcp.zw, sd.normalBias );
// get shadowmap texcoords
real3 posTC = EvalShadow_GetTexcoords( sd, positionWS );
// get the algorithm

}
#define EvalShadow_PointDepth_( _samplerType ) \
real EvalShadow_PointDepth( ShadowContext shadowContext, uint shadowAlgorithm, Texture2DArray tex, _samplerType samp, real3 positionWS, real3 normalWS, int index, real3 lightPositionWS, real3 L ) \
real EvalShadow_PointDepth( ShadowContext shadowContext, uint shadowAlgorithm, Texture2DArray tex, _samplerType samp, real3 positionWS, real3 normalWS, int index, real4 L ) \
real3 biased_posWS = positionWS + EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), sd.texelSizeRcp.zw, sd.normalBias ); \
real3 lpos = lightPositionWS; \
real3 biased_posWS = positionWS + EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L.xyz ) ), sd.texelSizeRcp.zw, sd.normalBias ); \
real3 lpos = positionWS + L.xyz * L.w; \
positionWS = biased_posWS; \
int faceIndex = EvalShadow_GetCubeFaceID( lpos - biased_posWS ) + 1; \
/* load the right shadow data for the current face */ \

positionWS += EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), sd.texelSizeRcp.zw, sd.normalBias ); \
positionWS += EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L.xyz ) ), sd.texelSizeRcp.zw, sd.normalBias ); \
/* get shadowmap texcoords */ \
real3 posTC = EvalShadow_GetTexcoords( sd, positionWS ); \
/* sample the texture */ \

//
// Punctual shadows for Point and Spot
//
real EvalShadow_PunctualDepth( ShadowContext shadowContext, real3 positionWS, real3 normalWS, int index, real3 lightPositionWS, real3 L )
real EvalShadow_PunctualDepth( ShadowContext shadowContext, real3 positionWS, real3 normalWS, int index, real4 L )
{
// load the right shadow data for the current face
int faceIndex = 0;

[branch]
if( shadowType == GPUSHADOWTYPE_POINT )
{
real3 biased_posWS = positionWS + EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), sd.texelSizeRcp.zw, sd.normalBias );
real3 lpos = lightPositionWS;
positionWS = biased_posWS;
faceIndex = EvalShadow_GetCubeFaceID( lpos - biased_posWS ) + 1;
real3 biased_posWS = positionWS + EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L.xyz ) ), sd.texelSizeRcp.zw, sd.normalBias );
real3 lpos = positionWS + L.xyz * L.w;
positionWS = biased_posWS;
faceIndex = EvalShadow_GetCubeFaceID( lpos - biased_posWS ) + 1;
positionWS += EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), sd.texelSizeRcp.zw, sd.normalBias );
positionWS += EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L.xyz ) ), sd.texelSizeRcp.zw, sd.normalBias );
sd = shadowContext.shadowDatas[index + faceIndex];
uint payloadOffset = GetPayloadOffset( sd );

}
#define EvalShadow_PunctualDepth_( _samplerType ) \
real EvalShadow_PunctualDepth( ShadowContext shadowContext, uint shadowAlgorithm, Texture2DArray tex, _samplerType samp, real3 positionWS, real3 normalWS, int index, real3 lightPositionWS, real3 L ) \
real EvalShadow_PunctualDepth( ShadowContext shadowContext, uint shadowAlgorithm, Texture2DArray tex, _samplerType samp, real3 positionWS, real3 normalWS, int index, real4 L ) \
{ \
/* load the right shadow data for the current face */ \
int faceIndex = 0; \

[branch] \
if( shadowType == GPUSHADOWTYPE_POINT ) \
{ \
real3 biased_posWS = positionWS + EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), sd.texelSizeRcp.zw, sd.normalBias ); \
real3 lpos = lightPositionWS; \
positionWS = biased_posWS; \
faceIndex = EvalShadow_GetCubeFaceID( lpos - biased_posWS ) + 1; \
real3 biased_posWS = positionWS + EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L.xyz ) ), sd.texelSizeRcp.zw, sd.normalBias ); \
real3 lpos = positionWS + L.xyz * L.w; \
positionWS = biased_posWS; \
faceIndex = EvalShadow_GetCubeFaceID( lpos - biased_posWS ) + 1; \
positionWS += EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), sd.texelSizeRcp.zw, sd.normalBias ); \
positionWS += EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L.xyz ) ), sd.texelSizeRcp.zw, sd.normalBias ); \
\
sd = shadowContext.shadowDatas[index + faceIndex]; \
uint payloadOffset = GetPayloadOffset( sd ); \

return closestWS.xyz / closestWS.w;
}
real3 EvalShadow_GetClosestSample_Cascade( ShadowContext shadowContext, real3 positionWS, real3 normalWS, int index, real3 lightPositionWS, real3 L )
real3 EvalShadow_GetClosestSample_Cascade( ShadowContext shadowContext, real3 positionWS, real3 normalWS, int index, real4 L )
{
// load the right shadow data for the current face
real4 dirShadowSplitSpheres[4];

return closestWS.xyz / closestWS.w;
}
real3 EvalShadow_GetClosestSample_Cascade( ShadowContext shadowContext, Texture2DArray tex, real3 positionWS, real3 normalWS, int index, real3 lightPositionWS, real3 L )
real3 EvalShadow_GetClosestSample_Cascade( ShadowContext shadowContext, Texture2DArray tex, real3 positionWS, real3 normalWS, int index, real4 L )
{
// load the right shadow data for the current face
real4 dirShadowSplitSpheres[4];

12
ScriptableRenderPipeline/Core/CoreRP/Shadow/AdditionalShadowData.cs


return DefaultShadowResolution;
}
[Range(0.0F, 1.0F)]
[Range(0.0f, 1.0f)]
// Contact shadows
public bool enableContactShadows = false;
[Range(0.0f, 1.0f)]
public float contactShadowLength = 0.0f;
[Range(0.0f, 1.0f)]
public float contactShadowDistanceScaleFactor = 0.5f;
public float contactShadowMaxDistance = 50.0f;
public float contactShadowFadeDistance = 5.0f;
[Range(4, 64)]
public uint contactShadowSampleCount = 8;
// shadow related parameters
[System.Serializable]

2
ScriptableRenderPipeline/Core/package.json


{
"name": "com.unity.render-pipelines.core",
"description": "Core library for Unity render pipelines.",
"version": "0.1.23",
"version": "0.1.24",
"unity": "2018.1",
"dependencies": {
"com.unity.postprocessing": "0.1.7"

16
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugColorPicker.shader


{
uint4 mouseValue = int4(mouseResult * 255.5);
DrawCharacter('R', _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
DrawCharacter(':', _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
DrawInteger(mouseValue.x, _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
if (_ColorPickerMode == COLORPICKERDEBUGMODE_BYTE4)

DrawCharacter('G', _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
DrawCharacter(':', _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
DrawCharacter('B', _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
DrawCharacter(':', _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
DrawCharacter('A', _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
DrawCharacter(':', _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
DrawCharacter('X', _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
DrawCharacter(':', _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
DrawCharacter('Y', _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
DrawCharacter(':', _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
DrawCharacter('Z', _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
DrawCharacter(':', _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
DrawCharacter('W', _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
DrawCharacter(':', _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
DrawFloat(mouseResult.w, _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb);
}
}

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


#define DEBUG_FONT_TEXT_COUNT_Y 8
#define DEBUG_FONT_TEXT_ASCII_START 32
#define DEBUG_FONT_TEXT_SCALE_WIDTH 10 // This control the spacing between characters (if a character fill the text block it will overlap).
// Only support ASCII symbol from DEBUG_FONT_TEXT_ASCII_START to 126
// return black or white depends if we hit font character or not
// currentUnormCoord is current unormalized screen position

color = color * (1.0 - charColor) + charColor * fontColor;
}
fixedUnormCoord.x += DEBUG_FONT_TEXT_WIDTH * direction;
fixedUnormCoord.x += DEBUG_FONT_TEXT_SCALE_WIDTH * direction;
}
// Shortcut to not have to file direction

int numEntries = min((intValue == 0 ? 0 : log10(absIntValue)) + (intValue < 0 ? 1 : 0), maxStringSize);
// 2. Shift curseur to last location as we will go reverse
fixedUnormCoord.x += numEntries * DEBUG_FONT_TEXT_WIDTH;
fixedUnormCoord.x += numEntries * DEBUG_FONT_TEXT_SCALE_WIDTH;
// 3. Display the number
for (uint i = 0; i < maxStringSize; ++i)

}
// 5. Reset cursor at end location
fixedUnormCoord.x += (numEntries + 2) * DEBUG_FONT_TEXT_WIDTH;
fixedUnormCoord.x += (numEntries + 2) * DEBUG_FONT_TEXT_SCALE_WIDTH;
}
void DrawFloat(float floatValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, inout float3 color)

7
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDLightEditor.Styles.cs


public readonly GUIContent[] shapeNames;
// Additional shadow data
public readonly GUIContent shadowCascades = new GUIContent("Cascades", "");
public readonly GUIContent contactShadow = new GUIContent("Contact Shadows");
public readonly GUIContent contactShadowLength = new GUIContent("Length", "Length of rays used to gather contact shadows in world units.\nZero will disable the feature.");
public readonly GUIContent contactShadowDistanceScaleFactor = new GUIContent("Distance Scale Factor", "Contact Shadows are scaled up with distance. Use this parameter to dampen this effect.");
public readonly GUIContent contactShadowMaxDistance = new GUIContent("Max Distance", "Distance from the camera in world units at which contact shadows are faded out to zero.");
public readonly GUIContent contactShadowFadeDistance = new GUIContent("Fade Distance", "Distance in world units over which the contact shadows are faded out (see Max Distance).");
public readonly GUIContent contactShadowSampleCount = new GUIContent("Sample Count", "Number of samples when ray casting.");
public Styles()
{

33
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDLightEditor.cs


public SerializedProperty cascadeRatios;
public SerializedProperty cascadeBorders;
public SerializedProperty resolution;
public SerializedProperty enableContactShadows;
public SerializedProperty contactShadowLength;
public SerializedProperty contactShadowDistanceScaleFactor;
public SerializedProperty contactShadowMaxDistance;
public SerializedProperty contactShadowFadeDistance;
public SerializedProperty contactShadowSampleCount;
}
SerializedObject m_SerializedAdditionalLightData;

cascadeCount = o.Find("shadowCascadeCount"),
cascadeRatios = o.Find("shadowCascadeRatios"),
cascadeBorders = o.Find("shadowCascadeBorders"),
resolution = o.Find(x => x.shadowResolution)
resolution = o.Find(x => x.shadowResolution),
enableContactShadows = o.Find(x => x.enableContactShadows),
contactShadowLength = o.Find(x => x.contactShadowLength),
contactShadowDistanceScaleFactor = o.Find(x => x.contactShadowDistanceScaleFactor),
contactShadowMaxDistance = o.Find(x => x.contactShadowMaxDistance),
contactShadowFadeDistance = o.Find(x => x.contactShadowFadeDistance),
contactShadowSampleCount = o.Find(x => x.contactShadowSampleCount),
};
}

{
bool shadowsEnabled = EditorGUILayout.Toggle(CoreEditorUtils.GetContent("Enable Shadows"), settings.shadowsType.enumValueIndex != 0);
settings.shadowsType.enumValueIndex = shadowsEnabled ? (int)LightShadows.Hard : (int)LightShadows.None;
if (settings.lightType.enumValueIndex == (int)LightType.Directional)
{
EditorGUILayout.PropertyField(m_AdditionalShadowData.enableContactShadows, CoreEditorUtils.GetContent("Enable Contact Shadows"));
}
}
EditorGUILayout.PropertyField(m_AdditionalLightData.showAdditionalSettings);

for (int i = 0; i < arraySize; i++)
EditorGUILayout.Slider(m_AdditionalShadowData.cascadeRatios.GetArrayElementAtIndex(i), 0f, 1f, s_Styles.shadowCascadeRatios[i]);
EditorGUI.indentLevel--;
if(!m_AdditionalShadowData.enableContactShadows.hasMultipleDifferentValues && m_AdditionalShadowData.enableContactShadows.boolValue)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField(s_Styles.contactShadow, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_AdditionalShadowData.contactShadowLength, s_Styles.contactShadowLength);
EditorGUILayout.PropertyField(m_AdditionalShadowData.contactShadowDistanceScaleFactor, s_Styles.contactShadowDistanceScaleFactor);
EditorGUILayout.PropertyField(m_AdditionalShadowData.contactShadowMaxDistance, s_Styles.contactShadowMaxDistance);
EditorGUILayout.PropertyField(m_AdditionalShadowData.contactShadowFadeDistance, s_Styles.contactShadowFadeDistance);
EditorGUILayout.PropertyField(m_AdditionalShadowData.contactShadowSampleCount, s_Styles.contactShadowSampleCount);
EditorGUI.indentLevel--;
}
}
if (settings.isBakedOrMixed)

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/FrameSettingsUI.cs


EditorGUILayout.PropertyField(p.enableSubsurfaceScattering, _.GetContent("Enable Subsurface Scattering"));
EditorGUILayout.PropertyField(p.enableTransmission, _.GetContent("Enable Transmission"));
EditorGUILayout.PropertyField(p.enableShadow, _.GetContent("Enable Shadow"));
EditorGUILayout.PropertyField(p.enableContactShadow, _.GetContent("Enable Contact Shadows"));
EditorGUILayout.PropertyField(p.enableShadowMask, _.GetContent("Enable Shadow Masks"));
}
}

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


public SerializedProperty root;
public SerializedProperty enableShadow;
public SerializedProperty enableContactShadow;
public SerializedProperty enableSSR;
public SerializedProperty enableSSAO;
public SerializedProperty enableSubsurfaceScattering;

this.root = root;
enableShadow = root.Find((FrameSettings d) => d.enableShadow);
enableContactShadow = root.Find((FrameSettings d) => d.enableContactShadows);
enableSSR = root.Find((FrameSettings d) => d.enableSSR);
enableSSAO = root.Find((FrameSettings d) => d.enableSSAO);
enableSubsurfaceScattering = root.Find((FrameSettings d) => d.enableSubsurfaceScattering);

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


public void ApplyDebugDisplaySettings(HDCamera hdCamera, CommandBuffer cmd)
{
if (m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled() ||
if (m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled() ||
m_CurrentDebugDisplaySettings.fullScreenDebugMode != FullScreenDebugMode.None ||
m_CurrentDebugDisplaySettings.colorPickerDebugSettings.colorPickerMode != ColorPickerDebugMode.None)
{

}
void PushFullScreenDebugDepthMip(CommandBuffer cmd, RenderTargetIdentifier textureID, int lodCount, RenderTextureDescriptor desc, FullScreenDebugMode debugMode)
{
{
if (debugMode == m_CurrentDebugDisplaySettings.fullScreenDebugMode)
{
var mipIndex = Mathf.FloorToInt(m_CurrentDebugDisplaySettings.fullscreenDebugMip * (lodCount));

8
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipelineAsset.asset


m_EditorClassIdentifier:
m_RenderPipelineResources: {fileID: 11400000, guid: 3ce144cff5783da45aa5d4fdc2da14b7,
type: 2}
serializedFrameSettings:
m_FrameSettings:
enableContactShadows: 1
enableSSSAndTransmission: 1
enableSubsurfaceScattering: 1
enableTransmission: 1
diffuseGlobalDimmer: 1
specularGlobalDimmer: 1
enableForwardRenderingOnly: 0

supportShadowMask: 1
supportSSR: 1
supportSSAO: 1
supportSSSAndTransmission: 1
supportSubsurfaceScattering: 1
supportDBuffer: 1
supportMSAA: 0
supportAsyncCompute: 0

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs


public static readonly int _DeferredShadowTexture = Shader.PropertyToID("_DeferredShadowTexture");
public static readonly int _DeferredShadowTextureUAV = Shader.PropertyToID("_DeferredShadowTextureUAV");
public static readonly int _DirectionalShadowIndex = Shader.PropertyToID("_DirectionalShadowIndex");
public static readonly int _DirectionalContactShadowParams = Shader.PropertyToID("_ScreenSpaceShadowsParameters");
public static readonly int _DirectionalContactShadowSampleCount = Shader.PropertyToID("_SampleCount");
public static readonly int _DirectionalLightDirection = Shader.PropertyToID("_LightDirection");
public static readonly int unity_OrthoParams = Shader.PropertyToID("unity_OrthoParams");
public static readonly int _ZBufferParams = Shader.PropertyToID("_ZBufferParams");

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


// Each #kernel tells which function to compile; you can have many kernels
#pragma kernel DeferredDirectionalShadow
#pragma kernel DeferredDirectionalShadow DEFERRED_DIRECTIONAL=DeferredDirectionalShadow
#pragma kernel DeferredDirectionalShadow_Contact DEFERRED_DIRECTIONAL=DeferredDirectionalShadow_Contact ENABLE_CONTACT_SHADOWS
//#pragma enable_d3d11_debug_symbols
float _DirectionalShadowIndex;
CBUFFER_START(DeferredShadowParameters)
float _DirectionalShadowIndex;
float3 _LightDirection;
float4 _ScreenSpaceShadowsParameters;
uint _SampleCount;
CBUFFER_END
#define _ContactShadowLength _ScreenSpaceShadowsParameters.x
#define _ContactShadowDistanceScaleFactor _ScreenSpaceShadowsParameters.y
#define _ContactShadowFadeEnd _ScreenSpaceShadowsParameters.z
#define _ContactShadowFadeOneOverRange _ScreenSpaceShadowsParameters.w
// Return 1.0 if occluded 0.0 if not
float4 ScreenSpaceShadowRayCast(float3 positionWS, float3 rayDirection, float rayLength)
{
uint3 hashInput = uint3(abs(GetAbsolutePositionWS(positionWS)) * 1000);
// Dither pattern is shifted by 0.5 because we want to jitter the ray starting position backward and forward (so we need values between -0.5 and 0.5)
float ditherBias = 0.5;
float dither = GenerateHashedRandomFloat(hashInput) - ditherBias;
float3 rayStartWS = positionWS;
float3 rayEndWS = rayStartWS + rayDirection * rayLength;
float4 rayStartCS = TransformWorldToHClip(rayStartWS);
float4 rayEndCS = TransformWorldToHClip(rayEndWS);
// Here we compute a ray perpendicular to view space. This is the ray we use to compute the threshold for rejecting samples.
// This is done this way so that the threshold is less dependent of ray slope.
float4 rayOrthoViewSpace = rayStartCS + mul(GetViewToHClipMatrix(), float4(0, 0, rayLength, 0));
rayOrthoViewSpace = rayOrthoViewSpace / rayOrthoViewSpace.w;
rayStartCS.xyz = rayStartCS.xyz / rayStartCS.w;
rayEndCS.xyz = rayEndCS.xyz / rayEndCS.w;
// Pixel to light ray in clip space.
float3 rayCS = rayEndCS.xyz - rayStartCS.xyz;
// Depth at the start of the ray
float startDepth = rayStartCS.z;
// Depth range of the ray
float rayDepth = rayCS.z;
// Starting UV of the sampling loop
float2 startUV = rayStartCS.xy * 0.5f + 0.5f;
startUV.y = 1.0 - startUV.y;
// Pixel to light ray in
float2 rayUV = rayCS.xy * 0.5f;
rayUV.y = -rayUV.y;
float step = 1.0 / _SampleCount;
float compareThreshold = abs(rayOrthoViewSpace.z - rayStartCS.z) * step;
float occluded = 0.0f;
for (int i = 0; i < _SampleCount; i++)
{
// Step for this sample
float sampleStep = ((i + 1) * step + step * dither);
// UVs for the current sample
float2 sampleUV = startUV + rayUV * sampleStep;
// Ray depth for this sample
float raySampleDepth = startDepth + rayDepth * sampleStep;
// Depth buffer depth for this sample
float sampleDepth = SAMPLE_TEXTURE2D_LOD(_MainDepthTexture, sampler_MainDepthTexture, sampleUV, 0.0).x;
bool Hit = false;
float depthDiff = sampleDepth - raySampleDepth;
Hit = depthDiff < compareThreshold && depthDiff > 0.0;// 1e-4;
if (Hit)
occluded = 1.0f;
}
// Off screen masking
// We remove the occlusion if the ray is occluded and only if direction steps out of the screen
float2 vignette = max(6.0 * abs(rayStartCS.xy + rayCS.xy * occluded * 0.5) - 5.0, 0.0);
occluded *= saturate( 1.0 - dot(vignette, vignette) );
return occluded;
}
void DeferredDirectionalShadow(uint2 groupThreadId : SV_GroupThreadID, uint2 groupId : SV_GroupID)
void DEFERRED_DIRECTIONAL(uint2 groupThreadId : SV_GroupThreadID, uint2 groupId : SV_GroupID)
uint2 pixelCoord = groupId * DEFERRED_SHADOW_TILE_SIZE + groupThreadId;
uint2 tileCoord = groupId;
uint2 pixelCoord = groupId * DEFERRED_SHADOW_TILE_SIZE + groupThreadId;
uint2 tileCoord = groupId;
PositionInputs posInput = GetPositionInput(pixelCoord.xy, _ScreenSize.zw, tileCoord);
PositionInputs posInput = GetPositionInput(pixelCoord.xy, _ScreenSize.zw, tileCoord);
float depth = LOAD_TEXTURE2D(_MainDepthTexture, posInput.positionSS).x;
UpdatePositionInput(depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_VP, posInput);
float depth = LOAD_TEXTURE2D(_MainDepthTexture, posInput.positionSS).x;
ShadowContext shadowContext = InitShadowContext();
float shadow = GetDirectionalShadowAttenuation(shadowContext, posInput.positionWS, float3(0.0, 0.0, 0.0), (uint)_DirectionalShadowIndex, float3(0.0, 0.0, 0.0));
if (depth == UNITY_RAW_FAR_CLIP_VALUE)
return;
_DeferredShadowTextureUAV[pixelCoord] = float4(shadow.xxx, 0.0);
UpdatePositionInput(depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_VP, posInput);
ShadowContext shadowContext = InitShadowContext();
float shadow = GetDirectionalShadowAttenuation(shadowContext, posInput.positionWS, float3(0.0, 0.0, 0.0), (uint)_DirectionalShadowIndex, float3(0.0, 0.0, 0.0));
#ifdef ENABLE_CONTACT_SHADOWS
float contactShadow = 1.0f;
if (_ContactShadowLength > 0.0f)
{
float4 result = ScreenSpaceShadowRayCast(posInput.positionWS, normalize(_LightDirection), _ContactShadowLength * max(0.5, posInput.linearDepth * _ContactShadowDistanceScaleFactor));
contactShadow = 1.0 - result.x * saturate((_ContactShadowFadeEnd - posInput.linearDepth) * _ContactShadowFadeOneOverRange);
shadow *= contactShadow;
}
#endif
_DeferredShadowTextureUAV[pixelCoord] = float4(shadow, 0.0, 0.0, 0.0);
}

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightEvaluation.hlsl


{
// TODO: make projector lights cast shadows.
float3 offset = float3(0.0, 0.0, 0.0); // GetShadowPosOffset(nDotL, normal);
shadow = GetPunctualShadowAttenuation(lightLoopContext.shadowContext, positionWS + offset, N, lightData.shadowIndex, lightData.positionWS, L, posInput.positionSS);
float4 L_dist = float4(L, distances.x);
shadow = GetPunctualShadowAttenuation(lightLoopContext.shadowContext, positionWS + offset, N, lightData.shadowIndex, L_dist, posInput.positionSS);
#ifdef SHADOWS_SHADOWMASK
// Note: Legacy Unity have two shadow mask mode. ShadowMask (ShadowMask contain static objects shadow and ShadowMap contain only dynamic objects shadow, final result is the minimun of both value)
// and ShadowMask_Distance (ShadowMask contain static objects shadow and ShadowMap contain everything and is blend with ShadowMask based on distance (Global distance setup in QualitySettigns)).

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


static int[] s_shadeOpaqueIndirectShadowMaskFptlKernels = new int[LightDefinitions.s_NumFeatureVariants];
static int s_deferredDirectionalShadowKernel;
static int s_deferredDirectionalShadow_Contact_Kernel;
static ComputeBuffer s_LightVolumeDataBuffer = null;
static ComputeBuffer s_ConvexBoundsBuffer = null;

s_shadeOpaqueDirectShadowMaskFptlDebugDisplayKernel = deferredComputeShader.FindKernel("Deferred_Direct_ShadowMask_Fptl_DebugDisplay");
s_deferredDirectionalShadowKernel = deferredDirectionalShadowComputeShader.FindKernel("DeferredDirectionalShadow");
s_deferredDirectionalShadow_Contact_Kernel = deferredDirectionalShadowComputeShader.FindKernel("DeferredDirectionalShadow_Contact");
for (int variant = 0; variant < LightDefinitions.s_NumFeatureVariants; variant++)
{

public void RenderDeferredDirectionalShadow(HDCamera hdCamera, RenderTargetIdentifier deferredShadowRT, RenderTargetIdentifier depthTexture, CommandBuffer cmd)
{
if (m_CurrentSunLight == null)
if (m_CurrentSunLight == null || m_CurrentSunLight.GetComponent<AdditionalShadowData>() == null)
m_ShadowMgr.BindResources(cmd, deferredDirectionalShadowComputeShader, s_deferredDirectionalShadowKernel);
AdditionalShadowData asd = m_CurrentSunLight.GetComponent<AdditionalShadowData>();
bool enableContactShadows = m_FrameSettings.enableContactShadows && asd.enableContactShadows && asd.contactShadowLength > 0.0f;
int kernel = enableContactShadows ? s_deferredDirectionalShadow_Contact_Kernel : s_deferredDirectionalShadowKernel;
m_ShadowMgr.BindResources(cmd, deferredDirectionalShadowComputeShader, kernel);
if (enableContactShadows)
{
float contactShadowRange = Mathf.Clamp(asd.contactShadowFadeDistance, 0.0f, asd.contactShadowMaxDistance);
float contactShadowFadeEnd = asd.contactShadowMaxDistance;
float contactShadowOneOverFadeRange = 1.0f / (contactShadowRange);
Vector4 contactShadowParams = new Vector4(asd.contactShadowLength, asd.contactShadowDistanceScaleFactor, contactShadowFadeEnd, contactShadowOneOverFadeRange);
cmd.SetComputeVectorParam(deferredDirectionalShadowComputeShader, HDShaderIDs._DirectionalContactShadowParams, contactShadowParams);
cmd.SetComputeIntParam(deferredDirectionalShadowComputeShader, HDShaderIDs._DirectionalContactShadowSampleCount, (int)asd.contactShadowSampleCount);
}
cmd.SetComputeTextureParam(deferredDirectionalShadowComputeShader, s_deferredDirectionalShadowKernel, HDShaderIDs._DeferredShadowTextureUAV, deferredShadowRT);
cmd.SetComputeTextureParam(deferredDirectionalShadowComputeShader, s_deferredDirectionalShadowKernel, HDShaderIDs._MainDepthTexture, depthTexture);
cmd.SetComputeVectorParam(deferredDirectionalShadowComputeShader, HDShaderIDs._DirectionalLightDirection, -m_CurrentSunLight.transform.forward);
cmd.SetComputeTextureParam(deferredDirectionalShadowComputeShader, kernel, HDShaderIDs._DeferredShadowTextureUAV, deferredShadowRT);
cmd.SetComputeTextureParam(deferredDirectionalShadowComputeShader, kernel, HDShaderIDs._MainDepthTexture, depthTexture);
hdCamera.SetupComputeShader(deferredDirectionalShadowComputeShader, cmd);
cmd.DispatchCompute(deferredDirectionalShadowComputeShader, s_deferredDirectionalShadowKernel, numTilesX, numTilesY, 1);
cmd.DispatchCompute(deferredDirectionalShadowComputeShader, kernel, numTilesX, numTilesY, 1);
}
}

12
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/Shadow.hlsl


// example of overriding punctual lights
#ifdef SHADOW_DISPATCH_USE_CUSTOM_PUNCTUAL
float GetPunctualShadowAttenuation( ShadowContext shadowContext, float3 positionWS, float3 normalWS, int shadowDataIndex, float3 lightPositionWS, float3 L)
float GetPunctualShadowAttenuation( ShadowContext shadowContext, float3 positionWS, float3 normalWS, int shadowDataIndex, float4 L )
{
#ifdef SHADOW_DISPATCH_USE_SEPARATE_PUNC_ALGOS
// example for choosing different algos for point and spot lights

Texture2DArray tex = shadowContext.tex2DArray[SHADOW_DISPATCH_POINT_TEX];
SamplerComparisonState compSamp = shadowContext.compSamplers[SHADOW_DISPATCH_POINT_SMP];
uint algo = SHADOW_DISPATCH_POINT_ALG;
return EvalShadow_PointDepth( shadowContext, algo, tex, compSamp, positionWS, normalWS, shadowDataIndex, lightPositionWS, L );
return EvalShadow_PointDepth( shadowContext, algo, tex, compSamp, positionWS, normalWS, shadowDataIndex, L );
}
else
{

return EvalShadow_SpotDepth( shadowContext, algo, tex, compSamp, positionWS, normalWS, shadowDataIndex, lightPositionWS, L );
return EvalShadow_SpotDepth( shadowContext, algo, tex, compSamp, positionWS, normalWS, shadowDataIndex, L );
}
#else
// example for choosing the same algo

return EvalShadow_PunctualDepth( shadowContext, algo, tex, compSamp, positionWS, normalWS, shadowDataIndex, lightPositionWS, L );
return EvalShadow_PunctualDepth( shadowContext, algo, tex, compSamp, positionWS, normalWS, shadowDataIndex, L );
float GetPunctualShadowAttenuation( ShadowContext shadowContext, float3 positionWS, float3 normalWS, int shadowDataIndex, float3 lightPositionWS, float3 L, float2 positionSS )
float GetPunctualShadowAttenuation( ShadowContext shadowContext, float3 positionWS, float3 normalWS, int shadowDataIndex, float4 L, float2 positionSS )
return GetPunctualShadowAttenuation( shadowContext, positionWS, normalWS, shadowDataIndex, lightPositionWS, L );
return GetPunctualShadowAttenuation( shadowContext, positionWS, normalWS, shadowDataIndex, L );
}
#endif

7
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipeline/FrameSettings.cs


[Serializable]
public class FrameSettings
{
public static string kEnableShadow = "Enable Shadow";
public static string kEnableShadow = "Enable Shadows";
public static string kEnableContactShadows = "Enable Contact Shadows";
public static string kEnableSSR = "Enable SSR";
public static string kEnableSSAO = "Enable SSAO";
public static string kEnableSubsurfaceScattering = "Enable SubsurfaceScattering";

// Lighting
// Setup by users
public bool enableShadow = true;
public bool enableContactShadows = true;
public bool enableSSR = true; // Depends on DepthPyramid
public bool enableSSAO = true;
public bool enableSubsurfaceScattering = true;

public void CopyTo(FrameSettings frameSettings)
{
frameSettings.enableShadow = this.enableShadow;
frameSettings.enableContactShadows = this.enableContactShadows;
frameSettings.enableSSR = this.enableSSR;
frameSettings.enableSSAO = this.enableSSAO;
frameSettings.enableSubsurfaceScattering = this.enableSubsurfaceScattering;

}
aggregate.enableShadow = srcFrameSettings.enableShadow;
aggregate.enableContactShadows = srcFrameSettings.enableContactShadows;
aggregate.enableSSR = camera.cameraType != CameraType.Reflection && srcFrameSettings.enableSSR && renderPipelineSettings.supportSSR;
aggregate.enableSSAO = srcFrameSettings.enableSSAO && renderPipelineSettings.supportSSAO;
aggregate.enableSubsurfaceScattering = camera.cameraType != CameraType.Reflection && srcFrameSettings.enableSubsurfaceScattering && renderPipelineSettings.supportSubsurfaceScattering;

{
// Register the camera into the debug menu
DebugMenuManager.instance.AddDebugItem<bool>(menuName, kEnableShadow, () => frameSettings.enableShadow, (value) => frameSettings.enableShadow = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>(menuName, kEnableContactShadows, () => frameSettings.enableContactShadows, (value) => frameSettings.enableContactShadows = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>(menuName, kEnableSSR, () => frameSettings.enableSSR, (value) => frameSettings.enableSSR = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>(menuName, kEnableSSAO, () => frameSettings.enableSSAO, (value) => frameSettings.enableSSAO = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>(menuName, kEnableSubsurfaceScattering, () => frameSettings.enableSubsurfaceScattering, (value) => frameSettings.enableSubsurfaceScattering = (bool)value);

23
ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderVariablesFunctions.hlsl


}
// Transform to homogenous clip space
float4x4 GetViewToHClipMatrix()
{
return UNITY_MATRIX_P;
}
float4x4 GetWorldToHClipMatrix()
{
return UNITY_MATRIX_VP;

float4 TransformWorldToHClip(float3 positionWS)
{
return mul(GetWorldToHClipMatrix(), float4(positionWS, 1.0));
}
// Tranforms vector from world space to homogenous space
float3 TransformWorldToHClipDir(float3 directionWS)
{
return mul((float3x3)GetWorldToHClipMatrix(), directionWS);
}
// Tranforms position from view space to homogenous space
float4 TransformWViewToHClip(float3 positionVS)
{
return mul(GetViewToHClipMatrix(), float4(positionVS, 1.0));
}
// Tranforms vector from world space to homogenous space
float3 TransformViewToHClipDir(float3 directionVS)
{
return mul((float3x3)GetViewToHClipMatrix(), directionVS);
}
float3 GetAbsolutePositionWS(float3 positionWS)

4
ScriptableRenderPipeline/HDRenderPipeline/package.json


{
"name": "com.unity.render-pipelines.high-definition",
"description": "HD Render Pipeline for Unity.",
"version": "0.1.23",
"version": "0.1.24",
"com.unity.render-pipelines.core": "0.1.23"
"com.unity.render-pipelines.core": "0.1.24"
}
}

2
ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/LightweightShaderIncludePaths.cs


using System.IO;
using System.IO;
using System.Linq;
using UnityEngine;

8
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Input.hlsl


half4 _AdditionalLightSpotAttenuation[MAX_VISIBLE_LIGHTS];
CBUFFER_END
// These are set internally by the engine upon request by RendererConfiguration.
// Check GetRendererSettings in LightweightPipeline.cs
CBUFFER_START(_PerObject)
half4 unity_LightIndicesOffsetAndCount;
half4 unity_4LightIndices0;
half4 unity_4LightIndices1;
CBUFFER_END
#define UNITY_MATRIX_M unity_ObjectToWorld
#define UNITY_MATRIX_I_M unity_WorldToObject
#define UNITY_MATRIX_V unity_MatrixV

13
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/InputBuiltin.hlsl


// ----------------------------------------------------------------------------
CBUFFER_START(UnityPerDraw : register(b0))
#ifdef UNITY_USE_PREMULTIPLIED_MATRICES
float4x4 glstate_matrix_mvp;
float4x4 glstate_matrix_modelview0;
float4x4 glstate_matrix_invtrans_modelview0;
#endif
CBUFFER_START(UnityPerDraw)
float4x4 unity_ObjectToWorld;
float4x4 unity_WorldToObject;

// HDR environment map decode instructions
half4 unity_SpecCube0_HDR;
// These are set internally by the engine upon request by RendererConfiguration.
// Check GetRendererSettings in LightweightPipeline.cs
half4 unity_LightIndicesOffsetAndCount;
half4 unity_4LightIndices0;
half4 unity_4LightIndices1;
CBUFFER_END

2
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/InputSurface.hlsl


#define SAMPLE_METALLICSPECULAR(uv) SAMPLE_TEXTURE2D(_MetallicGlossMap, sampler_MetallicGlossMap, uv)
#endif
CBUFFER_START(MaterialProperties)
CBUFFER_START(UnityPerMaterial)
half4 _MainTex_ST;
half4 _Color;
half _Cutoff;

6
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Lighting.hlsl


half4 LightweightFragmentLambert(float3 positionWS, half3 normalWS, half3 viewDirectionWS,
half fogFactor, half3 bakedGI, half3 diffuse, half3 emission, half alpha)
{
half3 lightDirection;
Light mainLight = GetMainLight(positionWS);
half3 indirectDiffuse = SubtractDirectMainLightFromLightmap(mainLight, normalWS, bakedGI);
half3 lambert = LightingLambert(mainLight.color, mainLight.direction, normalWS);

{
Light light = GetLight(i, positionWS);
half3 attenuatedLightColor = light.color * light.attenuation;
diffuseColor += LightingLambert(attenuatedLightColor, lightDirection, normalWS);
diffuseColor += LightingLambert(attenuatedLightColor, light.direction, normalWS);
}
#endif

half4 LightweightFragmentBlinnPhong(float3 positionWS, half3 normalWS, half3 viewDirectionWS,
half fogFactor, half3 bakedGI, half3 diffuse, half4 specularGloss, half shininess, half3 emission, half alpha)
{
half3 lightDirection;
Light mainLight = GetMainLight(positionWS);
half3 indirectDiffuse = SubtractDirectMainLightFromLightmap(mainLight, normalWS, bakedGI);

3
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassMeta.hlsl


// d3d9 shader compiler doesn't like NaNs and infinity.
unity_OneOverOutputBoost = saturate(unity_OneOverOutputBoost);
// Disable pow(f, e) warning will not work with negative values
#pragma warning (disable : 3571)
#pragma warning (enable : 3571)
}
if (unity_MetaFragmentControl.y)
{

4
ScriptableRenderPipeline/LightweightPipeline/package.json


{
"name": "com.unity.render-pipelines.lightweight",
"description": "Lightweight Render Pipeline for Unity.",
"version": "0.1.23",
"version": "0.1.24",
"com.unity.render-pipelines.core": "0.1.23"
"com.unity.render-pipelines.core": "0.1.24"
}
}

2
ScriptableRenderPipeline/master-package.json


{
"version": "0.1.23",
"version": "0.1.24",
"unity": "2018.1",
"dependencies": {
"com.unity.postprocessing": "0.1.7"

正在加载...
取消
保存