1. Rocket Science
  2. News

Rocket Science News

Dev Update: Solving Thermodynamics

Greetings, fellow rocket scientists!

One of the big features which I get asked about all the time is the re-entry effect. I've been putting this feature off for the future for a long time because I didn't know how to even get started with it. You need not only to add the whole thermodynamics simulation into the game while trying to maintain the game's performance, but also somehow solve a re-entry effect for the crafts of any shape and form. Not many other games have done this before and there is very little info out there on how to properly do it.

But now I think I have gathered enough expertise to accept this challenge. Because the whole new system not only should improve the depth of the game and bring a lot of new rocket parts, but it will solve one of the big problems it has. See, the game is capable of maintaining several physics simulations in the background. So if you launch a plane and then return to the space center, it will continue the flight (if it is stable enough). In the meantime you can launch another rocket or assemble a spacecraft and then return to your plane in an hour and continue the flight.

The drawback of this feature is that it will simulate any other craft in the background even if it is just a used decoupled stage that entered the atmosphere. But any background physics simulation locks timewarp to a maximum of 10x which can be annoying. But if we add the aerodynamic heating of atmosphere entry vehicles into the mix, almost all debris should quickly burn and there will be no problem with that.

So there were basically two parts of research I had to make: thermodynamics itself and the re-entry and part heat visuals. Let’s talk about thermodynamics first.

After reading different articles on the subject for several days straight and nearly going crazy from the amount of math that dropped into my head, I decided to stop and approach this task incrementally as I did with aerodynamics. It is much better to start with a simpler, predictable and understandable system and refine it, adding complexity over time, than just be buried under the formulas creep and don't produce anything meaningful.

So, what are the sources of heat gains and losses that most spacecrafts will experience? There are a lot of them, but I decided to start with these ones:
  • incoming solar radiance;
  • outgoing thermal radiation;
  • modules that produce thermal energy during the work (engines, command modules, instruments, charging batteries etc)
  • parts that dissipate heat over time, like radiators;
  • aerodynamic heating;
  • atmospheric cooling or heating due to convection.

Most of the formulas for heat flux above are not very complicated (except for aerodynamic heating). But they are non-linear either, so you can’t just write it as a function of time, you need to integrate it. It would not be a problem for physics simulation, since we have plenty of integration in it already. But spacecraft will constantly receive solar radiation and radiate heat even during the math simulation. So it needs to support time warps up to one month per second and give consistent results.

While you can find an analytical solution for thermal radiation integration, it is not so easy for incoming solar radiance. Because it is a function of time and distance from the Sun and distance can not be described as a simple function of time, because it will depend on the spacecraft's orbit. But I think I will find or invent some approximation for that.

As for aerodynamic heating it is much more complicated than everything I encountered before. There are dozens of papers published by NASA with complicated math I can barely wrap my head around. And even if I could understand all of this, it would be very computationally expensive to add into the game.

My brain immediately turns off when I see something like this

But I found an approximation that I could use to begin with.

Nice and simple formula, but...

The problem is that k is the precalculated constant for a specific atmosphere and I found values for it only for Earth and Mars. Also R is the bluntness of the rocket part. I understand what this means and why it is there but I didn’t find out yet how this value is calculated or at least in what ranges it lies. If you know any of this or at least could point me in the right direction please let me know in the comments below.

Enough of math for today. Let’s talk about the visual component of reentry heating. It is a combination of plasma and flames which should encompass the spacecraft when it enters the atmosphere at a high speed.



It would be easy to do if you know the shape of the rocket ahead of time. But in this game spacecraft could be of any shape. And not many games have rocket construction combined with the re-entry heating, so this problem has no commonly known solution.

There is a talk on Youtube “Unite 2013 - Building a new universe in Kerbal Space Program” where the original developers of the game talk about their solution of this problem. They basically take the rocket part mesh and render it multiple times with some offset and increasing opacity and scale.

It is interesting, that this shader is also used for fur rendering

