artifacts caused by scaling (2D).. (was mini-map thread)

Started by
18 comments, last by Kalidor 19 years, 3 months ago
ok, ive tried swapping the texture coords so that the top left vertex is matched with the bottom left texture coord, etc. however the result is _exactly_ the same!

anyone have any clue what im doing wrong?

thanks a lot for any help.
FTA, my 2D futuristic action MMORPG
Advertisement
ok, i found the answer to both my problems, but of course, a new problem has arised..

first of all, the reason why switching texture coordines didnt work is because i was switching the wrong texture coordinates. i thought you meant i should switch the texture coordinates of the quads i drew on the screen before i converted the screen into a texture. however, i now see you meant to reverse the texture coordinates of the actual quad that i rendered using the texture i got from rendering to a texture.

next, i figured out how to render the entire map onto the texture. i did use scaling. and in fact, the main problem was from from integer division [flaming]. i forgot to cast to float, so my scale factors were 0.0, hence the black texture.

anyway, now on to my new problem. there are visual artifacts appearing in my texture. i think it has to do with scaling... and i think ive read this before, i think i can solve this problem with some sort of texture settings.. basically, i believe this problem is due to the tiles bleeding togeather due to scaling. i have this same exact problem with my map editors "zoom" function. when i zoom out, i just scale everything and draw more quads - the problem is, the tiles seem to bleed togeather unless i am scaling be .5. .5 seems to work fine for some reason (i think another worked fine too, i cant remember what it was though).

anyway, can anyone help me here? here's a few pictures.

first, heres me standing in a small map (around 35x35 tiles). the mini-map is being rendered in the top left corner of the screen. notice how the mini-map has artifacts spread throughout it. in this case, its not very bad or noticable.


now, in this map, its much worse. i belive its much worse because this map is much bigger, and therefore i had to scale a lot more. this map is 250x250 tiles, so the i had to scale a lot (around .1 scale factor).


if you look at the mini-map, the most noticable artifact is those grey lines (which appear to be my grey tiles you see to the left of my character) striping down in almost perfect columns. note that these do NOT exist in the map. they are pure artifacts!

thanks a lot for any help!
FTA, my 2D futuristic action MMORPG
after talking with some people, it has come to my attention that this is actually a much more difficult problem to solve then i expected. i talked to someone who said theres really no way around this, even using software. is this true? is this really an unsolvable problem?

im using SDL with OpenGL. i thought i could maybe do this in software. render the map into an SDL_Surface, use SDL_gfx to scale it, and then convert that surface to a texture. but apparently this is not possible either? someone said that even using software the same artifacts will appear. how could this be? and is there any nice way to handle this?

what i really dont get is, how is Paint Shop Pro able to shrink images without these artifacts? surely it must be possible then..

thanks a lot for any help.
FTA, my 2D futuristic action MMORPG
EDIT: NOOO!!! My beautiful post was eaten by the evil cgi error! anywho:

Why not just render-to-texture? it would be (relatively) easy, and you could do it after youve loaded the map (or at any other time really) so it would be quite well suited to your persistent world (NOTE: i admit i didnt read really anything from this thread, so if anyone else has said it, i second it :-D)

hope that helps
-Dan

[Edited by - Ademan555 on January 23, 2005 3:10:42 AM]
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
graveyard filla: The problem is your image size, your storing a largemap into a small texture, if you think about it each tile is likely becoming one pixel or less.
So how do you get around this? You could just use a larger texture, but I would go ahead and say use multiple small textures. This way you wont scale the map down as much, but you'll have to translate it for each texture.
Allternatively dont put the whole level into the minimap - just a subset, like a 3 screen radius, thats one screen offset from the current scroll offset in each direction (negative & positive).
@ademan

i already am rendering to a texture

@x-out

well, if you think about it, the texture is 256x256, and the map is 250x250 tiles, so a tile IS a little bigger then a pixel. also, i am not planning on drawing the entire map - i am only going to draw a section of the map, a small piece that represents the area immediately around the player. i dont think rendering a piece of the texture will change anything, if you think about it, either way the texture itself is distorted.

so, how can i do this then? i know its possible by doing something like re-sampling, but i have no clue how to do something like that..

thanks a lot for any more help.
FTA, my 2D futuristic action MMORPG
You need a higher resolution texture to store it in. Like I said, one tile is becoming more or less 1 pixel.
Just to prove a fact, Half-lifes minimap texture dimensions are 1024*768 (thats split into smaller sections of 256)
I would try rendering to a size that is a whole multiple of the map size. If your map is 250x250, and you render it to a texture that's 256x256, each pixel of the texture will hit the texture of the underlying image in a slightly different place.

Think of stretching a grid of 256 horizontal lines and 256 vertical lines over your whole map. The spots where the lines cross would be on a different place in every row. It is those spots that OpenGL is getting the color from.

You also may want to make sure that you're using either bilinear filtering, mipmaping, or both... Apparently the default minification filter is GL_NEAREST_MIPMAP_LINEAR. I don't think it will do much if you haven't set up any mipmap levels, though. You might want to try changing it to GL_LINEAR like this:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

That should cause it to use the four closest pixels to the point of intersection instead of just the closest pixel.

You might also want to look into the GLU function gluBuild2DMipmaps to automatically generate mipmaps for your tiles as you will get better quality that way than you would with simple linear filtering. =)
--Shon
thanks for the replies.

you guys were right, i resized my map to be 256x256, and the mini-map looks perfect. but, is there anyway to get this to work the way i want, or do my maps have to be a power of 2 for the mini-map to work?

i tried using gluBuild2DMipmaps and GL_LINEAR_MIPMAP_LINEAR, however, this didnt work. the mini-map still looked distorted. also, my regular textures didnt look to right. one of my tiles appeared all grey except at the corners, when normally the tile is grey with slightly darker grey dots spread across it.

thanks a lot for any more help.
FTA, my 2D futuristic action MMORPG
Just an FYI...

For a minimap you probably shouldn't use mipmapping because you'll really only ever see one mipmap level, so creating all the other levels is just a waste of vram.

This topic is closed to new replies.

Advertisement