浏览代码

[srl]Start porting loops to use new state context.

/main
Tim Cooper 8 年前
当前提交
6efb23b6
共有 5 个文件被更改,包括 70 次插入48 次删除
  1. 17
      Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs
  2. 21
      Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs
  3. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Editor/HDRenderLoopInspector.cs
  4. 38
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
  5. 40
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs

17
Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs


// - This loop also does not setup lightmaps, light probes, reflection probes or light cookies
[ExecuteInEditMode]
public class BasicRenderLoop : RenderPipeline<ICameraProvider>
public class BasicRenderLoop : BaseRenderPipeline
{
#if UNITY_EDITOR
[UnityEditor.MenuItem("Renderloop/Create BasicRenderLoop")]

}
#endif
public override void Build()
{}
public override void Cleanup()
{}
public override void Render(ScriptableRenderContext renderLoop)
public override void Render(ScriptableRenderContext renderLoop, IScriptableRenderDataStore dataStore)
if (realCameraProvider == null)
realCameraProvider = new DefaultCameraProvider();
realCameraProvider.GetCamerasToRender(m_CamerasToRender);
base.Render(renderLoop, dataStore);
cameraProvider.GetCamerasToRender(m_CamerasToRender);
Render(renderLoop, m_CamerasToRender);
}

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


using UnityEngine.Rendering;
[ExecuteInEditMode]
public class RenderLoopTestFixture : RenderPipeline<ICameraProvider>
public class RenderLoopTestFixture : BaseRenderPipeline
{
public delegate void TestDelegate(Camera camera, CullResults cullResults, ScriptableRenderContext renderLoop);
private static TestDelegate s_Callback;

[NonSerialized]
readonly List<Camera> m_CamerasToRender = new List<Camera>();
public override void Render(ScriptableRenderContext renderLoop)
public override void Render(ScriptableRenderContext renderLoop, IScriptableRenderDataStore dataStore)
if (realCameraProvider == null)
realCameraProvider = new DefaultCameraProvider();
realCameraProvider.GetCamerasToRender(m_CamerasToRender);
cameraProvider.GetCamerasToRender(m_CamerasToRender);
foreach (var camera in m_CamerasToRender)
{

renderLoop.Submit();
}
public override void Build()
{
}
public override void Cleanup()
{
}
public static void Run(TestDelegate renderCallback)
{
if (m_Instance == null)

2
Assets/ScriptableRenderLoop/HDRenderLoop/Editor/HDRenderLoopInspector.cs


EditorUtility.SetDirty(renderLoop); // Repaint
// SetAssetDirty will tell renderloop to rebuild
renderLoop.SetAssetDirty();
renderLoop.CleanupAllDataStores();
}
EditorGUI.BeginChangeCheck();

38
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs


{
[ExecuteInEditMode]
// This HDRenderLoop assume linear lighting. Don't work with gamma.
public partial class HDRenderLoop : RenderPipeline<ICameraProvider>
public partial class HDRenderLoop : BaseRenderPipeline
{
const string k_HDRenderLoopPath = "Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset";

}
}
#endif
private class HDLoopDataStore : BaseScriptableRenderDataStore
{
public HDLoopDataStore(BaseRenderPipeline owner) : base(owner)
{ }
protected override void InternalBuild()
{
base.InternalBuild();
HDRenderLoop realOwner = GetRealOwner<HDRenderLoop>();
realOwner.Build();
}
protected override void InternalCleanup()
{
base.InternalBuild();
HDRenderLoop realOwner = GetRealOwner<HDRenderLoop>();
realOwner.Cleanup();
}
}
public override IScriptableRenderDataStore ConstructDataStore()
{
return new HDLoopDataStore(this);
}
SkyManager m_SkyManager = new SkyManager();
public SkyManager skyManager

get { return m_CommonSettings; }
}
public override void Build()
public void Build()
{
#if UNITY_EDITOR
UnityEditor.SupportedRenderingFeatures.active = new UnityEditor.SupportedRenderingFeatures

m_lightLoop.Build(m_TextureSettings);
}
public override void Cleanup()
public void Cleanup()
{
m_lightLoop.Cleanup();
m_LitRenderLoop.Cleanup();

[NonSerialized]
readonly List<Camera> m_CamerasToRender = new List<Camera>();
public override void Render(ScriptableRenderContext renderLoop)
public override void Render(ScriptableRenderContext renderLoop, IScriptableRenderDataStore dataStore)
if (realCameraProvider == null)
realCameraProvider = new DefaultCameraProvider();
realCameraProvider.GetCamerasToRender(m_CamerasToRender);
base.Render(renderLoop, dataStore);
cameraProvider.GetCamerasToRender(m_CamerasToRender);
if (!m_LitRenderLoop.isInit)
{

40
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


namespace UnityEngine.Experimental.ScriptableRenderLoop
{
[ExecuteInEditMode]
public class FptlLighting : RenderPipeline<ICameraProvider>
public class FptlLighting : BaseRenderPipeline
{
#if UNITY_EDITOR
[UnityEditor.MenuItem("Renderloop/CreateRenderLoopFPTL")]

UnityEditor.AssetDatabase.CreateAsset(instance, "Assets/renderloopfptl.asset");
//AssetDatabase.CreateAsset(instance, "Assets/ScriptableRenderLoop/fptl/renderloopfptl.asset");
}
#endif
#endif
private class FptlLightingDataStore : BaseScriptableRenderDataStore
{
public FptlLightingDataStore(BaseRenderPipeline owner) : base(owner)
{}
protected override void InternalBuild()
{
base.InternalBuild();
FptlLighting realOwner = GetRealOwner<FptlLighting>();
realOwner.Build();
}
protected override void InternalCleanup()
{
base.InternalBuild();
FptlLighting realOwner = GetRealOwner<FptlLighting>();
realOwner.Cleanup();
}
}
[SerializeField]
ShadowSettings m_ShadowSettings = ShadowSettings.Default;

private Texture2D m_LightAttentuationTexture;
private int m_shadowBufferID;
public override void Cleanup()
public void Cleanup()
{
if (m_DeferredMaterial) DestroyImmediate(m_DeferredMaterial);
if (m_DeferredReflectionMaterial) DestroyImmediate(m_DeferredReflectionMaterial);

}
}
public override void Build()
public void Build()
{
s_GBufferAlbedo = Shader.PropertyToID("_CameraGBufferTexture0");
s_GBufferSpecRough = Shader.PropertyToID("_CameraGBufferTexture1");

s_BigTileLightList = null;
m_shadowBufferID = Shader.PropertyToID("g_tShadowBuffer");
}
public override IScriptableRenderDataStore ConstructDataStore()
{
return new FptlLightingDataStore(this);
}
static void SetupGBuffer(int width, int height, CommandBuffer cmd)

[NonSerialized]
readonly List<Camera> m_CamerasToRender = new List<Camera>();
public override void Render(ScriptableRenderContext renderLoop)
public override void Render(ScriptableRenderContext renderLoop, IScriptableRenderDataStore dataStore)
if (realCameraProvider == null)
realCameraProvider = new DefaultCameraProvider();
realCameraProvider.GetCamerasToRender(m_CamerasToRender);
base.Render(renderLoop, dataStore);
cameraProvider.GetCamerasToRender(m_CamerasToRender);
foreach (var camera in m_CamerasToRender)
{

正在加载...
取消
保存