srp render queue 失效

srp的render queue

根据每次render的时候的sortflags来选择开关

public enum SortFlags
{
    /// <summary>
    ///   <para>Do not sort objects.</para>
    /// </summary>
    None = 0x0,
    /// <summary>
    ///   <para>Sort by renderer sorting layer.</para>
    /// </summary>
    SortingLayer = 0x1,
    /// <summary>
    ///   <para>Sort by material render queue.</para>
    /// </summary>
    RenderQueue = 0x2,
    /// <summary>
    ///   <para>Sort objects back to front.</para>
    /// </summary>
    BackToFront = 0x4,
    /// <summary>
    ///   <para>Sort objects in rough front-to-back buckets.</para>
    /// </summary>
    QuantizedFrontToBack = 0x8,
    /// <summary>
    ///   <para>Sort objects to reduce draw state changes.</para>
    /// </summary>
    OptimizeStateChanges = 0x10,
    /// <summary>
    ///   <para>Sort renderers taking canvas order into account.</para>
    /// </summary>
    CanvasOrder = 0x20,
    /// <summary>
    ///   <para>Sorts objects by renderer priority.</para>
    /// </summary>
    RendererPriority = 0x40,
    /// <summary>
    ///   <para>Typical sorting for opaque objects.</para>
    /// </summary>
    CommonOpaque = 0x3B,
    /// <summary>
    ///   <para>Typical sorting for transparencies.</para>
    /// </summary>
    CommonTransparent = 0x17
}

 

用的时候 可以直接设置

 

var sortFlags = SortFlags.RenderQueue;
var drawSettings = CreateDrawRendererSettings(renderingData.cameraData.camera, sortFlags, RendererConfiguration.None, renderingData.supportsDynamicBatching);
context.DrawRenderers(renderingData.cullResults.visibleRenderers, ref drawSettings, opaqueFilterSettings);


 

还可以从renderingData.cameraData.defaultOpaqueSortFlags这里拿统一的设置

lwrp 里面的CommonOpaque 应该就是个distance sort

 

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;

  

 https://docs.unity3d.com/Manual/SL-SubShaderTags.html

posted on 2020-03-10 11:31  minggoddess  阅读(479)  评论(0编辑  收藏  举报