/// <summary> Renders all translucent (e.g. water) blocks. </summary> /// <remarks> Pixels drawn blend into existing geometry. </remarks> public void RenderTranslucent(double deltaTime) { if (chunks == null) { return; } IGraphicsApi gfx = game.Graphics; // First fill depth buffer int vertices = game.Vertices; gfx.SetBatchFormat(VertexFormat.P3fT2fC4b); gfx.Texturing = false; gfx.AlphaBlending = false; gfx.ColWriteMask(false, false, false, false); for (int batch = 0; batch < _1DUsed; batch++) { if (translucentPartsCount[batch] <= 0) { continue; } if (pendingTranslucent[batch] || usedTranslucent[batch]) { RenderTranslucentBatch(batch); pendingTranslucent[batch] = false; } } game.Vertices = vertices; // Then actually draw the transluscent blocks gfx.AlphaBlending = true; gfx.Texturing = true; gfx.ColWriteMask(true, true, true, true); gfx.DepthWrite = false; // we already calculated depth values in depth pass int[] texIds = Atlas1D.TexIds; gfx.EnableMipmaps(); for (int batch = 0; batch < _1DUsed; batch++) { if (translucentPartsCount[batch] <= 0) { continue; } if (!usedTranslucent[batch]) { continue; } gfx.BindTexture(texIds[batch]); RenderTranslucentBatch(batch); } gfx.DisableMipmaps(); gfx.DepthWrite = true; // If we weren't under water, render weather after to blend properly if (!inTranslucent && game.World.Env.Weather != Weather.Sunny) { gfx.AlphaTest = true; game.WeatherRenderer.Render(deltaTime); gfx.AlphaTest = false; } gfx.AlphaBlending = false; gfx.Texturing = false; }