Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 3 ■ advanCed 3d Content rendering: 3d asset ConCepts and prinCiples


texture maps also applied. If you purchase third-party 3D models, you expect them to look like what they
are when you render them, instead of just being flat gray, which is what a rendered model will look like
without any texture mapping (and no vertex color) information applied. In fact, some 3D models that you
will find online (free or paid) will not even have smoothing groups applied, so you will have some that are
faceted, some that are smoothed, and some that are textured to various levels of detail. Some may even have
their normals flipped and will not even appear in your 3D scene until you apply a flip normals operation or
modifier to them. Usually you will have to do additional modeling, smoothing, and texture mapping work to
any preexisting models that you do not create from scratch. I usually try to create everything from scratch,
so I have control over, and familiarity with, the underlying 3D geometry topology and how my smoothing
groups, UVW mapping coordinates, shaders, and texture maps are applied to a model. We will be covering
all of this in this section.


Texture Map Basics: Concepts, Channels, Shading, Effects, and UVW


Coordinates


Texture mapping is as complex an area of 3D as creating geometric topology correctly is; in fact, each of
the areas of 3D is equally complex, which is what makes 3D the most complex new media type by far and
why 3D feature films employ artists to specifically focus on (work on) and handle each of these areas we are
looking at during this chapter. Texture mapping is one of the primary areas in 3D modeling that is able to use
2D vector, or 2D raster image, assets.
It is important to note that there is also a more complex area of 3D texture mapping, also called
texturing, that uses 3D texture algorithms, commonly termed volumetric textures, to create texture effects
that go all the way through your 3D object, as though it were a solid and not a hollow (think double-sided
here) 3D object.
The basic concept behind texture mapping is taking 2D assets, such as those that we learned about
during the previous chapter, and applying these 2D assets to the surface of your 3D geometry. This is
accomplished by using UVW, or 3D, mapping coordinates to show how you want that 2D image (plane)
oriented to, or projected on, your 3D geometry surface topology. Now I want you to quickly look up from the
book and exclaim to those within earshot: “I really need to decimate this spline topology into a polygonal
topology so that I can apply shaders using UVW texture mapping coordinates onto the resulting geometry
and export this 3D model into my JavaFX Scene Graph hierarchy.” Then just resume reading as though
nothing has happened, even though you just established your pending interactive multimedia production
genius to everyone who is currently within earshot.
You can add more than one texture map to the surface of your 3D geometry using texture channels,
which are analogous to the layers that you use in your 2D image compositing software. JavaFX currently
supports four of the most important texture channels: the diffuse texture map (basic ARGB color values),
the specular texture map (where surface is shiny or dull), the illumination texture map (also called a glow
map), and a bump texture map.
3D software packages support other texture map channel types for additional texture mapping effects.
To be able to bring these into JavaFX, you’ll have to use a process called baking. Baking texture maps
involves rendering all of the not yet supported texture channels into a single diffuse texture map since that
is what JavaFX 8 and 9 supports. This provides much of the same visual result that you get in your more
advanced 3D animation packages.
As you can see in Figure 3-4, Blender 2.8 also uses a Scene Graph, just like most modern-day 3D
software packages do, and JavaFX offers this Scene Graph functionality as well; we will be covering it in
Chapter 8. The sphere geometry and texture mapping are grouped together in the Scene Graph hierarchy,
which I expanded for you.

Free download pdf