2025-03-19 17:05:30 +08:00
|
|
|
|
using AOT.Common;
|
|
|
|
|
|
using UnityEngine;
|
2024-09-26 17:57:22 +08:00
|
|
|
|
using UnityEngine.Rendering;
|
|
|
|
|
|
using UnityEngine.Rendering.RendererUtils;
|
|
|
|
|
|
using UnityEngine.Rendering.Universal;
|
|
|
|
|
|
namespace AOT.PostProcess.CustomDraw
|
|
|
|
|
|
{
|
|
|
|
|
|
public class CustomDrawRPF : ScriptableRendererFeature
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
|
public class Settings
|
|
|
|
|
|
{
|
|
|
|
|
|
public RenderPassEvent renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
|
|
|
|
|
|
public LayerMask layerMask;
|
|
|
|
|
|
public string lightModeName = "CustomDraw";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class CustomRenderPass : ScriptableRenderPass
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
private Settings _settings;
|
|
|
|
|
|
private ShaderTagId _shaderTagId;
|
|
|
|
|
|
|
|
|
|
|
|
public CustomRenderPass(Settings settings)
|
|
|
|
|
|
{
|
|
|
|
|
|
_settings = settings;
|
|
|
|
|
|
_shaderTagId = new ShaderTagId(settings.lightModeName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Execute(ScriptableRenderContext context,
|
|
|
|
|
|
ref RenderingData renderingData)
|
|
|
|
|
|
{
|
2025-03-19 17:05:30 +08:00
|
|
|
|
if (!AOTCodeDefine.ENABLE_MESH_OUTLINE) return;
|
2024-09-26 17:57:22 +08:00
|
|
|
|
var cmd = CommandBufferPool.Get("CustomDraw");
|
|
|
|
|
|
cmd.Clear();
|
|
|
|
|
|
var renderListDesc = new RendererListDesc(_shaderTagId,
|
|
|
|
|
|
renderingData.cullResults,
|
|
|
|
|
|
renderingData.cameraData.camera);
|
|
|
|
|
|
renderListDesc.renderQueueRange = RenderQueueRange.all;
|
|
|
|
|
|
renderListDesc.layerMask = _settings.layerMask;
|
|
|
|
|
|
var renderList = context.CreateRendererList(renderListDesc);
|
|
|
|
|
|
cmd.DrawRendererList(renderList);
|
|
|
|
|
|
|
|
|
|
|
|
context.ExecuteCommandBuffer(cmd);
|
|
|
|
|
|
CommandBufferPool.Release(cmd);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Settings settings = new Settings();
|
|
|
|
|
|
|
|
|
|
|
|
private CustomRenderPass _scriptablePass;
|
|
|
|
|
|
|
|
|
|
|
|
public override void Create()
|
|
|
|
|
|
{
|
|
|
|
|
|
_scriptablePass = new CustomRenderPass(settings);
|
|
|
|
|
|
_scriptablePass.renderPassEvent = settings.renderPassEvent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
|
|
|
|
|
|
{
|
|
|
|
|
|
renderer.EnqueuePass(_scriptablePass);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|