3
votes

I'm working through Frank Luna's "DirectX 9.0c: A Shader Approach" book and I'm stuck on exercise 2 in chapter 10. I'm supposed to calculate a float value s and pass it to the pixel shader so I can calculate "toon lighting". I understand the theory behind how the calculations work, but I can't seem to figure out how to pass a single float value from my vertex shader to the pixel shader like that. When I searched on MSDN I only found the semantics that let you pass 3d vectors, etc.

It looks like maybe I need to modify my input and output structures somehow, but the exercises so far haven't had any structures besides a single "outputVS" structure.

In short, how do I pass a single float value from my vertex shader to the pixel shader in HLSL?

Thank you in advance.

1

1 Answers

1
votes

You put the float into one component of the vector. Then your pixel shader reads only that one component.

There's no law that says that every component of a vector must contain actual data ;)