[Feature request] Depth testing or GPU based raycasts

Problem

We are kind of limited in the way we can use raycasting (or ShapeTests as they are called in the natives; I’ll call them raycasts for this post).

These two are basically the only ones being used:

But they are kind of limited in their functionality.

  • Want to ignore more than one entity? Not possible (or using flags e.g. only all objects or all peds)
  • Cannot go through world hitboxes (unless flags specified which ignore all world objects) (e.g. a railing on a balcony that is not an object but has a rectangular hitbox although it is just 3 bars)

Example for the world hitbox issue:
This railing is a solid hitbox. If I use the collision flag to ignore world objects, it will not only go through the railing, but also the wall/floor behind it.


Location:

Suggestion

Wouldn’t it be really cool if we could have one raycast that acts as a depth test? Querying the depth buffer and returning the actual point in the world being rendered? Looking at a fence this would net the pixel position behind it without having to cast a ray and ignoring a giant manually created list of objects.

In general this should be possible (as I have already worked with DirectX and currently in Vulkan), however I don’t know if this is something that can be hooked into FiveM and it would probably take ages for me to get as far into this subject to be able to do it myself.

Use cases

… that I can think of right now:

  • Being able to select objects with disabled collision.
  • Selecting objects behind or inside other objects without ignoring those objects. (e.g. a crate on the backseat of a vehicle)
  • Ignoring two (or more) objects in a raycast without resorting to casting additional rays.

(“selecting” referring mostly to being able to use the ingame cursor to highlight and select objects like can be seen here [Release] ContextMenu v2.0 - Major Update!)

EDIT:
Now that I am writing this, another cool feature would be to be able to ignore certain models entirely and not just a single object. E.g. a raycast that ignores a list of models (like all fences for example).

Closing this since other topic open in Platform Suggestions