Editor camera and Editor/Runtime scene update separation

This commit is contained in:
Simon Lübeß
2022-05-17 19:06:28 +02:00
parent ccea61fb79
commit 5d8a4ad3a7
10 changed files with 486 additions and 126 deletions
+11
View File
@@ -288,6 +288,17 @@ namespace GlitchyEngine.Renderer
_sceneConstants.CompositionTarget = finalTarget;
}
public static void BeginScene(EditorCamera camera, RenderTarget2D finalTarget)
{
Debug.Profiler.ProfileRendererFunction!();
Matrix viewProjection = camera.Projection * camera.View;
_sceneConstants.ViewProjection = viewProjection;
_sceneConstants.CameraPosition = camera.Position;
_sceneConstants.CameraTarget = camera.RenderTarget;
_sceneConstants.CompositionTarget = finalTarget;
}
public static int SortMeshes(SubmittedMesh left, SubmittedMesh right)
{
// TODO: Once Material "inheritance" is ready we could perhaps check how similar materials are (e.g. shared textures/variables/etc...)
+42
View File
@@ -444,6 +444,48 @@ namespace GlitchyEngine.Renderer
s_drawOrder = drawOrder;
#if DEBUG
s_sceneRunning = true;
#endif
}
public static void BeginScene(EditorCamera camera, DrawOrder drawOrder = .SortByTexture, Effect effect = null, Effect circleEffect = null)
{
Debug.Profiler.ProfileRendererFunction!();
#if DEBUG
Log.EngineLogger.AssertDebug(s_initialized, "Renderer2D was not initialized.");
Log.EngineLogger.AssertDebug(!s_sceneRunning, "You have to call EndScene before you can make another call to BeginScene.");
#endif
//s_textureColorEffect.Bind(Renderer._context);
s_currentEffect?.ReleaseRef();
if(effect != null)
{
s_currentEffect = effect..AddRef();
}
else
{
s_currentEffect = s_batchEffect..AddRef();
}
s_currentCircleEffect?.ReleaseRef();
if(circleEffect != null)
{
s_currentCircleEffect = effect..AddRef();
}
else
{
s_currentCircleEffect = s_circleBatchEffect..AddRef();
}
Matrix viewProjection = camera.Projection * camera.View;
s_currentEffect.Variables["ViewProjection"].SetData(viewProjection);
s_currentCircleEffect.Variables["ViewProjection"].SetData(viewProjection);
s_drawOrder = drawOrder;
#if DEBUG
s_sceneRunning = true;
#endif