Evgenii Golubev 8 年前
当前提交
74657c39
共有 74 个文件被更改,包括 2246 次插入393 次删除
  1. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewMaterialGBuffer.shader
  2. 10
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewTiles.shader
  3. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Resources/Deferred.shader
  4. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild-bigtile.compute
  5. 58
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
  6. 81
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  7. 136
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs
  8. 38
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
  9. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl
  10. 59
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader
  11. 42
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl
  12. 19
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl
  13. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Resources/PreIntegratedFGD.shader
  14. 47
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
  15. 8
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/MaterialUtilities.hlsl
  16. 7
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Unlit.shader
  17. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl
  18. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl
  19. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl
  20. 6
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl
  21. 8
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader
  22. 4
      Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl
  23. 1
      Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl
  24. 62
      Assets/ScriptableRenderLoop/ShaderLibrary/EntityLighting.hlsl
  25. 40
      Assets/ScriptableRenderLoop/ShaderLibrary/Packing.hlsl
  26. 136
      Assets/ScriptableRenderLoop/ShaderLibrary/Tessellation.hlsl
  27. 2
      Assets/ScriptableRenderLoop/common/TextureCache.cs
  28. 18
      Assets/TestScenes/HDTest/LayeredLitTest.unity
  29. 30
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_HeightBased.mat
  30. 24
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Planar.mat
  31. 19
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Triplanar.mat
  32. 20
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV0.mat
  33. 23
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV1.mat
  34. 21
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV2.mat
  35. 21
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV3.mat
  36. 7
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_Ground_01_2x2.mat
  37. 3
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_Moss_02_2x2.mat
  38. 3
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_Sand01_2x2.mat
  39. 3
      Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_Spheres.mat
  40. 2
      Assets/TestScenes/HDTest/LayeredLitTest/Textures/VolumeTest_01_H.tga.meta
  41. 68
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl
  42. 78
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitSharePass.hlsl
  43. 56
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDistortionPass.hlsl
  44. 513
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  45. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader.meta
  46. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl.meta
  47. 41
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.hlsl
  48. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.hlsl.meta
  49. 391
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader
  50. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader.meta
  51. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass.meta
  52. 87
      Assets/ScriptableRenderLoop/ShaderLibrary/API/PSSL.hlsl
  53. 9
      Assets/ScriptableRenderLoop/ShaderLibrary/API/PSSL.hlsl.meta
  54. 170
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDepthPass.hlsl
  55. 77
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tessellation/TessellationShare.hlsl
  56. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tessellation/TessellationShare.hlsl.meta
  57. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitSurfaceData.hlsl.meta
  58. 108
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDepthPass.hlsl
  59. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
  60. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tessellation.meta
  61. 0
      /Assets/ScriptableRenderLoop/ShaderLibrary/Tessellation.hlsl.meta
  62. 0
      /Assets/ScriptableRenderLoop/ShaderLibrary/Tessellation.hlsl
  63. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl.meta
  64. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl
  65. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitSharePass.hlsl.meta
  66. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitSharePass.hlsl
  67. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitMetaPass.hlsl.meta
  68. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitMetaPass.hlsl
  69. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDistortionPass.hlsl.meta
  70. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDistortionPass.hlsl
  71. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDepthPass.hlsl.meta

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewMaterialGBuffer.shader


HLSLPROGRAM
#pragma target 5.0
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev
#pragma only_renderers d3d11 ps4// TEMP: unitl we go futher in dev
#pragma vertex Vert
#pragma fragment Frag

10
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewTiles.shader


HLSLPROGRAM
#pragma target 5.0
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev
#pragma only_renderers d3d11 ps4// TEMP: unitl we go futher in dev
#pragma vertex Vert
#pragma fragment Frag

float depthMouse = LOAD_TEXTURE2D(_CameraDepthTexture, mousePosInput.unPositionSS).x;
UpdatePositionInput(depthMouse, _InvViewProjMatrix, _ViewProjMatrix, mousePosInput);
int category = (LIGHTCATEGORY_COUNT - 1) - tileCoord.y;
int start;
int count;
uint category = (LIGHTCATEGORY_COUNT - 1) - tileCoord.y;
uint start;
uint count;
GetCountAndStart(mousePosInput, category, start, count);
float4 result2 = float4(.1,.1,.1,.9);

}
}
Fallback Off
}
}

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Resources/Deferred.shader


HLSLPROGRAM
#pragma target 5.0
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev
#pragma only_renderers d3d11 ps4// TEMP: unitl we go futher in dev
#pragma vertex Vert
#pragma fragment Frag

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild-bigtile.compute


#include "common.hlsl"
#include "../TilePass.cs.hlsl"
#include "../LightingConvexHullUtils.hlsl"
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
#if !defined(SHADER_API_XBOXONE)
#include "../SortingComputeUtils.hlsl"
#endif

58
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs


public readonly GUIContent layersText = new GUIContent("Layers");
public readonly GUIContent emissiveText = new GUIContent("Emissive");
public readonly GUIContent layerMapMaskText = new GUIContent("Layer Mask", "Layer mask (multiplied by vertex color if enabled)");
public readonly GUIContent layerMapVertexColorText = new GUIContent("Use Vertex Color", "Layer mask (multiplied by layer mask if enabled)");
public readonly GUIContent layerMapVertexColorText = new GUIContent("Use Vertex Color", "If no layer mask is set, vertex color values between 0 and 1.0 are used as final mask.\nIf a layer mask is set, vertex color values are remapped between -1 and 1 and added to the mask (neutral at 0.5 vertex color).");
public readonly GUIContent vertexColorHeightMultiplierText = new GUIContent("Vertex Height Scale", "Scale applied to the vertex color height.");
public readonly GUIContent layerCountText = new GUIContent("Layer Count", "Number of layers.");
public readonly GUIContent layerTexWorldScaleText = new GUIContent("Tiling", "Tiling factor applied to Planar/Trilinear mapping");

return result;
}
bool CheckInputFloatOptionConsistency(string optionName, ref string outValueNames)
{
bool result = true;
outValueNames = "";
for (int i = 0; i < numLayer; ++i)
{
Material layer = m_MaterialLayers[i];
if (layer != null)
{
float currentValue = layer.GetFloat(optionName);
for (int j = i + 1; j < numLayer; ++j)
{
Material otherLayer = m_MaterialLayers[j];
if (otherLayer != null)
{
if (currentValue != otherLayer.GetFloat(optionName))
{
result = false;
}
}
}
}
else
{
outValueNames += "X ";
}
}
return result;
}
bool CheckInputMapConsistency(string mapName, ref string outValueNames)
{
bool result = true;

// Input options consistency
string[] smoothnessSourceShortNames = { "Mask", "Albedo" };
string[] normalMapShortNames = { "Tan", "Obj" };
string[] heightMapShortNames = { "Parallax", "Disp" };
string[] detailModeShortNames = { "DNormal", "DAOHeight" };
string warningInputOptions = "";

{
warningInputOptions += "Normal Map Space: " + optionValueNames + "\n";
}
if (!CheckInputOptionConsistency(kHeightMapMode, heightMapShortNames, ref optionValueNames))
if (!CheckInputFloatOptionConsistency(kEnablePerPixelDisplacement, ref optionValueNames))
warningInputOptions += "Height Map Mode: " + optionValueNames + "\n";
warningInputOptions += "Per pixel displacement: " + optionValueNames + "\n";
}
if (!CheckInputOptionConsistency(kDetailMapMode, detailModeShortNames, ref optionValueNames))
{

{
material.SetFloat(kSmoothnessTextureChannel, firstLayer.GetFloat(kSmoothnessTextureChannel));
material.SetFloat(kNormalMapSpace, firstLayer.GetFloat(kNormalMapSpace));
material.SetFloat(kHeightMapMode, firstLayer.GetFloat(kHeightMapMode));
material.SetFloat(kEnablePerPixelDisplacement, firstLayer.GetFloat(kEnablePerPixelDisplacement));
// Force emissive to be emissive color
material.SetFloat(kEmissiveColorMode, (float)EmissiveColorMode.UseEmissiveColor);
}

SetKeyword(material, "_DETAIL_MAP", material.GetTexture(kDetailMap + i));
SetKeyword(material, "_DETAIL_MAP_WITH_NORMAL", ((DetailMapMode)material.GetFloat(kDetailMapMode)) == DetailMapMode.DetailWithNormal);
SetKeyword(material, "_HEIGHTMAP_AS_DISPLACEMENT", ((HeightmapMode)material.GetFloat(kHeightMapMode)) == HeightmapMode.Displacement);
bool perPixelDisplacement = material.GetFloat(kEnablePerPixelDisplacement) == 1.0;
SetKeyword(material, "_PER_PIXEL_DISPLACEMENT", perPixelDisplacement);
SetKeyword(material, "_NORMALMAP_TANGENT_SPACE", ((NormalMapSpace)material.GetFloat(kNormalMapSpace)) == NormalMapSpace.TangentSpace);
SetKeyword(material, "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A", ((SmoothnessMapChannel)material.GetFloat(kSmoothnessTextureChannel)) == SmoothnessMapChannel.AlbedoAlpha);
}

if(useHeightBasedBlend)
{
SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR", false);
SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_ADD", false);
SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_MUL", false);
SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR", material.GetFloat(kLayerMaskVertexColor) != 0.0f);
if (material.GetTexture(kLayerMaskMap) != null)
{
SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_ADD", material.GetFloat(kLayerMaskVertexColor) != 0.0f);
SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_MUL", false);
}
else
{
SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_MUL", material.GetFloat(kLayerMaskVertexColor) != 0.0f);
SetKeyword(material, "_LAYER_MASK_VERTEX_COLOR_ADD", false);
}
SetKeyword(material, "_HEIGHT_BASED_BLEND", false);
}

81
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader


_HeightMap2("HeightMap2", 2D) = "black" {}
_HeightMap3("HeightMap3", 2D) = "black" {}
_HeightScale0("Height Scale0", Float) = 1
_HeightScale1("Height Scale1", Float) = 1
_HeightScale2("Height Scale2", Float) = 1
_HeightScale3("Height Scale3", Float) = 1
_HeightAmplitude0("Height Scale0", Float) = 1
_HeightAmplitude1("Height Scale1", Float) = 1
_HeightAmplitude2("Height Scale2", Float) = 1
_HeightAmplitude3("Height Scale3", Float) = 1
_HeightBias0("Height Bias0", Float) = 0
_HeightBias1("Height Bias1", Float) = 0
_HeightBias2("Height Bias2", Float) = 0
_HeightBias3("Height Bias3", Float) = 0
_HeightCenter0("Height Bias0", Float) = 0
_HeightCenter1("Height Bias1", Float) = 0
_HeightCenter2("Height Bias2", Float) = 0
_HeightCenter3("Height Bias3", Float) = 0
_DetailMap0("DetailMap0", 2D) = "black" {}
_DetailMap1("DetailMap1", 2D) = "black" {}

_HeightFactor2("_HeightFactor2", Range(0, 5)) = 1
_HeightFactor3("_HeightFactor3", Range(0, 5)) = 1
_BlendSize1("_BlendSize1", Range(0, 0.05)) = 0.0
_BlendSize2("_BlendSize2", Range(0, 0.05)) = 0.0
_BlendSize3("_BlendSize3", Range(0, 0.05)) = 0.0
_BlendSize1("_BlendSize1", Range(0, 0.30)) = 0.0
_BlendSize2("_BlendSize2", Range(0, 0.30)) = 0.0
_BlendSize3("_BlendSize3", Range(0, 0.30)) = 0.0
_VertexColorHeightFactor("_VertexColorHeightFactor", Float) = 1.0
_VertexColorHeightFactor("_VertexColorHeightFactor", Float) = 0.3
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}

[Enum(Mask Alpha, 0, BaseColor Alpha, 1)] _SmoothnessTextureChannel("Smoothness texture channel", Float) = 1
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0
[Enum(Parallax, 0, Displacement, 1)] _HeightMapMode("Heightmap usage", Float) = 0
[ToggleOff] _EnablePerPixelDisplacement("Enable per pixel displacement", Float) = 0.0
[Enum(DetailMapNormal, 0, DetailMapAOHeight, 1)] _DetailMapMode("DetailMap mode", Float) = 0
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1

HLSLINCLUDE
#pragma target 5.0
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev
#pragma only_renderers d3d11 ps4// TEMP: unitl we go futher in dev
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _DISTORTION_ON

#pragma shader_feature _LAYER_MAPPING_TRIPLANAR_3
#pragma shader_feature _DETAIL_MAP_WITH_NORMAL
#pragma shader_feature _NORMALMAP_TANGENT_SPACE
#pragma shader_feature _HEIGHTMAP_AS_DISPLACEMENT
#pragma shader_feature _PER_PIXEL_DISPLACEMENT
#pragma shader_feature _REQUIRE_UV2_OR_UV3
#pragma shader_feature _EMISSIVE_COLOR

#pragma shader_feature _EMISSIVE_COLOR_MAP
#pragma shader_feature _HEIGHTMAP
#pragma shader_feature _DETAIL_MAP
#pragma shader_feature _LAYER_MASK_VERTEX_COLOR
#pragma shader_feature _ _LAYER_MASK_VERTEX_COLOR_MUL _LAYER_MASK_VERTEX_COLOR_ADD
#pragma shader_feature _HEIGHT_BASED_BLEND
#pragma shader_feature _ _LAYEREDLIT_3_LAYERS _LAYEREDLIT_4_LAYERS

#define SHADERPASS SHADERPASS_GBUFFER
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitSharePass.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"

#define SHADERPASS SHADERPASS_DEBUG_VIEW_MATERIAL
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitSharePass.hlsl"
#include "../../ShaderPass/ShaderPassDebugViewMaterial.hlsl"

// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light,
// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
#pragma vertex Vert
#pragma fragment Frag
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitMetaPass.hlsl"
#include "../Lit/LitMetaPass.hlsl"
#include "../../ShaderPass/ShaderPassLightTransport.hlsl"

HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitVelocityPass.hlsl"
#include "../Lit/LitVelocityPass.hlsl"
#include "../../ShaderPass/ShaderPassVelocity.hlsl"

HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitDepthPass.hlsl"
#include "../Lit/LitDepthPass.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"

HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitDepthPass.hlsl"
#include "../Lit/LitDepthPass.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"

Cull [_CullMode]
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitDistortionPass.hlsl"
#include "../Lit/LitDistortionPass.hlsl"
#include "../../ShaderPass/ShaderPassDistortion.hlsl"

#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
//#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF
#include "../../Lighting/Lighting.hlsl"
#include "../../Lighting/Lighting.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitSharePass.hlsl"
#include "../../ShaderPass/ShaderPassForward.hlsl"

CustomEditor "Experimental.ScriptableRenderLoop.LayeredLitGUI"
CustomEditor "Experimental.Rendering.HDPipeline.LayeredLitGUI"
}

136
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs


