浏览代码

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

/main
sebastienlagarde 7 年前
当前提交
0a28696e
共有 13 个文件被更改,包括 174 次插入58 次删除
  1. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl
  2. 4
      TestbedPipelines/OnTileDeferredPipeline/Shaders/LightingTemplate.hlsl
  3. 9
      TestbedPipelines/OnTileDeferredPipeline/Shaders/ShadowContext.hlsl
  4. 29
      TestbedPipelines/OnTileDeferredPipeline/Shaders/Standard.shader
  5. 29
      TestbedPipelines/OnTileDeferredPipeline/Shaders/StandardSpecular.shader
  6. 6
      Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/Scenes/3xxx_DebugView/3002_ObjectMotionVector.unity
  7. 15
      Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/Scenes/3xxx_DebugView/3003_CameraMotionVector_TranslateX.unity
  8. 15
      Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/Scenes/3xxx_DebugView/3004_CameraMotionVector_TranslateY.unity
  9. 15
      Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/Scenes/3xxx_DebugView/3005_CameraMotionVector_TranslateZ.unity
  10. 50
      TestbedPipelines/OnTileDeferredPipeline/Shaders/OnTileCommon.hlsl
  11. 9
      TestbedPipelines/OnTileDeferredPipeline/Shaders/OnTileCommon.hlsl.meta
  12. 40
      TestbedPipelines/OnTileDeferredPipeline/Shaders/Shadow.hlsl
  13. 9
      TestbedPipelines/OnTileDeferredPipeline/Shaders/Shadow.hlsl.meta

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


bool pixelHasSpecularColor = (metallic15 == GBUFFER_LIT_SPECULAR_COLOR); // This is always a dynamic test as it is very cheap
bool pixelHasTransmission = (metallic15 == GBUFFER_LIT_SSS_OR_TRANSMISSION && inGBuffer2.g > 0); // Thickness > 0
bool pixelHasSubsurface = (metallic15 == GBUFFER_LIT_SSS_OR_TRANSMISSION && inGBuffer2.b > 0); // TagSSS > 0
bool pixelHasAnisotropy = (metallic15 <= GBUFFER_LIT_ANISOTROPIC_UPPER_BOUND && (inGBuffer2.b - 0.5) >= 1.0/255.0); // Anisotropy > 0
bool pixelHasAnisotropy = (metallic15 <= GBUFFER_LIT_ANISOTROPIC_UPPER_BOUND && abs(inGBuffer2.b - 0.5) >= 1.0/255.0); // Anisotropy > 0
bool pixelHasIridescence = (metallic15 == GBUFFER_LIT_IRIDESCENCE);
bool pixelHasClearCoat = (coatMask > 0);

4
TestbedPipelines/OnTileDeferredPipeline/Shaders/LightingTemplate.hlsl


#define BOX_LIGHT (2)
#define DIRECTIONAL_LIGHT (3)
#include "OnTileCommon.hlsl"
#if defined(SHADER_API_D3D11)
# include "CoreRP/ShaderLibrary/API/D3D11.hlsl"
#elif defined(SHADER_API_PSSL)

# error unsupported shader api
#endif
#include "CoreRP/ShaderLibrary/API/Validate.hlsl"
#include "../../Fptl/Shadow.hlsl"
#include "Shadow.hlsl"
UNITY_DECLARE_DEPTH_TEXTURE(_CameraGBufferZ);

9
TestbedPipelines/OnTileDeferredPipeline/Shaders/ShadowContext.hlsl


// This can be custom for each project and needs to be in sync with the ShadowMgr
#ifndef ONTILE_SHADOW_CONTEXT_HLSL
#define ONTILE_SHADOW_CONTEXT_HLSL
#define SHADOWCONTEXT_MAX_TEX2DARRAY 1
#define SHADOWCONTEXT_MAX_TEXCUBEARRAY 0

SHADOWCONTEXT_DECLARE( SHADOWCONTEXT_MAX_TEX2DARRAY, SHADOWCONTEXT_MAX_TEXCUBEARRAY, SHADOWCONTEXT_MAX_COMPSAMPLER, SHADOWCONTEXT_MAX_SAMPLER );
#include "CoreRP/ShaderLibrary/Shadow/Shadow.hlsl"
SAMPLER2D_SHADOW(sampler_ShadowmapExp_PCF);
SAMPLER_CMP(sampler_ShadowmapExp_PCF);
StructuredBuffer<ShadowData> _ShadowDatasExp;
StructuredBuffer<int4> _ShadowPayloads;

