浏览代码

Merge pull request #742 from Unity-Technologies/prototype/decals_no_height

Prototype/decals no height
/main
GitHub 7 年前
当前提交
ca60bb19
共有 15 个文件被更改,包括 237 次插入73 次删除
  1. 49
      ScriptableRenderPipeline/Core/CoreRP/CoreUtils.cs
  2. 19
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalProjectorComponent.cs
  3. 140
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalSystem.cs
  4. 9
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Decal/DecalUI.cs
  5. 31
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
  6. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipelineAsset.asset
  7. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipelineAsset.asset.meta
  8. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
  9. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.cs
  10. 7
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.cs.hlsl
  11. 9
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.hlsl
  12. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.shader
  13. 9
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DecalData.hlsl
  14. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DecalProperties.hlsl
  15. 19
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DecalUtilities.hlsl

49
ScriptableRenderPipeline/Core/CoreRP/CoreUtils.cs


QuickSort(arr, pivot + 1, right);
}
}
public static Mesh CreateDecalMesh()
{
Mesh mesh = new Mesh();
Vector3[] vertices = new Vector3[8];
vertices[0] = new Vector3(-0.5f, -1.0f, -0.5f);
vertices[1] = new Vector3(0.5f, -1.0f, -0.5f);
vertices[2] = new Vector3(0.5f, 0.0f, -0.5f);
vertices[3] = new Vector3(-0.5f, 0.0f, -0.5f);
vertices[4] = new Vector3(-0.5f, -1.0f, 0.5f);
vertices[5] = new Vector3(0.5f, -1.0f, 0.5f);
vertices[6] = new Vector3(0.5f, 0.0f, 0.5f);
vertices[7] = new Vector3(-0.5f, 0.0f, 0.5f);
mesh.vertices = vertices;
int[] triangles = new int[36];
triangles[0] = 0; triangles[1] = 2; triangles[2] = 1;
triangles[3] = 0; triangles[4] = 3; triangles[5] = 2;
triangles[6] = 1; triangles[7] = 6; triangles[8] = 5;
triangles[9] = 1; triangles[10] = 2; triangles[11] = 6;
triangles[12] = 5; triangles[13] = 7; triangles[14] = 4;
triangles[15] = 5; triangles[16] = 6; triangles[17] = 7;
triangles[18] = 4; triangles[19] = 3; triangles[20] = 0;
triangles[21] = 4; triangles[22] = 7; triangles[23] = 3;
triangles[24] = 3; triangles[25] = 6; triangles[26] = 2;
triangles[27] = 3; triangles[28] = 7; triangles[29] = 6;
triangles[30] = 4; triangles[31] = 1; triangles[32] = 5;
triangles[33] = 4; triangles[34] = 0; triangles[35] = 1;
mesh.triangles = triangles;
return mesh;
}
public static BoundingSphere GetDecalMeshBoundingSphere(Matrix4x4 decalToWorld)
{
Vector4 min = new Vector4(-0.5f, -1.0f, -0.5f, 1.0f);
Vector4 max = new Vector4(0.5f, 0.0f, 0.5f, 1.0f);
min = decalToWorld * min;
max = decalToWorld * max;
BoundingSphere res = new BoundingSphere();
res.position = (max + min) / 2;
res.radius = ((Vector3)(max - min)).magnitude / 2;
return res;
}
}
}

19
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalProjectorComponent.cs