{
protected static class Styles
{
public static string OptionText = "Options";
public static string SurfaceTypeText = "Surface Type";
public static string BlendModeText = "Blend Mode";
public static string optionText = "Options";
public static string surfaceTypeText = "Surface Type";
public static string blendModeText = "Blend Mode";
public static string detailText = "Inputs Detail";
public static string lightingText = "Inputs Lighting";

public static GUIContent texWorldScaleText = new GUIContent("Tiling", "Tiling factor applied to Planar/Trilinear mapping");
public static GUIContent UVBaseDetailMappingText = new GUIContent("UV set for Base and Detail", "");
public static GUIContent normalMapSpaceText = new GUIContent("Normal/Tangent Map space", "");
public static GUIContent heightMapModeText = new GUIContent("Height Map Mode", "");
public static GUIContent enablePerPixelDisplacementText = new GUIContent("Enable Per Pixel Displacement", "");
public static GUIContent detailMapModeText = new GUIContent("Detail Map with Normal", "Detail Map with AO / Height");
public static GUIContent UVDetailMappingText = new GUIContent("UV set for Detail", "");
public static GUIContent emissiveColorModeText = new GUIContent("Emissive Color Usage", "Use emissive color or emissive mask");

public static GUIContent normalMapText = new GUIContent("Normal Map", "Normal Map (DXT5) - Need to implement BC5");
public static GUIContent heightMapText = new GUIContent("Height Map (R)", "Height Map");
public static GUIContent heightMapAmplitudeText = new GUIContent("Height Map Amplitude", "Height Map amplitude in world units.");
public static GUIContent heightMapCenterText = new GUIContent("Height Map Center", "Center of the heightmap in the texture (between 0 and 1)");
public static GUIContent tangentMapText = new GUIContent("Tangent Map", "Tangent Map (BC5) - DXT5 for test");
public static GUIContent anisotropyText = new GUIContent("Anisotropy", "Anisotropy scale factor");

public static GUIContent emissiveWarning = new GUIContent("Emissive value is animated but the material has not been configured to support emissive. Please make sure the material itself has some amount of emissive.");
public static GUIContent emissiveColorWarning = new GUIContent("Ensure emissive color is non-black for emission to have effect.");
public static string tessellationModeText = "Tessellation Mode";
public static readonly string[] tessellationModeNames = Enum.GetNames(typeof(TessellationMode));
public static GUIContent tessellationText = new GUIContent("Tessellation options", "Tessellation options");
public static GUIContent tessellationFactorFixedText = new GUIContent("Fixed tessellation factor", "If non negative, this value is a fixed tessellation factor use for tessellation");
public static GUIContent tessellationFactorMaxDistanceText = new GUIContent("Max Distance", "Maximun distance to the camera where triangle are tesselated");
public static GUIContent tessellationFactorTriangleSizeText = new GUIContent("Triangle size", "Desired screen space sized of triangle. Smaller value mean smaller triangle.");
public static GUIContent tessellationShapeFactorText = new GUIContent("Shape factor", "Strength of Phong tessellation shape (lerp factor)");
public static GUIContent tessellationBackFaceCullEpsilonText = new GUIContent("Triangle culling Epsilon", "If non zero, backface culling is enabled for tessellation, smaller number mean more aggressive culling and better performance");
public static GUIContent tessellationObjectScaleText = new GUIContent("Enable object scale", "Scale displacement taking into account the object scale");
}
public enum SurfaceType

}
public enum BlendMode
{
Lerp,

Premultiply
}
public enum DoubleSidedMode
{
None,

}
public enum TessellationMode
{
Phong,
Displacement,
DisplacementPhong,
}
void SurfaceTypePopup()
{
EditorGUI.showMixedValue = surfaceType.hasMixedValue;

mode = (SurfaceType)EditorGUILayout.Popup(Styles.SurfaceTypeText, (int)mode, Styles.surfaceTypeNames);
mode = (SurfaceType)EditorGUILayout.Popup(Styles.surfaceTypeText, (int)mode, Styles.surfaceTypeNames);
if (EditorGUI.EndChangeCheck())
{
m_MaterialEditor.RegisterPropertyChangeUndo("Surface Type");

EditorGUI.showMixedValue = false;
}
void TessellationModePopup()
{
EditorGUI.showMixedValue = tessellationMode.hasMixedValue;
var mode = (TessellationMode)tessellationMode.floatValue;
EditorGUI.BeginChangeCheck();
mode = (TessellationMode)EditorGUILayout.Popup(Styles.tessellationModeText, (int)mode, Styles.tessellationModeNames);
if (EditorGUI.EndChangeCheck())
{
m_MaterialEditor.RegisterPropertyChangeUndo("Tessellation Mode");
tessellationMode.floatValue = (float)mode;
}
EditorGUI.showMixedValue = false;
}
GUILayout.Label(Styles.OptionText, EditorStyles.boldLabel);
GUILayout.Label(Styles.optionText, EditorStyles.boldLabel);
SurfaceTypePopup();
if ((SurfaceType)surfaceType.floatValue == SurfaceType.Transparent)
{

m_MaterialEditor.ShaderProperty(depthOffsetEnable, Styles.depthOffsetEnableText.text);
EditorGUI.indentLevel--;
if (tessellationMode != null)
{
GUILayout.Label(Styles.tessellationText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
TessellationModePopup();
m_MaterialEditor.ShaderProperty(tessellationFactorFixed, Styles.tessellationFactorFixedText);
m_MaterialEditor.ShaderProperty(tessellationFactorMaxDistance, Styles.tessellationFactorMaxDistanceText);
m_MaterialEditor.ShaderProperty(tessellationFactorTriangleSize, Styles.tessellationFactorTriangleSizeText);
if ((TessellationMode)tessellationMode.floatValue == TessellationMode.Phong ||
(TessellationMode)tessellationMode.floatValue == TessellationMode.DisplacementPhong)
{
m_MaterialEditor.ShaderProperty(tessellationShapeFactor, Styles.tessellationShapeFactorText);
}
m_MaterialEditor.ShaderProperty(tessellationBackFaceCullEpsilon, Styles.tessellationBackFaceCullEpsilonText);
m_MaterialEditor.ShaderProperty(tessellationObjectScale, Styles.tessellationObjectScaleText);
EditorGUI.indentLevel--;
}
}
private void BlendModePopup()

EditorGUI.BeginChangeCheck();
mode = (BlendMode)EditorGUILayout.Popup(Styles.BlendModeText, (int)mode, Styles.blendModeNames);
mode = (BlendMode)EditorGUILayout.Popup(Styles.blendModeText, (int)mode, Styles.blendModeNames);
if (EditorGUI.EndChangeCheck())
{
m_MaterialEditor.RegisterPropertyChangeUndo("Blend Mode");

distortionOnly = FindProperty(kDistortionOnly, props);
distortionDepthTest = FindProperty(kDistortionDepthTest, props);
depthOffsetEnable = FindProperty(kDepthOffsetEnable, props);
// tessellation specific, silent if not found
tessellationMode = FindProperty(kTessellationMode, props, false);
tessellationFactorFixed = FindProperty(kTessellationFactorFixed, props, false);
tessellationFactorMaxDistance = FindProperty(kTessellationFactorMaxDistance, props, false);
tessellationFactorTriangleSize = FindProperty(kTessellationFactorTriangleSize, props, false);
tessellationShapeFactor = FindProperty(kTessellationShapeFactor, props, false);
tessellationBackFaceCullEpsilon = FindProperty(kTessellationBackFaceCullEpsilon, props, false);
tessellationObjectScale = FindProperty(kTessellationObjectScale, props, false);
}
protected void SetupCommonOptionsKeywords(Material material)

BlendMode blendMode = (BlendMode)material.GetFloat(kBlendMode);
DoubleSidedMode doubleSidedMode = (DoubleSidedMode)material.GetFloat(kDoubleSidedMode);
if (surfaceType == SurfaceType.Opaque)
{
material.SetOverrideTag("RenderType", alphaTestEnable ? "TransparentCutout" : "");

SetKeyword(material, "_DEPTHOFFSET_ON", depthOffsetEnable);
SetupEmissionGIFlags(material);
if (tessellationMode != null)
{
TessellationMode tessMode = (TessellationMode)material.GetFloat(kTessellationMode);
if (tessMode == TessellationMode.Phong)
{
material.DisableKeyword("_TESSELLATION_DISPLACEMENT");
material.DisableKeyword("_TESSELLATION_DISPLACEMENT_PHONG");
}
else if (tessMode == TessellationMode.Displacement)
{
material.EnableKeyword("_TESSELLATION_DISPLACEMENT");
material.DisableKeyword("_TESSELLATION_DISPLACEMENT_PHONG");
}
else
{
material.DisableKeyword("_TESSELLATION_DISPLACEMENT");
material.EnableKeyword("_TESSELLATION_DISPLACEMENT_PHONG");
}
}
}
protected void SetKeyword(Material m, string keyword, bool state)

protected MaterialEditor m_MaterialEditor;
MaterialProperty surfaceType = null;
const string kSurfaceType = "_SurfaceType";
const string kAlphaCutoffEnabled = "_AlphaCutoffEnable";
const string kBlendMode = "_BlendMode";
const string kAlphaCutoff = "_AlphaCutoff";
const string kDoubleSidedMode = "_DoubleSidedMode";
const string kDistortionEnable = "_DistortionEnable";
const string kDistortionOnly = "_DistortionOnly";
MaterialProperty depthOffsetEnable = null;
const string kSurfaceType = "_SurfaceType";
const string kBlendMode = "_BlendMode";
const string kAlphaCutoff = "_AlphaCutoff";
const string kAlphaCutoffEnabled = "_AlphaCutoffEnable";
const string kDoubleSidedMode = "_DoubleSidedMode";
const string kDistortionEnable = "_DistortionEnable";
const string kDistortionOnly = "_DistortionOnly";
MaterialProperty depthOffsetEnable = null;
// tessellation params
MaterialProperty tessellationMode = null;
const string kTessellationMode = "_TessellationMode";
MaterialProperty tessellationFactorFixed = null;
const string kTessellationFactorFixed = "_TessellationFactorFixed";
MaterialProperty tessellationFactorMaxDistance = null;
const string kTessellationFactorMaxDistance = "_TessellationFactorMaxDistance";
MaterialProperty tessellationFactorTriangleSize = null;
const string kTessellationFactorTriangleSize = "_TessellationFactorTriangleSize";
MaterialProperty tessellationShapeFactor = null;
const string kTessellationShapeFactor = "_TessellationShapeFactor";
MaterialProperty tessellationBackFaceCullEpsilon = null;
const string kTessellationBackFaceCullEpsilon = "_TessellationBackFaceCullEpsilon";
MaterialProperty tessellationObjectScale = null;
const string kTessellationObjectScale = "_TessellationObjectScale";
protected static string[] reservedProperties = new string[] { kSurfaceType, kBlendMode, kAlphaCutoff, kAlphaCutoffEnabled, kDoubleSidedMode };
protected abstract void FindMaterialProperties(MaterialProperty[] props);

38
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/LitUI.cs


protected const string kUVMappingPlanar = "_UVMappingPlanar";
protected MaterialProperty normalMapSpace = null;
protected const string kNormalMapSpace = "_NormalMapSpace";
protected MaterialProperty heightMapMode = null;
protected const string kHeightMapMode = "_HeightMapMode";
protected MaterialProperty enablePerPixelDisplacement = null;
protected const string kEnablePerPixelDisplacement = "_EnablePerPixelDisplacement";
protected MaterialProperty detailMapMode = null;
protected const string kDetailMapMode = "_DetailMapMode";
protected MaterialProperty UVDetail = null;

protected const string kNormalScale = "_NormalScale";
protected MaterialProperty heightMap = null;
protected const string kHeightMap = "_HeightMap";
protected MaterialProperty heightScale = null;
protected const string kHeightScale = "_HeightScale";
protected MaterialProperty heightBias = null;
protected const string kHeightBias= "_HeightBias";
protected MaterialProperty heightAmplitude = null;
protected const string kHeightAmplitude = "_HeightAmplitude";
protected MaterialProperty heightCenter = null;
protected const string kHeightCenter = "_HeightCenter";
protected MaterialProperty tangentMap = null;
protected const string kTangentMap = "_TangentMap";
protected MaterialProperty anisotropy = null;

protected MaterialProperty emissiveIntensity = null;
protected const string kEmissiveIntensity = "_EmissiveIntensity";
// These are options that are shared with the LayeredLit shader. Don't put anything that can't be shared here:
// For instance, properties like BaseColor and such don't exist in the LayeredLit so don't put them here.
protected void FindMaterialOptionProperties(MaterialProperty[] props)

heightMapMode = FindProperty(kHeightMapMode, props);
enablePerPixelDisplacement = FindProperty(kEnablePerPixelDisplacement, props);
detailMapMode = FindProperty(kDetailMapMode, props);
emissiveColorMode = FindProperty(kEmissiveColorMode, props);
}

normalMap = FindProperty(kNormalMap, props);
normalScale = FindProperty(kNormalScale, props);
heightMap = FindProperty(kHeightMap, props);
heightScale = FindProperty(kHeightScale, props);
heightBias = FindProperty(kHeightBias, props);
heightAmplitude = FindProperty(kHeightAmplitude, props);
heightCenter = FindProperty(kHeightCenter, props);
tangentMap = FindProperty(kTangentMap, props);
anisotropy = FindProperty(kAnisotropy, props);
anisotropyMap = FindProperty(kAnisotropyMap, props);

UVDetailsMappingMask.colorValue = new Color(X, Y, Z, W);
//m_MaterialEditor.ShaderProperty(detailMapMode, Styles.detailMapModeText.text);
m_MaterialEditor.ShaderProperty(normalMapSpace, Styles.normalMapSpaceText.text);
m_MaterialEditor.ShaderProperty(heightMapMode, Styles.heightMapModeText.text);
m_MaterialEditor.ShaderProperty(normalMapSpace, Styles.normalMapSpaceText.text);
m_MaterialEditor.ShaderProperty(enablePerPixelDisplacement, Styles.enablePerPixelDisplacementText.text);
EditorGUI.indentLevel--;
}

m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap, normalScale);
m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightScale, heightBias);
m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap);
if(!heightMap.hasMixedValue && heightMap.textureValue != null)
{
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(heightAmplitude, Styles.heightMapAmplitudeText);
m_MaterialEditor.ShaderProperty(heightCenter, Styles.heightMapCenterText);
EditorGUI.showMixedValue = false;
EditorGUI.indentLevel--;
}
m_MaterialEditor.TexturePropertySingleLine(Styles.tangentMapText, tangentMap);

m_MaterialEditor.LightmapEmissionProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
}
public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)

SetKeyword(material, "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A", ((SmoothnessMapChannel)material.GetFloat(kSmoothnessTextureChannel)) == SmoothnessMapChannel.AlbedoAlpha);
SetKeyword(material, "_MAPPING_TRIPLANAR", ((UVBaseMapping)material.GetFloat(kUVBase)) == UVBaseMapping.Triplanar);
SetKeyword(material, "_NORMALMAP_TANGENT_SPACE", ((NormalMapSpace)material.GetFloat(kNormalMapSpace)) == NormalMapSpace.TangentSpace);
SetKeyword(material, "_HEIGHTMAP_AS_DISPLACEMENT", ((HeightmapMode)material.GetFloat(kHeightMapMode)) == HeightmapMode.Displacement);
bool perPixelDisplacement = material.GetFloat(kEnablePerPixelDisplacement) == 1.0;
SetKeyword(material, "_PER_PIXEL_DISPLACEMENT", perPixelDisplacement);
SetKeyword(material, "_DETAIL_MAP_WITH_NORMAL", ((DetailMapMode)material.GetFloat(kDetailMapMode)) == DetailMapMode.DetailWithNormal);
SetKeyword(material, "_EMISSIVE_COLOR", ((EmissiveColorMode)material.GetFloat(kEmissiveColorMode)) == EmissiveColorMode.UseEmissiveColor);

4
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl


{
PreLightData preLightData;
// We do not saturate to correctly handle double-sided lighting.
// We have handle the case of NdotV being negative in GetData() function with GetShiftedNdotV.
// So we don't need to saturate or take the abs here.
// In case a material use negative normal for double sided lighting like speedtree this will be handle in the GetData() code too.
preLightData.NdotV = dot(bsdfData.normalWS, V);
preLightData.ggxLambdaV = GetSmithJointGGXLambdaV(preLightData.NdotV, bsdfData.roughness);

59
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader


_NormalScale("_NormalScale", Range(0.0, 2.0)) = 1
_HeightMap("HeightMap", 2D) = "black" {}
_HeightScale("Height Scale", Float) = 0.01
_HeightBias("Height Bias", Float) = 0
_HeightAmplitude("Height Amplitude", Float) = 0.01 // In world units
_HeightCenter("Height Center", Float) = 0.5 // In texture space
_TangentMap("TangentMap", 2D) = "bump" {}
_Anisotropy("Anisotropy", Range(0.0, 1.0)) = 0

[HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1,0,0,0)
[HideInInspector] _UVMappingPlanar("_UVMappingPlanar", Float) = 0
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0
[Enum(Parallax, 0, Displacement, 1)] _HeightMapMode("Heightmap usage", Float) = 0
[ToggleOff] _EnablePerPixelDisplacement("Enable per pixel displacement", Float) = 0.0
[Enum(DetailMapNormal, 0, DetailMapAOHeight, 1)] _DetailMapMode("DetailMap mode", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0
[HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1,0,0,0)

HLSLINCLUDE
#pragma target 5.0
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev
#pragma only_renderers d3d11 ps4// TEMP: unitl we go futher in dev
//-------------------------------------------------------------------------------------
// Variant

#pragma shader_feature _MAPPING_TRIPLANAR
#pragma shader_feature _DETAIL_MAP_WITH_NORMAL
#pragma shader_feature _NORMALMAP_TANGENT_SPACE
#pragma shader_feature _HEIGHTMAP_AS_DISPLACEMENT
#pragma shader_feature _PER_PIXEL_DISPLACEMENT
#pragma shader_feature _REQUIRE_UV2_OR_UV3
#pragma shader_feature _EMISSIVE_COLOR

HLSLPROGRAM
#define SHADERPASS SHADERPASS_GBUFFER
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitSharePass.hlsl"
#include "LitSharePass.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"

HLSLPROGRAM
#define SHADERPASS SHADERPASS_DEBUG_VIEW_MATERIAL
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitSharePass.hlsl"
#include "LitSharePass.hlsl"
#include "../../ShaderPass/ShaderPassDebugViewMaterial.hlsl"

// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light,
// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
#pragma vertex Vert
#pragma fragment Frag
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitMetaPass.hlsl"
#include "LitMetaPass.hlsl"
#include "../../ShaderPass/ShaderPassLightTransport.hlsl"

HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitDepthPass.hlsl"
#include "LitDepthPass.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"

HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitDepthPass.hlsl"
#include "LitDepthPass.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"

HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitVelocityPass.hlsl"
#include "LitVelocityPass.hlsl"
#include "../../ShaderPass/ShaderPassVelocity.hlsl"

HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitDistortionPass.hlsl"
#include "LitDistortionPass.hlsl"
#include "../../ShaderPass/ShaderPassDistortion.hlsl"

#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
//#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF
#include "../../Lighting/Lighting.hlsl"
#include "../../Lighting/Lighting.hlsl"
#include "ShaderPass/LitSharePass.hlsl"
#include "LitSharePass.hlsl"
#include "../../ShaderPass/ShaderPassForward.hlsl"

CustomEditor "Experimental.ScriptableRenderLoop.LitGUI"
CustomEditor "Experimental.Rendering.HDPipeline.LitGUI"
}

42
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl


#define LAYER_INDEX 0
#define ADD_IDX(Name) Name
#define ADD_ZERO_IDX(Name) Name
#include "LitSurfaceData.hlsl"
#include "LitDataInternal.hlsl"
#ifdef TESSELLATION_ON
#include "LitTessellation.hlsl"
#endif
void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
{

float depthOffset = 0.0;
#ifdef _DEPTHOFFSET_ON
ApplyDepthOffsetPositionInput(V, builtinData.depthOffset, posInput);
ApplyDepthOffsetPositionInput(V, depthOffset, posInput);
ApplyDepthOffsetAttribute(depthOffset, input);
#endif

surfaceData.normalWS = TransformTangentToWorld(normalTS, input.tangentToWorld);
surfaceData.tangentWS = input.tangentToWorld[0].xyz;
// NdotV should not be negative for visible pixels, but it can happen due to the
// perspective projection and the normal mapping + decals. In that case, the normal
// should be modified to become valid (i.e facing the camera) to avoid weird artifacts.
// Note: certain applications (e.g. SpeedTree) make use of double-sided lighting.
// This will potentially reduce the length of the normal at edges of geometry.
// This will always produce the correct 'NdotV' value, but potentially
// reduce the length of the normal at edges of geometry.
GetShiftedNdotV(surfaceData.normalWS, V, twoSided);
// Orthonormalize the basis vectors using the Gram-Schmidt process.

// Generate function for all layer
#define LAYER_INDEX 0
#define ADD_IDX(Name) Name##0
#include "LitSurfaceData.hlsl"
#include "LitDataInternal.hlsl"
#ifdef TESSELLATION_ON
#include "LitTessellation.hlsl" // Include only one time for layer 0
#endif
#include "LitSurfaceData.hlsl"
#include "LitDataInternal.hlsl"
#include "LitSurfaceData.hlsl"
#include "LitDataInternal.hlsl"
#include "LitSurfaceData.hlsl"
#include "LitDataInternal.hlsl"
#undef LAYER_INDEX
#undef ADD_IDX

{
float finalLayerHeight = heightFactor * layerHeight + heightOffset + _VertexColorHeightFactor * (vertexColor * 2.0 - 1.0);
edgeBlendStrength = max(0.001, edgeBlendStrength);
float heightThreshold = previousLayerHeight + edgeBlendStrength;
edgeBlendStrength = max(0.00001, edgeBlendStrength);
if (previousLayerHeight >= finalLayerHeight)
{

float depthOffset = 0.0;
#ifdef _DEPTHOFFSET_ON
ApplyDepthOffsetPositionInput(V, builtinData.depthOffset, posInput);
ApplyDepthOffsetPositionInput(V, depthOffset, posInput);
ApplyDepthOffsetAttribute(depthOffset, input);
#endif

// Mask Values : Layer 1, 2, 3 are r, g, b
float3 maskValues = SAMPLE_TEXTURE2D(_LayerMaskMap, sampler_LayerMaskMap, input.texCoord0).rgb;
#if defined(_LAYER_MASK_VERTEX_COLOR)
// Mutually exclusive with _HEIGHT_BASED_BLEND
#if defined(_LAYER_MASK_VERTEX_COLOR_MUL) // Used when no layer mask is set
#elif defined(_LAYER_MASK_VERTEX_COLOR_ADD) // When layer mask is set, color is additive to enable user to override it.
maskValues = saturate(maskValues + input.vertexColor.rgb * 2.0 - 1.0);
#endif
#if defined(_HEIGHT_BASED_BLEND)

surfaceData.normalWS = TransformTangentToWorld(normalTS, input.tangentToWorld);
surfaceData.tangentWS = input.tangentToWorld[0].xyz;
bool twoSided = false;
// NdotV should not be negative for visible pixels, but it can happen due to the
// perspective projection and the normal mapping + decals. In that case, the normal
// should be modified to become valid (i.e facing the camera) to avoid weird artifacts.
// Note: certain applications (e.g. SpeedTree) make use of double-sided lighting.
bool twoSided = false;
GetShiftedNdotV(surfaceData.normalWS, V, twoSided);
// Orthonormalize the basis vectors using the Gram-Schmidt process.

19
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl


TEXTURE2D(_HeightMap);
SAMPLER2D(sampler_HeightMap);
float _HeightScale;
float _HeightBias;
float _HeightAmplitude;
float _HeightCenter;
TEXTURE2D(_TangentMap);
SAMPLER2D(sampler_TangentMap);

PROP_DECL(float, _DetailHeightScale);
PROP_DECL(float, _DetailAOScale);
PROP_DECL(float, _HeightScale);
PROP_DECL(float, _HeightBias);
PROP_DECL(float, _HeightAmplitude);
PROP_DECL(float, _HeightCenter);
TEXTURE2D(_DiffuseLightingMap);
SAMPLER2D(sampler_DiffuseLightingMap);

float _AlphaCutoff;
#endif // LAYERED_LIT_SHADER
// Tessellation specific
#ifdef TESSELLATION_ON
float _TessellationFactorFixed;
float _TessellationFactorMaxDistance;
float _TessellationFactorTriangleSize;
float _TessellationShapeFactor;
float _TessellationBackFaceCullEpsilon;
float _TessellationObjectScale;
#endif

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Resources/PreIntegratedFGD.shader


#pragma vertex Vert
#pragma fragment Frag
#pragma target 5.0
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev
#pragma only_renderers d3d11 ps4// TEMP: unitl we go futher in dev
#include "Common.hlsl"
#include "ImageBasedLighting.hlsl"

47
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl


float height = 0.0f;
#ifdef _HEIGHTMAP
height = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), ADD_IDX(layerTexCoord.base)).r * ADD_IDX(_HeightScale) + ADD_IDX(_HeightBias);
height = (SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), ADD_IDX(layerTexCoord.base)).r - ADD_IDX(_HeightCenter)) * ADD_IDX(_HeightAmplitude);
//#ifndef _HEIGHTMAP_AS_DISPLACEMENT
// //height = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), ADD_IDX(layerTexCoord.base)).r * ADD_IDX(_HeightScale) + ADD_IDX(_HeightBias);
// float2 offset = ParallaxOffset(viewDirTS, height);
//#ifdef _PER_PIXEL_DISPLACEMENT
// //height = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), ADD_IDX(layerTexCoord.base)).r * ADD_IDX(_HeightScale) + ADD_IDX(_HeightBias);
// float2 offset = ParallaxOffset(viewDirTS, height);
// ADD_IDX(layerTexCoord.base).uv += offset;
// ADD_IDX(layerTexCoord.base).uvYZ += offset;
// ADD_IDX(layerTexCoord.base).uvZX += offset;
// ADD_IDX(layerTexCoord.base).uvXY += offset;
// ADD_IDX(layerTexCoord.base).uv += offset;
// ADD_IDX(layerTexCoord.base).uvYZ += offset;
// ADD_IDX(layerTexCoord.base).uvZX += offset;
// ADD_IDX(layerTexCoord.base).uvXY += offset;
// ADD_IDX(layerTexCoord.details).uv += offset;
// ADD_IDX(layerTexCoord.details).uvYZ += offset;
// ADD_IDX(layerTexCoord.details).uvZX += offset;
// ADD_IDX(layerTexCoord.details).uvXY += offset;
// ADD_IDX(layerTexCoord.details).uv += offset;
// ADD_IDX(layerTexCoord.details).uvYZ += offset;
// ADD_IDX(layerTexCoord.details).uvZX += offset;
// ADD_IDX(layerTexCoord.details).uvXY += offset;
// // Only modify texcoord for first layer, this will be use by for builtin data (like lightmap)
// if (LAYER_INDEX == 0)
// {
// input.texCoord0 += offset;
// input.texCoord1 += offset;
// input.texCoord2 += offset;
// input.texCoord3 += offset;
// }
// // Only modify texcoord for first layer, this will be use by for builtin data (like lightmap)
// if (LAYER_INDEX == 0)
// {
// input.texCoord0 += offset;
// input.texCoord1 += offset;
// input.texCoord2 += offset;
// input.texCoord3 += offset;
// }
// // Need to refetch for the right parallaxed height for layer blending to behave correctly...
// height = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), ADD_IDX(layerTexCoord.base)).r * ADD_IDX(_HeightScale) + ADD_IDX(_HeightBias);
// // Need to refetch for the right parallaxed height for layer blending to behave correctly...
// height = SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), ADD_IDX(layerTexCoord.base)).r * ADD_IDX(_HeightScale) + ADD_IDX(_HeightBias);
// #endif
// #endif
#endif
return height;

8
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/MaterialUtilities.hlsl


#ifdef DIRLIGHTMAP_COMBINED
bakeDiffuseLighting += SampleDirectionalLightmap(TEXTURE2D_PARAM(unity_Lightmap, samplerunity_Lightmap),
TEXTURE2D_PARAM(unity_LightmapInd, samplerunity_Lightmap),
uvStaticLightmap, unity_LightmapST, normalWS);
uvStaticLightmap, unity_LightmapST, normalWS, true);
bakeDiffuseLighting += SampleSingleLightmap(TEXTURE2D_PARAM(unity_Lightmap, samplerunity_Lightmap), uvStaticLightmap, unity_LightmapST);
bakeDiffuseLighting += SampleSingleLightmap(TEXTURE2D_PARAM(unity_Lightmap, samplerunity_Lightmap), uvStaticLightmap, unity_LightmapST, true);
#endif
#endif

TEXTURE2D_PARAM(unity_DynamicDirectionality, samplerunity_DynamicLightmap),
uvDynamicLightmap, unity_DynamicLightmapST, normalWS);
uvDynamicLightmap, unity_DynamicLightmapST, normalWS, false);
bakeDiffuseLighting += SampleSingleLightmap(TEXTURE2D_PARAM(unity_DynamicLightmap, samplerunity_DynamicLightmap), uvDynamicLightmap, unity_DynamicLightmapST);
bakeDiffuseLighting += SampleSingleLightmap(TEXTURE2D_PARAM(unity_DynamicLightmap, samplerunity_DynamicLightmap), uvDynamicLightmap, unity_DynamicLightmapST, false);
#endif
#endif

7
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Unlit.shader


// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light,
// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
#pragma vertex Vert
#pragma fragment Frag
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
#include "../../Material/Material.hlsl"
#include "UnlitData.hlsl"

CBUFFER_END
// This was not in constant buffer in original unity, so keep outiside. But should be in as ShaderRenderPass frequency
float unity_OneOverOutputBoost;
// This was not in constant buffer in original unity, so keep outiside. But should be in as ShaderRenderPass frequency
float unity_OneOverOutputBoost;
float unity_MaxOutputValue;
struct Attributes

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


outColor = float4(0.0, 0.0, 0.0, 0.0);
#ifdef _DEPTHOFFSET_ON
outputDepth = posInput.rawDepth;
outputDepth = posInput.depthRaw;
#endif
}

2
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl


outColor = float4(diffuseLighting + specularLighting, builtinData.opacity);
#ifdef _DEPTHOFFSET_ON
outputDepth = posInput.rawDepth;
outputDepth = posInput.depthRaw;
#endif
}

4
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl


OUTPUT_GBUFFER(outGBuffer)
OUTPUT_GBUFFER_VELOCITY(outVelocityBuffer)
#ifdef _DEPTHOFFSET_ON
, float outputDepth : SV_Depth
, out float outputDepth : SV_Depth
#endif
)
{

ENCODE_VELOCITY_INTO_GBUFFER(builtinData.velocity, outVelocityBuffer);
#ifdef _DEPTHOFFSET_ON
outputDepth = posInput.rawDepth;
outputDepth = posInput.depthRaw;
#endif
}

6
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl


#include "Color.hlsl"
// TODO: This is the max value allowed for emissive (bad name - but keep for now to retrieve it) (It is 8^2.2 (gamma) and 8 is the limit of punctual light slider...), comme from UnityCg.cginc. Fix it!
// Ask Jesper if this can be change for HDRenderPipeline
#define EMISSIVE_RGBM_SCALE 97.0
float4 Frag(PackedVaryings packedInput) : SV_Target
{
FragInputs input = UnpackVaryings(packedInput);

{
// TODO: THIS LIMIT MUST BE REMOVE, IT IS NOT HDR, change when RGB9e5 is here.
// Do we assume here that emission is [0..1] ?
res = PackRGBM(lightTransportData.emissiveColor, EMISSIVE_RGBM_SCALE);
res = PackEmissiveRGBM(lightTransportData.emissiveColor);
}
return res;

8
Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader


#ifdef PERFORM_SKY_OCCLUSION_TEST
// Determine whether the sky is occluded by the scene geometry.
// Do not perform blending with the environment map if the sky is occluded.
float rawDepth = max(skyDepth, LOAD_TEXTURE2D(_CameraDepthTexture, posInput.unPositionSS).r);
float skyTexWeight = (rawDepth > skyDepth) ? 0.0 : 1.0;
float depthRaw = max(skyDepth, LOAD_TEXTURE2D(_CameraDepthTexture, posInput.unPositionSS).r);
float skyTexWeight = (depthRaw > skyDepth) ? 0.0 : 1.0;
float rawDepth = skyDepth;
float depthRaw = skyDepth;
UpdatePositionInput(rawDepth, _InvViewProjMatrix, _ViewProjMatrix, posInput);
UpdatePositionInput(depthRaw, _InvViewProjMatrix, _ViewProjMatrix, posInput);
float4 c1, c2, c3;
VolundTransferScatter(posInput.positionWS, c1, c2, c3);

4
Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl


// Include language header
#if defined(SHADER_API_D3D11)
#include "API/D3D11.hlsl"
#elif defined(SHADER_API_PSSL)
#include "API/PSSL.hlsl"
#elif defined(SHADER_API_XBOXONE)
#include "API/D3D11_1.hlsl"
#else

}
// depthOffsetVS is always in the direction of the view vector (V)
void ApplyDepthOffsetPositionInput(float V, float depthOffsetVS, inout PositionInputs posInput)
void ApplyDepthOffsetPositionInput(float3 V, float depthOffsetVS, inout PositionInputs posInput)
{
posInput.depthVS += depthOffsetVS;
// TODO: it is an approx, need a correct value where we use projection matrix to reproject the depth from VS

1
Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl


// perspective projection and the normal mapping + decals. In that case, the normal
// should be modified to become valid (i.e facing the camera) to avoid weird artifacts.
// Note: certain applications (e.g. SpeedTree) make use of double-sided lighting.
// This will potentially reduce the length of the normal at edges of geometry.
float GetShiftedNdotV(inout float3 N, float3 V, bool twoSided)
{
float NdotV = dot(N, V);

62
Assets/ScriptableRenderLoop/ShaderLibrary/EntityLighting.hlsl


}
// Following functions are to sample enlighten lightmaps (or lightmaps encoded the same way as our
// enlighten implementation). They assume use of RGB9E5 for illuminance map.
// enlighten implementation). They assume use of RGB9E5 for dynamic illuminance map and RGBM for baked ones.
float3 SampleSingleLightmap(TEXTURE2D_ARGS(lightmapTex, lightmapSampler), float2 uv, float4 transform)
#define LIGHTMAP_RGBM_RANGE 5.0
// TODO: This is the max value allowed for emissive (bad name - but keep for now to retrieve it) (It is 8^2.2 (gamma) and 8 is the limit of punctual light slider...), comme from UnityCg.cginc. Fix it!
// Ask Jesper if this can be change for HDRenderPipeline
#define EMISSIVE_RGBM_SCALE 97.0
// RGBM stuff is temporary. For now baked lightmap are in RGBM and the RGBM range for lightmaps is specific so we can't use the generic method.
// In the end baked lightmaps are going to be BC6H so the code will be the same as dynamic lightmaps.
// Same goes for emissive packed as an input for Enlighten with another hard coded multiplier.
// TODO: This function is used with the LightTransport pass to encode lightmap or emissive
float4 PackEmissiveRGBM(float3 rgb)
{
float kOneOverRGBMMaxRange = 1.0 / EMISSIVE_RGBM_SCALE;
const float kMinMultiplier = 2.0 * 1e-2;
float4 rgbm = float4(rgb * kOneOverRGBMMaxRange, 1.0);
rgbm.a = max(max(rgbm.r, rgbm.g), max(rgbm.b, kMinMultiplier));
rgbm.a = ceil(rgbm.a * 255.0) / 255.0;
// Division-by-zero warning from d3d9, so make compiler happy.
rgbm.a = max(rgbm.a, kMinMultiplier);
rgbm.rgb /= rgbm.a;
return rgbm;
}
float3 UnpackLightmapRGBM(float4 rgbmInput)
{
return rgbmInput.rgb * rgbmInput.a * LIGHTMAP_RGBM_RANGE;
}
float3 SampleSingleLightmap(TEXTURE2D_ARGS(lightmapTex, lightmapSampler), float2 uv, float4 transform, bool lightmapRGBM)
// Remark: Lightmap is RGB9E5
float3 illuminance = float3(0.0, 0.0, 0.0);
// Remark: baked lightmap is RGBM for now, dynamic lightmap is RGB9E5
if (lightmapRGBM)
{
illuminance = UnpackLightmapRGBM(SAMPLE_TEXTURE2D(lightmapTex, lightmapSampler, uv).rgba);
}
else
{
illuminance = SAMPLE_TEXTURE2D(lightmapTex, lightmapSampler, uv).rgb;
}
float3 SampleDirectionalLightmap(TEXTURE2D_ARGS(lightmapTex, lightmapSampler), TEXTURE2D_ARGS(lightmapDirTex, lightmapDirSampler), float2 uv, float4 transform, float3 normalWS)
float3 SampleDirectionalLightmap(TEXTURE2D_ARGS(lightmapTex, lightmapSampler), TEXTURE2D_ARGS(lightmapDirTex, lightmapDirSampler), float2 uv, float4 transform, float3 normalWS, bool lightmapRGBM)
{
// In directional mode Enlighten bakes dominant light direction
// in a way, that using it for half Lambert and then dividing by a "rebalancing coefficient"

uv = uv * transform.xy + transform.zw;
float4 direction = SAMPLE_TEXTURE2D(lightmapDirTex, lightmapDirSampler, uv);
// Remark: Lightmap is RGB9E5
float3 illuminance = SAMPLE_TEXTURE2D(lightmapTex, lightmapSampler, uv).rgb;
// Remark: baked lightmap is RGBM for now, dynamic lightmap is RGB9E5
float3 illuminance = float3(0.0, 0.0, 0.0);
if (lightmapRGBM)
{
illuminance = UnpackLightmapRGBM(SAMPLE_TEXTURE2D(lightmapTex, lightmapSampler, uv).rgba);
}
else
{
illuminance = SAMPLE_TEXTURE2D(lightmapTex, lightmapSampler, uv).rgb;
}
#endif // UNITY_ENTITY_LIGHTING_INCLUDED
#endif // UNITY_ENTITY_LIGHTING_INCLUDED

40
Assets/ScriptableRenderLoop/ShaderLibrary/Packing.hlsl


return max(vRGB, float3(0.0, 0.0, 0.0));
}
// TODO: This function is used with the LightTransport pass to encode lightmap or emissive
float4 PackRGBM(float3 rgb, float maxRGBM)
{
float kOneOverRGBMMaxRange = 1.0 / maxRGBM;
const float kMinMultiplier = 2.0 * 1e-2;
float4 rgbm = float4(rgb * kOneOverRGBMMaxRange, 1.0);
rgbm.a = max(max(rgbm.r, rgbm.g), max(rgbm.b, kMinMultiplier));
rgbm.a = ceil(rgbm.a * 255.0) / 255.0;
// Division-by-zero warning from d3d9, so make compiler happy.
rgbm.a = max(rgbm.a, kMinMultiplier);
rgbm.rgb /= rgbm.a;
return rgbm;
}
// Alternative...
#define RGBMRANGE (8.0)
float4 PackRGBM(float3 color)
{
float4 rgbm;
color *= (1.0 / RGBMRANGE);
rgbm.a = saturate(max(max(color.r, color.g), max(color.b, 1e-6)));
rgbm.a = ceil(rgbm.a * 255.0) / 255.0;
rgbm.rgb = color / rgbm.a;
return rgbm;
}
float3 UnpackRGBM(float4 rgbm)
{
return RGBMRANGE * rgbm.rgb * rgbm.a;
}
// The standard 32-bit HDR color format
uint PackR11G11B10f(float3 rgb)
{

return PackFloatInt(f, i, maxi, 255.0);
}
float UnpackFloatInt8bit(float val, float maxi, out float f, out int i)
void UnpackFloatInt8bit(float val, float maxi, out float f, out int i)
{
UnpackFloatInt(val, maxi, 255.0, f, i);
}

return PackFloatInt(f, i, maxi, 1024.0);
}
float UnpackFloatInt10bit(float val, float maxi, out float f, out int i)
void UnpackFloatInt10bit(float val, float maxi, out float f, out int i)
{
UnpackFloatInt(val, maxi, 1024.0, f, i);
}

