The changes that we are introducing with the 1.40 update for both American Truck Simulator and Euro Truck Simulator 2 have been visible to the public for some time now, in the currently still ongoing Open Beta builds. By far the most visible change is the new lighting system, which has turned out to be the largest graphical rework for us in years. In today's blog post we would like to reveal more about what we have been through to make this change happen; let's take a look under the hood once again. [img]https://clan.cloudflare.steamstatic.com/images//4419325/81005b6c9b5196807463f465450ae55d91327c9b.jpg[/img] [previewyoutube=glv8ONotnKM;full][/previewyoutube] [h3][b]Let there be light![/b][/h3] Our 3D engine's approach to representing light and color in scenes - and in the rendering [url=https://en.wikipedia.org/wiki/Framebuffer]buffers[/url] that end up being displayed on-screen - has been established over a decade ago. It was an era when the state of the art was to represent all [url=https://en.wikipedia.org/wiki/RGB_color_model]RGB[/url] values in the 0-255 numerical range, to fit inside a [url=https://en.wikipedia.org/wiki/Byte]byte[/url] of information. That's how all values were defined, whether in a [url=https://en.wikipedia.org/wiki/Texel_(graphics)]texel[/url] of a [url=https://en.wikipedia.org/wiki/Texture_mapping]texture map[/url] (the "skin" of a 3D object, a tree, vehicle, or skybox), or in the encoding of a light source's intensity (from a vehicle's tail lights to street lamps, all the way to the sun intensity), and combining all these in the rendering stage into a [url=https://en.wikipedia.org/wiki/Pixel]pixel[/url]; it was again the representation in the display buffer to be shown on the screen, with only 256 shades of each base color. In recent years, the explosion of available memory in 3D accelerators, the progress in computational power, and flexibility in [url=https://en.wikipedia.org/wiki/Shading_language]shading languages[/url] for programming 3D cards' operations on [url=https://en.wikipedia.org/wiki/Fragment_(computer_graphics)]fragments[/url] have opened the way to store and compute color and light values at much higher precision and range - with [url=https://en.wikipedia.org/wiki/Floating-point_arithmetic]floating-point[/url] numbers. Instead of just layering color filter operations, which was, essentially, all the tricks that we had available in the 8-bits per color component era, the switch to using real numbers is quite a revolution in how a game engine can truly represent light sources in realistic ranges and ratios. In the real world, the difference between a light bulb's intensity and the sunlight is many orders of magnitude. If we are able to store the intensity values of light sources properly, and more importantly to perform all the light vs. surface operations at their proper ranges of values, without a major loss of precision, we can do true [url=https://en.wikipedia.org/wiki/High_dynamic_range]high dynamic range[/url] (HDR) light in the graphics pipeline. When we started experimenting with the new technique some 18 months ago and saw the first results, there was no way back for us, we knew we wanted this in the engine.  [table][tr][td][url=https://clan.cloudflare.steamstatic.com/images//4419325/76833fd48454a05c2b3d27d8f09007bbb42315ad.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/76833fd48454a05c2b3d27d8f09007bbb42315ad.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/ae488db8657084e423b54c6874e5a4c9f4e6e42d.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/ae488db8657084e423b54c6874e5a4c9f4e6e42d.jpg[/img][/url][/td][/tr][/table][table][tr] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/3d76283e17525c43a39eb199e0e00c666d3422f1.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/3d76283e17525c43a39eb199e0e00c666d3422f1.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/b74a22426d42fedc2a7ae4463c13f6a7666743d0.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/b74a22426d42fedc2a7ae4463c13f6a7666743d0.jpg[/img][/url][/td][/tr][/table] [h3][b]What's new?[/b][/h3] We had to start with the light sources (and for a while, we were hopeful that this will suffice). Each and every light source is now defined with a realistic value gleaned from real-world measurements (we have done a ton of sampling with a [url=https://en.wikipedia.org/wiki/Light_meter]light meter[/url] over various daylight and weather settings) and reference tables. In reality as well as in the game world now, tens of thousands of [url=https://en.wikipedia.org/wiki/Lux]lux[/url] units now brighten day scenes, while at night the ambient brightness approaches just a few lux units. Basing all light source values on reality gives us way more confidence as opposed to the old days when a new light would just fit into the system. It's no longer a question of should it be a 150 or 170 with no actual meaning to the values. Now we know and have tables to pick for a street lamp or a neon light at a gas station. In light computation formulas, we can now go with proper quadratic drop [url=https://en.wikipedia.org/wiki/Attenuation]attenuation[/url], to have lights behave in a physically-correct manner. With the higher precision, we can even go as far as introducing a small random variation in light intensity to otherwise identical light sources, to simulate a street's night feeling better, without having unnaturally-identical lamps. [table][tr][td][url=https://clan.cloudflare.steamstatic.com/images//4419325/1c328cc5c5bf2fe6d60c39ed6d5663ce92759f07.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/1c328cc5c5bf2fe6d60c39ed6d5663ce92759f07.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/4663dd8c0d94c87082be9e5afb663777b6c73310.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/4663dd8c0d94c87082be9e5afb663777b6c73310.jpg[/img][/url][/td][/tr][/table][table][tr] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/437c343f59e2136a56740597051ff2ed7e8cd7fe.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/437c343f59e2136a56740597051ff2ed7e8cd7fe.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/3d64239a316f52d4be7dfc5c8d31a550dbe63871.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/3d64239a316f52d4be7dfc5c8d31a550dbe63871.jpg[/img][/url][/td][/tr][/table][table][tr] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/68947e866608e84f60d84a296ce45ba0156f6014.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/68947e866608e84f60d84a296ce45ba0156f6014.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/1e53c30e06128729ecc44e9d10566f09df4e5a7b.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/1e53c30e06128729ecc44e9d10566f09df4e5a7b.jpg[/img][/url][/td][/tr][/table][table][tr] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/058d1fcbef8f8fc99fc7d41e43800e01ab8b75d6.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/058d1fcbef8f8fc99fc7d41e43800e01ab8b75d6.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/b792aa0351a1650402760c7369c63254ef142b82.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/b792aa0351a1650402760c7369c63254ef142b82.jpg[/img][/url][/td][/tr][/table] When all the internal light computations are done, we have to adjust the resulting values for the screen by emulating camera [url=https://en.wikipedia.org/wiki/Exposure_(photography)]exposure[/url]. Much like a modern camera in your mobile phone, we need to take all the rich values and variety of incoming light - sun or shade, early morning, high noon, dusk, or deep night - and "squish" or "expand" the values into the range appropriate for the screen. Our exposure emulation system has a critical impact on the final look and feel of the game - it's partly physics, but also partly about a subjective artistic feeling too. It has to be adjusted dynamically not just based on incoming light from the game world, but it also has to take into account the difference between the light inside and outside of a vehicle's cabin, to allow dashboard instruments to be legible. The human eye is an incredible creation, able to adjust and adapt to a vast range of light intensities as focus switches between objects. We had to use a lot of smart math when analyzing the light [url=https://en.wikipedia.org/wiki/Histogram]histogram[/url] for each frame and between frames to fit all these values into the screen's inevitably limited dynamic range and [url=https://en.wikipedia.org/wiki/Gamut]color gamut[/url], in order to make everything that's portrayed both believable and discernible. Some improvements were a cherry on top, like the fact that with the internal range of floating-point buffers of [url=https://en.wikipedia.org/wiki/Cube_mapping]cube maps[/url], we can have much shinier reflections off of glossy surfaces, such as water bodies, glass, or car paint. We have followed this development path in a small team happily until the realization that while the intermedia results were promising, we won't be able to pull this off without re-balancing ALL the existing materials/textures on all game objects. When a ray of light is cast on the surface of any object, what is reflected or refracted depends not just on the properties of the incoming light, but largely on the properties of the object's surface. Over the many years of development, we have accumulated tens of thousands of textures, some from photographic sources at various settings, some painted by hand, some through the process of [url=https://en.wikipedia.org/wiki/Procedural_generation]procedural generation[/url] in various smart tools. As the years went by, the authoring of these sources has been subject to various schools of thought, or different creation pipelines, but the "old light" system was held together by the proverbial duct tape and was in any case imprecise enough to reveal certain imbalances that were present. The new exposure emulation system is way more sensitive and simply requires physically correct brightness [url=https://en.wikipedia.org/wiki/Albedo]albedo[/url] values. Our concrete surface can no longer be [i]some[/i] sort of grey, and a tree cannot just be [i]nice and green[/i]. And that was when a vast majority of our art team had to be involved for a major overhaul. [table][tr][td][url=https://clan.cloudflare.steamstatic.com/images//4419325/c8e0ec2281322946a5f2d71ced6e37779f2c7ba5.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/c8e0ec2281322946a5f2d71ced6e37779f2c7ba5.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/dd4c81bbf964e564aa812886b8350c176b9bed3d.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/dd4c81bbf964e564aa812886b8350c176b9bed3d.jpg[/img][/url][/td][/tr][/table][table][tr] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/31a3d0ea766b47dd6b391181184fd9d1a3da5886.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/31a3d0ea766b47dd6b391181184fd9d1a3da5886.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/059f68770d6bdec0c35117234b715d0bcb588d5c.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/059f68770d6bdec0c35117234b715d0bcb588d5c.jpg[/img][/url][/td][/tr][/table][table][tr] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/a5d771e426ddbf760c6c41677acd9c8c2f04a78a.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/a5d771e426ddbf760c6c41677acd9c8c2f04a78a.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/a1fc4d074d3f35887ba518eaa47112a8c6bfc08a.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/a1fc4d074d3f35887ba518eaa47112a8c6bfc08a.jpg[/img][/url][/td][/tr][/table][table][tr] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/7ebf5ffae4810fbed1832f77697d6830950962a5.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/7ebf5ffae4810fbed1832f77697d6830950962a5.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/aace537aadd05b4c2a934e018895b2950b38df79.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/aace537aadd05b4c2a934e018895b2950b38df79.jpg[/img][/url][/td][/tr][/table] [h3][b]What had to be changed?[/b][/h3] Once our small pioneering cross-discipline team implemented all of the necessary code and GPU [url=https://en.wikipedia.org/wiki/Shader]shader[/url] changes, which took many months of experimentation, we had to involve a lot more people. First, we had to readjust all the light sources in the world and any vehicle lights to the new logic. In some cases, it was a relatively trivial numeric conversion somewhere in a table. In others, it may have required a map designer to revisit a particular location to make the manual adjustment. In many cases, it meant that a game object like a whole factory or delivery yard with pre-defined light sources had to be re-opened, adjusted, and re-exported again in a 3D tool like Maya. We are talking thousands and thousands of such retouches, in some cases involving not just a few dozen "numbers" defining lights, but also major changes to [url=https://en.wikipedia.org/wiki/Lightmap]lightmaps[/url] of the objects, where fake shadows and light effects were "baked in" for a better look in the old light system. Finally, for some weeks, the majority of all our teams had to stop working on anything else related to our future projects, and go over all the game objects, vegetation, vehicles, and effects; re-balancing things, again and again, to sync them on a shared agreed-upon albedo reference table. We had to revisit the fundamentals of many sub-systems, very notably the vehicle lights and bulbs taking many iterations and fine-tuning to make them look good at various daylight settings. We have a new set of skyboxes at a higher resolution, and a slightly richer variety of weather, too. Ultimately, no stone was left unturned, as we had to evaluate and adjust every single element of the games. [table][tr][td][url=https://clan.cloudflare.steamstatic.com/images//4419325/7172b84035ba21ffe8359f48f824e967bd4e9678.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/7172b84035ba21ffe8359f48f824e967bd4e9678.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/fba1de0f3a97ab6b62da2e4a63aba3d3d5b27c52.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/fba1de0f3a97ab6b62da2e4a63aba3d3d5b27c52.jpg[/img][/url][/td][/tr][/table][table][tr] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/840b201dea51d5013c616fcd2dbbe318f30f1479.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/840b201dea51d5013c616fcd2dbbe318f30f1479.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/d6265e801abb7d40e2500077ba5805167af67c78.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/d6265e801abb7d40e2500077ba5805167af67c78.jpg[/img][/url][/td][/tr][/table] [h3][b]What does this all mean?[/b][/h3] The new light system and the start of our new physical light model is a critical step towards a complete and better physical model of the whole world in our games. We are not quite there yet with true [url=https://en.wikipedia.org/wiki/Physically_based_rendering]physically based rendering[/url], but the 1.40 update represents a major step in the right direction. Cleaning up the old art and basing all light intensities and operations on fundamental physics make future systemic work in this area finally possible. As with many things in long-term development, while this step is a minor revolution, it is at the same time only a milestone towards a bigger vision.  [table][tr][td][url=https://clan.cloudflare.steamstatic.com/images//4419325/65b98b2b6567d916d9f3b312cb9e7d33c1e415b2.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/65b98b2b6567d916d9f3b312cb9e7d33c1e415b2.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/9ab7b10c26680f88ed4846fcede878d2526782aa.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/9ab7b10c26680f88ed4846fcede878d2526782aa.jpg[/img][/url][/td][/tr][/table] From the graphics artists' point of view (but this applies to mod authors, too!), we are introducing a new concept of creating and keeping all game art "in check" and in balance with the rest of the art. Materials based on photos, frequently used as sources of in-game art, now have to go through a calibration process before they are applicable, otherwise one may end up with a surface that is either too dark or too bright, affecting the exposure and the perception of the general scene. Often, it's worth exploring alternate material creation methods, like the high-resolution procedural generation in tools like Substance Designer. More trust is placed into the engine's rendering system now; rather than faking and baking subtle shadows and light effects into models. Between new light and SSAO, our shader code now plays a greater part in creating the final look; this results in a bit less responsibility, control, and possibly work from the artist. This may be both good and bad depending on what one is trying to achieve in each particular case. [table][tr][td][url=https://clan.cloudflare.steamstatic.com/images//4419325/7dfbe433c18991f601dacbf70ff44b435de117f5.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/7dfbe433c18991f601dacbf70ff44b435de117f5.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/7cb44e677d964c5789819cefdef1f9a6cc13b6c2.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/7cb44e677d964c5789819cefdef1f9a6cc13b6c2.jpg[/img][/url][/td][/tr][/table] As with each major change, there were a ton of teething problems, a lot of dead-ends to reverse from, and the amount of effort we have been through far exceeded the expectations we had a year ago. We still have a bit of Open Beta ahead of us to iron out the last few wrinkles. But even now, we are very confident that the changes are worth all the hard work. Just wait until you drive your truck in the early morning hours along with the coast of Italy, or on a nice late afternoon in Sweden, in a drizzle in Washington state, during scorching noon in Spain, or pulling into a well-lit truck stop deep into the night. Through all the process of changes, we tried our best not to cause any major increase in the load on the CPU or GPU. A few of the new effects have a slightly higher performance cost, but overall we believe the changes are very well balanced, or allow for sensible trade-offs in game options, to keep the performance acceptable. We definitely do not want to lose players and fans that play our games without the newest hardware by pushing too hard on graphical effects. We are looking forward to bringing you further improvements and new features, so hold on to your steering wheels! More of a fan of changelogs? Let's look at: [b]The major internal changes[/b] [list] [*] The scene is lit using real-life intensities (illumination: tens of thousands of lux for the daytime, tens of lux at night) [*] To get light ratios into play - the rising sun overpowering street lamp lights and truck headlights, etc. This means we had to adjust all light sources and also readjust every emissive material in the game. [*] We have a new display mapping function for better artistic control (exposure, contrast, toe, shoulder) [*] We needed to get those real-life intensities onto the computer screen in a similar way as a camera's exposure works. [*] Improved and more sensitive histogram for exposure selection [*] This is due to the actual exposure being selected differently in every scene, and this varies also with differing light levels and the current weather type. [*] Light source (street lamps, vehicle lights) changes. [*] We have switched light sources to a more physical attenuation ('inverse square falloff'). [*] We are in the process of switching to a physical-unit-based configuration to reduce guesswork. [b]But also many smaller visual tweaks [/b] [*] Relightable reflection [*] Reflections in shop windows and smooth surfaces better matches the time of day and weather [*] Improved reflection behavior [*] On truck paint, shop windows, and glass in general [*] Sun horizon shadow [*] Visible when the sun rises or sets [*] And a zillion other small tweaks, fixes, and changes. [/list] As you can imagine by now - all this has been a tremendous amount of work for our team. The initial bright spark (pun intended) that made this all possible came from a small team of programmers and a visual effects artist (pictured below). They have kept hacking, iterating, and laying out plans until the whole team had it "[i]easy[/i]", and all that was left to do was just to throw in many years of additional man-hours to adjust everything to the new logic.  [table][tr][td][url=https://clan.cloudflare.steamstatic.com/images//4419325/fce158b569f6841c8557632dce802a404ac8310c.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/fce158b569f6841c8557632dce802a404ac8310c.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/e9cd4fd41619009c0d9f59a40a977c37b23ecf5d.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/e9cd4fd41619009c0d9f59a40a977c37b23ecf5d.jpg[/img][/url][/td][/tr][/table][table][tr] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/f3ae732a7c809c0db5b20ea5381dbfa4d47f8948.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/f3ae732a7c809c0db5b20ea5381dbfa4d47f8948.jpg[/img][/url][/td][/tr][/table] The new light system, just as the implementation of FMOD support for the SFX part of our games, is still under further development, polishing, and tuning. And there is still a lot of work ahead of us. At this juncture, we feel that it's already more or less in a presentable shape, and you may experience it too if you decide to give it a try in an open beta build right now on Steam. [table][tr][td][url=https://clan.cloudflare.steamstatic.com/images//4419325/d73e366d630246284ebacc515d2d5331c930b3fc.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/d73e366d630246284ebacc515d2d5331c930b3fc.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/c0b136b285bb933c4703e4f7611ee69a60ad483a.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/c0b136b285bb933c4703e4f7611ee69a60ad483a.jpg[/img][/url][/td][/tr][/table][table][tr] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/c20c12dba61a20da4b34ced9a5e36bc6fd74f152.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/c20c12dba61a20da4b34ced9a5e36bc6fd74f152.jpg[/img][/url][/td] [td][url=https://clan.cloudflare.steamstatic.com/images//4419325/ea8daad2f8f8229e0bc150ba54f44c1be3036b91.jpg][img]https://clan.cloudflare.steamstatic.com/images//4419325/ea8daad2f8f8229e0bc150ba54f44c1be3036b91.jpg[/img][/url][/td][/tr][/table] So please, if you'd like to help us - put on your favorite sunglasses and help us catch the perfect sunrise! We're looking forward to reading your thoughts and opinions on the new light system. Thank you very much!