Jump to content
  • Advertisement
Sign in to follow this  
gSharq

BF3 Lens flares

This topic is 2310 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to add a similar effect to my engine, but my attempts so far didn't look nearly as good!
I'm able to have a sun occlusion value (0->1) using occlusion queries, my question is how to use that value to drive the effect.

Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Looking at the screenshot, there's probably at least 3 different effects there.
1) The sun's glowing starburst.
2) The octagonal lens flare to the bottom right of the starburst.
3) The 'dirty lens' effect along the bottom of the screen.

For (1), plug your occlusion value into the scale and brightness of the starburst overlay. N.B. there might be multiple overlapping sprites involved here, possibly rotating in different directions.
For (2), it's an overlay placed somewhere along a line that goes through the sun's location and the centre of the screen. It can use the same effect of being scaled/dimmed with occlusion.
For (3), the "specks of dust" are a static (non-moving) overlay which probably isn't directly tied to the sun's occlusion -- instead it's probably driven by the bloom results.

Share this post


Link to post
Share on other sites
Thanks!
for (3), do you mean just scale it with average scene luminance?
Yeah that would be a good starting point. I'm not sure exactly how they do it, so another thing I'd try is to use a blurred version of the scene's lumincance (e.g. like an intermediate bloom result), and I'd also try flipping this bloom-result up-side-down and left-to-right -- so that if the top right of the screen is very bright, then the 'dirt' in the bottom left becomes visible.

Share this post


Link to post
Share on other sites

Thanks!
for (3), do you mean just scale it with average scene luminance?

No, the actual bloom buffer. Looks like it's also flipped/scaled to not occupy the entire screen. As to how it's actually composited, that's an interesting question. It *looks* like it may be alpha-blended (color possibly modulated by bloom color?) with the alpha coming from bloom brightness somehow.

EDIT: I think there's also some extra magic going on with the sun, almost as if they render a lens flare into that buffer somehow.

Share this post


Link to post
Share on other sites
Mainly regarding (3): I get pretty good results doing as follows:
1) Do a 'bright pass' (downscale + threshold)
2) Take the result and flip left-right top-bottom (as Hodgman says)
3) Apply a radial blur to the flipped bright pass
4) Blend this with the original, unflipped bright pass
5) Apply a gaussian blur to the whole thing
6) Upscale and blend with the original image, modulating with a lens dirt texture

I actually apply another threshold at step 2 so that only very bright pixels get 'flipped'. The flipped, radially blurred results give a soft 'pseudo lens flare' which works best when it's made quite subtle (hence the secondary threshold). The lens dirt texture gives the whole thing an organic look and hides any artifacts (e.g. caused by using a low number of samples for the radial blur). I've included the lens texture I made and some examples; I think overall it works better being more subtle.

As for elements (1) and (2): looking closely in BF3 I don't think the lens flare sprites are modulated by the lens dirt texture. Part of me thinks they should be...

Share this post


Link to post
Share on other sites
@TiagoCosta: the geometry for the buddha statuette and the column are available from archive3d.net. The walls of the cornell box I knocked together in 3ds max. I've put the 3DS file up here.

This thread got me thinking about the 'psuedo lens flare' agan and how it might be improved, possibly by modulating it radially by a 1D texture; offsets into the texture are controlled by the camera's rotation. Stylistic, of course, but it might look cool...

Share this post


Link to post
Share on other sites
Sorry for bumping this old thread, but I'm really interested how they made this beautiful starburst.
It don't think it's just static texture blended to the sun's position.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!