Skip to content

Decal in material debug display #3608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed an issue with transparent meshes writing their depths and recursive rendering (case 1314409).
- Fixed issue with compositor custom pass hooks added/removed repeatedly (case 1315971).
- Fixed: SSR with transparent (case 1311088)
- Fixed decals in material debug display.

### Changed
- Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void DrawDecalGUI()
materialEditor.ShaderProperty(smoothness, Styles.smoothnessText);
}

PopupShaderProperty(maskBlendSrc, Styles.normalOpacityChannelText, allMaskMap ? blendSourceNames : blendSourceNamesNoMap);
PopupShaderProperty(maskBlendSrc, Styles.maskOpacityChannelText, allMaskMap ? blendSourceNames : blendSourceNamesNoMap);

EditorGUI.indentLevel--;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void GetSurfaceData(FragInputs input, float3 V, PositionInputs posInput, float a
#endif

float albedoMapBlend = fadeFactor;
float maskMapBlend = fadeFactor;
float maskMapBlend = _DecalMaskMapBlueScale * fadeFactor;

ZERO_INITIALIZE(DecalSurfaceData, surfaceData);

Expand Down Expand Up @@ -57,16 +57,13 @@ void GetSurfaceData(FragInputs input, float3 V, PositionInputs posInput, float a
#ifdef _MATERIAL_AFFECTS_MASKMAP
#ifdef _MASKMAP
surfaceData.mask = SAMPLE_TEXTURE2D(_MaskMap, sampler_MaskMap, texCoords);
surfaceData.mask.z *= _DecalMaskMapBlueScale;
maskMapBlend *= surfaceData.mask.z; // store before overwriting with smoothness
#ifdef DECALS_4RT
surfaceData.mask.x = lerp(_MetallicRemapMin, _MetallicRemapMax, surfaceData.mask.x);
surfaceData.mask.y = lerp(_AORemapMin, _AORemapMax, surfaceData.mask.y);
#endif
surfaceData.mask.z = lerp(_SmoothnessRemapMin, _SmoothnessRemapMax, surfaceData.mask.w);
#else
surfaceData.mask.z = _DecalMaskMapBlueScale;
maskMapBlend *= surfaceData.mask.z; // store before overwriting with smoothness
#ifdef DECALS_4RT
surfaceData.mask.x = _Metallic;
surfaceData.mask.y = _AO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1012,12 +1012,16 @@ class DebugViewMaterialData
public Material debugGBufferMaterial;
public FrameSettings frameSettings;

public bool decalsEnabled;
public ComputeBufferHandle perVoxelOffset;
public DBufferOutput dbuffer;

public Texture clearColorTexture;
public RenderTexture clearDepthTexture;
public bool clearDepth;
}

TextureHandle RenderDebugViewMaterial(RenderGraph renderGraph, CullingResults cull, HDCamera hdCamera)
TextureHandle RenderDebugViewMaterial(RenderGraph renderGraph, CullingResults cull, HDCamera hdCamera, BuildGPULightListOutput lightLists, DBufferOutput dbuffer)
{
bool msaa = hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA);

Expand Down Expand Up @@ -1066,6 +1070,10 @@ TextureHandle RenderDebugViewMaterial(RenderGraph renderGraph, CullingResults cu
rendererConfiguration: m_CurrentRendererConfigurationBakedLighting,
stateBlock: m_DepthStateNoWrite)));

passData.decalsEnabled = (hdCamera.frameSettings.IsEnabled(FrameSettingsField.Decals)) && (DecalSystem.m_DecalDatasCount > 0);
passData.perVoxelOffset = builder.ReadComputeBuffer(lightLists.perVoxelOffset);
passData.dbuffer = ReadDBuffer(dbuffer, builder);

passData.clearColorTexture = Compositor.CompositionManager.GetClearTextureForStackedCamera(hdCamera); // returns null if is not a stacked camera
passData.clearDepthTexture = Compositor.CompositionManager.GetClearDepthForStackedCamera(hdCamera); // returns null if is not a stacked camera
passData.clearDepth = hdCamera.clearDepth;
Expand All @@ -1080,7 +1088,14 @@ TextureHandle RenderDebugViewMaterial(RenderGraph renderGraph, CullingResults cu
{
HDUtils.BlitColorAndDepth(context.cmd, data.clearColorTexture, data.clearDepthTexture, new Vector4(1, 1, 0, 0), 0, !data.clearDepth);
}

BindDBufferGlobalData(data.dbuffer, context);
DrawOpaqueRendererList(context, data.frameSettings, data.opaqueRendererList);

if (data.decalsEnabled)
DecalSystem.instance.SetAtlas(context.cmd); // for clustered decals
if (data.perVoxelOffset.IsValid())
context.cmd.SetGlobalBuffer(HDShaderIDs.g_vLayeredOffsetsBuffer, data.perVoxelOffset);
DrawTransparentRendererList(context, data.frameSettings, data.transparentRendererList);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,16 @@ void ExecuteWithRenderGraph(RenderRequest renderRequest,
}
else if (m_CurrentDebugDisplaySettings.IsDebugMaterialDisplayEnabled() || m_CurrentDebugDisplaySettings.IsMaterialValidationEnabled() || CoreUtils.IsSceneLightingDisabled(hdCamera.camera))
{
gpuLightListOutput = BuildGPULightList(m_RenderGraph, hdCamera, m_TileAndClusterData, m_TotalLightCount, ref m_ShaderVariablesLightListCB, prepassOutput.depthBuffer, prepassOutput.stencilBuffer, prepassOutput.gbuffer);

// For alpha output in AOVs or debug views, in case we have a shadow matte material, we need to render the shadow maps
if (m_CurrentDebugDisplaySettings.data.materialDebugSettings.debugViewMaterialCommonValue == Attributes.MaterialSharedProperty.Alpha)
RenderShadows(m_RenderGraph, hdCamera, cullingResults, ref shadowResult);

// Stop Single Pass is after post process.
StartXRSinglePass(m_RenderGraph, hdCamera);

colorBuffer = RenderDebugViewMaterial(m_RenderGraph, cullingResults, hdCamera);
colorBuffer = RenderDebugViewMaterial(m_RenderGraph, cullingResults, hdCamera, gpuLightListOutput, prepassOutput.dbuffer);
colorBuffer = ResolveMSAAColor(m_RenderGraph, hdCamera, colorBuffer);
}
else if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) &&
Expand Down