More DrawBlankLight natives (DrawVolumetricSpotLight, DrawCapsule)

At the moment the game has the following natives:
DRAW_SPOT_LIGHT
DRAW_SPOT_LIGHT_WITH_SHADOW
DRAW_SPHERE
DRAW_LIGHT_WITH_RANGE (Point Lights)
DRAW_LIGHT_WITH_RANGE_AND_SHADOW

These are nice however there are some holes:

  • You cannot do volumetric lights at all
  • You cannot do capsule lights at all
  • You cannot do emitted textures

You can get by with using SetObjectLightColour but it’s performance can get to catastrophic levels of eating 3ms per frame just for setting about two dozen lights colours as it iterates over every single active light instance in the entire scene for every call. This is bad enough that rockstar staggers it to a very visible degree in GTA Online.

Things you cannot do as is:

  • Smooth spotlight radius adjustments (unless you want to make 50 props with different parameters and create/destroy them every frame (this would stink))

In the interest of making some highly programmable lights, the best avenue i can see is just offloading this to one frame natives that draw it with the appropriate parameters as needed. From what i could gather the logic is fairly modular and it should probably be doable to add these without too much trouble. Only thing that might be iffy is the emitted textures which is not make or break.

Mainly, i just want to be able to control volumetric spot lights. and maybe draw capsules to emit some light from some other types of fixtures.

Clips for reference of what i want to do but cant really go too far with due to limitations or performance concerns:
Below eats 3ms a frame and i would love to do more than this, i also cannot tweak the volumetric parameters or the radius at all. And im sure this would be even worse on lower end PCs and thats not even accounting the render toll this already would take.

2 Likes

This is a nice suggestion, I already tried adding the DrawVolumetricSpotLight but I didn’t finish it because I got some errors, hope someone can start with this or I’ll try again another time.

1 Like

Just started the reverse necessary to accomplish this
I did a fuck tons of natives, but it’s very flexible

CREATE_LIGHT
DELETE_LIGHT
SET_LIGHT_COORDS
SET_LIGHT_COLOR
SET_LIGHT_DIRECTION
SET_LIGHT_RADIUS
SET_LIGHT_FALLOFF
SET_LIGHT_CONE
SET_LIGHT_HEADLIGHT
SET_LIGHT_AO
SET_LIGHT_CAPSULE_SIZE
SET_LIGHT_FLAGS

For now I did a CREATE / DELETE system with light handle (like ptfx kinda) rather than a per frame DRAW native call.
So you create you light with pos/rgb/intensity/type/flags, then you add or modify anything you want on this light. The way i’m doing it is causing it to draw only the next frame for now.

Not sure if this is the best way to do it honestly, but there are probably too many arguments to do it in a single native “draw” call.

Example with texture projection:

And it’s also possible to add the flag for the volume draw

Still a lot of things to test, and probably needs some feedback from the cfx team to know if this is the right approach.

2 Likes

OooooOoOooO. Very cool. Realistically the creation/deletion approach is probably best for performance and cleanliness. Would also allow some optimizations to avoid native calls when nothing is changing. But this would be extremely powerful. Mildly worried it’ll be too powerful and ill get in over my head but awesome work, seriously!