浏览代码

hack to quickly get render pass working.

/demo-work-customrenderer
Felipe Lira 5 年前
当前提交
669169f7
共有 2 个文件被更改,包括 28 次插入32 次删除
  1. 5
      Assets/Rendering/BoatRenderer.cs
  2. 55
      Assets/Rendering/MainRenderPass.cs

5
Assets/Rendering/BoatRenderer.cs


RenderTargetHandle m_ActiveCameraColorAttachment;
RenderTargetHandle m_ActiveCameraDepthAttachment;
RenderTargetHandle m_CameraColorAttachment;
RenderTargetHandle m_CameraDepthAttachment;
public RenderTargetHandle m_CameraColorAttachment;
public RenderTargetHandle m_CameraDepthAttachment;
RenderTargetHandle m_AfterPostProcessColor;
RenderTargetHandle m_ColorGradingLut;

EnqueuePass(m_ColorGradingLutPass);
}
m_MainRenderPass.renderer = this;
EnqueuePass(m_MainRenderPass);
// If a depth texture was created we necessarily need to copy it, otherwise we could have render it to a renderbuffer

55
Assets/Rendering/MainRenderPass.cs


AttachmentDescriptor depthAttachmentDescriptor;
Material m_CausticsMaterial;
public BoatRenderer renderer;
public MainRenderPass(RenderPassEvent renderPassEvent, Material causticsMaterial)
{

var opaqueDrawingSettings = CreateDrawingSettings(m_UniversalForwardPass, ref renderingData, SortingCriteria.CommonOpaque);
var transparentDrawingSettings = CreateDrawingSettings(m_UniversalForwardPass, ref renderingData, SortingCriteria.CommonTransparent);
//var cameraTargetDescriptor = renderingData.cameraData.cameraTargetDescriptor;
//int width = cameraTargetDescriptor.width;
//int height = cameraTargetDescriptor.height;
//var attachments = new NativeArray<AttachmentDescriptor>(2, Allocator.Temp);
//attachments[0] = colorAttachmentDescriptor;
//attachments[1] = depthAttachmentDescriptor;
var cameraTargetDescriptor = renderingData.cameraData.cameraTargetDescriptor;
int width = cameraTargetDescriptor.width;
int height = cameraTargetDescriptor.height;
colorAttachmentDescriptor.ConfigureTarget(renderer.m_CameraColorAttachment.Identifier(), false, true);
depthAttachmentDescriptor.ConfigureTarget(renderer.m_CameraDepthAttachment.Identifier(), false, true);
var descriptors = new NativeArray<AttachmentDescriptor>(
new[] { colorAttachmentDescriptor, depthAttachmentDescriptor },
Allocator.Temp);
//var descriptors = new NativeArray<AttachmentDescriptor>(
// new[] { colorAttachmentDescriptor, depthAttachmentDescriptor },
// Allocator.Temp);
//using (context.BeginScopedRenderPass(width, height, 1, descriptors, 1))
//{
// descriptors.Dispose();
// NativeArray<int> attachmentIndices = new NativeArray<int>(new[] { 0 }, Allocator.Temp);
// using (context.BeginScopedSubPass(attachmentIndices))
// {
// attachmentIndices.Dispose();
// context.DrawRenderers(renderingData.cullResults, ref opaqueDrawingSettings, ref m_OpaqueFilteringSettings);
// context.DrawSkybox(renderingData.cameraData.camera);
// context.DrawRenderers(renderingData.cullResults, ref transparentDrawingSettings, ref m_TransparentFilteringSettings);
// }
//}
context.DrawRenderers(renderingData.cullResults, ref opaqueDrawingSettings, ref m_OpaqueFilteringSettings);
context.DrawSkybox(renderingData.cameraData.camera);
var cmd = CommandBufferPool.Get("DrawCaustics");
cmd.DrawMesh(RenderingUtils.fullscreenMesh, Matrix4x4.identity, m_CausticsMaterial);
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
//context.DrawRenderers(renderingData.cullResults, ref transparentDrawingSettings, ref m_TransparentFilteringSettings);
using (context.BeginScopedRenderPass(width, height, 1, descriptors, 1))
{
descriptors.Dispose();
NativeArray<int> attachmentIndices = new NativeArray<int>(new[] { 0 }, Allocator.Temp);
using (context.BeginScopedSubPass(attachmentIndices))
{
attachmentIndices.Dispose();
context.DrawRenderers(renderingData.cullResults, ref opaqueDrawingSettings, ref m_OpaqueFilteringSettings);
context.DrawSkybox(renderingData.cameraData.camera);
var cmd = CommandBufferPool.Get("DrawCaustics");
cmd.DrawMesh(RenderingUtils.fullscreenMesh, Matrix4x4.identity, m_CausticsMaterial);
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
//context.DrawRenderers(renderingData.cullResults, ref transparentDrawingSettings, ref m_TransparentFilteringSettings);
}
}
}
}
正在加载...
取消
保存