#How do I make SubViewports render?
1 messages · Page 1 of 1 (latest)
I think the way most would do that is have a shader that displays a VieportTexture, have a camera as child of the viewport that points backwards.
By "capture things below" it means cameras.
So that it doesn't try to capture stuff from your normal camera.
Hi! Try updating the viewport texture via a runtime script like this:
var viewport_texture = $SubViewport.get_texture()
$MeshInstance.material_override.albedo_texture = viewport_texture
Let me know if this solves the problem, i hope i have helped!
tried it but it just gave me a weird error on load
that's pm how I have it set up, but nothing is getting captured properly.
the doc said "MeshA will not be visible from the SubViewport because SubViewports only capture nodes below them in the hierarchy." in reference to a sibling of the subviewport
Mmmm.... Try to reorganize your hierarchy like this:
Root
├── SubViewport
│ ├── Camera
│ ├── MeshA
│ └── MeshB
└── OtherNodes
Im not 100% sure that will work,Just to try out
I solved this by using a Node2D as a fake camera
Well I dunno what to tell you.
My game has a fake mirror using a camera and it displays the whole room just fine even though it's at the bottom.
in _process on the SubViewport: canvas_transform = fake_cam.global_transform.affine_inverse()
i tried making a temp mesh to see if it would pick it up but it didn't (the viewport did, but the texture was still pink), the problem tho is I need it to render stuff that's outside of the parent's hierarchy.
i'll check it out👍
can i see the properties on the mirror and viewport? it might just be a settings issue or something
Default settings on subviewport except for 512 x 512 size to make it perform a bit better.
Maybe I'm wrong, but IIRC there was no way to make the Camera node ignore the hierarchy
And the mirror surface has a material with texture2D parameter. Then I click the parameter, select "new viewport texture" and it will ask me to pick a viewport. So I select the subviewport.
my setup is pretty much the same, hmm
https://docs.godotengine.org/en/latest/tutorials/rendering/viewports.html is just wrong about subviewports when it comes to 3D, but it is right about 2D.
i tried just doing it manually before by getting the viewport's texture and setting the mesh's material to it.
it worked for capturing the root viewport, but still nothing for this one
Doesn't explain why your texture is pink, though.
Does the Subviewport show pink in the inspector too? Like on the panel with size settings etc.
Does it behave differently if you change the update mode (hidden inside "render target" in the properties) to always?
I have found that sometimes it doesn't always agree with me about whether the subviewport is visible.
no, in the editor it looks fine, just when it's loaded
tried it earlier but it didn't seem to do anything
If your mirror thing is a prefab you might need to right click, select "editable children" and add a new vieport texture to it.
Mine breaks sometimes
also, in the editor the mirror shows the texture just fine, but not in game
Oooh? Extra weird...
True, I am not very familiar with godot 3d, but this should not happen.
omg, i got it to work finally
i just set the ViewportTexture manually in code and it fixed it
Hahaha Im glad that the problem has been solved