{"id":408,"date":"2022-05-22T19:22:00","date_gmt":"2022-05-22T18:22:00","guid":{"rendered":"https:\/\/starshipsimulator.co.uk\/?p=408"},"modified":"2022-08-17T19:27:10","modified_gmt":"2022-08-17T18:27:10","slug":"back-to-galaxy-oop-there-goes-rapidity","status":"publish","type":"post","link":"https:\/\/starshipsimulator.co.uk\/?p=408","title":{"rendered":"Back To Galaxy, Oop There Goes Rapidity"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;4.9.1&#8243; _module_preset=&#8221;default&#8221; background_color=&#8221;RGBA(0,0,0,0)&#8221; custom_margin=&#8221;0px|0px|0px|0px|true|true&#8221; custom_padding=&#8221;0px|0px|0px|0px|true|true&#8221; border_color_all=&#8221;#000000&#8243;][et_pb_row _builder_version=&#8221;4.9.1&#8243; _module_preset=&#8221;default&#8221; background_color=&#8221;RGBA(0,0,0,0)&#8221; width=&#8221;100%&#8221; custom_margin=&#8221;0px|0px|0px|0px|true|true&#8221; custom_padding=&#8221;0px|0px|0px|0px|true|true&#8221; border_color_all=&#8221;#FFFFFF&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.9.1&#8243; _module_preset=&#8221;default&#8221;][et_pb_text _builder_version=&#8221;4.9.1&#8243; _module_preset=&#8221;default&#8221; text_font=&#8221;||||||||&#8221; text_text_color=&#8221;#FFFFFF&#8221; text_font_size=&#8221;16px&#8221; text_letter_spacing=&#8221;1px&#8221; hover_enabled=&#8221;0&#8243; sticky_enabled=&#8221;0&#8243;]Having gotten the new player character working reasonably well on the UE5 build, I&#8217;ve gone back to getting the new 1:1 scale Galaxy System working smoothly as well. The first step in the process was generating the complete starfield around the ship using the new scale, but with a greater number of sectors than before so that we can use the same data to render a real-time, dynamic skybox (ie, the stars move outside while at warp).<\/p>\n<p>Instead of the 8 sectors, we were generating before (a 2&#215;2 cube), we now need to generate a whopping 27 (3&#215;3 cube) to form a full sphere with a radius of 150ly. Given an average of 4000 stars per sector, that&#8217;s over 100,000 star systems to manage. Efficiency is the name of the game here, so I&#8217;ve been carefully juggling just how much data to generate at set points in the process so as not to overload everything. For example, do I convert each star&#8217;s Kelvin temperature to RGB colour at the time of generation, or do I perform that task after the data has been filtered? The jury is still out on that one, but that&#8217;s an example of how carefully this needs to be managed.<\/p>\n<p>Generating a full 3&#215;3 cube of sectors means I only have to regenerate that data afresh when the ship moves into a whole new sector, and given that each sector is 100ly wide, it&#8217;s not something that will be happening very often at all. As such, I can generate the data fairly slowly over a period of say 20 seconds so as not to cause any performance impact. All the real-time systems then simply reference the stored data and filter it as needed.<\/p>\n<p>In case you were wondering (because surely you were), this is what 300x300x300 lightyears looks like when trimmed to a sphere:<\/p>\n<p><a href=\"https:\/\/starshipsimulator.co.uk\/wp-content\/uploads\/2022\/08\/22.5.22.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/starshipsimulator.co.uk\/wp-content\/uploads\/2022\/08\/22.5.22-1024x622.png\" width=\"1024\" height=\"622\" alt=\"\" class=\"wp-image-610 aligncenter size-large\" srcset=\"https:\/\/starshipsimulator.co.uk\/wp-content\/uploads\/2022\/08\/22.5.22-980x596.png 980w, https:\/\/starshipsimulator.co.uk\/wp-content\/uploads\/2022\/08\/22.5.22-480x292.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/a><\/p>\n<p>The next step was harder though because the galaxy is now represented at a literal cm scale and we need to translate the location of the ship within a given cubic lightyear from centimetres to more reasonable galactic coordinates. As you can see here, the local coordinates are massive:<\/p>\n<p><a href=\"https:\/\/starshipsimulator.co.uk\/wp-content\/uploads\/2022\/08\/unknown-11.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/starshipsimulator.co.uk\/wp-content\/uploads\/2022\/08\/unknown-11.png\" width=\"721\" height=\"547\" alt=\"\" class=\"wp-image-612 aligncenter size-full\" srcset=\"https:\/\/starshipsimulator.co.uk\/wp-content\/uploads\/2022\/08\/unknown-11.png 721w, https:\/\/starshipsimulator.co.uk\/wp-content\/uploads\/2022\/08\/unknown-11-480x364.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 721px, 100vw\" \/><\/a><\/p>\n<p>With the power of math however I was eventually able to get my head around it, and I&#8217;m happy to say we now have a fully working system for traversing the entire 1:1 scale galaxy per centimetre. Don&#8217;t just take my word for it though, here&#8217;s a video of the ship moving at a very real 200,000,000 times the speed of light:<\/p>\n<p><iframe loading=\"lazy\" title=\"Moving at a very real 200,000,000 times the speed of light\" width=\"1080\" height=\"608\" src=\"https:\/\/www.youtube.com\/embed\/0IgMHQAbmAE?feature=oembed\"  allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<p>The flickering you see is where it&#8217;s taking the 27 stored sector data and discarding anything further away than 50ly to render the holo-display. It&#8217;s having to do that a couple of times per second, which is a mad amount of data processing, but the ship is never going to be moving anywhere near that quickly during normal gameplay, so it should be fine.<\/p>\n<p>As a stress test though I wondered if it could handle moving at 1 billion times the speed of light. The answer is yes, yes it can:<\/p>\n<p><iframe loading=\"lazy\" title=\"Moving at 1 billion times the speed of light\" width=\"1080\" height=\"608\" src=\"https:\/\/www.youtube.com\/embed\/qq8cmASNtzk?feature=oembed\"  allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<p>It&#8217;s a lot more glitchy and the galaxy gen couldn&#8217;t keep up with generating new data, but it handled it like a boss and didn&#8217;t crash so I&#8217;m counting it as a win<\/p>\n<p>During normal gameplay the ship will have a max speed of around 2,000,000C, so the speeds shown above are way, way faster than needed. What this does mean however is that we have a huge margin to play with in terms of ship upgrades etc. Even a tenfold increase in ship capability is still significantly slower than the speeds tested, so we can look forward to a wide array of alien bolt-ons and interesting new minerals to make getting around the galaxy a bit quicker <img decoding=\"async\" src=\"https:\/\/starshipsimulator.co.uk\/wp-content\/themes\/Divi\/includes\/builder\/frontend-builder\/assets\/vendors\/plugins\/emoticons\/img\/smiley-smile.gif\" alt=\"smile\" \/><\/p>\n<p><strong><\/strong>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;4.9.1&#8243; _module_preset=&#8221;default&#8221; background_color=&#8221;RGBA(0,0,0,0)&#8221; custom_margin=&#8221;0px|0px|0px|0px|true|true&#8221; custom_padding=&#8221;0px|0px|0px|0px|true|true&#8221; border_color_all=&#8221;#000000&#8243;][et_pb_row _builder_version=&#8221;4.9.1&#8243; _module_preset=&#8221;default&#8221; background_color=&#8221;RGBA(0,0,0,0)&#8221; width=&#8221;100%&#8221; custom_margin=&#8221;0px|0px|0px|0px|true|true&#8221; custom_padding=&#8221;0px|0px|0px|0px|true|true&#8221; border_color_all=&#8221;#FFFFFF&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.9.1&#8243; _module_preset=&#8221;default&#8221;][et_pb_text _builder_version=&#8221;4.9.1&#8243; _module_preset=&#8221;default&#8221; text_font=&#8221;||||||||&#8221; text_text_color=&#8221;#FFFFFF&#8221; text_font_size=&#8221;16px&#8221; text_letter_spacing=&#8221;1px&#8221; hover_enabled=&#8221;0&#8243; sticky_enabled=&#8221;0&#8243;]Having gotten the new player character working reasonably well on the UE5 build, I&#8217;ve gone back to getting the new 1:1 scale Galaxy System working smoothly as well. The first [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-408","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/starshipsimulator.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/starshipsimulator.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/starshipsimulator.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/starshipsimulator.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/starshipsimulator.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=408"}],"version-history":[{"count":14,"href":"https:\/\/starshipsimulator.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/408\/revisions"}],"predecessor-version":[{"id":981,"href":"https:\/\/starshipsimulator.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/408\/revisions\/981"}],"wp:attachment":[{"href":"https:\/\/starshipsimulator.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/starshipsimulator.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/starshipsimulator.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}