浏览代码

Merge branch 'master' into metal-ios

/fptl_cleanup
Antti Tapaninen 8 年前
当前提交
101239a7
共有 25 个文件被更改,包括 307 次插入110 次删除
  1. 14
      Assets/LowEndMobilePipeline/TestScenes/LDRenderPipelineBasicScene/LightingData.asset
  2. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/Resources/DebugViewMaterialGBuffer.shader
  3. 5
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/Resources/Deferred.shader
  4. 34
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/FeatureFlags.hlsl
  5. 39
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild.compute
  6. 18
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Resources/shadeopaque.compute
  7. 43
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  8. 16
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs.hlsl
  9. 10
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePassLoop.hlsl
  10. 5
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePassProducer.asset
  11. 10
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs
  12. 9
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs.hlsl
  13. 153
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  14. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/CombineSubsurfaceScattering.shader
  15. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/SubsurfaceScatteringProfile.cs
  16. 13
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Material.hlsl
  17. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl
  18. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassDistortion.hlsl
  19. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl
  20. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl
  21. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl
  22. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassVelocity.hlsl
  23. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader
  24. 21
      Assets/ScriptableRenderPipeline/ShaderLibrary/BSDF.hlsl
  25. 5
      Assets/ScriptableRenderPipeline/ShaderLibrary/Common.hlsl

14
Assets/LowEndMobilePipeline/TestScenes/LDRenderPipelineBasicScene/LightingData.asset


