Merge pull request #323 from Azaezel/alpha40_smoothToRough_clean

shift pbrconfig to ORM in keeping with the prepoderance of industry standards
This commit is contained in:
Brian Roberts 2020-10-03 11:49:10 -05:00 committed by GitHub
commit 681dbe108c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
55 changed files with 970 additions and 767 deletions

View file

@ -91,7 +91,7 @@ ImplementEnumType(ImageAssetType,
"@ingroup gameObjects")
{ ImageAsset::Albedo, "Albedo", "" },
{ ImageAsset::Normal, "Normal", "" },
{ ImageAsset::PBRConfig, "PBRConfig", "" },
{ ImageAsset::ORMConfig, "ORMConfig", "" },
{ ImageAsset::GUI, "GUI", "" },
{ ImageAsset::Roughness, "Roughness", "" },
{ ImageAsset::AO, "AO", "" },
@ -315,7 +315,7 @@ const char* ImageAsset::getImageTypeNameFromType(ImageAsset::ImageTypes type)
static const char* _names[] = {
"Albedo",
"Normal",
"PBRConfig",
"ORMConfig",
"GUI",
"Roughness",
"AO",

View file

@ -56,7 +56,7 @@ public:
{
Albedo = 0,
Normal = 1,
PBRConfig = 2,
ORMConfig = 2,
GUI = 3,
Roughness = 4,
AO = 5,
@ -128,15 +128,32 @@ typedef ImageAsset::ImageTypes ImageAssetType;
DefineEnumType(ImageAssetType);
#define assetText(x,suff) std::string(std::string(#x) + std::string(#suff)).c_str()
#define scriptBindMapSlot(name, consoleClass) addField(#name, TypeImageFilename, Offset(m##name##Filename, consoleClass), assetText(name,texture map.)); \
#define initMapSlot(name) m##name##Filename = String::EmptyString; m##name##AssetId = StringTable->EmptyString(); m##name##Asset = NULL;
#define bindMapSlot(name) if (m##name##AssetId != String::EmptyString) m##name##Asset = m##name##AssetId;
#define scriptBindMapSlot(name, consoleClass, docs) addField(#name, TypeImageFilename, Offset(m##name##Filename, consoleClass), assetText(name, docs)); \
addField(assetText(name,Asset), TypeImageAssetPtr, Offset(m##name##AssetId, consoleClass), assetText(name,asset reference.));
#define scriptBindMapArraySlot(name, arraySize, consoleClass) addField(#name, TypeImageFilename, Offset(m##name##Filename, consoleClass), arraySize, assetText(name,texture map.)); \
#define initMapArraySlot(name,id) m##name##Filename[id] = String::EmptyString; m##name##AssetId[id] = StringTable->EmptyString(); m##name##Asset[id] = NULL;
#define bindMapArraySlot(name,id) if (m##name##AssetId[id] != String::EmptyString) m##name##Asset[id] = m##name##AssetId[id];
#define scriptBindMapArraySlot(name, arraySize, consoleClass, docs) addField(#name, TypeImageFilename, Offset(m##name##Filename, consoleClass), arraySize, assetText(name, docs)); \
addField(assetText(name,Asset), TypeImageAssetPtr, Offset(m##name##AssetId, consoleClass), arraySize, assetText(name,asset reference.));
#define DECLARE_TEXTUREMAP(name) FileName m##name##Filename;\
#define DECLARE_TEXTUREMAP(name) protected: \
FileName m##name##Filename;\
StringTableEntry m##name##AssetId;\
AssetPtr<ImageAsset> m##name##Asset;
AssetPtr<ImageAsset> m##name##Asset;\
public: \
const String& get##name##() const { return m##name##Filename; }\
void set##name##(FileName _in) { m##name##Filename = _in; }\
const AssetPtr<ImageAsset> & get##name##Asset() const { return m##name##Asset; }\
void set##name##Asset(AssetPtr<ImageAsset>_in) { m##name##Asset = _in; }
#define GET_TEXTUREMAP(name) get##name##()
#define SET_TEXTUREMAP(name,_in) set##name##(_in)
#define GET_TEXTUREASSET(name) get##name##Asset()
#define SET_TEXTUREASSET(name,_in) set##name##Asset(_in)
#define DECLARE_TEXTUREARRAY(name,max) FileName m##name##Filename[max];\
StringTableEntry m##name##AssetId[max];\

View file

@ -61,7 +61,7 @@ AssetImportConfig::AssetImportConfig() :
reverseWindingOrder(false),
invertNormals(false),
ImportMaterials(true),
CreatePBRConfig(true),
CreateORMConfig(true),
UseDiffuseSuffixOnOriginImage(false),
UseExistingMaterials(false),
IgnoreMaterials(""),
@ -160,11 +160,11 @@ void AssetImportConfig::initPersistFields()
addGroup("Materials");
addField("ImportMaterials", TypeBool, Offset(ImportMaterials, AssetImportConfig), "Does this config allow for importing of materials");
addField("CreatePBRConfig", TypeBool, Offset(PreventImportWithErrors, AssetImportConfig), "When importing a material, should it automatically attempt to merge Roughness, AO and Metalness maps into a single, composited PBR Configuration map");
addField("CreateORMConfig", TypeBool, Offset(PreventImportWithErrors, AssetImportConfig), "When importing a material, should it automatically attempt to merge Roughness, AO and Metalness maps into a single, composited PBR Configuration map");
addField("UseDiffuseSuffixOnOriginImage", TypeBool, Offset(UseDiffuseSuffixOnOriginImage, AssetImportConfig), "When generating a material off of an importing image, should the importer force appending a diffusemap suffix onto the end to avoid potential naming confusion.\n e.g. MyCoolStuff.png is imported, generating MyCoolStuff material asset and MyCoolStuff_Diffuse image asset");
addField("UseExistingMaterials", TypeBool, Offset(UseExistingMaterials, AssetImportConfig), "Should the importer try and use existing material assets in the game directory if at all possible. (Not currently utilized)");
addField("IgnoreMaterials", TypeRealString, Offset(IgnoreMaterials, AssetImportConfig), "A list of material names that should not be imported. Separated by either , or ;");
addField("PopulateMaterialMaps", TypeBool, Offset(PopulateMaterialMaps, AssetImportConfig), "When processing a material asset, should the importer attempt to populate the various material maps on it by looking up common naming conventions for potentially relevent image files.\n e.g. If MyCoolStuff_Diffuse.png is imported, generating MyCoolStuff material, it would also find MyCoolStuff_Normal and MyCoolStuff_PBR images and map them to the normal and PBRConfig maps respectively automatically");
addField("PopulateMaterialMaps", TypeBool, Offset(PopulateMaterialMaps, AssetImportConfig), "When processing a material asset, should the importer attempt to populate the various material maps on it by looking up common naming conventions for potentially relevent image files.\n e.g. If MyCoolStuff_Diffuse.png is imported, generating MyCoolStuff material, it would also find MyCoolStuff_Normal and MyCoolStuff_PBR images and map them to the normal and ORMConfig maps respectively automatically");
endGroup("Materials");
addGroup("Meshes");
@ -186,14 +186,14 @@ void AssetImportConfig::initPersistFields()
addGroup("Images");
addField("importImages", TypeBool, Offset(importImages, AssetImportConfig), "Does this configuration support importing images.");
addField("ImageType", TypeRealString, Offset(ImageType, AssetImportConfig), "What is the default ImageType images are imported as. Options are: N/A, Diffuse, Normal, Metalness, Roughness, AO, PBRConfig, GUI, Cubemap");
addField("ImageType", TypeRealString, Offset(ImageType, AssetImportConfig), "What is the default ImageType images are imported as. Options are: N/A, Diffuse, Normal, Metalness, Roughness, AO, ORMConfig, GUI, Cubemap");
addField("DiffuseTypeSuffixes", TypeRealString, Offset(DiffuseTypeSuffixes, AssetImportConfig), "What type of suffixes are scanned to detect if an importing image is a diffuse map. \n e.g. _Albedo or _Color");
addField("NormalTypeSuffixes", TypeRealString, Offset(NormalTypeSuffixes, AssetImportConfig), "What type of suffixes are scanned to detect if an importing image is a normal map. \n e.g. _Normal or _Norm");
addField("MetalnessTypeSuffixes", TypeRealString, Offset(MetalnessTypeSuffixes, AssetImportConfig), "What type of suffixes are scanned to detect if an importing image is a metalness map. \n e.g. _Metalness or _Metal");
addField("RoughnessTypeSuffixes", TypeRealString, Offset(RoughnessTypeSuffixes, AssetImportConfig), "What type of suffixes are scanned to detect if an importing image is a roughness map.\n e.g. _roughness or _rough");
addField("SmoothnessTypeSuffixes", TypeRealString, Offset(SmoothnessTypeSuffixes, AssetImportConfig), "What type of suffixes are scanned to detect if an importing image is a smoothness map. \n e.g. _smoothness or _smooth");
addField("AOTypeSuffixes", TypeRealString, Offset(AOTypeSuffixes, AssetImportConfig), "What type of suffixes are scanned to detect if an importing image is a ambient occlusion map. \n e.g. _ambient or _ao");
addField("PBRTypeSuffixes", TypeRealString, Offset(PBRTypeSuffixes, AssetImportConfig), "What type of suffixes are scanned to detect if an importing image is a PBRConfig map.\n e.g. _Composite or _PBR");
addField("PBRTypeSuffixes", TypeRealString, Offset(PBRTypeSuffixes, AssetImportConfig), "What type of suffixes are scanned to detect if an importing image is a ORMConfig map.\n e.g. _Composite or _PBR");
addField("TextureFilteringMode", TypeRealString, Offset(TextureFilteringMode, AssetImportConfig), "Indicates what filter mode images imported with this configuration utilizes. Options are Linear, Bilinear, Trilinear");
addField("UseMips", TypeBool, Offset(UseMips, AssetImportConfig), "Indicates if images imported with this configuration utilize mipmaps");
@ -251,7 +251,7 @@ void AssetImportConfig::loadImportConfig(Settings* configSettings, String config
//Materials
ImportMaterials = dAtob(configSettings->value(String(configName + "/Materials/ImportMaterials").c_str()));
CreatePBRConfig = dAtob(configSettings->value(String(configName + "/Materials/CreatePBRConfig").c_str()));
CreateORMConfig = dAtob(configSettings->value(String(configName + "/Materials/CreateORMConfig").c_str()));
UseDiffuseSuffixOnOriginImage = dAtob(configSettings->value(String(configName + "/Materials/UseDiffuseSuffixOnOriginImage").c_str()));
UseExistingMaterials = dAtob(configSettings->value(String(configName + "/Materials/UseExistingMaterials").c_str()));
IgnoreMaterials = configSettings->value(String(configName + "/Materials/IgnoreMaterials").c_str());
@ -334,7 +334,7 @@ void AssetImportConfig::CopyTo(AssetImportConfig* target) const
//Materials
target->ImportMaterials = ImportMaterials;
target->CreatePBRConfig = CreatePBRConfig;
target->CreateORMConfig = CreateORMConfig;
target->UseDiffuseSuffixOnOriginImage = UseDiffuseSuffixOnOriginImage;
target->UseExistingMaterials = UseExistingMaterials;
target->IgnoreMaterials = IgnoreMaterials;
@ -439,7 +439,7 @@ void AssetImportObject::initPersistFields()
addField("tamlFilePath", TypeRealString, Offset(tamlFilePath, AssetImportObject), "What is the ultimate asset taml file path for this import item");
addField("imageType", TypeRealString, Offset(imageSuffixType, AssetImportObject), "Specific to ImageAsset type. What is the image asset's suffix type. Options are: Albedo, Normal, Roughness, AO, Metalness, PBRConfig");
addField("imageType", TypeRealString, Offset(imageSuffixType, AssetImportObject), "Specific to ImageAsset type. What is the image asset's suffix type. Options are: Albedo, Normal, Roughness, AO, Metalness, ORMConfig");
addField("shapeInfo", TYPEID< GuiTreeViewCtrl >(), Offset(shapeInfo, AssetImportObject), "Specific to ShapeAsset type. Processed information about the shape file. Contains numbers and lists of meshes, materials and animations");
}
@ -714,7 +714,7 @@ String AssetImporter::parseImageSuffixes(String assetName, String* suffixType)
break;
case 5:
suffixList = activeImportConfig->PBRTypeSuffixes;
suffixType->insert(0, "PBRConfig", 10);
suffixType->insert(0, "ORMConfig", 10);
break;
default:
suffixList = "";
@ -1635,7 +1635,7 @@ void AssetImporter::processMaterialAsset(AssetImportObject* assetItem)
case ImageAsset::Normal:
suffixList = activeImportConfig->NormalTypeSuffixes;
break;
case ImageAsset::PBRConfig:
case ImageAsset::ORMConfig:
suffixList = activeImportConfig->PBRTypeSuffixes;
break;
case ImageAsset::Metalness:
@ -2644,10 +2644,10 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
return "";
}
//build the PBRConfig file if we're flagged to and have valid image maps
if (activeImportConfig->CreatePBRConfig)
//build the ORMConfig file if we're flagged to and have valid image maps
if (activeImportConfig->CreateORMConfig)
{
AssetImportObject* pbrConfigMap = nullptr;
AssetImportObject* ormMap = nullptr;
AssetImportObject* roughnessMap = nullptr;
AssetImportObject* metalnessMap = nullptr;
AssetImportObject* aoMap = nullptr;
@ -2660,8 +2660,8 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
if (childItem->skip || childItem->assetType.compare("ImageAsset") != 0)
continue;
if (childItem->imageSuffixType.compare("PBRConfig") == 0)
pbrConfigMap = childItem;
if (childItem->imageSuffixType.compare("ORMConfig") == 0)
ormMap = childItem;
else if(childItem->imageSuffixType.compare("Roughness") == 0)
roughnessMap = childItem;
else if (childItem->imageSuffixType.compare("Metalness") == 0)
@ -2670,14 +2670,14 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
aoMap = childItem;
}
if (pbrConfigMap != nullptr && pbrConfigMap->generatedAsset)
if (ormMap != nullptr && ormMap->generatedAsset)
{
if (roughnessMap != nullptr || metalnessMap != nullptr || aoMap != nullptr)
{
U32 channelKey[4] = { 0,1,2,3 };
GFX->getTextureManager()->saveCompositeTexture(aoMap->filePath.getFullPath(), roughnessMap->filePath.getFullPath(), metalnessMap->filePath.getFullPath(), "",
channelKey, pbrConfigMap->filePath.getFullPath(), &GFXTexturePersistentProfile);
channelKey, ormMap->filePath.getFullPath(), &GFXTexturePersistentProfile);
}
}
}
@ -2722,9 +2722,9 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
{
mapFieldName = "NormalMap";
}
else if (imageType == ImageAsset::ImageTypes::PBRConfig)
else if (imageType == ImageAsset::ImageTypes::ORMConfig)
{
mapFieldName = "PBRConfig";
mapFieldName = "ORMConfig";
}
else if (imageType == ImageAsset::ImageTypes::Metalness)
{
@ -2784,9 +2784,9 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
{
mapFieldName = "NormalMap";
}
else if (imageType == ImageAsset::ImageTypes::PBRConfig)
else if (imageType == ImageAsset::ImageTypes::ORMConfig)
{
mapFieldName = "PBRConfigMap";
mapFieldName = "ORMConfigMap";
}
else if (imageType == ImageAsset::ImageTypes::Metalness)
{

View file

@ -185,7 +185,7 @@ public:
/// <summary>
/// When importing a material, should it automatically attempt to merge Roughness, AO and Metalness maps into a single, composited PBR Configuration map
/// </summary>
bool CreatePBRConfig;
bool CreateORMConfig;
/// <summary>
/// When generating a material off of an importing image, should the importer force appending a diffusemap suffix onto the end to avoid potential naming confusion.
@ -205,7 +205,7 @@ public:
/// <summary>
/// When processing a material asset, should the importer attempt to populate the various material maps on it by looking up common naming conventions for potentially relevent image files
/// e.g. If MyCoolStuff_Diffuse.png is imported, generating MyCoolStuff material, it would also find MyCoolStuff_Normal and MyCoolStuff_PBR images and map them to the normal and PBRConfig maps respectively automatically
/// e.g. If MyCoolStuff_Diffuse.png is imported, generating MyCoolStuff material, it would also find MyCoolStuff_Normal and MyCoolStuff_PBR images and map them to the normal and ORMConfig maps respectively automatically
/// </summary>
bool PopulateMaterialMaps;
@ -276,7 +276,7 @@ public:
bool importImages;
/// <summary>
/// What is the default ImageType images are imported as. Options are: N/A, Diffuse, Normal, Metalness, Roughness, AO, PBRConfig, GUI, Cubemap
/// What is the default ImageType images are imported as. Options are: N/A, Diffuse, Normal, Metalness, Roughness, AO, ORMConfig, GUI, Cubemap
/// </summary>
String ImageType;
@ -317,7 +317,7 @@ public:
String AOTypeSuffixes;
/// <summary>
/// What type of suffixes are scanned to detect if an importing image is a PBRConfig map.
/// What type of suffixes are scanned to detect if an importing image is a ORMConfig map.
/// e.g. _Composite or _PBR
/// </summary>
String PBRTypeSuffixes;
@ -490,7 +490,7 @@ public:
//
/// <summary>
/// Specific to ImageAsset type
/// What is the image asset's suffix type. Options are: Albedo, Normal, Roughness, AO, Metalness, PBRConfig
/// What is the image asset's suffix type. Options are: Albedo, Normal, Roughness, AO, Metalness, ORMConfig
/// </summary>
String imageSuffixType;

View file

@ -132,7 +132,7 @@ ReflectionProbe::ReflectionProbe() :
mProbeInfo = nullptr;
mPrefilterSize = 64;
mPrefilterMipLevels = mLog2(F32(mPrefilterSize));
mPrefilterMipLevels = mLog2(F32(mPrefilterSize))+1;
mPrefilterMap = nullptr;
mIrridianceMap = nullptr;
@ -645,7 +645,7 @@ void ReflectionProbe::processDynamicCubemap()
if (mCubeReflector.getCubemap())
{
U32 resolution = Con::getIntVariable("$pref::ReflectionProbes::BakeResolution", 64);
U32 prefilterMipLevels = mLog2(F32(resolution));
U32 prefilterMipLevels = mLog2(F32(resolution))+1;
//Prep it with whatever resolution we've dictated for our bake
mIrridianceMap->mCubemap->initDynamic(resolution, PROBEMGR->PROBE_FORMAT);
@ -700,7 +700,7 @@ void ReflectionProbe::processBakedCubemap()
mIrridianceMap->updateFaces();
}
if (mIrridianceMap == nullptr || mIrridianceMap->mCubemap.isNull())
if (mIrridianceMap == nullptr || !mIrridianceMap->mCubemap->isInitialized())
{
Con::errorf("ReflectionProbe::processDynamicCubemap() - Unable to load baked irradiance map at %s", getIrradianceMapPath().c_str());
return;
@ -713,7 +713,7 @@ void ReflectionProbe::processBakedCubemap()
mPrefilterMap->updateFaces();
}
if (mPrefilterMap == nullptr || mPrefilterMap->mCubemap.isNull())
if (mPrefilterMap == nullptr || !mPrefilterMap->mCubemap->isInitialized())
{
Con::errorf("ReflectionProbe::processDynamicCubemap() - Unable to load baked prefilter map at %s", getPrefilterMapPath().c_str());
return;