The drawback of this solution is that you can notice bands of color along this effect. You can decrease these visual artifacts by increasing the number of render steps or by applying some dithering algorithm on top of that. But this solution is expensive and pretty limited in visual expression. I didn't find anything else on the topic, so I decided to try to implement re-entry effect by myself.

I took a simple quad sphere, copied it, scaled it a bit and started experimenting. After several days of tinkering with shader magic I ended up with something usable.

All screenshots will be from Unity Editor, since I didn’t incorporate this effect into the game yet

But how can we apply this effect on any rocket part? See, the great property of the quad sphere is that it has uniformly distributed vertices.

A simple quad sphere wireframe. In fact this is the basis also for planet generation

So we can apply vertex offsets to it from any direction. And we need this mesh property, because spacecraft can be in any orientation when entering the atmosphere. This means we can’t take rocket part mesh, scale it and just apply this shader. Because most of the parts have meshes with sparsely distributed vertices.

Here is an example of a Fuel Tank mesh, there are not a lot of vertices, especially at the bottom

Another example: this is a command module mesh, it is better suited for this effect, but vertices still non-unifromly distributed and effect will look bad in some cases

So we need a mesh that will follow the shape of the part but would have a uniform vertex distribution. Manually creating such a mesh just for re-entry effect for each existing rocket part in the game and for all future ones is not an option. I heard you can easily do it using Houdini, but I have no time to learn a new tool and also I can’t afford it. I am pretty sure you can do it in Blender, but the workflow would not be ideal. So is there any way to do it faster, preferably using only Unity Editor?

After some hard thinking I remembered my signed distance field terrain generation experiments from three years ago.

Every experiment is a great for gaining an experience and expertise even if it had no use in the beginning

Here is a terrain generated using a signed distance field or shortly SDF. SDF is a scalar field for each given point of which we can obtain a distance from some surface. If the distance is negative then this point lies inside this surface, if positive then outside. Then we can build a model from any SDF using a mesh extraction algorithm such as Marching Cubes. Mesh, generated in this way, has a property that we seek – a pretty uniform vertex distribution per unit of volume. On the screenshot above the SDF was generated by the noise function. But the great news is that we can turn any model into SDF first and then reconstruct it using the mentioned algorithm!

Unity has a built-in mesh to SDF generator. But has no tools for the other way around. So I’ve implemented the Marching Cubes algorithm specifically for my case. And tried to reconstruct the command module from above using it.



The result was closer to what I need, but as you can see, there are a lot of unnecessary vertices in some places which not only affect the quality of the effect, but would also be a bit taxing.

After some additional time spent on research I found and implemented another algorithm called Surface Nets. It generates less accurate representation of the surface, but produces less vertices and they are more uniform.



This was exactly what I needed. I plugged the resulting mesh into my earlier shader and got the following results.

There are a lot that can be improved here but I think it is a good starting point

Thanks to uniform mesh, the effect works from any side

So I’ve written a special tool for Unity, that can convert meshes with a single button press.



While the process is greatly automated now, it still requires a bunch of manual tweaking for each rocket part. I think this is as far as I can push automation forward. And I beleive I have a good foundation now on which thermodynamics effects will be built upon. But there are still a lot of work with the shader. I need to account parts occlusion, rocket bounds, add flutter and pulse, also make it more dynamic and varied.

Here is a quick proof of concept, that it will work for assembled rocket

This dev update is already huge and I told only 20% of all things I needed to research and experiment with while working on thermodynamics for the game. I will probably continue this story another time (or better record a video about it at some point). But I need to get back to v0.22.0 development which has a big scope and not a lot of time to work with.

Thank you for reading this post and have a nice flight!

Patch v0.21.9

I got a lot of bug reports thanks to our amazing Discord community and some of the videos that were published on youtube last week. I fixed all the critical bugs with reproducible scenarios. And a bunch of less important ones that didn’t require big changes to the game.

