public void RenderSceneWithParticles(FBO destination) { if (Particles.SoftParticles) { if (destination.ColorTextures.Length < 2) { Log.Error("RenderSceneWithParticles: fbo must have at least 2 colorbuffers."); } // rendaa skenen depth colorbufferiin, ei textureita/materiaaleja destination.BindFBO(); { // TODO rendaa vain zbufferiin, tsekkaa miten se on tehty shadowmappingissa //GL.Disable(EnableCap.Blend); //GL.ColorMask(false, false, false, false); //GL.Disable(EnableCap.CullFace); GL.ReadBuffer(ReadBufferMode.ColorAttachment1); GL.DrawBuffer(DrawBufferMode.ColorAttachment1); GL.ClearColor(float.MaxValue, float.MaxValue, float.MaxValue, float.MaxValue); destination.Clear(); GL.ClearColor(0.0f, 0.0f, 0.1f, 0); VBO.FastRenderPass = true; Particles.SetDepthProgram(); Render(); VBO.FastRenderPass = false; // TODO rendaa vain zbufferiin, tsekkaa miten se on tehty shadowmappingissa //GL.Enable(EnableCap.Blend); //GL.ColorMask(true, true, true, true); //GL.Enable(EnableCap.CullFace); // rendaa skene uudelleen textureineen GL.ReadBuffer(ReadBufferMode.ColorAttachment0); GL.DrawBuffer(DrawBufferMode.ColorAttachment0); destination.Clear(); RenderAgain(); GL.ReadBuffer(ReadBufferMode.ColorAttachment1); destination.BindColorBuffer(1, Settings.DEPTH_TEXUNIT); Particles.Render(); destination.UnBindColorBuffer(Settings.DEPTH_TEXUNIT); GL.ReadBuffer(ReadBufferMode.ColorAttachment0); } destination.UnBindFBO(); } else { // rendaa skene textureineen destination.BindFBO(); { destination.Clear(); Render(); Particles.Render(); } destination.UnBindFBO(); } }
/// <summary> /// renderoi worldin valosta päin (pelkän depthin) /// </summary> public static void SetupShadows(Renderable world, int lightNo, bool withParticles) { if (UseShadowMapping == false) { return; } if (Light.Lights.Count == 0) { Log.WriteLine("SetupShadows requires at least one light source!", false); return; } GL.Disable(EnableCap.Blend); GL.ColorMask(false, false, false, false); GL.Disable(EnableCap.CullFace); GL.PolygonOffset(1, 1); GL.Enable(EnableCap.PolygonOffsetFill); fbo.BindDepth(); fbo.BindFBO(); fbo.Clear(); // kuvakulma valosta päin GLExt.LoadMatrix(ref Light.Lights[lightNo].OrigOrientationMatrix); GLExt.Translate(-Light.Lights[lightNo].Position.X, -Light.Lights[lightNo].Position.Y, -Light.Lights[lightNo].Position.Z); SetTextureMatrix(); Frustum.CalculateFrustum(); VBO.FastRenderPass = true; depthShader.UseProgram(); world.Render(); if (withParticles) { depthShaderAlphaTest.UseProgram(); Particles.Render(); GLSLShader.UnBindShader(); } VBO.FastRenderPass = false; fbo.UnBindFBO(); GL.Disable(EnableCap.PolygonOffsetFill); GL.Enable(EnableCap.CullFace); GL.ColorMask(true, true, true, true); GLExt.LoadIdentity(); GameClass.NumOfObjects = 0; ShadowMapping.UnBindLightMask(); }
public void RenderSceneWithParticles(FBO destination) { if (Particles.SoftParticles) { if (destination.ColorTextures.Length < 2) Log.Error("RenderSceneWithParticles: fbo must have at least 2 colorbuffers."); // rendaa skenen depth colorbufferiin, ei textureita/materiaaleja destination.BindFBO(); { // TODO rendaa vain zbufferiin, tsekkaa miten se on tehty shadowmappingissa //GL.Disable(EnableCap.Blend); //GL.ColorMask(false, false, false, false); //GL.Disable(EnableCap.CullFace); GL.ReadBuffer(ReadBufferMode.ColorAttachment1); GL.DrawBuffer(DrawBufferMode.ColorAttachment1); GL.ClearColor(float.MaxValue, float.MaxValue, float.MaxValue, float.MaxValue); destination.Clear(); GL.ClearColor(0.0f, 0.0f, 0.1f, 0); VBO.FastRenderPass = true; Particles.SetDepthProgram(); Render(); VBO.FastRenderPass = false; // TODO rendaa vain zbufferiin, tsekkaa miten se on tehty shadowmappingissa //GL.Enable(EnableCap.Blend); //GL.ColorMask(true, true, true, true); //GL.Enable(EnableCap.CullFace); // rendaa skene uudelleen textureineen GL.ReadBuffer(ReadBufferMode.ColorAttachment0); GL.DrawBuffer(DrawBufferMode.ColorAttachment0); destination.Clear(); RenderAgain(); GL.ReadBuffer(ReadBufferMode.ColorAttachment1); destination.BindColorBuffer(1, Settings.DEPTH_TEXUNIT); Particles.Render(); destination.UnBindColorBuffer(Settings.DEPTH_TEXUNIT); GL.ReadBuffer(ReadBufferMode.ColorAttachment0); } destination.UnBindFBO(); } else { // rendaa skene textureineen destination.BindFBO(); { destination.Clear(); Render(); Particles.Render(); } destination.UnBindFBO(); } }