Graphics Reference
In-Depth Information
cbuffer ParaboloidTransforms
{
matrix WorldViewMatrix;
};
Texture2D
ColorTexture
:
register(
t0 );
SamplerState
LinearSampler
:
register(
s0 );
struct VS_INPUT
{
float3
position
:
POSITION;
float2
tex
:
TEXCOORDS0;
};
struct GS_INPUT
{
float4
position
:
SV_Position;
float2
tex
:
TEXCOORD0;
float z_value
:
ZVALUE;
};
struct PS_INPUT
{
ftoat4
position
:
SV_Position;
float2 tex
:
TEXCOORD0;
float
z_value
:
ZVALUE;
uint
rtindex
:
SV_RenderTargetArrayIndex;
};
GS_INPUT
VSMAIN(
VS_INPUT
IN
)
{
GS_INPUT
OUT;
// Transform the vertex to be relative to the paraboloid's basis.
OUT.position
= mul(
float4(
IN.position,
1
),
WorldViewMatrix
);
// Determine the distance between the paraboloid origin and the vertex,
float
L =
length(
OUT.position.xyz
);
// Normalize the vector to the vertex
OUT.position
=
OUT.position
/ L;
// Save the z-component of
the
normalized vector
OUT.z_value
= OUT.position.z;
// Store the distance to the vertex for use in the depth buffer.
OUT.position.z
=
L
/ 500;
// Set w to 1 since we aren't doing any perspective distortion.
OUT.position.w
= 1;
// Pass through texture coordinates
OUT.tex
= IN.
tex;
return OUT;
}
Listing 13.1.
The vertex shader for rendering a textured object into a paraboloid map.
Search WWH ::
Custom Search