DirectX 12, Chapter 6 Exercise 16: Use shader to pulse the box colour

This is my answer to Frank Luna’s “Introduction to 3D Game Programming with Direct X 12”, Chapter 6 “Drawing in Direct3D”, Exercise 16: “Modify the pixel shader in the Box demo to smoothly pulse between the interpolated vertex color and a gPulseColor specified through the constant buffer. You will also need to update the constant buffer on the application side.”

The constant buffer that passes the time and colour to the shader is updated like so:

Of course the objConstants struct needs to be modified:

Here is the shader that is needed:

Leave a Reply

Your email address will not be published. Required fields are marked *