Graphics Reference
In-Depth Information
3.4 Preview Rendering
Once the weathered textures are composed, we can start with the preview render-
ing, which serves two purposes: First, it is a preview for the eventually employed
renderer, thus needs to resemble it closely. Ideally, the simulation system should
be integrated into a content creation system, running on top of the eventually
used rendering engine. For our demo, we render the scene with forward shading
and apply the output textures from the composition stage, i.e., the aged color,
normals, height, and shininess. Second, the preview rendering needs to make the
amounts of material visible to give the content artist feedback. Therefore, we use
distance-dependent tessellation and displacement mapping to display the height
and place billboards to visualize lichen growth.
float
dtf
(
float3 pos
)
// distance
−
dependent tess factor
{
return
lerp
(
g_MinTessFactor
,
g_MaxTessFactor
,
smoothstep
(
g_MinTessDist
,
g_MaxTessDist
,
dist
(
g_Eye
,
pos
)));
}
HS__CONSTANT__DATA ConstantHS
(
in InputPatch
<
float3
,3
>
Pos
,
out
float
Edges
[3] :
SV_TessFactor
,
out
float
Inside
[1] :
SV_InsideTessFactor
)
{
HS__CONSTANT__DATA output
;
// compute tessellation factors for each vertex
float3 tess
=
float3
(
dtf
(
Pos
[0]) ,
dtf
(
Pos
[1]) ,
dtf
(
Pos
[2]));
// set factors for the edges and the interior
Edges
[0] =
max
(
tess
.
y
,
tess
.
z
);
Edges
[1] =
max
(
tess
.
x
,
tess
.
z
);
Edges
[2] =
max
(
tess
.
x
,
tess
.
y
);
Inside
[0] =
max
(
tess
.
x
,
Edges
[0]) ;
}
[
domain
(
”tri”
)]
PS_INPUT DomainShader
(
HS__CONSTANT__DATA input
,
float3 UV
:
SV_DomainLocation
,
const
OutputPatch
<
DS_INPUT
,3
>
controlPnt
)
{
// Barycentric interpolation of control points
float3 outPos
=
controlPnt
[0].
Pos
UV
.
x
+
controlPnt
[1].
Pos
UV
.
y
+
controlPnt
[2].
Pos
UV
.
z
;
/
Barycentric interpolation of normal, tangents , ...
/
/
Displace surface point outPos in normal direction ...
/
return
PS_INPUT
(
outPos
,
normal
,
tangents
,...);
}
Listing 3.9.
We employ distance-dependent tessellation in the preview rendering to
display the amount of material on the surface by displacement mapping.