Depth ordering moving objects on impossible geometry

Started by
11 comments, last by Khatharr 8 years, 1 month ago

I have an idea for game where you move over the surface of impossible figures, something like the mobile game Hocus but with more complex puzzles.

The impossible shapes are made by splitting up sprites or 3d models, & moving over a seam causes the object to jump to another spot which is aligned in screen space.

With one moving object, seam-jumping is easily handled with several cases based on whether it's touching or leaving a planar trigger, & if its surface faces towards or away from camera.

But with multiple moving objects you get ordering problems:
impossible_ordering.png

My first thought was to render a mask for the movers with collision geometry as black & the movers white, so that they could be ordered independantly of the level mesh then pasted back onto it.

But that still doesn't solve things in an extreme example like this:

triangle_ordering.png

I suppose this could be done with screen-facing sprites on a path that overlaps behind itself (with the red cubes end of the path behind the blue), then masking it somehow. But I wonder if there's a simpler solution that wouldn't need much manual editing of paths etc when doing level design? Preferably 3d to make collisions easier. Any ideas?

Advertisement

I guess they call it impossible geometry for a reason. tongue.png

You could try to render a mesh in orthographic projection and mess with the depth value by adding an offset along one of the legs like so:

O3jqh8w.png

The depth value on the upper end of the leg would be as it was below the upper leg and the lower end as it was above the lower one. You also need to apply the same offset to objects sticking to the leg. Notice that the depth gradient doesn't start right at the edge. I never tried this, but if you make your geometry large enough and it's not to crowded with objects it should work.

blah :)
I think you may just need to hack it. You can manually specify depth relationships based on what surface the cube is attached to. I'm hoping someone comes in here with a more elegant solution though. I have a notion about 2D depth buffers similar to kolrabi's solution but I need to think about it more.
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

have you tried modeling the three sections as separate objects which are always drawn so they appear to intersect? movement from one section to the next could be special cased. movement along a single section would be basic physics. so you move stuff in world space, and just draw it so it looks right in screen space. not even sure if this would work, but i'd probably try it first. before trying some world/screen space hybrid solution.

3d tiling is another possible option. IE painters algo, and draw everything one cube at a time. again, getting screen space alignment perfect might be tricky - but i'd imagine its doable.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

You may need to just constrain level design to make sure there are few enough movers that you can "solve" an ordering before rendering. Also, consider generating your level geometry in tile-sized pieces, so they can participate as freely in depth solving as necessary, instead of having only one depth solution for all geometry.

RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.

@kolrabi your lerping idea got me thinking about this solution - the level mesh stretched in screen space with some kind of lerping triggers or path points either side of the warp.

You get intersections with cubes:

cubes.gif

But turn those to spheres & there's only a slight clipping which you can't notice in isometric:

spheres.gif

It's crude but I should probably keep it that way since I'm not much of a coder yet. Actually I've only used Construct 2 so far for event-scripted 2d prototyping, so this will be my first time writing proper code smile.png

@Norman Barrows - interesting, i'll think about this. I like the idea of rendering different chunks & stitching them together, there's probably a great game idea there. Incidentally I followed the wiki page on painter's algorithm to this - https://en.wikipedia.org/wiki/Newell's_algorithm - might be useful for this problem.

@Khatharr - yeah manually setting depth based on surface would be ideal

@Wyrframe - constraints on level design? Never! I wanted to have an impossible snake level, & if I make the segments from spheres like in the above gif then it seems to be doable.

So that wasn't a solution: lerping over the seams just stretches out the area of wrongness to many incorrectly ordered objects instead of just one at the warp seam:

wrongness.PNG

going to think about the separate sections ideas...

People have made these impossible geometries in real life, but they generally only work from constrained views since they really are not what they appear.

You can build something similar in your game, if you need to.

1280px-Perth_Impossible_Triangle.jpg


I followed the wiki page on painter's algorithm to this - https://en.wikipedia.org/wiki/Newell's_algorithm - might be useful for this problem.

indeed! i remember that from when i wrote my own software renderer back in the day. i decided that the triple oeverlap case was something i would not bother supporting.

but yes, it might be adaptable to your situation.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php


People have made these impossible geometries in real life, but they generally only work from constrained views since they really are not what they appear.

yeah, that's what i'm talking about with separate sections and then adjusting the view angle so it look right in screen space. an excellent example. a picture is worth a thousand words.

but as you say, only one view angle will work with a given draw order, i'd imagine.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement