Page 10 of 10

Lens flare behind objects

Posted: Wed Feb 17, 2010 9:04 pm
by Edwart
hello,

i added the lens flare in my game project.
it looks great, but i have a problem that the lens flare is everytime in front of objetcs.

in the demo, when a model is in front of the sun, the lens flare is disabled.
in my game not. i have everytime the lensflare.

i use the blureffect to.

do you have an idea why the lens flare is everytime visible and not hidden, when an object is in front of the sun?

thanx
edwart

Posted: Wed Feb 17, 2010 9:18 pm
by Dorth
Dunno, but can't you raytrace from camera to "Sun", and disable the effect if the ray collides a non-transparent object in-between?

Posted: Thu Feb 18, 2010 3:14 pm
by Halifax
Dorth wrote:Dunno, but can't you raytrace from camera to "Sun", and disable the effect if the ray collides a non-transparent object in-between?
You could do that, although it's not terribly physically accurate because the flare will completely pop-in and pop-out. The better way to do it would be to render a billboard in the position of the sun with an occlusion query around it, then modulate the intensity of the flare given how many fragments were visible.

Posted: Thu Feb 18, 2010 3:41 pm
by Dorth
A lot of real flare effects pop btw... Or at least, close enough to the human eye.

Posted: Thu Feb 18, 2010 6:46 pm
by DavidJE13
Edwart; the class uses 2 possible methods to check sun visibility. Set the quality to CRUDE and it will do bounding-box checks in the direction of the sun. NORMAL (default) will check the colour at the sun. If it's above 0.9 (i.e ~240) in brightness, the sun is visible, otherwise not.
Both have limitations, and if you look back in this thread you'll see several discussions about better methods which will be added later.
For best results now (easy method), make sure that your obstructing object is dark and your sun is bright, and use normal quality. Also note that it will cause some slowdown.

As Dorth & Halifax said, you may be better off doing the checks yourself and disabling / enabling the effect manually (and change the colour to change the intensity of the flare). Though this is a bit more difficult.

Posted: Mon Feb 22, 2010 10:36 pm
by kulesz
Can't get it to work on 1.7.1.

Changed dimension2di to dimension2du in:

Code: Select all

	IPostProc* ppRenderer = new CRendererPostProc( smgr, dimension2du( 1024, 512 ), true, true, SColor( 255u, 100u, 101u, 140u ) );
	// When setting up the effect, the parameters are:
	// Input, size of output, effect ID (see CEffectPostProc.h for full list), effect parameters (in this case, blur size)
	CEffectPostProc* ppBlur = new CEffectPostProc( ppRenderer, dimension2du( 1024, 512 ), PP_BLUR, 0.01f );
	// Change to a better quality - not all shaders will respect these, but they can be used to hint the rendering standard required.
	ppBlur->setQuality( PPQ_GOOD );
and TextureWrap in some sources:

Code: Select all

mat.TextureLayer[ 1u ].TextureWrap = irr::video::ETC_CLAMP_TO_EDGE;
to:

Code: Select all

mat.TextureLayer[ 1u ].TextureWrapU = irr::video::ETC_CLAMP_TO_EDGE;
mat.TextureLayer[ 1u ].TextureWrapV = irr::video::ETC_CLAMP_TO_EDGE;
and I get nothing, only cleared background.
Did anyone test PP on newest version of engine?

Posted: Tue Feb 01, 2011 2:06 am
by lazerblade
I've patched and tested this to run on Irrlicht 1.7.2 SVN.

Download on mediafire: http://www.mediafire.com/?hfnzc289rm49h4v

P.S:

Sorry to bring up an old thread, I just thought others might be interested in using this as well.

Posted: Tue Feb 01, 2011 2:13 am
by bitplane
Good stuff, thanks! You shouldn't apologise for performing your civic duty!

Posted: Fri Mar 25, 2011 11:39 am
by anoki
this class has great effects ...
Even the class is written a long time ago ...

Thanks for updating it to 1.72

Anoki

Re:

Posted: Tue Sep 18, 2012 7:41 pm
by jorgerosa
lazerblade wrote:I've patched and tested this to run on Irrlicht 1.7.2 SVN.
Download on mediafire: http://www.mediafire.com/?hfnzc289rm49h4v
Url is dead, can someone update the url? Thankyou! :)