From 83b222889605602b4f02366432680597ca722eef Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 27 Jun 2015 19:53:24 +1000 Subject: [PATCH] Do not write depth values for translucent blocks (already calculated them in depth pass), remove unused adapative VSync code. --- OpenTK/GameWindow.cs | 18 ------------------ Rendering/MapRenderer.cs | 8 ++++---- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/OpenTK/GameWindow.cs b/OpenTK/GameWindow.cs index 9fb8655c7..873ef83b8 100644 --- a/OpenTK/GameWindow.cs +++ b/OpenTK/GameWindow.cs @@ -433,24 +433,6 @@ namespace OpenTK if (time > 0) { - // Todo: revisit this code. Maybe check average framerate instead? - // Note: VSyncMode.Adaptive enables vsync by default. The code below - // is supposed to disable vsync if framerate becomes too low (half of target - // framerate in the current approach) and reenable once the framerate - // rises again. - // Note 2: calling Context.VSync = true repeatedly seems to cause jitter on - // some configurations. If possible, we should avoid repeated calls. - // Note 3: we may not read/write the VSync property without a current context. - // This may come to pass if the user has moved rendering to his own thread. - if (Context.IsCurrent && VSync == VSyncMode.Adaptive && TargetRenderPeriod != 0) - { - // Check if we have enough time for a vsync - if (RenderTime > 2.0 * TargetRenderPeriod) - Context.VSync = false; - else - Context.VSync = true; - } - render_period = render_args.Time = time; OnRenderFrameInternal(render_args); render_time = render_watch.Elapsed.TotalSeconds; diff --git a/Rendering/MapRenderer.cs b/Rendering/MapRenderer.cs index 139157d14..0de06614b 100644 --- a/Rendering/MapRenderer.cs +++ b/Rendering/MapRenderer.cs @@ -220,18 +220,18 @@ namespace ClassicalSharp { // First fill depth buffer Graphics.ColourWrite = false; for( int batch = 0; batch < _1Dcount; batch++ ) { - RenderTranslucentBatchNoAdd( batch ); + RenderTranslucentBatchDepthPass( batch ); } // Then actually draw the transluscent blocks Graphics.AlphaBlending = true; Graphics.Texturing = true; Graphics.ColourWrite = true; - //Graphics.DepthWrite = false; TODO: test if this makes a difference. + Graphics.DepthWrite = false; // we already calculated depth values in depth pass for( int batch = 0; batch < _1Dcount; batch++ ) { Graphics.Bind2DTexture( texIds[batch] ); RenderTranslucentBatch( batch ); } - //Graphics.DepthWrite = true; + Graphics.DepthWrite = true; Graphics.AlphaTest = false; Graphics.AlphaBlending = false; Graphics.Texturing = false; @@ -333,7 +333,7 @@ namespace ClassicalSharp { } } - void RenderTranslucentBatchNoAdd( int batch ) { + void RenderTranslucentBatchDepthPass( int batch ) { for( int i = 0; i < chunks.Length; i++ ) { ChunkInfo info = chunks[i]; if( info.TranslucentParts == null || !info.Visible ) continue;