private static readonly int m_DecalToWorldR = Shader.PropertyToID("_DecalToWorldR");
public Material m_Material;
private MaterialPropertyBlock m_PropertyBlock;
public const int kInvalidIndex = -1;
private int m_CullIndex = kInvalidIndex;
private MaterialPropertyBlock m_PropertyBlock;
public int CullIndex
{
get
{
return this.m_CullIndex;
}
set
{
this.m_CullIndex = value;
}
}
public void OnEnable()
{

public void OnValidate()
{
BoundingSphere sphere = CoreUtils.GetDecalMeshBoundingSphere(transform.localToWorldMatrix);
if (m_Material != null)
{
Shader shader = m_Material.shader;

}
}
}
private void DrawGizmo(bool selected)
{

public void OnDrawGizmosSelected()
{
DrawGizmo(true);
// if this object is selected there is a chance the transform was changed so update culling info
DecalSystem.instance.UpdateBoundingSphere(this);
}
public void UpdatePropertyBlock(Vector3 cameraPos)

140
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalSystem.cs


return m_Instance;
}
}
internal HashSet<DecalProjectorComponent> m_Decals = new HashSet<DecalProjectorComponent>();
Mesh m_CubeMesh;
private Mesh m_DecalMesh = null;
private CullingGroup m_CullingGroup = null;
private const int kDecalBlockSize = 128;
private BoundingSphere[] m_BoundingSpheres = new BoundingSphere[kDecalBlockSize];
private DecalProjectorComponent[] m_Decals = new DecalProjectorComponent[kDecalBlockSize];
private int[] m_ResultIndices = new int[kDecalBlockSize];
private int m_NumResults = 0;
private int m_DecalsCount = 0;
CreateCubeMesh();
m_DecalMesh = CoreUtils.CreateDecalMesh();
void CreateCubeMesh()
// update bounding sphere for a single decal
public void UpdateBoundingSphere(DecalProjectorComponent decal)
m_CubeMesh = new Mesh();
m_BoundingSpheres[decal.CullIndex] = CoreUtils.GetDecalMeshBoundingSphere(decal.transform.localToWorldMatrix);
}
Vector3[] vertices = new Vector3[8];
vertices[0] = new Vector3(-0.5f, -1.0f, -0.5f);
vertices[1] = new Vector3( 0.5f, -1.0f, -0.5f);
vertices[2] = new Vector3( 0.5f, 0.0f, -0.5f);
vertices[3] = new Vector3(-0.5f, 0.0f, -0.5f);
vertices[4] = new Vector3(-0.5f, -1.0f, 0.5f);
vertices[5] = new Vector3( 0.5f, -1.0f, 0.5f);
vertices[6] = new Vector3( 0.5f, 0.0f, 0.5f);
vertices[7] = new Vector3(-0.5f, 0.0f, 0.5f);
public void AddDecal(DecalProjectorComponent decal)
{
if (decal.CullIndex != DecalProjectorComponent.kInvalidIndex) //do not add the same decal more than once
return;
m_CubeMesh.vertices = vertices;
// increase array size if no space left
if(m_DecalsCount == m_Decals.Length)
{
DecalProjectorComponent[] newDecals = new DecalProjectorComponent[m_DecalsCount + kDecalBlockSize];
BoundingSphere[] newSpheres = new BoundingSphere[m_DecalsCount + kDecalBlockSize];
m_ResultIndices = new int[m_DecalsCount + kDecalBlockSize];
int[] triangles = new int[36];
m_Decals.CopyTo(newDecals, 0);
m_BoundingSpheres.CopyTo(newSpheres, 0);
triangles[0] = 0; triangles[1] = 2; triangles[2] = 1;
triangles[3] = 0; triangles[4] = 3; triangles[5] = 2;
triangles[6] = 1; triangles[7] = 6; triangles[8] = 5;
triangles[9] = 1; triangles[10] = 2; triangles[11] = 6;
triangles[12] = 5; triangles[13] = 7; triangles[14] = 4;
triangles[15] = 5; triangles[16] = 6; triangles[17] = 7;
triangles[18] = 4; triangles[19] = 3; triangles[20] = 0;
triangles[21] = 4; triangles[22] = 7; triangles[23] = 3;
triangles[24] = 3; triangles[25] = 6; triangles[26] = 2;
triangles[27] = 3; triangles[28] = 7; triangles[29] = 6;
triangles[30] = 4; triangles[31] = 1; triangles[32] = 5;
triangles[33] = 4; triangles[34] = 0; triangles[35] = 1;
m_Decals = newDecals;
m_BoundingSpheres = newSpheres;
}
m_CubeMesh.triangles = triangles;
m_Decals[m_DecalsCount] = decal;
m_Decals[m_DecalsCount].CullIndex = m_DecalsCount;
UpdateBoundingSphere(m_Decals[m_DecalsCount]);
m_DecalsCount++;
public void AddDecal(DecalProjectorComponent d)
public void RemoveDecal(DecalProjectorComponent decal)
// If no decal material assign, don't add it
if (d.m_Material == null)
return;
if (decal.CullIndex == DecalProjectorComponent.kInvalidIndex) //do not remove decal that has not been added
return;
int removeAtIndex = decal.CullIndex;
// replace with last decal in the list and update index
m_Decals[removeAtIndex] = m_Decals[m_DecalsCount - 1]; // move the last decal in list
m_Decals[removeAtIndex].CullIndex = removeAtIndex;
m_Decals[m_DecalsCount - 1] = null;
if (d.m_Material.GetTexture("_BaseColorMap") || d.m_Material.GetTexture("_NormalMap"))
// update the bounding spheres array
m_BoundingSpheres[removeAtIndex] = m_BoundingSpheres[m_DecalsCount - 1];
m_DecalsCount--;
decal.CullIndex = DecalProjectorComponent.kInvalidIndex;
}
public void BeginCull(Camera camera)
{
if (m_CullingGroup != null)
RemoveDecal(d);
m_Decals.Add(d);
Debug.LogError("Begin/EndCull() called out of sequence for decal projectors.");
m_NumResults = 0;
m_CullingGroup = new CullingGroup();
m_CullingGroup.targetCamera = camera;
m_CullingGroup.SetBoundingSpheres(m_BoundingSpheres);
m_CullingGroup.SetBoundingSphereCount(m_DecalsCount);
public void RemoveDecal(DecalProjectorComponent d)
public int QueryCullResults()
{
m_NumResults = m_CullingGroup.QueryIndices(true, m_ResultIndices, 0);
return m_NumResults;
}
public void Render(ScriptableRenderContext renderContext, HDCamera camera, CommandBuffer cmd)
m_Decals.Remove(d);
if (m_DecalMesh == null)
m_DecalMesh = CoreUtils.CreateDecalMesh();
for (int resultIndex = 0; resultIndex < m_NumResults; resultIndex++)
{
int decalIndex = m_ResultIndices[resultIndex];
// If no decal material assigned, don't draw it
if (m_Decals[decalIndex].m_Material == null)
continue;
// don't draw decals that do not have textures assigned
if (!m_Decals[decalIndex].m_Material.GetTexture("_BaseColorMap") && !m_Decals[decalIndex].m_Material.GetTexture("_NormalMap") &&
!m_Decals[decalIndex].m_Material.GetTexture("_MaskMap"))
continue;
m_Decals[decalIndex].UpdatePropertyBlock(camera.cameraPos);
cmd.DrawMesh(m_DecalMesh, m_Decals[decalIndex].transform.localToWorldMatrix, m_Decals[decalIndex].m_Material, 0, 0,
m_Decals[decalIndex].GetPropertyBlock());
}
public void Render(ScriptableRenderContext renderContext, Vector3 cameraPos, CommandBuffer cmd)
public void EndCull()
if (m_CubeMesh == null)
CreateCubeMesh();
foreach (var decal in m_Decals)
if (m_CullingGroup == null)
{
Debug.LogError("Begin/EndCull() called out of sequence for decal projectors.");
}
else
decal.UpdatePropertyBlock(cameraPos);
cmd.DrawMesh(m_CubeMesh, decal.transform.localToWorldMatrix, decal.m_Material, 0, 0, decal.GetPropertyBlock());
m_CullingGroup.Dispose();
m_CullingGroup = null;
}
}
}

