Various graphical bugs in maps

For discussion of the code running behind the game

Moderator: Staff

User avatar
Roots
Dictator
Posts: 8666
Joined: Wed Jun 16, 2004 6:07 pm
Location: Austin TX
Contact:

Various graphical bugs in maps

Postby Roots » Wed May 25, 2011 2:14 am

These have been around since the demo 1.0 release I think, and I want to get them fixed. On my machine, (Ubuntu Linux, x86-64, latest nVidia drivers) there are a number of graphical glitches which are really ugly and do a disgrace to the artwork that's been created for the game. I want to solve these problems during development of the prologue module. Having said that, I took a number of screenshots from my machine to highlight the various problems. Note that these problems do not seem to be prevalent on every system, so there may be even more problems that I'm not seeing.

Bug #01: Black line appears between tiles from certain camera positions
Image

This one I believe I may have fixed already by hacking around. I haven't got a formal fix in place yet though as I'm still investigating, but here's what I think is the problem so far.

Code: Select all

   VideoManager->GetPixelSize(x_pixel_length, y_pixel_length);
   rounded_x_offset = FloorToFloatMultiple(_camera->x_offset, x_pixel_length);
   rounded_y_offset = FloorToFloatMultiple(_camera->y_offset, x_pixel_length); // TODO: Change back
   camera_x = static_cast<float>(_camera->x_position) + rounded_x_offset;
   camera_y = static_cast<float>(_camera->y_position) + rounded_y_offset;


The code snippet above is from void MapMode::_CalculateMapFrame() in map.cpp around line 562. What this block does is re-adjust the position of the camera so that it is aligned to a specific pixel. What do I mean by this? Well, the game usually runs in a 1024x768 screen resolution, and the coordinate system for the map is set so that the width of the screen is 16 tiles and the height is 12 tiles (each tile is 32x32 pixels). We use collision grid coordinates for the screen though (which are 16x16 pixel units) so our true screen coordinates are 32x24. Therefore, each pixel represents a certain fraction of that space. The dimensions for a single pixel are: 0.03125x0.03125(32/1024) and (24/768). I believe the code above is supposed to align the camera position's offset (its decimal portion) to be a factor of 0.03125. However, the GetPixelSize function returns pixel size values of: [0.025000, 0.023438], which is very odd (first of all that they are not what I expected, second of all that the x and y values are unequal).

What I did for my hack to make this black line go away was to use the pixel x value of 0.025 for both x and y. I haven't been able to reproduce this since. So perhaps the cause of this problem is the GetPixelSize() function is buggy and returning inaccurate results.


Bug #02: Grey outlines appear around certain objects and tiles
Image

This is an eyesore. See all those ugly grey outlines appearing around walls and other objects? This is not something that is wrong with map mode, but with the video engine. We've done some looking into this and believe it has something to do with the texture properties we set, either the scaling interpretation (GL_linear?) or something to do with mipmapping. We'll need someone to dive into OpenGL to figure this one out. This bug shows up in the editor too, by the way, since the editor uses the video engine to render the map.


Bug #03: Tile alignment issues
Image

Simply put, tiles are not matching up correctly and I'm not sure why. Its painfully obvious where the "grid" of tiles lies because they don't stitch together nicely. Its almost like a line in the tiles is duplicated or missing or something. I'm not sure why this problem happens because the drawing code for tiles is pretty simple. It starts from the top left, then draws each tile across the screen to the end before going down and starting on the next line. We increment the same distance of the draw cursor for each tile we draw.

I was looking into this earlier and, as an experiment, tried adding a small additional distance between each horizontal tile that was drawn on the lower layer (middle and upper layer tiles were unaffected). The value I used was 0.02f (each tile is 2.0f across). Look at the screenshot below. There's a small black gap between most tiles, which is what I expected. But sometimes there's no gap at all! So if the draw position of each tile isn't persistent, its only natural that the type of problems I am describing would occur.

Image


-----------------

I'll do what I can to investigate here, but I think we're going to need some OpenGL expertise to really nail these suckers. I could look through the OpenGL docs if I really need to, but I'd rather not work on these problems alone...
Image
User avatar
Roots
Dictator
Posts: 8666
Joined: Wed Jun 16, 2004 6:07 pm
Location: Austin TX
Contact:

Re: Various graphical bugs in maps

Postby Roots » Wed May 25, 2011 7:36 pm

Well I "fixed" bug #02 on my machine, the grey line outlines. Turns out I was running in 1280x1024 resolution, not 1024x768. I checked the GetPixelSize() function I mentioned in bug #01 and it is working correctly and returning the proper values, so that's not the problem. When I run the game in its native 1024x768 resolution, bugs #01 and #02 completely disappear for me, without needing any changes. So, I guess we can tack those issues as problems as being a cause of trying to run the game in a "non-pixel-perfect" screen resolution. The only thing I think we could do there is to set the coordinate system to slightly different values depending on the current screen resolution. :shrug:


Bug #03 still seems like its a problem to me though.
Image
User avatar
Roots
Dictator
Posts: 8666
Joined: Wed Jun 16, 2004 6:07 pm
Location: Austin TX
Contact:

Re: Various graphical bugs in maps

Postby Roots » Fri May 27, 2011 2:24 am

Maybe one of the algorithms here will help us address running the game in other resolutions.

https://secure.wikimedia.org/wikipedia/ ... algorithms
Image

Return to “Programming”

Who is online

Users browsing this forum: No registered users and 5 guests