• 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

understanding theory of bloom effect

2 posts in this topic

hey all.

i want to implement a bloom effect similar to the one described by [url="http://kalogirou.net/2006/05/20/how-to-do-good-bloom-for-hdr-rendering/"]this guy[/url].
i do understand the basic principle of what he is doing, since it seems fairly easy to understand and to implement, but im not sure about the technical details.
seems to me, unless you have a card with an awesome fill rate, this method is rather expensive. but maybe it isn't, or i'm just not doing it right.

so this is how i would generate the bloom texture:

[list][*]i do a regular render of my scene to a texture 'SCENE'. to keep this example easy, lets say i have a square screen with 1024x1024 resolution. *without* the bloom effect, i would now simply render a screen filling quad with this texture to the backbuffer and advance the swapchain, displaying the scene on screen. at the moment, this is also the status quo for my code.[*]however, now i want to generate a bloom texture based on the SCENE texture. so i go and render the SCENE screen quad to another texture BRIGHTPASS (by 'screen quad' im talking of normalized device coordinates, obviously, just something that fills the rendertarget) the size of BRIGHTPASS is only 1/64 of SCENE: 128x128. the pixelshader for this pass has to look something like this (pseudocode):[/list][indent][code]
sample all texels from (x-blursize,y) to (x+blursize,y) {
if (luminance is above a certain value) //probably something like (texel.r+texel.g+texel.b > 2.4)
accumulate the contribution in color, multiplied by the gauss blur constant for that texel
normalize color in respect to samples taken
return color

this would yield a brightpass and a horizontal blur
[/indent][list][*]now render to yet another texture BLUR1 applying a vertical blur (size of BLUR1 128x128)[*]at this point BLUR1 should contain a downscaled, brightpass filtered and blurred texture.[*]repeat this process for 2 other rendertargets with the sizes 256x256, BLUR2, and 512x512 BLUR3[*]render SCENE, then blend in BLUR1 to BLUR3 additively (which are all now mapped to a screen filling quad), using linear filtering or such to magnify[*]drink a beer[/list]its probably quicker to do the brightpass only once for a 512x512 unblurred texture, then use this texture as the base for the BLUR1~3 textures. should save a lot of conditionals, the extra mul and add of scalar values should be faster, esp. since one of the factors is constant. however, this whole thing looks *awfully* slow ans expensive, and im not sure the author in the link i posted was talking about doing it this way.
would be nice if anyone could comment on this. dont care too much about the numbers used, they are more or less arbitrary, im more interested if the m.o. is correct. if you have got a completely different method of doing a nice bloom/glare effect that is even way more awesome than this feel free to post :) realism is not necessary, im more interested in speed, and, to a degree, in flexibilty considering the parameters (like the strength of the glare, scalability of the speed/quality tradeoff).

and yes, i do intend to drink a beer EVERY FRAME.


Share this post

Link to post
Share on other sites
A modern GPU will tear through a few low-res guassian blurs in no time at all, so don't worry about that. I've seen similar implementations to what's described in that article, and they usually work something like this:

1. Render your scene to a 1024x1024 render target
2. Run your threshold pass, rendering to a 512x512 render target
3. Downsample to 256x256
4. Downsample to 128x128
5. Blur the 128x128
6. Blur the 256x256
7. Sum the blurred 256x256 with the blurred 128x128 (can do this doing the last blur step if you want)
8. Blur the 512x512
9. Sum the blurred 512x512 with the blurred 256x256
10. Composite the result with your original scene render target

[quote name='Tasche' timestamp='1318421739' post='4871808']
and yes, i do intend to drink a beer EVERY FRAME.

That's the [i]real[/i] secret to good bloom. :P

Share this post

Link to post
Share on other sites
so, when you say 'summing' or 'blurring' or 'downssample', do you actually mean render passes?

so i first render to severeal different sized rendertargets (512^2 to 128^2), using the initial texture obtained in the threshold pass (the 512x512 one).
then i do horizontal blur passes on all these textures, and verticals too.
in a final render pass i sum up all the textures obtained in these render passes.
so i end up with (in this example) 1 threshold pass + 3 passes for the different sizes + 3 horizantal + 3 vertical + 1 final summing pass = 11 render passes

im just making sure i understand this correctly, since this seems like a lot of render passes... i do realize they should be rather fast since you just have a single quad as geometry every pass. i also realize that this can be optimized by doing two steps in a single pass (vertical blur + summing can always be done in a single step, as you mentioned in your post, reducing the count by another pass). im not sure if this works how i think it does, but binding multiple rendertargets (i'm using dx11) should also cut the generation of the unblurred textures from 3 to 0, as they can be filled when the threshold texture is being rendered. this would still leave 1 threshold pass + 3 horizontal + 3 vertical+summing + 1 composite with original = 8 passes.

now, i've got no idea about this at all, but one could probably use compute shaders for the blurring, since all of it happens in video memory anyway, and you dont have the overhead of running the whole render pipeline. but like i said, i have got no idea what compute shaders actually do and if they are useful in this context, but might be a good exercise to learn about this maybe? but i want to get a low performance bloom shader working first, of course :)

thanks for the help (again), MJP

[quote name='MJP' timestamp='1318444033' post='4871942']
That's the [i]real[/i] secret to good bloom. :P

hehe, then i must be an awesome game programmer :)

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