[SOLVED] Isometric Depth Perception

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Bogdan705
Prole
Posts: 15
Joined: Sun Aug 05, 2018 9:04 pm

[SOLVED] Isometric Depth Perception

Post by Bogdan705 »

So I am working on a small isometric thing, and I recently added the ability to delete and place blocks. I built a staircase, jumped on top of it and realized that even though I was on the top it still looked like I was back on the floor, only being able to make out how high I am by carefully looking at overlapping tiles. So I decided to make the tiles that are further down darker, in order to add some sort of depth perception. Problem is, only the first 3 or 4 tiles at the bottom of the map actually have that depth perception and it's kind of faint.

Code: Select all

1 - ( 1 / z )
That is what I use to get the 'depth', using it in setColor, z being the z axis ( up and down in my game )

Code: Select all

love.graphics.setColor(1 - ( 1 / z ),1 - ( 1 / z ),1 - ( 1 / z ))
While writing this I was thinking about maybe having the depth relative to the player's z position, but how would that look like in code?
Any ideas?
Last edited by Bogdan705 on Wed Aug 08, 2018 6:39 pm, edited 1 time in total.
KSP has thaught me that if you aim for the Mun and miss, you'll crash violently into the ground.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Isometric Depth Perception

Post by raidho36 »

In isometric view it should be very obvious if you're climbing upstairs, as they'd be "diagonal" and you'd clearly see them. Can you post a picture?

To do the "relative z" you just subtract one from another!

Code: Select all

local z = player.z - cell.z
Since this will now start at 0 and go positive and negative depending on relative height, you'd probably want to use a sort of sigmoid function to calculate color fade.

Code: Select all

local fade = 1 / ( 1 + math.exp ( -z ) )
love.graphics.setColor ( fade, fade, fade )
You'll have to tweak it to get to look right, and the engine doesn't support HDR color since version 11 (which I think was a stupid change) so you'd have to highlight the tiles at elevated level using some other means.
User avatar
Bogdan705
Prole
Posts: 15
Joined: Sun Aug 05, 2018 9:04 pm

Re: Isometric Depth Perception

Post by Bogdan705 »

This is what I mean by depth perception issues :

https://www.dropbox.com/s/1zwv7b87k1143 ... 9.jpg?dl=0

https://www.dropbox.com/s/oikp4c6bv4do9 ... 7.jpg?dl=0

Same elevation, just walked south. I will try your solution and see if it works thank you.
KSP has thaught me that if you aim for the Mun and miss, you'll crash violently into the ground.
User avatar
Bogdan705
Prole
Posts: 15
Joined: Sun Aug 05, 2018 9:04 pm

Re: Isometric Depth Perception

Post by Bogdan705 »

Unfortunately it didn't work :cry: , BUT I did find something that works and I could say I'm quite happy with the result.

https://www.dropbox.com/s/yo2qypqn69bne ... 6.jpg?dl=0

Code: Select all

fade = 1 / (math.abs(player.z - cube.z) * 0.5)
OR

Code: Select all

fade = 1 / (math.abs(player.z - cube.z) * settings.fade)
Since you know, it's good to have settings. I'm new to the forums, so I don't know how to lock a thread. Could you please tell me how to do so? And if I can't lock a thread, do I just rename it by adding "[SOLVED]" to the title?

Thank you :awesome:
KSP has thaught me that if you aim for the Mun and miss, you'll crash violently into the ground.
User avatar
Bogdan705
Prole
Posts: 15
Joined: Sun Aug 05, 2018 9:04 pm

Re: [SOLVED] Isometric Depth Perception

Post by Bogdan705 »

Welp I just renamed it.
KSP has thaught me that if you aim for the Mun and miss, you'll crash violently into the ground.
Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 3 guests