• Announcements

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.
Followers 0

how to do a brightpass properly

14 posts in this topic

ello, been off the forums (and off my hobby) for a while, now back at it :)

so im trying to write a bloom/glow/whateveryouwantocallit shader for my app along the lines of this page:

http://kalogirou.net/2006/05/20/how-to-do-good-bloom-for-hdr-rendering/

okeys... got stuff working now, still looks kinda crappy :D

parameters used:
-gauss blur sigma: 0.84
-gauss blur domain: -3*sigma to 3*sigma; codomain normalized to sum = 1
-gauss kernel samples: 15 (on all targets)
-highpass filter funtion: inputColor-(0.5,0.5,0.5)
-target sizes: B0:512x256, B1: 256x128, B2: 128:64
-scene texture size: 1280x720
-combine blur targets function: blurAccum = B0+B1+B2
-combine bloomtexture with scene: finalColor = blurAccum*0.5+scene*0.5

EDIT: ha i actually found my old thread:
http://www.gamedev.net/topic/612541-understanding-theory-of-bloom-effect/

that one wasn't quite answered completely so feel free to comment on that too :)

EDITEDIT: updated the original post to reflect the progress Edited by Tasche
0

Share on other sites

Physically, all you need is "input * fraction", but on my last project we used "(input - threshold) * fraction".
If you're working with HDR data, then you should avoid saturate too.

There's a lot of other details that will contribute to how 'sucky' the final effect looks -- e.g.
• are you using HDR inputs? Are the blur passes done with HDR data? Which texture formats are used?
• whether you're compositing the result before or after tone-mapping(if using HDR)
• which compositing function is used.
• how the blurring passes work.

Also, it's quite likely that the 'brightpass' texture will look quite ugly, even if the final effect looks good. You need to evaluate it as a whole.

Edited by Hodgman
0

Share on other sites

ok very nice, thanks alot Hodgman, this is very helpful.

ill post some feedback as soon as i get this done down to the last pass, maybe some screenshots...

as for testing purposes im not using HDR calculations.

actually, all those question in your bullets, thats stuff ive been asking myself too :), except for the blurring used; ill go with the one discribed in the link, maybe use different size kernels.

but il cross those bridges when i get there :P

to add anything to this topic i really need to get the whole effect going first i guess, so ill be posting back on friday probably

again, thx for the input.

cheers,

tasche

0

Share on other sites
okeys... got stuff working now, still looks kinda crappy :D

parameters used:
-gauss blur sigma: 0.84
-gauss blur domain: -3*sigma to 3*sigma; codomain normalized to sum = 1
-gauss kernel samples: 15 (on all targets)
-highpass filter funtion: inputColor-(0.5,0.5,0.5)
-target sizes: B0:512x256, B1: 256x128, B2: 128:64
-scene texture size: 1280x720
-combine blur targets function: blurAccum = B0+B1+B2
-combine bloomtexture with scene: finalColor = blurAccum*0.5+scene*0.5

i played with the values, but not too much (only thing that can be changed in runtime is sigma and domain range, rest is hardcoded atm)
esp. the combining of the blurs and the final add to the scene are probably really lame, but its just preliminary testing
if anyone knows any good values, or how to come up with those other than trial and error, or has anything else to add, feel free to post

EDIT: removed screenshots Edited by Tasche
1

Share on other sites
Don't you need some light areas in your sample image to bring out the bright pass? Also, your last image didn't work (for me)
0

Share on other sites
Don't you need some light areas in your sample image to bring out the bright pass? Also, your last image didn't work (for me)

hm im not sure i understand you correctly, but i have a light source, the sun. effectively, its just a color_of_the_terrain * lightmap_value, nothing too fancy. however if you notice my brightpass calculation, any color with at least one component above 0.5 will write to the highpass texture. i was just too lazy to post a SS, but the highpass has content. but true, its probably not the best scene to do bloom effect testing on :D

0

Share on other sites
There's no sun in your sample screenshot though, it's a fairly mid-dark landscape. If you looked at that in real life, you wouldn't expect any bloom because there are no light areas for the light to bleed through. The whole idea of bloom is give the illusion that light is effectively bleeding out over objects that are occluding the light source.

Think of standing in a room with a window and looking at the sun, the light from the sun will appear to bloom over the edges of the window. The idea is that you bright pass your scene to mask out areas darker than your brightness threshold, apply a blur to that bright pass and then modulate it with the original scene. Is that what you're trying to achieve?
0

Share on other sites
Sorry, my post sounds like I'm assuming you don't know what you're doing, that's not the case...
0

Share on other sites

okeys, i removed the screenshots because ppl kinda got hung up on those, they were actually just meant for ppl who are bored :)

