Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / Correct way of using draw_as_quad
- - By rremedio Date 2017-10-03 14:17
So, after reading through I thought it would be nice to create a pseudo 3d racer in Ruby/Gosu. I'm especially interested in the "True 3d-Projected Segments" section since Road Rash is one of my all-time favorites and it looks great.

I managed to create an early version of the engine and it runs very fast (60fps with up to 900 polygon calculations made in pure Ruby per frame in my use case...increasing the drawing distance so we have 1500 polygons didn't impact fps, but that's not even needed).

Here is how it looks:

The problem is #Image.draw_as_quad is not behaving as I would like. It displays the correct shape but the image is distorted in the wrong way. In case it is not so noticeable in the previous picture, here is another one with a straight line in the road texture. Shouldn't it follow the road? It "zig-zags" in the middle. I've played with the vertex order but it didn't help. Is there anything I'm missing (maybe that's the intented behavior?)? In case you wonder, the strips at the center of the road look better because I'm using 2 side by side textures for the road, as a way to minimize this "bug". Apparently, this won't happen if I use a perfectly rectangular shape (it can be done that way with the "pure raster" approach on the pseudo 3d tutorial, but it would limit the engine a lot).

Parent - - By jlnr (dev) Date 2017-10-04 09:30
First, nice work!

What you are seeing is an unfortunate artifact of how OpenGL works - the distorted quads are split into two triangles, and textured independently. See this answer:

Basically, there is no way to have OpenGL fix these perspective issues for you without passing Z coordinates for each vertex, which Gosu does not support :/
Parent - - By jlnr (dev) Date 2017-10-04 09:35
Ooohh never mind, apparently there is a solution:

Thanks for making me google this again! I've created a GitHub issue here:
Parent - By rremedio Date 2017-10-04 12:42
Thanks! Hopefully it can be implemented.

I was almost going to create a separated polygon for each line, which would probably be bad.
Up Topic Gosu / Gosu Exchange / Correct way of using draw_as_quad

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill