From 52ef23d0ecbce240ce2b2b4e0861f29dace844b1 Mon Sep 17 00:00:00 2001 From: Azaezel Date: Tue, 18 Mar 2014 05:52:54 -0500 Subject: [PATCH] clipping the lighting result via ciel was causing banding issues with specular maps with alpha channels. rev2. also addresses the warning: "warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them" since it was coming from the same line --- .../lighting/advanced/glsl/advancedLightingFeaturesGLSL.cpp | 3 ++- .../lighting/advanced/hlsl/advancedLightingFeaturesHLSL.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.cpp b/Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.cpp index 1da348f03..7db07368d 100644 --- a/Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.cpp +++ b/Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.cpp @@ -533,7 +533,8 @@ void DeferredPixelSpecularGLSL::processPix( Vector &component AssertFatal( lightInfoSamp, "Something hosed the deferred features! Can't find lightInfoSample" ); // (a^m)^n = a^(m*n) - meta->addStatement( new GenOp( " @ = pow(d_specular, ceil(@ / @)) * @;\r\n", specDecl, specPow, constSpecPow, specStrength ) ); + meta->addStatement( new GenOp( " @ = pow( abs(@), max((@ / AL_ConstantSpecularPower),1.0f)) * @;\r\n", + specDecl, d_specular, specPow, specStrength ) ); LangElement *specMul = new GenOp( "@ * @", specCol, specular ); LangElement *final = specMul; diff --git a/Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.cpp b/Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.cpp index c2bf42834..9e04f3f76 100644 --- a/Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.cpp +++ b/Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.cpp @@ -479,7 +479,7 @@ void DeferredPixelSpecularHLSL::processPix( Vector &component "DeferredPixelSpecularHLSL::processPix - Something hosed the deferred features!" ); // (a^m)^n = a^(m*n) - meta->addStatement( new GenOp( " @ = pow( @, ceil(@ / AL_ConstantSpecularPower)) * @;\r\n", + meta->addStatement( new GenOp( " @ = pow( abs(@), max((@ / AL_ConstantSpecularPower),1.0f)) * @;\r\n", specDecl, d_specular, specPow, specStrength ) ); LangElement *specMul = new GenOp( "float4( @.rgb, 0 ) * @", specCol, specular );