浏览代码

Remove camera provider (pass from C++ again) + update loops to match new unity side code.

/main
Tim Cooper 8 年前
当前提交
2a19f5f7
共有 7 个文件被更改,包括 31 次插入125 次删除
  1. 18
      Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs
  2. 21
      Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs
  3. 21
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
  4. 31
      Assets/ScriptableRenderLoop/core/RenderPipeline.cs
  5. 20
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
  6. 33
      Assets/ScriptableRenderLoop/core/DefaultCameraProvider.cs
  7. 12
      Assets/ScriptableRenderLoop/core/DefaultCameraProvider.cs.meta

18
Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs


public class BasicRenderLoopInstance : RenderPipeline
{
protected override void InternalBuild()
{}
protected override void InternalCleanup()
{}
[NonSerialized]
readonly List<Camera> m_CamerasToRender = new List<Camera>();
public override void Render(ScriptableRenderContext renderLoop)
public override void Render(ScriptableRenderContext renderLoop, Camera[] cameras)
cameraProvider.GetCamerasToRender(m_CamerasToRender);
BasicRendering.Render(renderLoop, m_CamerasToRender);
CleanCameras(m_CamerasToRender);
m_CamerasToRender.Clear();
base.Render(renderLoop, cameras);
BasicRendering.Render(renderLoop, cameras);
}
}

21
Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs


private static TestDelegate s_Callback;
private static RenderLoopTestFixture m_Instance;
protected override void InternalBuild()
{}
protected override void InternalCleanup()
{}
[NonSerialized]
readonly List<Camera> m_CamerasToRender = new List<Camera>();
public override void Render(ScriptableRenderContext renderLoop)
public override void Render(ScriptableRenderContext renderLoop, Camera[] cameras)
cameraProvider.GetCamerasToRender(m_CamerasToRender);
base.Render(renderLoop, cameras);
foreach (var camera in m_CamerasToRender)
foreach (var camera in cameras)
{
if (!camera.enabled)
continue;

}
renderLoop.Submit();
CleanCameras(m_CamerasToRender);
m_CamerasToRender.Clear();
}
public static void Run(TestDelegate renderCallback)

21
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs


public HDRenderLoopInstance(HDRenderLoop owner)
{
m_Owner = owner;
}
protected override void InternalBuild()
{
protected override void InternalCleanup()
public override void Dispose()
base.Dispose();
[NonSerialized]
readonly List<Camera> m_CamerasToRender = new List<Camera>();
public override void Render(ScriptableRenderContext renderContext)
public override void Render(ScriptableRenderContext renderContext, Camera[] cameras)
cameraProvider.GetCamerasToRender(m_CamerasToRender);
m_Owner.Render(renderContext, m_CamerasToRender);
CleanCameras(m_CamerasToRender);
m_CamerasToRender.Clear();
base.Render(renderContext, cameras);
m_Owner.Render(renderContext, cameras);
}
}

31
Assets/ScriptableRenderLoop/core/RenderPipeline.cs


using System;
public abstract class RenderPipeline : BaseRenderPipeline
public abstract class RenderPipeline : IRenderPipeline
private ICameraProvider m_CameraProvider;
public override ICameraProvider cameraProvider
public virtual void Render(ScriptableRenderContext renderContext, Camera[] cameras)
get
{
if (m_CameraProvider == null)
m_CameraProvider = ConstructCameraProvider();
return m_CameraProvider;
}
set { m_CameraProvider = value; }
if (disposed)
throw new ObjectDisposedException(string.Format("{0} has been disposed. Do not call Render on disposed RenderLoops.", this));
public override ICameraProvider ConstructCameraProvider()
public bool disposed { get; private set; }
public virtual void Dispose()
return new DefaultCameraProvider();
}
public static void CleanCameras(IEnumerable<Camera> cameras)
{
foreach (var camera in cameras)
camera.ClearIntermediateRenderers();
disposed = true;
}
}
}

20
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


public FptlLightingInstance(FptlLighting owner)
{
m_Owner = owner;
}
protected override void InternalBuild()
{
protected override void InternalCleanup()
public override void Dispose()
base.Dispose();
[NonSerialized]
readonly List<Camera> m_CamerasToRender = new List<Camera>();
public override void Render(ScriptableRenderContext renderContext)
public override void Render(ScriptableRenderContext renderContext, Camera[] cameras)
cameraProvider.GetCamerasToRender(m_CamerasToRender);
m_Owner.Render(renderContext, m_CamerasToRender);
CleanCameras(m_CamerasToRender);
m_CamerasToRender.Clear();
base.Render(renderContext, cameras);
m_Owner.Render(renderContext, cameras);
}
}

33
Assets/ScriptableRenderLoop/core/DefaultCameraProvider.cs


using System.Collections.Generic;
using UnityEngine.Experimental.Rendering;
namespace UnityEngine.ScriptableRenderPipeline
{
public class DefaultCameraProvider : ICameraProvider
{
public Camera overrideCamera { get; set; }
public static void GetCamerasToRenderDefault(List<Camera> cameras)
{
cameras.Clear();
foreach (var c in Camera.allCameras)
{
if (c.enabled)
cameras.Add(c);
}
}
public void GetCamerasToRender(List<Camera> cameras)
{
if (overrideCamera != null)
{
cameras.Clear();
cameras.Add(overrideCamera);
}
else
{
GetCamerasToRenderDefault(cameras);
}
}
}
}

12
Assets/ScriptableRenderLoop/core/DefaultCameraProvider.cs.meta


fileFormatVersion: 2
guid: 3ac0b0f83d74a194f8578dc2907cacf6
timeCreated: 1483007679
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存