浏览代码

Merge pull request #37 from Unity-Technologies/scriptablerenderloop-graphicssettings

Scriptablerenderloop graphicssettings
/main
GitHub 8 年前
当前提交
3e5093c1
共有 5 个文件被更改,包括 23 次插入54 次删除
  1. 8
      Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs
  2. 10
      Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs
  3. 4
      Assets/ScriptableRenderLoop/HDRenderLoop/Editor/HDRenderLoopInspector.cs
  4. 40
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
  5. 15
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs

8
Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs


private ShaderPassName shaderPassBasic;
public void OnEnable()
public override void Build()
Rebuild();
public override void Initialize()
public override void Cleanup()
shaderPassBasic = new ShaderPassName("BasicPass");
}
// Main entry point for our scriptable render loop

SetupLightShaderVariables (cull.visibleLights, loop);
// Draw opaque objects using BasicPass shader pass
var settings = new DrawRendererSettings (cull, camera, shaderPassBasic);
var settings = new DrawRendererSettings (cull, camera, new ShaderPassName("BasicPass"));
settings.sorting.flags = SortFlags.CommonOpaque;
settings.inputFilter.SetQueuesOpaque ();
loop.DrawRenderers (ref settings);

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


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

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


{
EditorUtility.SetDirty(renderLoop); // Repaint
// If something is chanage regarding tile/cluster rendering we need to force a OnValidate() OnHDRenderLoop, else change Rebuild() will not be call
renderLoop.OnValidate();
// SetAssetDirty will tell renderloop to rebuild
renderLoop.SetAssetDirty();
}
EditorGUI.BeginChangeCheck();

40
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs


int m_VelocityBuffer;
int m_DistortionBuffer;
public bool m_Dirty = false;
RenderTargetIdentifier m_CameraColorBufferRT;
RenderTargetIdentifier m_CameraDepthBufferRT;
RenderTargetIdentifier m_VelocityBufferRT;

// TODO TO CHECK: SebL I move allocation from Rebuild() to here, but there was a comment "// Our object can be garbage collected, so need to be allocate here", it is still true ?
Lit.RenderLoop m_LitRenderLoop = new Lit.RenderLoop();
public void OnValidate()
public override void Build()
// Calling direction Rebuild() here cause this warning:
// "SendMessage cannot be called during Awake, CheckConsistency, or OnValidate UnityEngine.Experimental.ScriptableRenderLoop.HDRenderLoop:OnValidate()"
// Workaround is to declare this dirty flag and call REbuild in Render()
m_Dirty = true;
}
public override void Rebuild()
{
// We call Cleanup() here because Rebuild() can be call by OnValidate(), i.e when inspector is touch
// Note that module don't need to do the same as the call here is propagated correctly
Cleanup();
#if UNITY_EDITOR
UnityEditor.SupportedRenderingFeatures.active = new UnityEditor.SupportedRenderingFeatures
{
reflectionProbe = UnityEditor.SupportedRenderingFeatures.ReflectionProbe.Rotation
};
#endif
m_CameraColorBuffer = Shader.PropertyToID("_CameraColorTexture");
m_CameraDepthBuffer = Shader.PropertyToID("_CameraDepthTexture");

m_LitRenderLoop.Rebuild();
m_lightLoop.Rebuild(m_TextureSettings);
m_Dirty = false;
}
public override void Initialize()
{
#if UNITY_EDITOR
UnityEditor.SupportedRenderingFeatures.active = new UnityEditor.SupportedRenderingFeatures
{
reflectionProbe = UnityEditor.SupportedRenderingFeatures.ReflectionProbe.Rotation
};
#endif
Rebuild();
}
public override void Cleanup()

public override void Render(Camera[] cameras, RenderLoop renderLoop)
{
if (m_Dirty)
{
Rebuild();
}
if (!m_LitRenderLoop.isInit)
{
m_LitRenderLoop.RenderInit(renderLoop);

15
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


private Texture2D m_LightAttentuationTexture;
private int m_shadowBufferID;
private void OnValidate()
{
Rebuild();
}
public override void Initialize()
{
Rebuild();
}
// RenderLoop.renderLoopDelegate -= ExecuteRenderLoop;
if (m_DeferredMaterial) DestroyImmediate(m_DeferredMaterial);
if (m_DeferredReflectionMaterial) DestroyImmediate(m_DeferredReflectionMaterial);
if (m_BlitMaterial) DestroyImmediate(m_BlitMaterial);

}
}
public override void Rebuild()
public override void Build()
ClearComputeBuffers();
s_GBufferAlbedo = Shader.PropertyToID("_CameraGBufferTexture0");
s_GBufferSpecRough = Shader.PropertyToID("_CameraGBufferTexture1");
s_GBufferNormal = Shader.PropertyToID("_CameraGBufferTexture2");

正在加载...
取消
保存