#SubViewport rendering as black image

1 messages · Page 1 of 1 (latest)

buoyant badger
#

Anyone able to help with my issue, I have a QuadMash with a shader applied to it, I want to get a screenshot of the generated mesh to do some processing on it. I have set up a SubViewport with an orthnographic camera pointing at it, and a gdscript which tries to get the texture from that subviewport, so it can then get the image from the texture and do the processing.

My problem is the image is always black when I actually run the project. In the inspector preview for the camera it looks correct. The code is

@export var viewport : SubViewport

func _ready():
  var texture = viewport.get_texture()
  var image : Image = texture.get_image()

and the attached image is my scene view. This is a child scene of the root scene being run for the game. The image is just black. I've set the SubViewport to update "Always"

All I want is a 2d image of the generated texture from this shader, is there another way to achieve this?

buoyant badger
#

I added a directional light to the scene and now the image is pure white instead