The problem:
1) All the shaders have two shininessMap() functions; one active, one commented out. From my revised shader, out of laziness:
Code: Select all
//float shininessMap(float shininess, vec4 specmap) { return clamp(specmap.a*shininess,1.0,255.0); } // alpha-based shininess modulation
float shininessMap(float shininess, vec4 specmap) // luma-based shininess modulation
{
float temp = dot( specmap.rgb, specmap.rgb );
temp *= 0.333;
return clamp( temp*shininess, 1.0, 255.0 );
}
The second one uses an ad-hoc way of coming up with a shininess value based on the specular color (which in OUR shader has been improved).
But the problem is that, although I have a shininess in the alpha channel of my Tarsus' spec map, I cannot use it until ALL the models in PU have the shininess in spec.alpha !!!
2) Using the spec luma -based, ad hoc function sucks.
Well, in YOUR shaders it is based on spec luma alone, and it super-sucks. In OUR (PU's) new shader, it is based partly on luma, partly on chroma, and has a more quadratic linearity, to great benefit. But it still sucks: The assumption that the more specular a material is, the more shininess it has, is simply wrong, and it shows.
I can come up with many counter-examples, but Klauss has proven to be completely stuck on the idea that this is a generally good assumption, and no matter how much evidence I present to disprove it, months go by and I can't make him see the light. And Klauss is one of the most reasonable people I've ever known, so what are my chances?
Well, all I can do is keep trying...
Examples of low specularity but high shininess materials:
a) Glossy paints. Do you have a white fridge nearby? Go take a look at reflections on it. Do it! They are usually pretty faint; and yet, well defined and sharp. Doesn't have to be white paint. Most glossy paints, of any color, show sharp but dim reflections.
b) Glass: Reflects only 6% of light face-on; but whatever light it does reflect, it does so sharply.
c) Shiny plastics, latex suits, leather boots, and other dielectric materials you can see sharp, yet dim reflections on.
Examples of high specularity, but low shininess, materials:
a) Stainless steel. It has no diffuse color at all. Pitch black in diffuse. And it speculates about 70% of the light that hits it. Yet, it would be very hard and expensive to polish, so most stainless kitchen appliances and pans have very low shininess.
b) Cast aluminium: You've got over 90% specularity. Almost white in specular; black in diffuse; and yet the casting process leaves it with the lowest possible shininess.
c) There's gazillions of examples of materials having shininess dispropotionately low, relative to their specularity. Look at your teflon pan: It hardly has a diffuse component at all, --almost purely specular--; and even if it's not too reflective, its shininess is well below what and ad-hoc formula based on specularity would predict.
Heck, I can even come up with one material that occupies both of the categories above, and tramples the ad-hoc assumption two ways:
Metalized paint. (Remember cars back in the 60's?)
Metalized paint presents two layers of specularity: A faint but sharp, fresnel specularity off the outer surface of the glossy base, kind of "alpha blended with" a high specularity but ultra-low shininess reflection off the randomly oriented surfaces of the metal particles in suspension within the glossy base.
But I've given up trying to argue this point with Klauss. His mind will NOT be changed on this subject. In the end, he always says "Yeah, there are exceptions, but generally it's a good formula...", "don't underestimate it...", etceteras.
And yet, I agree with him that an ad-hoc formula needs to be there as a fall-back, because if you can't convince most artists to put a simple ambient occlusion on their textures, despite the obvious benefits, how many of them will one be able to persuade to produce a shininess map, whose benefit is hard to grasp?
But an ad-hoc formula needs to go beyond looking at the specular color. VERY FAR beyond, to be any good at all. Changing the shader from using spec luma to using dot(specmap.rgb,specmap.rgb)*0.33 was a tremendous improvement; and I have tons of ideas for how to improve the ad-hoc formula by yet about another order of magnitude (such as using a front end, ad-hoc formula for separating dielectrics from non-dielectrics by looking at specular AND diffuse color, and then having one ad-hoc shininess formula for each); but the shader isn't the right place to do this: Instruction count is a primary concern, with shaders, first of all. But more importantly, having the shader do it will continue to deny responsible artists like yours truly the right to use alpha based shininess.
The proposed solution:
What I propose is that an ad-hoc formula be used by the CPU, to automatically generate an alpha channel for the specular texture, IF it finds it missing, and save the supplemented texture with a "Created by the VS engine" signature in the header.
I can use Blender nodes to come up with the algorithm; and then I can write the shininess computation part of the code in c++, if someone more familiar with the engine can do the part of checking for the presence of alpha channel, and reading and writing the texture.
Deal?
EDIT:
And, while we're at it, we could also correct texturing snafus, such as diffuse and specular colors for a given texel adding to more than 1.0 in any of the three channels; and write a corrected specular. There seems to be an overabundance of artists out there that don't understand that a material cannot reflect back more light than it receives...