I am trying to update the texture of a material (the Ground Material assigned to the ground plane of the new game example) but it fails to render.
What I do:
[CODE]
cam_texture = Texture.New2D(GraphicsDevice, RenderTextureWidth, RenderTextureHeight, 1, PixelFormat.R8G8B8A8_UNorm_SRgb, usage: GraphicsResourceUsage.Dynamic);
Entity.Get().Model.Materials[0].Material.Parameters.Set(MaterialKeys.DiffuseMap, cam_texture);
byte[] data = new byte[RenderTextureWidth * RenderTextureHeight * 4];
Marshal.Copy(img_rgba.ImageData, data, 0, RenderTextureWidth * RenderTextureHeight * 4);
cam_texture.SetData(commandlist, data);
[/CODE]
The img_rgba is an IplImage image from a web cam I capture. I know that this part works because I am able to render the cam_texture in a Sprite Batch with no problems.
I can also see that the cam_texture is assigned to the Material of the Model when I debug the code.
I am missing something in the way I need to set up my material and texture to get this to work?