diff options
author | Oz Linden <oz@lindenlab.com> | 2013-02-04 09:38:06 -0500 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2013-02-04 09:38:06 -0500 |
commit | 68ec77127b158f0abffb6160eb7d870c85b278ad (patch) | |
tree | ad43a05bb4a45449d27f4c077ef8ca653f35d7b9 /indra/newview/pipeline.cpp | |
parent | 19233999edfd143d0e7f8e3743dc07455d206172 (diff) | |
parent | 7cc7ae873c5aeca9b5939176fb70677365e25395 (diff) |
merge tonyas loop fixes
Diffstat (limited to 'indra/newview/pipeline.cpp')
-rw-r--r-- | indra/newview/pipeline.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 07246391e3..ea7de6f399 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1262,31 +1262,26 @@ void LLPipeline::createLUTBuffers() U32 lightResY = gSavedSettings.getU32("RenderSpecularResY"); F32* ls = new F32[lightResX*lightResY]; //F32 specExp = gSavedSettings.getF32("RenderSpecularExponent"); // Note: only use this when creating new specular lighting functions. - // Calculate the (normalized) Gaussian specular lookup texture. (with a few tweaks) + // Calculate the (normalized) blinn-phong specular lookup texture. (with a few tweaks) for (U32 y = 0; y < lightResY; ++y) { for (U32 x = 0; x < lightResX; ++x) { ls[y*lightResX+x] = 0; F32 sa = (F32) x/(lightResX-1); - F32 spec = (F32) y/(lightResY); - F32 n = spec; + F32 spec = (F32) y/(lightResY-1); + F32 n = spec * spec * 368; - float angleNormalHalf = acosf(sa); - float exponent = angleNormalHalf / ((1 - n)); - exponent = -(exponent * exponent); - spec = expf(exponent); + // Nothing special here. Just your typical blinn-phong term. + spec = powf(sa, n); // Apply our normalization function. - // This is based around the phong normalization function, trading n+2 for n+1 instead. - // Since we're using a gaussian model here, we actually don't really need as large of an exponent as blinn-phong shading. - // Instead, we assume that the correct exponent is 8 here. - // This was achieved through much tweaking to find a decent "middleground" with our specular highlights with the gaussian term. - // Bigger highlights don't look too soft, smaller highlights don't look too bright, and everything in the middle seems to have a well maintained highlight curvature. - // There isn't really much theory behind this one. This was done purely to produce a nice and mostly customizable BRDF. - - spec = lerpf(spec, spec * (n * 8 + 1) / 4.5, n); + // Note: This is the full equation that applies the full normalization curve, not an approximation. + // This is fine, given we only need to create our LUT once per buffer initialization. + spec *= (((n + 2) * (n + 4)) / (8 * F_PI * (powf(2, -n/2) + n))); + // Since we use R16F, we no longer have a dynamic range issue we need to work around here. + // Though some older drivers may not like this, newer drivers shouldn't have this problem. ls[y*lightResX+x] = spec; } } |