Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

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


If you need something (like a house, for instance) where the 3D geometry has to render from the
outside as well as from the inside, which is common in i3D (virtual worlds, for instance), you would have
to create the geometry, the faces in particular, to be double-sided. You would then need to apply a double-
sided texture map and UVW map, which we will be covering in the next section of the chapter when we talk
about 3D texture mapping concepts and techniques.
It is important to note that for i3D, double-sided geometry with double-sided textures requires
significantly more rendering engine processing, and the rendering is being implemented in real time based
on a user’s exploration of the interactive 3D environment, world, or simulation, so JavaFX will be navigating,
processing, and rendering an i3D scene all at the same time, which requires a lot of processor cycles to do
smoothly, so data optimization is important.
Although you can assign a normal to a vertex in JavaFX, a normal is usually assigned on a per-face basis.
This is why there are two formats for the VertexFormat class. One supports location and texture for polygons
that have the normal defined once because defining the normal using three vertices is not as efficient as just
using the one face, and the other is a VertexFormat data format for when you want to define normals using
the vertices instead of the polygons.


Smoothing the Surface: Using Smoothing Groups to Make Polys Look Like


Splines


You probably have seen 3D models that are rendered as solid (instead of wireframe) but still look like they
are chiseled; that is, you can see the polygons (faces) rendered as if they were flat. In this case, the rendering
engine has smoothing turned off. If you render with smoothing turned on, this effect disappears, and the
geometry looks like it was intended to look, which is infinitely smooth, like it was created using splines
when it actually is using polygons. It is more efficient to have the rendering engine do the smoothing,
so there is something called a smoothing group, which is applied to each face, to tell a renderer when
to smooth between two faces and when to not smooth, which leaves what is commonly referred to as a
seam. A smoothing group uses simple integer numbers. If the numbers match on each side of a face (for
each adjacent face on the opposite side of that edge), it renders as a smooth transition (color gradient). If
the numbers are different, it renders as a seam; that is, the edge is clearly visible as the color gradients on
each side of that edge are different (the color gradient is not seamless across the two faces, also known as
polygons).
In some 3D software packages, such as Autodesk 3D Studio Max, you can see this smoothing group
number schema in the user interface and can actually select the (integer) numbers used next to each edge.
You can also select the numbers on either side of an edge, which is a much more complex approach but
gives a 3D modeler much more precise smoothing control.
In others such as Blender, the numbering is hidden, and the smoothing group function is “exposed” by
using commands such as Mark Seam, Clear Seam, Mark Sharp, and Clear Sharp. These commands are
found in the Blender Edges Menu, as shown on the left side of Figure 3-3 with the Mark Sharp option shown
selected in light blue.

Free download pdf