We’re excited to announce that Future Is Bright Phase 2, aka Technology.ShadowMap, is now enabled on desktop platforms (Windows and macOS using DX11, Metal, Vulkan) for all developers to use. Windows 10 Store and Xbox support coming next week. Huge thanks to the team who made this happen! It was a long road, but we have finally made it. Kudos to @zeuxcg, @Qiblox, @ConvexRumbler, @Homeomorph, @NeoBuilder101, @vrtblox you are fantastic!
What’s new?
We have added shadow map support to the lighting voxel engine! Now every single object in the scene can cast shadows. Currently, only the Sun and Moon can cast shadows; we can’t do shadows from the local lights (yet) due to some internal voxel lighting limitations, but we will do this for the Future Is Bright Phase 3.
How do I use it?
There are several new options available:
New lighting technology: ShadowMap
Shadow Softness property which allows you to specify how blurry the shadows are
And you can now control if a part casts shadows by using the new CastShadow property. This property also affects voxel shadows.
How does this work?
Shadow mapping is a common way to do shadows for games. Our task is for each pixel on the screen to determine if this pixel is visible from the light perspective or not; in other words, we have to solve the visibility problem. To solve this visibility problem, we can render the scene from the light’s point of view into an offscreen texture (shadow map). For each pixel of this texture, we will store distance from the light to the nearest shadow caster.
Then for each pixel on the screen, we can compare the current distance to the light source with the distance that we saved in shadow-map. If current pixel distance is greater than stored distance than this pixel are in shadow otherwise pixel is lit.
Of course, this description is oversimplified, and there are tons of different details, tricks, and optimizations to make it fast. But I hope you get the point, for the shadow-maps we should render the scene at least twice; the first time to generate shadow-map itself and the second time to render a scene.
That is why from a performance perspective it is crucial to render as few objects as possible. Here are some performance tips:
- We will never draw objects to the shadow map with CastShadow property disabled; this is an excellent way to save some performance. For example, if your game has lots of grass meshes, you probably want to disable shadow casting for them.
- We will try not to re-render static objects. If your object is not moving this will save some performance
- Unfortunately, when then sun direction changes we have to invalidate our cached shadow maps. The less frequently sun moves, the better for performance. Try to do not change the time of day frequently; you may want to consider moving sun in short bursts and waiting between these, like some games (Skyrim) do.
What’s next?
We’re already working hard on phase 2 for the mobile platforms iOS, and Vulkan powered Android devices. We’re working even harder on phase 2.5 which will introduce more realistic physically based specular highlights from the materials and image-based lighting.
We also hope to implement even more performance optimizations for lower end desktop systems to make shadows work better everywhere.
At this time we don’t plan to implement shadow map support for OpenGL or Direct3D 9 systems. If you use OpenGL in Studio intentionally, please switch to Automatic or Vulkan/Metal depending on the platform.
We’re super excited, and we are looking forward to seeing how your games will look like with this new awesome feature!
Known bugs
We have a couple of known issues that will be fixed soon; we’ll update this post when fixes go live:
- Decals on parts with CastShadows=False still cast shadows Fixed some time in May 2019
- On mobile, ShadowMap reverts to Legacy instead of Voxel Fixed on 5/15/2019