How to make particles in custom viewport use non-local coords

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

I am attempting to make “pixelated” particles by placing a Particles2D node inside of a custom Viewport and setting its parent ViewportContainer to stretch mode. Since the Viewport will “pixelate” everything inside it, the particles will snap to the actual game pixels and produce the pixelated effect that I want. Here’s a gif comparing normal particles (right) with the pixelated version (left).

This system works great except for one problem: non-local coords. While I’m not sure exactly why, my theory is that the global transform that the particles are supposed to use in non-local coords mode is actually the custom Viewport itself, rather than the “root” Viewport. Since the custom Viewport is itself instanced in other nodes that want to use pixelated particles, the inner particles end up just following that viewport, rather than the “root” one that I want. Here’s a gif demonstrating this effect. Note that both particle systems in this example are using non-local coords (regular on the right, pixelated on the left).

Is there a way to get the inner particles in the custom viewport to use the “root” viewport as the base of the global transform? Alternatively, if there are easier ways of pixelating particles in Godot than this I’m open to suggestions for that as well.

Thanks in advance for the help! You can find the project files here if you want to mess around with this yourself.

can’t you just do something like global_position = local_position - customViewport.position + globalViewport.position?

nonchip | 2020-04-24 15:59

Unless I’m misunderstanding, I’m not sure that will work. I don’t want to affect the global position of the particles node, I want the particles themselves to emit in non-local coords where the coords they use instead are the root viewport’s coordinate system, rather than the custom viewport’s coordinate system (which is what appears to be happening).

AUD_FOR_IUV | 2020-04-24 16:47