浏览代码

Merge pull request #89 from Unity-Technologies/Add-tesselation

Add tesselation
/main
GitHub 8 年前
当前提交
789af10a
共有 47 个文件被更改,包括 1702 次插入240 次删除
  1. 53
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
  2. 36
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  3. 5
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs
  4. 30
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
  5. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl
  6. 36
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader
  7. 33
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl
  8. 6
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl
  9. 45
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
  10. 7
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Unlit.shader
  11. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl
  12. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl
  13. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl
  14. 8
      Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader
  15. 2
      Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl
  16. 1
      Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl
  17. 17
      Assets/ScriptableRenderLoop/ShaderLibrary/Packing.hlsl
  18. 119
      Assets/ScriptableRenderLoop/ShaderLibrary/Tesselation.hlsl
  19. 68
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl
  20. 78
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitSharePass.hlsl
  21. 56
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDistortionPass.hlsl
  22. 504
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTesselation.shader
  23. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTesselation.shader.meta
  24. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl.meta
  25. 41
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTesselation.hlsl
  26. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTesselation.hlsl.meta
  27. 382
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader
  28. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader.meta
  29. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass.meta
  30. 53
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tesselation/TesselationShare.hlsl
  31. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tesselation/TesselationShare.hlsl.meta
  32. 170
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDepthPass.hlsl
  33. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitSurfaceData.hlsl.meta
  34. 108
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDepthPass.hlsl
  35. 0
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tesselation/ShareTesselation.hlsl
  36. 9
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tesselation/ShareTesselation.hlsl.meta
  37. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
  38. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl.meta
  39. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl
  40. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitSharePass.hlsl.meta
  41. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitSharePass.hlsl
  42. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitMetaPass.hlsl.meta
  43. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitMetaPass.hlsl
  44. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDistortionPass.hlsl.meta
  45. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDistortionPass.hlsl
  46. 0
      /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDepthPass.hlsl.meta

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


MaterialProperty layerEmissiveColor = null;
MaterialProperty layerEmissiveColorMap = null;
MaterialProperty layerEmissiveIntensity = null;
MaterialProperty layerTesselationFactor = null;
override protected void FindMaterialProperties(MaterialProperty[] props)
{

layerEmissiveColor = FindProperty(kEmissiveColor, props);
layerEmissiveColorMap = FindProperty(kEmissiveColorMap, props);
layerEmissiveIntensity = FindProperty(kEmissiveIntensity, props);
layerTesselationFactor = FindProperty(kTesselationFactor, props, false);
}
int numLayer

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);
}

m_MaterialEditor.ShaderProperty(layerEmissiveIntensity, Styles.emissiveIntensityText);
m_MaterialEditor.LightmapEmissionProperty(1);
EditorGUI.indentLevel--;
if (layerTesselationFactor != null)
{
GUILayout.Label(Styles.tesselationText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(layerTesselationFactor, Styles.tesselationFactorText);
EditorGUI.indentLevel--;
}
CheckLayerConsistency();

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


[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

#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

#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"

// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitMetaPass.hlsl"
#include "../Lit/LitMetaPass.hlsl"
#include "../../ShaderPass/ShaderPassLightTransport.hlsl"

HLSLPROGRAM
#define SHADERPASS SHADERPASS_VELOCITY
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitVelocityPass.hlsl"
#include "../Lit/LitVelocityPass.hlsl"
#include "../../ShaderPass/ShaderPassVelocity.hlsl"

HLSLPROGRAM
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitDepthPass.hlsl"
#include "../Lit/LitDepthPass.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"

HLSLPROGRAM
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "../Lit/ShaderPass/LitDepthPass.hlsl"
#include "../Lit/LitDepthPass.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"

HLSLPROGRAM
#define SHADERPASS SHADERPASS_DISTORTION
#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"

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


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 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 GUIContent tesselationText = new GUIContent("Tesselation options", "Tesselation options");
public static GUIContent tesselationFactorText = new GUIContent("Tesselation factor", "Tesselation factor");
}
public enum SurfaceType

30
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 kEmissiveColorMap = "_EmissiveColorMap";
protected MaterialProperty emissiveIntensity = null;
protected const string kEmissiveIntensity = "_EmissiveIntensity";
// tesselation params
protected MaterialProperty tesselationFactor = null;
protected const string kTesselationFactor = "_TesselationFactor";
// 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.

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

emissiveColor = FindProperty(kEmissiveColor, props);
emissiveColorMap = FindProperty(kEmissiveColorMap, props);
emissiveIntensity = FindProperty(kEmissiveIntensity, props);
// tesselation specific, don't care if not found
tesselationFactor = FindProperty(kTesselationFactor, props, false);
}
override protected void ShaderInputOptionsGUI()

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.LightmapEmissionProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
if (tesselationFactor != null)
{
GUILayout.Label(Styles.tesselationText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(tesselationFactor, Styles.tesselationFactorText);
EditorGUI.indentLevel--;
}
}
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);

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


