Game Development Reference
In-Depth Information
C
D
C
D
N
N
P
P
V
R
V
R
Figure 1.2. The view vector of the reflected camera equals the reflected view vector of
the camera.
The rendering process is similar to standard real-time planar reflection render-
ing. We build a ViewProjection matrix by mirroring the View matrix by the reflec-
tion plane and compose it with an oblique near clipping plane matrix [Lengyel 07].
We then render the back face of the geometry proxy with this ViewProjection
matrix.
As we reflect the camera, we must inverse the winding order.
C++
pseudocode and shader code are provided in Listing 1.1.
// C++ pseudocode
Matrix Mirror = CreateMirrorMatrix(ReflectionPlaneWS);
Matrix ReflectView = Mirror * View;
Matrix ClipProjection = NearObliqueMatrix(ReflectionPlaneVS);
Matrix ViewProjection = View * ClipProjection;
// Render back face but remember to inverse culling order
SetInverseFrontFaceCulling();
DrawConvexVolume();
// Shader code
float4x4 LocalToWorld;
float4x4 ViewProjection;
VertexMain() {
float4 PositionWS = mul(LocalToWorld , InPositionOS);
float4 PositionSS = mul(ViewProjection , PositionWS);
OutPosition = PositionSS;
// Current direction sampling direction
OutDirection = PositionWS.xyz - CubeCenterWS.xyz;
}
PixelMain() {
OutColor = texCUBE(CubeTexture, OutDirection);
}
Listing 1.1. Pseudocode of parallax-corrected cubemap.
 
 
Search Nedrilad ::




Custom Search