浏览代码

Moving to interfaced based SRL for better abstraction from Unity core

/main
Tim Cooper 8 年前
当前提交
5ce376fd
共有 13 个文件被更改,包括 197 次插入7 次删除
  1. 3
      Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs
  2. 3
      Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs
  3. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Editor/HDRenderLoopInspector.cs
  4. 5
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
  5. 5
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
  6. 9
      Assets/ScriptableRenderLoop/core.meta
  7. 33
      Assets/ScriptableRenderLoop/core/DefaultCameraProvider.cs
  8. 12
      Assets/ScriptableRenderLoop/core/DefaultCameraProvider.cs.meta
  9. 63
      Assets/ScriptableRenderLoop/core/RenderPipeline.cs
  10. 12
      Assets/ScriptableRenderLoop/core/RenderPipeline.cs.meta
  11. 45
      Assets/ScriptableRenderLoop/core/RenderingDataStore.cs
  12. 12
      Assets/ScriptableRenderLoop/core/RenderingDataStore.cs.meta

3
Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs


using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
using UnityEngine.ScriptableRenderPipeline;
// Very basic scriptable rendering loop example:
// - Use with BasicRenderLoopShader.shader (the loop expects "BasicPass" pass type to exist)

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

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


using UnityEngine.Experimental.Rendering;
using NUnit.Framework;
using UnityEngine.Rendering;
using UnityEngine.ScriptableRenderPipeline;
public class RenderLoopTestFixture : BaseRenderPipeline
public class RenderLoopTestFixture : RenderPipeline
{
public delegate void TestDelegate(Camera camera, CullResults cullResults, ScriptableRenderContext renderLoop);
private static TestDelegate s_Callback;

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


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

5
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs


using UnityEngine.Experimental.Rendering;
using System.Collections.Generic;
using System;
using UnityEngine.ScriptableRenderPipeline;
public partial class HDRenderLoop : BaseRenderPipeline
public partial class HDRenderLoop : RenderPipeline
{
const string k_HDRenderLoopPath = "Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset";

}
}
#endif
private class HDLoopDataStore : BaseScriptableRenderDataStore
private class HDLoopDataStore : RenderingDataStore
{
public HDLoopDataStore(BaseRenderPipeline owner) : base(owner)
{ }

5
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


using UnityEngine.Experimental.Rendering;
using System;
using System.Collections.Generic;
using UnityEngine.ScriptableRenderPipeline;
public class FptlLighting : BaseRenderPipeline
public class FptlLighting : RenderPipeline
{
#if UNITY_EDITOR
[UnityEditor.MenuItem("Renderloop/CreateRenderLoopFPTL")]

}
#endif
private class FptlLightingDataStore : BaseScriptableRenderDataStore
private class FptlLightingDataStore : RenderingDataStore
{
public FptlLightingDataStore(BaseRenderPipeline owner) : base(owner)
{}

9
Assets/ScriptableRenderLoop/core.meta


fileFormatVersion: 2
guid: 2850f79359a84d84793e8feefa3ebb54
folderAsset: yes
timeCreated: 1483004461
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

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:

63
Assets/ScriptableRenderLoop/core/RenderPipeline.cs


using System;
using System.Collections.Generic;
using UnityEngine.Experimental.Rendering;
namespace UnityEngine.ScriptableRenderPipeline
{
public abstract class RenderPipeline : BaseRenderPipeline
{
private readonly HashSet<IScriptableRenderDataStore> m_AssociatedDataStores = new HashSet<IScriptableRenderDataStore>();
private ICameraProvider m_CameraProvider;
public override ICameraProvider cameraProvider
{
get
{
if (m_CameraProvider == null)
m_CameraProvider = ConstructCameraProvider();
return m_CameraProvider;
}
set { m_CameraProvider = value; }
}
public override void Render(ScriptableRenderContext renderContext, IScriptableRenderDataStore dataStore)
{
if (dataStore == null)
throw new ArgumentException(string.Format("DataStore has been passed into pipe {0}", this));
if (dataStore.owner == null)
throw new ArgumentException(string.Format("DataStore owner is not set to {0}", this));
if (dataStore.owner != null && !ReferenceEquals(dataStore.owner, this))
throw new ArgumentException(string.Format("DataStore {0} has been passed into pipe {1}, but is owned by {2}", dataStore, this, dataStore.owner));
m_AssociatedDataStores.Add(dataStore);
dataStore.Build();
}
public override void Cleanup()
{
foreach (var store in m_AssociatedDataStores)
store.Cleanup();
m_AssociatedDataStores.Clear();
}
public override ICameraProvider ConstructCameraProvider()
{
return new DefaultCameraProvider();
}
public override IScriptableRenderDataStore ConstructDataStore()
{
return new RenderingDataStore(this);
}
public static void CleanCameras(IEnumerable<Camera> cameras)
{
foreach (var camera in cameras)
camera.ClearIntermediateRenderers();
}
}
}

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


fileFormatVersion: 2
guid: 841216767fdff24409a31bd55d2f6f72
timeCreated: 1483005410
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

45
Assets/ScriptableRenderLoop/core/RenderingDataStore.cs


using UnityEngine.Experimental.Rendering;
namespace UnityEngine.ScriptableRenderPipeline
{
public class RenderingDataStore : IScriptableRenderDataStore
{
private bool m_NeedsBuild = true;
public RenderingDataStore(IRenderPipeline owner)
{
this.owner = owner;
}
public void Build()
{
if (m_NeedsBuild)
{
InternalBuild();
m_NeedsBuild = false;
}
}
protected virtual void InternalBuild()
{}
public void Cleanup()
{
if (!m_NeedsBuild)
{
InternalCleanup();
m_NeedsBuild = true;
}
}
protected virtual void InternalCleanup()
{}
public IRenderPipeline owner { get; private set; }
public T GetRealOwner<T>() where T : IRenderPipeline
{
return (T)owner;
}
}
}

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


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