This patch includes some features and a lot of changes too. I’ve added a third rocket assembly tutorial to the game that shows how to use some tools that weren't touched in the previous ones. And I changed the orbit parameters panel. In the collapsed state it shows the most important parameters for any flight: orbit apoapsis and periapsis and time to these nodes. If your spacecraft’s trajectory ends up on the planet’s surface it shows time to impact instead of time to periapsis.

Using this panel you can now put a spacecraft on orbit without opening the map even once

If you click the expand button, then you will get all the other orbit parameters.

This panel is gigantic in the expanded state, but what can you do

There is still one major bug that I am trying to hunt down where the rocket sometimes becomes corrupted during rocket assembly and can’t be loaded. But you still can find the rocket file in the save folders. If it happens to you, please contact me via email or Discord and send me this rocket file with the description of what happened. I will be able to fix your rocket and also it could help find the issue.

This is the last big patch to v0.21 version. I can push some smaller hotfixes here and there but I will mainly focus on the next game update now. All other non-critical bug reports I received will be included in that one.

Stay tuned and have a nice flight!

[h2]v0.21.9 release notes[/h2]

[h3]Features:[/h3]
🔸 added time to apoapsis/periapsis/impact to the orbit stats panel;
🔸 added third rocket assembly tutorial;
🔸 navball mod now supports black colors for numbers and have a separate intensities for each channel.

[h3]Changes:[/h3]
🔸 added expand/collapse button to orbit panel which will toggle visibility of additional orbit parameters;
🔸 reduced assembly colliders of "Raduga-52" and "Vega-072" engines so they can be attached to big fuel tanks in more different ways;
🔸 engines are now grouped by fuel pair first and then by thrust on the parts panel.
🔸 added fuel name and image to rcs tooltip;
🔸 increased camera exposure compensation range that could be set during the flight and on the map;
🔸 improved memory allocations on assembly shop scene;
🔸 improved "Citrine" external RCS plume effect;
🔸 reduced mass for "Clap" Longitudinal Decoupler;
🔸 added hydrazine fuel variant to "The little one" Fuel Tank FT-0;
🔸 removed fog from assembly blueprint scene;
🔸 automatic time warp is no longer interrupted by physics simulation, it is just capped at 10x speed;
🔸 part name properly updates when changing its config using select tool;
🔸 increased resolution of navball texture and tweaked colors a bit.

[h3]Fixes:[/h3]
🔸 big memory leak on spacecraft mode scene;
🔸 switching pass resources mode in the attached parts using “Select” tool, doesn’t work (mode switches, but part continue to work in the previous mode);
🔸 not being able to open context menu and raycast highly eccentric orbits;
🔸 equatorial inclination doesn't account for orbit's longitude of ascending node and can produce incorrect results;
🔸 part rotation is lost when detaching part and then using undo;
🔸 sometimes assembly stuck when constantly switching from grab to select mode and back and clicking on different parts;
🔸 1.2m radius parts could not be attached to the bottom of rover_fairing_0;
🔸 command module porthole shows Earth's water through the part;
🔸 some props are missing in the control center;
🔸 engine thrust effects and sounds start playing when turning on engines end time is paused;
🔸 center of lift and center of drag forces overlays are swapped between each other;
🔸 ALT+click on rocket part doesn't focus camera, when "Select" or "Rotate" mode was selected;
🔸 game loads in initial 10x time warp and then switches back to 1x;
🔸 sometimes game stuck when quitting to desktop or main menu;
🔸 sometimes game stuck after using Select tool and selecting one of the parts;
🔸 buttons are vertically stretched on instruments panel on surface and navball mods;
🔸 stages are cut off by the bottom of the screen in the ultra-wide resolution;
🔸 game stuck when several parts was selected using symmetry and then they were removed by pressing undo;
🔸 part params window is clipping through celestial bodies filter when solar system map is open.

Patch v0.21.4

I usually make only fixes and do not add any new features in patches in between updates, however since many new players are joining and trying out the game I decided to process feedback faster and implement features that do not require big changes to the game as soon as possible.