1;�1 2017.1.0a3������:'���BIr���:�b���7���������� �� ��".�+���� ��".�+H��������1�1����� @���
Q�j� 4C���� Je���� ��z����1�1���������j�P��������������������������0���� �� ������ ��!��!"��%#��)$��-%��1&��5����'1�1�����(���)��j� * ��@+ ��B, ��D- ��F����.1�1�����/���0Rj�1`h2��o3��x4���5���6���7���8���9���:���;���<���=���>���?���@���A���B��C��D������E1�1�����F���G��j� H ��@I ��BJ ��DK ��!����L1�1�����M���N�j�O`��P��oQ��xR���S���T���U���V���W���X���Y���Z���[���\���]���^���_���`��
�a��F����b1�1�����c���dZj�le��of��vg��}h���i���j���k���l���m���n���o���p���q���r���s���t���u���v���w���x���y���z��{�� |��}��~����%���,�����1�1����������Bj������;�V�����1�1������������j��;�q�����1�1������������j��;�}�����1�1����������5�j��LightProbesPPtr<EditorExtension>m_FileIDm_PathIDLightProbeDatam_DataProbeSetTetrahedralizationm_Tetrahedralizationm_TetrahedraTetrahedronindices[0]indices[1]indices[2]indices[3]neighbors[0]neighbors[1]neighbors[2]neighbors[3]Matrix3x4fmatrixe00e01e02e03e10e11e12e13e20e21e22e23m_HullRaysxyzm_ProbeSetsProbeSetIndexHash128m_Hashbytes[0]bytes[1]bytes[2]bytes[3]bytes[4]bytes[5]bytes[6]bytes[7]bytes[8]bytes[9]bytes[10]bytes[11]bytes[12]bytes[13]bytes[14]bytes[15]m_Offsetm_Sizem_Positionsm_NonTetrahedralizedProbeSetIndexMapm_BakedCoefficientsSphericalHarmonicsL2sh[ 0]sh[ 1]sh[ 2]sh[ 3]sh[ 4]sh[ 5]sh[ 6]sh[ 7]sh[ 8]sh[ 9]sh[10]sh[11]sh[12]sh[13]sh[14]sh[15]sh[16]sh[17]sh[18]sh[19]sh[20]sh[21]sh[22]sh[23]sh[24]sh[25]sh[26]m_BakedLightOcclusionLightProbeOcclusionm_ProbeOcclusionLightIndexm_Occlusionm_OcclusionMaskChannel`���-�G�2��(����1� �7������������ ��(.�1���� ��(.�1H��������1�1����� @���
Q�j� ��:���� 1�1����� ���Fj�$��S ��(.�1��^ ��(.�1��l ��(.�1y� ��(.�1�����l��������� ���!���"���#��$�� %��&��'�� (��')��.*��5+��<,��C-��J.��Q/��X0��_1��f2��m3��t4��{5���6���7���8�������91�1�����:���;�j�P<�� =��(>.�1?���@ ���A ���B ���C ���D ���E ���F ���G ���H ���I ��J��K��&L ���M ���N ���O ���P ��1Q ���R ���S ���T ���U ��C����V1�1�����W���X`j�Y.�vZ.��[������\�������]1�1�����^���_�j�@`y�� a��(b.�1c���d ���e ���f ���g ���h ��
ij��(k��1l��:m��Cn��Lo��Up��^q��gr��ps��yt���u���v���w���x���y���z�{���(|���1}���:~���C���L����U����^����g����p����y����������������������������������������1�1�����������j�4����������� ������#�0���(���1���:���C���L���U���^���g���p���y�������������������������@���(���1���:���C���L���U���^���g���p���y���������������������������T�����1�1����������j����(���1���:���C���L���U���^���g���p���y���������������������������`�����1�1����������pj����������(���1���:���C���L���U���^���g���p���y�������������������������������������1�1�����������j� ���������������������1�1����������`j��.�v�.�����!�����1�1����������`j��.�v�.�����*�����1�1����������?j� ���Q���j������������1�1������������j� ���(.�1�������1�1��������`j�.�v.����������1�1����� @���
��j� ��� LightingDataAssetPPtr<EditorExtension>m_FileIDm_PathIDm_LightmapsLightmapDatam_Lightmapm_DirLightmapm_ShadowMaskPPtr<LightProbes>m_LightProbesm_LightmapsModeSphericalHarmonicsL2m_BakedAmbientProbeInLinearsh[ 0]sh[ 1]sh[ 2]sh[ 3]sh[ 4]sh[ 5]sh[ 6]sh[ 7]sh[ 8]sh[ 9]sh[10]sh[11]sh[12]sh[13]sh[14]sh[15]sh[16]sh[17]sh[18]sh[19]sh[20]sh[21]sh[22]sh[23]sh[24]sh[25]sh[26]m_LightmappedRendererDataRendererDataPPtr<Mesh>uvMeshterrainDynamicUVSTxyzwterrainChunkDynamicUVSTlightmapIndexlightmapIndexDynamiclightmapSTlightmapSTDynamicm_LightmappedRendererDataIDsSceneObjectIdentifiertargetObjecttargetPrefabEnlightenSceneMappingm_EnlightenSceneMappingm_RenderersEnlightenRendererInformationrendererdynamicLightmapSTInSystemsystemIdHash128instanceHashbytes[0]bytes[1]bytes[2]bytes[3]bytes[4]bytes[5]bytes[6]bytes[7]bytes[8]bytes[9]bytes[10]bytes[11]bytes[12]bytes[13]bytes[14]bytes[15]geometryHashm_SystemsEnlightenSystemInformationrendererIndexrendererSizeatlasIndexatlasOffsetXatlasOffsetYinputSystemHashradiositySystemHashm_Probesetsm_SystemAtlasesEnlightenSystemAtlasInformationatlasSizeatlasHashfirstSystemIdm_TerrainChunksEnlightenTerrainChunksInformationnumChunksInXnumChunksInYm_EnlightenSceneMappingRendererIDsm_Lightsm_LightBakingOutputsLightBakingOutputprobeOcclusionLightIndexocclusionMaskChannellightmappingMaskm_BakedReflectionProbeCubemapsm_BakedReflectionProbesm_EnlightenDatam_EnlightenDataVersion@��H��H@
<'��S��I�3�UO�-1�ʭ�G��A��R�@ LightingDataLightingDataAsset��*@��v�;>l����<���d���R�;NAV<$��q��<�Fh>$�*=��i<��5P��K�1<�L�<�����%=�ߖ>�/�=��<d��� 9L��x�<��<�B5�tC=�?�?�?�?��G>G>J>�?�?�?�?�?�?����+=��+=@I?�?�?�?�?�?�?��H>H>�?�?�?�?�?�?��G>G>I>J?�?�?�?�?�?�?��G>G>��>�?�?�?�?�?�?����+=��+=>@I?�?�?�?�?�?�?��H>H>I>�?�?�?�?�?�?�?���O>�O>!�?�(I>�?�?�?�?�?�?����+=��+=�=@I?�?�?�?�?�?�?��[+`=[+`=h=nlk?�?�?�?�?�?�?��G>G>��>J>�?�?�?�?�?�?����+=��+=4=@I?�?�?�?�?�?�?��H>H>I>J>�?�?�?�?�?�?��H>H>�>�?�?�?�?�?�?��H>H>J>�?�?�?�?�?�?��H>H>I>�>�?�?�?�?�?�?��G>G>?�?�?�?�?�?�?��H>H>�?�?�?�?�?�?�?��G>G>J?�?�?�?�?�?�?��[+`=[+`=�=nlk?�?�?�?�?�?�?��D1!>D1!>�\'���P?�?�?�?�?�?�?��[+`=[+`=nlk?�?�?O��C��RdG�z���d��5=\(_F�.dEKP�wCh�44fR �e�ZY OL�v�*��� �����)� a)F{~mp�J5�V�V�X��J�BnQ\�eV?$�b���q�S�x�������������������������͇;UnityFS5.x.x2017.1.0a3;
1;�1 2017.1.0b1�������Ƣ��^Ee��c���_��7���������� �� ��".�+���� ��".�+H��������1�1����� @���
Q�j� 4C���� �Je���� ���z�����1�1�����@����j�P��������������������������0���� �� ������ ��!��!"��%#��)$��-%��1&��5����'�1�1�����(@���)��j� * ��@+ ��B, ��D- ��F����.�1�1�����/@���0Rj�1`h2��o3��x4���5���6���7���8���9���:���;���<���=���>���?���@���A���B��C��D������E�1�1�����F@���G��j� H ��@I ��BJ ��DK ��!����L1�1�����M���N�j�O`��P��oQ��xR���S���T���U���V���W���X���Y���Z���[���\���]���^���_���`��
�a��F����b�1�1�����c@���dZj�le��of��vg��}h���i���j���k���l���m���n���o���p���q���r���s���t���u���v���w���x���y���z��{�� |��}��~����%���,������1�1������@����Bj������;�V�����1�1������������j��;�q�����1�1������������j��;�}�����1�1����������5�j��LightProbesPPtr<EditorExtension>m_FileIDm_PathIDLightProbeDatam_DataProbeSetTetrahedralizationm_Tetrahedralizationm_TetrahedraTetrahedronindices[0]indices[1]indices[2]indices[3]neighbors[0]neighbors[1]neighbors[2]neighbors[3]Matrix3x4fmatrixe00e01e02e03e10e11e12e13e20e21e22e23m_HullRaysxyzm_ProbeSetsProbeSetIndexHash128m_Hashbytes[0]bytes[1]bytes[2]bytes[3]bytes[4]bytes[5]bytes[6]bytes[7]bytes[8]bytes[9]bytes[10]bytes[11]bytes[12]bytes[13]bytes[14]bytes[15]m_Offsetm_Sizem_Positionsm_NonTetrahedralizedProbeSetIndexMapm_BakedCoefficientsSphericalHarmonicsL2sh[ 0]sh[ 1]sh[ 2]sh[ 3]sh[ 4]sh[ 5]sh[ 6]sh[ 7]sh[ 8]sh[ 9]sh[10]sh[11]sh[12]sh[13]sh[14]sh[15]sh[16]sh[17]sh[18]sh[19]sh[20]sh[21]sh[22]sh[23]sh[24]sh[25]sh[26]m_BakedLightOcclusionLightProbeOcclusionm_ProbeOcclusionLightIndexm_Occlusionm_OcclusionMaskChannel`�����/�:�AI�I F� �7������������ ��(.�1���� ��(.�1H��������1�1����� @���
Q�j� ��:���� �1�1����� @���Fj�$��S ��(.�1��^ ��(.�1��l ��(.�1y� ��(.�1�����l��������� ���!���"���#��$�� %��&��'�� (��')��.*��5+��<,��C-��J.��Q/��X0��_1��f2��m3��t4��{5���6���7���8�������9�1�1�����:@���;�j�P<�� =��(>.�1?���@ ���A ���B ���C ���D ���E ���F ���G ���H ���I ��J��K��&L ���M ���N ���O ���P ��1Q ���R ���S ���T ���U ��C����V�1�1�����W@���X`j�Y.�vZ.��[������\��������]�1�1�����^@���_�j�@`y�� a��(b.�1c���d ���e ���f ���g ���h ��
ij��(k��1l��:m��Cn��Lo��Up��^q��gr��ps��yt���u���v���w���x���y���z�{���(|���1}���:~���C���L����U����^����g����p����y�����������������������������������������1�1������@�����j�4����������� ������#�0���(���1���:���C���L���U���^���g���p���y�������������������������@���(���1���:���C���L���U���^���g���p���y���������������������������T������1�1������@����j����(���1���:���C���L���U���^���g���p���y���������������������������`������1�1������@����pj����������(���1���:���C���L���U���^���g���p���y��������������������������������������1�1������@�����j� ����������������������1�1������@����`j��.�v�.�����!������1�1������@����`j��.�v�.�����*������1�1������@����?j� ���Q���j�������������1�1������@������j� ���(.�1��������1�1�����@���`j�.�v.����������1�1����� @���
��j� ��� LightingDataAssetPPtr<EditorExtension>m_FileIDm_PathIDm_LightmapsLightmapDatam_Lightmapm_DirLightmapm_ShadowMaskPPtr<LightProbes>m_LightProbesm_LightmapsModeSphericalHarmonicsL2m_BakedAmbientProbeInLinearsh[ 0]sh[ 1]sh[ 2]sh[ 3]sh[ 4]sh[ 5]sh[ 6]sh[ 7]sh[ 8]sh[ 9]sh[10]sh[11]sh[12]sh[13]sh[14]sh[15]sh[16]sh[17]sh[18]sh[19]sh[20]sh[21]sh[22]sh[23]sh[24]sh[25]sh[26]m_LightmappedRendererDataRendererDataPPtr<Mesh>uvMeshterrainDynamicUVSTxyzwterrainChunkDynamicUVSTlightmapIndexlightmapIndexDynamiclightmapSTlightmapSTDynamicm_LightmappedRendererDataIDsSceneObjectIdentifiertargetObjecttargetPrefabEnlightenSceneMappingm_EnlightenSceneMappingm_RenderersEnlightenRendererInformationrendererdynamicLightmapSTInSystemsystemIdHash128instanceHashbytes[0]bytes[1]bytes[2]bytes[3]bytes[4]bytes[5]bytes[6]bytes[7]bytes[8]bytes[9]bytes[10]bytes[11]bytes[12]bytes[13]bytes[14]bytes[15]geometryHashm_SystemsEnlightenSystemInformationrendererIndexrendererSizeatlasIndexatlasOffsetXatlasOffsetYinputSystemHashradiositySystemHashm_Probesetsm_SystemAtlasesEnlightenSystemAtlasInformationatlasSizeatlasHashfirstSystemIdm_TerrainChunksEnlightenTerrainChunksInformationnumChunksInXnumChunksInYm_EnlightenSceneMappingRendererIDsm_Lightsm_LightBakingOutputsLightBakingOutputprobeOcclusionLightIndexocclusionMaskChannellightmappingMaskm_BakedReflectionProbeCubemapsm_BakedReflectionProbesm_EnlightenDatam_EnlightenDataVersion@��H��H8
<'��S��I�3�UO�-1�ʭ�G��A��R�@ LightingData LightingData��*@��v�;>l����<���d���R�;NAV<$��q��<�Fh>$�*=��i<��5P��K�1<�L�<�����%=�ߖ>�/�=��<d��� 9L��x�<��<�B5�tC=�?�?�?�?��G>G>J>�?�?�?�?�?�?����+=��+=@I?�?�?�?�?�?�?��H>H>�?�?�?�?�?�?��G>G>I>J?�?�?�?�?�?�?��G>G>��>�?�?�?�?�?�?����+=��+=>@I?�?�?�?�?�?�?��H>H>I>�?�?�?�?�?�?�?���O>�O>!�?�(I>�?�?�?�?�?�?����+=��+=�=@I?�?�?�?�?�?�?��[+`=[+`=h=nlk?�?�?�?�?�?�?��G>G>��>J>�?�?�?�?�?�?����+=��+=4=@I?�?�?�?�?�?�?��H>H>I>J>�?�?�?�?�?�?��H>H>�>�?�?�?�?�?�?��H>H>J>�?�?�?�?�?�?��H>H>I>�>�?�?�?�?�?�?��G>G>?�?�?�?�?�?�?��H>H>�?�?�?�?�?�?�?��G>G>J?�?�?�?�?�?�?��[+`=[+`=�=nlk?�?�?�?�?�?�?��D1!>D1!>�\'���P?�?�?�?�?�?�?��[+`=[+`=nlk?�?�?O��C��RdG�z���d��5=\(_F�.dEKP�wCh�44fR �e�ZY OL�v�*��� �����)� a)F{~mp�J5�V�V�X��J�BnQ\�eV?$�b���q�S�x�������������������������͇;UnityFS5.x.x2017.1.0a3;
�Pk

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/Resources/DebugViewMaterialGBuffer.shader


float4 Frag(Varyings input) : SV_Target
{
// input.positionCS is SV_Position
PositionInputs posInput = GetPositionInput(input.positionCS.xy, _ScreenSize.zw, uint2(0, 0));
PositionInputs posInput = GetPositionInput(input.positionCS.xy, _ScreenSize.zw);
float depth = LOAD_TEXTURE2D(_MainDepthTexture, posInput.unPositionSS).x;
UpdatePositionInput(depth, _InvViewProjMatrix, _ViewProjMatrix, posInput);

DECODE_FROM_GBUFFER(gbuffer, bsdfData, bakeDiffuseLighting);
DECODE_FROM_GBUFFER(gbuffer, 0xFFFFFFFF, bsdfData, bakeDiffuseLighting);
// Init to not expected value
float3 result = float3(-666.0, 0.0, 0.0);

5
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/Resources/Deferred.shader


UpdatePositionInput(depth, _InvViewProjMatrix, _ViewProjMatrix, posInput);
float3 V = GetWorldSpaceNormalizeViewDir(posInput.positionWS);
uint featureFlags = 0xFFFFFFFF;
DECODE_FROM_GBUFFER(gbuffer, bsdfData, bakeDiffuseLighting);
DECODE_FROM_GBUFFER(gbuffer, featureFlags, bsdfData, bakeDiffuseLighting);
uint featureFlags = 0xFFFFFFFF;
float3 diffuseLighting;
float3 specularLighting;
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, featureFlags, diffuseLighting, specularLighting);

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


#ifndef __FEATURE_FLAGS_H__
#define __FEATURE_FLAGS_H__
#include "TilePass.cs.hlsl"
static const uint FEATURE_FLAG_ALL_MATERIALS = FEATURE_FLAG_MATERIAL_LIT_STANDARD | FEATURE_FLAG_MATERIAL_LIT_SSS | FEATURE_FLAG_MATERIAL_LIT_CLEAR_COAT | FEATURE_FLAG_MATERIAL_LIT_SPECULAR | FEATURE_FLAG_MATERIAL_LIT_ANISO;
/* 0 */ 0,
/* 1 */ FEATURE_FLAG_SKY_LIGHT | FEATURE_FLAG_DIRECTIONAL_LIGHT,
/* 2 */ FEATURE_FLAG_SKY_LIGHT | FEATURE_FLAG_DIRECTIONAL_LIGHT | FEATURE_FLAG_ENV_LIGHT,
/* 3 */ FEATURE_FLAG_SKY_LIGHT | FEATURE_FLAG_DIRECTIONAL_LIGHT | FEATURE_FLAG_PUNCTUAL_LIGHT,
/* 3 */ FEATURE_FLAG_SKY_LIGHT | FEATURE_FLAG_DIRECTIONAL_LIGHT | FEATURE_FLAG_PUNCTUAL_LIGHT | FEATURE_FLAG_ENV_LIGHT,
/* 5 */ FEATURE_FLAG_SKY_LIGHT | FEATURE_FLAG_DIRECTIONAL_LIGHT | FEATURE_FLAG_AREA_LIGHT,
/* 6 */ FEATURE_FLAG_SKY_LIGHT | FEATURE_FLAG_DIRECTIONAL_LIGHT | FEATURE_FLAG_AREA_LIGHT | FEATURE_FLAG_PUNCTUAL_LIGHT | FEATURE_FLAG_ENV_LIGHT,
/* 7 */ 0xFFFFFFFF,
/* 0 */ 0 | FEATURE_FLAG_ALL_MATERIALS,
/* 1 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_MATERIAL_LIT_STANDARD,
/* 2 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_ENV | FEATURE_FLAG_MATERIAL_LIT_STANDARD,
/* 3 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_PUNCTUAL | FEATURE_FLAG_MATERIAL_LIT_STANDARD,
/* 3 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_PUNCTUAL | FEATURE_FLAG_LIGHT_ENV | FEATURE_FLAG_MATERIAL_LIT_STANDARD,
/* 5 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_AREA | FEATURE_FLAG_MATERIAL_LIT_STANDARD,
/* 6 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_AREA | FEATURE_FLAG_LIGHT_PUNCTUAL | FEATURE_FLAG_LIGHT_ENV | FEATURE_FLAG_MATERIAL_LIT_STANDARD,
/* 7 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_ALL_MATERIALS,
/* 8 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_ENV | FEATURE_FLAG_ALL_MATERIALS,
/* 9 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_PUNCTUAL | FEATURE_FLAG_ALL_MATERIALS,
/*10 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_PUNCTUAL | FEATURE_FLAG_LIGHT_ENV | FEATURE_FLAG_ALL_MATERIALS,
/*11 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_AREA | FEATURE_FLAG_ALL_MATERIALS,
/*12 */ FEATURE_FLAG_LIGHT_SKY | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_AREA | FEATURE_FLAG_LIGHT_PUNCTUAL | FEATURE_FLAG_LIGHT_ENV | FEATURE_FLAG_ALL_MATERIALS,
/*13 */ 0xFFFFFFFF,
/*14 */ 0xFFFFFFFF,
/*15 */ 0xFFFFFFFF,
/*
public static uint FEATURE_FLAG_PUNCTUAL_LIGHT = 1<<0;
public static uint FEATURE_FLAG_AREA_LIGHT = 1<<1;
public static uint FEATURE_FLAG_DIRECTIONAL_LIGHT = 1<<2;
public static uint FEATURE_FLAG_ENV_LIGHT = 1<<3;
public static uint FEATURE_FLAG_SKY_LIGHT = 1<<4;
*/
uint FeatureFlagsToTileVariant(uint featureFlags)
{

39
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild.compute


#include "../ShaderBase.hlsl"
#include "../TilePass.cs.hlsl"
#include "../LightingConvexHullUtils.hlsl"
#include "../FeatureFlags.hlsl"
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
#include "../../../Material/Material.hlsl" // This include Material.hlsl
#include "../FeatureFlags.hlsl"
#define USE_MATERIAL_FEATURE_FLAGS
uniform int g_iNrVisibLights;
uniform uint2 g_viDimensions;

groupshared uint ldsFeatureFlags;
RWBuffer<uint> g_DispatchIndirectBuffer;
RWStructuredBuffer<uint> g_TileList;
#ifdef USE_MATERIAL_FEATURE_FLAGS
DECLARE_GBUFFER_TEXTURE(_GBufferTexture);
#endif
#endif

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

iNrCoarseLights = SphericalIntersectionTests( t, iNrCoarseLights, float2(min(viTilLL.xy+uint2(16/2,16/2), uint2(iWidth-1, iHeight-1))) );
#endif
#ifndef FINE_PRUNING_ENABLED
#ifndef FINE_PRUNING_ENABLED
{
if((int)t<iNrCoarseLights) prunedList[t] = coarseList[t];
if(t==0) ldsNrLightsFinal=iNrCoarseLights;

#endif
#ifdef USE_FEATURE_FLAGS
#ifdef USE_MATERIAL_FEATURE_FLAGS
float2 invScreenSize = float2(1.0f / iWidth, 1.0f / iHeight);
uint materialFeatureFlags = 0;
{
[unroll]
for(int i = 0; i < 4; i++)
{
int idx = i * NR_THREADS + t;
uint2 uCrd = min(uint2(viTilLL.x + (idx & 0xf), viTilLL.y + (idx >> 4)), uint2(iWidth - 1, iHeight - 1));
if(FetchDepth(g_depth_tex, uCrd) < VIEWPORT_SCALE_Z) // if not skydome. //TODO: reuse depths from before
{
PositionInputs posInput = GetPositionInput(uCrd, invScreenSize);
FETCH_GBUFFER(gbuffer, _GBufferTexture, posInput.unPositionSS);
materialFeatureFlags |= MATERIAL_FEATURE_FLAGS_FROM_GBUFFER(gbuffer);
}
}
}
InterlockedOr(ldsFeatureFlags, materialFeatureFlags); //TODO: driver might optimize this or we might have to do a manual reduction
GroupMemoryBarrierWithGroupSync();
#else
uint materialFeatureFlags = 0xFFFFF000;
#endif
featureFlags &= ~(FEATURE_FLAG_PUNCTUAL_LIGHT | FEATURE_FLAG_AREA_LIGHT | FEATURE_FLAG_DIRECTIONAL_LIGHT | FEATURE_FLAG_ENV_LIGHT); // list of features that are not enabled on background
featureFlags &= ~(FEATURE_FLAG_LIGHT_PUNCTUAL | FEATURE_FLAG_LIGHT_AREA | FEATURE_FLAG_LIGHT_DIRECTIONAL | FEATURE_FLAG_LIGHT_ENV | 0xFFFFF); // list of features that are not enabled on background
}
uint variant = FeatureFlagsToTileVariant(featureFlags);

18
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Resources/shadeopaque.compute


#pragma kernel ShadeOpaque_Indirect_Fptl_Variant5 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant5 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=5
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant6 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant6 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=6
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant7 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant7 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=7
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant8 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant8 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=8
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant9 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant9 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=9
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant10 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant10 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=10
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant11 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant11 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=11
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant12 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant12 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=12
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant13 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant13 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=13
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant14 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant14 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=14
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant15 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant15 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=15
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant0 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant0 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=0
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant1 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant1 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=1

#pragma kernel ShadeOpaque_Indirect_Clustered_Variant5 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant5 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=5
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant6 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant6 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=6
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant7 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant7 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=7
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant8 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant8 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=8
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant9 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant9 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=9
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant10 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant10 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=10
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant11 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant11 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=11
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant12 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant12 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=12
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant13 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant13 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=13
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant14 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant14 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=14
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant15 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant15 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=15
#pragma #pragma enable_d3d11_debug_symbols

FETCH_GBUFFER(gbuffer, _GBufferTexture, posInput.unPositionSS);
BSDFData bsdfData;
float3 bakeDiffuseLighting;
DECODE_FROM_GBUFFER(gbuffer, bsdfData, bakeDiffuseLighting);
DECODE_FROM_GBUFFER(gbuffer, featureFlags, bsdfData, bakeDiffuseLighting);
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);

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


}
[GenerateHLSL]
public class LightFeatureFlags
{
public static uint FEATURE_FLAG_LIGHT_PUNCTUAL = 1 << 0;
public static uint FEATURE_FLAG_LIGHT_AREA = 1 << 1;
public static uint FEATURE_FLAG_LIGHT_DIRECTIONAL = 1 << 2;
public static uint FEATURE_FLAG_LIGHT_ENV = 1 << 3;
public static uint FEATURE_FLAG_LIGHT_SKY = 1 << 4;
}
[GenerateHLSL]
public class LightDefinitions
{
public static int MAX_NR_LIGHTS_PER_CAMERA = 1024;

public static int IS_BOX_PROJECTED = 4;
public static int HAS_SHADOW = 8;
// feature flags
public static uint FEATURE_FLAG_PUNCTUAL_LIGHT = 1 << 0;
public static uint FEATURE_FLAG_AREA_LIGHT = 1 << 1;
public static uint FEATURE_FLAG_DIRECTIONAL_LIGHT = 1 << 2;
public static uint FEATURE_FLAG_ENV_LIGHT = 1 << 3;
public static uint FEATURE_FLAG_SKY_LIGHT = 1 << 4;
public static int NUM_FEATURE_VARIANTS = 8;
public static int NUM_FEATURE_VARIANTS = 16;
}
[GenerateHLSL]

bool GetFeatureVariantsEnabled()
{
return m_PassSettings.enableComputeLightEvaluation && m_PassSettings.enableComputeFeatureVariants;
return m_PassSettings.enableComputeLightEvaluation && m_PassSettings.enableComputeFeatureVariants && !(m_PassSettings.enableClustered && !m_PassSettings.enableFptlForOpaqueWhenClustered);
}
TileLightLoopProducer.TileSettings m_PassSettings;

lightVolumeData.lightPos = worldToView.MultiplyPoint(lightPos);
lightVolumeData.radiusSq = range * range;
lightVolumeData.cotan = cota;
lightVolumeData.featureFlags = LightDefinitions.FEATURE_FLAG_PUNCTUAL_LIGHT;
lightVolumeData.featureFlags = LightFeatureFlags.FEATURE_FLAG_LIGHT_PUNCTUAL;
}
else if (gpuLightType == GPULightType.Point)
{

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

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

lightVolumeData.lightAxisZ = zAxisVS;
lightVolumeData.boxInnerDist = new Vector3(lightData.size.x * 0.5f, 0.01f, 0.01f);
lightVolumeData.boxInvRange.Set(1.0f / radius, 1.0f / radius, 1.0f / radius);
lightVolumeData.featureFlags = LightDefinitions.FEATURE_FLAG_AREA_LIGHT;
lightVolumeData.featureFlags = LightFeatureFlags.FEATURE_FLAG_LIGHT_AREA;
}
else
{

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

var invProjscr = projscr.inverse;
var cmd = new CommandBuffer() { name = "" };
cmd.SetRenderTarget(new RenderTargetIdentifier((Texture)null));
// generate screen-space AABBs (used for both fptl and clustered).
if (m_lightCount != 0)

if (m_PassSettings.enableBigTilePrepass)
cmd.SetComputeBufferParam(buildPerTileLightListShader, s_GenListPerTileKernel, "g_vBigTileLightList", s_BigTileLightList);
cmd.SetComputeTextureParam(buildPerTileLightListShader, s_GenListPerTileKernel, "_GBufferTexture0", Shader.PropertyToID("_GBufferTexture0"));
cmd.SetComputeTextureParam(buildPerTileLightListShader, s_GenListPerTileKernel, "_GBufferTexture1", Shader.PropertyToID("_GBufferTexture1"));
cmd.SetComputeTextureParam(buildPerTileLightListShader, s_GenListPerTileKernel, "_GBufferTexture2", Shader.PropertyToID("_GBufferTexture2"));
cmd.SetComputeTextureParam(buildPerTileLightListShader, s_GenListPerTileKernel, "_GBufferTexture3", Shader.PropertyToID("_GBufferTexture3"));
baseFeatureFlags |= LightDefinitions.FEATURE_FLAG_DIRECTIONAL_LIGHT;
baseFeatureFlags |= LightFeatureFlags.FEATURE_FLAG_LIGHT_DIRECTIONAL;
baseFeatureFlags |= LightDefinitions.FEATURE_FLAG_SKY_LIGHT;
baseFeatureFlags |= LightFeatureFlags.FEATURE_FLAG_LIGHT_SKY;
}
cmd.SetComputeBufferParam(buildPerTileLightListShader, s_GenListPerTileKernel, "g_DispatchIndirectBuffer", s_DispatchIndirectBuffer);
cmd.SetComputeBufferParam(buildPerTileLightListShader, s_GenListPerTileKernel, "g_TileList", s_TileList);

cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_GBufferTexture1", Shader.PropertyToID("_GBufferTexture1"));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_GBufferTexture2", Shader.PropertyToID("_GBufferTexture2"));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_GBufferTexture3", Shader.PropertyToID("_GBufferTexture3"));
//cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_GBufferTexture4", Shader.PropertyToID("_GBufferTexture4"));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "g_tShadowBuffer", Shader.PropertyToID("g_tShadowBuffer"));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_LtcData", Shader.GetGlobalTexture(Shader.PropertyToID("_LtcData")));

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


#define LIGHTCATEGORY_COUNT (3)
//
// UnityEngine.Experimental.Rendering.HDPipeline.TilePass.LightFeatureFlags: static fields
//
#define FEATURE_FLAG_LIGHT_PUNCTUAL (1)
#define FEATURE_FLAG_LIGHT_AREA (2)
#define FEATURE_FLAG_LIGHT_DIRECTIONAL (4)
#define FEATURE_FLAG_LIGHT_ENV (8)
#define FEATURE_FLAG_LIGHT_SKY (16)
//
// UnityEngine.Experimental.Rendering.HDPipeline.TilePass.LightDefinitions: static fields
//
#define MAX_NR_LIGHTS_PER_CAMERA (1024)

#define HAS_COOKIE_TEXTURE (2)
#define IS_BOX_PROJECTED (4)
#define HAS_SHADOW (8)
#define FEATURE_FLAG_PUNCTUAL_LIGHT (1)
#define FEATURE_FLAG_AREA_LIGHT (2)
#define FEATURE_FLAG_DIRECTIONAL_LIGHT (4)
#define FEATURE_FLAG_ENV_LIGHT (8)
#define FEATURE_FLAG_SKY_LIGHT (16)
#define NUM_FEATURE_VARIANTS (8)
#define NUM_FEATURE_VARIANTS (16)
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.TilePass.SFiniteLightBound
// PackingRules = Exact

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


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

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

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

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

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

5
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePassProducer.asset


m_TileSettings:
enableTileAndCluster: 1
enableSplitLightEvaluation: 1
enableComputeLightEvaluation: 0
debugViewTilesFlags: 0
enableComputeLightEvaluation: 1
enableComputeFeatureVariants: 1
tileDebugByCategory: 0
m_PassResources: {fileID: 11400000, guid: 7f2998544b2ac3848822b80ec3e6c446, type: 2}

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


LitAniso = 4 // Should be the last as it is not setup by the users but generated based on anisotropy property
};
[GenerateHLSL]
public class MaterialFeatureFlags
{
public static uint FEATURE_FLAG_MATERIAL_LIT_STANDARD = 1 << 12;
public static uint FEATURE_FLAG_MATERIAL_LIT_SSS = 1 << 13;
public static uint FEATURE_FLAG_MATERIAL_LIT_CLEAR_COAT = 1 << 14;
public static uint FEATURE_FLAG_MATERIAL_LIT_SPECULAR = 1 << 15;
public static uint FEATURE_FLAG_MATERIAL_LIT_ANISO = 1 << 16;
}
//-----------------------------------------------------------------------------
// SurfaceData
//-----------------------------------------------------------------------------

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


#define MATERIALID_LIT_ANISO (4)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit.MaterialFeatureFlags: static fields
//
#define FEATURE_FLAG_MATERIAL_LIT_STANDARD (4096)
#define FEATURE_FLAG_MATERIAL_LIT_SSS (8192)
#define FEATURE_FLAG_MATERIAL_LIT_CLEAR_COAT (16384)
#define FEATURE_FLAG_MATERIAL_LIT_SPECULAR (32768)
#define FEATURE_FLAG_MATERIAL_LIT_ANISO (65536)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit.SurfaceData: static fields
//
#define DEBUGVIEW_LIT_SURFACEDATA_BASE_COLOR (1000)

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


else if (bsdfData.materialId == MATERIALID_LIT_SSS)
{
bsdfData.diffuseColor = surfaceData.baseColor;
bsdfData.fresnel0 = 0.028; // TODO take from subsurfaceProfile
// TODO take from subsurfaceProfile
bsdfData.fresnel0 = 0.04; /* 0.028 ? */
bsdfData.subsurfaceProfile = surfaceData.subsurfaceProfile;
// Make the Std. Dev. of 1 correspond to the effective radius of 1 cm (three-sigma rule).
bsdfData.subsurfaceRadius = SSS_UNIT_CONVERSION * surfaceData.subsurfaceRadius;

}
void DecodeFromGBuffer(
#if SHADEROPTIONS_PACK_GBUFFER_IN_U16
GBufferType0 inGBufferU0,
GBufferType1 inGBufferU1,
#else
GBufferType0 inGBuffer0,
GBufferType1 inGBuffer1,
GBufferType2 inGBuffer2,
GBufferType3 inGBuffer3,
#endif
out BSDFData bsdfData,
out float3 bakeDiffuseLighting)
#if SHADEROPTIONS_PACK_GBUFFER_IN_U16
GBufferType0 inGBufferU0,
GBufferType1 inGBufferU1,
#else
GBufferType0 inGBuffer0,
GBufferType1 inGBuffer1,
GBufferType2 inGBuffer2,
GBufferType3 inGBuffer3,
#endif
uint featureFlags,
out BSDFData bsdfData,
out float3 bakeDiffuseLighting)
#if SHADEROPTIONS_PACK_GBUFFER_IN_U16
#if SHADEROPTIONS_PACK_GBUFFER_IN_U16
float4 inGBuffer0, inGBuffer1, inGBuffer2, inGBuffer3;
inGBuffer0 = DecodeGBuffer0(inGBufferU0);

uint packedGBuffer3 = inGBufferU1.z | inGBufferU1.w << 16;
inGBuffer3.xyz = UnpackR11G11B10f(packedGBuffer1);
inGBuffer3.w = 0.0;
#endif
#endif
float3 baseColor = inGBuffer0.rgb;
bsdfData.specularOcclusion = inGBuffer0.a;

bsdfData.roughness = PerceptualRoughnessToRoughness(bsdfData.perceptualRoughness);
bsdfData.materialId = UnpackMaterialId(inGBuffer1.a);
if (bsdfData.materialId == MATERIALID_LIT_STANDARD)
int supportsStandard = (featureFlags & (FEATURE_FLAG_MATERIAL_LIT_STANDARD | FEATURE_FLAG_MATERIAL_LIT_ANISO)) != 0;
int supportsSSS = (featureFlags & (FEATURE_FLAG_MATERIAL_LIT_SSS)) != 0;
int supportsClearCoat = (featureFlags & (MATERIALID_LIT_CLEAR_COAT)) != 0;
int supportsSpecular = (featureFlags & (FEATURE_FLAG_MATERIAL_LIT_SPECULAR)) != 0;
if(supportsStandard + supportsSSS + supportsClearCoat + supportsSpecular > 1)
{
bsdfData.materialId = UnpackMaterialId(inGBuffer1.a); // only fetch materialid if it is not statically known from feature flags
}
else
{
// materialid is statically known. this allows the compiler to eliminate a lot of code.
if(supportsStandard) bsdfData.materialId = MATERIALID_LIT_STANDARD;
else if(supportsSSS) bsdfData.materialId = MATERIALID_LIT_SSS;
else if(supportsClearCoat) bsdfData.materialId = MATERIALID_LIT_CLEAR_COAT;
else bsdfData.materialId = MATERIALID_LIT_SPECULAR;
}
if (supportsStandard && bsdfData.materialId == MATERIALID_LIT_STANDARD)
{
float metallic = inGBuffer2.a;
// TODO extract spec

ConvertAnisotropyToRoughness(bsdfData.roughness, anisotropy, bsdfData.roughnessT, bsdfData.roughnessB);
bsdfData.anisotropy = anisotropy;
bsdfData.materialId = anisotropy > 0 ? MATERIALID_LIT_ANISO : bsdfData.materialId;
if ((featureFlags & FEATURE_FLAG_MATERIAL_LIT_ANISO) && (featureFlags & FEATURE_FLAG_MATERIAL_LIT_STANDARD) == 0 || anisotropy > 0)
{
bsdfData.materialId = MATERIALID_LIT_ANISO;
}
else if (bsdfData.materialId == MATERIALID_LIT_SSS)
else if (supportsSSS && bsdfData.materialId == MATERIALID_LIT_SSS)
bsdfData.fresnel0 = 0.028; // TODO take from subsurfaceProfile
// TODO take from subsurfaceProfile
bsdfData.fresnel0 = 0.04; /* 0.028 ? */
bsdfData.subsurfaceProfile = (SSS_N_PROFILES - 1) * inGBuffer2.a;
// Make the Std. Dev. of 1 correspond to the effective radius of 1 cm (three-sigma rule).
bsdfData.subsurfaceRadius = SSS_UNIT_CONVERSION * inGBuffer2.r;

bsdfData.thickness, bsdfData.subsurfaceRadius);
}
}
else if (bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
else if (supportsClearCoat && bsdfData.materialId == MATERIALID_LIT_CLEAR_COAT)
{
float metallic = inGBuffer2.a;
// TODO extract spec

bsdfData.coatNormalWS = UnpackNormalOctEncode(float2(inGBuffer2.rg * 2.0 - 1.0));
bsdfData.coatRoughness = inGBuffer2.b;
}
else if (bsdfData.materialId == MATERIALID_LIT_SPECULAR)
else if (supportsSpecular && bsdfData.materialId == MATERIALID_LIT_SPECULAR)
{
bsdfData.diffuseColor = baseColor;
bsdfData.fresnel0 = inGBuffer2.rgb;

ApplyDebugToBSDFData(bsdfData);
}
uint MaterialFeatureFlagsFromGBuffer(
#if SHADEROPTIONS_PACK_GBUFFER_IN_U16
GBufferType0 inGBufferU0,
GBufferType1 inGBufferU1
#else
GBufferType0 inGBuffer0,
GBufferType1 inGBuffer1,
GBufferType2 inGBuffer2,
GBufferType3 inGBuffer3
#endif
)
{
#if SHADEROPTIONS_PACK_GBUFFER_IN_U16
float4 inGBuffer0, inGBuffer1, inGBuffer2, inGBuffer3;
inGBuffer0 = DecodeGBuffer0(inGBufferU0);
uint packedGBuffer1 = inGBufferU0.z | inGBufferU0.w << 16;
inGBuffer1 = UnpackR10G10B10A2(packedGBuffer1);
inGBuffer2.x = UnpackUIntToFloat(inGBufferU1.x, 8, 0);
inGBuffer2.y = UnpackUIntToFloat(inGBufferU1.x, 8, 8);
inGBuffer2.z = UnpackUIntToFloat(inGBufferU1.y, 8, 0);
inGBuffer2.w = UnpackUIntToFloat(inGBufferU1.y, 8, 8);
uint packedGBuffer3 = inGBufferU1.z | inGBufferU1.w << 16;
inGBuffer3.xyz = UnpackR11G11B10f(packedGBuffer1);
inGBuffer3.w = 0.0;
#endif
int materialId = UnpackMaterialId(inGBuffer1.a);
float anisotropy = inGBuffer2.b;
uint featureFlags = 0;
if (materialId == MATERIALID_LIT_STANDARD)
{
featureFlags |= (anisotropy > 0) ? FEATURE_FLAG_MATERIAL_LIT_ANISO : FEATURE_FLAG_MATERIAL_LIT_STANDARD;
}
else if (materialId == MATERIALID_LIT_SSS)
{
featureFlags |= FEATURE_FLAG_MATERIAL_LIT_SSS;
}
else if (materialId == MATERIALID_LIT_CLEAR_COAT)
{
featureFlags |= FEATURE_FLAG_MATERIAL_LIT_CLEAR_COAT;
}
else if (materialId == MATERIALID_LIT_SPECULAR)
{
featureFlags |= FEATURE_FLAG_MATERIAL_LIT_SPECULAR;
}
return featureFlags;
}
//-----------------------------------------------------------------------------
// Debug method (use to display values)
//-----------------------------------------------------------------------------

out float3 diffuseLighting,
out float3 specularLighting)
{
float3 H = normalize(V + L);
float LdotH = saturate(dot(L, H));
float NdotH = saturate(dot(bsdfData.normalWS, H));
float NdotL = saturate(dot(bsdfData.normalWS, L));
float NdotL = saturate(dot(bsdfData.normalWS, L));
float NdotV = preLightData.NdotV;
float LdotV = dot(L, V);
float invLenLV = rsqrt(abs(2 + 2 * LdotV)); // invLenLV = rcp(length(L + V))
float NdotH = saturate((NdotL + NdotV) * invLenLV);
float LdotH = saturate(invLenLV + invLenLV * LdotV);
float3 F = F_Schlick(bsdfData.fresnel0, LdotH);
float Vis;

if (bsdfData.materialId == MATERIALID_LIT_ANISO)
{
float3 H = (L + V) * invLenLV;
// For anisotropy we must not saturate these values
float TdotH = dot(bsdfData.tangentWS, H);
float TdotL = dot(bsdfData.tangentWS, L);

bsdfData.roughnessB = ClampRoughnessForAnalyticalLights(bsdfData.roughnessB);
#ifdef LIT_USE_BSDF_PRE_LAMBDAV
Vis = V_SmithJointGGXAnisoLambdaV( preLightData.TdotV, preLightData.BdotV, preLightData.NdotV, TdotL, BdotL, NdotL,
Vis = V_SmithJointGGXAnisoLambdaV( preLightData.TdotV, preLightData.BdotV, NdotV, TdotL, BdotL, NdotL,
Vis = V_SmithJointGGXAniso( preLightData.TdotV, preLightData.BdotV, preLightData.NdotV, TdotL, BdotL, NdotL,
Vis = V_SmithJointGGXAniso( preLightData.TdotV, preLightData.BdotV, NdotV, TdotL, BdotL, NdotL,
bsdfData.roughnessT, bsdfData.roughnessB);
#endif

bsdfData.roughness = ClampRoughnessForAnalyticalLights(bsdfData.roughness);
#ifdef LIT_USE_BSDF_PRE_LAMBDAV
Vis = V_SmithJointGGX(NdotL, preLightData.NdotV, bsdfData.roughness, preLightData.ggxLambdaV);
Vis = V_SmithJointGGX(NdotL, NdotV, bsdfData.roughness, preLightData.ggxLambdaV);
Vis = V_SmithJointGGX(NdotL, preLightData.NdotV, bsdfData.roughness);
Vis = V_SmithJointGGX(NdotL, NdotV, bsdfData.roughness);
#ifdef LIT_DIFFUSE_LAMBERT_BRDF
float diffuseTerm = Lambert();
#else
float diffuseTerm = DisneyDiffuse(preLightData.NdotV, NdotL, LdotH, bsdfData.perceptualRoughness);
#endif
#ifdef LIT_DIFFUSE_LAMBERT_BRDF
float diffuseTerm = Lambert();
#elif LIT_DIFFUSE_GGX_BRDF
float3 diffuseTerm = DiffuseGGX(bsdfData.diffuseColor, NdotV, NdotL, NdotH, LdotV, bsdfData.perceptualRoughness);
#else
float diffuseTerm = DisneyDiffuse(NdotV, NdotL, LdotH, bsdfData.perceptualRoughness);
#endif
diffuseLighting = bsdfData.diffuseColor * diffuseTerm;
}

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


BSDFData bsdfData;
FETCH_GBUFFER(gbuffer, _GBufferTexture, posInput.unPositionSS);
DECODE_FROM_GBUFFER(gbuffer, bsdfData, unused);
DECODE_FROM_GBUFFER(gbuffer, 0xFFFFFFFF, bsdfData, unused);
int profileID = bsdfData.subsurfaceProfile;
float distScale = bsdfData.subsurfaceRadius;

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/SubsurfaceScatteringProfile.cs


halfRcpVariancesAndLerpWeights = null;
halfRcpWeightedVariances = null;
filterKernels = null;
OnValidate(); // Perform initialization
}
public void OnValidate()

13
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Material.hlsl


GBufferType1 MERGE_NAME(NAME, 1) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 1), unCoord2);
#define ENCODE_INTO_GBUFFER(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, NAME) EncodeIntoGBuffer(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, MERGE_NAME(NAME,0), MERGE_NAME(NAME,1))
#define DECODE_FROM_GBUFFER(NAME, BSDF_DATA, BAKE_DIFFUSE_LIGHTING) DecodeFromGBuffer(MERGE_NAME(NAME,0), MERGE_NAME(NAME,1), BSDF_DATA, BAKE_DIFFUSE_LIGHTING)
#define DECODE_FROM_GBUFFER(NAME, FEATURE_FLAGS, BSDF_DATA, BAKE_DIFFUSE_LIGHTING) DecodeFromGBuffer(MERGE_NAME(NAME,0), MERGE_NAME(NAME,1), FEATURE_FLAGS, BSDF_DATA, BAKE_DIFFUSE_LIGHTING)
#define MATERIAL_FEATURE_FLAGS_FROM_GBUFFER(NAME) MaterialFeatureFlagsFromGBuffer(MERGE_NAME(NAME,0), MERGE_NAME(NAME,1))
#if SHADEROPTIONS_VELOCITY_IN_GBUFFER
#define OUTPUT_GBUFFER_VELOCITY(NAME) ,out float4 NAME : SV_Target2

GBufferType2 MERGE_NAME(NAME, 2) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 2), unCoord2);
#define ENCODE_INTO_GBUFFER(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, NAME) EncodeIntoGBuffer(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, MERGE_NAME(NAME,0), MERGE_NAME(NAME,1), MERGE_NAME(NAME,2))
#define DECODE_FROM_GBUFFER(NAME, BSDF_DATA, BAKE_DIFFUSE_LIGHTING) DecodeFromGBuffer(MERGE_NAME(NAME,0), MERGE_NAME(NAME,1), MERGE_NAME(NAME,2), BSDF_DATA, BAKE_DIFFUSE_LIGHTING)
#define DECODE_FROM_GBUFFER(NAME, FEATURE_FLAGS, BSDF_DATA, BAKE_DIFFUSE_LIGHTING) DecodeFromGBuffer(MERGE_NAME(NAME,0), MERGE_NAME(NAME,1), MERGE_NAME(NAME,2), FEATURE_FLAGS, BSDF_DATA, BAKE_DIFFUSE_LIGHTING)
#define MATERIAL_FEATURE_FLAGS_FROM_GBUFFER(NAME) MaterialFeatureFlagsFromGBuffer(MERGE_NAME(NAME,0), MERGE_NAME(NAME,1), MERGE_NAME(NAME,2))
#if SHADEROPTIONS_VELOCITY_IN_GBUFFER
#define OUTPUT_GBUFFER_VELOCITY(NAME) ,out float4 NAME : SV_Target3

GBufferType3 MERGE_NAME(NAME, 3) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 3), unCoord2);
#define ENCODE_INTO_GBUFFER(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, NAME) EncodeIntoGBuffer(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3))
#define DECODE_FROM_GBUFFER(NAME, BSDF_DATA, BAKE_DIFFUSE_LIGHTING) DecodeFromGBuffer(MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3), BSDF_DATA, BAKE_DIFFUSE_LIGHTING)
#define DECODE_FROM_GBUFFER(NAME, FEATURE_FLAGS, BSDF_DATA, BAKE_DIFFUSE_LIGHTING) DecodeFromGBuffer(MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3), FEATURE_FLAGS, BSDF_DATA, BAKE_DIFFUSE_LIGHTING)
#define MATERIAL_FEATURE_FLAGS_FROM_GBUFFER(NAME) MaterialFeatureFlagsFromGBuffer(MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3))
#if SHADEROPTIONS_VELOCITY_IN_GBUFFER
#define OUTPUT_GBUFFER_VELOCITY(NAME) ,out float4 NAME : SV_Target4

GBufferType4 MERGE_NAME(NAME, 4) = LOAD_TEXTURE2D(MERGE_NAME(TEX, 4), unCoord2);
#define ENCODE_INTO_GBUFFER(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, NAME) EncodeIntoGBuffer(SURFACE_DATA, BAKE_DIFFUSE_LIGHTING, MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3), MERGE_NAME(NAME, 4))
#define DECODE_FROM_GBUFFER(NAME, BSDF_DATA, BAKE_DIFFUSE_LIGHTING) DecodeFromGBuffer(MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3), MERGE_NAME(NAME, 4), BSDF_DATA, BAKE_DIFFUSE_LIGHTING)
#define DECODE_FROM_GBUFFER(NAME, FEATURE_FLAGS, BSDF_DATA, BAKE_DIFFUSE_LIGHTING) DecodeFromGBuffer(MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3), MERGE_NAME(NAME, 4), FEATURE_FLAGS, BSDF_DATA, BAKE_DIFFUSE_LIGHTING)
#define MATERIAL_FEATURE_FLAGS_FROM_GBUFFER(NAME) MaterialFeatureFlagsFromGBuffer(MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3), MERGE_NAME(NAME, 4))
#if SHADEROPTIONS_VELOCITY_IN_GBUFFER
#define OUTPUT_GBUFFER_VELOCITY(NAME) ,out float4 NAME : SV_Target5

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl


FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh);
// input.unPositionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw, uint2(0, 0));
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.unPositionSS.z, input.unPositionSS.w, input.positionWS, posInput);
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS);

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassDistortion.hlsl


FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh);
// input.unPositionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw, uint2(0, 0));
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.unPositionSS.z, input.unPositionSS.w, input.positionWS, posInput);
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS);

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl


FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh);
// input.unPositionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw, uint2(0, 0));
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.unPositionSS.z, input.unPositionSS.w, input.positionWS, posInput);
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS);

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl


FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh);
// input.unPositionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw, uint2(0, 0));
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.unPositionSS.z, input.unPositionSS.w, input.positionWS, posInput);
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS);

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl


FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh);
// input.unPositionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw, uint2(0, 0));
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw);
// No position and depth in case of light transport
float3 V = float3(0, 0, 1); // No vector view in case of light transport

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassVelocity.hlsl


FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh);
// input.unPositionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw, uint2(0, 0));
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.unPositionSS.z, input.unPositionSS.w, input.positionWS, posInput);
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS);

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader


float3 rotatedDir = float3(dot(rotDirX, dir), dir.y, dot(rotDirY, dir));
// input.positionCS is SV_Position
PositionInputs posInput = GetPositionInput(input.positionCS.xy, _ScreenSize.zw, uint2(0,0));
PositionInputs posInput = GetPositionInput(input.positionCS.xy, _ScreenSize.zw);
// An arbitrary value attempting to match the size of the sky mesh from the Blacksmith demo.
const float skyDepth = 0.00025;

21
Assets/ScriptableRenderPipeline/ShaderLibrary/BSDF.hlsl


return INV_PI * DisneyDiffuseNoPI(NdotV, NdotL, LdotH, perceptualRoughness);
}
// Ref: Diffuse Lighting for GGX + Smith Microsurfaces, p. 113.
float3 DiffuseGGXNoPI(float3 albedo, float NdotV, float NdotL, float NdotH, float LdotV, float perceptualRoughness)
{
float facing = 0.5 + 0.5 * LdotV;
float rough = facing * (0.9 - 0.4 * facing) * ((0.5 + NdotH) / NdotH);
float transmitL = 1 - F_Schlick(0, 1, NdotL);
float transmitV = 1 - F_Schlick(0, 1, NdotV);
float smooth = transmitL * transmitV * 1.05; // Normalize F_t over the hemisphere
float single = lerp(smooth, rough, perceptualRoughness); // Rescaled by PI
// This constant is picked s.t. setting perceptualRoughness, albedo and all angles to 1
// allows us to match the Lambertian and the Disney Diffuse models. Original value: 0.1159.
float multiple = perceptualRoughness * (0.079577 * PI); // Rescaled by PI
return single + albedo * multiple;
}
float3 DiffuseGGX(float3 albedo, float NdotV, float NdotL, float NdotH, float LdotV, float perceptualRoughness)
{
// Note that we could save 2 cycles by inlining the multiplication by INV_PI.
return INV_PI * DiffuseGGXNoPI(albedo, NdotV, NdotL, NdotH, LdotV, perceptualRoughness);
}
#endif // UNITY_BSDF_INCLUDED

5
Assets/ScriptableRenderPipeline/ShaderLibrary/Common.hlsl


return posInput;
}
PositionInputs GetPositionInput(float2 unPositionSS, float2 invScreenSize)
{
return GetPositionInput(unPositionSS, invScreenSize, uint2(0, 0));
}
// From forward
// depthRaw and depthVS come directly form .zw of SV_Position
void UpdatePositionInput(float depthRaw, float depthVS, float3 positionWS, inout PositionInputs posInput)

正在加载...
取消
保存