From 44b0ad8cf743259d45391d2bfc5eb0db9eec76b4 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Fri, 15 May 2020 19:15:06 +0200 Subject: [PATCH 1/4] Forest scale for tessellation change --- .../Runtime/Material/LayeredLit/LayeredLitData.hlsl | 3 ++- .../Material/LayeredLit/LayeredLitDataDisplacement.hlsl | 9 +++++++++ .../Runtime/Material/Lit/LitData.hlsl | 3 ++- .../Runtime/Material/Lit/LitDataDisplacement.hlsl | 6 ++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl index 501d6c8f3a4..9a60fc3c5f7 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl @@ -658,7 +658,8 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p input.texCoord1 = ((_UVMappingMask0.y + _UVMappingMask1.y + _UVMappingMask2.y + _UVMappingMask3.y + _UVDetailsMappingMask0.y + _UVDetailsMappingMask1.y + _UVDetailsMappingMask2.y + _UVDetailsMappingMask3.y) > 0) ? input.texCoord1 : 0; #endif -#ifndef SHADER_STAGE_RAY_TRACING +// Don't dither if displaced tessellation (we're fading out the displacement instead to match the next LOD) +#if !defined(SHADER_STAGE_RAY_TRACING) && !defined(_TESSELLATION_DISPLACEMENT) #ifdef LOD_FADE_CROSSFADE // enable dithering LOD transition if user select CrossFade transition in LOD group LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x); #endif diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitDataDisplacement.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitDataDisplacement.hlsl index b408f25a983..2be0e26e622 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitDataDisplacement.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitDataDisplacement.hlsl @@ -307,6 +307,15 @@ float3 ComputePerVertexDisplacement(LayerTexCoord layerTexCoord, float4 vertexCo float height1 = (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap1, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base1, lod).r - _HeightCenter1) * _HeightAmplitude1; float height2 = (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap2, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base2, lod).r - _HeightCenter2) * _HeightAmplitude2; float height3 = (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap3, SAMPLER_HEIGHTMAP_IDX, layerTexCoord.base3, lod).r - _HeightCenter3) * _HeightAmplitude3; + + // Scale by lod factor to ensure tessellated displacement influence is fully removed by the time we transition LODs +#if defined(LOD_FADE_CROSSFADE) && defined(_TESSELLATION_DISPLACEMENT) + height0 *= unity_LODFade.x; + height1 *= unity_LODFade.x; + height2 *= unity_LODFade.x; + height3 *= unity_LODFade.x; +#endif + // Height is affected by tiling property and by object scale (depends on option). // Apply scaling from tiling properties (TexWorldScale and tiling from BaseColor) ApplyDisplacementTileScale(height0, height1, height2, height3); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl index d7458ebba82..5d1d048151e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl @@ -186,7 +186,8 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p input.texCoord1 = (_UVMappingMask.y + _UVDetailsMappingMask.y) > 0 ? input.texCoord1 : 0; #endif -#if !defined(SHADER_STAGE_RAY_TRACING) +// Don't dither if displaced tessellation (we're fading out the displacement instead to match the next LOD) +#if !defined(SHADER_STAGE_RAY_TRACING) && !defined(_TESSELLATION_DISPLACEMENT) #ifdef LOD_FADE_CROSSFADE // enable dithering LOD transition if user select CrossFade transition in LOD group LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x); #endif diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDataDisplacement.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDataDisplacement.hlsl index d5203b67196..b2ccd968abf 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDataDisplacement.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDataDisplacement.hlsl @@ -202,6 +202,12 @@ float3 ComputePerVertexDisplacement(LayerTexCoord layerTexCoord, float4 vertexCo { #ifdef _HEIGHTMAP float height = (SAMPLE_UVMAPPING_TEXTURE2D_LOD(_HeightMap, sampler_HeightMap, layerTexCoord.base, lod).r - _HeightCenter) * _HeightAmplitude; + + // Scale by lod factor to ensure tessellated displacement influence is fully removed by the time we transition LODs +#if defined(LOD_FADE_CROSSFADE) && defined(_TESSELLATION_DISPLACEMENT) + height *= unity_LODFade.x; +#endif + #else float height = 0.0; #endif From 6a903f7a53bfef035ccfa0127d68f3372e7001c1 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Fri, 15 May 2020 19:17:40 +0200 Subject: [PATCH 2/4] Forest scale for tessellation change --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 1d66f8ffd54..3d15bcd68f6 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -732,6 +732,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Improved performance of reflection probe management when using a lot of probes. - Ignoring the disable SSR flags for recursive rendering. - Removed logic in the UI to disable parameters for contact shadows and fog volume components as it was going against the concept of the volume system. +- Lit and LayeredLit tessellation cross lod fade don't used dithering anymore between LOD but fade the tessellation height instead. Allow a smoother transition ## [7.1.1] - 2019-09-05 From c4fff1e764f9721fdbdaa2e61cc1c6596e4fde50 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Mon, 8 Jun 2020 15:00:11 +0200 Subject: [PATCH 3/4] Update Upgrading-from-2019.3-to-2020.1.md --- .../Documentation~/Upgrading-from-2019.3-to-2020.1.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2019.3-to-2020.1.md b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2019.3-to-2020.1.md index 624f51a07a5..b60b47e3de4 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2019.3-to-2020.1.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2019.3-to-2020.1.md @@ -2,6 +2,10 @@ In the High Definition Render Pipeline (HDRP), some features work differently between major versions of Unity. This document helps you upgrade HDRP from Unity 2019.3 to 2020.1. +## Mesh LOD Transition + +From Unity 2020.1, the cross LOD fade transition between a LitTessellation.shader or a LayeredLit.shader to object with a Material with no tessellation is no longer a dithering but a smooth decrease of the displacement strenght. It allow to improve transition between Firt high quality LOD done with tessellation to a second mid-qality LOD without it. The remaining transition are the same, i.e transition to low decimated mesh will still be a dithering. + ## Scene View Camera Settings From Unity 2020.1, the HDRP-specific settings of the scene view camera (anti-aliasing mode and stop NaNs) can be found in the same pop-up window as the standard scene camera settings, which are accessible by clicking the scene camera button on the toolbar of the scene window. These settings were previously in the HDRP preferences window (Edit > Preferences). From f7caa3fd915162f949762dd62b45518168e33f3a Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Mon, 8 Jun 2020 16:12:25 +0200 Subject: [PATCH 4/4] Update Upgrading-from-2019.3-to-2020.1.md --- .../Documentation~/Upgrading-from-2019.3-to-2020.1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2019.3-to-2020.1.md b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2019.3-to-2020.1.md index b60b47e3de4..eef46db39e1 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2019.3-to-2020.1.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2019.3-to-2020.1.md @@ -4,7 +4,7 @@ In the High Definition Render Pipeline (HDRP), some features work differently be ## Mesh LOD Transition -From Unity 2020.1, the cross LOD fade transition between a LitTessellation.shader or a LayeredLit.shader to object with a Material with no tessellation is no longer a dithering but a smooth decrease of the displacement strenght. It allow to improve transition between Firt high quality LOD done with tessellation to a second mid-qality LOD without it. The remaining transition are the same, i.e transition to low decimated mesh will still be a dithering. +From Unity 2020.1, HDRP no longer uses dithering for the LOD crossfade transition between a LOD that uses a material with tessellation and a LOD that uses a material with no tessellation. Instead, HDRP smoothly decreases the tessellation displacement strength. This improves the transition between the first high-quality LOD with tessellation and a second mid-quality LOD without tessellation. The remaining transitions between non-tessellation materials still use dithering. ## Scene View Camera Settings