One of those features was the request to decouple some side boosters without needing additional decouplers to match the behavior “Proton” or “Souz” rockets have. And now you can easily do that.

Just select new decouple mode in the part configuration

And enjoy the new behaviour. No additional decouplers required!

Other than that, I updated some outdated information in tutorials. And made several fixes that will make the game more stable.

[h2]v0.21.4 release notes[/h2]

[h3]Features:[/h3]
🔸 added additional configuration to side boosters Side Fuel Block and Conic Fuel Block so they can be decoupled from rocket without using a dedicated decoupler;
🔸 added one more time warp step in between 1 day and 1 month, equal to 1 week;
🔸 added toggle to orbit stats panel that switches orbit inclination display mode from the ecliptic to equatorial plane and vice versa;


[h3]Changes:[/h3]
🔸 re-enable thrust limiter slider for all engines in the engine parameters window during the flight.
🔸 all "Reach orbit" contracts now have correct inclination set relative equatorial plane (previously was incorrectly set to ecliptic plane);
🔸 Molniya and Tundra contracts now have correct periapsis and orbital periods;

[h3]Fixes:[/h3]
🔸 Molniya and Tundra contracts can't be completed;
🔸 game stuck after completing any "Reach orbit" contract and trying to exit to main menu or quit the game;
🔸 crash when changing from select mode to grab mode removing previously selected part and switching back to select mode;
🔸 sometimes there is no missing fuel warning displayed when attaching some engines to the fuel tank that have no required fuel for them;
🔸 mods list window have no background;
🔸 navball is black in the navball mod scene;
🔸 some translation strings are missing;
🔸 some tutorial steps have outdated information;
🔸 fixed missing caption in one of the advanced tutorials

[h3]Known issues::[/h3]
🔸 switching pass resources mode in the attached parts using “Select” tool, doesn’t work (mode switches, but part continue to work in the previous mode);
🔸 geostationary orbit contract references ecliptic plane instead of equatorial one;

Update v0.21.0 "Essentials" is now LIVE!

Hi, there! Three months have passed in a blink of an eye and it is time to publish the next update. This is a medium-sized update but it has a lot of changes under the hood. Because most of the changes were localized and there were no engine version updates, I decided to release this update without the beta cycle. We will see how it goes, but without further ado let’s dive into it.

[h2]Support for different fuel types[/h2]

As I mentioned in the previous update, all the engines in the game are based on real world counterparts. And the last two engines I’ve added have a much higher ISP, but should consume a hydrogen / oxygen fuel pair instead of UDMH / dinitrogen tetroxide all the other engines use. But while the game was designed around different fuel pairs, some game systems were still not fully reworked to support that. For this update I’ve added a hydrogen / oxygen fuel pair and support for every single one of them. For example, stage dV calculation, fuel level indicators, maneuver dV calculations and even fuel transfer in docking ports are working not only for the H2 / O2 pair but for any other one I will add in the future.

All engines and fuel tanks tooltips have color coded fuel indicators now

This change would greatly affect the rocket design. See, liquid hydrogen has a very small density and mass. At the same time engines that use it have much higher ISP which means they are more efficient. So the upper stages of a typical rocket will be much lighter, but carry less fuel for the same volume. Because of that you will probably build smaller lower stages or could make the upper ones bigger depending on your need. I'm looking forward to seeing screenshots of your new designs.

Stages now grouped by fuel consumption, have fuel indicators too and change color to red, when the stage doesn't have fuel that engine use

It is also interesting that the USSR designed and built only three different engine models that used hydrogen as a fuel. So I’ve added the missing one. But it looks like another popular fuel pair is just around the corner.

Meet 1-socket "DVK-1" Liquid Fuel Engine

[h2]Assembly improvements[/h2]

