{"id":302,"date":"2013-11-05T10:30:50","date_gmt":"2013-11-05T18:30:50","guid":{"rendered":"http:\/\/www.teamfizzgames.com\/Matt\/?p=302"},"modified":"2014-05-25T20:23:31","modified_gmt":"2014-05-26T03:23:31","slug":"errors-with-continuous-output-also-terrain","status":"publish","type":"post","link":"https:\/\/www.teamfizzgames.com\/Matt\/errors-with-continuous-output-also-terrain\/","title":{"rendered":"Errors With Continuous Output.  Also, Terrain."},"content":{"rendered":"<p>Last time I said I would be talking about my work on terrain and some errors I ran into over the course of developing my framework for this year. \u00a0So, surprisingly, that&#8217;s what&#8217;s about to happen.<\/p>\n<p>I&#8217;ll talk about terrain first because it&#8217;s visually more appealing (and I actually remembered to take screenshots of it!) and also likely infinitely less boring to people that aren&#8217;t me. \u00a0Right now I&#8217;m taking a fairly traditional approach of utilizing a heightmap to generate a 2D array of vertices, and decoding the color values of each pixel into height values. \u00a0I&#8217;m still early into my implementation, so things are very basic but functional. \u00a0Here&#8217;s a screen capture:<\/p>\n<div style=\"width: 673px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.anguishgames.com\/download\/images\/GoodGraphics28.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"http:\/\/www.anguishgames.com\/download\/images\/GoodGraphics28.png\" width=\"663\" height=\"387\" \/><\/a><p class=\"wp-caption-text\">GoodGraphics28.png, Terrains.<\/p><\/div>\n<p>So, again, I&#8217;m still very early into my implementation. \u00a0That image represents approximately 3 days worth of work. \u00a0I still have a lot of work to do in spatial partitioning, LOD, and blending different detail maps to get something that looks and performs as well as I need it to. \u00a0I also found an <a href=\"https:\/\/developer.nvidia.com\/nvidia-graphics-sdk-11-direct3d\" target=\"_blank\">Nvidia sample<\/a> that utilizes the tessellation hardware to great effect that I want to try to incorporate. \u00a0However, right now I&#8217;m able to generate 10 square kilometers worth of game world terrain and maintain over 60fps so I&#8217;m not unhappy with how things are going right now. \u00a0To get a sense of the scale, here are some images:<\/p>\n<p><a href=\"http:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2013\/11\/TerrainWork2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-303\" alt=\"TerrainWork2\" src=\"http:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2013\/11\/TerrainWork2-1024x597.png\" width=\"800\" height=\"466\" srcset=\"https:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2013\/11\/TerrainWork2-1024x597.png 1024w, https:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2013\/11\/TerrainWork2-300x174.png 300w, https:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2013\/11\/TerrainWork2-250x145.png 250w, https:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2013\/11\/TerrainWork2-150x87.png 150w, https:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2013\/11\/TerrainWork2.png 1382w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2013\/11\/TerrainWork.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-304\" alt=\"TerrainWork\" src=\"http:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2013\/11\/TerrainWork-1024x597.png\" width=\"800\" height=\"466\" srcset=\"https:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2013\/11\/TerrainWork-1024x597.png 1024w, https:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2013\/11\/TerrainWork-300x174.png 300w, https:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2013\/11\/TerrainWork-250x145.png 250w, https:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2013\/11\/TerrainWork-150x87.png 150w, https:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2013\/11\/TerrainWork.png 1382w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a>Now, unfortunately these screenshots have different terrains in them and it kind of ruins the effect of what I was trying to illustrate. \u00a0But, the movement of the terrain is minuscule as the car moves out of view into the far distance. \u00a0I would have retaken them to fix this inconsistency, except I&#8217;ve made dramatic changes to the lighting model that I want to save for my next post. \u00a0Sorry!<\/p>\n<p>And that brings me to the other issue I wanted to talk about; errors in the framework. \u00a0Some of them are caused by subtle problems but are still obvious. \u00a0For example, setting the depth function to D3D11_COMPARISON_EQUAL can be a great way to re-use depth information and eliminate pixel overdraw on subsequent material passes. \u00a0However, if one pass multiplies the viewprojection matrix against the world matrix on the cpu, and another does this on the gpu, you will not get the result you want because of differing precision. \u00a0It seems obvious as I type it, but it took me about 30 minutes to realize what was going on. \u00a0But at least it was incredibly obvious that something WAS wrong because the output was broken.<\/p>\n<p>Things get tougher when you get a continuous output from your error and you don&#8217;t realize anything is wrong, and this can happen a lot in graphics. \u00a0A good example is depth data usage in my lighting and postprocessing. \u00a0The image in my last post was actually completely incorrect, but I didn&#8217;t realize it when it was initially taken. \u00a0Tweaking some data lead me to realize that moving the camera far enough away caused illumination to zero out, which makes no sense. \u00a0But for a large range of distances it seemed correct, so it took me a while to even realize there was a problem. \u00a0A good way to simulate this (but wasn&#8217;t my actual problem) is to bind the active depth buffer as the shader resource view my lighting is sampling, ensuring I get an all black texture. \u00a0That&#8217;s obviously wrong, but the output you get can seem right within the right data set. \u00a0This problem also manifested itself in my depth of field effect. \u00a0When I first implemented it, I happened upon values that worked against my incorrect depth data. \u00a0It wasn&#8217;t until I started tweaking focal distance and width that I realized something was very wrong.<\/p>\n<p>Those problems might be specific to me, but I think the real takeaway here is that when you implement something new in graphics, you really need to test a wide range of data to ensure your effect is really doing what you want, and not doing it by circumstance. \u00a0If you don&#8217;t, a fundamental error can persist in your code base for a long, long time without anyone realizing, and it makes it much harder to add new features when basic code additions don&#8217;t do what you should reasonably expect them to.<\/p>\n<p>So, that&#8217;s it for this time. \u00a0I wish I&#8217;d taken some screenshots of output of the errors I talked about, but I think the information is still pretty worthwhile without pretty pictures. \u00a0Next time (hopefully soon), I&#8217;ll talk about the start of my move to a physically based rendering model, beginning with replacing the specular reflection model.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last time I said I would be talking about my work on terrain and some errors I ran into over the course of developing my framework for this year. \u00a0So, surprisingly, that&#8217;s what&#8217;s about to happen. I&#8217;ll talk about terrain first because it&#8217;s visually more appealing (and I actually remembered \u2026 <a class=\"continue-reading-link\" href=\"https:\/\/www.teamfizzgames.com\/Matt\/errors-with-continuous-output-also-terrain\/\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[2],"tags":[19],"class_list":["post-302","post","type-post","status-publish","format-standard","hentry","category-graphicsdev","tag-terrain"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p39ImV-4S","_links":{"self":[{"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/posts\/302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/comments?post=302"}],"version-history":[{"count":7,"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/posts\/302\/revisions"}],"predecessor-version":[{"id":363,"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/posts\/302\/revisions\/363"}],"wp:attachment":[{"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/media?parent=302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/categories?post=302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/tags?post=302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}