/// <summary> /// Renders the scene to each of the 6 faces of the cube map /// </summary> private void RenderSceneIntoEnvMap() { // Set the projection matrix for a field of view of 90 degrees Matrix matProj; matProj = Matrix.PerspectiveFovLH((float)Math.PI * 0.5f, 1.0f, 0.5f, 1000.0f); // Get the current view matrix, to concat it with the cubemap view vectors Matrix matViewDir = ViewMatrix; matViewDir.M41 = 0.0f; matViewDir.M42 = 0.0f; matViewDir.M43 = 0.0f; // Render the six cube faces into the environment map if (environment != null) { rte.BeginCube(environment); } for (int i = 0; i < 6; i++) { rte.Face((CubeMapFace)i, 1); // Set the view transform for this cubemap surface Matrix matView = Matrix.Multiply(matViewDir, GetCubeMapViewMatrix((CubeMapFace)i)); // Render the scene (except for the teapot) RenderScene(matView, matProj, false); } rte.End(1); }
private void DrawToEnvironment() { rte.BeginCube(cubeTexture); for (int i = 0; i < 6; i++) { rte.Face(( CubeMapFace )i, ( int )Filter.None); d3dDevice.Transform.World = Matrix.Translation(teapotPos); d3dDevice.Transform.Projection = Matrix.PerspectiveFovLH(( float )Math.PI / 4, 1.0f, 1.0f, 10000.0f); d3dDevice.Transform.View = GetViewMatrixForSide(( CubeMapFace )i); DrawQ3Map(); } rte.End(( int )Filter.None); }