You can finally change configuration for already attached parts. All you need to do is to switch to “Select mode” on the instruments panel and then click on the part you want to change. Symmetry is working too. Note, that at this moment, only existing configurations are supported. For example, you can change fuel type, decoupler resources pass mode or control surface parameters for the attached part. I will add full configuration support for all the parts in the next update, because it will be easier to change by combining it with the redesign of the rocket part flight windows.

Just switch to the Select mode and click on part you want to change

I’ve also added support for 8-way radial symmetry. It is a bit awkward because it can produce buggy looking results when trying to attach 8 fuel tanks that have the same size as a central one. But this is not the only use case for that and it opens more design space, so why not.



Below some new parts structure parts, made with 8-way symmetry in mind.

Octagonal Prism O-100

Octagonal Prism O-200

Structural Adapter Octahedron-Hexagon

I’ve also made a full rebalance pass on all fuel tanks in the game. I have developed several formulas and carefully recalculated all part parameters, including mass, surface area and volume, making it much more consistent. Thanks to this change, most of the tanks, especially medium sized ones, can hold more fuel now. I also found a bug in the calculations that made all cubic-shaped tanks hold two times less fuel than they should do. And now it is fixed too.

[h2]Flight changes[/h2]

Another one most requested feature is to warp to a point on the orbit. And now you can finally do it!

I can't even imagine how I lived without this feature before

I’ve also added a button to the maneuver panel, so you can warp 10 seconds before the start of engine burn. Not only that, but there are a set of indicators with sounds that will help to make your maneuvers much more precise.

Making maneuvers become very enjoyable process

I’ve also added two more indicators to the time panel. One will light up every time the game is in physics simulation. Another one – when automatic time warp was initiated. I hope this will answer a common question, why time warp sometimes is not working as expected.

The third indicator is reserved, I haven't figured out what it can be used for yet

[h2]More UI redesign[/h2]

Assembly shop and main menu UI was visually redesigned to approach the quality standard set by the flight UI. There are plenty of old interfaces left in the game, but I will deal with them sooner or later.

Parts, rockets, spacecrafts and assembly lists were greatly improved

As well as some smaller UI elements

[h2]Textures improvement[/h2]

Solar map textures of all gas giants were improved. I’ve also added solar map materials to 4 biggest Jupiter satellites.

If a planet still has no surface materials, it will load solar map texture now. I think it is better that just a white sphere, despite it has very limited resolution

As always, there is much more that this update brings. You can find full patch notes below. Thanks for playing and stay safe!

⚠️Important!
Your old save file is compatible, but it is highly recommended to rebuild all your rockets, because old ones will not recive updated paramters or simply could not work properly.

[h2]v0.21.0 release notes[/h2]

[h3]Features:[/h3]
🔸 added H2 and O2 fuel pair;
🔸 added Select mode for Assembly and ability to change rocket part configigration for already attached parts;
🔸 full rebalance pass on all fuel tanks parameters;
🔸 added 8-way symmetry and part variants, that support it;
🔸 added warp to maneuver button and start burn indicators to maneuver panel;
🔸 all planets, that still have no surface, now use textures from the scaled space model, instead of just a white sphere;
🔸 added Callisto, Ganymede, Io and Europa solar map textures;
🔸 improved all gas giants solar map textures;
🔸 [Space context menu] added warp to point option;
🔸 added two indicators to the time panel, that will show if the game is running physics simulation or if auto time warp is used;
🔸 added more sfx to the game;
🔸 redesign of some old interfaces;
🔸 added irregular moon celestial body type and corresponding map filter;

[h3]New rocket parts:[/h3]
🔸 "DVK-1" Liquid Fuel Engine
🔸 Octagonal Prism O-100
🔸 Octagonal Prism O-200
🔸 Structural Adapter Octahedron-Hexagon
🔸 "Mini-Prizm" Fuel Adapter
🔸 "Mini-Cone" Fuel Adapter

[h3]Part changes:[/h3]
🔸 engine 6 and engine 7 now uses H2+O2 fuel pair;
🔸 corrected engine_skycrane hydrazine consumption;
🔸 adjusted visuals and slot positions for decoupler_radial_1

