Bytes.
For details about the calculation, see the d3d sample as follows: Code
D3dxmatrixa16 matviewsaved;
M_pd3ddevice -> Gettransform (d3dts_view, & Matviewsaved ); // Obtain view Matrix
// Define a flip reference plane. You can define the position and normal as needed.
D3dxvector3 vpoint ( 0 , 0 , 0 );
D3dxvector3 vnormal ( 0 , 1 , 0 )
;
D3dxmatrixa16 matview, matreflect;
D3dxplane plane;
D3dxplanefrompointnormal ( & Plane, & Vpoint, & Vnormal ); // Generate this plane
D3dxmatrixreflect ( & Matreflect, & Plane ); // Obtain the reflection matrix of the plane.
D3dxmatrixmultiply ( & Matview, & Matreflect, & Matviewsaved ); // Use the reflection matrix to flip the view matrix. The camera is flipped to the reflection position.
M_pd3ddevice -> Settransform (d3dts_view, & Matview ); // Set view matrix so that the content rendered by the camera is flipped
// Sets the shear plane so that the content on the reflector is rendered and the content on the plane is discarded.
M_pd3ddevice -> Setclipplane ( 0 , Plane );
M_pd3ddevice -> Setrenderstate (d3drs_clipplaneenable, 0x01 );
// (I wonder if this function works in the shader)
// If it is rendered to the material, you need to use the projection matrix to paste the material to the actual reflected object. You can also convert an object point to screen coordinates and then map it. The principle is the same.