I have been trying–and failing–to figure out how to send int3x3 values between the shader and my application for about an hour and a half. No matter what I tried, I was presented with a very generic invalid cast exception.
Finally, I tried “var value = Parameters[“Name”].GetValueSingleArray();” and saw a different error–that I cannot cast Int32[] to float[]. That’s great apart from the fact that none of the available methods accept or return Int32[].
Following the convention, I did a quick Google search for GetValueInt32Array. MSDN appeared, telling me that this public method was, indeed, the correct method to call. Unfortunately, it seems to not exist. Did it not actually exist in XNA? Is it only absent from MonoGame? Am I doing something completely wrong?
For now, I am just going to shove my data into a texture to get it into and out of the shader, but it would be great to know what I did wrong or if parts of XNA are actually missing from MonoGame.
What I needed was to get them into the shader. I only started trying to get them out to see if I could figure out which type it wanted, which is apparently Int32[]. That led to MSDN, which made it sound like EffectParameter should support int arrays where MonoGame’s EffectParameter appears not to. Getting them out just sort of became part of the narrative along the way, but I do not actually need to do that. Just in.
Textures turned out to be a better fit after all, but I am still curious about the int matrices/arrays and documentation mismatch. Are pieces of XNA missing from MonoGame, is MSDN wrong, or am I misunderstanding something? Though I do not ever see myself needing to get an Int3x3 out of a shader, I can envision needing to get them in–or to get Int32[] in/out.
Done. I reviewed all of the Get/Set methods for EffectParameter on MSDN, and the following were missing, along with their most of their SetValue counterparts:
GetValueInt32Array
GetValueBooleanArray
GetValueMatrixTranspose
GetValueMatrixArrayTranspose
GetValueQuaternionArray