Handle 'inverse roughness' flag.
This commit is contained in:
parent
d0883136d3
commit
ce2a9f8d85
|
@ -249,7 +249,8 @@ static void ReadMesh(
|
||||||
toVec3f(fbxMatInfo->emissive),
|
toVec3f(fbxMatInfo->emissive),
|
||||||
fbxMatInfo->emissiveIntensity,
|
fbxMatInfo->emissiveIntensity,
|
||||||
fbxMatInfo->metallic,
|
fbxMatInfo->metallic,
|
||||||
fbxMatInfo->roughness));
|
fbxMatInfo->roughness,
|
||||||
|
fbxMatInfo->invertRoughnessMap));
|
||||||
} else {
|
} else {
|
||||||
FbxTraditionalMaterialInfo* fbxMatInfo =
|
FbxTraditionalMaterialInfo* fbxMatInfo =
|
||||||
static_cast<FbxTraditionalMaterialInfo*>(fbxMaterial.get());
|
static_cast<FbxTraditionalMaterialInfo*>(fbxMaterial.get());
|
||||||
|
|
|
@ -65,9 +65,6 @@ std::unique_ptr<FbxRoughMetMaterialInfo> Fbx3dsMaxPhysicalMaterialResolver::reso
|
||||||
roughness = 1.0f - roughness;
|
roughness = 1.0f - roughness;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: turn this into a normal map through simple numerial differentiation
|
|
||||||
const auto* bumpMap = getTex("bump");
|
|
||||||
|
|
||||||
std::string unsupported;
|
std::string unsupported;
|
||||||
const auto addUnsupported = [&](const std::string bit) {
|
const auto addUnsupported = [&](const std::string bit) {
|
||||||
if (!unsupported.empty()) {
|
if (!unsupported.empty()) {
|
||||||
|
@ -76,6 +73,12 @@ std::unique_ptr<FbxRoughMetMaterialInfo> Fbx3dsMaxPhysicalMaterialResolver::reso
|
||||||
unsupported += bit;
|
unsupported += bit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: turn this into a normal map through simple numerial differentiation
|
||||||
|
const auto* bumpMap = getTex("bump");
|
||||||
|
if (bumpMap != nullptr) {
|
||||||
|
addUnsupported("bump map");
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: bake transparency > 0.0f into the alpha of baseColor?
|
// TODO: bake transparency > 0.0f into the alpha of baseColor?
|
||||||
double transparency = getValue(props, "transparency", 0.0);
|
double transparency = getValue(props, "transparency", 0.0);
|
||||||
const auto* transparencyMap = getTex("transparency");
|
const auto* transparencyMap = getTex("transparency");
|
||||||
|
@ -157,6 +160,7 @@ std::unique_ptr<FbxRoughMetMaterialInfo> Fbx3dsMaxPhysicalMaterialResolver::reso
|
||||||
|
|
||||||
res->texMetallic = metalnessMap;
|
res->texMetallic = metalnessMap;
|
||||||
res->texRoughness = roughnessMap;
|
res->texRoughness = roughnessMap;
|
||||||
|
res->invertRoughnessMap = invertRoughness;
|
||||||
|
|
||||||
res->emissive = emissiveColor;
|
res->emissive = emissiveColor;
|
||||||
res->emissiveIntensity = emissiveWeight;
|
res->emissiveIntensity = emissiveWeight;
|
||||||
|
|
|
@ -35,6 +35,7 @@ struct FbxRoughMetMaterialInfo : FbxMaterialInfo {
|
||||||
const FbxDouble metallic;
|
const FbxDouble metallic;
|
||||||
const FbxDouble roughness;
|
const FbxDouble roughness;
|
||||||
|
|
||||||
|
FbxBool invertRoughnessMap = false;
|
||||||
FbxDouble baseWeight = 1;
|
FbxDouble baseWeight = 1;
|
||||||
FbxVector4 emissive = FbxVector4(0, 0, 0, 1);
|
FbxVector4 emissive = FbxVector4(0, 0, 0, 1);
|
||||||
FbxDouble emissiveIntensity = 1;
|
FbxDouble emissiveIntensity = 1;
|
||||||
|
|
|
@ -276,7 +276,13 @@ ModelData* Raw2Gltf(
|
||||||
},
|
},
|
||||||
"ao_met_rough",
|
"ao_met_rough",
|
||||||
[&](const std::vector<const TextureBuilder::pixel*> pixels) -> TextureBuilder::pixel {
|
[&](const std::vector<const TextureBuilder::pixel*> pixels) -> TextureBuilder::pixel {
|
||||||
return {{(*pixels[0])[0], (*pixels[2])[0], (*pixels[1])[0], 1}};
|
const float occlusion = (*pixels[0])[0];
|
||||||
|
const float metallic = (*pixels[1])[0];
|
||||||
|
const float roughness = (*pixels[2])[0];
|
||||||
|
return {{occlusion,
|
||||||
|
props->invertRoughnessMap ? 1.0f - roughness : roughness,
|
||||||
|
metallic,
|
||||||
|
1}};
|
||||||
},
|
},
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
|
|
@ -234,18 +234,21 @@ struct RawMetRoughMatProps : RawMatProps {
|
||||||
const Vec3f&& emissiveFactor,
|
const Vec3f&& emissiveFactor,
|
||||||
float emissiveIntensity,
|
float emissiveIntensity,
|
||||||
float metallic,
|
float metallic,
|
||||||
float roughness)
|
float roughness,
|
||||||
|
bool invertRoughnessMap)
|
||||||
: RawMatProps(shadingModel),
|
: RawMatProps(shadingModel),
|
||||||
diffuseFactor(diffuseFactor),
|
diffuseFactor(diffuseFactor),
|
||||||
emissiveFactor(emissiveFactor),
|
emissiveFactor(emissiveFactor),
|
||||||
emissiveIntensity(emissiveIntensity),
|
emissiveIntensity(emissiveIntensity),
|
||||||
metallic(metallic),
|
metallic(metallic),
|
||||||
roughness(roughness) {}
|
roughness(roughness),
|
||||||
|
invertRoughnessMap(invertRoughnessMap) {}
|
||||||
const Vec4f diffuseFactor;
|
const Vec4f diffuseFactor;
|
||||||
const Vec3f emissiveFactor;
|
const Vec3f emissiveFactor;
|
||||||
const float emissiveIntensity;
|
const float emissiveIntensity;
|
||||||
const float metallic;
|
const float metallic;
|
||||||
const float roughness;
|
const float roughness;
|
||||||
|
const bool invertRoughnessMap;
|
||||||
|
|
||||||
bool operator==(const RawMatProps& other) const override {
|
bool operator==(const RawMatProps& other) const override {
|
||||||
if (RawMatProps::operator==(other)) {
|
if (RawMatProps::operator==(other)) {
|
||||||
|
|
Loading…
Reference in New Issue