Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411507 Posts in 69374 Topics- by 58429 Members - Latest Member: Alternalo

April 26, 2024, 01:14:56 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Unusual Projection and drawing order (COOL GIFS!)
Pages: [1]
Print
Author Topic: Unusual Projection and drawing order (COOL GIFS!)  (Read 1097 times)
RujiK
Level 2
**



View Profile
« on: September 18, 2017, 08:24:10 AM »

I'm working on some OBLIQUE PROJECTION stuff but I cannot for the life of me figure out how to handle depth/object draw order. Behold this gif!


The only time the player's depth is correct is if he is lined up perfectly with the tiles. I've tried half a dozen different methods but none give the proper result.

Currently I am using:
Depth = xx+yy-zz;

But I've also tried making some form of pseudo-raycasting engine by calculating the distance to some point and using that as the depth. Unfortunately it didn't seem to be any better. Should I make some kind of Z-buffer? Completely different depth method? Any suggestions?

Thank you for your time.
Logged

Foxwarrior
Level 1
*



View Profile WWW
« Reply #1 on: September 18, 2017, 09:17:55 AM »

It looks a bit to me like you're sorting the depth of the character by the position of their center, when you should be sorting by the position of their front-right corner.
Logged
RujiK
Level 2
**



View Profile
« Reply #2 on: September 18, 2017, 09:45:20 AM »

@FoxWarrior Wow! That makes a huge difference! Thanks!

Unfortunately it still has some issues with going behind stuff, as seen in the above gif when I'm jumping. (Notice I clip the ledge.)

If I SLIGHTLY decrease the depth so as to stay behind the walls, I end up with this floor clipping:



So it's either floor clipping or ledge clipping... Maybe I should put more weight on the x and y values?

IE Depth = xx*2 + yy*2 - zz;

or something... Anyway though, thanks for that tip, it makes a giant difference! I'll keep messing with it but I'd still love to hear any new suggestions.
Logged

qMopey
Level 6
*


View Profile WWW
« Reply #3 on: September 18, 2017, 02:55:51 PM »

Maybe a silly question but why can't you render these in 3D with depth testing?

Also I'm sure I'm missing edge cases, but what is wrong with sorting first by y axis, then by x axis, then by z axis? It looks like floor would be at z = 0, and the player at z = 1. x would be left-right, y would be front-back, and z would be up-down. This would make sure the player couldn't possibly render itself in front of cliffs, so long as the cliff has a higher y-axis position. It would also make sure the player is always rendered above the ground he stands on (due to the z axis as final priority for tie-breaker on the tiles he stands on).

And you would need to sort based on not just the "center" of the images, but the bottom right corner (since the bottom right corner represents highest priority piece of an image).
Logged
DrDerekDoctors
THE ARSEHAMMER
Level 8
******



View Profile WWW
« Reply #4 on: September 18, 2017, 11:38:14 PM »

While you only have a single block moving freely you should be able to order things on a per-object basis, but I wouldn't worry about solving that issue too much because the second you have a anything else moving in your game you're going to have to solve the issue on a per-pixel level because it's possible to have 3 objects, each of which overlaps part of the other so there's no "front" object.

https://www.dropbox.com/s/jqjcsmqofgztx7a/IsometricOverlap.gif?dl=0
Logged

Me, David Williamson and Mark Foster do an Indie Games podcast. Give it a listen. And then I'll send you an apology.
http://pigignorant.com/
RujiK
Level 2
**



View Profile
« Reply #5 on: September 19, 2017, 09:20:03 AM »

@qMopey Unfortunately if the Y value has a greater influence than the X value, it doesn't look right if you go in front of walls, since the x-axis SHOULD be the deciding factor in this case. Like this:


(X is greater but since Y trumps X, it doesn't work.)

Fo the bottom right corner sorting, I have switched over to using that after Fox's post. Thanks though. As to the 3d depth testing, to be honest the reason I'm not using 3d is because I have almost no knowledge on 3d graphics. I'm using Game maker and although it has 3d functions I'm not sure if they would be able to do 3d and keep the pixel perfect perspective. I want the current pseudo-3d look I have, not a true 3d look.

@DrDerekDoctors
I hadn't thought of that but I can see that is definitely correct... Fortunately I'm planning on having 2d sprites for all of the actors in the game that won't have a fake 3d look so I think I can get away with it. Thanks for your comment.
Logged

qMopey
Level 6
*


View Profile WWW
« Reply #6 on: September 19, 2017, 12:41:48 PM »

OK, and what is wrong with sort by x, then y, then z?

Logged
jgrams
Level 3
***



View Profile
« Reply #7 on: September 24, 2017, 05:06:19 PM »

You might also have a look at Shaun leBron's excellent introduction to drawing order for isometric blocks.  Yeah, different projection, but the basic principles are the same.  And...if all your blocks are cubes of the same size you can use a fairly simple algorithm, but if you ever want different sized blocks you need to do a proper topological sort and you can have impossible situations like Derek pointed out.

--Josh
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic