private void RenderGeometry(Camera camera) { FrameBuffer.Current = this.frameBufferGeometry; this.Matrices.View = camera.ViewMatrix; this.Matrices.Projection = camera.ProjectionMatrix; GL.Disable(EnableCap.Blend); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); GL.DepthFunc(DepthFunction.Less); GL.ClearColor(0.0f, 0.0f, 0.0f, 1.0f); GL.ClearDepth(1.0f); GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit); foreach (var job in this.SolidRenderJobs) { this.Matrices.World = job.Transform; var shader = job.Material.Shader ?? this.DefaultShader; CompiledShader cs = shader.Select("DeferredRenderer", this.geometryPixelShader); cs.Bind(); cs.BindUniforms(Game.Current.Time, job.Material, this.Matrices, this); job.Model.Draw((mesh) => cs.BindUniform(mesh), cs.HasTesselation); } FrameBuffer.Current = null; }
private void RenderOpaque(Camera camera) { this.Matrices.View = camera.ViewMatrix; this.Matrices.Projection = camera.ProjectionMatrix; FrameBuffer.Current = this.frameBufferScene; // No depth, we use the depth from the previous pass. GL.ClearColor(0.0f, 0.0f, 0.0f, 1.0f); GL.Clear(ClearBufferMask.ColorBufferBit); // Don't write z, just compare GL.DepthMask(false); this.Sky.Draw(this, camera); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.CullFace); GL.Disable(EnableCap.Blend); GL.CullFace(CullFaceMode.Back); GL.DepthFunc(DepthFunction.Lequal); //this.OpaqueCount = 0; foreach (var job in this.SolidRenderJobs) { this.Matrices.World = job.Transform; var shader = job.Material.Shader ?? this.DefaultShader; CompiledShader cs = shader.Select("DeferredRenderer"); cs.Bind(); cs.BindUniforms(Game.Current.Time, job.Material, this.Matrices, this); job.Model.Draw((mesh) => cs.BindUniform(mesh), cs.HasTesselation); //this.OpaqueCount += 1; } GL.DepthMask(true); FrameBuffer.Current = null; }