Set/Get array of value using effects framework C#

Started by
1 comment, last by BlackJoker 9 years, 2 months ago

I faced with fact that I dont know how to get or set array of values to/from shader via effects framework.

In my case I need to pass array of matrices to shader.

Could someone help me with this? Need I use constant buffers or somethig else?

P.S. I am using managed code with sharpdx, but I think that in pure C++ the way to do it must be the same.

Advertisement

Not sure about SharpDX, but in SlimDX, you can do something like this:


SlimDX.Direct3D11.Effect FX = ... // Create an effect from the device and shader bytecode

// Assuming gBoneTransforms is a float4x4 array and _boneTransformsArray is a SlimDX.Matrix array
_boneTransforms = FX.GetVariableByName("gBoneTransforms").AsMatrix();

_boneTransforms.SetMatrixArray(_boneTransformsArray);

Eric Richards

SlimDX tutorials - http://www.richardssoftware.net/

Twitter - @EricRichards22

Thanks for help!

In sharpdx there is a little difference, but in general almost the same:


var matrixArray = renderSystem.customEffect.GetVariableByName("jointsArray").AsMatrix();
matrixArray.SetMatrix(JointMatrices);

This topic is closed to new replies.

Advertisement