Jump to content
  • Advertisement
Sign in to follow this  
matt_b

Depth ordering moving objects on impossible geometry

This topic is 862 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?
 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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. Edited by Khatharr

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

@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.

Edited by matt_b

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Edited by Norman Barrows

Share this post


Link to post
Share on other sites


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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!