rendering – Learn how to use Subviewports to render a texture for Sprite3D?

rendering – Learn how to use Subviewports to render a texture for Sprite3D?

[ad_1]

Godot 4.2

Background:

In my recreation prototype, I’ve a following participant entity:

enter image description here

Paperdoll2D has a script that dynamically provides the weapon/armor/and so on Sprite2D nodes to the primary sprite to “dress-up” the character in-game, much like this:

enter image description here

The sport is 3D with flat textures used to characterize ingame objects (thinks authentic Doom, Daggerfall and so on).

Drawback assertion:

I would love the Player3D to have such a texture (for cutscenes, third individual and so on). Already, Paperdoll2D node mainly composes a whole 2D texture with geared up gear and whatnot, so it is smart to make use of it to supply a Sprite3D texture.

enter image description here

Suppose the inexperienced define on the picture above is the “Screenshot space”. That space (and solely that space of the 2D display) is rendered to a texture and utilized as a texture to the Sprite3D (non-realtime, solely on demand).

enter image description here

Viewports can be nice for this as a result of they’ll “screenshot” the paperdoll and supply a ViewportTexture to be used in Sprite3D.

Drawback is, to me Viewports have been at all times non-intuitive. Each tutorial on YT and the official Documentation on Viewports lists the next technique to have Viewport really show one thing:

Node StructureNode structure within my game

It really works, however all of the “energetic” nodes (sprites, participant,and so on) should be “inside” the viewport. Additionally it is very unwieldy – any youngsters of the viewport can’t be moved,scaled, rotated, nothing.Furthermore it unnecessarily complicates the tree construction making irritating to work with.

How do I implement this with out having to have the viewport contained in the Player3D node or having to .reparent the Paperdoll2D to the viewport exterior?

[ad_2]

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply