#Rendering tile unto a texture for shader in 2D

10 messages · Page 1 of 1 (latest)

slender barn
#

Hi all, we are trying to a very simple thing in 2D. We want to render only specific tiles unto a texture that we then send to a shader. What would be the best approach for this? What we tried (and we have done something similiar in 3D and it worked) is to create a subviewport with its own camera, but we can't get the camera to render anything on the subviewport. Camera3D has culling mask so it's easy to put objects into specific layer and let only them render on the second subviewport, but we are not sure how we should approach this in 2D. Any tips?

woven viper
outer grotto
#

@woven viper Hello. We have tried with and without viewportcontainer via similiar approach as in 3D scene, but it didnt work. The only approach that worked was to duplicate relevant part of the scene and add it under the subviewport. Then we could add the subviewport as the texture for TextureRect and it displayed it correctly. Here is a screenshot of what worked in 3D scene.

#

Here is an example of what we have tried in 2D scene. Where only SubViewpor3 worked properly as I have mentioned.

woven viper
#

but in 3d they share the world by default, so the only thing that has to be the child is the camera

#

did you set the update_mode ov the subviewport to always?

outer grotto
#

@woven viper No we didn't.

woven viper
sweet pond
#

If you're trying to display a separate camera in the same world using a subviewport, you gotta set the world 2D via code