{"id":4524,"date":"2013-07-16T07:35:31","date_gmt":"2013-07-16T12:35:31","guid":{"rendered":"https:\/\/spaceengine.org\/?p=4524"},"modified":"2022-08-18T07:43:15","modified_gmt":"2022-08-18T12:43:15","slug":"logarithmic-depth-buffer","status":"publish","type":"post","link":"https:\/\/spaceengine.org\/news\/blog130716\/","title":{"rendered":"Logarithmic depth buffer"},"content":{"rendered":"<p>I've made experiments with the <a href=\"https:\/\/outerra.blogspot.com\/2009\/08\/logarithmic-z-buffer.html\" rel=\"noopener\" target=\"_blank\">logarithmic depth buffer<\/a>. Results are pretty cool, but there is a lot of work to do. For these screenshots I used astronaut and Discovery model from Doc's 2001 ships pack. Their sizes are real, not exaggerated as Doc originally made. No near plane clipping and no z-fighting.<\/p>\n<p><a href=\"https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/9825234.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/9825234-1024x543.jpg\" alt=\"\" width=\"1024\" height=\"543\" class=\"aligncenter size-large wp-image-4528\" srcset=\"https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/9825234-1024x543.jpg 1024w, https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/9825234-300x159.jpg 300w, https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/9825234-768x407.jpg 768w, https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/9825234-1536x814.jpg 1536w, https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/9825234-700x371.jpg 700w, https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/9825234.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>This will be not enabled in the next patch by default, because full support of the log Z-buffer requires a lot of changes in the engine. There are two ways of using logarithmic Z-buffer: in the vertex shader and in the pixel shader. The first one gives artifacts on near or elongaetd triangles - their Z value are interpolated incorrectly (perspectively). The second method fixes that, but kills FPS to almost zero: SpaceEngine have a huge overdraw on planets, so disabling fast Z test (what is required for this method) makes complex planetary surface shader with atmospheric effect to apply to huge amount of pixels.<\/p>\n<p><a href=\"https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/2133255.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/2133255-1024x543.jpg\" alt=\"\" width=\"1024\" height=\"543\" class=\"aligncenter size-large wp-image-4527\" srcset=\"https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/2133255-1024x543.jpg 1024w, https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/2133255-300x159.jpg 300w, https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/2133255-768x407.jpg 768w, https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/2133255-1536x814.jpg 1536w, https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/2133255-700x371.jpg 700w, https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/2133255.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>Anyway, I plan to implement a deferred shading pipeline in SpaceEngine, and logarithmic Z-buffer is the first step towards it. Deferred pipeline have a lot of benefits: fast Z-pass (that will speedup logarithmic Z buffer in a pixel shader), atmosphere as a post effect (that will speedup it a lot, because there will be no overdraw, and atmosphere will be applied to a planetary surface and ships that are inside the atmosphere), hundreds of lights (requires for ships at the first place), proper lens flare occlusion, and many other.<\/p>\n<p><a href=\"https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/4386868.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/4386868-1024x543.jpg\" alt=\"\" width=\"1024\" height=\"543\" class=\"aligncenter size-large wp-image-4526\" srcset=\"https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/4386868-1024x543.jpg 1024w, https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/4386868-300x159.jpg 300w, https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/4386868-768x407.jpg 768w, https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/4386868-1536x814.jpg 1536w, https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/4386868-700x371.jpg 700w, https:\/\/spaceengine.org\/wp-content\/uploads\/2022\/08\/4386868.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I've made experiments with the logarithmic depth buffer. Results are pretty cool, but there is a lot of work to do. For these screenshots I used astronaut and Discovery model from Doc's 2001 ships pack. Their sizes are real, not exaggerated as Doc originally made....<\/p>\n","protected":false},"author":1,"featured_media":4525,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4524","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"_links":{"self":[{"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/posts\/4524","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/comments?post=4524"}],"version-history":[{"count":1,"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/posts\/4524\/revisions"}],"predecessor-version":[{"id":4529,"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/posts\/4524\/revisions\/4529"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/media\/4525"}],"wp:attachment":[{"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/media?parent=4524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/categories?post=4524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/tags?post=4524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}