Preparing the vertex and constant buffers for materials and lighting

In this recipe, we will update the vertex and pixel shader structures and our constant buffers to provide additional information that our vertex shader and pixel shader need to be able to perform material and lighting operations.

After extending our per object constant buffer to support the transformation of the normal vector and position into world space, we will also add a per frame constant buffer that will contain our camera position and light configuration. How to create C# structures that reflect the HLSL constant buffers is also covered.

Our vertex shader input structure will be changed to accept the normal vector and UV coordinates from the previous recipe, and then update ...

Get Direct3D Rendering Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.