#Can you render a sprite to a viewport, but have it be a child of a different node?
49 messages · Page 1 of 1 (latest)
for example:
scene:
player:
particles (gets rendered on the pixel_perfect_viewport)
pixel_perfect_viewport
Someone may correct me if I'm wrong, but a viewport just needs information on what to render, it can render things that aren't its children.
how would that work?
this would come in handy for me too.
I'm not sure but if it wasn't possible you wouldn't be able to have a split screen or a hind camera or similar things.
I think it's easier if you explained what you want to achieve.
Render all particles on a seperate surface thats gonna be pixel perfect
Can you go into more detail?
thats literally it,
have a second viewport that i render all particles to and then ill make it pixel perfect with a shader
I'm sorry, I cannot visualise this.
Whats the confusing part?
You say 'all particles' but I don't know what particles you're using. I don't even know whether the game is 2D or 3D, I don't know where this second viewport is being rendered, or how a shader makes it pixel perfect, or what pixel perfect even means in this context.
Its 2d, gpu particles, its getting rendered on the screen, how the shader makes it pixel perfect doesnt really matter, but if you wanna know, i will just snap the UV
After some searching, I concluded that Manock is wrong and this is not possible.
Split screen is possible because of the World2D is already part of the tree and rendered to root Viewport.
It appears that to benefit from the viewport, you need to have everything as a child of the viewport.
To clarify, it needs to be a child of some Viewport so it can be passed around, given your use case, I think the best solution would be to spawn the particle emitters as children of the viewport directly via signals. (like in the event bus system video by GDQuest)
Can you explain that?
How can two viewports show the same game world when the other camera exists in a separate world entirely?
World2D, read the documentation
Can you explain, I don't understand what World2D does.
I've never used a World2D or World3D in any of my games. I once tried reading it but it makes no sense to me. I don't place any objects in it. Any objects I place are just children of the root viewport.
I looked at the docs again and neither World nor World2D really explain what they are.
I'm not saying I can't be wrong, I probably am, but now I'm curious why I'm wrong.
In addition, do you somehow understand what particles are being rendered or where the second viewport is being rendered? Or what pixel perfect means?
particles being rendered means, particles getting drawn on some surface, pixel perfect means the texture is of set resolution and pixels cant be in between one another
What particles are we talking about though?
First off, anything rendered to Viewport is pixel-perfect.
yeah, but what if i want some particles to follow the player, do i just gotta keep a referance to them and move them and stuff, because that sounds kinda tedious, there must be a better solution
Yep. that seems to be the issue of it. You need to set the global position each frame.
Like, when I think of particles I think of stuff like fire or flashy effects that require a lot of small images to be rendered all at once.
yes, but its not pixel perfect on a lower resolution i want, ill solve that with a quick shader
Like do you want to render particles to a viewport that is overlaid on top of the regular one?
have i not made that clear?
you did
Whether or not you did, to me it was very unclear. That's what I've been asking this whole time.
well anyways, im gonna go find a workaround or something, thanks for the answers
EDIT:
is the SCALE of the particles not (1,1)?
But these particles are just... What am I thinking of? Flash effects from sword swipes or something?
no? (the node, particles2d)
Yeah but what particles? What sort of effect do you want to show on the screen?
particles?
Please Manock you are kind of derailing the conversation if you don't understand the problem by now.
I'm sorry for committing the awful crime of trying to help.
@stuck flax if you are modifying the scale of the particle, only the approximation will be drawn onto the viewport.
The same situation happens if the particle's rotation is different form 0
What is the resolution of the game?
and what resolution it is rendered at? the window i mean
i am assuming that the game is not played at this resolution
i checked the camera zoom, test resolution and shrink, but u cant find where i scaled it :/
https://docs.godotengine.org/en/stable/classes/class_visualserver.html#class-visualserver
Maybe the VisualServer class could be helpful...?
Inherits: Object Server for anything visible. Description: Server for anything visible. The visual server is the API backend for everything visible. The whole scene system mounts on it to display. ...
I still think what i suggested earlier is the simplest solution
i could also try and make a shader to lower the res of each particle