Welcome, Unregistered.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Reply
Old 19-Jul-2010, 13:13   #1
gjaegy
Junior Member
 
Join Date: Mar 2007
Posts: 50
Default premultiplied alpha + HDR/tone map

Hi,

I am currently wondering if premultiplied alpha can still be used when using a full HDR pipeline, where the tone mapping appends at the very end of the frame rendering operation...

My pipeline relies on premultiplied alpha for several stuffs:
- normal 3D objects
- impostors
- low-resolution off-screen particles rendering, kind of impostor, where the content is blit onto the back buffer before tone map

Now, in my opinion, for premultiplied-alpha to produce correct results, it should happen after the tone mapping, and not before.

But then the issue is that it is not possible anymore to tone map at the very end of the pipeline, but each pixel should be tone mapped in the pixel shader...

any thoughts ?
gjaegy is offline   Reply With Quote
Old 20-Jul-2010, 23:58   #2
Andrew Lauritzen
AndyTX
 
Join Date: May 2004
Location: British Columbia, Canada
Posts: 1,090
Default

Quote:
Originally Posted by gjaegy View Post
Now, in my opinion, for premultiplied-alpha to produce correct results, it should happen after the tone mapping, and not before.
Why do you say this? Shouldn't it happen in linear space? Tone mapping should operate on the final colors reaching the camera/eye.
__________________
The content of this message is my personal opinion only.
Andrew Lauritzen is offline   Reply With Quote
Old 21-Jul-2010, 08:12   #3
gjaegy
Junior Member
 
Join Date: Mar 2007
Posts: 50
Default

Hi Andy,

I was wondering because of the way I used to tone map each pixel at the end of the pixel shader, in each shader. Now I use the (more correct and cheaper) way to render all pixels in HDR, and then tone map at the very end, by doing a custom-MSAA resolve once the scene has been fully rendered, and blitting the resolved and tone-mapped pixel onto the back buffer.

However, what I used to do in my main shader (for standard objects) was:
Code:
- render pixel in HDR
- tone map
- premultiply by alpha
- blend onto RT
Now, I am doing the following:
Code:
- render in HDR
- once the scene has been fully rendered, bind the HDR RT
- render a full-screen quad and a custom blit shader
- custom blit shader performs a custom MSAA resolve by tone-mapping each subsample and averaging (paper page 18)
So, basically we don't have the same math, and I was in fact wondering if the second method is still giving correct results...

Below the equation for a given pixel:

method 1:
alpha * (1.0 - exp(-exposure * colour))

method2:
1.0 - exp(-exposure * alpha * colour)

any thoughts ?
gjaegy is offline   Reply With Quote
Old 21-Jul-2010, 17:22   #4
Andrew Lauritzen
AndyTX
 
Join Date: May 2004
Location: British Columbia, Canada
Posts: 1,090
Default

My intuition tells me that all the alpha stuff should be done in linear space since the pre-multiplied RGB portion represents how much color the surface is *adding* (linearly) to the reflected light and the alpha portion represents how much it is occluding (also linearly) from the light behind it. All should be done in linear space (both in terms of gamma and pre-tone map). Thus my intuition is that your second pipeline is more correct.
__________________
The content of this message is my personal opinion only.
Andrew Lauritzen is offline   Reply With Quote
Old 22-Jul-2010, 07:22   #5
gjaegy
Junior Member
 
Join Date: Mar 2007
Posts: 50
Default

Thanks for your answer Andy.

With a bit of hindsight, and seing the equation again, I think you are right.

The blending operation should happen in linear colour space, and therefore the alpha pre-multiplication should also logically take place in linear space.

I will keep an eye on the graphical result for a while, to make sure it also produces good results visually with different scenes.

Thanks for your feedback man !

Greg
gjaegy is offline   Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 00:52.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.