Dynamic Cube Map

Started by
1 comment, last by Nik02 16 years, 3 months ago
Hello, I have created a sky via atmospheric scattering and a skydome. I just render the skydome and for every skydome-vertex I calculate the color in a vertexshader. Now I want to render the sky with a cubemap instead of a skydome. I am using DirectX10 and SM 4.0. I thought about placing the camera with a perspective projection and a 90° FOV. Then I render 2 Triangles for each cube face and in the pixelshader I create a ray from camera position to the pixel and calculate the intersection point with the virtual skydome. At the intersection point I calculate the color like I did for the skydome approach. This procedure I do for all of the 6 cube faces. My questions are: 1. How do I render to a texture in DirectX10? 2. How do I set the texture dimension of each face? I mean, if I load a static cubemap then I have 6 complete textures with a fixed resolution like 128x128. But if I just set the camera to 90° FOV I never set any texture dimension (I never tell DX10 how many pixels I want to render). What resolution will I get and how can I set them? 3. For every pixel I need a ray from camera position to that pixel. I have this idea in mind: In the vertexshader of every cube vertex I calculate a ray from campos to that vertex and store it in a texcoord. Now all of these rays get interpolated accross the triangle and so I have the ray in the pixel shader. Will this work? I guess I have to normalize the ray in the pixelshader? Or is there a better solution (thought about picking)? 4. I have read something about, that in DX10 its possible to render all 6 faces of the cubemap at the same time. Do they mean I place the SAME picture on all 6 faces? Or can I have different settings for each face? Thanks!
Advertisement
1) ID3D10Device::OMSetRenderTargets()

2) You can set this functionality by using ID3D10Device::RSSetViewports(). A viewport defines the area to render to. I'm not sure, but I think that if you don't set this, then the viewport automatically becomes the entire render target. But don't quote me on that.
NextWar: The Quest for Earth available now for Windows Phone 7.
3: This will work, but you don't get to have actual ray tracing since by the time that the skybox objects have been rendered to the cube map, they are effectively 2d data. That said, in practical use such as reflection mapping, this is often accurate enough to fool the eye of the beholder.

4: If you have multiple render targets bound in D3D10 (faces of cube, for example), you can specify a render target destination (SV_RenderTargetArrayIndex) in geometry shader to dynamically direct your output to a given target. The SDK sample "CubeMapGS" covers this pretty well.

D3D10.1 extends this capability by allowing you to index arrays of cube maps, greatly reducing call overhead if you do need to render multiple cube maps from the same data.

Niko Suni

This topic is closed to new replies.

Advertisement