Highlight where a 3D volume would intersect terrain

Godot Version

4.3

Question

I am attempting to work on a 3D “telegraph” system, where some area on the terrain will be highlighted red (or any arbitrary color; generally red for hostile effects).

If I wish to represent a cubic telegraph, a Decal works. Easy-peasy. It gets projected on the ground, shows over uneven terrain, climbs slopes appropriately, all within its provided bounds.

I wish to emulate that behavior for any arbitrary 3D shape. If I supplied a tetrahedron (triangular pyramid), there should be a triangular telegraph. If the tetrahedron were to sink lower into the ground, the highlighted area would shrink to a proportionally-smaller triangle, matching where the ground is intersecting the provided volume.

My difficulty is in detecting the area to be colored red. My intuition was to add a render pass where I render the depth from the camera, compare the collision volume(s) to the worldspace in said buffer, and color the albedo of each intersected surface. But I do not know how to add a render pass in godot, nor do I know how to calculate whether any given pixel is within a collision volume.

For my purposes, I am mostly looking to work with rectangular boxes, spheres, and cones. The prompt of “any arbitrary shape” may have been a bit over-ambitious, though I do believe it helps convey what I am attempting to accomplish.

Boxes and spheres are convex.

Cones - in a 2d space, I would take a circle and carve out some angle, maybe 60 degrees for a narrow cone, or 210 degrees for a wide cleave. I could also define an inner radius if I wanted to further refine the cone’s shape. I am attempting to create telegraphs like that in 3d by utilizing telegraphs. By this definition, a cone would be convex until I attempt to apply an inner radius, at which point it becomes a concave shape.

If you are familiar with the game Wildstar, that game had highly-advanced telegraph effects like I am attempting to describe here.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.