return sc;
}
#endif // ONTILE_SHADOW_CONTEXT_HLSL

29
TestbedPipelines/OnTileDeferredPipeline/Shaders/Standard.shader


{
_Color("Color", Color) = (1,1,1,1)
_MainTex("Albedo", 2D) = "white" {}
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5

_EmissionColor("Color", Color) = (0,0,0)
_EmissionMap("Emission", 2D) = "white" {}
_DetailMask("Detail Mask", 2D) = "white" {}
_DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {}

}
CGINCLUDE
#include "OnTileCommon.hlsl"
#define UNITY_SETUP_BRDF_INPUT MetallicSetup
ENDCG

LOD 300
// ------------------------------------------------------------------
// Forward pass
Pass

// Base forward pass (directional light, emission, lightmaps, ...)
Pass
{
Name "FORWARD_BASE"
Name "FORWARD_BASE"
Tags { "LightMode" = "ForwardBase" }
Blend [_SrcBlend] [_DstBlend]

// This pass it not used during regular rendering.
Pass
{
Name "META"
Name "META"
Tags { "LightMode"="Meta" }
Cull Off

// Base forward pass (directional light, emission, lightmaps, ...)
Pass
{
Name "FORWARD"
Name "FORWARD"
Tags { "LightMode" = "ForwardBase" }
Blend [_SrcBlend] [_DstBlend]

#pragma target 2.0
#pragma shader_feature _EMISSION
#pragma shader_feature _METALLICGLOSSMAP
#pragma shader_feature _EMISSION
#pragma shader_feature _METALLICGLOSSMAP
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
#pragma shader_feature _ _GLOSSYREFLECTIONS_OFF

Fog { Color (0,0,0,0) } // in additive pass fog should be black
ZWrite Off
ZTest LEqual
CGPROGRAM
#pragma target 2.0

#pragma shader_feature ___ _DETAIL_MULX2
// SM2.0: NOT SUPPORTED shader_feature _PARALLAXMAP
#pragma skip_variants SHADOWS_SOFT
#pragma vertex vertAdd
#pragma fragment fragAdd
#include "UnityStandardCoreForward.cginc"

Pass {
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
ZWrite On ZTest LEqual
CGPROGRAM

// This pass it not used during regular rendering.
Pass
{
Name "META"
Name "META"
Tags { "LightMode"="Meta" }
Cull Off

29
TestbedPipelines/OnTileDeferredPipeline/Shaders/StandardSpecular.shader


{
_Color("Color", Color) = (1,1,1,1)
_MainTex("Albedo", 2D) = "white" {}
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5

_EmissionColor("Color", Color) = (0,0,0)
_EmissionMap("Emission", 2D) = "white" {}
_DetailMask("Detail Mask", 2D) = "white" {}
_DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {}

}
CGINCLUDE
#include "OnTileCommon.hlsl"
#define UNITY_SETUP_BRDF_INPUT SpecularSetup
ENDCG

LOD 300
Pass
{
Name "FORWARD"

// Base forward pass (directional light, emission, lightmaps, ...)
Pass
{
Name "FORWARD"
Name "FORWARD"
Tags { "LightMode" = "ForwardBase" }
Blend [_SrcBlend] [_DstBlend]

// This pass it not used during regular rendering.
Pass
{
Name "META"
Name "META"
Tags { "LightMode"="Meta" }
Cull Off

// Base forward pass (directional light, emission, lightmaps, ...)
Pass
{
Name "FORWARD"
Name "FORWARD"
Tags { "LightMode" = "ForwardBase" }
Blend [_SrcBlend] [_DstBlend]

#pragma target 2.0
#pragma shader_feature _EMISSION
#pragma shader_feature _EMISSION
#pragma shader_feature _SPECGLOSSMAP
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF

#pragma skip_variants SHADOWS_SOFT DYNAMICLIGHTMAP_ON DIRLIGHTMAP_COMBINED
#pragma multi_compile_fwdbase
#pragma multi_compile_fog

Fog { Color (0,0,0,0) } // in additive pass fog should be black
ZWrite Off
ZTest LEqual
CGPROGRAM
#pragma target 2.0

#pragma shader_feature ___ _DETAIL_MULX2
// SM2.0: NOT SUPPORTED shader_feature _PARALLAXMAP
#pragma skip_variants SHADOWS_SOFT
#pragma vertex vertAdd
#pragma fragment fragAdd
#include "UnityStandardCoreForward.cginc"

Pass {
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
ZWrite On ZTest LEqual
CGPROGRAM

// This pass it not used during regular rendering.
Pass
{
Name "META"
Name "META"
Tags { "LightMode"="Meta" }
Cull Off

6
Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/Scenes/3xxx_DebugView/3002_ObjectMotionVector.unity


m_GameObject: {fileID: 12769659}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c413a5df32c4fec4eb320c4465678193, type: 3}
m_Script: {fileID: 11500000, guid: 9311bd511d7afc04b95779ad6b218383, type: 3}
m_Name:
m_EditorClassIdentifier:
localSpace: 0

m_GameObject: {fileID: 176131434}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c413a5df32c4fec4eb320c4465678193, type: 3}
m_Script: {fileID: 11500000, guid: 9311bd511d7afc04b95779ad6b218383, type: 3}
m_Name:
m_EditorClassIdentifier:
localSpace: 0

m_GameObject: {fileID: 1243403287}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c413a5df32c4fec4eb320c4465678193, type: 3}
m_Script: {fileID: 11500000, guid: 9311bd511d7afc04b95779ad6b218383, type: 3}
m_Name:
m_EditorClassIdentifier:
localSpace: 0

15
Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/Scenes/3xxx_DebugView/3003_CameraMotionVector_TranslateX.unity


m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientIntensity: 0
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}

m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_ReflectionIntensity: 0
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 0}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:

m_GameObject: {fileID: 340622392}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c413a5df32c4fec4eb320c4465678193, type: 3}
m_Script: {fileID: 11500000, guid: 9311bd511d7afc04b95779ad6b218383, type: 3}
frequency: 1
frequency: 5
fps: 60
--- !u!1 &382759167
GameObject:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 441482e8936e35048a1dffac814e3ef8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Profile: {fileID: 11400000, guid: 4d48fcc4780c115488c2c903f28b068e, type: 2}
m_Profile: {fileID: 0}
m_BakingSkyUniqueID: 1
--- !u!114 &382759169
MonoBehaviour:

priority: 0
blendDistance: 0
weight: 1
sharedProfile: {fileID: 11400000, guid: 4d48fcc4780c115488c2c903f28b068e, type: 2}
sharedProfile: {fileID: 0}
--- !u!4 &382759170
Transform:
m_ObjectHideFlags: 0

15
Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/Scenes/3xxx_DebugView/3004_CameraMotionVector_TranslateY.unity


m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientIntensity: 0
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}

m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_ReflectionIntensity: 0
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 0}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:

m_GameObject: {fileID: 340622392}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c413a5df32c4fec4eb320c4465678193, type: 3}
m_Script: {fileID: 11500000, guid: 9311bd511d7afc04b95779ad6b218383, type: 3}
frequency: 1
frequency: 5
fps: 60
--- !u!1 &382759167
GameObject:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 441482e8936e35048a1dffac814e3ef8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Profile: {fileID: 11400000, guid: 4d48fcc4780c115488c2c903f28b068e, type: 2}
m_Profile: {fileID: 0}
m_BakingSkyUniqueID: 1
--- !u!114 &382759169
MonoBehaviour:

priority: 0
blendDistance: 0
weight: 1
sharedProfile: {fileID: 11400000, guid: 4d48fcc4780c115488c2c903f28b068e, type: 2}
sharedProfile: {fileID: 0}
--- !u!4 &382759170
Transform:
m_ObjectHideFlags: 0

15
Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/Scenes/3xxx_DebugView/3005_CameraMotionVector_TranslateZ.unity


m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientIntensity: 0
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}

m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_ReflectionIntensity: 0
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 0}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:

