浏览代码

Update shaderVariableDecal (fix issue with decal and batcher)

/main
Sebastien Lagarde 6 年前
当前提交
413dd3f2
共有 5 个文件被更改,包括 30 次插入63 次删除
  1. 2
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.cs
  2. 35
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.cs.hlsl
  3. 19
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.hlsl
  4. 19
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/ShaderVariablesDecal.hlsl
  5. 18
      com.unity.render-pipelines.high-definition/HDRP/ShaderVariables.hlsl

2
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.cs


public partial class Decal
{
// Main structure that store the user data (i.e user input of master node in material graph)
[GenerateHLSL(PackingRules.Exact, false, true, 200)]
[GenerateHLSL(PackingRules.Exact, false)]
public struct DecalSurfaceData
{
[SurfaceDataAttributes("Base Color", false, true)]

35
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.cs.hlsl


#ifndef DECAL_CS_HLSL
#define DECAL_CS_HLSL
//
// UnityEngine.Experimental.Rendering.HDPipeline.Decal+DecalSurfaceData: static fields
//
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_BASE_COLOR (200)
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_NORMAL (201)
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_MASK (202)
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_AOSBLEND (203)
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_HTILE_MASK (204)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Decal+DBufferMaterial: static fields
//
#define DBUFFERMATERIAL_COUNT (4)

float4 baseColor;
float3 blendParams;
};
//
// Debug functions
//
void GetGeneratedDecalSurfaceDataDebug(uint paramId, DecalSurfaceData decalsurfacedata, inout float3 result, inout bool needLinearToSRGB)
{
switch (paramId)
{
case DEBUGVIEW_DECAL_DECALSURFACEDATA_BASE_COLOR:
result = decalsurfacedata.baseColor.xyz;
needLinearToSRGB = true;
break;
case DEBUGVIEW_DECAL_DECALSURFACEDATA_NORMAL:
result = decalsurfacedata.normalWS.xyz;
break;
case DEBUGVIEW_DECAL_DECALSURFACEDATA_MASK:
result = decalsurfacedata.mask.xyz;
break;
case DEBUGVIEW_DECAL_DECALSURFACEDATA_AOSBLEND:
result = float3(decalsurfacedata.MAOSBlend, 0.0);
break;
case DEBUGVIEW_DECAL_DECALSURFACEDATA_HTILE_MASK:
result = GetIndexColor(decalsurfacedata.HTileMask);
break;
}
}
#endif

19
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.hlsl


#include "CoreRP/ShaderLibrary/Debug.hlsl"
#include "Decal.cs.hlsl"
#define DBufferType0 float4
#define DBufferType1 float4
#define DBufferType2 float4

#define DECODE_FROM_DBUFFER(NAME, DECAL_SURFACE_DATA) DecodeFromDBuffer(MERGE_NAME(NAME,0), MERGE_NAME(NAME,1), MERGE_NAME(NAME,2), DECAL_SURFACE_DATA)
#endif
UNITY_INSTANCING_BUFFER_START(Decal)
UNITY_DEFINE_INSTANCED_PROP(float4x4, _NormalToWorld)
UNITY_INSTANCING_BUFFER_END(matrix)
RW_TEXTURE2D(float, _DecalHTile); // DXGI_FORMAT_R8_UINT is not supported by Unity
TEXTURE2D(_DecalHTileTexture);
uint _DecalCount;
StructuredBuffer<DecalData> _DecalDatas;
TEXTURE2D_ARRAY(_DecalAtlas);
SAMPLER(sampler_DecalAtlas);
TEXTURE2D(_DecalAtlas2D);
SAMPLER(_trilinear_clamp_sampler_DecalAtlas2D);
// Must be in sync with RT declared in HDRenderPipeline.cs ::Rebuild
void EncodeIntoDBuffer( DecalSurfaceData surfaceData

19
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/ShaderVariablesDecal.hlsl


#ifdef SHADER_VARIABLES_INCLUDE_CB
uint _EnableDecals;
float2 _DecalAtlasResolution;
uint _DecalCount;
#include "HDRP/Material/Decal//Decal.cs.hlsl"
StructuredBuffer<DecalData> _DecalDatas;
TEXTURE2D_ARRAY(_DecalAtlas);
SAMPLER(sampler_DecalAtlas);
TEXTURE2D(_DecalAtlas2D);
SAMPLER(_trilinear_clamp_sampler_DecalAtlas2D);
RW_TEXTURE2D(float, _DecalHTile); // DXGI_FORMAT_R8_UINT is not supported by Unity
TEXTURE2D(_DecalHTileTexture);
UNITY_INSTANCING_BUFFER_START(Decal)
UNITY_DEFINE_INSTANCED_PROP(float4x4, _NormalToWorld)
UNITY_INSTANCING_BUFFER_END(matrix)
#endif

18
com.unity.render-pipelines.high-definition/HDRP/ShaderVariables.hlsl


CBUFFER_END
// Undef in order to include all textures and buffers declarations
#undef SHADER_VARIABLES_INCLUDE_CB
#include "Lighting/LightLoop/ShaderVariablesLightLoop.hlsl"
#include "Lighting/AtmosphericScattering/ShaderVariablesAtmosphericScattering.hlsl"
#include "Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceLighting.hlsl"
#include "Material/Decal/ShaderVariablesDecal.hlsl"
#include "Material/SubsurfaceScattering/ShaderVariablesSubsurfaceScattering.hlsl"
// Custom generated by HDRP, not from Unity Engine (passed in via HDCamera)
#if defined(USING_STEREO_MATRICES)

// This define allow to tell to unity instancing that we will use our camera relative functions (ApplyCameraTranslationToMatrix and ApplyCameraTranslationToInverseMatrix) for the model view matrix
#define MODIFY_MATRIX_FOR_CAMERA_RELATIVE_RENDERING
#include "CoreRP/ShaderLibrary/UnityInstancing.hlsl"
// This is located after the include of UnityInstancing.hlsl so it can be used for declaration
// Undef in order to include all textures and buffers declarations
#undef SHADER_VARIABLES_INCLUDE_CB
#include "Lighting/LightLoop/ShaderVariablesLightLoop.hlsl"
#include "Lighting/AtmosphericScattering/ShaderVariablesAtmosphericScattering.hlsl"
#include "Lighting/ScreenSpaceLighting/ShaderVariablesScreenSpaceLighting.hlsl"
#include "Material/Decal/ShaderVariablesDecal.hlsl"
#include "Material/SubsurfaceScattering/ShaderVariablesSubsurfaceScattering.hlsl"
#include "ShaderVariablesFunctions.hlsl"
#endif // UNITY_SHADER_VARIABLES_INCLUDED
正在加载...
取消
保存