New Blinn-Phong with Specular Alpha.
by Azaezel · in Torque 3D Professional · 11/25/2013 (11:37 am) · 10 replies
So one of our artists threw an alpha-enabled specular map at the new blinn-phong system and noticed what he described as banding errors using 8.8.8.8s. Present resolution this end is to alter:
to
to get rid of the wrapping.
As this one strikes me as one of those situations with more than one way to skin a cat, figured I'd go ahead and check with folks to see what methodologies they'd prefer.
// If the gloss map flag is set, than the specular power is in the alpha
// channel of the specular map
if( fd.features[ MFT_GlossMap ] )
meta->addStatement( new GenOp( " @ = @.a * 255;\r\n", new DecOp( specPow ), specCol ) );
elseto
// If the gloss map flag is set, than the specular power is in the alpha
// channel of the specular map
if( fd.features[ MFT_GlossMap ] )
meta->addStatement( new GenOp( " @ = @.a;\r\n", new DecOp( specPow ), specCol ) );
elseto get rid of the wrapping.
As this one strikes me as one of those situations with more than one way to skin a cat, figured I'd go ahead and check with folks to see what methodologies they'd prefer.
#2
Ron
11/25/2013 (3:02 pm)
That is interesting. Can't say I have ever run into that issue. I guess I will dig in and see what's going on.Ron
#3
advancedlightingfeatures.hlsl
As far as mitigating the banding. 1's right out since that mangles the rest, 2 (since the non-maped specular power listed is 128) leaves the least ammount of stepping.
11/25/2013 (3:10 pm)
After a bit more poking, it seems to be more related to:advancedlightingfeatures.hlsl
void DeferredPixelSpecularHLSL::processPix( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
...
// (a^m)^n = a^(m*n)
meta->addStatement( new GenOp( " @ = pow( @, ceil(@ / AL_ConstantSpecularPower)) * @;\r\n",
specDecl, d_specular, specPow, specStrength ) );
...
}and#define AL_ConstantSpecularPower 12.0f
As far as mitigating the banding. 1's right out since that mangles the rest, 2 (since the non-maped specular power listed is 128) leaves the least ammount of stepping.
#4
Ron
11/25/2013 (4:57 pm)
Hmmm, Thanks for the info. I am looking at how things are done and the resource that I was basing all of this off did not take into account a gradient type map. This seems to be the issue in a nutshell.Ron
#5
11/25/2013 (5:04 pm)
That'd be my take on it as well. Not quite sure on the required math for smoothing those out m'self.
#6
Ron
11/25/2013 (8:30 pm)
I think it would be a much finer 'blend' procedure. What we have at the moment is pretty ruff and appears to based on shadow settings. (bane of my existence)Ron
#7
11/26/2013 (7:19 am)
Quote:lol! I think my next game will be completely baked lightmaps - and use the extra fps for really complex models. ;)
(bane of my existence)
#8
Still mulling over how (or even if) to apply specular hardness in addition to an explicit map, but would you say (throwing out all the rest so far):
would meet intent?
11/26/2013 (6:44 pm)
@Ron:Still mulling over how (or even if) to apply specular hardness in addition to an explicit map, but would you say (throwing out all the rest so far):
// (a^m)^n = a^(m*n)
if( fd.features[ MFT_GlossMap ] )
{
meta->addStatement( new GenOp( " @ = pow( abs(@), ceil(@ * @)) * @;\r\n",
specDecl, d_specular, specPow, d_NL_Att, specStrength ) );
}
else
{
meta->addStatement( new GenOp( " @ = pow( abs(@), ceil(@ / AL_ConstantSpecularPower)) * @;\r\n",
specDecl, d_specular, specPow, specStrength ) );
}would meet intent?
#9
11/26/2013 (11:52 pm)
*sigh* and I'd just got done sayin if it wasn't obvious, ask a different question... ceil rounds to the nearest integer.// (a^m)^n = a^(m*n)
if( fd.features[ MFT_GlossMap ] )
{
meta->addStatement( new GenOp( " @ = pow( abs(@), @ / AL_ConstantSpecularPower) * (@*@);\r\n",
specDecl, d_specular, specPow, d_NL_Att, specStrength ) );
}
else
{
meta->addStatement( new GenOp( " @ = pow( abs(@), @ / AL_ConstantSpecularPower) * @;\r\n",
specDecl, d_specular, specPow, specStrength ) );
}
#10
12/02/2013 (4:18 pm)
One issue with the above method I'm mulling over at present before considering turning it into a pull-request: The need to set specularPower[x] to a default of 64 (rectal extraction based on the 128 range presented) for materials with specular masks, but without a glossmap component to prevent over-exposure by default.
Andrew Robinson