You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
3.4 KiB
82 lines
3.4 KiB
using System;
|
|
using UnityEngine.Experimental.Rendering;
|
|
|
|
namespace UnityEngine.Rendering.HighDefinition
|
|
{
|
|
partial class Decal
|
|
{
|
|
// Main structure that store the user data (i.e user input of master node in material graph)
|
|
[GenerateHLSL(PackingRules.Exact, false)]
|
|
public struct DecalSurfaceData
|
|
{
|
|
[SurfaceDataAttributes("Base Color", false, true)]
|
|
public Vector4 baseColor;
|
|
[SurfaceDataAttributes("Normal", true)]
|
|
public Vector4 normalWS;
|
|
[SurfaceDataAttributes("Mask", true)]
|
|
public Vector4 mask; // Metal, AmbientOcclusion, Smoothness, smoothness opacity
|
|
[SurfaceDataAttributes("Emissive")]
|
|
public Vector3 emissive;
|
|
[SurfaceDataAttributes("AOSBlend", true)]
|
|
public Vector2 MAOSBlend; // Metal opacity and Ambient occlusion opacity
|
|
};
|
|
|
|
[GenerateHLSL(PackingRules.Exact)]
|
|
public enum DBufferMaterial
|
|
{
|
|
Count = 4
|
|
};
|
|
|
|
[GenerateHLSL]
|
|
public enum DecalAtlasTextureType
|
|
{
|
|
Diffuse,
|
|
Normal,
|
|
Mask,
|
|
Count
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// DBuffer management
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// should this be combined into common class shared with Lit.cs???
|
|
static public int GetMaterialDBufferCount() { return (int)DBufferMaterial.Count; }
|
|
|
|
static GraphicsFormat[] m_RTFormat = { GraphicsFormat.R8G8B8A8_SRGB, GraphicsFormat.R8G8B8A8_UNorm, GraphicsFormat.R8G8B8A8_UNorm, GraphicsFormat.R8G8_UNorm };
|
|
static GraphicsFormat[] m_RTFormatHP = { GraphicsFormat.R8G8B8A8_SRGB, GraphicsFormat.R16G16B16A16_SFloat, GraphicsFormat.R8G8B8A8_UNorm, GraphicsFormat.R8G8_UNorm };
|
|
|
|
static public void GetMaterialDBufferDescription(out GraphicsFormat[] RTFormat)
|
|
{
|
|
HDRenderPipeline hdPipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline;
|
|
bool hp = hdPipeline.currentPlatformRenderPipelineSettings.supportSurfaceGradient &&
|
|
hdPipeline.currentPlatformRenderPipelineSettings.decalNormalBufferHP;
|
|
RTFormat = hp ? m_RTFormatHP : m_RTFormat;
|
|
}
|
|
}
|
|
|
|
// normal to world only uses 3x3 for actual matrix so some data is packed in the unused space
|
|
// blend:
|
|
// float decalBlend = decalData.normalToWorld[0][3];
|
|
// albedo contribution on/off:
|
|
// float albedoContribution = decalData.normalToWorld[1][3];
|
|
// tiling:
|
|
// float2 uvScale = float2(decalData.normalToWorld[3][0], decalData.normalToWorld[3][1]);
|
|
// float2 uvBias = float2(decalData.normalToWorld[3][2], decalData.normalToWorld[3][3]);
|
|
[GenerateHLSL(PackingRules.Exact, false)]
|
|
struct DecalData
|
|
{
|
|
public Matrix4x4 worldToDecal;
|
|
public Matrix4x4 normalToWorld;
|
|
public Vector4 diffuseScaleBias;
|
|
public Vector4 normalScaleBias;
|
|
public Vector4 maskScaleBias;
|
|
public Vector4 baseColor;
|
|
public Vector4 remappingAOS;
|
|
public Vector2 remappingMetallic; // (min, max) or metallic value if no texture is used
|
|
public float scalingBlueMaskMap;
|
|
public float sampleNormalAlpha;
|
|
public Vector3 blendParams; // x normal blend source, y mask blend source, z mask blend mode
|
|
public uint decalLayerMask;
|
|
};
|
|
}
|