浏览代码

update to using CommandBufferPool and add depth bind pass for scene view

/main
Filip Iliescu 7 年前
当前提交
91376559
共有 1 个文件被更改,包括 21 次插入12 次删除
  1. 33
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/ClassicDeferredPipeline.cs

33
Assets/ScriptableRenderPipeline/MobileRenderPipeline/ClassicDeferred/ClassicDeferredPipeline.cs


// present frame buffer.
FinalPass(loop);
// bind depth surface for editor grid/gizmo/selection rendering
if (camera.cameraType == CameraType.SceneView)
{
var cmd = CommandBufferPool.Get();
cmd.SetRenderTarget(BuiltinRenderTextureType.CameraTarget, new RenderTargetIdentifier(s_CameraDepthTexture));
loop.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}
}
static Matrix4x4 GetFlipMatrix()

static void RenderGBuffer(CullResults cull, Camera camera, ScriptableRenderContext loop)
{
// setup GBuffer for rendering
var cmd = new CommandBuffer { name = "Create G-Buffer" };
var cmd = CommandBufferPool.Get ("Create G-Buffer");
cmd.Dispose();
CommandBufferPool.Release(cmd);
// render opaque objects using Deferred pass
var settings = new DrawRendererSettings(cull, camera, new ShaderPassName("Deferred"))

void RenderLighting (Camera camera, CullResults inputs, ScriptableRenderContext loop)
{
var cmd = new CommandBuffer { name = "Lighting" };
var cmd = CommandBufferPool.Get ("Lighting");
// IF PLATFORM_MAC -- cannot use framebuffer fetch
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX

RenderReflections (camera, cmd, inputs, loop);
loop.ExecuteCommandBuffer (cmd);
cmd.Dispose ();
CommandBufferPool.Release(cmd);
}
void RenderSpotlight(VisibleLight light, CommandBuffer cmd, MaterialPropertyBlock properties, bool renderAsQuad, bool intersectsNear, bool deferred)

static void DepthOnlyForForwardOpaques(CullResults cull, Camera camera, ScriptableRenderContext loop)
{
var cmd = new CommandBuffer { name = "Forward Opaques - Depth Only" };
var cmd = CommandBufferPool.Get ("Forward Opaques - Depth Only");
cmd.Dispose();
CommandBufferPool.Release(cmd);
// render opaque objects using Deferred pass
var settings = new DrawRendererSettings(cull, camera, new ShaderPassName("DepthOnly"))

static void CopyDepthAfterGBuffer(ScriptableRenderContext loop)
{
var cmd = new CommandBuffer { name = "Copy depth" };
var cmd = CommandBufferPool.Get ("Copy depth");
cmd.Dispose();
CommandBufferPool.Release(cmd);
var cmd = new CommandBuffer { name = "FinalPass" };
var cmd = CommandBufferPool.Get ("FinalPass");
cmd.Dispose();
CommandBufferPool.Release(cmd);
}
void RenderForward(CullResults cull, Camera camera, ScriptableRenderContext loop, bool opaquesOnly)

s_LightDataBuffer.SetData(lightData);
CommandBuffer cmd = new CommandBuffer() {name = "SetupShaderConstants"};
CommandBuffer cmd = CommandBufferPool.Get ("SetupShaderConstants");
cmd.SetGlobalMatrix("g_mViewToWorld", viewToWorld);
cmd.SetGlobalMatrix("g_mWorldToView", viewToWorld.inverse);

cmd.SetGlobalFloat ("_transparencyShadows", TransparencyShadows ? 1.0f : 0.0f);
context.ExecuteCommandBuffer(cmd);
cmd.Dispose();
CommandBufferPool.Release(cmd);
}
}
正在加载...
取消
保存