// render depthmap public void Render(Shader shader, SceneGraph scene) { GL.BindFramebuffer(FramebufferTarget.Framebuffer, framebuffer); GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, id); GL.Viewport(0, 0, programValues.depthmapres, programValues.depthmapres); GL.Enable(EnableCap.DepthTest); GL.Clear(ClearBufferMask.DepthBufferBit); GL.CullFace(CullFaceMode.Front); scene.SimpleRender(camera, position, shader); GL.CullFace(CullFaceMode.Back); GL.Disable(EnableCap.DepthTest); GL.Viewport(0, 0, programValues.screenwidth, programValues.screenheight); }
public void Render(Shader shader, Vector3 transform, SceneGraph scene) { GL.BindFramebuffer(FramebufferTarget.Framebuffer, framebuffer); GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.TextureCubeMap, id); Matrix4 cameraPosition = Matrix4.CreateTranslation(-transform); GL.Viewport(0, 0, programValues.cubedepthmapres, programValues.cubedepthmapres); GL.Enable(EnableCap.DepthTest); GL.CullFace(CullFaceMode.Front); for (int i = 0; i < 6; ++i) { GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, TextureTarget.TextureCubeMapPositiveX + i, id, 0); GL.Clear(ClearBufferMask.DepthBufferBit); scene.SimpleRender(cameraPosition * cameraRotations[i] * cameraFOV, cameraPosition, programValues.depthcubemapshader); } GL.CullFace(CullFaceMode.Back); GL.Viewport(0, 0, programValues.screenwidth, programValues.screenheight); }
// render cubemap public void Render(Shader shader, Vector3 transform, SceneGraph scene, ParentMesh parent) { GL.BindFramebuffer(FramebufferTarget.Framebuffer, framebuffer); GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.TextureCubeMap, id); Matrix4 cameraPosition = Matrix4.CreateTranslation(-transform); GL.Viewport(0, 0, programValues.cubemapres, programValues.cubemapres); GL.Enable(EnableCap.DepthTest); for (int i = 0; i < 6; ++i) { GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.TextureCubeMapPositiveX + i, id, 0); GL.Clear(ClearBufferMask.ColorBufferBit); GL.Clear(ClearBufferMask.DepthBufferBit); GL.ClearColor(0, 0, 0, 0); scene.RenderSkyBox(cameraPosition, cameraRotations[i], cameraFOV, programValues.skyboxshader); scene.SimpleRender(cameraPosition * cameraRotations[i] * cameraFOV, cameraPosition, programValues.cubemapshader, parent); } GL.Disable(EnableCap.DepthTest); GL.Viewport(0, 0, programValues.screenwidth, programValues.screenheight); }