return PackFloatInt(f, i, maxi, 65536.0);
}
float UnpackFloatInt16bit(float val, float maxi, out float f, out int i)
void UnpackFloatInt16bit(float val, float maxi, out float f, out int i)
{
UnpackFloatInt(val, maxi, 65536.0, f, i);
}

136
Assets/ScriptableRenderLoop/ShaderLibrary/Tessellation.hlsl


#define TESSELLATION_INTERPOLATE_BARY(name, bary) ouput.name = input0.name * bary.x + input1.name * bary.y + input2.name * bary.z
float3 ProjectPointOnPlane(float3 position, float3 planePosition, float3 planeNormal)
{
return position - (dot(position - planePosition, planeNormal) * planeNormal);
}
// p0, p1, p2 triangle world position
// p0, p1, p2 triangle world vertex normal
float3 PhongTessellation(float3 positionWS, float3 p0, float3 p1, float3 p2, float3 n0, float3 n1, float3 n2, float3 baryCoords, float shape)
{
float3 c0 = ProjectPointOnPlane(positionWS, p0, n0);
float3 c1 = ProjectPointOnPlane(positionWS, p1, n1);
float3 c2 = ProjectPointOnPlane(positionWS, p2, n2);
float3 phongPositionWS = baryCoords.x * c0 + baryCoords.y * c1 + baryCoords.z * c2;
return lerp(positionWS, phongPositionWS, shape);
}
// ---- utility functions
float CalcDistanceTessFactor(float3 positionWS, float minDist, float maxDist, float4x4 objectToWorld, float3 cameraPosWS)
{
float dist = distance(positionWS, cameraPosWS);
float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0);
return f;
}
float4 UnityCalcTriEdgeTessFactors(float3 triVertexFactors)
{
float4 tess;
tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z);
tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z);
tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y);
tess.w = (triVertexFactors.x + triVertexFactors.y + triVertexFactors.z) / 3.0f;
return tess;
}
/*
float UnityCalcEdgeTessFactor(float3 wpos0, float3 wpos1, float edgeLen)
{
// distance to edge center
float dist = distance(0.5 * (wpos0 + wpos1), _WorldSpaceCameraPos);
// length of the edge
float len = distance(wpos0, wpos1);
// edgeLen is approximate desired size in pixels
float f = max(len * _ScreenParams.y / (edgeLen * dist), 1.0);
return f;
}
float UnityDistanceFromPlane(float3 pos, float4 plane)
{
float d = dot(float4(pos, 1.0f), plane);
return d;
}
// Returns true if triangle with given 3 world positions is outside of camera's view frustum.
// cullEps is distance outside of frustum that is still considered to be inside (i.e. max displacement)
bool UnityWorldViewFrustumCull(float3 wpos0, float3 wpos1, float3 wpos2, float cullEps)
{
float4 planeTest;
// left
planeTest.x = ((UnityDistanceFromPlane(wpos0, unity_CameraWorldClipPlanes[0]) > -cullEps) ? 1.0f : 0.0f) +
((UnityDistanceFromPlane(wpos1, unity_CameraWorldClipPlanes[0]) > -cullEps) ? 1.0f : 0.0f) +
((UnityDistanceFromPlane(wpos2, unity_CameraWorldClipPlanes[0]) > -cullEps) ? 1.0f : 0.0f);
// right
planeTest.y = ((UnityDistanceFromPlane(wpos0, unity_CameraWorldClipPlanes[1]) > -cullEps) ? 1.0f : 0.0f) +
((UnityDistanceFromPlane(wpos1, unity_CameraWorldClipPlanes[1]) > -cullEps) ? 1.0f : 0.0f) +
((UnityDistanceFromPlane(wpos2, unity_CameraWorldClipPlanes[1]) > -cullEps) ? 1.0f : 0.0f);
// top
planeTest.z = ((UnityDistanceFromPlane(wpos0, unity_CameraWorldClipPlanes[2]) > -cullEps) ? 1.0f : 0.0f) +
((UnityDistanceFromPlane(wpos1, unity_CameraWorldClipPlanes[2]) > -cullEps) ? 1.0f : 0.0f) +
((UnityDistanceFromPlane(wpos2, unity_CameraWorldClipPlanes[2]) > -cullEps) ? 1.0f : 0.0f);
// bottom
planeTest.w = ((UnityDistanceFromPlane(wpos0, unity_CameraWorldClipPlanes[3]) > -cullEps) ? 1.0f : 0.0f) +
((UnityDistanceFromPlane(wpos1, unity_CameraWorldClipPlanes[3]) > -cullEps) ? 1.0f : 0.0f) +
((UnityDistanceFromPlane(wpos2, unity_CameraWorldClipPlanes[3]) > -cullEps) ? 1.0f : 0.0f);
// has to pass all 4 plane tests to be visible
return !all(planeTest);
}
*/
// ---- functions that compute tessellation factors
// Distance based tessellation:
// Tessellation level is "tess" before "minDist" from camera, and linearly decreases to 1
// up to "maxDist" from camera.
float4 DistanceBasedTess(float3 p0, float3 p1, float3 p2, float minDist, float maxDist, float4x4 objectToWorld, float3 cameraPosWS)
{
float3 f;
f.x = CalcDistanceTessFactor(p0, minDist, maxDist, objectToWorld, cameraPosWS);
f.y = CalcDistanceTessFactor(p1, minDist, maxDist, objectToWorld, cameraPosWS);
f.z = CalcDistanceTessFactor(p2, minDist, maxDist, objectToWorld, cameraPosWS);
return UnityCalcTriEdgeTessFactors(f);
}
/*
// Desired edge length based tessellation:
// Approximate resulting edge length in pixels is "edgeLength".
// Does not take viewing FOV into account, just flat out divides factor by distance.
float4 UnityEdgeLengthBasedTess(float4 v0, float4 v1, float4 v2, float edgeLength)
{
float3 pos0 = mul(unity_ObjectToWorld, v0).xyz;
float3 pos1 = mul(unity_ObjectToWorld, v1).xyz;
float3 pos2 = mul(unity_ObjectToWorld, v2).xyz;
float4 tess;
tess.x = UnityCalcEdgeTessFactor(pos1, pos2, edgeLength);
tess.y = UnityCalcEdgeTessFactor(pos2, pos0, edgeLength);
tess.z = UnityCalcEdgeTessFactor(pos0, pos1, edgeLength);
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
return tess;
}
// Same as UnityEdgeLengthBasedTess, but also does patch frustum culling:
// patches outside of camera's view are culled before GPU tessellation. Saves some wasted work.
float4 UnityEdgeLengthBasedTessCull(float4 v0, float4 v1, float4 v2, float edgeLength, float maxDisplacement)
{
float3 pos0 = mul(unity_ObjectToWorld, v0).xyz;
float3 pos1 = mul(unity_ObjectToWorld, v1).xyz;
float3 pos2 = mul(unity_ObjectToWorld, v2).xyz;
float4 tess;
if (UnityWorldViewFrustumCull(pos0, pos1, pos2, maxDisplacement))
{
tess = 0.0f;
}
else
{
tess.x = UnityCalcEdgeTessFactor(pos1, pos2, edgeLength);
tess.y = UnityCalcEdgeTessFactor(pos2, pos0, edgeLength);
tess.z = UnityCalcEdgeTessFactor(pos0, pos1, edgeLength);
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
}
return tess;
}
*/

2
Assets/ScriptableRenderLoop/common/TextureCache.cs


}
public abstract class TextureCache : Object
public abstract class TextureCache
{
protected int m_NumMipLevels;

18
Assets/TestScenes/HDTest/LayeredLitTest.unity


m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 112888599}
m_LocalRotation: {x: 0.4442191, y: -0, z: -0, w: 0.8959182}
m_LocalPosition: {x: -41.31, y: -1.55, z: 13.03}
m_LocalPosition: {x: -41.514, y: -1.55, z: 12.008}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1732353142}

format: 0
dimension: 4
m_DataSize: 2200
_typelessdata: 020020c1feff1fc10000002900000000000000000000803ffffefe3efffefe3efffefe3e0000803ffeff7f3f00000033d4fd4d3e9c3c10be326ca43fe8df5bbf0000003f0000003f000080bf0000000000000000000080bf0300a0c0ffff1fc17cac6a3400000000000000000000803f8848fc3efffefe3efffefe3e0000803fffff3f3f0000003370deec3d2ca6c03d52aa3f3f061e37bf0000003f0000003f000080bf0000000000000000000080bf0200a0c0feff9fc00000802800000000000000000000803ffffefe3efffefe3efffefe3e0000803fffff3f3f0000803e757fb33eb2e1373e326c643fd0bf37be0000003f0000003f000080bf0000000000000000000080bf010020c1fdff9fc079ac6ab400000000000000000000803ffffefe3efffefe3efffefe3e0000803ffeff7f3f0000803ec346df3e00b862bd23cdb63fa863a5be0000003f0000003f000080bf0000000000000000000080bf0000a0c01fab5a357aac6ab400000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000403fffffff3ea7e3153f27b8873e0a97843f3f7cb63e0000003f0000003f000080bf0000000000000000000080bf000020c11fabda357aaceab400000000000000000000803ffffefe3efffefe3efffefe3e0000803fffff7f3fffffff3e4ec72b3fe004f73c132ec93ffcf0593e0000003f0000003f000080bf0000000000000000000080bffeff9fc00200a0407aaceab400000000000000000000803f8b3ade3cfffefe3efffefe3e0000803f0000403fffff3f3f9407523f757fb33efaf7963f326c643f0000003f0000003f000080bf0000000000000000000080bfffff1fc10300a0405c0130b500000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000803fffff3f3f3aeb673f70deec3d038fdb3f52aa3f3f0000003f0000003f000080bf0000000000000000000080bffdff9fc0010020415c0130b500000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000403ffeff7f3fc015873fc346df3eea58a93f23cdb63f0000003f0000003f000080bf0000000000000000000080bffeff1fc1020020417aac6ab500000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000803ffeff7f3f9407923fd4fd4d3ef4efed3f326ca43f0000003f0000003f000080bf0000000000000000000080bf1fab5ab50000a0c07bac6a3400000000000000000000803ffffefe3efffefe3efffefe3e0000803fffffff3e0100803e27b8873eb238d43e3f7cb63e30e112bd0000003f0000003f000080bf0000000000000000000080bf1fabdab5000020c17bacea3400000000000000000000803f7994f23efffefe3efffefe3e0000803fffffff3e00008033e004f73c6471a83efcf0593e265c12bf0000003f0000003f000080bf0000000000000000000080bf00000000000000000000000000000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000003f0000003f0000003f0000003f0000003f0000003f0000003f0000003f000080bf0000000000000000000080bf1fab5a350000a0407bac6ab400000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000003f0000403fec233c3fa7e3153fe0c1243f0a97843f0000003f0000003f000080bf0000000000000000000080bf1fabda35000020417baceab400000000000000000000803ffffefe3efffefe3efffefe3e0000803f0100003fffff7f3fd947783f4ec72b3fc183493f132ec93f0000003f0000003f000080bf0000000000000000000080bffeff9f400200a0c07aacea3400000000000000000000803f876de337da4f563eda4f563e0000803f0000803e0200803eb2e1373e4640263fd0bf37be6c9edc3d0000003f0000003f000080bf0000000000000000000080bffdff9f40010020c15c01303500000000000000000000803ff0d72e38fffefe3efffefe3e0000803f0000803e0000c03300b862bd9e5c103fa863a5be8c34dbbe0000003f0000003f000080bf0000000000000000000080bf0000a0401fab5ab57aac6a3400000000000000000000803ffffefe3efffefe3efffefe3e0000803f0100803e0000003fb238d43eec233c3f30e112bde0c1243f0000003f0000003f000080bf0000000000000000000080bf0200a040feff9f40000080a800000000000000000000803ffffefe3efffefe3efffefe3e0000803f0200803e0000403f4640263f9407523f6c9edc3dfaf7963f0000003f0000003f000080bf0000000000000000000080bf0300a040ffff1f417cac6ab400000000000000000000803ffffefe3efffefe3efffefe3e0000803f0200803e0000803f3264623f3aeb673f5cab803e038fdb3f0000003f0000003f000080bf0000000000000000000080bfffff1f410300a0c05c01303500000000000000000000803f59fb0d30fffefe3efffefe3e0000803f000000330200803e2ca6c03d3264623f061e37bf5cab803e0000003f0000003f000080bf0000000000000000000080bffeff1f41020020c17aac6a3500000000000000000000803fdc5cbd3afffefe3efffefe3e0000803f000000330000c0339c3c10be8b804c3fe8df5bbfcab091be0000003f0000003f000080bf0000000000000000000080bf000020411fabdab57aacea3400000000000000000000803ffffefe3efffefe3efffefe3e0000803f000080330100003f6471a83ed947783f265c12bfc183493f0000003f0000003f000080bf0000000000000000000080bf01002041fdff9f4079ac6a3400000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000c0330000403f9e5c103fc015873f8c34dbbeea58a93f0000003f0000003f000080bf0000000000000000000080bf02002041feff1f41000000a900000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000c0330000803f8b804c3f9407923fcab091bef4efed3f0000003f0000003f000080bf0000000000000000000080bf
_typelessdata: 020020c1feff1fc10000002900000000000000000000803ffffefe3efffefe3efffefe3e0000803ffeff7f3f00000033d4fd4d3e9c3c10be326ca43fe8df5bbf0000003f0000003f000080bf0000000000000000000080bf0300a0c0ffff1fc17cac6a3400000000000000000000803ffffefe3efffefe3efffefe3e0000803fffff3f3f0000003370deec3d2ca6c03d52aa3f3f061e37bf0000003f0000003f000080bf0000000000000000000080bf0200a0c0feff9fc00000802800000000000000000000803ffffefe3efffefe3efffefe3e0000803fffff3f3f0000803e757fb33eb2e1373e326c643fd0bf37be0000003f0000003f000080bf0000000000000000000080bf010020c1fdff9fc079ac6ab400000000000000000000803ffffefe3efffefe3efffefe3e0000803ffeff7f3f0000803ec346df3e00b862bd23cdb63fa863a5be0000003f0000003f000080bf0000000000000000000080bf0000a0c01fab5a357aac6ab400000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000403fffffff3ea7e3153f27b8873e0a97843f3f7cb63e0000003f0000003f000080bf0000000000000000000080bf000020c11fabda357aaceab400000000000000000000803ffffefe3efffefe3efffefe3e0000803fffff7f3fffffff3e4ec72b3fe004f73c132ec93ffcf0593e0000003f0000003f000080bf0000000000000000000080bffeff9fc00200a0407aaceab400000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000403fffff3f3f9407523f757fb33efaf7963f326c643f0000003f0000003f000080bf0000000000000000000080bfffff1fc10300a0405c0130b500000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000803fffff3f3f3aeb673f70deec3d038fdb3f52aa3f3f0000003f0000003f000080bf0000000000000000000080bffdff9fc0010020415c0130b500000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000403ffeff7f3fc015873fc346df3eea58a93f23cdb63f0000003f0000003f000080bf0000000000000000000080bffeff1fc1020020417aac6ab500000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000803ffeff7f3f9407923fd4fd4d3ef4efed3f326ca43f0000003f0000003f000080bf0000000000000000000080bf1fab5ab50000a0c07bac6a3400000000000000000000803ffffefe3efffefe3efffefe3e0000803fffffff3e0100803e27b8873eb238d43e3f7cb63e30e112bd0000003f0000003f000080bf0000000000000000000080bf1fabdab5000020c17bacea3400000000000000000000803ffffefe3efffefe3efffefe3e0000803fffffff3e00008033e004f73c6471a83efcf0593e265c12bf0000003f0000003f000080bf0000000000000000000080bf00000000000000000000000000000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000003f0000003f0000003f0000003f0000003f0000003f0000003f0000003f000080bf0000000000000000000080bf1fab5a350000a0407bac6ab400000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000003f0000403fec233c3fa7e3153fe0c1243f0a97843f0000003f0000003f000080bf0000000000000000000080bf1fabda35000020417baceab400000000000000000000803ffffefe3efffefe3efffefe3e0000803f0100003fffff7f3fd947783f4ec72b3fc183493f132ec93f0000003f0000003f000080bf0000000000000000000080bffeff9f400200a0c07aacea3400000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000803e0200803eb2e1373e4640263fd0bf37be6c9edc3d0000003f0000003f000080bf0000000000000000000080bffdff9f40010020c15c01303500000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000803e0000c03300b862bd9e5c103fa863a5be8c34dbbe0000003f0000003f000080bf0000000000000000000080bf0000a0401fab5ab57aac6a3400000000000000000000803ffffefe3efffefe3efffefe3e0000803f0100803e0000003fb238d43eec233c3f30e112bde0c1243f0000003f0000003f000080bf0000000000000000000080bf0200a040feff9f40000080a800000000000000000000803ffffefe3efffefe3efffefe3e0000803f0200803e0000403f4640263f9407523f6c9edc3dfaf7963f0000003f0000003f000080bf0000000000000000000080bf0300a040ffff1f417cac6ab400000000000000000000803ffffefe3efffefe3efffefe3e0000803f0200803e0000803f3264623f3aeb673f5cab803e038fdb3f0000003f0000003f000080bf0000000000000000000080bfffff1f410300a0c05c01303500000000000000000000803ffffefe3efffefe3efffefe3e0000803f000000330200803e2ca6c03d3264623f061e37bf5cab803e0000003f0000003f000080bf0000000000000000000080bffeff1f41020020c17aac6a3500000000000000000000803ffffefe3efffefe3efffefe3e0000803f000000330000c0339c3c10be8b804c3fe8df5bbfcab091be0000003f0000003f000080bf0000000000000000000080bf000020411fabdab57aacea3400000000000000000000803ffffefe3efffefe3efffefe3e0000803f000080330100003f6471a83ed947783f265c12bfc183493f0000003f0000003f000080bf0000000000000000000080bf01002041fdff9f4079ac6a3400000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000c0330000403f9e5c103fc015873f8c34dbbeea58a93f0000003f0000003f000080bf0000000000000000000080bf02002041feff1f41000000a900000000000000000000803ffffefe3efffefe3efffefe3e0000803f0000c0330000803f8b804c3f9407923fcab091bef4efed3f0000003f0000003f000080bf0000000000000000000080bf
m_CompressedMesh:
m_Vertices:
m_NumItems: 0

