O'Reilly logo

OpenGL Insights by Christophe Riccio, Patrick Cozzi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Layered Textures R endering
Pipeline
Dzmitry Malyshau
14.1 Introduction
Texture mapping is a fundamental part of the contemporary rendering pipeline.
It provides various shading models with surface-varying properties, such as diffuse
color, specular color and glossiness, normal direction and displacement offset. Dur-
ing rendering, these properties become parameters of the lighting equation produc-
ing the final pixel colors. There are many ways to define the coordinates used for
texture sampling, such as prebaked UV, parametric projections, including the screen
position, world position, normal vector, reflection vector, etc. When applied to an
existing primitive, texture data can be mixed using various blending equations and
coefficients: add, mix, alpha blend, replace. Table 14.1 shows many of the parame-
ters of the texturing pipeline.
Texture Type Semantics Coordinates Blending Mode
1D file Diffuse One of the UV channels Mix
2D file Opacity Screen position Add
3D file Specular World position Subtract
Cube file Glossiness Normal vector Multiply
Generated Normal Reflection vector Overlay
Encoded Displace Tangent vector Difference
... ... ... ...
Table 14.1. Texturing pipeline parameters.
195
14
196 II Rendering Techniques
Any combination of these parameters may be requested by an artist, hence the
6
4
= 1296 variations already shown in this limited example. Unlike filtering and
wrapping modes, these parameters are not encapsulated in the OpenGL texture sam-
pling state. Supporting these parameters in the real-time pipeline requires different
execution paths on both the CPU and the GPU.
Some 3D engines have a limited number of material profiles like Diffuse only,
Diffuse + Normal, Diffuse + Environment. Source engine [Valve 11] gives an ex-
ample: “The Phong mask is a greyscale image stored in the alpha channel of the
model’s normal map.” There is always a workaround to write our own shader that
implements any combination of the parameters in our table. However, an artist is
not going to do it, and it is too time consuming to be used in the prototyping stage.
These limitations basically leave no way for an artist to experiment with texturing
pipeline in a full degree of freedom in real time.
This article presents an original rendering pipeline designed to support a flexible
texture pipeline, allowing any combination of texture and blending options. It was
inspired by the Blender texturing pipeline [KatsBits 00] and designed for it. Our
pipeline allows artists to use Blenders texturing expressiveness during the early de-
velopment stage, while retaining the advantage of 3D engines ’ real-time performance
when visualizing the results of texturing experiments.
14.1.1 Terminology
Let’s start by clearing up some terminology:
Phong lighting. A commonly used lighting model with the following pa-
rameters: diffuse and specular colors, shininess, surface normal, camera, and
light vectors.
G-buffer. A storage of material properties baked in screen space. Can b e rep-
resented by a number of textures or a single layered texture. The information
is extracted from the G-buffer when the light contribution to the fragment is
evaluated.
Deferred rendering. A family of rendering pipelines that split material
properties and lighting evaluation. Generally, it is implemented in two steps:
G-buffer creation and light resolution.
14.1.2 Textures in Blender
A Blender material contains a list of textures. Material properties correspond to the
uniform properties of a geometric primitive and define the initial parameter val-
ues. Textures are applied in a sequence, modifying some of these values in a high-
frequency manner. Table 14.1 is constructed from a core set, but not all of the
Blender texture parameters. After the primitive parameters are set by the material

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required