Semi-randomly tweak Phong->PBR conversion.

I stole expressions from Gary Hsu's PBR conversion routines here:

3606e79717/extensions/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows/js/three.pbrUtilities.js

which is experimental enough as it is, but I had gone further into the
domain of madness and uses this with *old* diffuse/specular values, not
PBR specular/glossness.

As a result a lot of old content was coming up with 100% metal values
quite often, which in turn means completely ignoring diffuse when
assembling a new base colour...

I should rip out this whole conversion. But not just now...
This commit is contained in:
Par Winzell 2018-02-04 14:42:57 -08:00
parent 54c3b04fce
commit 20b1bd7051
1 changed files with 5 additions and 6 deletions

View File

@ -701,10 +701,7 @@ ModelData *Raw2Gltf(
/**
* Traditional FBX Material -> PBR Met/Rough glTF.
*
* Diffuse channel is used as base colour. No metallic/roughness texture is attempted. Constant
* metallic/roughness values are hard-coded.
*
* TODO: If we have specular & optional shininess map, we can generate a reasonable rough/met map.
* Diffuse channel is used as base colour.
*/
const RawTraditionalMatProps *props = ((RawTraditionalMatProps *) material.info.get());
diffuseFactor = props->diffuseFactor;
@ -731,7 +728,8 @@ ModelData *Raw2Gltf(
metRoughTex = merge3Tex("rough_met",
RAW_TEXTURE_USAGE_SPECULAR, RAW_TEXTURE_USAGE_SHININESS, RAW_TEXTURE_USAGE_DIFFUSE,
[&](const std::vector<const pixel *> pixels) -> pixel {
const Vec3f specular = pixels[0] ? toVec3f(*pixels[0]) : props->specularFactor;
const Vec3f specular = Vec3f(0.4f, 0.4f, 0.4f) +
0.2f * (pixels[0] ? toVec3f(*pixels[0]) : props->specularFactor);
float shininess = pixels[1] ? (*pixels[1])[0] : props->shininess;
const Vec4f diffuse = pixels[2] ? toVec4f(*pixels[2]) : props->diffuseFactor;
@ -748,7 +746,8 @@ ModelData *Raw2Gltf(
baseColorTex = merge2Tex("base_col", RAW_TEXTURE_USAGE_DIFFUSE, RAW_TEXTURE_USAGE_SPECULAR,
[&](const std::vector<const pixel *> pixels) -> pixel {
const Vec4f diffuse = pixels[0] ? toVec4f(*pixels[0]) : props->diffuseFactor;
const Vec3f specular = pixels[1] ? toVec3f(*pixels[1]) : props->specularFactor;
const Vec3f specular = Vec3f(0.4f, 0.4f, 0.4f) +
0.2f * (pixels[1] ? toVec3f(*pixels[1]) : props->specularFactor);
float oneMinus = 1 - getMaxComponent(specular);