Graphics Reference
In-Depth Information
for
(
int i
= 0;
i
< 3; i++ )
{
// Create
a
projection
factor, which
determines which half space
//
will
be
considered
positive
and
also adds the
viewing
vector
// which
is
(0,0,1) and
hence
can
only
be added
to
the z-component.
float projFactor
=
input[order[i]
]
.z_value
*
direction
+ 1.0f;
output.position.x
=
input[order[i]].position.x
/
projFactor;
output.position.y
=
input[order[i]].position.y
/
projFactor;
output.position.z
=
input[order[i]].position.z;
output.position.w
= 1.0f;
//
Simply use
the
geometry shader
instance
as
the
render
target
//
index
for
this primitive,
output.rtindex
=
id;
//
Propagate
the normal and
eye
vectors,
output.normal
=
input[order[i]].normal;
output.eye
=
input[order[i]].eye;
output.z_value
=
input[order[i]].z_value
*
direction;
// Write
the vertex
to
the
output stream.
OutputStream.
Append
(output);
}
OutputStream.
RestartStrip(
);
}
Listing
13.7. The geometry shader for rendering a reflective object into another object's paraboloid map.
The final step this rendering configuration is to look up the paraboloid map of the ob-
ject being rendered. This is done in the pixel shader, which is in fact the same pixel shader
that we used when rendering the reflective object into a standard render target.
6
float4
PSMAIN(
PS_INPUT IN
) :
SV_Target
{
float4 OUT;
clip(
IN.z_value
+ 0.05f );
//
Normalize
the
input
normal
and
eye
vectors
float3 N
=
normalize(
IN.normal
);
float3 E
=
normalize(
IN.eye
);
6
At this point in the pipeline, the pixel shader isn't concerned with whether we are rendering into another
paraboloid map, or if we are rendering into
a
standard perspective-projection-based render target. This is one
of the advantages of designing the rendering pipeline in stages, which promotes the reuse of individual shader
programs.
Search WWH ::
Custom Search