I plan to spam viewports if they are cheap for every NPCs.

Not a good idea to do that. Although it depends on what they're rendering, viewports can get computationally expensive if you create them unwieldy. Why do you need a viewport for each NPC anyway?

Viewports render the scene and show whatever is visible with the Camera or Camera2D node under the Viewport. So, it is the equivalent of rendering the screen, which can be costly depending on how many you are using and what you are rendering.

That said, Viewports can be set to only render once, which would mean the performance impact would be relatively minor (though there is a memory cost), at the cost of not being able to update the viewport dynamically.

You could also have the Viewport only update when visible, which may save performance here and there and would allow you to dynamically update whatever is in the Viewport, but the scene has to be rendered N+1 many times, where N is the number of visible Viewports. This could lead to performance issues depending on how many you have.

If you can, you probably want to try to find alternative solutions if you need lots of Viewport nodes. Though, as @SIsilicon28 said, it depends on what they are rendering, as well as your use case.

Thank you for answers. The reason I need to use many viewports is because I cannot make 2D Skeletons work in 3d world, IDK I think I need to do more research on 3D Skeleton before execute this solution.

Viewports I don't think will help you with skeletons, those are very different things. However, you can animate 2D characters inside Blender or other software, with 3D bones, just the same as 3D characters (you just never move into or out of the screen).

@cybereality Currently we are trying to execute this solution, but we have hard time import sprites not even rig bones yet, can you teach us how to do that, thank.

Just create a Sprite node and click on the Texture property (in the Inspector on the right) and load an image that has previously been imported into the engine. To import the image, simply copy and paste it into the Godot project folder using your operating system file manager. Hope that helps.

@cybereality Sorry, But I mean in Blender. Anyway, thank for helping on off topic question.

3 years later