[h3]Changes:[/h3]
🔸 significantly improved fuel tanks attachment stability, when trying to connect it to the radial decoupler;
🔸 advanced assembly tutorial received additional tutorial steps, clarifying some assembly mechanics;
🔸 advanced assembly tutorial was split into two parts, to reduce its size;
🔸 stage groups with engines now have fuel type indicators;
🔸 collapsed stage groups are now grouped by fuel type;
🔸 stage fuel navball indicator now works with any fuel that engines consume;
🔸 stage fuel navball indicator now calculate amount and % for entire fuel pair instead of only fuel alone;
🔸 added indication that engines have no required fuel in the stage to stage group;
🔸 base time warp in the spaceport is 1 now (previously was x10);
🔸 time warp acceleration / deceleration is frame rate independent now;
🔸 game will unpause if you click pause button a second time;
🔸 changing time warp using hotkeys will also unpause the game if it was paused;
🔸 orbit raycast no longer processed if orbit point is behind the celestial body;
🔸 small improvements to scaled space atmosphere computation, that will improve its quality;
🔸 added window for parts, that contain kerosene;
🔸 improved UI for widescreen displays;

[h3]Fixes:[/h3]
🔸 symmetry not working when trying to detach / reattach fuel tank from decoupler;
🔸 sometimes you can notice a strait line on a planet surface;
🔸 sometimes there is a wrong ambient light color when flying over the planet;
🔸 dV is not calculated for hydrazine engine on stages;
🔸 dV is incorrectly calculated when stage contains more fuel or oxidizer than required by engine's consumption ratio ;
🔸 sometimes maneuver placed using orbit context menu, appeared in the wrong place or not appear at all;
🔸 orbit raycast distance is resolution-dependent;
🔸 orbit with section sometimes looks broken;
🔸 orbit raycast doesn't work on high eccentric orbits with no sections;
🔸 orbit with encounter doesn’t reset it's shape after switching to spacecraft with this orbit and to another one;
🔸 wrong door connection between coal generator and elevator;
🔸 sun flares are visible through solid geometry, when the sun is near the edge of the screen;
🔸 fuel transfer in docking port window doesn't work;
🔸 placeable actions subpanel remains visible, when exiting to rocket list and assembly was in Select or Rotate mode;

Patch v0.20.8

Here is a small patch with a bunch of fixed bugs that was mostly found by the community. Also this patch brings a pretty big change in rotation steps of big hexagon-like sockets that can be found mostly on fuel tanks. Initially those sockets supported only 60 degrees turns to follow the hexagon sockets restrictions. After receiving some feedback and thinking about it for a while I decided to remove this restriction and allow rotation on those sockets with a 10 degrees step. Despite being not very “socket accurate” It should not break anything and will greatly increase customizability of all rockets. I hope you will enjoy this change.

[h2]v0.20.8 release notes[/h2]

[h3]Part changes:[/h3]
🔸 rotation step for hexagon, heptahedron, star and heptahedron range sockets increased from 6 to 36 steps;

[h3]Changes:[/h3]
🔸 updated to latest Unity patch version, increasing the game stability;
🔸 removed CRC check on asset bundles, that can randomly prevent the game from starting up;
🔸 removed some shader duplication wich should improve performance;
🔸 update game input module to a version that fully supports current Unity Engine.

[h3]Fixes:[/h3]
🔸 spacecraft item lose status line when spacecraft name is too long;
🔸 newely created rocket could failed to save, if rocket with the same id did not load properly;
🔸 game crashes on quit from flight or spaceport;
🔸 black squares appears on windows in the assembly shop;
🔸 orbit stats panel breaks when changing SOI from Earth to Moon;
🔸 flipped socket for nano reaction wheel;
🔸 visible tiling on skycrane material;
🔸 crash on skycrane detach when spacecraft is on the ground;
🔸 crash when adjusting manever using mouse wheel, when editing values in input fields at the same time.