• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Yours3!f

boom

6 posts in this topic

Hi,

I'd like to implement the bloom effect. I already have the lighting result in a rgba16f texture, and I can already do an efficient gaussian blur. I've already implemented a filmic tone mapping too.
My question is that how do I do the bloom effect?

My thoughts were the following after reading some:
1. blur the shading result (2 passes, hori, vert )
2. downsample
3. combine the 4 + 1 (original) textures using screen blending
4. tonemap

to add, how can I downsample the texture efficiently (1 pass, maybe) ?

best regards,
Yours3!f
0

Share this post


Link to post
Share on other sites
Usually you down-sample before blurring, simply to get a bigger blur radius for cheaper. To downsample, just draw a full-screen quad textured with your original texture, and make sure you're using linear filtering ([i]not nearest/point filtering![/i]).

Often bloom effects also include a "threshold" pass, so that the effect is only applied to "bright" pixels. You can do this during your downsample pass by simply subtracting a uniform variable from the texture sample -- e.g. [font=courier new,courier,monospace]texture2D(....) - 6.0f[/font] would make it so that only objects brighter than "6 brightness" will glow.

One issue with "screen" blending is that it only works for non-HDR textures -- i.e. "screen" requires all the values to be from 0.0 to 1.0. So you can either replace this with a simple additive blend, or you can perform the "screen" blend after tonemapping ([i]you might have to tonemap the scene, and also tone-map your blurred bloom data[/i]).
2

Share this post


Link to post
Share on other sites
[quote name='Hodgman' timestamp='1345631789' post='4972145']
Usually you down-sample before blurring, simply to get a bigger blur radius for cheaper. To downsample, just draw a full-screen quad textured with your original texture, and make sure you're using linear filtering ([i]not nearest/point filtering![/i]).

Often bloom effects also include a "threshold" pass, so that the effect is only applied to "bright" pixels. You can do this during your downsample pass by simply subtracting a uniform variable from the texture sample -- e.g. [font=courier new,courier,monospace]texture2D(....) - 6.0f[/font] would make it so that only objects brighter than "6 brightness" will glow.

One issue with "screen" blending is that it only works for non-HDR textures -- i.e. "screen" requires all the values to be from 0.0 to 1.0. So you can either replace this with a simple additive blend, or you can perform the "screen" blend after tonemapping ([i]you might have to tonemap the scene, and also tone-map your blurred bloom data[/i]).
[/quote]

thanks Hodgman :)

then I'll simply use additive blending, I just thought that screen blending works better, because it preserves more details in the highlights. But I don't want to do 4 tonemapping passes.
I understand the threshold part, but how do I decide which parts to blur? obviously the threshold must be >1.0 because 0...1 is the usual range. what is an ideal value?
for example I'm using the filmic tonemapping from uncharted 2 ([url="http://filmicgames.com/Downloads/GDC_2010/Uncharted2-Hdr-Lighting.pptx"]http://filmicgames.com/Downloads/GDC_2010/Uncharted2-Hdr-Lighting.pptx[/url]) from slide 142, and it sets some kind of white point (11.2), and I'm curious how do they set it... is it the same thing? To add can this be set automatically?
One more question about the downsampling, if I render it to a linear filtered texture then the resolution will be the same, right? So how do I get the 4 textures? (half-size, quater-size etc.)
0

Share this post


Link to post
Share on other sites
[quote name='Yours3!f' timestamp='1345637138' post='4972165']I just thought that screen blending works better, because it preserves more details in the highlights[/quote]Yes this is true, but unfortunately the function is only valid if you're doing post-processing on "regular" 0-1 range images, not HDR images.
N.B. you could also choose to do your post-processing after tone-mapping, which is less physically correct but much cheaper. If you read about games using "screen" blending for their bloom, it means they are compositing their bloom after tone-mapping.[quote]But I don't want to do 4 tonemapping passes[/quote]Where does '4' come from? You've got 1 bloom result and 1 regular scene that need to be combined.[quote]I understand the threshold part, but how do I decide which parts to blur?[/quote]The threshold determines which parts of the image will 'bloom' (as they become black). You still blur these black areas, but later when blending them back into the image they have no effect.[quote]obviously the threshold must be >1.0 because 0...1 is the usual range. what is an ideal value?[/quote]There's no such thing as a "usual" range in HDR. The whole scene might be from 100 to 1,000, with a few bright objects that are 1,000,000 and some dark objects that are 0.001. If you're basing it on real-life values, the human eye normally deals with brightness levels that differ by a factor of 10,000x.
You'll have to experiment to find what is a good threshold for your scene, depending on how bright your lights are, etc... it's an artistic choice.[quote]One more question about the downsampling, if I render it to a linear filtered texture then the resolution will be the same, right?[/quote]Linear filtering is a property of the input texture sampler, not the output render target. To downsample by half, you render to a half-sized output render-target, while fetching from a full-sized input texture ([i]with linear filtering on this input texture sampler[/i]).
0

Share this post


Link to post
Share on other sites
[quote]Where does '4' come from? You've got 1 bloom result and 1 regular scene that need to be combined.[/quote]
I'm not sure, but I think I've read somewhere that I downsample 4 times, then blur each then combine. (or not exactly in this order) this way the blur radius will be much bigger.

[quote]The threshold determines which parts of the image will 'bloom' (as they become black). You still blur these black areas, but later when blending them back into the image they have no effect.[/quote]
ok thanks

