Texture Filtering with large scaled down textures

Hello guys, well as the title says i’m scaling down textures rendering them in quads, when animating this i get allot of jitter in the texture, so the texture filtering is having problems.

result

(please download the gif to watch it, its 5mg so i couldnt upload it on a better place)

this is the result, it looks like i need mipmaps, do i really need to? cant i go around the recalculated mipmaps, i’m asking this 'cos i’m going to be loading most textures as streams from a wpf app, so I cant really create the maps in the CP.
If you guys know any way to accomplish this let me know, should I just save 2 textures per image? a big and a small one? like a 2 level mip map (lol)? Or is there any way to create a mipmap programmatically, i could do that on the loading mechanims

I’m using these big textures because the user can click them, and they are animated to the screen, so to make them look good they are big.

using the usual quad renderer with these options:

 m_objBasicEffect.World = world;
 m_objBasicEffect.View = view;
 m_objBasicEffect.Projection = proj;

 m_objBasicEffect.Texture = texture;
 m_objBasicEffect.TextureEnabled = true;
 m_objBasicEffect.Alpha = alpha;
 m_objBasicEffect.DiffuseColor = tintcolor.ToVector3();

and using DrawUserIndexedPrimitives();

I tried to change the sampler states, and the texture filtering options, no success.
if you guys need more information let me know.

Enviorement: Win7 x64 in VWare Virtual Machine, VS2010, using MGame 3.0.1 WindowsGL

Edit: After searching a bit more i found out i can just use Texture2D.SetData and add mipmaps. But I dont know how to downscale the texture to use it there, any tip? (long day)

Edit2: After trying some stuff (http:// www. gamedev.net/topic/636883-xna-generate-mip-maps-with-texturefromstream/#entry5028401)

i found some road blocks.
I have an extension in the content manager, to load stuff in background workers with a dispatcher, creating a render target to use there breaks with “Framebuffer Incomplete.” message.

https:// github .com/mono/MonoGame/blob/master/MonoGame.Framework/Graphics/GraphicsDevice.cs#L1378

Going around that, i found that mipmaps are not implemented in RT’s with a notImplemented exception

https:// github .com/mono/MonoGame/blob/master/MonoGame.Framework/Graphics/GraphicsDevice.cs#L1412

, are they done in develop?

Well yesterday i was in a hurry at the end of the post so it’s is messy.

Just at home i searched a bit more, and found some issues in github.

I managed to get mipmaps working by uncommenting and changing a bit what was on the original graphicsdevice class:

 GL.ActiveTexture(TextureUnit.Texture0);
 GL.BindTexture(TextureTarget.Texture2D, renderTarget.glTexture);
 GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
 GL.BindTexture(TextureTarget.Texture2D, 0);

now the other problem of the incomplete framebuffer.
So as i said i’m using a background worker to load these textures.
looks like this:

 static class ContentManagerExtensions
    {
 public static void LoadMipMaped(this ContentManager contentManager, GraphicsDevice gd, SpriteBatch sp,
                                                                            List<string> assetName, Action<List<Texture2D>> action)
        {
            ThreadPool.QueueUserWorkItem((s) =>
            {
                List<Texture2D> assests = new List<Texture2D>();
                //load assets 

                for (int i = 0; i < assetName.Count; i++)
                {
                    Texture2D original = contentManager.Load<Texture2D>(assetName[i]);
                    using (RenderTarget2D renderTarget = new RenderTarget2D(
                         gd,
                         original.Width,
                         original.Height,
                         mipMap: true,
                         preferredFormat: SurfaceFormat.Color,
                         preferredDepthFormat: DepthFormat.None,
                         preferredMultiSampleCount: 0,
                         usage: RenderTargetUsage.PreserveContents))
                    {
                        Texture2D mipmaped = BuildMipMap(original, gd, sp, renderTarget);

                        assests.Add(mipmaped);
                    }
                }
                //report done
                if (action != null)
                {
                    Dispatcher.CurrentDispatcher.Invoke(action, assests);

                }
            });
        }

so this is using that auxiliary graphics device (i suppose) created by the threading class, so maybe it has to do with that, i’ll investigate.

Roger.

Edit:

so GL.CheckFramebufferStatus(GLFramebuffer) returns 0.
from gl docs on glCheckFramebufferStatus we can read :
“Additionally, if an error occurs, zero is returned.”

so i did a GL.GetError(), the result was NoError. so this is weird, what is happening?

Day ending, just wanted to give the last result.

so mip maping works, doing it in the render thread. It seems i’m not able to render on the background thread, just loading stuff.
When i try to render i get the throw from Threading.ensureuithread or something, so i will have to look for a way to do it by setting the data of the loaded texture, with that i can use a background thread to do it, (really important, these textures need to be loaded at runtime after content loading), from what i saw on github there was a guy that contributed that code so i need to look into that.

now even with mipmaped textures, i’m getting some issues.
result

that is the bloomComponent on an image that is a power of 2. this image is really far from the point of view, and its only blurred 'cos the problem gets more visible.
So to me this looks like a texture filtering problem, but i don’t really know, if there is movement to the texture, those artifacts are really visible.

I hope someone here knows what is happening, i need to get this working.

Thanks, Roger.

hello again guys the error in the last post persists.

I talked with the person that shared his fix for the manual mipmaping, and got “working” code going on.

http://pastebin.com/DfqVRSBP

the problem is the GetData calls return all black… then i saw this, and added that to the texture2d class but with no result, they are all still black.
Tried in the local machine (i’m using vmware normally) and the problem persists so its not Mesa’s fault.
There is probably some problem going on here with GL.GetTexImage call, i added a GL.GetError() and the string was NoError at first and then InvalidOperation.
so i added a lock to threading.background context, since the invalid operation happens between gl.begin gl.end calls (my threading class is public).

the calling function for this is this one:

        public static void LoadTextures(this ContentManager contentManager, List<string> assetName, Action<List<Texture2D>> action)
    {
        lock (Threading.BackgroundContext)
        {
            ThreadPool.QueueUserWorkItem((s) =>
            {
                IGraphicsDeviceService serv = contentManager.ServiceProvider.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService;

                List<Texture2D> assests = new List<Texture2D>();
                //load assets 

                for (int i = 0; i < assetName.Count; i++)
                    assests.Add(BuildMipMapCPU(contentManager.Load<Texture2D>(assetName[i])));

                //report done
                if (action != null)
                {
                    Dispatcher.CurrentDispatcher.Invoke(action, assests);

                }

            });
        }
    }

What is happening with getdata?
Edit: they are all RGBA textures
Edit2: https://github.com/mono/MonoGame/issues/1449 hmmmmmmmmmmmmmmmmm going to test this
nope, still black
Edit3: that does not work it is the same.
I skipped getdata on the texture by creating the array myself (this), and it seems that setdata is failing also, still have black textures.