Compositor problem

Godot Version

I would like to copy a part of the framebuffer to texture to create a mesh card that is essentially a billboard object from a screen photo of a mesh that is rendered in the scene with the correct lighting etc. Is there a way to do it using the compositor? Can I stencil and scissor out a rectangle surrounding the object and then copy the output to a texture? Can I put a compute shader in the compositor ?

The reason for this is that I could photo graph distant objects from each location then free them up from memory and only display the photo, then figure out how to load in the real mesh at a later time.

You don’t need a compositor for that. You can use a SubViewport. Check the documentation about using them:



Is this what they did in Kingdom Come: Deliverance II?

Thankyou!

I think I can make a subviewport that uses the same environment as the world environment, the demo projects look like a good place to start.

Yeah something like that whats in KCD2 … I am not great at the artistic side of producing billboard and LOD meshes to go with HD models so I need to try render to texture. Otherwise loading up content dynamically in threads is less effective for landscape levels.

This works great, the subviewport has a copy of the world environment and only draws the model. Its just a bit difficult to line up the camera properly, for blending with an actual model. I don’t know how this would be done, possibly from setting the camera projection parameters from the world card coordinates (the card is outside the subviewport).

extends MeshInstance3D

@onready var sub_viewport: SubViewport = $"../SubViewport"




# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	if Input.is_action_just_pressed("Attack2"):
		var img := sub_viewport.get_texture().get_image()

	# Create a texture for it.
		var tex := ImageTexture.create_from_image(img)
		var mat = get_active_material(0)
		mat.albedo_texture = tex
		

Also this only works with bilinear filtering - setting FSR 2.0 causes the billboard to lose the transparency.

He made a good point about using MultiMesh and Y-axis billboarding. For creating the texture, I would personally use Blender, as you can render it straight away without a background for better quality.

I prefer the billboards created in the Godot scene because they are lit properly. There is a problem in that each instance would need seperate textures, so this method can work if from each tile each visible distant model has another billboard.

So for the house, lets say there are tiles of 64 or 32 units, and the billboard is actually four smaller images from the tile corners then each billboard is just the image with interpolated UV’s. The billboards are actve at 128 units distance maybe right down to 64 units.

So then each tile has a list of textures for distant objects, and meshes for close by. The tiles are loaded in a pattern, only updating whete neccessary.

The method requires a large database of images, so memory footprint is large, and render time is small.

Othewise I can create imposters that load up a large texture atlas with all major angles (8 or 16) …these dont look as accurate and cost more memory on GPU, have a longer render time … But on the flip side they also work for multiple objects.

Maybe i could dynamically render and display billboards, but that requires the large mesh is at least temporarily in memory.

Its about several 100 megabytes of mesh and texture data, maybe even gigabytes.

Looking into the docs, I don’t see much about the renderer proxy, which is a massive part of The Witcher 3 REDkit. It’ll be interesting to see how that works out for you with the viewport.

I dont want the computer to get hot…

So I am just going to squeeze everything that can be visible onto the GPU …and use instances. The packed scenes will have imposters to hopefully speed up the render.

This is turning into another chunk loading thread.