I’d like to send my view vector to an ID3D10Effect variable in order to calculate specular lighting. How do I send a vector or even just scalar values to the HLSL from the running DirectX program? I want to do something like
render() {
//do transformations
D3DXMatrix view = camera->getViewMatrix();
basicEffect.setVariable(viewVector, view);
//render stuff
}
In your effect, you should have something like:
Then in your render function, before binding the effect:
As with most effect attribute handles, I would suggest ‘caching’ the pointer to the variable. Storing the matrix variable in another pointer outside of your render loop, like:
And then setting the variable turns into: