SpiritQuaddicted / reQuiem

reQuiem is a custom OpenGL Quake engine for Windows and Linux. It's designed for maximum compatibility with all things Quake - past, present and future. It's fast, reliable, and easy to configure. In short: it fixes what was broken, improves what needed improving, and leaves the rest alone. It was developed by jdhack.
GNU General Public License v2.0
17 stars 2 forks source link

crosshair is misdrawn #53

Open neogeographica opened 10 years ago

neogeographica commented 10 years ago

I originally thought this only happened in 4:3 resolutions, but it's not limited to that. The problem shows up in certain combinations of resolution and crosshair size.

It looks like it is vertically mispositioned.

When the problem shows up, it looks like some of the top bit has "wrapped around" to the bottom of the character space. Below is 800x600 at crosshair size 1: e1m1_004 (This isn't related to any recent changes... original reQuiem release had this issue too.)

Even in 1920x1080 it looks a little wrong at crosshairsize 1, like some of the bottom arm is missing, but that could just be an artifact of the crosshair scaling.

neogeographica commented 10 years ago

If I add this into Draw_Crosshair just before the glBegin:

            glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
            glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

...then the "wraparound" wigginess shown above will be fixed.

I'm not an OpenGL guy so I'm not sure yet that's the right thing. Also there is some oddness going on in how the center and bounds of the crosshair are being calculated ... especially (but not only) in the case where crosshairimage is set. Although I haven't actually tried using crosshairimage.

I might end up just adding the clamp code and then leaving the other stuff for later investigation.

(P.S. It looks like we may actually want GL_CLAMP_TO_EDGE instead of GL_CLAMP, but that's an extension that doesn't show up in reQuiem's current GL.h header. Since it came in with OpenGL 1.2, almost certainly anything that can run reQuiem will support it. On the other hand, I tried using it and didn't see a difference compared to using GL_CLAMP.)

neogeographica commented 10 years ago

And it turns out that the other crosshair shape problems -- looking like an arm is too short, or even misshapen arms (try crosshairsize 3) -- can be "solved" by declaring linear filtering for the crosshair. I tried specifying GL_LINEAR for both GL_TEXTURE_MIN_FILTER and GL_TEXTURE_MAG_FILTER on the crosshair, and the crosshair shape issues went away.

Of course then I had a fuzzy crosshair, which is a different problem. But anyway that does seem to indicate that the remaining shape issues are from the nearest-pixel texture mapping. It's possible we could solve those with more attention to the definition of the crosshair bounding box.

neogeographica commented 10 years ago

Quick pre-Monday-work update. :-)

If I change ofs1 and ofs2 from 3.5/4.5 to 4.0/4.0, the crosshair shape issues go away.

My understanding is that in an OpenGL 2D coordinate space like this one, when laying out the vertices of a quad, an integer position (like x=400 y=300) represents the upper-left corner of a pixel, not the center of a pixel. If that's the case then the 4.0/4.0 offsets really seem like the "mathematically correct" thing to do in any case.

That makes me wonder where 3.5/4.5 came from though. I'll look into that more later and perhaps also experiment with crosshairimage.

neogeographica commented 10 years ago

Experimental changes on the crosshair_placement branch. See comments for https://github.com/SpiritQuaddicted/reQuiem/commit/eefeab611ae3912eb6ae18ca6407fee635f06863

neogeographica commented 10 years ago

Started a fishing thread at http://forums.inside3d.com/viewtopic.php?f=3&t=5528

neogeographica commented 10 years ago

Fishing thread may have hooked some results.