   "Accumulation Buffer" Question (Deferred Shading paper by nvidia)
  Hello,in the 6800 leagues paper by nvidia about deferred shading they mention an accumulation buffer. The way I understand it, you add up all light stuff for a pixel without albedo and then in the end multiply with the material color.What is the purpose of this? That you save a multiplication for every light?On the other hand this only really works with some floating point buffer which seems to slow stuff down again. I am not sure I understand this correctly. What do you think?   
  Hi, your understanding seems to be correct. Forward rendering is generally O(M*N), where M is the number of objects and N is the number of lights. However, deferred rendering is O(M + N). At first, this might look appealing, but as you mentioned, there's a high upfront constant to rendering to multiple floating point buffers. However, there is generally a cross-over point where deferred shading is faster in certain applications. There's other drawbacks to deferred shading as well, including no good way that I know of to take advantage of MSAA, transparency requires a seperate pass, and you're basically limiting yourself to SM3.0+ hardware at least. What you store in the MRTs is completely up to you, provided its enough information to relight the scene later on.Deferred shading does give you zero overdraw after you build the G-buffer, which is kind of nice, though you could get this with forward rendering by performing a depth-only pass anways, so I don't see it as a major advantage.I think the main advantage to deferred rendering is it decouples visibility determination (ie, what does the camera see) from the lighting and shading of what the camera sees. Whether or not one is faster than the other generally depends on the application.   ;  I'm not completely sure why they do it that way, your guess as to saving a bit of shader math seems as good as any.  Perhaps someone else can shed some light on this.At any rate, in my deferred renderer I add the diffuse and specular and blend the sum into an accumulation buffer (if I'm doing post-processing).  If I'm doing HDR its fp, otherwise its just fixed-point.   ;Quote:Original post by MJPI'm not completely sure why they do it that way, your guess as to saving a bit of shader math seems as good as any.  Perhaps someone else can shed some light on this.At any rate, in my deferred renderer I add the diffuse and specular and blend the sum into an accumulation buffer (if I'm doing post-processing).  If I'm doing HDR its fp, otherwise its just fixed-point.So for what reason are YOU using an accumulation buffer? Do you gain anything from it? What format specifically do you mean by fixed-point? ;  This is something i am just coming too. I think you use accumulation buffer because you want to multiply your diffuse light with your ambient texture and then add the specular light.  Final = Albedo * (Ambient +  DiffuseLight) + SpecularLightI think thats right, if you didnt use an accumulation buffer and modified the albedo texture directly then you would need to start with your albed texture combined with ambient light. If your format is not floating point (eg A8R8G8B8) then you will be losing a lot of precision in the colour.Little side question:  Does anyone use seperate accumulation buffers for specular and diffuse components? because i cant see any other way of doing it.EDIT: fixed a bit   ;Quote:Original post by B_oldQuote:Original post by MJPI'm not completely sure why they do it that way, your guess as to saving a bit of shader math seems as good as any.  Perhaps someone else can shed some light on this.At any rate, in my deferred renderer I add the diffuse and specular and blend the sum into an accumulation buffer (if I'm doing post-processing).  If I'm doing HDR its fp, otherwise its just fixed-point.So for what reason are YOU using an accumulation buffer? Do you gain anything from it? What format specifically do you mean by fixed-point?I use an accumulation buffer for when I'm performing post-processing for HDR, Bloom, Motion Blur, etc.   If I'm not doing any post-processing, I just blend directly into the back-buffer.  Oh and by fixed-point, I mean A8R8G8B8.;Quote:Original post by jrmcvThis is something i am just coming too. I think you use accumulation buffer because you want to multiply your diffuse light with your ambient texture and then add the specular light.  Final = Albedo * (Ambient +  DiffuseLight) + SpecularLightI think thats right, if you didnt use an accumulation buffer and modified the albedo texture directly then you would need to start with your albed texture combined with ambient light. If your format is not floating point (eg A8R8G8B8) then you will be losing a lot of precision in the colour.Little side question:  Does anyone use seperate accumulation buffers for specular and diffuse components? because i cant see any other way of doing it.EDIT: fixed a bitInteresting...I've been doing (Albedo * Ambient) in my first pass, and then (Albedo * Diffuse) + Specular in all my successive passes.  I haven't noticed any problems with that, I'll have to check a few extreme cases.As for your side question, Nvidia suggested using a single RGBA accumulation buffer with your monochrome specular stored in the alpha.  If monochrome specular is no good, you'd need to use two seperate buffers (and I can't imagine performance would be great blending into two buffers simultaneously).  ;Quote:Original post by MJPI use an accumulation buffer for when I'm performing post-processing for HDR, Bloom, Motion Blur, etc.   If I'm not doing any post-processing, I just blend directly into the back-buffer.  Oh and by fixed-point, I mean A8R8G8B8.Well ok, to me it sounded like you where using A8R8G8B8 as an accumulation buffer and I couldn't see that working.But there is not really a connection between post-processing and the accumulation buffer, is it? You could just render to the floating point buffer with the same shaders.   ;Quote:Original post by MJPInteresting...I've been doing (Albedo * Ambient) in my first pass, and then (Albedo * Diffuse) + Specular in all my successive passes.  I haven't noticed any problems with that, I'll have to check a few extreme cases.yeah its the same thing but i think i prefer your way now because you dont split the diffuse and specular in to seperate passes.. much better. :-);Quote:Original post by B_oldQuote:Original post by MJPI use an accumulation buffer for when I'm performing post-processing for HDR, Bloom, Motion Blur, etc.   If I'm not doing any post-processing, I just blend directly into the back-buffer.  Oh and by fixed-point, I mean A8R8G8B8.Well ok, to me it sounded like you where using A8R8G8B8 as an accumulation buffer and I couldn't see that working.But there is not really a connection between post-processing and the accumulation buffer, is it? You could just render to the floating point buffer with the same shaders.Perhaps I've been misleading with the term "accumulation buffer".  I use that in a very general sense, meaning its just a buffer where I store an intermediate image that I use as a source for post-processing.  I'm using Direct3D9, so I don't even have a "proper" accumulation buffer like you have in GL. (I'm assuming you're using GL?)  And for my uses as an intermediate image for post-processing, A8R8G8B8 does work just fine (as long as I'm not doing HDR).  In fact, if floating-point blending isn't available on the GPU (only ATI X1000-series, X2000-series, and Nvidia 8000 series support that, IIRC) then I'm stuck with A8R8G8B8.  It works, because I'm multiplying the diffuse by the albedo in the pixel shader then summing with the specular and outputting the result.  If I had to use my buffer to multiply with the albedo afterwards (as Nvidia suggests), the lack of precision would kill me.   