9
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Decal/DecalUI.cs


public static GUIContent baseColorText = new GUIContent("Base Color + Blend", "Albedo (RGB) and Blend Factor (A)");
public static GUIContent normalMapText = new GUIContent("Normal Map", "Normal Map (BC7/BC5/DXT5(nm))");
public static GUIContent decalBlendText = new GUIContent("Decal Blend", "Combines with Base Color (A)");
public static GUIContent maskMapText = new GUIContent("Mask Map - M(R), AO(G), D(B), S(A)", "Mask map");
public static GUIContent decalBlendText = new GUIContent("Decal Blend", "Whole decal blend");
}
protected MaterialProperty baseColorMap = new MaterialProperty();

protected const string kNormalMap = "_NormalMap";
protected MaterialProperty maskMap = new MaterialProperty();
protected const string kMaskMap = "_MaskMap";
protected MaterialProperty decalBlend = new MaterialProperty();
protected const string kDecalBlend = "_DecalBlend";

{
baseColorMap = FindProperty(kBaseColorMap, props);
normalMap = FindProperty(kNormalMap, props);
maskMap = FindProperty(kMaskMap, props);
decalBlend = FindProperty(kDecalBlend, props);
}

{
CoreUtils.SetKeyword(material, "_COLORMAP", material.GetTexture(kBaseColorMap));
CoreUtils.SetKeyword(material, "_NORMALMAP", material.GetTexture(kNormalMap));
CoreUtils.SetKeyword(material, "_MASKMAP", material.GetTexture(kMaskMap));
}
protected void SetupMaterialKeywordsAndPassInternal(Material material)

