Book Image

Direct3D Rendering Cookbook

Book Image

Direct3D Rendering Cookbook

Overview of this book

Table of Contents (19 chapters)
Direct3D Rendering Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Further Reading
Index

Implementing multithreaded dynamic cubic environment mapping


In this recipe, we will implement dynamic cubic environment mapping or cube mapping and explore how threading impacts the rendering performance. A cube map is commonly used for skyboxes with the camera located inside the cube. In this recipe, we will be using cube maps to implement reflections for objects. We will also be rendering directly to the cube map resource in order to implement dynamic reflections. In Direct3D, a cube map is implemented using a texture cube; this is a special texture array with six slices where each slice represents a face of the cube along an axis. The TextureCube HLSL shader resource provides built-in sampling support. The following figure shows a static cube map laid out flat, and the texture array indices are matched to the appropriate axis:

Static cubic environment map with texture array indices.

Note that the cube map is defined using a left-handed coordinate system (that is, +Z is forward, +X is...