jPCT - a 3d engine for Java => Support => Topic started by: Wojtek on February 07, 2010, 01:50:48 am

Title: How LensFlare hiding works?
Post by: Wojtek on February 07, 2010, 01:50:48 am

I was playing a little bit with the LensFlare class. It i a very nice feature :)
I see in the documentation that it is possible to enable hiding of that effect when there is something on a way between camera and light source (in fact it is enabled by default). During my play with that effect I was not able to achieve that and I was even able to see the same behavior on a terrain demo...
The first image shows the sun and lens flare effect:
When I hide behind mountain, the effect is still applied:
Is is a correct behavior? And if yes, how the hiding feature works?

Title: Re: How LensFlare hiding works?
Post by: EgonOlsen on February 07, 2010, 09:14:31 pm
The terrain demo doesn't make use of this feature. To use it, you have to enable it in the lens flare class and the potential blocker object has to have the correct collision mode set (Object3D.COLLISION_CHECK_OTHERS). The algorithm simply casts a ray from the sun to the viewer (or vice versa, depending on the mode). If something blocks the ray, the lens flares will be turned off.