Graphics Reference
In-Depth Information
// Calculate the world space reflection vector, and then transform it to
// the paraboloid basis.
float3
R =
reflect
(
E, N
);
R
=
mul( R,
(float3x3)ParaboloidBasis
);
//
Calculate the forward paraboloid map texture coordinates, with z
// determining which paraboloid map to sample (front
or
back).
float3
front;
front.
x
= (R.x / (2*(1 + R.z))) + 0.5;
front.y = l-((R.y / (2*(1 + R.z))) + 0.5);
front.
z
= 0.0f;
//
Calculate the backward paraboloid map texture coordinates, with z
//
determining which
paraboloid
map to sample (front or back).
float3 back;
back.x = (R.x / (2*(1 - R.z))') + 0.5;
back.y = l-((R.y / (2*(1 - R.z))) + 0.5);
back.z
= 1.0f;
// Sample the appropriate paraboloid map based on which direction
// the reflection vector is pointing,
if
(
R.z
> 0 )
OUT
=
ParaboloidTexture.Sample( ParaboloidSampler, front );
else
OUT = ParaboloidTexture.Sample( ParaboloidSampler, back );
OUT *= 0.8f;
return
OUT;
}
Listing
1
3.8. The pixel shader for rendering a reflective object into another object's paraboloid map.
Figure
13.11. The result of rendering reflective objects into another reflective object's reflection. Model
courtesy of Radioactive Software, LLC,
www.radioactive-software.com
.
Created by Tomas Drinovsky,
Danny Green.
Search WWH ::
Custom Search