Skip to main content
Added relevant tag
Link
liggiorgio
  • 5.5k
  • 6
  • 27
  • 38
edited body
Source Link
liggiorgio
  • 5.5k
  • 6
  • 27
  • 38

Assume there is a viewport that "looks" at some Sprite2D. This viewport's view is providing the texture for a Sprite3D by:

Sprite3D.texture = spriteViewport.get_texture()

It works fine, and the Sprite3D looks exactly like Sprite2D.

This effectively makes the Sprite3D's texture a "dynamic" one: if Sprite2D changes (or anything in the view of the viewport changes) these changes will be immediately reflected on Sprite3D.

While this is an intended behaviour of ViewportTextureViewportTexture, I would like to know if there is a way to make a "one and done" snap of that viewport's view. To render the dynamic ViewportTextureViewportTexture to a static Texture2D so that any subsequent changes in the viewport do not affect the Sprite3D anymore. Ideally without the use of resources or .png workarounds and in the form of a function akin to:

func updateTexture(viewport: Subviewport,sprite3D: Sprite3D)
        <code that permanently redraws the texture of the sprite3D to whatever was in viewport's view>

The obvious solution is saving the "viewport view" as a .png and then assigning the .png to the Sprite3D's texture. However, it is computationally slow and takes extra space, creates extra files, i.e. a mess and I'd rather avoid it.

I've also tried creating a new Texture2D and then assigning the viewport texture to it like so:

newTex = Texture2D.new()
newTex = someViewport.get_texture()

It did not work. Any tips?

Assume there is a viewport that "looks" at some Sprite2D. This viewport's view is providing the texture for a Sprite3D by:

Sprite3D.texture = spriteViewport.get_texture()

It works fine, and the Sprite3D looks exactly like Sprite2D.

This effectively makes the Sprite3D's texture a "dynamic" one: if Sprite2D changes (or anything in the view of the viewport changes) these changes will be immediately reflected on Sprite3D.

While this is an intended behaviour of ViewportTexture, I would like to know if there is a way to make a "one and done" snap of that viewport's view. To render the dynamic ViewportTexture to a static Texture2D so that any subsequent changes in the viewport do not affect the Sprite3D anymore. Ideally without the use of resources or .png workarounds and in the form of a function akin to:

func updateTexture(viewport: Subviewport,sprite3D: Sprite3D)
        <code that permanently redraws the texture of the sprite3D to whatever was in viewport's view>

The obvious solution is saving the "viewport view" as a .png and then assigning the .png to the Sprite3D's texture. However, it is computationally slow and takes extra space, creates extra files, i.e. a mess and I'd rather avoid it.

I've also tried creating a new Texture2D and then assigning the viewport texture to it like so:

newTex = Texture2D.new()
newTex = someViewport.get_texture()

It did not work. Any tips?

Assume there is a viewport that "looks" at some Sprite2D. This viewport's view is providing the texture for a Sprite3D by:

Sprite3D.texture = spriteViewport.get_texture()

It works fine, and the Sprite3D looks exactly like Sprite2D.

This effectively makes the Sprite3D's texture a "dynamic" one: if Sprite2D changes (or anything in the view of the viewport changes) these changes will be immediately reflected on Sprite3D.

While this is an intended behaviour of ViewportTexture, I would like to know if there is a way to make a "one and done" snap of that viewport's view. To render the dynamic ViewportTexture to a static Texture2D so that any subsequent changes in the viewport do not affect the Sprite3D anymore. Ideally without the use of resources or .png workarounds and in the form of a function akin to:

func updateTexture(viewport: Subviewport,sprite3D: Sprite3D)
        <code that permanently redraws the texture of the sprite3D to whatever was in viewport's view>

The obvious solution is saving the "viewport view" as a .png and then assigning the .png to the Sprite3D's texture. However, it is computationally slow and takes extra space, creates extra files, i.e. a mess and I'd rather avoid it.

I've also tried creating a new Texture2D and then assigning the viewport texture to it like so:

newTex = Texture2D.new()
newTex = someViewport.get_texture()

It did not work. Any tips?

Minor grammar fixes, markdown formatting
Source Link
liggiorgio
  • 5.5k
  • 6
  • 27
  • 38