m_MaterialEditor.TexturePropertySingleLine(Styles.baseColorText, baseColorMap);
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap);
m_MaterialEditor.TexturePropertySingleLine(Styles.maskMapText, maskMap);
m_MaterialEditor.ShaderProperty(decalBlend, Styles.decalBlendText);
EditorGUI.indentLevel--;

31
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


public const int k_MaxDbuffer = 4;
public int dbufferCount { get; set; }
public int vsibleDecalCount { get; set; }
RenderTargetIdentifier[] m_ColorMRTs;
RenderTargetIdentifier[] m_RTIDs = new RenderTargetIdentifier[k_MaxDbuffer];

}
return m_ColorMRTs;
}
public void PushGlobalParams(CommandBuffer cmd)
{
cmd.SetGlobalInt(HDShaderIDs._EnableDBuffer, vsibleDecalCount > 0 ? 1 : 0);
}
}

hdCamera.SetupGlobalParams(cmd);
m_SSSBufferManager.PushGlobalParams(cmd, sssParameters, m_FrameSettings);
m_DbufferManager.PushGlobalParams(cmd);
}
}

ScriptableRenderContext.EmitWorldGeometryForSceneView(camera);
}
#endif
// decal system needs to be updated with current camera
if (m_FrameSettings.enableDBuffer)
DecalSystem.instance.BeginCull(camera);
using (new ProfilingSample(cmd, "CullResults.Cull", GetSampler(CustomSamplerId.CullResultsCull)))
{

m_DbufferManager.vsibleDecalCount = 0;
if (m_FrameSettings.enableDBuffer)
{
m_DbufferManager.vsibleDecalCount = DecalSystem.instance.QueryCullResults();
DecalSystem.instance.EndCull();
}
var postProcessLayer = camera.GetComponent<PostProcessLayer>();
var hdCamera = HDCamera.Get(camera, postProcessLayer, m_FrameSettings);

InitAndClearBuffer(hdCamera, enableBakeShadowMask, cmd);
RenderDepthPrepass(m_CullResults, hdCamera, renderContext, cmd);
bool forcePrepassForDecals = m_DbufferManager.vsibleDecalCount > 0;
RenderDepthPrepass(m_CullResults, hdCamera, renderContext, cmd, forcePrepassForDecals);
RenderDBuffer(hdCamera.cameraPos, renderContext, cmd);
RenderDBuffer(hdCamera, renderContext, cmd);
RenderGBuffer(m_CullResults, hdCamera, renderContext, cmd);

// Forward only renderer: We always render everything
// Deferred renderer: We render a depth prepass only if engine request it. We can decide if we render everything or only opaque alpha tested object.
// Forward opaque with deferred renderer (DepthForwardOnly pass): We always render everything
void RenderDepthPrepass(CullResults cull, HDCamera hdCamera, ScriptableRenderContext renderContext, CommandBuffer cmd)
void RenderDepthPrepass(CullResults cull, HDCamera hdCamera, ScriptableRenderContext renderContext, CommandBuffer cmd, bool forcePrepass)
{
// In case of deferred renderer, we can have forward opaque material. These materials need to be render in the depth buffer to correctly build the light list.
// And they will tag the stencil to not be lit during the deferred lighting pass.

using (new ProfilingSample(cmd, addAlphaTestedOnly ? "Depth Prepass alpha test" : "Depth Prepass", GetSampler(CustomSamplerId.DepthPrepass)))
{
CoreUtils.SetRenderTarget(cmd, m_CameraDepthStencilBufferRT);
if (m_FrameSettings.enableDBuffer || (addFullDepthPrepass && !addAlphaTestedOnly)) // Always true in case of forward rendering, use in case of deferred rendering if requesting a full depth prepass
if (forcePrepass || (addFullDepthPrepass && !addAlphaTestedOnly)) // Always true in case of forward rendering, use in case of deferred rendering if requesting a full depth prepass
{
// We render first the opaque object as opaque alpha tested are more costly to render and could be reject by early-z (but not Hi-z as it is disable with clip instruction)
// This is handled automatically with the RenderQueue value (OpaqueAlphaTested have a different value and thus are sorted after Opaque)

}
}
void RenderDBuffer(Vector3 cameraPos, ScriptableRenderContext renderContext, CommandBuffer cmd)
void RenderDBuffer(HDCamera camera, ScriptableRenderContext renderContext, CommandBuffer cmd)
{
if (!m_FrameSettings.enableDBuffer)
return;

cmd.SetGlobalTexture(HDShaderIDs._MainDepthTexture, GetDepthTexture());
CoreUtils.SetRenderTarget(cmd, m_DbufferManager.GetDBuffers(), m_CameraDepthStencilBufferRT, ClearFlag.Color, CoreUtils.clearColorAllBlack);
DecalSystem.instance.Render(renderContext, cameraPos, cmd);
DecalSystem.instance.Render(renderContext, camera, cmd);
}
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipelineAsset.asset


supportSSR: 1
supportSSAO: 1
supportSSSAndTransmission: 1
supportDBuffer: 0
supportDBuffer: 1
supportMSAA: 0
supportAsyncCompute: 0
lightLoopSettings:

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipelineAsset.asset.meta


fileFormatVersion: 2
guid: 449281dd2b4fbee49b8397de0541ea3c
guid: 1fa8c4c8604deee4e99ff30888538ca5
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs


public static readonly int _CameraFilteringBuffer = Shader.PropertyToID("_CameraFilteringTexture");
public static readonly int _IrradianceSource = Shader.PropertyToID("_IrradianceSource");
public static readonly int _EnableDBuffer = Shader.PropertyToID("_EnableDBuffer");
public static readonly int[] _GBufferTexture =
{
Shader.PropertyToID("_GBufferTexture0"),

8
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.cs


public Vector4 baseColor;
[SurfaceDataAttributes("Normal", true)]
public Vector4 normalWS;
[SurfaceDataAttributes("Mask", true)]
public Vector4 mask;
};
[GenerateHLSL(PackingRules.Exact)]

Count = 2
Count = 3
};
//-----------------------------------------------------------------------------

// should this be combined into common class shared with Lit.cs???
static public int GetMaterialDBufferCount() { return (int)DBufferMaterial.Count; }
static RenderTextureFormat[] m_RTFormat = { RenderTextureFormat.ARGB32, RenderTextureFormat.ARGB32};
static RenderTextureReadWrite[] m_RTReadWrite = { RenderTextureReadWrite.sRGB, RenderTextureReadWrite.Linear};
static RenderTextureFormat[] m_RTFormat = { RenderTextureFormat.ARGB32, RenderTextureFormat.ARGB32, RenderTextureFormat.ARGB32 };
static RenderTextureReadWrite[] m_RTReadWrite = { RenderTextureReadWrite.sRGB, RenderTextureReadWrite.Linear, RenderTextureReadWrite.Linear };
static public void GetMaterialDBufferDescription(out RenderTextureFormat[] RTFormat, out RenderTextureReadWrite[] RTReadWrite)
{

7
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.cs.hlsl


//
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_BASE_COLOR (10000)
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_NORMAL_WS (10001)
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_MASK (10002)
#define DBUFFERMATERIAL_COUNT (2)
#define DBUFFERMATERIAL_COUNT (3)
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Decal+DecalSurfaceData
// PackingRules = Exact

float4 normalWS;
float4 mask;
};
//

break;
case DEBUGVIEW_DECAL_DECALSURFACEDATA_NORMAL_WS:
result = decalsurfacedata.normalWS.xyz;
break;
case DEBUGVIEW_DECAL_DECALSURFACEDATA_MASK:
result = decalsurfacedata.mask.xyz;
break;
}
}

