I know volumes are coming to blender shortly, but I know they can be taxing on the computer and will be experimental and CPU only for a while. So, I figured I’d make a fake volumetric lighting cone of sorts. It works really well for simple beams of light.
My setup:
My process:
I know the node setup may seem confusing at first, so let me break it down into its main components. I figure the appearance of a simple visible beam of light is a function of how thick the beam of light is at every point on the surface of the “light cone” in line with the viewers eye, and how far it has traveled. A similar effect has been achieved with the ray length output of the light path node to simulate attenuation and absorption. However, when another object is inside this object with the absorbing material, unrealistic effects result. So, I then figured the appearance of my light cone could be a function of the distance it has traveled, the normals of the “surface” of this cone, and the direction the light cone is facing relative the viewer. The distance is easily achieved by UV unwrapping the cone into a flat grid and mapping a gradient texture from tip to base. This gradient should then be re-mapped using an RGB curves node, where the curve should look like a 1/x[SUP]2[/SUP] function to reasonably accurately model the light falloff. To give the cone the fuzzy edges where the the viewer would be looking through less illuminated volume, I used the facing value of the layer weight node. This makes the center of the cone appear more bright while the edges appear dimmer. This too can be adjusted with an RGB curve node, but I found a blend value of 0.75 in the layer weight node itself works well. However, this results in a problem where the cone appears dimmer as the light beam appears to shine at you or away from you due to the faces of the cone’s surface no longer facing toward the viewer. I corrected that with my third parameter. When I modeled my cone, I assumed the light beam would always be pointing along its local z axis. If I had to re-position the cone, I would apply all transformations in object mode. To achieve the effect itself, I had to determine how the viewer’s point of view compared to the direction the light was shining. If my viewpoint was more parallel with the direction the light was pointing, I wanted the value to be higher, as I would be looking through more illuminated volume. If my viewpoint were perpendicular, I wanted it to be lower, as I would be looking through less of the light cone. This can be achieved by taking the absolute value of the dot product of the direction the light is facing (0,0,1) and the direction of the viewpoint (Incoming value of the Geometry node). To get the absolute value, I had to take the dot product of the view vector again, but this time with the other direction of the light (0,0,-1). Both the dot products were clamped to values between 0 and 1 (This works fine because the incoming value, (0,0,1) and (0,0,-1) are all unit vectors) and then added them together. I wanted this effect to dominate at angles where the viewpoint and direction of light beam were small, but not kill the other effects at larger angles. So, I re-mapped this in an RGB curves node as well, where the graph resembled a negative cosine function, with a minimum value around .25 and a max value of 1. because the beam became so weak at the small angles due to the facing node, I multiplied this effect by 1.5 before then multiplying it with the other 2 effects to create what I like to think of as an intensity map. This intensity map becomes the factor for a mix between an emission shader and a transparent shader. To finalize things, I did not want the beam casting shadows, so I also made the entire shader transparent should it be viewed by a shadow ray.
This cone should then be combined with an actual lamp, spot light or emission object to take care of illuminating other objects properly.
I have attached my .blend file for people to check out.
Comments? questions? concerns? Please let me know. I hope to improve it a bit with some people’s help who are more familiar with this stuff than I.
Thanks
Erik
Attachments
VolumeLightFakeTest.blend (656 KB)