Assume there is a viewport that "looks" at some Sprite2DSprite2D. This viewport's view is providing the texture for Sprite3Da Sprite3D by:

Sprite3D.texture = spriteViewport.get_texture()

It works fine, and Sprite3Dthe Sprite3D looks exactly like Sprite2DSprite2D.

TisThis effectively makes the Sprite3D'sSprite3D's texture a "dynamic" one: if Sprite2DSprite2D changes (or anything in the view of the Viewportviewport changes) these changes will be immediately reflected on Sprite3DSprite3D.

While this is an intended behaviour of ViewportTextureViewportTexture, I would like to know if there is a way to make a "one and done" snap of that Viewport'sviewport's view. To render the dynamic ViewportTextureViewportTexture to a static Texture2DTexture2D so that any subsequent changes in the Viewportviewport do not affect the Sprite3DSprite3D anymore. Ideally without the use of resources or .png workarounds and in athe form of a function akin to:

func updateTexture(viewport: Subviewport,sprite3D: Sprite3D)
        <code that permanently redraws the texture of the sprite3D to whatever was in viewport's view>

There is anThe obvious solution ofis saving the "Viewport"viewport view" as a .png and then assigning the .png to Sprie3Dthe Sprite3D's texture. However, it is computationally slow and takes extra space, creates extra files, i.e. a mess and I'd rather avoid it. I've

I've also tried creating a new .new() Texture2DTexture2D and then assigning the viewport texture to it like so:

newTex = Texture2D.new()
newTex = someViewport.get_texture()

It obviously did not work. Any tips?

Assume there is a viewport that "looks" at some Sprite2D. This viewport's view is providing the texture for Sprite3D by:

Sprite3D.texture = spriteViewport.get_texture()

It works fine, and Sprite3D looks exactly like Sprite2D.

Tis effectively makes the Sprite3D's texture a "dynamic" one: if Sprite2D changes (or anything in the view of the Viewport changes) these changes will be immediately reflected on Sprite3D.

While this is an intended behaviour of ViewportTexture I would like to know if there is a way to make a "one and done" snap of that Viewport's view. To render the dynamic ViewportTexture to a static Texture2D so that any subsequent changes in the Viewport do not affect the Sprite3D anymore. Ideally without the use of resources or .png workarounds and in a form of a function akin to:

func updateTexture(viewport: Subviewport,sprite3D: Sprite3D)
        <code that permanently redraws the texture of the sprite3D to whatever was in viewport's view>

There is an obvious solution of saving the "Viewport view" as a .png then assigning the .png to Sprie3D texture. However, it is computationally slow and takes extra space, creates extra files, i.e. a mess and I'd rather avoid it. I've also tried creating a .new() Texture2D then assigning the viewport texture to it like so:

newTex = Texture2D.new()
newTex = someViewport.get_texture()

It obviously did not work. Any tips?

Assume there is a viewport that "looks" at some Sprite2D. This viewport's view is providing the texture for a Sprite3D by:

Sprite3D.texture = spriteViewport.get_texture()

It works fine, and the Sprite3D looks exactly like Sprite2D.

This effectively makes the Sprite3D's texture a "dynamic" one: if Sprite2D changes (or anything in the view of the viewport changes) these changes will be immediately reflected on Sprite3D.

While this is an intended behaviour of ViewportTexture, I would like to know if there is a way to make a "one and done" snap of that viewport's view. To render the dynamic ViewportTexture to a static Texture2D so that any subsequent changes in the viewport do not affect the Sprite3D anymore. Ideally without the use of resources or .png workarounds and in the form of a function akin to:

func updateTexture(viewport: Subviewport,sprite3D: Sprite3D)
        <code that permanently redraws the texture of the sprite3D to whatever was in viewport's view>

The obvious solution is saving the "viewport view" as a .png and then assigning the .png to the Sprite3D's texture. However, it is computationally slow and takes extra space, creates extra files, i.e. a mess and I'd rather avoid it.

I've also tried creating a new Texture2D and then assigning the viewport texture to it like so:

newTex = Texture2D.new()
newTex = someViewport.get_texture()

It did not work. Any tips?

Source Link
Loading