9
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.hlsl


#endif
#endif // #ifdef DBUFFERMATERIAL_COUNT
CBUFFER_START(UnityDecalParameters)
uint _EnableDBuffer;
CBUFFER_END
out DBufferType1 outDBuffer1
out DBufferType1 outDBuffer1,
out DBufferType2 outDBuffer2
outDBuffer2 = surfaceData.mask;
DBufferType2 inDBuffer2,
out DecalSurfaceData surfaceData
)
{

surfaceData.normalWS.w = inDBuffer1.w;
surfaceData.mask = inDBuffer2;
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.shader


{
_BaseColorMap("BaseColorMap", 2D) = "white" {}
_NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map
_MaskMap("MaskMap", 2D) = "white" {}
_DecalBlend("_DecalBlend", Range(0.0, 1.0)) = 0.5
}

//-------------------------------------------------------------------------------------
#pragma shader_feature _COLORMAP
#pragma shader_feature _NORMALMAP
#pragma shader_feature _MASKMAP
//-------------------------------------------------------------------------------------

9
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DecalData.hlsl


{
surfaceData.baseColor = float4(0,0,0,0);
surfaceData.normalWS = float4(0,0,0,0);
surfaceData.mask = float4(0,0,0,0);
totalBlend *= surfaceData.baseColor.w;
surfaceData.baseColor.w = totalBlend;
surfaceData.baseColor.w *= totalBlend;
#endif
UVMapping texCoord;
ZERO_INITIALIZE(UVMapping, texCoord);

surfaceData.normalWS.w = totalBlend;
#endif
#if _MASKMAP
surfaceData.mask = SAMPLE_TEXTURE2D(_MaskMap, sampler_MaskMap, texCoordDS.xy);
surfaceData.mask.z = totalBlend;
#endif
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DecalProperties.hlsl


SAMPLER(sampler_BaseColorMap);
TEXTURE2D(_NormalMap);
SAMPLER(sampler_NormalMap);
TEXTURE2D(_MaskMap);
SAMPLER(sampler_MaskMap);
float _DecalBlend;

19
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DecalUtilities.hlsl


void AddDecalContribution(uint2 unPositionSS, inout SurfaceData surfaceData)
{
// Currently disabled
#if 0
FETCH_DBUFFER(DBuffer, _DBufferTexture, unPositionSS);
DecalSurfaceData decalSurfaceData;
DECODE_FROM_DBUFFER(DBuffer, decalSurfaceData);
if(_EnableDBuffer)
{
FETCH_DBUFFER(DBuffer, _DBufferTexture, unPositionSS);
DecalSurfaceData decalSurfaceData;
DECODE_FROM_DBUFFER(DBuffer, decalSurfaceData);
surfaceData.baseColor.xyz = lerp(surfaceData.baseColor.xyz, decalSurfaceData.baseColor.xyz, decalSurfaceData.baseColor.w);
surfaceData.normalWS.xyz = normalize(lerp(surfaceData.normalWS.xyz, decalSurfaceData.normalWS.xyz, decalSurfaceData.normalWS.w));
#endif
surfaceData.baseColor.xyz = lerp(surfaceData.baseColor.xyz, decalSurfaceData.baseColor.xyz, decalSurfaceData.baseColor.w);
surfaceData.normalWS.xyz = normalize(lerp(surfaceData.normalWS.xyz, decalSurfaceData.normalWS.xyz, decalSurfaceData.normalWS.w));
surfaceData.metallic = lerp(surfaceData.metallic, decalSurfaceData.mask.x, decalSurfaceData.mask.z);
surfaceData.ambientOcclusion = lerp(surfaceData.ambientOcclusion, decalSurfaceData.mask.y, decalSurfaceData.mask.z);
surfaceData.perceptualSmoothness = lerp(surfaceData.perceptualSmoothness, decalSurfaceData.mask.w, decalSurfaceData.mask.z);
}
}
正在加载...
取消
保存