what i actually wanted to hear are some comments on the used parameters and functions, if anyone cares to comment.

especially interested in comments from people who have tried doing bloom in their project, since they must have faced the same questions (more or less)

i am still aware that in the end, its a matter of taste, i'm just interested in seeing how other people decided on those things.

also, maybe the mod (Hodgman) maybe wants to give me some good links on where (and if) to use HDR (like some pros and cons, or generally how much it actually affects visual quality, stuff i found so far just goes about explaning the technique, not the intended results)

the bold text is for tl;dr :)

0

Share on other sites

I've tried a few different approaches before, but right now my preferred one is this: don't do a brightpass at all.  Instead, raise the original colour to some power, greyscale the result, then multiply the original colour by that result.  I find that it gives a nice smooth transition between boomed parts of the scene and non-bloomed parts, and preserves the original colour balance perfectly.

2

Share on other sites
I've tried a few different approaches before, but right now my preferred one is this: don't do a brightpass at all.  Instead, raise the original colour to some power, greyscale the result, then multiply the original colour by that result.  I find that it gives a nice smooth transition between boomed parts of the scene and non-bloomed parts, and preserves the original colour balance perfectly.

okeys, this is interesting. so what you suggest is something like this (pixelshader ...pre blur pass pseudo code)?

powColor.r=inColor.r * inColor.r     //i thought of using x^n with n=2 because pow() seems expensive? pls comment on this! :)

powColor.r=inColor.g * inColor.g

powColor.r=inColor.b * inColor.b

greyscale = (powColor.r +.powColor.b +powColor.g)/3    //calculate the arithmetic mean value (i think graphics guys refer to this as luminance, right?)

inColor *= greyscale          //rescale the original color

this results in texture data which can be fed to the rest of the effect pipeline (the blurs and combining) just like the brightpass.

is this what you had in mind? or did i get something wrong?

0

Share on other sites

okeys, even if you didnt mean it the way i interpreted it, it looks *ways* better than my original brightpass, at almost no fps cost at all, even when using pow()

and preserves the original colour balance perfectly.

word

probably the best gain to this method

0

Share on other sites

[quote name='Tasche' timestamp='1357871509' post='5020113']
okeys, this is interesting. so what you suggest is something like this (pixelshader ...pre blur pass pseudo code)?

powColor.r=inColor.r * inColor.r //i thought of using x^n with n=2 because pow() seems expensive? pls comment on this!

powColor.r=inColor.g * inColor.g

powColor.r=inColor.b * inColor.b

greyscale = (powColor.r +.powColor.b +powColor.g)/3 //calculate the arithmetic mean value (i think graphics guys refer to this as luminance, right?)

inColor *= greyscale //rescale the original color

this results in texture data which can be fed to the rest of the effect pipeline (the blurs and combining) just like the brightpass.

is this what you had in mind? or did i get something wrong?
[/quote]

Some notes, this is more like a contrast function than a brightpass, but will work. Luminance is often a weighted sum of RGB like Y = 0.2126 R + 0.7152 G + 0.0722 B, And eventually I believe, that most compilers will optimize the pow function, therefor pow(x,2) will most likely compile to x*x if the compile mean that this one is faster.

0

Share on other sites
Can we see some screenshots of before and after? ;)
0

Share on other sites
I've tried a few different approaches before, but right now my preferred one is this: don't do a brightpass at all.  Instead, raise the original colour to some power, greyscale the result, then multiply the original colour by that result.  I find that it gives a nice smooth transition between boomed parts of the scene and non-bloomed parts, and preserves the original colour balance perfectly.

okeys, this is interesting. so what you suggest is something like this (pixelshader ...pre blur pass pseudo code)?

powColor.r=inColor.r * inColor.r     //i thought of using x^n with n=2 because pow() seems expensive? pls comment on this!

powColor.r=inColor.g * inColor.g

powColor.r=inColor.b * inColor.b

greyscale = (powColor.r +.powColor.b +powColor.g)/3    //calculate the arithmetic mean value (i think graphics guys refer to this as luminance, right?)

inColor *= greyscale          //rescale the original color

this results in texture data which can be fed to the rest of the effect pipeline (the blurs and combining) just like the brightpass.

is this what you had in mind? or did i get something wrong?

You're pretty much correct here, although obviously your code is going to be different to mine; here's my calculation:

return float4 (ColorIn.rgb * pow (abs (max (ColorIn.r, max (ColorIn.g, ColorIn.b))), powerFactor), 1.0f);

If you're concerned about performance of the power function an option is to encode it as a 256x1 floating point texture then do a look up.  In practice I don't find that really necessary.

1

Create an account

Register a new account