Hello MonoGame People.
I filed an issue for this problem - https://github.com/mono/MonoGame/issues/2913
I’m encountering an issue with MonoGame unexpectedly destroying a Texture2D image that is being sent to an effect as a sampler.
Here is a screenshot.
http://tagenigma.com/monogame/ repro1.png (can’t add image links yet)
The red texture is the source texture2d.
The dotted texture is a mask texture.
The other red texture is supposed to be the red texture with the dotted texture subtracted.
Unfortunately when I pass the texture as the sampler in the effect parameters, it’s destroying the second texture setting it to all black.
Use above link image repro 2. (I can’t post images yet)
One way to set the sampler texture that reproduces the issue.
GraphicsDevice.Textures = _light; // some how the _light Texture2D is being disposed when this is set
Another way to set the sample that reproduces the issue.
_lightingEffect.Parameters[“LightSampler”].SetValue(_light); // this also causes the _light texture2D to be disposed
I’ve also included a repro project that reproduces the issues.
(link in the issue tracker)
Just uncomment the two different ways to set the sampler and you’ll see the texture being destroyed.
The expected result here should be setting the sampler should definitely not affect texture #2.
The other expected result is setting the sampler should cause the second red texture to do *something.
I’m running this test on the OUYA.
Feedback is definitely appreciated.