A useful explanation from AnKor.
I've been trying to get a surface with high specular and low reflective values, and I can't seem to figure out how. I can't seem to manipulate them separately anymore. What do I need to do to make it work?
Specular – strength of environment reflections (I suspect in GMAX it is set as Specular Color * Specular Level).
Glossiness – sharpness of sun and environment reflections.
To make existing models look better if Specular > Glossiness then glossiness is increased to match specular to avoid having very strong but blurred reflections (real material don’t usually work this way).
However, it still works vice versa - to get materials with sharp sun highlights, but not reflecting the environment you should set
high glossiness, but
low specular.
If you are doing HEX editing of existing m3d files, I have a correction for the info “Projected Knowledge Base” thread on SOH.
Here what it says now:
- ff ff ff ff specular factor (RGB components plus intensity)
- 00 00 00 43 glossiness, usually goes from 00 00 00 40 to 00 00 00 44
I doubt the last FF in specular has any use, but more importantly my shaders actually ignore the tint of specular and just average its RGB components to get single specular value.
So
FF FF FF FF is the highest specular value (= 255) and thus the strongest environment reflection.
While
00 00 00 FF is the lowest specular value and minimum env reflection (my code will add a bit of reflectivity anyway).
Does it work for you?
If not I will need to check my code – I never actually tried high gloss/low specular combination so maybe it doesn’t work as expected. Just note that our eyes will always see sharp detailed reflection as stronger than a blurred one.
Glossiness is more complex.
That 00 00 00 43 is actually floating point number 128.0 which is high glossiness (my code also multiplies it x1.5 by default).
Note that in this example a special rule I mentioned above will kick in and the glossiness will become = 255 to match specular.
Now, to convert between floating point number and hex bytes you can use this simple site:
http://gregstoll.dyndns.org/~gregstoll/floattohex/
The only inconvenience is that you need to reverse the order of bytes, while keeping the order inside pairs.
Simply speaking 00 00 00 43 becomes 43000000, and 12 34 56 78 becomes 78563412 – you also have to remove whitespace.
Some simple values that mentioned in the thread are:
00 00 00 40 = 2.0 – very low, basically absolutely dull surface – my shaders will almost certainly override it to make shinier.
00 00 00 41 = 8.0 – rough surface
00 00 00 42 = 32.0 – normal shine
00 00 00 43 = 128.0 – highly shiny
00 00 00 44 = 512.0 – very shiny, this will be reduced by my shaders which don’t allow glossiness above 250 (it doesn’t make much sense for normal materials)
For convenience 64.0 will look like 00 00 80 42 in hex, and 16 will be 00 00 80 41.
Finally, my shaders use _s textures (standard or DX9 specific +sr) to adjust
glossiness instead of specular. This is more correct approach used in most modern rendering engines.