Repository
The above picture is included in the tutorial only for demonstration purposes only. It shows the kind of planet look that can be achieved with procedural texture generation. However, the tutorial does not cover how to do the atmospheric scattering effect found in this picture.
Details
This post arose out of two things: first, I wanted to infuse the Godot documentation with more procedural generation content, and second, I wanted to showcase how to use Viewports in 3D in Godot. Viewports are something that a lot of users have trouble with, even experienced users express confusion over what Viewports should be used for. This post walks the user through the process of setting up a Viewport and using it as a render texture. At the end of the tutorial the user is able to use render a planet from a 2D texture including setting the roughness of the ocean to make it more water-like. I hope that new users will be able to use this tutorial to jumpstart making procedural solar systems of their own!
Components
The tutorial covers the following topics:
- How to use a Viewport as a render texture
- Mapping a texture to a sphere with equirectangular mapping
- Fragment shader techniques for procedural planets
- Setting a Roughness map from a Viewport Texture
In a game engine, a Viewport is a surface that objects are rendered to. By default your scene contains a Viewport that is built into the scene itself. Godot also provides an interface to create your own Viewports to render to. In other engines these would be called offscreen buffers, or render targets. While using a Viewport is actually quite easy, many users express frustration over the process. This tutorial aims to make it a little easier to understand.
One area that the tutorial covers that is relatively unique is how equirectangular projection works and how to set your texture up so that the equirectangular projection works out of the box in Godot. Equirectangular projection is one way of mapping a 2D texture to a sphere. It is very commonly used in computer graphics nowadays.
At the end of the tutorial the reader will have created a planet that looks like the one below.
Links
http://docs.godotengine.org/en/latest/tutorials/viewports/using_viewport_as_texture.html
GitHub Proof of Authorship
- GitHub Account: https://github.com/clayjohn
- Pull Request: https://github.com/godotengine/godot-docs/pull/1606