- {x: -0.28455192, y: 1.8588853}
_colors:
- {r: 0.49803922, g: 0.49803922, b: 0.49803922, a: 1}
- {r: 0.49274087, g: 0.49803922, b: 0.49803922, a: 1}
- {r: 0.027127525, g: 0.49803922, b: 0.49803922, a: 1}
- {r: 0.473789, g: 0.49803922, b: 0.49803922, a: 1}
- {r: 0.000027111511, g: 0.20928898, b: 0.20928898, a: 1}
- {r: 0.00004168594, g: 0.49803922, b: 0.49803922, a: 1}
- {r: 5.165269e-10, g: 0.49803922, b: 0.49803922, a: 1}
- {r: 0.001444723, g: 0.49803922, b: 0.49803922, a: 1}
- {r: 0.49803922, g: 0.49803922, b: 0.49803922, a: 1}
- {r: 0.49803922, g: 0.49803922, b: 0.49803922, a: 1}
- {r: 0.49803922, g: 0.49803922, b: 0.49803922, a: 1}
- {r: 0.49803922, g: 0.49803922, b: 0.49803922, a: 1}
- {r: 0.49803922, g: 0.49803922, b: 0.49803922, a: 1}
- {r: 0.49803922, g: 0.49803922, b: 0.49803922, a: 1}
- {r: 0.49803922, g: 0.49803922, b: 0.49803922, a: 1}
- {r: 0.49803922, g: 0.49803922, b: 0.49803922, a: 1}
- {r: 0.49803922, g: 0.49803922, b: 0.49803922, a: 1}
- {r: 0.49803922, g: 0.49803922, b: 0.49803922, a: 1}

30
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_HeightBased.mat


- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _BlendMode: 0
- _BlendSize1: 0.0035
- _BlendSize2: 0.0034
- _BlendSize3: 0.0018
- _BlendSize1: 0.023
- _BlendSize2: 0.011
- _BlendSize3: 0.008
- _BumpScale: 1
- _CullMode: 2
- _Cutoff: 0.5

- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _HeightAmplitude0: 0.25
- _HeightAmplitude1: 0.15
- _HeightAmplitude2: 0.1
- _HeightAmplitude3: 0.15
- _HeightFactor1: 1.81
- _HeightCenter0: 0.5
- _HeightCenter1: 0.5
- _HeightCenter2: 0.5
- _HeightCenter3: 0.5
- _HeightFactor1: 1
- _HeightFactor3: 0.62
- _HeightFactor3: 1
- _HeightOffset1: -0.003
- _HeightOffset2: 0.01
- _HeightOffset3: 0.003
- _HeightOffset1: 0.057
- _HeightOffset2: 0.015
- _HeightOffset3: 0
- _HeightScale0: 0.127
- _HeightScale1: 0.1
- _HeightScale2: 0.05

- _Metallic3: 0
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale0: 1
- _NormalScale1: 1
- _NormalScale2: 1
- _NormalScale3: 1
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Smoothness0: 0.5

- _UseHeightBasedBlend1: 1
- _UseHeightBasedBlend2: 1
- _UseHeightBasedBlend3: 1
- _VertexColorHeightFactor: 0.19
- _VertexColorHeightFactor: 0.3
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

24
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Planar.mat


m_Name: Layered_Layer0_Planar
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MAPPING_TRIPLANAR_0 _LAYER_MASK_VERTEX_COLOR
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _LAYER_MASK_VERTEX_COLOR_MUL
disabledShaderPasses: []
disabledShaderPasses:
- DistortionVectors
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _HeightAmplitude0: 0.01
- _HeightAmplitude1: 0.01
- _HeightAmplitude2: 1
- _HeightAmplitude3: 1
- _HeightCenter0: 0.5
- _HeightCenter1: 0.5
- _HeightCenter2: 0
- _HeightCenter3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _HeightScale1: 1
- _HeightScale2: 1
- _HeightScale3: 1
- _InheritBaseLayer1: 0
- _InheritBaseLayer2: 0
- _InheritBaseLayer3: 0
- _LayerCount: 2
- _LayerMaskVertexColor: 1
- _Metallic: 0

- _Metallic3: 0
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale0: 1
- _NormalScale1: 1
- _NormalScale2: 1
- _NormalScale3: 1
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Smoothness0: 0.5

- _UVDetailsMappingMask1: 0
- _UVDetailsMappingMask2: 0
- _UVDetailsMappingMask3: 0
- _UVMappingPlanar0: 0
- _UVMappingPlanar0: 1
- _UseHeightBasedBlend: 0
- _VertexColorHeightFactor: 0.3
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

19
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Triplanar.mat


m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MAPPING_TRIPLANAR_0 _LAYER_MASK_VERTEX_COLOR
_NORMALMAP_TANGENT_SPACE
_LAYER_MASK_VERTEX_COLOR_MUL _NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}

- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _HeightAmplitude0: 0.01
- _HeightAmplitude1: 0.01
- _HeightAmplitude2: 1
- _HeightAmplitude3: 1
- _HeightCenter0: 0.5
- _HeightCenter1: 0.5
- _HeightCenter2: 0
- _HeightCenter3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _HeightScale1: 1
- _HeightScale2: 1
- _HeightScale3: 1
- _InheritBaseLayer1: 0
- _InheritBaseLayer2: 0
- _InheritBaseLayer3: 0
- _LayerCount: 2
- _LayerMaskVertexColor: 1
- _Metallic: 0

- _Metallic3: 0
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale0: 1
- _NormalScale1: 1
- _NormalScale2: 1
- _NormalScale3: 1
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Smoothness0: 0.5

- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UVSec: 0
- _UseHeightBasedBlend: 0
- _VertexColorHeightFactor: 0.3
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

20
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV0.mat


m_Name: Layered_Layer0_UV0
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _LAYER_MASK_VERTEX_COLOR_MUL
_NORMALMAP_TANGENT_SPACE
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}

- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _HeightAmplitude0: 0.01
- _HeightAmplitude1: 0.01
- _HeightAmplitude2: 1
- _HeightAmplitude3: 1
- _HeightCenter0: 0.5
- _HeightCenter1: 0.5
- _HeightCenter2: 0
- _HeightCenter3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _HeightScale1: 1
- _HeightScale2: 1
- _HeightScale3: 1
- _InheritBaseLayer1: 0
- _InheritBaseLayer2: 0
- _InheritBaseLayer3: 0
- _LayerCount: 2
- _LayerMaskVertexColor: 1
- _Metallic: 0

- _Metallic3: 0
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale0: 1
- _NormalScale1: 1
- _NormalScale2: 1
- _NormalScale3: 1
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Smoothness0: 0.5

- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UVSec: 0
- _UseHeightBasedBlend: 0
- _VertexColorHeightFactor: 0.3
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

23
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV1.mat


m_Name: Layered_Layer0_UV1
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _LAYER_MASK_VERTEX_COLOR_MUL
_NORMALMAP_TANGENT_SPACE
disabledShaderPasses: []
disabledShaderPasses:
- DistortionVectors
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:

- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _HeightAmplitude0: 0.01
- _HeightAmplitude1: 0.01
- _HeightAmplitude2: 1
- _HeightAmplitude3: 1
- _HeightCenter0: 0.5
- _HeightCenter1: 0.5
- _HeightCenter2: 0
- _HeightCenter3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _HeightScale1: 1
- _HeightScale2: 1
- _HeightScale3: 1
- _InheritBaseLayer1: 0
- _InheritBaseLayer2: 0
- _InheritBaseLayer3: 0
- _LayerCount: 2
- _LayerMaskVertexColor: 1
- _Metallic: 0

- _Metallic3: 0
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale0: 1
- _NormalScale1: 1
- _NormalScale2: 1
- _NormalScale3: 1
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Smoothness0: 0.5

- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UVSec: 0
- _UseHeightBasedBlend: 0
- _VertexColorHeightFactor: 0.3
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

21
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV2.mat


m_Name: Layered_Layer0_UV2
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
_REQUIRE_UV2_OR_UV3 _REQUIRE_UV3
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _LAYER_MASK_VERTEX_COLOR_MUL
_NORMALMAP_TANGENT_SPACE _REQUIRE_UV2_OR_UV3 _REQUIRE_UV3
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}

- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _HeightAmplitude0: 0.01
- _HeightAmplitude1: 0.01
- _HeightAmplitude2: 1
- _HeightAmplitude3: 1
- _HeightCenter0: 0.5
- _HeightCenter1: 0.5
- _HeightCenter2: 0
- _HeightCenter3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _HeightScale1: 1
- _HeightScale2: 1
- _HeightScale3: 1
- _InheritBaseLayer1: 0
- _InheritBaseLayer2: 0
- _InheritBaseLayer3: 0
- _LayerCount: 2
- _LayerMaskVertexColor: 1
- _Metallic: 0

- _Metallic3: 0
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale0: 1
- _NormalScale1: 1
- _NormalScale2: 1
- _NormalScale3: 1
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Smoothness0: 0.5

- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UVSec: 0
- _UseHeightBasedBlend: 0
- _VertexColorHeightFactor: 0.3
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

21
Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV3.mat


m_Name: Layered_Layer0_UV3
m_Shader: {fileID: 4800000, guid: 81d02e8644315b742b154842a3a2f98c, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _DETAIL_MAP _DETAIL_MAP_WITH_NORMAL _DISTORTIONDEPTHTEST_OFF
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _NORMALMAP_TANGENT_SPACE
_REQUIRE_UV2_OR_UV3 _REQUIRE_UV3
_DISTORTIONONLY_OFF _EMISSION _EMISSIVE_COLOR _LAYER_MASK_VERTEX_COLOR _LAYER_MASK_VERTEX_COLOR_MUL
_NORMALMAP_TANGENT_SPACE _REQUIRE_UV2_OR_UV3 _REQUIRE_UV3
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}

- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _HeightAmplitude0: 0.01
- _HeightAmplitude1: 0.01
- _HeightAmplitude2: 1
- _HeightAmplitude3: 1
- _HeightCenter0: 0.5
- _HeightCenter1: 0.5
- _HeightCenter2: 0
- _HeightCenter3: 0
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _HeightScale1: 1
- _HeightScale2: 1
- _HeightScale3: 1
- _InheritBaseLayer1: 0
- _InheritBaseLayer2: 0
- _InheritBaseLayer3: 0
- _LayerCount: 2
- _LayerMaskVertexColor: 1
- _Metallic: 0

- _Metallic3: 0
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale0: 1
- _NormalScale1: 1
- _NormalScale2: 1
- _NormalScale3: 1
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Smoothness0: 0.5

- _UVMappingPlanar2: 0
- _UVMappingPlanar3: 0
- _UVSec: 0
- _UseHeightBasedBlend: 0
- _VertexColorHeightFactor: 0.3
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:

7
Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_Ground_01_2x2.mat


- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _HeightBias: -0.03
- _HeightAmplitude: 0.15
- _HeightBias: -0.01
- _HeightCenter: 0.5
- _HeightScale: 0.06
- _HeightScale: 0.02
- _NormalScale: 1
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Smoothness: 1

3
Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_Moss_02_2x2.mat


- _GlossMapScale: 0
- _Glossiness: 0.5
- _GlossyReflections: 1
- _HeightAmplitude: 0.1
- _HeightCenter: 0.5
- _HeightMapMode: 0
- _HeightScale: 0.05
- _MaterialId: 0

- _NormalMapSpace: 0
- _NormalScale: 1
- _OcclusionStrength: 1
- _Parallax: 0.08
- _Smoothness: 1

3
Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_Sand01_2x2.mat


- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 1
- _HeightAmplitude: 0.15
- _HeightCenter: 0.5
- _HeightMapMode: 0
- _HeightScale: 0.1
- _MaterialId: 0

- _NormalMapSpace: 0
- _NormalScale: 1
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Smoothness: 1

3
Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_Spheres.mat


- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _HeightAmplitude: 0.25
- _HeightCenter: 0.5
- _HeightFactor1: 1
- _HeightFactor2: 1
- _HeightFactor3: 1

- _Metallic3: 0
- _Mode: 0
- _NormalMapSpace: 0
- _NormalScale: 1
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Smoothness: 0.5

2
Assets/TestScenes/HDTest/LayeredLitTest/Textures/VolumeTest_01_H.tga.meta


mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0

68
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl


