I have the following problem. Suppose I have a scene where (I simplify it very much) I have 2 objects: the sun and the planet. The sun, as is the custom of the sun, shines. The planet, of course not. I am skipping the shading issues now. What I want to do is render visible light rays coming out of my sun. So I am writing the code as follows:
from panda3d.core import * from direct.showbase.ShowBase import ShowBase from direct.filter.CommonFilters import CommonFilters loadPrcFileData("", "textures-power-2 none") loadPrcFileData("", "basic-shaders-only #t") base = ShowBase() props = WindowProperties() props.setSize(base.pipe.getDisplayWidth(), base.pipe.getDisplayHeight()) base.win.requestProperties(props) base.setBackgroundColor(0, 0, 0) sun = base.loader.loadModel("ripple") sun.reparentTo(base.render) sun.setPos(-3, 0, 0) planet = base.loader.loadModel("ripple") planet.reparentTo(base.render) planet.setPos(3, 0, 0) filters = CommonFilters(base.win, base.cam) filters.setVolumetricLighting(sun, 32, 0.5, 0.98, 0.1) base.cam.setPos(0, -10, 0) base.run()
(yes, I know suns are usually “a little” bigger than the planets orbiting them)
If we look at the left side (the sun) it is so far so good. But when we look at the right side (planet) we have a problem: the planet casts a “light shadow” from the sun!
Of course, I can try to change the parameters, for example like this:
filters.setVolumetricLighting(sun, 32, 1.0, 0.98, 0.01)
But no matter what I set I land somewhere in between I either still have an unwanted “light shadow” or I have to limit the volumetric lighting to a very modest glow around the sun:
Moreover, it is enough to move the planet object a little and already disturb the fragile balance of the power of volumetric lighting.
So the question is: is there an easy (read: without writing your own shader) way to turn on volumetric lighting only for selected objects? In the relatively modest documentation of this filter, I did not find such a possibility.