Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

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


2D imagery as inputs but instead use complex algorithm definitions that produce a 3D shader that cuts
through the 3D object, which is why it is called volumetric. These 3D volumetric shaders can also be
animated and can change color and translucency based on their position in 3D space.
On top of this, advanced shader languages, such as Open GL Shader Language (GLSL), use code to
specify how these channels interrelate to each other, how to apply or process the data contained in these
channels, and how to provide other more complex applications of the data within these channels based
on complex factors such as time, orientation, or position in 3D space. The complex nature of shaders
also means that the render-time processing of the shader is more time-consuming, and processing cycle
consuming, the more complex a shader becomes. The processor cycles required can often be expensive
because of the ability of complex shaders to produce photorealistic results.
This is probably the primary reason that JavaFX 9.0 currently supports the four basic (and easiest to
process) shaders. As hardware becomes more powerful (you’ll see six-, eight-, and ten-core CPUs in more
consumer electronics products), JavaFX will probably add the last two important shader channels: opacity
(or transparency mapping) and normals mapping.


Texture Map Orientation: Texture Map Projection Types and UVW Coordinates


It is important to align the detail features in your 2D texture map channels, especially the foundational
diffuse color channel, to the 3D geometry correctly or some fairly odd or at least visually incorrect results
can appear at render time. This needs to be done in 3D X,Y,Z space, especially for volumetric textures but
also for 2D textures to define how they project onto, or envelop around, the 3D geometry.
One of the easiest ways this can be done is by applying texture map projection types, and related
settings, which will then automatically set your UVW mapping numeric values for you. These UVW map
coordinate values will define how the 2D imagery plane maps onto the 3D geometry in 3D space, sort of
a bridge between the 2D space and the 3D space, and UVW floating point values can be set or tweaked
manually in order to fine-tune your visual results.
The simplest of these is planar projection, which you can visualize as if your texture map were in front
of the 3D object and you were shining a light through it, so it looks like the colors in the diffuse texture map
are on the 3D object. Planar projection is the simplest for a computer to process, so use it if you can get
the results that you’ll need for your pro Java game or IoT application. However, it is usually used for static
rendered 3D imagery because once you move (the camera) around to the sides of the 3D model, this type of
projection mapping does not provide photoreal results.
Camera Projection is similar to planar projection. Camera projection projects your texture from
the camera lens (100 percent parallel with the lens) onto a 3D object surface much like a slide projector
would do. This could be used for projecting video backgrounds on your scene so that you could model,
or eventually animate, your 3D assets in front of them. If the camera moves, the camera projection stays
parallel with the front of the lens. This is sometimes termed billboard mode (or projection).
The next simplest is cylindrical projection, which provides more of a 3D application of the texture map
than the (inherently) 2D planar projection of a texture map onto a 3D object from one direction. A cylinder
would surround your object, in the up and down (the z-axis) dimension, projecting the image all the way
around your object! So, if you walked around it, there would be unique texture detail in another dimension
that planar projection does not provide.
A more complex type of projection is called a spherical projection. This provides an even more
complete 3D application of the texture map than the cylindrical projection of a texture map onto a 3D object,
from both the X and Y directions along the Z dimension. Spherical projection attempts to address all three
(X,Y,Z) axis projection directions.
Similar to a spherical projection is the cubic projection, which is like having six planar projections in a
cube format; this gives a result similar to the spherical projection. When you apply a cubic projection to a 3D
object, the object’s faces are assigned to a specific face of a cubic texture map, based on the orientation of the
polygon normal or on the proximity to the face. The texture is then projected from each face of the cubic texture
map using a planar projection method, or possibly a spherical projection map for some 3D software packages.

Free download pdf