Are you familiar with shadertoy? A lot of examples there use signed distance fields and Ray marching. I think it is aplicable. Otherwise you could slice through your function with a plane. Possibly also stack planes and mimick volumes.
As @pailhead said it can be done with ray marching, but if the light should be affected by objects you would need the depth target. Since it’s only light, the resolution can be quite low. Basically it would be similar to deferred lights.
Godrays are very interesting, but I’m looking for the lighting of the object itself, not the lighting of the environment. The intended result is similar to rendering fire: each “particle” is bright and visible, and doesn’t block the light from particles behind: all lights mix up.
One simple approach I imagine is to divide some bounded space into a grid of cubes; then one would require that one cube is visible with a given intensity and color (perhaps Lambert material with emission?) without blocking the “light” from cubes behind.
With ray marching you could archive “volumetric light objects”, not only lighting of the scene, though optimizations should be considered depending on what you’ll use it for. Using a lowres target is one of those, since it’s only light. For example volumetric clouds/smoke/fire etc. can be archived very realistic in this way too, but it’s a rather advanced approach and requires optimizations.
I would go for a particle system to do this. Use additive blend mode. If you want to be clever about it you can simulate the physics in the shader, it took me a few weeks to figure out how to do that type of stuff but it’s pretty great once it begins to work.
Probably, you do get all sorts of exciting effects from the additive blend mode. If each particle contains the whole gradient (black at the edge and the brighter in the center) I think this is what you get as a default if you scatter them around a spherical distribution. (If you need a very specific type of control you can extend the shader to manipulate colors based on position but I would consider that to require quite a bit more studies and work around how shaders work.)
I have not used the proton library myself but it looks to be similar to my own hack.
The example also has the XY-plane, which you can move along Z-axis. It uses the same code for its fragment shader as the code for the points, thus you can kind of to slice the cloud and see how the colors and transparency change in space. Criticism and advice are very welcomed
You might consider a custom shader so the ShaderToy route as those raymarching demos explained above.
Here is one that get’s 0.1 FPS, while other examples might just crash chrome desktop, still there’s something to learn from them. https://www.shadertoy.com/view/XlBSRz
code links here
This one is more about how light penitrates and how shadows are incorporated.
Your looking more for just the length of the ray from surface-in to surface-out for a simple sphere so much easier, but as to the harmonics or orbitals you’ll likely need to compute that weight differently (for extra marks with no geo really). https://www.falstad.com/qmatom/ [check out real combinations and click little circles {vector knobs!} at bottom, also 3d mouse movements]
Still maybe you just have a shape and back to the distance inside geo calculation, so maybe the full concept of ray marching is not needed.
so maybe this is also helpful http://www.chemtube3d.com/orbitals-d.htm
If when the Fragment Shader is triggered you could then render only that ray again with the same scene object geometry with inverted normals, then you’d get the other side’s exit ray location, so you can then calculate the difference in Z from camera and calculate with a log function that gives you the right density for the look you want. Should be faster then the shadows in the above example I suspect.
Wow right I’m getting 22 fps on the samsung note 8. [My desktop is a GTX 780 Ti so that’s odd. I’ll look into it also note its chrome 66. Firefox gets 60 FPS?] Anyway it’s a better example then I thought.
Okay so it seems ShaderToy can have certain shaders that permanently damage the ability to render until restart etc.
I was looking at ones under the search of ‘volume’ and on this second or third page it seems to crash the GL connection of either Firefox or Chrome must be the second one on that page or just all of them on a page loading together is too much. So anyway that’s how the system was damaged and only played 0.1 FPS if I restart Chrome it also gets 60 FPS on that particular one. Alas if I open this page it’s lights out. https://www.shadertoy.com/results?query=volume&sort=popular&from=24&num=12