m_GameObject: {fileID: 340622392}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c413a5df32c4fec4eb320c4465678193, type: 3}
m_Script: {fileID: 11500000, guid: 9311bd511d7afc04b95779ad6b218383, type: 3}
frequency: 1
frequency: 5
fps: 60
--- !u!1 &382759167
GameObject:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 441482e8936e35048a1dffac814e3ef8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Profile: {fileID: 11400000, guid: 4d48fcc4780c115488c2c903f28b068e, type: 2}
m_Profile: {fileID: 0}
m_BakingSkyUniqueID: 1
--- !u!114 &382759169
MonoBehaviour:

priority: 0
blendDistance: 0
weight: 1
sharedProfile: {fileID: 11400000, guid: 4d48fcc4780c115488c2c903f28b068e, type: 2}
sharedProfile: {fileID: 0}
--- !u!4 &382759170
Transform:
m_ObjectHideFlags: 0

50
TestbedPipelines/OnTileDeferredPipeline/Shaders/OnTileCommon.hlsl


// The function of the shader library are stateless, no uniform decalare in it.
// Any function that require an explicit precision, use float or half qualifier, when the function can support both, it use real (see below)
// If a function require to have both a half and a float version, then both need to be explicitly define
#ifndef real
#ifdef SHADER_API_MOBILE
#define real half
#define real2 half2
#define real3 half3
#define real4 half4
#define real2x2 half2x2
#define real2x3 half2x3
#define real3x2 half3x2
#define real3x3 half3x3
#define real3x4 half3x4
#define real4x3 half4x3
#define real4x4 half4x4
#define REAL_MIN HALF_MIN
#define REAL_MAX HALF_MAX
#define TEMPLATE_1_REAL TEMPLATE_1_HALF
#define TEMPLATE_2_REAL TEMPLATE_2_HALF
#define TEMPLATE_3_REAL TEMPLATE_3_HALF
#else
#define real float
#define real2 float2
#define real3 float3
#define real4 float4
#define real2x2 float2x2
#define real2x3 float2x3
#define real3x2 float3x2
#define real3x3 float3x3
#define real3x4 float3x4
#define real4x3 float4x3
#define real4x4 float4x4
#define REAL_MIN FLT_MIN
#define REAL_MAX FLT_MAX
#define TEMPLATE_1_REAL TEMPLATE_1_FLT
#define TEMPLATE_2_REAL TEMPLATE_2_FLT
#define TEMPLATE_3_REAL TEMPLATE_3_FLT
#endif // SHADER_API_MOBILE
#endif // #ifndef real

