iamgreaser / iceball

Open-source rewrite of the VOXLAP version of Ace of Spades.
http://iceball.build
GNU General Public License v3.0
113 stars 32 forks source link

Zooming allows you to see through blocks. #161

Closed DetectDefective closed 9 years ago

DetectDefective commented 9 years ago

Was messing around while chatting with another player, and noticed that if I used the zoom of the rifle, I could see clear through blocks.

Before zooming.

After zooming.

dany-on-demand commented 9 years ago

So you're a DefectDetective now, huh? \o/ Welcome <3

DetectDefective commented 9 years ago

Yes, that's my original name, and thanks for the welcome as well as the fix regarding the red screen. :D

rakiru commented 9 years ago

This is a known issue, but I hadn't made a ticket since I didn't want it to be widely known until we got it patched. If other people are noticing it though, then this might as well stay here as extra incentive to fix it quick. Thanks for the well-written bug report. :)

iamgreaser commented 9 years ago

One of the problems with making a game using a rasteriser such as OpenGL is that they tend to use a thing called a Z buffer or a depth buffer. These usually store the value 1/z relative to the camera, and scaled so it fits within a [0, 1) or [-1, 1) range - typically using fixed-point arithmetic. Because 1/0 is infinity, and making the near plane really really really close to the camera will give you absolutely dreadful Z buffer precision, we have to cope with this. (Also, even if we didn't have this problem, you still need to clip polygons against the screen.)

I'll give you the gist of how I'd go about fixing this.

The VA API allows creation of any triangle soup. client.va_render_local can render things relative to the camera. There's almost definitely some function on the Lua side which can work out if a box touches anything solid on the map. The near plane seems to be configured to be 0.05.

Combine all that and you can do a check where if the camera is touching something solid in a 0.06*this.zoom area, and if so then draw something in the fog colour in front of the camera.

Another approach would be to stream into a VA showing the geometry of the 3x3x3 around the camera, but with the faces inverted. (Basically, one of the many wonderful tricks you can do with backface culling is to invert the faces and get weird fun things happening.) This should work a little bit betterer, assuming that streaming into a STATIC_DRAW VBO isn't going to have a similar effect to performance as what the font renderer in 0.61-0.75 did.

But of course we may be able to get away with simply moving the camera back by whatever_it_is*this.zoom considering that we do something to fix the unzoomed case already.

rakiru commented 9 years ago

The camera move thing is what I was considering (I'd completely forgot about this issue though honestly). Drawing the inside of blocks that the camera is in/near may be wise though (in addition), as it would allow for any cases where a game[mode] may want to put someone inside a block for some reason, and would stop glitching inside the map from being easily exploited at the very least.

iamgreaser commented 9 years ago

Yeah I think we can basically close this one now. If anyone wants to implement the 3x3x3 thing, go ahead, but we have enough open issues right now already.