tag:blogger.com,1999:blog-3460906122833508895.post8956868717624290208..comments2024-02-13T00:25:34.752-06:00Comments on Graphic Rants: Deferred rendering 2Brian Karishttp://www.blogger.com/profile/03069330593380092516noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-3460906122833508895.post-58807559992767317262008-11-20T00:20:00.000-06:002008-11-20T00:20:00.000-06:00The pre-pass idea is one that I like. It was more ...The pre-pass idea is one that I like. It was more the formats explicitly that I do not think are feature full enough to support the demands of a high end game. The color for the specular response of a material is based on both the light and the material. A purely red light will not reflect anything but red light. You will be storing only the intensity of this specular response. You also don't really have N.L * Att to use to divide out afterward. You have N.L * Att * lightColor. The result would be (N.H)^c / lightColor which is not going to look right at all. Ignoring color for a moment ((N.H1)^c + (N.H2)^c)^(c/matSpec) != (N.H1)^matSpec + (N.H2)^matSpec. If all your specular exponents are very close to c this will be fine but I would just call that a fixed exponent and not give any variation at all. There is a large difference between a rough highlight and a glossy one and this will break down.<BR/><BR/>As far as adding things in LUV space this is incorrect as well as can be seen in your shots. Adding lights in multiple passes is perceptually correct if it uses RGB linear space. The reason RGB works is because it matches the L (red), M (green) and S (blue) receptors in our eyes. Adding light of these 3 frequencies remains identical to our eyes response as adding the original frequencies themselves. This is the reason monitor phosphors and all sorts of things use the RGB model. There may be other color models that give identical results upon adding as RGB but I don't know what they are. LUV certainly isn't one of them as is demonstrated in your shots.<BR/><BR/>For a production environment I would not choose the formats given to implement pre-pass lighting. I would choose Naughty Dog's method. For further clarification their method wrote out a diffuse color and specular color to 2 different render targets. These were encoded in LogLUV. The adding of the light was done in their 8 light shader and the encoding was after the light was added. Because they stored out the specular exponent in the same buffer as the normals they have this material specific specular exponent to apply to the lighting. There are more render targets required in this versus the other but it is obviously fast enough because they shipped Uncharted with it.Brian Karishttps://www.blogger.com/profile/03069330593380092516noreply@blogger.comtag:blogger.com,1999:blog-3460906122833508895.post-6879614961035116922008-11-18T12:09:00.000-06:002008-11-18T12:09:00.000-06:00I'd like to respectfully disagree about pre-pass b...I'd like to respectfully disagree about pre-pass being non-production ready. Approximating a per-material specular power can be done quite accurately depending on the range of specular powers in the scene. Since the color of a specular highlight is a property of the material, and not the light, so I do not believe that it should be stored during accumulation. <BR/><BR/>The value stored in the specular channel for pre-pass rendering is:<BR/>(N.H)^c * N.L * Att<BR/>Dividing this value by N.L * Att, then raising the result to (c/matSpec) gives a very usable per-material specular value. <BR/><BR/>I implemented a version of the light pass which uses the CIE-LUV color space. There is some discussion about it here: http://www.gamedev.net/community/forums/topic.asp?topic_id=514536Pat Wilsonhttps://www.blogger.com/profile/09248944074292458916noreply@blogger.com