9
TestbedPipelines/OnTileDeferredPipeline/Shaders/OnTileCommon.hlsl.meta


fileFormatVersion: 2
guid: 0d2d72d5a6eba1946bf9fd0737251cd4
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

40
TestbedPipelines/OnTileDeferredPipeline/Shaders/Shadow.hlsl


#ifndef FPTL_SHADOW_HLSL
#define FPTL_SHADOW_HLSL
#define SHADOW_DISPATCH_USE_CUSTOM_PUNCTUAL // Define this to provide custom implementations of GetPunctualShadowAttenuation
#define SHADOW_DISPATCH_USE_CUSTOM_DIRECTIONAL // Define this to provide custom implementations of GetDirectionalShadowAttenuation
#include "ShadowContext.hlsl"
#ifdef SHADOW_DISPATCH_USE_CUSTOM_DIRECTIONAL
float GetDirectionalShadowAttenuation( ShadowContext shadowContext, float3 positionWS, float3 normalWS, int shadowDataIndex, float3 L )
{
Texture2DArray tex = shadowContext.tex2DArray[0];
SamplerComparisonState compSamp = shadowContext.compSamplers[0];
uint algo = GPUSHADOWALGORITHM_PCF_9TAP;
return EvalShadow_CascadedDepth_Blend( shadowContext, algo, tex, compSamp, positionWS, normalWS, shadowDataIndex, L );
}
float GetDirectionalShadowAttenuation( ShadowContext shadowContext, float3 positionWS, float3 normalWS, int shadowDataIndex, float3 L, float2 unPositionSS )
{
return GetDirectionalShadowAttenuation( shadowContext, positionWS, normalWS, shadowDataIndex, L );
}
#endif
#ifdef SHADOW_DISPATCH_USE_CUSTOM_PUNCTUAL
float GetPunctualShadowAttenuation( ShadowContext shadowContext, float3 positionWS, float3 normalWS, int shadowDataIndex, float4 L )
{
// example for choosing the same algo
Texture2DArray tex = shadowContext.tex2DArray[0];
SamplerComparisonState compSamp = shadowContext.compSamplers[0];
uint algo = GPUSHADOWALGORITHM_PCF_9TAP;
return EvalShadow_PunctualDepth( shadowContext, algo, tex, compSamp, positionWS, normalWS, shadowDataIndex, L );
}
float GetPunctualShadowAttenuation( ShadowContext shadowContext, float3 positionWS, float3 normalWS, int shadowDataIndex, float4 L, float2 unPositionSS )
{
return GetPunctualShadowAttenuation( shadowContext, positionWS, normalWS, shadowDataIndex, L );
}
#endif
#endif // FPTL_SHADOW_HLSL

9
TestbedPipelines/OnTileDeferredPipeline/Shaders/Shadow.hlsl.meta


fileFormatVersion: 2
guid: f4991b12b26eeeb49ba0f3fbadeec148
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存