{"id":1474,"date":"2015-08-19T12:59:03","date_gmt":"2015-08-19T19:59:03","guid":{"rendered":"http:\/\/universesandbox.com\/blog\/?p=1474"},"modified":"2015-08-19T13:44:29","modified_gmt":"2015-08-19T20:44:29","slug":"log-z-us2","status":"publish","type":"post","link":"https:\/\/universesandbox.com\/blog\/2015\/08\/log-z-us2\/","title":{"rendered":"Logarithmic Z-Buffering in Universe Sandbox \u00b2"},"content":{"rendered":"<h3>The Z-Fighting Problem<\/h3>\n<p>Z-fighting is a graphical issue which occurs when a game tries to draw two layers at the same depth.<\/p>\n<p>The results vary &#8212; sometimes one layer can appear to poke through another or they will flicker back and forth as they &#8220;fight&#8221; over which one should be drawn in front and which one in back.<\/p>\n<div id=\"attachment_1480\" style=\"width: 660px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/commons.wikimedia.org\/wiki\/File:ZfightingCB.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1480\" class=\"size-large wp-image-1480\" alt=\"Z-fighting demonstration from https:\/\/en.wikipedia.org\/wiki\/Z-fighting\" src=\"https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2015\/07\/Z-Fighting-650x300.jpg\" width=\"650\" height=\"300\" srcset=\"https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2015\/07\/Z-Fighting-650x300.jpg 650w, https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2015\/07\/Z-Fighting-300x138.jpg 300w, https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2015\/07\/Z-Fighting.jpg 941w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/a><p id=\"caption-attachment-1480\" class=\"wp-caption-text\">Z-fighting demonstration from <a href=\"https:\/\/en.wikipedia.org\/wiki\/Z-fighting\">Wikipedia article<\/a><\/p><\/div>\n<h3>From the Teapot to the Milky Way<\/h3>\n<p>If you&#8217;re a gamer, you&#8217;ve probably seen z-fighting before. But this issue mostly affects games which are working with very large camera distances. For example, open-world games may try to draw mountains and clouds in the distance, but because they both are designated as &#8220;very far away,&#8221; they fight over which is drawn in front.<\/p>\n<p>Universe Sandbox \u00b2 handles camera distances on a scale even larger than this. The camera may be a few meters away from a teapot, and lightyears away from a galaxy. And somewhere in between there may be a whole bunch of planets. The issue here would be distinguishing which planet should be drawn in front when, relatively, they&#8217;re much closer to each other than they are to either the teapot or the galaxy.<\/p>\n<h3>Log-Z<\/h3>\n<p>This is where logarithmic z-buffering comes in. In non-technical terms, log-z is a programming technique which opens up more &#8220;options&#8221; at which layers can be drawn. For example, instead of all planets being grouped together at depth 5, they can be drawn at 5 as well as 5.1 and 5.2 and so on. And with their own personal space, they no longer fight!<\/p>\n<p>Here&#8217;s a great interactive example of logarithmic versus standard z-buffering:\u00a0<a href=\"http:\/\/threejs.org\/examples\/webgl_camera_logarithmicdepthbuffer.html\">http:\/\/threejs.org\/examples\/webgl_camera_logarithmicdepthbuffer.html<\/a><\/p>\n<p>Using this technique in Universe Sandbox \u00b2 has been a long time coming &#8212; its implementation had been held up by a bug in Unity (the engine we use for development), which has now been fixed.<\/p>\n<p>It won&#8217;t be an obvious change for users, but now that Georg has added it in, we&#8217;re ready to move forward with a whole bunch of other visual improvements as well, not to mention the small performance increase we expect.<\/p>\n<p>Thanks, Georg! Now there&#8217;ll be no more of this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1515\" style=\"line-height: 1.5em;\" alt=\"Pluto-Z-Fighting\" src=\"https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2015\/08\/2015-08-19-13_34_28-Universe-Sandbox-\u00b2-650x359.png\" width=\"650\" height=\"359\" srcset=\"https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2015\/08\/2015-08-19-13_34_28-Universe-Sandbox-\u00b2-650x359.png 650w, https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2015\/08\/2015-08-19-13_34_28-Universe-Sandbox-\u00b2-300x165.png 300w, https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2015\/08\/2015-08-19-13_34_28-Universe-Sandbox-\u00b2.png 819w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>You can buy Universe Sandbox \u00b2 now for instant access to the alpha via our website: <a href=\"http:\/\/universesandbox.com\/2\">universesandbox.com\/2\u00a0<\/a><\/p>\n<p>Universe Sandbox \u00b2 will be on Steam Early Access later this summer.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Z-Fighting Problem Z-fighting is a graphical issue which occurs when a game tries to draw two layers at the same depth. The results vary &#8212; sometimes one layer can appear to poke through another or they will flicker back and forth as they &#8220;fight&#8221; over which one should be drawn in front and which [&hellip;]<\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1474","post","type-post","status-publish","format-standard","hentry","category-development"],"_links":{"self":[{"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/posts\/1474","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/comments?post=1474"}],"version-history":[{"count":18,"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/posts\/1474\/revisions"}],"predecessor-version":[{"id":1517,"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/posts\/1474\/revisions\/1517"}],"wp:attachment":[{"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/media?parent=1474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/categories?post=1474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/tags?post=1474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}