   Volumetric spot lights
  I am working on the simulation of volumetric lights. The problem, assuming a medium of constant density, is that of calculating the length of a ray (from the camera to the shaded pixel) crossing a given volume.In the case of spherical point lights, both analytical and approximate solutions exist; for example, I can use the approximation for spherical billboards described in ShaderX 5. Unfortunately I could not find an effective solution for spot lights shaped as a capped cone. The analytical solution consists in calculating the intersection(s) between a ray and a cone and that's too heavy on the math side to be well performing, especially for lights covering a large part of the screen.Anybody got any ideas or code for this problem? Bear in mind that I'm looking for a robust solution that works equally well when the camera is outside and inside the light volume, without abrupt transitions between the two cases, and for all viewing directions.ThanksStefano Lanza   
  Render back and front faces of the cone separately, and use the difference as the length the ray passes through the volume?   ;  harveypekar, I tried it and AFAIR did not receive any good results... Line integral of two functions (cone and sphere attenuation) might help.   ;  I read in shader x something that you could make so many volumetric slats in the vicinity of the shaft, then when rendering each slat you take its world space positions (the corners of each slat) from the point of the cones perspective and you can render a gobo onto it - and itll spread right up from the floor to the light.It looks real pretty and you can add lots of effects but i dont think you could get more than one rendering at once, its pretty gpu intensive.   ;  Hi guys,Thanks for your suggestions but I'm really looking for a simple, analytical formula. I'll stop being lazy and try to come up with one myself, and post it here afterwards.Does anybody know any games or engines which support physically correct volumetric lighting? I'm talking about multiple lights placed inside partecipating mediums of varying density, with scattering affecting both the direct illumination (from light to object) of objects (affecting their diffuse and specular color) and their appearance (from object to viewer). ThanksStefano;  I know Crysis lights up their particles and fog and UE3 uses line integrals to calculate volumetric lighting. So you may start with this.Quote:multiple lights placed inside partecipating mediums of varying density, with scattering affecting both the direct illumination (from light to object) of objects (affecting their diffuse and specular color) and their appearance (from object to viewer).I'm developing the same thing right now in my engine. So I will report about my results.