Has anyone attempted a pseudo 3D racing game using Defold? I mean games like Outrun.
I’m sure it’s possible but so far the only ways I can imagine drawing the track are quite limited and inefficent.
Has anyone attempted a pseudo 3D racing game using Defold? I mean games like Outrun.
I’m sure it’s possible but so far the only ways I can imagine drawing the track are quite limited and inefficent.
This is something that is always in my mind but never had time to try.
I’ve seen recently a good version in love2d here:
Maybe it can serve as inspiration
I was reminded of this post. Perhaps it’s useful.
There are different ways of doing this.
E.g. skewing 2d sprites to create arbitrary polygons, to get a 3D perspective.
You can also rasterize the polygons yourself.
How would I go about that? I’ve been trying to do this for the last couple of days, but I couldn’t make it work.
I tried to add a transform matrix to a shader, but I couldn’t make it independent of the world position. I ended up just modifying the coordinates of specific vertices to force it into the shape I wanted, but that breaks the texture, as the sprite is made of two triangular polygons and moving a vertex only skews half the sprite the right way.
I ended up just going with that, as it’s not that bad and it was meant to be just a simple practice project anyway, but I’d like to know what’s the correct way to do that. I did learn a lot about shaders, though, such as “what the hell is a shader”.
I should try to find that source and put it up somewhere ^^
Here’s one way. Since it uses uniforms, it will break batches, but could still be useful sometimes:
Thanks! I’ll look into it when I have the time. Looks like I wasn’t that far-off.
I’m trying a method that’s based on using horizontal scanlines rather than polygons. It’s quite limited in how far your can distort the road round a corner or view it from weird angles. At least, I imagine it will be, I haven’t got that far yet
Hmm… that doesn’t solve my problem. In fact, it’s pretty much the same partial solution I ended up with, I think (which is a huge confidence boost, btw!).
I added a simple grid texture to your example and changed the shape a bit to make it more clear and this is the result:
When I made 198X, I started thinking of ways to do it in Defold, but my lack of solutions for pseudo racer rendering was one of the things that made me go for another engine (then I ended up making it in Compute shaders and totally custom anyway, but that is a different story). I did however get a lot of good ideas regarding how to handle things mathematically from both https://codeincomplete.com/posts/javascript-racer-v1-straight/ and https://www.youtube.com/watch?v=KkMZI5Jbf18. The latter might be a little too much on the kindergarten-computer-class-side of things, but he has a few good and simple solutions to some problems.
Sort of got curves working though it really needs a scrolling horizon to sell the effect. The overall techincal difficulty is not that hard if you build up functionality in stages. Could add hills to this without too much trouble. Probably not going to take it any further though as it doesn’t actually loook that great compared to a polygon based approach.
We will be releasing custom vertex buffers pretty soon (it’s in review atm) which means you can generate mesh data in any way you prefer, even in runtime. Would that help? You could have a separate vertex attribute för vertex id’s if you want.
That’s sounds really good. I’ll take a look at it upon release.
I love how you snuck in a bit of Swedish there! Let’s slowly start converting API functions and some manuals to Swedish and see when the community notices!