Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Game Development with Blender and Godot

You're reading from  Game Development with Blender and Godot

Product type Book
Published in Sep 2022
Publisher Packt
ISBN-13 9781801816021
Pages 330 pages
Edition 1st Edition
Author (1):
Kumsal Obuz Kumsal Obuz
Profile icon Kumsal Obuz

Table of Contents (20) Chapters

Preface 1. Part 1: 3D Assets with Blender
2. Chapter 1: Creating Low-Poly Models 3. Chapter 2: Building Materials and Shaders 4. Chapter 3: Adding and Creating Textures 5. Chapter 4: Adjusting Cameras and Lights 6. Chapter 5: Setting Up Animation and Rigging 7. Part 2: Asset Management
8. Chapter 6: Exporting Blender Assets 9. Chapter 7: Importing Blender Assets into Godot 10. Chapter 8: Adding Sound Assets 11. Part 3: Clara’s Fortune – An Adventure Game
12. Chapter 9: Designing the Level 13. Chapter 10: Making Things Look Better with Lights and Shadows 14. Chapter 11: Creating the User Interface 15. Chapter 12: Interacting with the World through Camera and Character Controllers 16. Chapter 13: Finishing with Sound and Animation 17. Chapter 14: Conclusion 18. Index 19. Other Books You May Enjoy

Adding and Creating Textures

In a typical 3D workflow, one of the most common properties you would add to a material is texture. A texture is an image file that is responsible for the textured look of a model so surfaces don’t show just flat colors. Although objects you come across in real life have a perceived color, they also have a characteristic look that is defined by this property in 3D applications. For example, both a flower and a sandy surface may have a yellow color, but you know a flower’s petal would look smoother, whereas grains of sand would look gritty.

Most day-to-day objects have wear and tear. Look around and you’ll see that most surfaces will either have chipped paint, a slight deformation, or some scratches. Imagine the barrel you designed in the first two chapters has been in use for some time. It’d naturally have a few scratches on the metal rings. You can only go so far by applying colors to your materials and altering the roughness...

Technical requirements

This book’s GitHub repo (https://github.com/PacktPublishing/Game-Development-with-Blender-and-Godot) will have a Chapter 3 folder with Start and Finish folders in it for you to compare your work with as you go. These folders also contain other dependencies such as the texture files necessary to follow and complete the exercises.

Although you worked on a barrel in the previous chapters, we’ll only use the standard Blender objects, such as a cube and a plane, to keep things simple so you can focus on the texturing workflow.

Understanding UVs and texture coordinates

While you are modeling, you are altering the coordinates of the vertices of a model. Thus, you are working with spatial coordinates. To apply a texture over your model, you need to work in a different kind of coordinate system that is called texture coordinates or UVs. Let’s see how these two terms relate to each other.

The spatial coordinate system is often described with the XYZ acronym since we often use X, Y, and Z axes to define the position of 3D objects. Similarly, UV is another acronym but it is used in the texturing workflow; the letters U and V were picked to describe the texture coordinate system. So, UV doesn’t really stand for ultraviolet.

The process that maps UV coordinates to XYZ coordinates is called UV unwrapping. Via this method, you tell Blender how a graphic file is mapped to XYZ coordinates. If unwrapping sounds counterintuitive, you could try to reverse the process in your mind. What kind of texture...

Using the UV Editor

Blender comes with preset workspaces so you can focus on a particular workflow. So far, you’ve been in the Layout workspace. You can see it as the active tab just under the header of the application, next to the Help menu. You should create a new file and switch to the UV Editing workspace by clicking the appropriate tab. Figure 3.2 is what you’ll see when you are in the UV Editing workspace.

Figure 3.2 – UV Editing is one of many default workspaces in Blender

In the UV Editing workspace, the application will mainly be divided into two sections: the left side, which is called UV Editor, shows a bunch of squares laid out on a flat surface, and the right side shows the default cube. The black dots you see in UV Editor are actually the vertices of the cube in 3D Viewport. You might notice that if you counted the dots in UV Editor, they don’t add up to the number of vertices the cube has. There are more points in...

Importing and applying a texture

When you've dragged the texture file into UV Editor, you have effectively imported it, but, in reality, the material for the cube doesn’t know how to use that texture yet. That being said, the material has all of the information it needs to map 3D vertices to 2D texture coordinates thanks to UV Editor. It just needs to be told which texture to apply to the cube.

To accomplish this, we’ll switch to a new workspace so we can connect textures with materials. Also, we’ll import another texture using a different method and assign it to the cube’s material to showcase how you can use the same UV information with different texture files.

Just like when you switched to the UV Editing workspace, it’s now time to switch to a different workspace for convenience. The sixth workspace, labeled as Shading, is the one you are looking for. We’ll do our work in the lower half of the new workspace, which looks like...

Creating textures procedurally

The word “procedural” has been used a lot in recent years, especially in the video game industry, to describe different things. Although one might say everything we have done so far is following a certain procedure, the word means something else in our context. When we imported the texture file in the preceding section, it was already designed for us. In other terms, it was a static file. The word “procedural,” on the other hand, is a fancy word that means dynamic.

In a dynamic or procedural texturing workflow, the goal is to expose certain parameters of the texture so that the texture can be changed on the fly, instead of going back to a graphic editing application. Since it’s all dynamic, you won’t have to import graphic files, and you’ll be able to change aspects of the final texture. For example, if the six-sided die was using a procedural texture, it’d be like changing the color and/or the...

Exporting your textures

In later chapters, when we get close to working with Godot Engine, we’ll look into asset and project management in more detail. However, after all the hard work we have done with the lava material, it’s now time to learn how to export the texture.

We’ll do a few interesting but necessary things in this section to export our texture. First, we’ll change Blender’s rendering engine. Then, we’ll add an Image Texture node in the middle of our material without connecting it to anything. Weird, right? Blender works mysteriously sometimes.

Changing the rendering engine

We have been using the default Eevee rendering engine so far. Eevee is a real-time rendering engine that gives you really fast results. Most game engines have their own internal real-time rendering engines that are responsible for calculating lights and shadows. So, Eevee is a good way to simulate in Blender what you’ll most likely experience when...

Summary

This chapter started off with a brief discussion about what textures are and why they might be needed. To recap, if you are fine with models that have just the color info on their surface, you are done as soon as the modeling and material application process is finished. If you think you need to show distinctive qualities on your models’ surfaces, you need to utilize textures.

To that end, you discovered how a new coordinate system—one that involves mapping spatial coordinates to texture coordinates via a method called UV unwrapping—might be necessary. Once the UV unwrapping is done, you can apply and swap different textures to your 3D models since the mapping from 2D to 3D is established.

Although creating textures with image editing applications is quite possible, you also know how to create textures procedurally in Blender. This is a powerful method, especially when it comes to surfaces that are hard to UV unwrap, such as landscapes.

Last but...

Further reading

To read more about what each shader node does, you can refer to the official documentation at the following link: https://docs.blender.org/manual/en/2.93/render/shader_nodes/.

For further practice, imagine where else the method for the lava texture could be used. Perhaps, with carefully planned values and more color variations, the hot lava might be rust, and the cool lava might be paint?

If you are curious and would like to investigate different software out there capable of producing procedural textures, you can give Adobe Substance Designer a try. It’s a powerful program dedicated solely to creating textures. Not all of the nodes are labeled the same, but there are a lot of similar nodes to Blender’s. In fact, if you practice your skills there and look at other people’s creations, you might gain insight into creating such textures in Blender.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Game Development with Blender and Godot
Published in: Sep 2022 Publisher: Packt ISBN-13: 9781801816021
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}