Godot Documentation: Using a Viewport As a Texture

in #utopian-io6 years ago


Godot Documentation and Godot

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.


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!


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.



GitHub Proof of Authorship


Thats a really great contribution.

As I pointed out before that you are doing really great work for this project.

I really appreciate your efforts

I can honestly say this is one of the gem contributions of my category and I am staff picking it.

Keep up the great work.

I am really looking forward to more contributions from you.

Keep Contributing

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.

Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.

Thank you for your review, @ms10398!

So far this week you've reviewed 3 contributions. Keep up the good work!

Hey @clayjohn
Thanks for contributing on Utopian.
Congratulations! Your contribution was Staff Picked to receive a maximum vote for the documentation category on Utopian for being of significant value to the project and the open source community.

We’re already looking forward to your next contribution!

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Hi @clayjohn! We are @steem-ua, a new Steem dApp, computing UserAuthority for all accounts on Steem. We are currently in test modus upvoting quality Utopian-io contributions! Nice work!

Coin Marketplace

STEEM 0.29
TRX 0.11
JST 0.041
BTC 67119.36
ETH 3214.85
USDT 1.00
SBD 4.40