[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)

#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"

// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON.
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitMetaPass.hlsl"
#include "LitMetaPass.hlsl"
#include "../../ShaderPass/ShaderPassLightTransport.hlsl"

HLSLPROGRAM
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitDepthPass.hlsl"
#include "LitDepthPass.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"

HLSLPROGRAM
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitDepthPass.hlsl"
#include "LitDepthPass.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"

HLSLPROGRAM
#define SHADERPASS SHADERPASS_VELOCITY
#include "../../Material/Material.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitVelocityPass.hlsl"
#include "LitVelocityPass.hlsl"
#include "../../ShaderPass/ShaderPassVelocity.hlsl"

HLSLPROGRAM
#define SHADERPASS SHADERPASS_DISTORTION
#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"

33
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 TESSELATION_ON
#include "LitTesselation.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 TESSELATION_ON
#include "LitTesselation.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 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;
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.

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


float _AlphaCutoff;
#endif // LAYERED_LIT_SHADER
// Tesselation specific
#ifdef TESSELATION_ON
float _TesselationFactor;
#endif

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


#ifdef _HEIGHTMAP
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;

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
}

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);

2
Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl


}
// 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);

17
Assets/ScriptableRenderLoop/ShaderLibrary/Packing.hlsl


return max(vRGB, float3(0.0, 0.0, 0.0));
}
// 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)
{

119
Assets/ScriptableRenderLoop/ShaderLibrary/Tesselation.hlsl


#define TESSELATION_INTERPOLATE_BARY(name, bary) ouput.name = input0.name * bary.x + input1.name * bary.y + input2.name * bary.z
// ---- utility functions
float UnityCalcDistanceTessFactor(float3 positionOS, float minDist, float maxDist, float tess, float4x4 objectToWorld, float3 cameraPosWS)
{
float3 positionWS = mul(objectToWorld, float4(positionOS, 1.0)).xyz;
float dist = distance(positionWS, cameraPosWS);
float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0) * tess;
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 UnityDistanceBasedTess(float3 positionOS0, float3 positionOS1, float3 positionOS2, float minDist, float maxDist, float tess, float4x4 objectToWorld, float3 cameraPosWS)
{
float3 f;
f.x = UnityCalcDistanceTessFactor(positionOS0, minDist, maxDist, tess, objectToWorld, cameraPosWS);
f.y = UnityCalcDistanceTessFactor(positionOS1, minDist, maxDist, tess, objectToWorld, cameraPosWS);
f.z = UnityCalcDistanceTessFactor(positionOS2, minDist, maxDist, tess, 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;
}
*/

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 TESSELATION_ON
// Copy paste of above struct with POSITION rename to INTERNALTESSPOS (internal of unity shader compiler)
struct AttributesTesselation
{
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
};
AttributesTesselation AttributesToAttributesTesselation(Attributes input)
{
AttributesTesselation 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 AttributesTesselationToAttributes(AttributesTesselation 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;
}
AttributesTesselation InterpolateWithBary(AttributesTesselation input0, AttributesTesselation input1, AttributesTesselation input2, float3 baryWeight)
{
AttributesTesselation ouput;
TESSELATION_INTERPOLATE_BARY(positionOS, baryWeight);
TESSELATION_INTERPOLATE_BARY(previousPositionOS, baryWeight);
#if NEED_TEXCOORD0
TESSELATION_INTERPOLATE_BARY(uv0, baryWeight);
#endif
#if NEED_TANGENT_TO_WORLD
// TESSELATION_INTERPOLATE_BARY(normalOS, baryWeight);
TESSELATION_INTERPOLATE_BARY(tangentOS, baryWeight);
#endif
return ouput;
}
#endif // TESSELATION_ON
struct Varyings
{

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


// UNITY_INSTANCE_ID
};
#ifdef TESSELATION_ON
// Copy paste of above struct with POSITION rename to INTERNALTESSPOS (internal of unity shader compiler)
struct AttributesTesselation
{
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;
};
AttributesTesselation AttributesToAttributesTesselation(Attributes input)
{
AttributesTesselation 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 AttributesTesselationToAttributes(AttributesTesselation 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;
}
AttributesTesselation InterpolateWithBary(AttributesTesselation input0, AttributesTesselation input1, AttributesTesselation input2, float3 baryWeight)
{
AttributesTesselation ouput;
TESSELATION_INTERPOLATE_BARY(positionOS, baryWeight);
TESSELATION_INTERPOLATE_BARY(normalOS, baryWeight);
TESSELATION_INTERPOLATE_BARY(uv0, baryWeight);
TESSELATION_INTERPOLATE_BARY(uv1, baryWeight);
#if WANT_UV2
TESSELATION_INTERPOLATE_BARY(uv2, baryWeight);
#endif
#if WANT_UV3
TESSELATION_INTERPOLATE_BARY(uv3, baryWeight);
#endif
TESSELATION_INTERPOLATE_BARY(tangentOS, baryWeight);
TESSELATION_INTERPOLATE_BARY(color, baryWeight);
return ouput;
}
#endif // TESSELATION_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 TESSELATION_ON
// Copy paste of above struct with POSITION rename to INTERNALTESSPOS (internal of unity shader compiler)
struct AttributesTesselation
{
float3 positionOS : INTERNALTESSPOS;
float2 uv0 : TEXCOORD0;
#if NEED_TANGENT_TO_WORLD
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
#endif
};
AttributesTesselation AttributesToAttributesTesselation(Attributes input)
{
AttributesTesselation 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 AttributesTesselationToAttributes(AttributesTesselation 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;
}
AttributesTesselation InterpolateWithBary(AttributesTesselation input0, AttributesTesselation input1, AttributesTesselation input2, float3 baryWeight)
{
AttributesTesselation ouput;
TESSELATION_INTERPOLATE_BARY(positionOS, baryWeight);
TESSELATION_INTERPOLATE_BARY(uv0, baryWeight);
#if NEED_TANGENT_TO_WORLD
TESSELATION_INTERPOLATE_BARY(normalOS, baryWeight);
TESSELATION_INTERPOLATE_BARY(tangentOS, baryWeight);
#endif
return ouput;
}
#endif // TESSELATION_ON
struct Varyings
{

504
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTesselation.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
_TesselationFactor("Tesselation Factor", Float) = 3.0
}
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
#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/LayeredLitTesselation.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/LitTesselation.hlsl


/*
float _Tess;
float _TessNear;
float _TessFar;
float _UseDisplacementfalloff;
float _DisplacementfalloffNear;
float _DisplacementfalloffFar;
*/
float4 TesselationEdge(Attributes input0, Attributes input1, Attributes input2)
{
// float minDist = 0; // _TessNear;
// float maxDist = 15; // _TessFar;
// return UnityDistanceBasedTess(input0.positionOS, input1.positionOS, input2.positionOS, minDist, maxDist, 0.5 /* _Tess */, unity_ObjectToWorld, _WorldSpaceCameraPos);
return float4(_TesselationFactor, _TesselationFactor, _TesselationFactor, _TesselationFactor);
}
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/LitTesselation.hlsl.meta


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

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


Shader "HDRenderPipeline/LitTesselation"
{
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
// Tesselation specific
_TesselationFactor("Tesselation Factor", Float) = 3.0
}
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
#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 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
//-------------------------------------------------------------------------------------
#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 "ShaderPass/LitSharePass.hlsl"
#include "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 "ShaderPass/LitSharePass.hlsl"
#include "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.
// No tesselation 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 VertTesselation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitDepthPass.hlsl"
#include "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 "ShaderPass/LitDepthPass.hlsl"
#include "LitData.hlsl"
#include "../Tesselation/TesselationShare.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 VertTesselation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_VELOCITY
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitVelocityPass.hlsl"
#include "LitData.hlsl"
#include "../Tesselation/TesselationShare.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 VertTesselation
#pragma hull Hull
#pragma domain Domain
#define SHADERPASS SHADERPASS_DISTORTION
#include "../../Material/Material.hlsl"
#include "ShaderPass/LitDistortionPass.hlsl"
#include "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 "ShaderPass/LitSharePass.hlsl"
#include "LitData.hlsl"
#include "../Tesselation/TesselationShare.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:

53
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tesselation/TesselationShare.hlsl


AttributesTesselation VertTesselation(Attributes input)
{
return AttributesToAttributesTesselation(input);
}
struct TessellationFactors
{
float edge[3] : SV_TessFactor;
float inside : SV_InsideTessFactor;
};
TessellationFactors HullConstant(InputPatch<AttributesTesselation, 3> input)
{
Attributes params[3];
params[0] = AttributesTesselationToAttributes(input[0]);
params[1] = AttributesTesselationToAttributes(input[1]);
params[2] = AttributesTesselationToAttributes(input[2]);
float4 tf = TesselationEdge(params[0], params[1], params[2]);
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)]
AttributesTesselation Hull(InputPatch<AttributesTesselation, 3> input, uint id : SV_OutputControlPointID)
{
return input[id];
}
[domain("tri")]
PackedVaryings Domain(TessellationFactors tessFactors, const OutputPatch<AttributesTesselation, 3> input, float3 baryWeight : SV_DomainLocation)
{
Attributes params = InterpolateWithBary(input[0], input[1], input[2], baryWeight);
// perform displacement
Displacement(params);
// Evaluate regular vertex shader
PackedVaryings outout = Vert(params);
return outout;
}

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tesselation/TesselationShare.hlsl.meta


fileFormatVersion: 2
guid: 398b52fe541a9964a85a043bffd670e9
timeCreated: 1483954253
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 tesselation so it can access normalOS
// When modifying this structure, update the tesselation 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 TESSELATION_ON
// Copy paste of above struct with POSITION rename to INTERNALTESSPOS (internal of unity shader compiler)
struct AttributesTesselation
{
float3 positionOS : INTERNALTESSPOS;
#if NEED_TEXCOORD0
float2 uv0 : TEXCOORD0;
#endif
#if NEED_TANGENT_TO_WORLD
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
#endif
};
AttributesTesselation AttributesToAttributesTesselation(Attributes input)
{
AttributesTesselation 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 AttributesTesselationToAttributes(AttributesTesselation 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;
}
AttributesTesselation InterpolateWithBary(AttributesTesselation input0, AttributesTesselation input1, AttributesTesselation input2, float3 baryWeight)
{
AttributesTesselation ouput;
TESSELATION_INTERPOLATE_BARY(positionOS, baryWeight);
#if NEED_TEXCOORD0
TESSELATION_INTERPOLATE_BARY(uv0, baryWeight);
#endif
#if NEED_TANGENT_TO_WORLD
TESSELATION_INTERPOLATE_BARY(normalOS, baryWeight);
TESSELATION_INTERPOLATE_BARY(tangentOS, baryWeight);
#endif
return ouput;
}
#endif // TESSELATION_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);
}

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);
}

0
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tesselation/ShareTesselation.hlsl

9
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tesselation/ShareTesselation.hlsl.meta


fileFormatVersion: 2
guid: 70a7ee6a44b86494daad0acd691e1d51
timeCreated: 1483692743
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitSurfaceData.hlsl → /Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.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

正在加载...
取消
保存