How to fake 3d with per-object parallaxing

Get help using Construct 3!

Post » Tue Sep 19, 2017 11:39 am

Hi everyone,

was wondering how to best do a simple per-object parallaxing to create a fake 3d effect, like they do e.g. on the trees in Darkwood?
https://www.youtube.com/watch?v=3S3tmWfFACQ

Using C2's layer parallaxing is hard to control; perhaps this is something to best do in a dedicated behavior? (not like I was capable of that ...) I imagine a container of two objects, one on the ground, staying in place, the other one panning within a height-dependent offset, based on it's position on screen - assuming that the player is always in the center of the screen.

Does anyone know of available solutions or approaches for this kind of thing?
B
19
S
9
Posts: 284
Reputation: 2,428

Post » Wed Sep 20, 2017 9:26 am

@facecrime I found that this sort of technique works better if you use scaling on layers rather than parallax.
B
24
S
9
G
4
Posts: 515
Reputation: 4,472

Post » Wed Sep 20, 2017 9:51 am

@facecrime

you set a global variable " screen distance from camera" [Bz]
(this represents your eye distance to the projection screen (you game window) )

and every 3d object has as "distance from camera" instance variable [Az]

then the scale / position of any 3D object is directly related to the "screen distance from camera" variable divided by the "distance from camera" instance variable

eg scaled size = original size * Bz/Az
and x or y position from 0 is original x or y * Bz/Az

its quite simple if you keep every thing in the 2 d plane with no rotation

here is an old vid where I had it in action

https://drive.google.com/file/d/0B6AQ9znz3zwxdkRZdWtoQ1psa0E/view?usp=drivesdk

it is explained better on wiki link below, ignore all the big matrix maths (this is all including rotation) and just go to the last picture at the bottom of the page. (which we can use in 2 d games for simple pan and zoom)

https://en.wikipedia.org/wiki/3D_projection
NOTE: There is a high a probability that I am wrong.
B
53
S
27
G
7
Posts: 490
Reputation: 9,051

Post » Thu Sep 21, 2017 9:02 pm

@mekonbekon
that sounds interesting, not sure how this would work, are you saying you'd scale entire layers?

@NetOne
thanks for the writeup! the logic sounds straight forward enough. Now I'd love if there was a behavior to assign to my object families, else I could only think of going through tags to mark the scaling objects and have a bnuch of new variables on each of these objects to set all those depth parameters.
Would you have better concepts to assign logic to the objects?
B
19
S
9
Posts: 284
Reputation: 2,428

Post » Fri Sep 22, 2017 10:48 am

@facecrime

Like this:

https://www.dropbox.com/s/p2rxe7wne4t5q ... r.c3p?dl=0


You need to make sure that the layout is set to unbounded scrolling in its properties.

You can fiddle around with the layer scale to adjust the depth of each layer. It's also worth playing around with the layer scale-rates and the overall layout scale to create some interesting effects.
B
24
S
9
G
4
Posts: 515
Reputation: 4,472

Post » Fri Sep 22, 2017 12:19 pm

@mekonbekon
that's it :) I expected parallaxing to do that for me.
beautifully easy solution, thanks for the example also!
B
19
S
9
Posts: 284
Reputation: 2,428

Post » Fri Sep 22, 2017 6:08 pm

@facecrime You're welcome :)
B
24
S
9
G
4
Posts: 515
Reputation: 4,472

Post » Sun Sep 24, 2017 11:05 pm

hey no fair you said you wanted per object .....

anyway yea , better to use layers like mekonbekon has done

I tried out the per object theory in my in-work shmup just to see , the buildings you see are using the per object parallax on a single layer
so it works but not its not very performant. as you are kind of trying to do stuff the gpu should be doing, interesting though.

https://drive.google.com/open?id=0B6AQ9znz3zwxNnFwRllkaGJPQTA
NOTE: There is a high a probability that I am wrong.
B
53
S
27
G
7
Posts: 490
Reputation: 9,051

Post » Mon Sep 25, 2017 10:54 am

@NetOne
Oh cool! You're right its not per object in fact, wasn't aware i was just approaching Layers the wrong way ...

Your game looks super flashy btw, curious to see that when its done!
B
19
S
9
Posts: 284
Reputation: 2,428


Return to How do I...?

Who is online

Users browsing this forum: The Maddog and 4 guests