浏览代码

height is being written to dbuffer

/prototype-decals
Paul Melamed 7 年前
当前提交
097ea5b1
共有 6 个文件被更改,包括 23 次插入26 次删除
  1. 1
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/Decal/DecalUI.cs
  2. 13
      ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/Decal.cs
  3. 7
      ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/Decal.cs.hlsl
  4. 14
      ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/Decal.hlsl
  5. 11
      ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/DecalData.hlsl
  6. 3
      ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/DecalProperties.hlsl

1
ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/Decal/DecalUI.cs


if (EditorGUI.EndChangeCheck())
{
heightAmplitude.floatValue = (heightMax.floatValue - heightMin.floatValue) * 0.01f; // Conversion centimeters to meters.
foreach (var obj in m_MaterialEditor.targets)
SetupMaterialKeywordsAndPassInternal((Material)obj);
}

13
ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/Decal.cs


public Vector4 normalWS;
[SurfaceDataAttributes("Mask", true)]
public Vector4 mask;
[SurfaceDataAttributes("Height", false)]
public Vector4 height;
[GenerateHLSL(PackingRules.Exact, false, true, 10001)]
public struct DecalSurfaceDataVS
{
[SurfaceDataAttributes("Height", true)]
public float height;
}
[GenerateHLSL(PackingRules.Exact)]
public enum DBufferMaterial

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

7
ScriptableRenderPipeline/HDRenderPipeline/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 DEBUGVIEW_DECAL_DECALSURFACEDATA_HEIGHT (10003)
#define DBUFFERMATERIAL_COUNT (3)
#define DBUFFERMATERIAL_COUNT (4)
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Decal+DecalSurfaceData
// PackingRules = Exact

float4 normalWS;
float4 mask;
float4 height;
};
//

break;
case DEBUGVIEW_DECAL_DECALSURFACEDATA_MASK:
result = decalsurfacedata.mask.xyz;
break;
case DEBUGVIEW_DECAL_DECALSURFACEDATA_HEIGHT:
result = decalsurfacedata.height.xyz;
break;
}
}

14
ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/Decal.hlsl


#define DBufferType0 float4
#define DBufferType1 float4
#define DBufferType2 float4
#define DBufferType3 float
#define DBufferType3 float4
#ifdef DBUFFERMATERIAL_COUNT

out DBufferType0 outDBuffer0,
out DBufferType1 outDBuffer1,
out DBufferType2 outDBuffer2,
out DBufferType2 outDBuffer3
out DBufferType3 outDBuffer3
)
{
outDBuffer0 = surfaceData.baseColor;

DBufferType0 inDBuffer0,
DBufferType1 inDBuffer1,
DBufferType2 inDBuffer2,
DBufferType3 inDBuffer3,
out DecalSurfaceData surfaceData
)
{

surfaceData.normalWS.w = inDBuffer1.w;
surfaceData.mask = inDBuffer2;
}
void DecodeFromDBufferVS(
DBufferType3 inDBuffer3,
out DecalSurfaceDataVS surfaceData
)
{
ZERO_INITIALIZE(DecalSurfaceDataVS, surfaceData);

11
ScriptableRenderPipeline/HDRenderPipeline/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);
surfaceData.height = 0;
float totalBlend = _DecalBlend;
#if _COLORMAP
surfaceData.baseColor = SAMPLE_TEXTURE2D(_BaseColorMap, sampler_BaseColorMap, texCoordDS.xy);

surfaceData.normalWS.w *= surfaceData.mask.z;
surfaceData.mask.z *= totalBlend;
#endif
}
void GetSurfaceDataVS(float2 texCoordDS, out DecalSurfaceDataVS surfaceData)
{
surfaceData.height = 0;
surfaceData.mask = SAMPLE_TEXTURE2D(_HeightMap, sampler_HeightMap, texCoordDS.xy);
surfaceData.height.x = (SAMPLE_TEXTURE2D(_HeightMap, sampler_HeightMap, texCoordDS.xy).x - _HeightCenter) * _HeightAmplitude;
surfaceData.height.y = _DecalBlend;

3
ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/DecalProperties.hlsl


TEXTURE2D(_HeightMap);
SAMPLER(sampler_HeightMap);
float _HeightAmplitude;
float _HeightCenter;
float _DecalBlend;
CBUFFER_START(Decal)

正在加载...
取消
保存