You will have to write custom shaders for this.
Here’s an example for a standard material and for your case 1:
It’s a bit involved, as you have to overwrite the function calculating the light contribution.
For a point light (and directional light), it is the
computeLighting function. It is called from the
lightFragment include, so basically you have to:
- make your own
customLightFragment include by copying the content of
lightFragment and replace
customComputeLighting - lines 72 to 76 in the PG
- provide an implementation for
customComputeLighting - lines 35 to 69 in the PG. I have copy/pasted the content of the existing
computeLighting function and only changed the lines 44-45
I have used a
CustomMaterial in the PG that makes this relatively easy.
Regarding your point 2 it’s more difficult, you will have to write code that determines if the point to be shaded (
vPositionW) is in the volume or not.