|
From: James W. W. <os...@jw...> - 2009-08-22 16:52:04
|
On Aug 22, 2009, at 1:48 AM, Roger Holmes wrote: > > On 22 Aug 2009, at 01:25, James Walker wrote: > >> I thought I was correctly handling transparency with multiple >> lighting >> passes in QORenderer::Renderer::RenderTransparent, but it turns out >> that >> in some cases it can be visibly incorrect. I'll try to explain a >> simplified scenario. >> >> Suppose we have an nearly-opaque object with color A, and in front of >> that there is a transparent object with color B. There are 2 >> lighting >> passes, contributing brightnesses L and M respectively. Then the >> resulting color value ought to be B*(L+M) + (1-alpha)*A*(L+M). > > For the diffuse component of the lighting, shouldn't that be > alpha*B*(L > +M) + (1-alpha)*A*(L+M) ? I was assuming premultiplied alpha. > As my renderers are pure software ones, I'm not familiar with > glBlendFunc so cannot comment on that but maybe it supports my version > of the formula. Maybe your renderer doesn't have a limit of 8 lights, so you don't need multiple passes. > The specular component is just added on, not being affected by the > alpha. I was omitting specular for simplicity. |