浏览代码

Merge pull request #1891 from Unity-Technologies/lw/no_front_to_back_sorting_of_opaques_on_gpu_with_hsr

Disable front-to-back sorting of opaque objects on hardware with HSR
/main
GitHub 6 年前
当前提交
eb39ae4e
共有 6 个文件被更改,包括 21 次插入3 次删除
  1. 3
      com.unity.render-pipelines.lightweight/CHANGELOG.md
  2. 9
      com.unity.render-pipelines.lightweight/LWRP/LightweightPipeline.cs
  3. 4
      com.unity.render-pipelines.lightweight/LWRP/LightweightPipelineCore.cs
  4. 3
      com.unity.render-pipelines.lightweight/LWRP/Passes/DepthOnlyPass.cs
  5. 3
      com.unity.render-pipelines.lightweight/LWRP/Passes/RenderOpaqueForwardPass.cs
  6. 2
      com.unity.render-pipelines.lightweight/package.json

3
com.unity.render-pipelines.lightweight/CHANGELOG.md


- When __HDR__ is enabled in the Camera but disabled in the Asset, an information box in the Camera Inspector informs you about it.
- When __MSAA__ is enabled in the Camera but disabled in the Asset, an information box in the Camera Inspector informs you about it.
- Enabled instancing on the terrain shader.
- Sorting of opaque objects now respects camera opaqueSortMode setting.
- Sorting of opaque objects disables front-to-back sorting flag when camera settings allow that and the GPU has hidden surface removal.
### Fixed
- The Unlit shader now samples Global Illumination correctly.
- The Inspector window for the Unlit shader now displays correctly.

9
com.unity.render-pipelines.lightweight/LWRP/LightweightPipeline.cs


#endif
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
using UnityEditor.Experimental.Rendering;
using UnityEngine;
using UnityEngine.Experimental.GlobalIllumination;
using Lightmapping = UnityEngine.Experimental.GlobalIllumination.Lightmapping;

}
cameraData.requiresDepthTexture |= cameraData.postProcessEnabled;
var commonOpaqueFlags = SortFlags.CommonOpaque;
var noFrontToBackOpaqueFlags = SortFlags.SortingLayer | SortFlags.RenderQueue | SortFlags.OptimizeStateChanges | SortFlags.CanvasOrder;
bool hasHSRGPU = SystemInfo.hasHiddenSurfaceRemovalOnGPU;
bool canSkipFrontToBackSorting = (camera.opaqueSortMode == OpaqueSortMode.Default && hasHSRGPU) || camera.opaqueSortMode == OpaqueSortMode.NoDistanceSort;
cameraData.defaultOpaqueSortFlags = canSkipFrontToBackSorting ? noFrontToBackOpaqueFlags : commonOpaqueFlags;
}
static void InitializeRenderingData(PipelineSettings settings, ref CameraData cameraData, ref CullResults cullResults,

4
com.unity.render-pipelines.lightweight/LWRP/LightweightPipelineCore.cs


using System.Collections.Generic;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.XR;
using UnityEngine.Experimental.Rendering;
namespace UnityEngine.Experimental.Rendering.LightweightPipeline
{

public bool requiresSoftParticles;
public bool requiresOpaqueTexture;
public Downsampling opaqueTextureDownsampling;
public SortFlags defaultOpaqueSortFlags;
public bool isStereoEnabled;

3
com.unity.render-pipelines.lightweight/LWRP/Passes/DepthOnlyPass.cs


context.ExecuteCommandBuffer(cmd);
cmd.Clear();
var drawSettings = CreateDrawRendererSettings(renderingData.cameraData.camera, SortFlags.CommonOpaque, RendererConfiguration.None, renderingData.supportsDynamicBatching);
var sortFlags = renderingData.cameraData.defaultOpaqueSortFlags;
var drawSettings = CreateDrawRendererSettings(renderingData.cameraData.camera, sortFlags, RendererConfiguration.None, renderingData.supportsDynamicBatching);
if (renderingData.cameraData.isStereoEnabled)
{
Camera camera = renderingData.cameraData.camera;

3
com.unity.render-pipelines.lightweight/LWRP/Passes/RenderOpaqueForwardPass.cs


cmd.Clear();
Camera camera = renderingData.cameraData.camera;
var drawSettings = CreateDrawRendererSettings(camera, SortFlags.CommonOpaque, rendererConfiguration, renderingData.supportsDynamicBatching);
var sortFlags = renderingData.cameraData.defaultOpaqueSortFlags;
var drawSettings = CreateDrawRendererSettings(camera, sortFlags, rendererConfiguration, renderingData.supportsDynamicBatching);
context.DrawRenderers(renderingData.cullResults.visibleRenderers, ref drawSettings, m_OpaqueFilterSettings);
// Render objects that did not match any shader pass with error shader

2
com.unity.render-pipelines.lightweight/package.json


"com.unity.render-pipelines.core": "3.4.0-preview",
"com.unity.shadergraph": "3.4.0-preview"
}
}
}
正在加载...
取消
保存