#endif
#define NEED_TEXCOORD0 defined(_ALPHATEST_ON)
#define NEED_TANGENT_TO_WORLD NEED_TEXCOORD0 && (defined(_HEIGHTMAP) && !defined(_HEIGHTMAP_AS_DISPLACEMENT))
#define NEED_TANGENT_TO_WORLD NEED_TEXCOORD0 && (defined(_HEIGHTMAP) && defined(_PER_PIXEL_DISPLACEMENT))
struct Attributes
{

float2 uv0 : TEXCOORD0;
#endif
#if NEED_TANGENT_TO_WORLD
// float3 normalOS : NORMAL; // TODO: This won't compile as we conflict with previousPositionOS. FIXME
#ifdef TESSELLATION_ON
// Copy paste of above struct with POSITION rename to INTERNALTESSPOS (internal of unity shader compiler)
struct AttributesTessellation
{
float3 positionOS : INTERNALTESSPOS;
float3 previousPositionOS : NORMAL;
#if NEED_TEXCOORD0
float2 uv0 : TEXCOORD0;
#endif
#if NEED_TANGENT_TO_WORLD
// float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
#endif
};
AttributesTessellation AttributesToAttributesTessellation(Attributes input)
{
AttributesTessellation output;
output.positionOS = input.positionOS;
output.previousPositionOS = input.previousPositionOS;
#if NEED_TEXCOORD0
output.uv0 = input.uv0;
#endif
#if NEED_TANGENT_TO_WORLD
// output.normalOS = input.normalOS;
output.tangentOS = input.tangentOS;
#endif
return output;
}
Attributes AttributesTessellationToAttributes(AttributesTessellation input)
{
Attributes output;
output.positionOS = input.positionOS;
output.previousPositionOS = input.previousPositionOS;
#if NEED_TEXCOORD0
output.uv0 = input.uv0;
#endif
#if NEED_TANGENT_TO_WORLD
// output.normalOS = input.normalOS;
output.tangentOS = input.tangentOS;
#endif
return output;
}
AttributesTessellation InterpolateWithBaryCoords(AttributesTessellation input0, AttributesTessellation input1, AttributesTessellation input2, float3 baryCoords)
{
AttributesTessellation ouput;
TESSELLATION_INTERPOLATE_BARY(positionOS, baryCoords);
TESSELLATION_INTERPOLATE_BARY(previousPositionOS, baryCoords);
#if NEED_TEXCOORD0
TESSELLATION_INTERPOLATE_BARY(uv0, baryCoords);
#endif
#if NEED_TANGENT_TO_WORLD
// TESSELLATION_INTERPOLATE_BARY(normalOS, baryCoords);
TESSELLATION_INTERPOLATE_BARY(tangentOS, baryCoords);
#endif
return ouput;
}
#endif // TESSELLATION_ON
struct Varyings
{

78
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitSharePass.hlsl


// UNITY_INSTANCE_ID
};
#ifdef TESSELLATION_ON
// Copy paste of above struct with POSITION rename to INTERNALTESSPOS (internal of unity shader compiler)
struct AttributesTessellation
{
float3 positionOS : INTERNALTESSPOS;
float3 normalOS : NORMAL;
float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
#if WANT_UV2
float2 uv2 : TEXCOORD2;
#endif
#if WANT_UV3
float2 uv3 : TEXCOORD3;
#endif
float4 tangentOS : TANGENT; // Always present as we require it also in case of anisotropic lighting
float4 color : COLOR;
};
AttributesTessellation AttributesToAttributesTessellation(Attributes input)
{
AttributesTessellation output;
output.positionOS = input.positionOS;
output.normalOS = input.normalOS;
output.uv0 = input.uv0;
output.uv1 = input.uv1;
#if WANT_UV2
output.uv2 = input.uv2;
#endif
#if WANT_UV3
output.uv3 = input.uv3;
#endif
output.tangentOS = input.tangentOS;
output.color = input.color;
return output;
}
Attributes AttributesTessellationToAttributes(AttributesTessellation input)
{
Attributes output;
output.positionOS = input.positionOS;
output.normalOS = input.normalOS;
output.uv0 = input.uv0;
output.uv1 = input.uv1;
#if WANT_UV2
output.uv2 = input.uv2;
#endif
#if WANT_UV3
output.uv3 = input.uv3;
#endif
output.tangentOS = input.tangentOS;
output.color = input.color;
return output;
}
AttributesTessellation InterpolateWithBaryCoords(AttributesTessellation input0, AttributesTessellation input1, AttributesTessellation input2, float3 baryCoords)
{
AttributesTessellation ouput;
TESSELLATION_INTERPOLATE_BARY(positionOS, baryCoords);
TESSELLATION_INTERPOLATE_BARY(normalOS, baryCoords);
TESSELLATION_INTERPOLATE_BARY(uv0, baryCoords);
TESSELLATION_INTERPOLATE_BARY(uv1, baryCoords);
#if WANT_UV2
TESSELLATION_INTERPOLATE_BARY(uv2, baryCoords);
#endif
#if WANT_UV3
TESSELLATION_INTERPOLATE_BARY(uv3, baryCoords);
#endif
TESSELLATION_INTERPOLATE_BARY(tangentOS, baryCoords);
TESSELLATION_INTERPOLATE_BARY(color, baryCoords);
return ouput;
}
#endif // TESSELLATION_ON
struct Varyings
{
float4 positionCS;

56
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDistortionPass.hlsl


#error Undefine_SHADERPASS
#endif
#define NEED_TANGENT_TO_WORLD NEED_TEXCOORD0 && (defined(_HEIGHTMAP) && !defined(_HEIGHTMAP_AS_DISPLACEMENT))
#define NEED_TANGENT_TO_WORLD NEED_TEXCOORD0 && (defined(_HEIGHTMAP) && defined(_PER_PIXEL_DISPLACEMENT))
struct Attributes
{

float3 normalOS : NORMAL;
#ifdef TESSELLATION_ON
// Copy paste of above struct with POSITION rename to INTERNALTESSPOS (internal of unity shader compiler)
struct AttributesTessellation
{
float3 positionOS : INTERNALTESSPOS;
float2 uv0 : TEXCOORD0;
#if NEED_TANGENT_TO_WORLD
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
#endif
};
AttributesTessellation AttributesToAttributesTessellation(Attributes input)
{
AttributesTessellation output;
output.positionOS = input.positionOS;
output.uv0 = input.uv0;
#if NEED_TANGENT_TO_WORLD
output.normalOS = input.normalOS;
output.tangentOS = input.tangentOS;
#endif
return output;
}
Attributes AttributesTessellationToAttributes(AttributesTessellation input)
{
Attributes output;
output.positionOS = input.positionOS;
output.uv0 = input.uv0;
#if NEED_TANGENT_TO_WORLD
output.normalOS = input.normalOS;
output.tangentOS = input.tangentOS;
#endif
return output;
}
AttributesTessellation InterpolateWithBaryCoords(AttributesTessellation input0, AttributesTessellation input1, AttributesTessellation input2, float3 baryCoords)
{
AttributesTessellation ouput;
TESSELLATION_INTERPOLATE_BARY(positionOS, baryCoords);
TESSELLATION_INTERPOLATE_BARY(uv0, baryCoords);
#if NEED_TANGENT_TO_WORLD
TESSELLATION_INTERPOLATE_BARY(normalOS, baryCoords);
TESSELLATION_INTERPOLATE_BARY(tangentOS, baryCoords);
#endif
return ouput;
}
#endif // TESSELLATION_ON
struct Varyings
{

513
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader


Shader "HDRenderPipeline/LayeredLitTesselation"
{
Properties
{
// Following set of parameters represent the parameters node inside the MaterialGraph.
// They are use to fill a SurfaceData. With a MaterialGraph this should not exist.
// Reminder. Color here are in linear but the UI (color picker) do the conversion sRGB to linear
_BaseColor0("BaseColor0", Color) = (1, 1, 1, 1)
_BaseColor1("BaseColor1", Color) = (1, 1, 1, 1)
_BaseColor2("BaseColor2", Color) = (1, 1, 1, 1)
_BaseColor3("BaseColor3", Color) = (1, 1, 1, 1)
_BaseColorMap0("BaseColorMap0", 2D) = "white" {}
_BaseColorMap1("BaseColorMap1", 2D) = "white" {}
_BaseColorMap2("BaseColorMap2", 2D) = "white" {}
_BaseColorMap3("BaseColorMap3", 2D) = "white" {}
_Metallic0("Metallic0", Range(0.0, 1.0)) = 0
_Metallic1("Metallic1", Range(0.0, 1.0)) = 0
_Metallic2("Metallic2", Range(0.0, 1.0)) = 0
_Metallic3("Metallic3", Range(0.0, 1.0)) = 0
_Smoothness0("Smoothness0", Range(0.0, 1.0)) = 0.5
_Smoothness1("Smoothness1", Range(0.0, 1.0)) = 0.5
_Smoothness2("Smoothness2", Range(0.0, 1.0)) = 0.5
_Smoothness3("Smoothness3", Range(0.0, 1.0)) = 0.5
_MaskMap0("MaskMap0", 2D) = "white" {}
_MaskMap1("MaskMap1", 2D) = "white" {}
_MaskMap2("MaskMap2", 2D) = "white" {}
_MaskMap3("MaskMap3", 2D) = "white" {}
_SpecularOcclusionMap0("SpecularOcclusion0", 2D) = "white" {}
_SpecularOcclusionMap1("SpecularOcclusion1", 2D) = "white" {}
_SpecularOcclusionMap2("SpecularOcclusion2", 2D) = "white" {}
_SpecularOcclusionMap3("SpecularOcclusion3", 2D) = "white" {}
_NormalMap0("NormalMap0", 2D) = "bump" {}
_NormalMap1("NormalMap1", 2D) = "bump" {}
_NormalMap2("NormalMap2", 2D) = "bump" {}
_NormalMap3("NormalMap3", 2D) = "bump" {}
_NormalScale0("_NormalScale0", Range(0.0, 2.0)) = 1
_NormalScale1("_NormalScale1", Range(0.0, 2.0)) = 1
_NormalScale2("_NormalScale2", Range(0.0, 2.0)) = 1
_NormalScale3("_NormalScale3", Range(0.0, 2.0)) = 1
_HeightMap0("HeightMap0", 2D) = "black" {}
_HeightMap1("HeightMap1", 2D) = "black" {}
_HeightMap2("HeightMap2", 2D) = "black" {}
_HeightMap3("HeightMap3", 2D) = "black" {}
_HeightAmplitude0("Height Scale0", Float) = 1
_HeightAmplitude1("Height Scale1", Float) = 1
_HeightAmplitude2("Height Scale2", Float) = 1
_HeightAmplitude3("Height Scale3", Float) = 1
_HeightCenter0("Height Bias0", Float) = 0
_HeightCenter1("Height Bias1", Float) = 0
_HeightCenter2("Height Bias2", Float) = 0
_HeightCenter3("Height Bias3", Float) = 0
_DetailMap0("DetailMap0", 2D) = "black" {}
_DetailMap1("DetailMap1", 2D) = "black" {}
_DetailMap2("DetailMap2", 2D) = "black" {}
_DetailMap3("DetailMap3", 2D) = "black" {}
_DetailMask0("DetailMask0", 2D) = "white" {}
_DetailMask1("DetailMask1", 2D) = "white" {}
_DetailMask2("DetailMask2", 2D) = "white" {}
_DetailMask3("DetailMask3", 2D) = "white" {}
_DetailAlbedoScale0("_DetailAlbedoScale0", Range(-2.0, 2.0)) = 1
_DetailAlbedoScale1("_DetailAlbedoScale1", Range(-2.0, 2.0)) = 1
_DetailAlbedoScale2("_DetailAlbedoScale2", Range(-2.0, 2.0)) = 1
_DetailAlbedoScale3("_DetailAlbedoScale3", Range(-2.0, 2.0)) = 1
_DetailNormalScale0("_DetailNormalScale0", Range(0.0, 2.0)) = 1
_DetailNormalScale1("_DetailNormalScale1", Range(0.0, 2.0)) = 1
_DetailNormalScale2("_DetailNormalScale2", Range(0.0, 2.0)) = 1
_DetailNormalScale3("_DetailNormalScale3", Range(0.0, 2.0)) = 1
_DetailSmoothnessScale0("_DetailSmoothnessScale0", Range(-2.0, 2.0)) = 1
_DetailSmoothnessScale1("_DetailSmoothnessScale1", Range(-2.0, 2.0)) = 1
_DetailSmoothnessScale2("_DetailSmoothnessScale2", Range(-2.0, 2.0)) = 1
_DetailSmoothnessScale3("_DetailSmoothnessScale3", Range(-2.0, 2.0)) = 1
_DetailHeightScale0("_DetailHeightScale0", Range(-2.0, 2.0)) = 1
_DetailHeightScale1("_DetailHeightScale1", Range(-2.0, 2.0)) = 1
_DetailHeightScale2("_DetailHeightScale2", Range(-2.0, 2.0)) = 1
_DetailHeightScale3("_DetailHeightScale3", Range(-2.0, 2.0)) = 1
_DetailAOScale0("_DetailAOScale0", Range(-2.0, 2.0)) = 1
_DetailAOScale1("_DetailAOScale1", Range(-2.0, 2.0)) = 1
_DetailAOScale2("_DetailAOScale2", Range(-2.0, 2.0)) = 1
_DetailAOScale3("_DetailAOScale3", Range(-2.0, 2.0)) = 1
// Specific to planar mapping
_TexWorldScale0("TexWorldScale0", Float) = 1.0
_TexWorldScale1("TexWorldScale1", Float) = 1.0
_TexWorldScale2("TexWorldScale2", Float) = 1.0
_TexWorldScale3("TexWorldScale3", Float) = 1.0
// Layer blending options
_LayerMaskMap("LayerMaskMap", 2D) = "white" {}
[ToggleOff] _LayerMaskVertexColor("Use Vertex Color Mask", Float) = 0.0
[ToggleOff] _UseHeightBasedBlend("UseHeightBasedBlend", Float) = 0.0
_HeightOffset1("_HeightOffset1", Range(-0.3, 0.3)) = 0.0
_HeightOffset2("_HeightOffset2", Range(-0.3, 0.3)) = 0.0
_HeightOffset3("_HeightOffset3", Range(-0.3, 0.3)) = 0.0
_HeightFactor1("_HeightFactor1", Range(0, 5)) = 1
_HeightFactor2("_HeightFactor2", Range(0, 5)) = 1
_HeightFactor3("_HeightFactor3", Range(0, 5)) = 1
_BlendSize1("_BlendSize1", Range(0, 0.05)) = 0.0
_BlendSize2("_BlendSize2", Range(0, 0.05)) = 0.0
_BlendSize3("_BlendSize3", Range(0, 0.05)) = 0.0
_InheritBaseLayer1("_InheritBaseLayer1", Range(0, 1.0)) = 0.0
_InheritBaseLayer2("_InheritBaseLayer2", Range(0, 1.0)) = 0.0
_InheritBaseLayer3("_InheritBaseLayer3", Range(0, 1.0)) = 0.0
_VertexColorHeightFactor("_VertexColorHeightFactor", Float) = 0.3
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
_EmissiveColor("EmissiveColor", Color) = (0, 0, 0)
_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {}
_EmissiveIntensity("EmissiveIntensity", Float) = 0
[ToggleOff] _DistortionEnable("Enable Distortion", Float) = 0.0
[ToggleOff] _DistortionOnly("Distortion Only", Float) = 0.0
[ToggleOff] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 0.0
[ToggleOff] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0
[ToggleOff] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0
[HideInInspector] _BlendMode ("__blendmode", Float) = 0.0
[HideInInspector] _SrcBlend ("__src", Float) = 1.0
[HideInInspector] _DstBlend ("__dst", Float) = 0.0
[HideInInspector] _ZWrite ("__zw", Float) = 1.0
[HideInInspector] _CullMode("__cullmode", Float) = 2.0
[HideInInspector] _ZTestMode("_ZTestMode", Int) = 8
[Enum(None, 0, DoubleSided, 1, DoubleSidedLigthingFlip, 2, DoubleSidedLigthingMirror, 3)] _DoubleSidedMode("Double sided mode", Float) = 0
[Enum(Mask Alpha, 0, BaseColor Alpha, 1)] _SmoothnessTextureChannel("Smoothness texture channel", Float) = 1
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0
[ToggleOff] _EnablePerPixelDisplacement("Enable per pixel displacement", Float) = 0.0
[Enum(DetailMapNormal, 0, DetailMapAOHeight, 1)] _DetailMapMode("DetailMap mode", Float) = 0
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1
[HideInInspector] _LayerCount("_LayerCount", Float) = 2.0
// WARNING
// All the following properties that concern the UV mapping are the same as in the Lit shader.
// This means that they will get overridden when synchronizing the various layers.
// To avoid this, make sure that all properties here are in the exclusion list in LayeredLitUI.SynchronizeLayerProperties
_TexWorldScale0("Tiling", Float) = 1.0
_TexWorldScale1("Tiling", Float) = 1.0
_TexWorldScale2("Tiling", Float) = 1.0
_TexWorldScale3("Tiling", Float) = 1.0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase0("UV Set for base0", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase1("UV Set for base1", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase2("UV Set for base2", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase3("UV Set for base3", Float) = 0
[HideInInspector] _UVMappingMask0("_UVMappingMask0", Color) = (1, 0, 0, 0)
[HideInInspector] _UVMappingMask1("_UVMappingMask1", Color) = (1, 0, 0, 0)
[HideInInspector] _UVMappingMask2("_UVMappingMask2", Color) = (1, 0, 0, 0)
[HideInInspector] _UVMappingMask3("_UVMappingMask3", Color) = (1, 0, 0, 0)
[HideInInspector] _UVMappingPlanar0("_UVMappingPlanar0", Float) = 0.0
[HideInInspector] _UVMappingPlanar1("_UVMappingPlanar1", Float) = 0.0
[HideInInspector] _UVMappingPlanar2("_UVMappingPlanar2", Float) = 0.0
[HideInInspector] _UVMappingPlanar3("_UVMappingPlanar3", Float) = 0.0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail0("UV Set for detail0", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail1("UV Set for detail1", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail2("UV Set for detail2", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail3("UV Set for detail3", Float) = 0
[HideInInspector] _UVDetailsMappingMask0("_UVDetailsMappingMask0", Color) = (1, 0, 0, 0)
[HideInInspector] _UVDetailsMappingMask1("_UVDetailsMappingMask1", Color) = (1, 0, 0, 0)
[HideInInspector] _UVDetailsMappingMask2("_UVDetailsMappingMask2", Color) = (1, 0, 0, 0)
[HideInInspector] _UVDetailsMappingMask3("_UVDetailsMappingMask3", Color) = (1, 0, 0, 0)
// Tesselation specific
[Enum(Phong, 0, Displacement, 1, DisplacementPhong, 2)] _TessellationMode("Tessellation mode", Float) = 1
_TessellationFactorFixed("Tessellation Factor", Float) = 4.0 // if != -1.0 force fixed factor
_TessellationFactorMaxDistance("Tessellation max distance factor", Float) = 12.0
_TessellationFactorTriangleSize("Tessellation triangle size", Float) = 20.0
_TessellationShapeFactor("Tessellation shape factor", Range(0.0, 1.0)) = 0.75 // Only use with Phong
_TessellationBackFaceCullEpsilon("Tessellation back face epsilon", Range(-1.0, 1.0)) = 0.25
[ToggleOff] _TessellationObjectScale("Tessellation object scale", Float) = 0.0
// TODO: Handle culling mode for backface culling
}
HLSLINCLUDE
#pragma target 5.0
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _DISTORTION_ON
#pragma shader_feature _DEPTHOFFSET_ON
#pragma shader_feature _ _DOUBLESIDED_LIGHTING_FLIP _DOUBLESIDED_LIGHTING_MIRROR
// Default is _TESSELATION_PHONG
#pragma shader_feature _ _TESSELATION_DISPLACEMENT _TESSELATION_DISPLACEMENT_PHONG
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR_0
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR_1
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR_2
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR_3
#pragma shader_feature _DETAIL_MAP_WITH_NORMAL
#pragma shader_feature _NORMALMAP_TANGENT_SPACE
#pragma shader_feature _PER_PIXEL_DISPLACEMENT
#pragma shader_feature _REQUIRE_UV2_OR_UV3
#pragma shader_feature _EMISSIVE_COLOR
#pragma shader_feature _NORMALMAP
#pragma shader_feature _MASKMAP
#pragma shader_feature _SPECULAROCCLUSIONMAP
#pragma shader_feature _EMISSIVE_COLOR_MAP
#pragma shader_feature _HEIGHTMAP
#pragma shader_feature _DETAIL_MAP
#pragma shader_feature _ _LAYER_MASK_VERTEX_COLOR_MUL _LAYER_MASK_VERTEX_COLOR_ADD
#pragma shader_feature _HEIGHT_BASED_BLEND
#pragma shader_feature _ _LAYEREDLIT_3_LAYERS _LAYEREDLIT_4_LAYERS
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
// TODO: We should have this keyword only if VelocityInGBuffer is enable, how to do that ?
//#pragma multi_compile VELOCITYOUTPUT_OFF VELOCITYOUTPUT_ON
//-------------------------------------------------------------------------------------
// Define
//-------------------------------------------------------------------------------------
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
#define TESSELATION_ON
//-------------------------------------------------------------------------------------
// Include
//-------------------------------------------------------------------------------------
#include "common.hlsl"
#include "tesselation.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Attributes.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
#define _MAX_LAYER 4
#if defined(_LAYEREDLIT_4_LAYERS)
# define _LAYER_COUNT 4
#elif defined(_LAYEREDLIT_3_LAYERS)
# define _LAYER_COUNT 3
#else
# define _LAYER_COUNT 2
#endif
// Explicitely said that we are a layered shader as we share code between lit and layered lit
#define LAYERED_LIT_SHADER
//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl"
// All our shaders use same name for entry point
#pragma fragment Frag
ENDHLSL
SubShader
{
Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
LOD 300
Pass
{
Name "GBuffer" // Name is not used
Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index
Cull [_CullMode]
HLSLPROGRAM
#pragma vertex VertTesselation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_GBUFFER
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../Tesselation/TesselationShare.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
Pass
{
Name "Debug"
Tags{ "LightMode" = "DebugViewMaterial" }
Cull[_CullMode]
HLSLPROGRAM
#pragma vertex VertTesselation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_DEBUG_VIEW_MATERIAL
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../Tesselation/TesselationShare.hlsl"
#include "../../ShaderPass/ShaderPassDebugViewMaterial.hlsl"
ENDHLSL
}
// Extracts information for lightmapping, GI (emission, albedo, ...)
// This pass it not used during regular rendering.
Pass
{
Name "META"
Tags{ "LightMode" = "Meta" }
Cull Off
HLSLPROGRAM
// Lightmap memo
// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light,
// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
#pragma vertex Vert
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitMetaPass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../../ShaderPass/ShaderPassLightTransport.hlsl"
ENDHLSL
}
Pass
{
Name "Motion Vectors"
Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity)
Cull[_CullMode]
ZWrite Off // TODO: Test Z equal here.
HLSLPROGRAM
#pragma vertex VertTesselation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_VELOCITY
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitVelocityPass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../Tesselation/TesselationShare.hlsl"
#include "../../ShaderPass/ShaderPassVelocity.hlsl"
ENDHLSL
}
Pass
{
Name "ShadowCaster"
Tags{ "LightMode" = "ShadowCaster" }
Cull[_CullMode]
ZWrite On
ZTest LEqual
HLSLPROGRAM
#pragma vertex VertTesselation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitDepthPass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../Tesselation/TesselationShare.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
Pass
{
Name "DepthOnly"
Tags{ "LightMode" = "DepthOnly" }
Cull[_CullMode]
ZWrite On
HLSLPROGRAM
#pragma vertex VertTesselation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitDepthPass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../Tesselation/TesselationShare.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
Pass
{
Name "Distortion" // Name is not used
Tags { "LightMode" = "DistortionVectors" } // This will be only for transparent object based on the RenderQueue index
Blend One One
ZTest [_ZTestMode]
ZWrite off
Cull [_CullMode]
HLSLPROGRAM
#pragma vertex VertTesselation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_DISTORTION
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitDistortionPass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../Tesselation/TesselationShare.hlsl"
#include "../../ShaderPass/ShaderPassDistortion.hlsl"
ENDHLSL
}
Pass
{
Name "Forward" // Name is not used
Tags{ "LightMode" = "Forward" } // This will be only for transparent object based on the RenderQueue index
Blend[_SrcBlend][_DstBlend]
ZWrite[_ZWrite]
Cull[_CullMode]
HLSLPROGRAM
#pragma vertex VertTesselation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_FORWARD
// TEMP until pragma work in include
// #include "../../Lighting/Forward.hlsl"
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
//#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF
#include "../../Lighting/Lighting.hlsl"
#include "../Lit/ShaderPass/LitSharePass.hlsl"
#include "../Lit/LitData.hlsl"
#include "../Tesselation/TesselationShare.hlsl"
#include "../../ShaderPass/ShaderPassForward.hlsl"
ENDHLSL
}
}
CustomEditor "Experimental.Rendering.HDPipeline.LayeredLitGUI"
}

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader.meta


fileFormatVersion: 2
guid: eab0538d9d5746246806a9611c04ac4d
timeCreated: 1484060873
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl.meta


fileFormatVersion: 2
guid: e190fae546bdd354e94a04e81eeb67e3
timeCreated: 1483954253
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

41
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.hlsl


/*
float _Tess;
float _TessNear;
float _TessFar;
float _UseDisplacementfalloff;
float _DisplacementfalloffNear;
float _DisplacementfalloffFar;
*/
float4 TessellationEdge(float3 p0, float3 p1, float3 p2, float3 n0, float3 n1, float3 n2)
{
// if (_TessellationFactorFixed >= 0.0f)
{
// return _TessellationFactorFixed.xxxx;
}
return DistanceBasedTess(p0, p1, p2, 0.0, _TessellationFactorMaxDistance, unity_ObjectToWorld, _WorldSpaceCameraPos) * _TessellationFactorFixed.xxxx;
}
void Displacement(inout Attributes v)
{
/*
float LengthLerp = length(ObjSpaceViewDir(v.vertex));
LengthLerp -= _DisplacementfalloffNear;
LengthLerp /= _DisplacementfalloffFar - _DisplacementfalloffNear;
LengthLerp = 1 - (saturate(LengthLerp));
float d = ((tex2Dlod(_DispTex, float4(v.texcoord.xy * _Tiling, 0, 0)).r) - _DisplacementCenter) * (_Displacement * LengthLerp);
d /= max(0.0001, _Tiling);
*/
#ifdef _HEIGHTMAP
float height = (SAMPLE_TEXTURE2D_LOD(ADD_ZERO_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), v.uv0, 0).r - ADD_ZERO_IDX(_HeightCenter)) * ADD_IDX(_HeightAmplitude);
#else
float height = 0.0;
#endif
#if (SHADERPASS != SHADERPASS_VELOCITY) && (SHADERPASS != SHADERPASS_DISTORTION)
v.positionOS.xyz += height * v.normalOS;
#endif
}

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.hlsl.meta


fileFormatVersion: 2
guid: 29d3b1d8672d46b4291970a2666b230e
timeCreated: 1483954252
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

391
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader


Shader "HDRenderPipeline/LitTessellation"
{
Properties
{
// Following set of parameters represent the parameters node inside the MaterialGraph.
// They are use to fill a SurfaceData. With a MaterialGraph this should not exist.
// Reminder. Color here are in linear but the UI (color picker) do the conversion sRGB to linear
_BaseColor("BaseColor", Color) = (1,1,1,1)
_BaseColorMap("BaseColorMap", 2D) = "white" {}
_Metallic("_Metallic", Range(0.0, 1.0)) = 0
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
_MaskMap("MaskMap", 2D) = "white" {}
_SpecularOcclusionMap("SpecularOcclusion", 2D) = "white" {}
_NormalMap("NormalMap", 2D) = "bump" {}
_NormalScale("_NormalScale", Range(0.0, 2.0)) = 1
_HeightMap("HeightMap", 2D) = "black" {}
_HeightAmplitude("Height Amplitude", Float) = 0.01 // In world units
_HeightCenter("Height Center", Float) = 0.5 // In texture space
_TangentMap("TangentMap", 2D) = "bump" {}
_Anisotropy("Anisotropy", Range(0.0, 1.0)) = 0
_AnisotropyMap("AnisotropyMap", 2D) = "white" {}
_DetailMap("DetailMap", 2D) = "black" {}
_DetailMask("DetailMask", 2D) = "white" {}
_DetailAlbedoScale("_DetailAlbedoScale", Range(-2.0, 2.0)) = 1
_DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1
_DetailSmoothnessScale("_DetailSmoothnessScale", Range(-2.0, 2.0)) = 1
_DetailHeightScale("_DetailHeightScale", Range(-2.0, 2.0)) = 1
_DetailAOScale("_DetailAOScale", Range(-2.0, 2.0)) = 1
_SubSurfaceRadius("SubSurfaceRadius", Range(0.0, 1.0)) = 0
_SubSurfaceRadiusMap("SubSurfaceRadiusMap", 2D) = "white" {}
//_Thickness("Thickness", Range(0.0, 1.0)) = 0
//_ThicknessMap("ThicknessMap", 2D) = "white" {}
//_SubSurfaceProfile("SubSurfaceProfile", Float) = 0
//_CoatCoverage("CoatCoverage", Range(0.0, 1.0)) = 0
//_CoatCoverageMap("CoatCoverageMapMap", 2D) = "white" {}
//_CoatRoughness("CoatRoughness", Range(0.0, 1.0)) = 0
//_CoatRoughnessMap("CoatRoughnessMap", 2D) = "white" {}
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
// Following options are for the GUI inspector and different from the input parameters above
// These option below will cause different compilation flag.
_EmissiveColor("EmissiveColor", Color) = (0, 0, 0)
_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {}
_EmissiveIntensity("EmissiveIntensity", Float) = 0
[ToggleOff] _DistortionEnable("Enable Distortion", Float) = 0.0
[ToggleOff] _DistortionOnly("Distortion Only", Float) = 0.0
[ToggleOff] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 0.0
[ToggleOff] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0
[ToggleOff] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0
[HideInInspector] _BlendMode("__blendmode", Float) = 0.0
[HideInInspector] _SrcBlend("__src", Float) = 1.0
[HideInInspector] _DstBlend("__dst", Float) = 0.0
[HideInInspector] _ZWrite("__zw", Float) = 1.0
[HideInInspector] _CullMode("__cullmode", Float) = 2.0
[HideInInspector] _ZTestMode("_ZTestMode", Int) = 8
// Material Id
[HideInInspector] _MaterialId("_MaterialId", FLoat) = 0
[Enum(None, 0, DoubleSided, 1, DoubleSidedLigthingFlip, 2, DoubleSidedLigthingMirror, 3)] _DoubleSidedMode("Double sided mode", Float) = 0
[Enum(Mask Alpha, 0, BaseColor Alpha, 1)] _SmoothnessTextureChannel("Smoothness texture channel", Float) = 1
[Enum(UV0, 0, Planar, 1, TriPlanar, 2)] _UVBase("UV Set for base", Float) = 0
_TexWorldScale("Scale to apply on world coordinate", Float) = 1.0
[HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0)
[HideInInspector] _UVMappingPlanar("_UVMappingPlanar", Float) = 0
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0
[ToggleOff] _EnablePerPixelDisplacement("Enable per pixel displacement", Float) = 0.0
[Enum(DetailMapNormal, 0, DetailMapAOHeight, 1)] _DetailMapMode("DetailMap mode", Float) = 0
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0
[HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0)
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1
// Tessellation specific
[Enum(Phong, 0, Displacement, 1, DisplacementPhong, 2)] _TessellationMode("Tessellation mode", Float) = 0
_TessellationFactorFixed("Tessellation Factor", Float) = 4.0 // if != -1.0 force fixed factor
_TessellationFactorMaxDistance("Tessellation max distance factor", Float) = 12.0
_TessellationFactorTriangleSize("Tessellation triangle size", Float) = 20.0
_TessellationShapeFactor("Tessellation shape factor", Range(0.0, 1.0)) = 0.75 // Only use with Phong
_TessellationBackFaceCullEpsilon("Tessellation back face epsilon", Range(-1.0, 1.0)) = 0.25
[ToggleOff] _TessellationObjectScale("Tessellation object scale", Float) = 0.0
// TODO: Handle culling mode for backface culling
}
HLSLINCLUDE
#pragma target 5.0
#pragma only_renderers d3d11 // TEMP: until we go futher in dev
//-------------------------------------------------------------------------------------
// Variant
//-------------------------------------------------------------------------------------
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _DISTORTION_ON
#pragma shader_feature _DEPTHOFFSET_ON
#pragma shader_feature _ _DOUBLESIDED_LIGHTING_FLIP _DOUBLESIDED_LIGHTING_MIRROR
// Default is _TESSELLATION_PHONG
#pragma shader_feature _ _TESSELLATION_DISPLACEMENT _TESSELLATION_DISPLACEMENT_PHONG
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
#pragma shader_feature _MAPPING_TRIPLANAR
#pragma shader_feature _DETAIL_MAP_WITH_NORMAL
#pragma shader_feature _NORMALMAP_TANGENT_SPACE
#pragma shader_feature _PER_PIXEL_DISPLACEMENT
#pragma shader_feature _REQUIRE_UV2_OR_UV3
#pragma shader_feature _EMISSIVE_COLOR
#pragma shader_feature _NORMALMAP
#pragma shader_feature _MASKMAP
#pragma shader_feature _SPECULAROCCLUSIONMAP
#pragma shader_feature _EMISSIVE_COLOR_MAP
#pragma shader_feature _HEIGHTMAP
#pragma shader_feature _TANGENTMAP
#pragma shader_feature _ANISOTROPYMAP
#pragma shader_feature _DETAIL_MAP
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
// TODO: We should have this keyword only if VelocityInGBuffer is enable, how to do that ?
//#pragma multi_compile VELOCITYOUTPUT_OFF VELOCITYOUTPUT_ON
//-------------------------------------------------------------------------------------
// Define
//-------------------------------------------------------------------------------------
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
#define TESSELLATION_ON
//-------------------------------------------------------------------------------------
// Include
//-------------------------------------------------------------------------------------
#include "common.hlsl"
#include "tessellation.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Attributes.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl"
// All our shaders use same name for entry point
#pragma fragment Frag
ENDHLSL
SubShader
{
Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
LOD 300
Pass
{
Name "GBuffer" // Name is not used
Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index
Cull [_CullMode]
HLSLPROGRAM
#pragma vertex VertTessellation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_GBUFFER
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitSharePass.hlsl"
#include "LitData.hlsl"
#include "../Tessellation/TessellationShare.hlsl"
#include "../../ShaderPass/ShaderPassGBuffer.hlsl"
ENDHLSL
}
Pass
{
Name "Debug"
Tags { "LightMode" = "DebugViewMaterial" }
Cull[_CullMode]
HLSLPROGRAM
#pragma vertex VertTessellation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_DEBUG_VIEW_MATERIAL
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitSharePass.hlsl"
#include "LitData.hlsl"
#include "../Tessellation/TessellationShare.hlsl"
#include "../../ShaderPass/ShaderPassDebugViewMaterial.hlsl"
ENDHLSL
}
// Extracts information for lightmapping, GI (emission, albedo, ...)
// This pass it not used during regular rendering.
Pass
{
Name "META"
Tags{ "LightMode" = "Meta" }
Cull Off
HLSLPROGRAM
// Lightmap memo
// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light,
// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
// No tessellation for Meta pass
#pragma vertex Vert
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitMetaPass.hlsl"
#include "LitData.hlsl"
#include "../../ShaderPass/ShaderPassLightTransport.hlsl"
ENDHLSL
}
Pass
{
Name "ShadowCaster"
Tags{ "LightMode" = "ShadowCaster" }
Cull[_CullMode]
ZWrite On
ZTest LEqual
HLSLPROGRAM
#pragma vertex VertTessellation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitDepthPass.hlsl"
#include "LitData.hlsl"
#include "../Tessellation/TessellationShare.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
Pass
{
Name "DepthOnly"
Tags{ "LightMode" = "DepthOnly" }
Cull[_CullMode]
ZWrite On
HLSLPROGRAM
#pragma vertex VertTessellation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitDepthPass.hlsl"
#include "LitData.hlsl"
#include "../Tessellation/TessellationShare.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
Pass
{
Name "Motion Vectors"
Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity)
Cull[_CullMode]
ZWrite Off // TODO: Test Z equal here.
HLSLPROGRAM
#pragma vertex VertTessellation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_VELOCITY
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitVelocityPass.hlsl"
#include "LitData.hlsl"
#include "../Tessellation/TessellationShare.hlsl"
#include "../../ShaderPass/ShaderPassVelocity.hlsl"
ENDHLSL
}
Pass
{
Name "Distortion" // Name is not used
Tags { "LightMode" = "DistortionVectors" } // This will be only for transparent object based on the RenderQueue index
Blend One One
ZTest [_ZTestMode]
ZWrite off
Cull [_CullMode]
HLSLPROGRAM
#pragma vertex VertTessellation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_DISTORTION
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitDistortionPass.hlsl"
#include "LitData.hlsl"
#include "../Tessellation/TessellationShare.hlsl"
#include "../../ShaderPass/ShaderPassDistortion.hlsl"
ENDHLSL
}
Pass
{
Name "Forward" // Name is not used
Tags { "LightMode" = "Forward" } // This will be only for transparent object based on the RenderQueue index
Blend [_SrcBlend] [_DstBlend]
ZWrite [_ZWrite]
Cull [_CullMode]
HLSLPROGRAM
#pragma vertex VertTessellation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_FORWARD
// TEMP until pragma work in include
// #include "../../Lighting/Forward.hlsl"
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
//#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF
#include "../../Lighting/Lighting.hlsl"
#include "ShaderPass/LitSharePass.hlsl"
#include "LitData.hlsl"
#include "../Tessellation/TessellationShare.hlsl"
#include "../../ShaderPass/ShaderPassForward.hlsl"
ENDHLSL
}
}
CustomEditor "Experimental.Rendering.HDPipeline.LitGUI"
}

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader.meta


fileFormatVersion: 2
guid: 756bac9090102564582875f4c7e30202
timeCreated: 1483720902
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass.meta


fileFormatVersion: 2
guid: cf157ff6c6d99d24b87ba5de6be19aec
folderAsset: yes
timeCreated: 1483954252
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

87
Assets/ScriptableRenderLoop/ShaderLibrary/API/PSSL.hlsl


// This file assume SHADER_API_D3D11 is defined
#define INTRINSIC_BITFIELD_EXTRACT
#define INTRINSIC_MAD24
#define Mad24 mad24
#define INTRINSIC_MED3
#define INTRINSIC_MINMAX3
#define Min3 min3
#define Max3 max3
//#define INTRINSIC_CUBEMAP_FACE_ID // Must investigate why AMD reference implementation is different than ours
#define UNITY_UV_STARTS_AT_TOP 1
#define UNITY_REVERSED_Z 1
#define UNITY_NEAR_CLIP_VALUE (1.0)
// This value will not go through any matrix projection convertion
#define UNITY_RAW_FAR_CLIP_VALUE (0.0)
#define FRONT_FACE_SEMATIC SV_IsFrontFace
#define FRONT_FACE_TYPE bool
#define IS_FRONT_VFACE(VAL, FRONT, BACK) ((VAL) ? (FRONT) : (BACK))
#define CBUFFER_START(name) cbuffer name {
#define CBUFFER_END };
// Initialize arbitrary structure with zero values.
// Do not exist on some platform, in this case we need to have a standard name that call a function that will initialize all parameters to 0
#define ZERO_INITIALIZE(type, name) name = (type)0;
// Texture abstraction
#define TEXTURE2D(textureName) Texture2D textureName
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
#define TEXTURECUBE(textureName) TextureCube textureName
#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define SAMPLER2D(samplerName) SamplerState samplerName
#define SAMPLERCUBE(samplerName) SamplerState samplerName
#define SAMPLER3D(samplerName) SamplerState samplerName
#define SAMPLER2D_SHADOW(samplerName) SamplerComparisonState samplerName
#define SAMPLERCUBE_SHADOW(samplerName) SamplerComparisonState samplerName
#define TEXTURE2D_ARGS(textureName, samplerName) Texture2D textureName, SamplerState samplerName
#define TEXTURE2D_ARRAY_ARGS(textureName, samplerName) Texture2DArray textureName, SamplerState samplerName
#define TEXTURECUBE_ARGS(textureName, samplerName) TextureCube textureName, SamplerState samplerName
#define TEXTURECUBE_ARRAY_ARGS(textureName, samplerName) TextureCubeArray textureName, SamplerState samplerName
#define TEXTURE3D_ARGS(textureName, samplerName) Texture3D textureName, SamplerState samplerName
#define TEXTURE2D_SHADOW_ARGS(textureName, samplerName) Texture2D textureName, SamplerComparisonState samplerName
#define TEXTURE2D_ARRAY_SHADOW_ARGS(textureName, samplerName) Texture2DArray textureName, SamplerComparisonState samplerName
#define TEXTURECUBE_SHADOW_ARGS(textureName, samplerName) TextureCube textureName, SamplerComparisonState samplerName
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_ARRAY_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURE2D_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define TEXTURECUBE_SHADOW_PARAM(textureName, samplerName) textureName, samplerName
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
#define SAMPLE_TEXTURECUBE(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURECUBE_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
#define SAMPLE_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) textureName.Sample(samplerName, float4(coord3, index))
#define SAMPLE_TEXTURECUBE_ARRAY_LOD(textureName, samplerName, coord3, index, lod) textureName.SampleLevel(samplerName, float4(coord3, index), lod)
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
#define SAMPLE_TEXTURE2D_SHADOW(textureName, samplerName, coord3) textureName.SampleCmpLevelZero(samplerName, (coord3).xy, (coord3).z)
#define SAMPLE_TEXTURE2D_ARRAY_SHADOW(textureName, samplerName, coord3, index) textureName.SampleCmpLevelZero(samplerName, float3((coord3).xy, index), (coord3).z)
#define SAMPLE_TEXTURECUBE_SHADOW(textureName, samplerName, coord4) textureName.SampleCmpLevelZero(samplerName, (coord3).xyz, (coord3).w)
#define TEXTURE2D_HALF TEXTURE2D
#define TEXTURE2D_FLOAT TEXTURE2D
#define SAMPLER2D_HALF SAMPLER2D
#define SAMPLER2D_FLOAT SAMPLER2D
#define LOAD_TEXTURE2D(textureName, unCoord2) textureName.Load(int3(unCoord2, 0))
#define LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) textureName.Load(int3(unCoord2, lod))
#define LOAD_TEXTURE2D_MSAA(textureName, unCoord2, sampleIndex) textureName.Load(unCoord2, sampleIndex)
#define LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) textureName.Load(int4(unCoord2, index, 0))
#define LOAD_TEXTURE2D_ARRAY_LOD(textureName, unCoord2, index, lod) textureName.Load(int4(unCoord2, index, lod))
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
#define GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Gather(samplerName, float3(coord2, index))
#define GATHER_TEXTURECUBE(textureName, samplerName, coord3) textureName.Gather(samplerName, coord3)
#define GATHER_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) textureName.Gather(samplerName, float4(coord3, index))

9
Assets/ScriptableRenderLoop/ShaderLibrary/API/PSSL.hlsl.meta


fileFormatVersion: 2
guid: 0437569999393274f8baf4c00cc0100a
timeCreated: 1483982129
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

170
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDepthPass.hlsl


#ifndef SHADERPASS
#error Undefine_SHADERPASS
#endif
// Check if Alpha test is enabled. If it is, check if parallax is enabled on this material
#define NEED_TEXCOORD0 1 // defined(_ALPHATEST_ON)
#define NEED_TANGENT_TO_WORLD 1 // NEED_TEXCOORD0 && (defined(_HEIGHTMAP) && defined(_PER_PIXEL_DISPLACEMENT)) TEMP!!!: until we fix tessellation so it can access normalOS
// When modifying this structure, update the tessellation code below
struct Attributes
{
float3 positionOS : POSITION;
#if NEED_TEXCOORD0
float2 uv0 : TEXCOORD0;
#endif
#if NEED_TANGENT_TO_WORLD
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
#endif
};
#ifdef TESSELLATION_ON
// Copy paste of above struct with POSITION rename to INTERNALTESSPOS (internal of unity shader compiler)
struct AttributesTessellation
{
float3 positionOS : INTERNALTESSPOS;
#if NEED_TEXCOORD0
float2 uv0 : TEXCOORD0;
#endif
#if NEED_TANGENT_TO_WORLD
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
#endif
};
AttributesTessellation AttributesToAttributesTessellation(Attributes input)
{
AttributesTessellation output;
output.positionOS = input.positionOS;
#if NEED_TEXCOORD0
output.uv0 = input.uv0;
#endif
#if NEED_TANGENT_TO_WORLD
output.normalOS = input.normalOS;
output.tangentOS = input.tangentOS;
#endif
return output;
}
Attributes AttributesTessellationToAttributes(AttributesTessellation input)
{
Attributes output;
output.positionOS = input.positionOS;
#if NEED_TEXCOORD0
output.uv0 = input.uv0;
#endif
#if NEED_TANGENT_TO_WORLD
output.normalOS = input.normalOS;
output.tangentOS = input.tangentOS;
#endif
return output;
}
AttributesTessellation InterpolateWithBaryCoords(AttributesTessellation input0, AttributesTessellation input1, AttributesTessellation input2, float3 baryCoords)
{
AttributesTessellation ouput;
TESSELLATION_INTERPOLATE_BARY(positionOS, baryCoords);
#if NEED_TEXCOORD0
TESSELLATION_INTERPOLATE_BARY(uv0, baryCoords);
#endif
#if NEED_TANGENT_TO_WORLD
TESSELLATION_INTERPOLATE_BARY(normalOS, baryCoords);
TESSELLATION_INTERPOLATE_BARY(tangentOS, baryCoords);
#endif
return ouput;
}
#endif // TESSELLATION_ON
struct Varyings
{
float4 positionCS;
#if NEED_TEXCOORD0
float2 texCoord0;
#endif
#if NEED_TANGENT_TO_WORLD
float3 positionWS;
float3 tangentToWorld[3];
#endif
};
struct PackedVaryings
{
float4 positionCS : SV_Position;
#if NEED_TANGENT_TO_WORLD
float4 interpolators[4] : TEXCOORD0;
#elif NEED_TEXCOORD0
float4 interpolators[1] : TEXCOORD0;
#endif
};
// Function to pack data to use as few interpolator as possible, the ShaderGraph should generate these functions
PackedVaryings PackVaryings(Varyings input)
{
PackedVaryings output;
output.positionCS = input.positionCS;
#if NEED_TANGENT_TO_WORLD
output.interpolators[0].xyz = input.positionWS.xyz;
output.interpolators[1].xyz = input.tangentToWorld[0];
output.interpolators[2].xyz = input.tangentToWorld[1];
output.interpolators[3].xyz = input.tangentToWorld[2];
output.interpolators[0].w = input.texCoord0.x;
output.interpolators[1].w = input.texCoord0.y;
#elif NEED_TEXCOORD0
output.interpolators[0] = float4(input.texCoord0, 0.0, 0.0);
#endif
return output;
}
FragInputs UnpackVaryings(PackedVaryings input)
{
FragInputs output;
ZERO_INITIALIZE(FragInputs, output);
output.unPositionSS = input.positionCS; // input.positionCS is SV_Position
#if NEED_TANGENT_TO_WORLD
output.positionWS.xyz = input.interpolators[0].xyz;
output.tangentToWorld[0] = input.interpolators[1].xyz;
output.tangentToWorld[1] = input.interpolators[2].xyz;
output.tangentToWorld[2] = input.interpolators[3].xyz;
output.texCoord0.xy = float2(input.interpolators[0].w, input.interpolators[1].w);
#elif NEED_TEXCOORD0
output.texCoord0.xy = input.interpolators[0].xy;
#endif
return output;
}
PackedVaryings Vert(Attributes input)
{
Varyings output;
float3 positionWS = TransformObjectToWorld(input.positionOS);
output.positionCS = TransformWorldToHClip(positionWS);
#if NEED_TEXCOORD0
output.texCoord0 = input.uv0;
#endif
#if NEED_TANGENT_TO_WORLD
output.positionWS = positionWS;
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w);
float3x3 tangentToWorld = CreateTangentToWorld(normalWS, tangentWS.xyz, tangentWS.w);
output.tangentToWorld[0] = tangentToWorld[0];
output.tangentToWorld[1] = tangentToWorld[1];
output.tangentToWorld[2] = tangentToWorld[2];
#endif
return PackVaryings(output);
}

77
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tessellation/TessellationShare.hlsl


AttributesTessellation VertTessellation(Attributes input)
{
return AttributesToAttributesTessellation(input);
}
struct TessellationFactors
{
float edge[3] : SV_TessFactor;
float inside : SV_InsideTessFactor;
};
TessellationFactors HullConstant(InputPatch<AttributesTessellation, 3> input)
{
Attributes params[3];
params[0] = AttributesTessellationToAttributes(input[0]);
params[1] = AttributesTessellationToAttributes(input[1]);
params[2] = AttributesTessellationToAttributes(input[2]);
#if (SHADERPASS != SHADERPASS_VELOCITY) && (SHADERPASS != SHADERPASS_DISTORTION)
// TEMP: We will provide world position but for now convert to world position here
float3 p0 = TransformObjectToWorld(input[0].positionOS);
float3 n0 = TransformObjectToWorldNormal(input[0].normalOS);
float3 p1 = TransformObjectToWorld(input[1].positionOS);
float3 n1 = TransformObjectToWorldNormal(input[1].normalOS);
float3 p2 = TransformObjectToWorld(input[2].positionOS);
float3 n2 = TransformObjectToWorldNormal(input[2].normalOS);
float4 tf = TessellationEdge(p0, p1, p2, n0, n1, n2);
#else
float4 tf = float4(0.0, 0.0, 0.0, 0.0);
#endif
TessellationFactors ouput;
ouput.edge[0] = tf.x;
ouput.edge[1] = tf.y;
ouput.edge[2] = tf.z;
ouput.inside = tf.w;
return ouput;
}
[maxtessfactor(15.0)] // AMD recommand this value for GCN http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/05/GCNPerformanceTweets.pdf
[domain("tri")]
[partitioning("fractional_odd")]
[outputtopology("triangle_cw")]
[patchconstantfunc("HullConstant")]
[outputcontrolpoints(3)]
AttributesTessellation Hull(InputPatch<AttributesTessellation, 3> input, uint id : SV_OutputControlPointID)
{
return input[id];
}
[domain("tri")]
PackedVaryings Domain(TessellationFactors tessFactors, const OutputPatch<AttributesTessellation, 3> input, float3 baryCoords : SV_DomainLocation)
{
Attributes params = InterpolateWithBaryCoords(input[0], input[1], input[2], baryCoords);
#ifndef _TESSELLATION_DISPLACEMENT // We have Phong tessellation in all case where we don't have only displacement
#if (SHADERPASS != SHADERPASS_VELOCITY) && (SHADERPASS != SHADERPASS_DISTORTION)
params.positionOS = PhongTessellation( params.positionOS,
input[0].positionOS, input[1].positionOS, input[2].positionOS,
input[0].normalOS, input[1].normalOS, input[2].normalOS,
baryCoords, _TessellationShapeFactor);
#endif
#endif
// perform displacement
Displacement(params);
// Evaluate regular vertex shader
PackedVaryings outout = Vert(params);
return outout;
}

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tessellation/TessellationShare.hlsl.meta


fileFormatVersion: 2
guid: 398b52fe541a9964a85a043bffd670e9
timeCreated: 1483954253
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitSurfaceData.hlsl.meta


fileFormatVersion: 2
guid: b24a503f5b489bb4896bc43d861f7f49
timeCreated: 1479984801
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

108
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDepthPass.hlsl


#ifndef SHADERPASS
#error Undefine_SHADERPASS
#endif
// Check if Alpha test is enabled. If it is, check if parallax is enabled on this material
#define NEED_TEXCOORD0 defined(_ALPHATEST_ON)
#define NEED_TANGENT_TO_WORLD NEED_TEXCOORD0 && (defined(_HEIGHTMAP) && !defined(_HEIGHTMAP_AS_DISPLACEMENT))
struct Attributes
{
float3 positionOS : POSITION;
#if NEED_TEXCOORD0
float2 uv0 : TEXCOORD0;
#endif
#if NEED_TANGENT_TO_WORLD
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
#endif
};
struct Varyings
{
float4 positionCS;
#if NEED_TEXCOORD0
float2 texCoord0;
#endif
#if NEED_TANGENT_TO_WORLD
float3 positionWS;
float3 tangentToWorld[3];
#endif
};
struct PackedVaryings
{
float4 positionCS : SV_Position;
#if NEED_TANGENT_TO_WORLD
float4 interpolators[4] : TEXCOORD0;
#elif NEED_TEXCOORD0
float4 interpolators[1] : TEXCOORD0;
#endif
};
// Function to pack data to use as few interpolator as possible, the ShaderGraph should generate these functions
PackedVaryings PackVaryings(Varyings input)
{
PackedVaryings output;
output.positionCS = input.positionCS;
#if NEED_TANGENT_TO_WORLD
output.interpolators[0].xyz = input.positionWS.xyz;
output.interpolators[1].xyz = input.tangentToWorld[0];
output.interpolators[2].xyz = input.tangentToWorld[1];
output.interpolators[3].xyz = input.tangentToWorld[2];
output.interpolators[0].w = input.texCoord0.x;
output.interpolators[1].w = input.texCoord0.y;
#elif NEED_TEXCOORD0
output.interpolators[0] = float4(input.texCoord0, 0.0, 0.0);
#endif
return output;
}
FragInputs UnpackVaryings(PackedVaryings input)
{
FragInputs output;
ZERO_INITIALIZE(FragInputs, output);
output.unPositionSS = input.positionCS; // input.positionCS is SV_Position
#if NEED_TANGENT_TO_WORLD
output.positionWS.xyz = input.interpolators[0].xyz;
output.tangentToWorld[0] = input.interpolators[1].xyz;
output.tangentToWorld[1] = input.interpolators[2].xyz;
output.tangentToWorld[2] = input.interpolators[3].xyz;
output.texCoord0.xy = float2(input.interpolators[0].w, input.interpolators[1].w);
#elif NEED_TEXCOORD0
output.texCoord0.xy = input.interpolators[0].xy;
#endif
return output;
}
PackedVaryings Vert(Attributes input)
{
Varyings output;
float3 positionWS = TransformObjectToWorld(input.positionOS);
output.positionCS = TransformWorldToHClip(positionWS);
#if NEED_TEXCOORD0
output.texCoord0 = input.uv0;
#endif
#if NEED_TANGENT_TO_WORLD
output.positionWS = positionWS;
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w);
float3x3 tangentToWorld = CreateTangentToWorld(normalWS, tangentWS.xyz, tangentWS.w);
output.tangentToWorld[0] = tangentToWorld[0];
output.tangentToWorld[1] = tangentToWorld[1];
output.tangentToWorld[2] = tangentToWorld[2];
#endif
return PackVaryings(output);
}

/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitSurfaceData.hlsl → /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl

/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tesselation.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tessellation.meta

/Assets/ScriptableRenderLoop/ShaderLibrary/Tesselation.hlsl.meta → /Assets/ScriptableRenderLoop/ShaderLibrary/Tessellation.hlsl.meta

/Assets/ScriptableRenderLoop/ShaderLibrary/Tesselation.hlsl → /Assets/ScriptableRenderLoop/ShaderLibrary/Tessellation.hlsl

/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitVelocityPass.hlsl.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl.meta

/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitVelocityPass.hlsl → /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl

/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitSharePass.hlsl.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitSharePass.hlsl.meta

/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitSharePass.hlsl → /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitSharePass.hlsl

/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitMetaPass.hlsl.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitMetaPass.hlsl.meta

/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitMetaPass.hlsl → /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitMetaPass.hlsl

/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDistortionPass.hlsl.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDistortionPass.hlsl.meta

/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDistortionPass.hlsl → /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDistortionPass.hlsl

/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDepthPass.hlsl.meta → /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDepthPass.hlsl.meta

正在加载...
取消
保存