Any way I could clip rect content of parallax background?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Danilo

I want to create 2D comic panel with parallax effect and clip content out of its margins.

EDIT: Basically I need parallax background inside a rectangular mask

For non parallax is quite simple with just control node - clip content, but it doesnt work for parallax layers

:bust_in_silhouette: Reply From: SnapCracklins

Dear mods: apologies for the accidental double post. Network shenanigans afoot.

One easy way would be to code the content directly so it doesn’t hit the margins. You can use something like a variable and then compare it to the screen size (or viewport) and adjust accordingly. People use it for player objects so you could use it for control nodes/UI elements.
Clamp can handle this, with the first argument being what you’re limiting, the second being the lowest possible value and the third is the maximum. May want to play with the value until you get the effect you want.
Something like:

example : (let’s assume your margin object is called myRectObject)

myRectObject.position.x = clamp(position.x, 0, screensize.x
myRectObject.position.y = clamp(position.y, 0, screensize.y

You can even export a variable to control the margin from the editor:

Export var marginVar = 1
myRectObject.position.x = clamp(position.x, 0, (screensize.x - marginVar)
myRectObject.position.y = clamp(position.y, 0, (screensize.y + marginVar)

You can assign a function like that to your objects and even change that number in the middle until you get the margin right.

Also, i love graphic novel style cutscenes. Hope your work goes well!

From what I understand clamp would be for node position, but I would need to cut out pixels from the image, like you would in the viewport shader… basically just like the mask in photoshop

Danilo | 2022-04-05 18:44

You mean like a windowed parallax scroll? Like a scrolling background inside the comic frames? (That sounds cool btw)

SnapCracklins | 2022-04-05 19:58

More like biding phone tilt to 2d camera so I can have some 3d effect with parallax layers on each panel.
Also have to consider that there might be more than one panel on the screen, so the panel content should be masked out

Danilo | 2022-04-06 03:44