[quote]There's no such thing as a "usual" range in HDR. The whole scene might be from 100 to 1,000, with a few bright objects that are 1,000,000 and some dark objects that are 0.001. If you're basing it on real-life values, the human eye normally deals with brightness levels that differ by a factor of 10,000x.
You'll have to experiment to find what is a good threshold for your scene, depending on how bright your lights are, etc... it's an artistic choice.[/quote]
yeah I've read about that too, I just thought it may make sense to decide on this. Is it a good idea to let the artist keyframe it (per scene) ?

[quote]Linear filtering is a property of the input texture sampler, not the output render target. To downsample by half, you render to a half-sized output render-target, while fetching from a full-sized input texture ([i]with linear filtering on this input texture sampler[/i]).[/quote]
oh I got that wrong, I was thinking about the reading too, not the writing.

so just to make sure that I got downsampling right:
I should render the input texture to a half-res texture (using half res viewport), then blur that, then upsample and combine right?
0

Share this post


Link to post
Share on other sites
[quote name='Yours3!f' timestamp='1345640625' post='4972186']
I'm not sure, but I think I've read somewhere that I downsample 4 times, then blur each then combine. (or not exactly in this order) this way the blur radius will be much bigger.
[/quote]Ok that makes sense now. Yeah there's a few ways you can do this:
e.g. if you only want one bloom result:
* Downsample (to half) -> blurH-> blurV-> downsample (to quarter)-> blurH-> blurV-> composite
* Downsample (to half) -> downsample (to quarter)-> blurH-> blurV-> blurH-> blurV-> blurH-> blurV-> composite
etc... each will give a different look, so experiment [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
So you can play with: number of times you downsample, number of times you blur each 'level', and the blur-radii used for each blur -- a lot of tweakables!
You can also try compositing together some of the different blur levels, before the final compositing with the scene -- I guess that's what you were thinking about with needing 4 tonemapping passes, if you wanted to screen-blend 4 'levels' of HDR bloom together ([i]instead of just using the final 'level', which is what I was originally thinking of[/i]).
[quote name='Yours3!f' timestamp='1345640625' post='4972186']
I should render the input texture to a half-res texture (using half res viewport), then blur that, then upsample and combine right?
[/quote]Yep - and if you want another 'level' of bloom, you can render your half-res to a quarter-res, and so on.
There's no need to upsample before combining though -- it will give you the same result either way, so you may as well skip the upsampling step ([i]and simply have the compositing shader read from the low-res bloom texture[/i])[quote name='Yours3!f' timestamp='1345640625' post='4972186']Is it a good idea to let the artist keyframe it (per scene) ?[/quote]It depends on the game. If it's a huge open world game with a huge variety of scenes, you may have to just pick 1 value, or try and make it dynamic ([i]e.g. tie it to average screen luminance or something[/i]). If it's a game with more controlled scenes, e.g. a typical first-person shooter based in corridors, then you could let your artists/level designers control it. Edited by Hodgman
2

Share this post


Link to post
Share on other sites
[quote]Ok that makes sense now. Yeah there's a few ways you can do this:
e.g. if you only want one bloom result:
* Downsample (to half) -> blurH-> blurV-> downsample (to quarter)-> blurH-> blurV-> composite
* Downsample (to half) -> downsample (to quarter)-> blurH-> blurV-> blurH-> blurV-> blurH-> blurV-> composite
etc... each will give a different look, so experiment [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
So you can play with: number of times you downsample, number of times you blur each 'level', and the blur-radii used for each blur -- a lot of tweakables!
You can also try compositing together some of the different blur levels, before the final compositing with the scene -- I guess that's what you were thinking about with needing 4 tonemapping passes, if you wanted to screen-blend 4 'levels' of HDR bloom together ([i]instead of just using the final 'level', which is what I was originally thinking of[/i]).[/quote]
I chose the first method as 4 blurs < 6 blurs in terms of rendering const. It looks great, so I guess I'll stick to it. I don't really want to overdo bloom. I think I'll play with this when I'll have more time. Yep that's what I was thinking about.

[quote]Yep - and if you want another 'level' of bloom, you can render your half-res to a quarter-res, and so on.
There's no need to upsample before combining though -- it will give you the same result either way, so you may as well skip the upsampling step ([i]and simply have the compositing shader read from the low-res bloom texture[/i])[/quote]
yeah I meant upsample as reading from lower res texture.

[quote]It depends on the game. If it's a huge open world game with a huge variety of scenes, you may have to just pick 1 value, or try and make it dynamic ([i]e.g. tie it to average screen luminance or something[/i]). If it's a game with more controlled scenes, e.g. a typical first-person shooter based in corridors, then you could let your artists/level designers control it.[/quote]
ok, then I think I'll let it be configurable, and then the artists will decide if they want it or not.

thanks again this worked like charm :)
btw is there a way to reduce the number of passes?
now I do 7:
-use fbo #1 to downsample input texture to tex #1
-use fbo #2 to blur tex #1 horizontally to tex #2
-use fbo #1 to blur tex #2 vertically to tex #1
-use fbo #3 to downsample tex #1 to tex #3
-use fbo #4 to blur tex #2 horizontally to tex #4
-use fbo #3 to blur tex #4 vertically to tex #3
-use the input texture, tex #1 and tex #3 to combine them (and tonemap and gamma correct the result)
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0