| ENBSeries http://enbdev.com/enbseries/forum/ |
|
| Get average image brightness http://enbdev.com/enbseries/forum/viewtopic.php?f=28&t=2250 |
Page 1 of 1 |
| Author: | Marty McFly [ 13 Aug 2013, 20:48 ] |
| Post subject: | Get average image brightness |
Hey guys, I need a fast shader that gives me as output the average brightness of the whole image. I know a few shaders for the luminance of one pixel, but not for all pixels at once. It doesn't have to be 100% accurate, only an approximate Value. I know that the newer enb versions have adaptation stuff to easily get this but since I'm mostly working with old versions who don't have any feature like this, I need a dedicated shader for that, something that gives me 0 for completely black screen and 1 for white screen for example. Thanks in advance, Marty |
|
| Author: | ENBSeries [ 14 Aug 2013, 11:46 ] |
| Post subject: | Re: Get average image brightness |
You need to store data in alpha channel of several pixels. For old videocards with ps_2_0 support only (short shaders), you must draw several pixels with smaller amount of texture reading from screen, then in last step mix them all to single. If shader is 3_0, one pass can be used, but i still recommend several pixels and mix them at last pass. How it's work? In vertex shader resize quad to small vertical (or horizontal) line which is on side of screen (1 pixel size) or draw it in wireframe mode (then clipped will be line on edge). When this pass rendered, for each pixels accumulate average screen pixels from horizon scan. Next step is to read that side line to mix result together in to single pixel (and store it in corner of screen for future usage). If you choose alpha channel for this, those data will not be visible to user, but if you need color, then don't forget to fill black line there at the end. |
|
| Author: | Marty McFly [ 16 Aug 2013, 19:32 ] |
| Post subject: | Re: Get average image brightness |
Ok got it. When I link it with tonemapping and want bright images scaled darker and dark ones brighter, how can I make this more smooth? I mean, that it changes after some seconds and is also smoother, atm it changes every millisecond to different brightness even when the image only changes a little bit (what I expected anyways). |
|
| Author: | ENBSeries [ 17 Aug 2013, 06:12 ] |
| Post subject: | Re: Get average image brightness |
Time dependent can't be created, because textures of previous frames are not passed to shaders and i didn't shader declaration for custom texture of adaptation. At this moment you can only use tricks with bloom shader, it's prepass pixel shader output used to compute adaptation texture (and not just it), so if you ignore bloom and make it's output as value you wish to be average brightness, it will be forced even in time dependent adaptation (but bloom will be corrupted). Not sure, but as i remember it work like that. |
|
| Author: | Marty McFly [ 17 Aug 2013, 08:35 ] |
| Post subject: | Re: Get average image brightness |
ENBSeries wrote: At this moment you can only use tricks with bloom shader, it's prepass pixel shader output used to compute adaptation texture (and not just it), so if you ignore bloom and make it's output as value you wish to be average brightness, it will be forced even in time dependent adaptation (but bloom will be corrupted). With texture you mean that type of textures texColor, texNoise etc? So I basically have to create a new texture whose information is that average brightness and I use that texture in a next pass? |
|
| Author: | ENBSeries [ 17 Aug 2013, 09:55 ] |
| Post subject: | Re: Get average image brightness |
Yes, textures like texColor, they must be not regular textures, but render target textures to draw in to them. Declaring such is impossible in all current versions of the mod, but i said how to trick enbbloom.fx, so for your purpose it's possible. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|