shift pbrconfig to ORM

This commit is contained in:
AzaezelX 2020-09-30 13:51:12 -05:00
parent 22b0785c73
commit 0c7811bd1a
54 changed files with 879 additions and 680 deletions

View file

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

View file

@ -56,7 +56,7 @@ public:
{ {
Albedo = 0, Albedo = 0,
Normal = 1, Normal = 1,
PBRConfig = 2, ORMConfig = 2,
GUI = 3, GUI = 3,
Roughness = 4, Roughness = 4,
AO = 5, AO = 5,

View file

@ -61,7 +61,7 @@ AssetImportConfig::AssetImportConfig() :
reverseWindingOrder(false), reverseWindingOrder(false),
invertNormals(false), invertNormals(false),
ImportMaterials(true), ImportMaterials(true),
CreatePBRConfig(true), CreateORMConfig(true),
UseDiffuseSuffixOnOriginImage(false), UseDiffuseSuffixOnOriginImage(false),
UseExistingMaterials(false), UseExistingMaterials(false),
IgnoreMaterials(""), IgnoreMaterials(""),
@ -160,11 +160,11 @@ void AssetImportConfig::initPersistFields()
addGroup("Materials"); addGroup("Materials");
addField("ImportMaterials", TypeBool, Offset(ImportMaterials, AssetImportConfig), "Does this config allow for importing of 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("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("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("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"); endGroup("Materials");
addGroup("Meshes"); addGroup("Meshes");
@ -186,14 +186,14 @@ void AssetImportConfig::initPersistFields()
addGroup("Images"); addGroup("Images");
addField("importImages", TypeBool, Offset(importImages, AssetImportConfig), "Does this configuration support importing 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("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("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("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("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("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("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("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"); 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 //Materials
ImportMaterials = dAtob(configSettings->value(String(configName + "/Materials/ImportMaterials").c_str())); 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())); UseDiffuseSuffixOnOriginImage = dAtob(configSettings->value(String(configName + "/Materials/UseDiffuseSuffixOnOriginImage").c_str()));
UseExistingMaterials = dAtob(configSettings->value(String(configName + "/Materials/UseExistingMaterials").c_str())); UseExistingMaterials = dAtob(configSettings->value(String(configName + "/Materials/UseExistingMaterials").c_str()));
IgnoreMaterials = configSettings->value(String(configName + "/Materials/IgnoreMaterials").c_str()); IgnoreMaterials = configSettings->value(String(configName + "/Materials/IgnoreMaterials").c_str());
@ -334,7 +334,7 @@ void AssetImportConfig::CopyTo(AssetImportConfig* target) const
//Materials //Materials
target->ImportMaterials = ImportMaterials; target->ImportMaterials = ImportMaterials;
target->CreatePBRConfig = CreatePBRConfig; target->CreateORMConfig = CreateORMConfig;
target->UseDiffuseSuffixOnOriginImage = UseDiffuseSuffixOnOriginImage; target->UseDiffuseSuffixOnOriginImage = UseDiffuseSuffixOnOriginImage;
target->UseExistingMaterials = UseExistingMaterials; target->UseExistingMaterials = UseExistingMaterials;
target->IgnoreMaterials = IgnoreMaterials; 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("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"); 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; break;
case 5: case 5:
suffixList = activeImportConfig->PBRTypeSuffixes; suffixList = activeImportConfig->PBRTypeSuffixes;
suffixType->insert(0, "PBRConfig", 10); suffixType->insert(0, "ORMConfig", 10);
break; break;
default: default:
suffixList = ""; suffixList = "";
@ -1635,7 +1635,7 @@ void AssetImporter::processMaterialAsset(AssetImportObject* assetItem)
case ImageAsset::Normal: case ImageAsset::Normal:
suffixList = activeImportConfig->NormalTypeSuffixes; suffixList = activeImportConfig->NormalTypeSuffixes;
break; break;
case ImageAsset::PBRConfig: case ImageAsset::ORMConfig:
suffixList = activeImportConfig->PBRTypeSuffixes; suffixList = activeImportConfig->PBRTypeSuffixes;
break; break;
case ImageAsset::Metalness: case ImageAsset::Metalness:
@ -2644,10 +2644,10 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
return ""; return "";
} }
//build the PBRConfig file if we're flagged to and have valid image maps //build the ORMConfig file if we're flagged to and have valid image maps
if (activeImportConfig->CreatePBRConfig) if (activeImportConfig->CreateORMConfig)
{ {
AssetImportObject* pbrConfigMap = nullptr; AssetImportObject* ormMap = nullptr;
AssetImportObject* roughnessMap = nullptr; AssetImportObject* roughnessMap = nullptr;
AssetImportObject* metalnessMap = nullptr; AssetImportObject* metalnessMap = nullptr;
AssetImportObject* aoMap = nullptr; AssetImportObject* aoMap = nullptr;
@ -2660,8 +2660,8 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
if (childItem->skip || childItem->assetType.compare("ImageAsset") != 0) if (childItem->skip || childItem->assetType.compare("ImageAsset") != 0)
continue; continue;
if (childItem->imageSuffixType.compare("PBRConfig") == 0) if (childItem->imageSuffixType.compare("ORMConfig") == 0)
pbrConfigMap = childItem; ormMap = childItem;
else if(childItem->imageSuffixType.compare("Roughness") == 0) else if(childItem->imageSuffixType.compare("Roughness") == 0)
roughnessMap = childItem; roughnessMap = childItem;
else if (childItem->imageSuffixType.compare("Metalness") == 0) else if (childItem->imageSuffixType.compare("Metalness") == 0)
@ -2670,14 +2670,14 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
aoMap = childItem; aoMap = childItem;
} }
if (pbrConfigMap != nullptr && pbrConfigMap->generatedAsset) if (ormMap != nullptr && ormMap->generatedAsset)
{ {
if (roughnessMap != nullptr || metalnessMap != nullptr || aoMap != nullptr) if (roughnessMap != nullptr || metalnessMap != nullptr || aoMap != nullptr)
{ {
U32 channelKey[4] = { 0,1,2,3 }; U32 channelKey[4] = { 0,1,2,3 };
GFX->getTextureManager()->saveCompositeTexture(aoMap->filePath.getFullPath(), roughnessMap->filePath.getFullPath(), metalnessMap->filePath.getFullPath(), "", 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"; mapFieldName = "NormalMap";
} }
else if (imageType == ImageAsset::ImageTypes::PBRConfig) else if (imageType == ImageAsset::ImageTypes::ORMConfig)
{ {
mapFieldName = "PBRConfig"; mapFieldName = "ORMConfig";
} }
else if (imageType == ImageAsset::ImageTypes::Metalness) else if (imageType == ImageAsset::ImageTypes::Metalness)
{ {
@ -2784,9 +2784,9 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
{ {
mapFieldName = "NormalMap"; mapFieldName = "NormalMap";
} }
else if (imageType == ImageAsset::ImageTypes::PBRConfig) else if (imageType == ImageAsset::ImageTypes::ORMConfig)
{ {
mapFieldName = "PBRConfigMap"; mapFieldName = "ORMConfigMap";
} }
else if (imageType == ImageAsset::ImageTypes::Metalness) else if (imageType == ImageAsset::ImageTypes::Metalness)
{ {

View file

@ -185,7 +185,7 @@ public:
/// <summary> /// <summary>
/// When importing a material, should it automatically attempt to merge Roughness, AO and Metalness maps into a single, composited PBR Configuration map /// When importing a material, should it automatically attempt to merge Roughness, AO and Metalness maps into a single, composited PBR Configuration map
/// </summary> /// </summary>
bool CreatePBRConfig; bool CreateORMConfig;
/// <summary> /// <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. /// 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> /// <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 /// 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> /// </summary>
bool PopulateMaterialMaps; bool PopulateMaterialMaps;
@ -276,7 +276,7 @@ public:
bool importImages; bool importImages;
/// <summary> /// <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> /// </summary>
String ImageType; String ImageType;
@ -317,7 +317,7 @@ public:
String AOTypeSuffixes; String AOTypeSuffixes;
/// <summary> /// <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 /// e.g. _Composite or _PBR
/// </summary> /// </summary>
String PBRTypeSuffixes; String PBRTypeSuffixes;
@ -490,7 +490,7 @@ public:
// //
/// <summary> /// <summary>
/// Specific to ImageAsset type /// 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> /// </summary>
String imageSuffixType; String imageSuffixType;

View file

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

View file

@ -1028,26 +1028,45 @@ GFXTextureObject *GFXTextureManager::createCompositeTexture(const Torque::Path &
GFXTextureObject *cacheHit = _lookupTexture(resourceTag, profile); GFXTextureObject *cacheHit = _lookupTexture(resourceTag, profile);
if (cacheHit != NULL) return cacheHit; if (cacheHit != NULL) return cacheHit;
Torque::Path lastValidPath = "";
GBitmap*bitmap[4]; GBitmap*bitmap[4];
bitmap[0] = loadUncompressedTexture(pathR, profile);
if (!pathR.isEmpty())
{
bitmap[0] = loadUncompressedTexture(pathR, profile);
lastValidPath = pathR;
}
else
bitmap[0] = NULL;
if (!pathG.isEmpty()) if (!pathG.isEmpty())
{
bitmap[1] = loadUncompressedTexture(pathG, profile); bitmap[1] = loadUncompressedTexture(pathG, profile);
lastValidPath = pathG;
}
else else
bitmap[1] = NULL; bitmap[1] = NULL;
if (!pathB.isEmpty()) if (!pathB.isEmpty())
{
bitmap[2] = loadUncompressedTexture(pathB, profile); bitmap[2] = loadUncompressedTexture(pathB, profile);
lastValidPath = pathB;
}
else else
bitmap[2] = NULL; bitmap[2] = NULL;
if (!pathA.isEmpty()) if (!pathA.isEmpty())
{
bitmap[3] = loadUncompressedTexture(pathA, profile); bitmap[3] = loadUncompressedTexture(pathA, profile);
lastValidPath = pathA;
}
else else
bitmap[3] = NULL; bitmap[3] = NULL;
Path realPath; Path realPath;
GFXTextureObject *retTexObj = NULL; GFXTextureObject *retTexObj = NULL;
realPath = validatePath(pathR); //associate path with r channel texture in. realPath = validatePath(lastValidPath); //associate path with last valid channel texture in.
retTexObj = createCompositeTexture(bitmap, inputKey, resourceTag, profile, false); retTexObj = createCompositeTexture(bitmap, inputKey, resourceTag, profile, false);
@ -1087,26 +1106,45 @@ void GFXTextureManager::saveCompositeTexture(const Torque::Path &pathR, const To
cacheHit->dumpToDisk("png", saveAs.getFullPath()); cacheHit->dumpToDisk("png", saveAs.getFullPath());
return; return;
} }
GBitmap*bitmap[4];
bitmap[0] = loadUncompressedTexture(pathR, profile); Torque::Path lastValidPath = "";
GBitmap* bitmap[4];
if (!pathR.isEmpty())
{
bitmap[0] = loadUncompressedTexture(pathR, profile);
lastValidPath = pathR;
}
else
bitmap[0] = NULL;
if (!pathG.isEmpty()) if (!pathG.isEmpty())
{
bitmap[1] = loadUncompressedTexture(pathG, profile); bitmap[1] = loadUncompressedTexture(pathG, profile);
lastValidPath = pathG;
}
else else
bitmap[1] = NULL; bitmap[1] = NULL;
if (!pathB.isEmpty()) if (!pathB.isEmpty())
{
bitmap[2] = loadUncompressedTexture(pathB, profile); bitmap[2] = loadUncompressedTexture(pathB, profile);
lastValidPath = pathB;
}
else else
bitmap[2] = NULL; bitmap[2] = NULL;
if (!pathA.isEmpty()) if (!pathA.isEmpty())
{
bitmap[3] = loadUncompressedTexture(pathA, profile); bitmap[3] = loadUncompressedTexture(pathA, profile);
lastValidPath = pathA;
}
else else
bitmap[3] = NULL; bitmap[3] = NULL;
Path realPath; Path realPath;
GFXTextureObject *retTexObj = NULL; GFXTextureObject *retTexObj = NULL;
realPath = validatePath(pathR); //associate path with r channel texture in. realPath = validatePath(lastValidPath); //associate path with last valid channel texture in.
retTexObj = createCompositeTexture(bitmap, inputKey, resourceTag, profile, false); retTexObj = createCompositeTexture(bitmap, inputKey, resourceTag, profile, false);
if (retTexObj != NULL) if (retTexObj != NULL)
@ -1130,9 +1168,16 @@ DefineEngineFunction(saveCompositeTexture, void, (const char* pathR, const char*
GFXTextureObject *GFXTextureManager::createCompositeTexture(GBitmap*bmp[4], U32 inputKey[4], GFXTextureObject *GFXTextureManager::createCompositeTexture(GBitmap*bmp[4], U32 inputKey[4],
const String &resourceName, GFXTextureProfile *profile, bool deleteBmp) const String &resourceName, GFXTextureProfile *profile, bool deleteBmp)
{ {
if (!bmp[0]) S32 lastValidTex = -1;
for (U32 i = 0; i < 4; i++)
{ {
Con::errorf(ConsoleLogEntry::General, "GFXTextureManager::createCompositeTexture() - Got NULL bitmap(R)!"); if (bmp[i])
lastValidTex = i;
}
if (lastValidTex == -1)
{
Con::errorf(ConsoleLogEntry::General, "GFXTextureManager::createCompositeTexture() - Got all NULL bitmaps!");
return NULL; return NULL;
} }
@ -1145,11 +1190,11 @@ GFXTextureObject *GFXTextureManager::createCompositeTexture(GBitmap*bmp[4], U32
U8 rChan, gChan, bChan, aChan; U8 rChan, gChan, bChan, aChan;
GBitmap *outBitmap = new GBitmap(); GBitmap *outBitmap = new GBitmap();
outBitmap->allocateBitmap(bmp[0]->getWidth(), bmp[0]->getHeight(),false, GFXFormatR8G8B8A8); outBitmap->allocateBitmap(bmp[lastValidTex]->getWidth(), bmp[lastValidTex]->getHeight(),false, GFXFormatR8G8B8A8);
//pack additional bitmaps into the origional //pack additional bitmaps into the origional
for (U32 x = 0; x < bmp[0]->getWidth(); x++) for (U32 x = 0; x < bmp[lastValidTex]->getWidth(); x++)
{ {
for (U32 y = 0; y < bmp[0]->getHeight(); y++) for (U32 y = 0; y < bmp[lastValidTex]->getHeight(); y++)
{ {
rChan = bmp[0]->getChanelValueAt(x, y, inputKey[0]); rChan = bmp[0]->getChanelValueAt(x, y, inputKey[0]);

View file

@ -364,7 +364,7 @@ void DeferredBumpFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
Parent::processPix( componentList, fd ); Parent::processPix( componentList, fd );
return; return;
} }
else if (!fd.features[MFT_PBRConfigMap] ) else if (!fd.features[MFT_OrmMap] )
{ {
Var *bumpSample = (Var *)LangElement::find( "bumpSample" ); Var *bumpSample = (Var *)LangElement::find( "bumpSample" );
if( bumpSample == NULL ) if( bumpSample == NULL )
@ -395,7 +395,7 @@ ShaderFeature::Resources DeferredBumpFeatGLSL::getResources( const MaterialFeatu
return Parent::getResources( fd ); return Parent::getResources( fd );
Resources res; Resources res;
if(!fd.features[MFT_PBRConfigMap]) if(!fd.features[MFT_OrmMap])
{ {
res.numTex = 1; res.numTex = 1;
res.numTexReg = 1; res.numTexReg = 1;
@ -438,7 +438,7 @@ void DeferredBumpFeatGLSL::setTexData( Material::StageData &stageDat,
passData.mTexSlot[texIndex++].texObject = stageDat.getTex(MFT_DetailNormalMap); passData.mTexSlot[texIndex++].texObject = stageDat.getTex(MFT_DetailNormalMap);
} }
} }
else if (!fd.features[MFT_Parallax] && !fd.features[MFT_PBRConfigMap] && else if (!fd.features[MFT_Parallax] && !fd.features[MFT_OrmMap] &&
( fd.features[MFT_DeferredConditioner]) ) ( fd.features[MFT_DeferredConditioner]) )
{ {
passData.mTexType[ texIndex ] = Material::Bump; passData.mTexType[ texIndex ] = Material::Bump;

View file

@ -35,72 +35,72 @@
//**************************************************************************** //****************************************************************************
// Deferred Shading Features // Deferred Shading Features
//**************************************************************************** //****************************************************************************
U32 PBRConfigMapGLSL::getOutputTargets(const MaterialFeatureData& fd) const U32 DeferredOrmMapGLSL::getOutputTargets(const MaterialFeatureData& fd) const
{ {
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget; return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
} }
void PBRConfigMapGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd ) void DeferredOrmMapGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
{ {
// Get the texture coord. // Get the texture coord.
Var *texCoord = getInTexCoord( "texCoord", "vec2", componentList ); Var *texCoord = getInTexCoord( "texCoord", "vec2", componentList );
MultiLine* meta = new MultiLine; MultiLine* meta = new MultiLine;
Var* pbrConfig; Var* ormConfig;
if (fd.features[MFT_isDeferred]) if (fd.features[MFT_isDeferred])
{ {
pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2)); ormConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2));
if (!pbrConfig) if (!ormConfig)
{ {
// create material var // create material var
pbrConfig = new Var; ormConfig = new Var;
pbrConfig->setType("vec4"); ormConfig->setType("vec4");
pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2)); ormConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2));
pbrConfig->setStructName("OUT"); ormConfig->setStructName("OUT");
} }
} }
else else
{ {
pbrConfig = (Var*)LangElement::find("PBRConfig"); ormConfig = (Var*)LangElement::find("ORMConfig");
if (!pbrConfig) if (!ormConfig)
{ {
pbrConfig = new Var("PBRConfig", "vec4"); ormConfig = new Var("ORMConfig", "vec4");
meta->addStatement(new GenOp(" @;\r\n", new DecOp(pbrConfig))); meta->addStatement(new GenOp(" @;\r\n", new DecOp(ormConfig)));
} }
} }
// create texture var // create texture var
Var *pbrConfigMap = new Var; Var *ormMap = new Var;
pbrConfigMap->setType( "sampler2D" ); ormMap->setType( "sampler2D" );
pbrConfigMap->setName( "pbrConfigMap" ); ormMap->setName( "ormMap" );
pbrConfigMap->uniform = true; ormMap->uniform = true;
pbrConfigMap->sampler = true; ormMap->sampler = true;
pbrConfigMap->constNum = Var::getTexUnitNum(); ormMap->constNum = Var::getTexUnitNum();
LangElement *texOp = new GenOp( "tex2D(@, @)", pbrConfigMap, texCoord ); LangElement *texOp = new GenOp( "tex2D(@, @)", ormMap, texCoord );
Var *metalness = (Var*)LangElement::find("metalness"); Var *metalness = (Var*)LangElement::find("metalness");
if (!metalness) metalness = new Var("metalness", "float"); if (!metalness) metalness = new Var("metalness", "float");
Var *smoothness = (Var*)LangElement::find("smoothness"); Var *roughness = (Var*)LangElement::find("roughness");
if (!smoothness) smoothness = new Var("smoothness", "float"); if (!roughness) roughness = new Var("roughness", "float");
Var* ao = (Var*)LangElement::find("ao"); Var* ao = (Var*)LangElement::find("ao");
if (!ao) ao = new Var("ao", "float"); if (!ao) ao = new Var("ao", "float");
meta->addStatement(new GenOp(" @.bga = @.rgb;\r\n", pbrConfig, texOp)); meta->addStatement(new GenOp(" @.gba = @.rgb;\r\n", ormConfig, texOp));
meta->addStatement(new GenOp(" @ = @.b;\r\n", new DecOp(smoothness), pbrConfig)); meta->addStatement(new GenOp(" @ = @.g;\r\n", new DecOp(ao), ormConfig));
if (fd.features[MFT_InvertSmoothness]) meta->addStatement(new GenOp(" @ = @.b;\r\n", new DecOp(roughness), ormConfig));
if (fd.features[MFT_InvertRoughness])
{ {
meta->addStatement(new GenOp(" @.b = 1.0-@.b;\r\n", pbrConfig, pbrConfig)); meta->addStatement(new GenOp(" @.b = 1.0-@.b;\r\n", ormConfig, ormConfig));
meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", smoothness, smoothness)); meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", roughness, roughness));
} }
meta->addStatement(new GenOp(" @ = @.g;\r\n", new DecOp(ao), pbrConfig)); meta->addStatement(new GenOp(" @ = @.a;\r\n", new DecOp(metalness), ormConfig));
meta->addStatement(new GenOp(" @ = @.a;\r\n", new DecOp(metalness), pbrConfig));
output = meta; output = meta;
} }
ShaderFeature::Resources PBRConfigMapGLSL::getResources( const MaterialFeatureData &fd ) ShaderFeature::Resources DeferredOrmMapGLSL::getResources( const MaterialFeatureData &fd )
{ {
Resources res; Resources res;
res.numTex = 1; res.numTex = 1;
@ -109,21 +109,21 @@ ShaderFeature::Resources PBRConfigMapGLSL::getResources( const MaterialFeatureDa
return res; return res;
} }
void PBRConfigMapGLSL::setTexData( Material::StageData &stageDat, void DeferredOrmMapGLSL::setTexData( Material::StageData &stageDat,
const MaterialFeatureData &fd, const MaterialFeatureData &fd,
RenderPassData &passData, RenderPassData &passData,
U32 &texIndex ) U32 &texIndex )
{ {
GFXTextureObject *tex = stageDat.getTex(MFT_PBRConfigMap); GFXTextureObject *tex = stageDat.getTex(MFT_OrmMap);
if ( tex ) if ( tex )
{ {
passData.mTexType[ texIndex ] = Material::Standard; passData.mTexType[ texIndex ] = Material::Standard;
passData.mSamplerNames[ texIndex ] = "pbrConfigMap"; passData.mSamplerNames[ texIndex ] = "ormMap";
passData.mTexSlot[ texIndex++ ].texObject = tex; passData.mTexSlot[ texIndex++ ].texObject = tex;
} }
} }
void PBRConfigMapGLSL::processVert( Vector<ShaderComponent*> &componentList, void DeferredOrmMapGLSL::processVert( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd ) const MaterialFeatureData &fd )
{ {
MultiLine *meta = new MultiLine; MultiLine *meta = new MultiLine;
@ -145,26 +145,26 @@ void MatInfoFlagsGLSL::processPix( Vector<ShaderComponent*> &componentList, cons
{ {
MultiLine *meta = new MultiLine; MultiLine *meta = new MultiLine;
Var* pbrConfig; Var* ormConfig;
if (fd.features[MFT_isDeferred]) if (fd.features[MFT_isDeferred])
{ {
pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2)); ormConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2));
if (!pbrConfig) if (!ormConfig)
{ {
// create material var // create material var
pbrConfig = new Var; ormConfig = new Var;
pbrConfig->setType("vec4"); ormConfig->setType("vec4");
pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2)); ormConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2));
pbrConfig->setStructName("OUT"); ormConfig->setStructName("OUT");
} }
} }
else else
{ {
pbrConfig = (Var*)LangElement::find("PBRConfig"); ormConfig = (Var*)LangElement::find("ORMConfig");
if (!pbrConfig) if (!ormConfig)
{ {
pbrConfig = new Var("PBRConfig", "vec4"); ormConfig = new Var("ORMConfig", "vec4");
meta->addStatement(new GenOp(" @;\r\n", new DecOp(pbrConfig))); meta->addStatement(new GenOp(" @;\r\n", new DecOp(ormConfig)));
} }
} }
@ -174,57 +174,57 @@ void MatInfoFlagsGLSL::processPix( Vector<ShaderComponent*> &componentList, cons
matInfoFlags->uniform = true; matInfoFlags->uniform = true;
matInfoFlags->constSortPos = cspPotentialPrimitive; matInfoFlags->constSortPos = cspPotentialPrimitive;
meta->addStatement(output = new GenOp(" @.r = @;\r\n", pbrConfig, matInfoFlags)); meta->addStatement(output = new GenOp(" @.r = @;\r\n", ormConfig, matInfoFlags));
output = meta; output = meta;
} }
U32 PBRConfigVarsGLSL::getOutputTargets(const MaterialFeatureData& fd) const U32 ORMConfigVarsGLSL::getOutputTargets(const MaterialFeatureData& fd) const
{ {
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget; return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
} }
// Spec Strength -> Blue Channel of Material Info Buffer. // Spec Strength -> Blue Channel of Material Info Buffer.
// Spec Power -> Alpha Channel ( of Material Info Buffer. // Spec Power -> Alpha Channel ( of Material Info Buffer.
void PBRConfigVarsGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd ) void ORMConfigVarsGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
{ {
MultiLine* meta = new MultiLine; MultiLine* meta = new MultiLine;
Var* pbrConfig; Var* ormConfig;
if (fd.features[MFT_isDeferred]) if (fd.features[MFT_isDeferred])
{ {
pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2)); ormConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2));
if (!pbrConfig) if (!ormConfig)
{ {
// create material var // create material var
pbrConfig = new Var; ormConfig = new Var;
pbrConfig->setType("vec4"); ormConfig->setType("vec4");
pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2)); ormConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2));
pbrConfig->setStructName("OUT"); ormConfig->setStructName("OUT");
} }
} }
else else
{ {
pbrConfig = (Var*)LangElement::find("PBRConfig"); ormConfig = (Var*)LangElement::find("ORMConfig");
if (!pbrConfig) if (!ormConfig)
{ {
pbrConfig = new Var("PBRConfig", "vec4"); ormConfig = new Var("ORMConfig", "vec4");
meta->addStatement(new GenOp(" @;\r\n", new DecOp(pbrConfig))); meta->addStatement(new GenOp(" @;\r\n", new DecOp(ormConfig)));
} }
} }
Var* metalness = new Var("metalness", "float"); Var* metalness = new Var("metalness", "float");
metalness->uniform = true; metalness->uniform = true;
metalness->constSortPos = cspPotentialPrimitive; metalness->constSortPos = cspPotentialPrimitive;
Var* smoothness = new Var("smoothness", "float"); Var* roughness = new Var("roughness", "float");
smoothness->uniform = true; roughness->uniform = true;
smoothness->constSortPos = cspPotentialPrimitive; roughness->constSortPos = cspPotentialPrimitive;
//matinfo.g slot reserved for AO later //matinfo.g slot reserved for AO later
meta->addStatement(new GenOp(" @.g = 1.0;\r\n", pbrConfig)); meta->addStatement(new GenOp(" @.g = 1.0;\r\n", ormConfig));
meta->addStatement(new GenOp(" @.b = @;\r\n", pbrConfig, smoothness)); meta->addStatement(new GenOp(" @.b = @;\r\n", ormConfig, roughness));
if (fd.features[MFT_InvertSmoothness]) if (fd.features[MFT_InvertRoughness])
meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", smoothness, smoothness)); meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", roughness, roughness));
meta->addStatement(new GenOp(" @.a = @;\r\n", pbrConfig, metalness)); meta->addStatement(new GenOp(" @.a = @;\r\n", ormConfig, metalness));
output = meta; output = meta;
} }

View file

@ -27,7 +27,7 @@
#include "shaderGen/GLSL/bumpGLSL.h" #include "shaderGen/GLSL/bumpGLSL.h"
// Specular Outputs // Specular Outputs
class PBRConfigMapGLSL : public ShaderFeatureGLSL class DeferredOrmMapGLSL : public ShaderFeatureGLSL
{ {
public: public:
virtual String getName() { return "Deferred Shading: PBR Config Map"; } virtual String getName() { return "Deferred Shading: PBR Config Map"; }
@ -60,7 +60,7 @@ public:
virtual U32 getOutputTargets(const MaterialFeatureData& fd) const; virtual U32 getOutputTargets(const MaterialFeatureData& fd) const;
}; };
class PBRConfigVarsGLSL : public ShaderFeatureGLSL class ORMConfigVarsGLSL : public ShaderFeatureGLSL
{ {
public: public:
virtual String getName() { return "Deferred Shading: PBR Config Explicit Numbers"; } virtual String getName() { return "Deferred Shading: PBR Config Explicit Numbers"; }

View file

@ -395,7 +395,7 @@ void DeferredBumpFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
Parent::processPix( componentList, fd ); Parent::processPix( componentList, fd );
return; return;
} }
else if (!fd.features[MFT_PBRConfigMap] ) else if (!fd.features[MFT_OrmMap] )
{ {
Var *bumpSample = (Var *)LangElement::find( "bumpSample" ); Var *bumpSample = (Var *)LangElement::find( "bumpSample" );
if( bumpSample == NULL ) if( bumpSample == NULL )
@ -428,7 +428,7 @@ ShaderFeature::Resources DeferredBumpFeatHLSL::getResources( const MaterialFeatu
return Parent::getResources( fd ); return Parent::getResources( fd );
Resources res; Resources res;
if(!fd.features[MFT_PBRConfigMap]) if(!fd.features[MFT_OrmMap])
{ {
res.numTex = 1; res.numTex = 1;
res.numTexReg = 1; res.numTexReg = 1;
@ -471,7 +471,7 @@ void DeferredBumpFeatHLSL::setTexData( Material::StageData &stageDat,
passData.mTexSlot[ texIndex++ ].texObject = stageDat.getTex( MFT_DetailNormalMap ); passData.mTexSlot[ texIndex++ ].texObject = stageDat.getTex( MFT_DetailNormalMap );
} }
} }
else if ( !fd.features[MFT_Parallax] && !fd.features[MFT_PBRConfigMap] && else if ( !fd.features[MFT_Parallax] && !fd.features[MFT_OrmMap] &&
( fd.features[MFT_DeferredConditioner]) ) ( fd.features[MFT_DeferredConditioner]) )
{ {
passData.mTexType[ texIndex ] = Material::Bump; passData.mTexType[ texIndex ] = Material::Bump;

View file

@ -35,79 +35,79 @@
//**************************************************************************** //****************************************************************************
// Deferred Shading Features // Deferred Shading Features
//**************************************************************************** //****************************************************************************
U32 PBRConfigMapHLSL::getOutputTargets(const MaterialFeatureData& fd) const U32 DeferredOrmMapHLSL::getOutputTargets(const MaterialFeatureData& fd) const
{ {
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget; return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
} }
void PBRConfigMapHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd ) void DeferredOrmMapHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
{ {
// Get the texture coord. // Get the texture coord.
Var *texCoord = getInTexCoord( "texCoord", "float2", componentList ); Var *texCoord = getInTexCoord( "texCoord", "float2", componentList );
MultiLine* meta = new MultiLine; MultiLine* meta = new MultiLine;
Var* pbrConfig; Var* ormConfig;
if (fd.features[MFT_isDeferred]) if (fd.features[MFT_isDeferred])
{ {
pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2)); ormConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2));
if (!pbrConfig) if (!ormConfig)
{ {
// create material var // create material var
pbrConfig = new Var; ormConfig = new Var;
pbrConfig->setType("fragout"); ormConfig->setType("fragout");
pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2)); ormConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2));
pbrConfig->setStructName("OUT"); ormConfig->setStructName("OUT");
} }
} }
else else
{ {
pbrConfig = (Var*)LangElement::find("PBRConfig"); ormConfig = (Var*)LangElement::find("ORMConfig");
if (!pbrConfig) if (!ormConfig)
{ {
pbrConfig = new Var("PBRConfig", "float4"); ormConfig = new Var("ORMConfig", "float4");
meta->addStatement(new GenOp(" @;\r\n", new DecOp(pbrConfig))); meta->addStatement(new GenOp(" @;\r\n", new DecOp(ormConfig)));
} }
} }
// create texture var // create texture var
Var * pbrConfigMap = new Var; Var * ormMap = new Var;
pbrConfigMap->setType( "SamplerState" ); ormMap->setType( "SamplerState" );
pbrConfigMap->setName( "PBRConfigMap" ); ormMap->setName( "ORMConfigMap" );
pbrConfigMap->uniform = true; ormMap->uniform = true;
pbrConfigMap->sampler = true; ormMap->sampler = true;
pbrConfigMap->constNum = Var::getTexUnitNum(); ormMap->constNum = Var::getTexUnitNum();
Var* pbrConfigMapTex = new Var; Var* ormMapTex = new Var;
pbrConfigMapTex->setName("PBRConfigMapTex"); ormMapTex->setName("ORMConfigMapTex");
pbrConfigMapTex->setType("Texture2D"); ormMapTex->setType("Texture2D");
pbrConfigMapTex->uniform = true; ormMapTex->uniform = true;
pbrConfigMapTex->texture = true; ormMapTex->texture = true;
pbrConfigMapTex->constNum = pbrConfigMap->constNum; ormMapTex->constNum = ormMap->constNum;
LangElement *texOp = new GenOp("@.Sample(@, @)", pbrConfigMapTex, pbrConfigMap, texCoord); LangElement *texOp = new GenOp("@.Sample(@, @)", ormMapTex, ormMap, texCoord);
Var *metalness = (Var*)LangElement::find("metalness"); Var *metalness = (Var*)LangElement::find("metalness");
if (!metalness) metalness = new Var("metalness", "float"); if (!metalness) metalness = new Var("metalness", "float");
Var *smoothness = (Var*)LangElement::find("smoothness"); Var *roughness = (Var*)LangElement::find("roughness");
if (!smoothness) smoothness = new Var("smoothness", "float"); if (!roughness) roughness = new Var("roughness", "float");
Var* ao = (Var*)LangElement::find("ao"); Var* ao = (Var*)LangElement::find("ao");
if (!ao) ao = new Var("ao", "float"); if (!ao) ao = new Var("ao", "float");
meta->addStatement(new GenOp(" @.bga = @.rgb;\r\n", pbrConfig, texOp)); meta->addStatement(new GenOp(" @.gba = @.rgb;\r\n", ormConfig, texOp));
meta->addStatement(new GenOp(" @ = @.b;\r\n", new DecOp(smoothness), pbrConfig)); meta->addStatement(new GenOp(" @ = @.g;\r\n", new DecOp(ao), ormConfig));
if (fd.features[MFT_InvertSmoothness]) meta->addStatement(new GenOp(" @ = @.b;\r\n", new DecOp(roughness), ormConfig));
if (fd.features[MFT_InvertRoughness])
{ {
meta->addStatement(new GenOp(" @.b = 1.0-@.b;\r\n", pbrConfig, pbrConfig)); meta->addStatement(new GenOp(" @.b = 1.0-@.b;\r\n", ormConfig, ormConfig));
meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", smoothness, smoothness)); meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", roughness, roughness));
} }
meta->addStatement(new GenOp(" @ = @.g;\r\n", new DecOp(ao), pbrConfig)); meta->addStatement(new GenOp(" @ = @.a;\r\n", new DecOp(metalness), ormConfig));
meta->addStatement(new GenOp(" @ = @.a;\r\n", new DecOp(metalness), pbrConfig));
output = meta; output = meta;
} }
ShaderFeature::Resources PBRConfigMapHLSL::getResources( const MaterialFeatureData &fd ) ShaderFeature::Resources DeferredOrmMapHLSL::getResources( const MaterialFeatureData &fd )
{ {
Resources res; Resources res;
res.numTex = 1; res.numTex = 1;
@ -116,21 +116,21 @@ ShaderFeature::Resources PBRConfigMapHLSL::getResources( const MaterialFeatureDa
return res; return res;
} }
void PBRConfigMapHLSL::setTexData( Material::StageData &stageDat, void DeferredOrmMapHLSL::setTexData( Material::StageData &stageDat,
const MaterialFeatureData &fd, const MaterialFeatureData &fd,
RenderPassData &passData, RenderPassData &passData,
U32 &texIndex ) U32 &texIndex )
{ {
GFXTextureObject *tex = stageDat.getTex(MFT_PBRConfigMap); GFXTextureObject *tex = stageDat.getTex(MFT_OrmMap);
if ( tex ) if ( tex )
{ {
passData.mTexType[ texIndex ] = Material::Standard; passData.mTexType[ texIndex ] = Material::Standard;
passData.mSamplerNames[ texIndex ] = "PBRConfigMap"; passData.mSamplerNames[ texIndex ] = "ORMConfigMap";
passData.mTexSlot[ texIndex++ ].texObject = tex; passData.mTexSlot[ texIndex++ ].texObject = tex;
} }
} }
void PBRConfigMapHLSL::processVert( Vector<ShaderComponent*> &componentList, void DeferredOrmMapHLSL::processVert( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd ) const MaterialFeatureData &fd )
{ {
MultiLine *meta = new MultiLine; MultiLine *meta = new MultiLine;
@ -151,23 +151,23 @@ U32 MatInfoFlagsHLSL::getOutputTargets(const MaterialFeatureData& fd) const
void MatInfoFlagsHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd ) void MatInfoFlagsHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
{ {
// search for material var // search for material var
Var* pbrConfig; Var* ormConfig;
if (fd.features[MFT_isDeferred]) if (fd.features[MFT_isDeferred])
{ {
pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2)); ormConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2));
if (!pbrConfig) if (!ormConfig)
{ {
// create material var // create material var
pbrConfig = new Var; ormConfig = new Var;
pbrConfig->setType("fragout"); ormConfig->setType("fragout");
pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2)); ormConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2));
pbrConfig->setStructName("OUT"); ormConfig->setStructName("OUT");
} }
} }
else else
{ {
pbrConfig = (Var*)LangElement::find("PBRConfig"); ormConfig = (Var*)LangElement::find("ORMConfig");
if (!pbrConfig) pbrConfig = new Var("PBRConfig", "float4"); if (!ormConfig) ormConfig = new Var("ORMConfig", "float4");
} }
Var *matInfoFlags = new Var; Var *matInfoFlags = new Var;
@ -176,50 +176,50 @@ void MatInfoFlagsHLSL::processPix( Vector<ShaderComponent*> &componentList, cons
matInfoFlags->uniform = true; matInfoFlags->uniform = true;
matInfoFlags->constSortPos = cspPotentialPrimitive; matInfoFlags->constSortPos = cspPotentialPrimitive;
output = new GenOp( " @.r = @;\r\n", pbrConfig, matInfoFlags ); output = new GenOp( " @.r = @;\r\n", ormConfig, matInfoFlags );
} }
U32 PBRConfigVarsHLSL::getOutputTargets(const MaterialFeatureData& fd) const U32 ORMConfigVarsHLSL::getOutputTargets(const MaterialFeatureData& fd) const
{ {
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget; return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
} }
void PBRConfigVarsHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd ) void ORMConfigVarsHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
{ {
MultiLine* meta = new MultiLine; MultiLine* meta = new MultiLine;
Var* pbrConfig; Var* ormConfig;
if (fd.features[MFT_isDeferred]) if (fd.features[MFT_isDeferred])
{ {
pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2)); ormConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2));
if (!pbrConfig) if (!ormConfig)
{ {
// create material var // create material var
pbrConfig = new Var; ormConfig = new Var;
pbrConfig->setType("fragout"); ormConfig->setType("fragout");
pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2)); ormConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2));
pbrConfig->setStructName("OUT"); ormConfig->setStructName("OUT");
} }
} }
else else
{ {
pbrConfig = (Var*)LangElement::find("PBRConfig"); ormConfig = (Var*)LangElement::find("ORMConfig");
if (!pbrConfig) pbrConfig = new Var("PBRConfig", "float4"); if (!ormConfig) ormConfig = new Var("ORMConfig", "float4");
meta->addStatement(new GenOp(" @;\r\n", new DecOp(pbrConfig))); meta->addStatement(new GenOp(" @;\r\n", new DecOp(ormConfig)));
} }
Var *metalness = new Var("metalness", "float"); Var *metalness = new Var("metalness", "float");
metalness->uniform = true; metalness->uniform = true;
metalness->constSortPos = cspPotentialPrimitive; metalness->constSortPos = cspPotentialPrimitive;
Var *smoothness = new Var("smoothness", "float"); Var *roughness = new Var("roughness", "float");
smoothness->uniform = true; roughness->uniform = true;
smoothness->constSortPos = cspPotentialPrimitive; roughness->constSortPos = cspPotentialPrimitive;
//matinfo.g slot reserved for AO later //matinfo.g slot reserved for AO later
meta->addStatement(new GenOp(" @.g = 1.0;\r\n", pbrConfig)); meta->addStatement(new GenOp(" @.g = 1.0;\r\n", ormConfig));
meta->addStatement(new GenOp(" @.b = @;\r\n", pbrConfig, smoothness)); meta->addStatement(new GenOp(" @.b = @;\r\n", ormConfig, roughness));
if (fd.features[MFT_InvertSmoothness]) if (fd.features[MFT_InvertRoughness])
meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", smoothness, smoothness)); meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", roughness, roughness));
meta->addStatement(new GenOp(" @.a = @;\r\n", pbrConfig, metalness)); meta->addStatement(new GenOp(" @.a = @;\r\n", ormConfig, metalness));
output = meta; output = meta;
} }

View file

@ -26,7 +26,7 @@
#include "shaderGen/HLSL/shaderFeatureHLSL.h" #include "shaderGen/HLSL/shaderFeatureHLSL.h"
#include "shaderGen/HLSL/bumpHLSL.h" #include "shaderGen/HLSL/bumpHLSL.h"
class PBRConfigMapHLSL : public ShaderFeatureHLSL class DeferredOrmMapHLSL : public ShaderFeatureHLSL
{ {
public: public:
virtual String getName() { return "Deferred Shading: PBR Config Map"; } virtual String getName() { return "Deferred Shading: PBR Config Map"; }
@ -59,7 +59,7 @@ public:
virtual U32 getOutputTargets(const MaterialFeatureData& fd) const; virtual U32 getOutputTargets(const MaterialFeatureData& fd) const;
}; };
class PBRConfigVarsHLSL : public ShaderFeatureHLSL class ORMConfigVarsHLSL : public ShaderFeatureHLSL
{ {
public: public:
virtual String getName() { return "Deferred Shading: PBR Config Explicit Numbers"; } virtual String getName() { return "Deferred Shading: PBR Config Explicit Numbers"; }

View file

@ -118,13 +118,13 @@ Material::Material()
mDiffuse[i].set( 1.0f, 1.0f, 1.0f, 1.0f ); mDiffuse[i].set( 1.0f, 1.0f, 1.0f, 1.0f );
mDiffuseMapSRGB[i] = true; mDiffuseMapSRGB[i] = true;
mSmoothness[i] = 0.0f; mRoughness[i] = 1.0f;
mMetalness[i] = 0.0f; mMetalness[i] = 0.0f;
mIsSRGb[i] = true; mIsSRGb[i] = true;
mInvertSmoothness[i] = false; mInvertRoughness[i] = false;
mSmoothnessChan[i] = 0; mRoughnessChan[i] = 0;
mAOChan[i] = 1; mAOChan[i] = 1;
mMetalChan[i] = 2; mMetalChan[i] = 2;
@ -265,11 +265,11 @@ void Material::initPersistFields()
addField( "detailNormalMapStrength", TypeF32, Offset(mDetailNormalMapStrength, Material), MAX_STAGES, addField( "detailNormalMapStrength", TypeF32, Offset(mDetailNormalMapStrength, Material), MAX_STAGES,
"Used to scale the strength of the detail normal map when blended with the base normal map." ); "Used to scale the strength of the detail normal map when blended with the base normal map." );
addField("smoothness", TypeF32, Offset(mSmoothness, Material), MAX_STAGES, addField("roughness", TypeF32, Offset(mRoughness, Material), MAX_STAGES,
"The degree of smoothness when not using a PBRConfigMap." ); "The degree of roughness when not using a ORMConfigMap." );
addField("metalness", TypeF32, Offset(mMetalness, Material), MAX_STAGES, addField("metalness", TypeF32, Offset(mMetalness, Material), MAX_STAGES,
"The degree of Metalness when not using a PBRConfigMap." ); "The degree of Metalness when not using a ORMConfigMap." );
addField("glowMul", TypeF32, Offset(mGlowMul, Material), MAX_STAGES, addField("glowMul", TypeF32, Offset(mGlowMul, Material), MAX_STAGES,
"glow mask multiplier"); "glow mask multiplier");
@ -295,11 +295,11 @@ void Material::initPersistFields()
addField("isSRGb", TypeBool, Offset(mIsSRGb, Material), MAX_STAGES, addField("isSRGb", TypeBool, Offset(mIsSRGb, Material), MAX_STAGES,
"Substance Designer Workaround."); "Substance Designer Workaround.");
addField("invertSmoothness", TypeBool, Offset(mInvertSmoothness, Material), MAX_STAGES, addField("invertRoughness", TypeBool, Offset(mInvertRoughness, Material), MAX_STAGES,
"Treat Smoothness as Roughness"); "Treat Roughness as Roughness");
addField("smoothnessChan", TypeF32, Offset(mSmoothnessChan, Material), MAX_STAGES, addField("roughnessChan", TypeF32, Offset(mRoughnessChan, Material), MAX_STAGES,
"The input channel smoothness maps use."); "The input channel roughness maps use.");
addField("AOChan", TypeF32, Offset(mAOChan, Material), MAX_STAGES, addField("AOChan", TypeF32, Offset(mAOChan, Material), MAX_STAGES,
"The input channel AO maps use."); "The input channel AO maps use.");

View file

@ -211,11 +211,11 @@ public:
DECLARE_TEXTUREARRAY(ToneMap, MAX_STAGES); DECLARE_TEXTUREARRAY(ToneMap, MAX_STAGES);
DECLARE_TEXTUREARRAY(DetailMap, MAX_STAGES);; DECLARE_TEXTUREARRAY(DetailMap, MAX_STAGES);;
DECLARE_TEXTUREARRAY(NormalMap, MAX_STAGES); DECLARE_TEXTUREARRAY(NormalMap, MAX_STAGES);
DECLARE_TEXTUREARRAY(PBRConfigMap, MAX_STAGES); DECLARE_TEXTUREARRAY(ORMConfigMap, MAX_STAGES);
bool mIsSRGb[MAX_STAGES]; bool mIsSRGb[MAX_STAGES];
DECLARE_TEXTUREARRAY(RoughMap, MAX_STAGES); DECLARE_TEXTUREARRAY(RoughMap, MAX_STAGES);
bool mInvertSmoothness[MAX_STAGES]; bool mInvertRoughness[MAX_STAGES];
F32 mSmoothnessChan[MAX_STAGES]; F32 mRoughnessChan[MAX_STAGES];
DECLARE_TEXTUREARRAY(AOMap, MAX_STAGES); DECLARE_TEXTUREARRAY(AOMap, MAX_STAGES);
F32 mAOChan[MAX_STAGES]; F32 mAOChan[MAX_STAGES];
DECLARE_TEXTUREARRAY(MetalMap, MAX_STAGES); DECLARE_TEXTUREARRAY(MetalMap, MAX_STAGES);
@ -240,7 +240,7 @@ public:
/// the diffuse texture color. /// the diffuse texture color.
LinearColorF mDiffuse[MAX_STAGES]; LinearColorF mDiffuse[MAX_STAGES];
F32 mSmoothness[MAX_STAGES]; F32 mRoughness[MAX_STAGES];
F32 mMetalness[MAX_STAGES]; F32 mMetalness[MAX_STAGES];
bool mVertLit[MAX_STAGES]; bool mVertLit[MAX_STAGES];

View file

@ -43,9 +43,9 @@ ImplementFeatureType( MFT_DetailMap, MFG_Texture, 4.0f, true );
ImplementFeatureType( MFT_DiffuseColor, MFG_Texture, 5.0f, true ); ImplementFeatureType( MFT_DiffuseColor, MFG_Texture, 5.0f, true );
ImplementFeatureType( MFT_DiffuseVertColor, MFG_Texture, 6.0f, true ); ImplementFeatureType( MFT_DiffuseVertColor, MFG_Texture, 6.0f, true );
ImplementFeatureType( MFT_AlphaTest, MFG_Texture, 7.0f, true ); ImplementFeatureType( MFT_AlphaTest, MFG_Texture, 7.0f, true );
ImplementFeatureType( MFT_InvertSmoothness, U32(-1), -1, true); ImplementFeatureType( MFT_InvertRoughness, U32(-1), -1, true);
ImplementFeatureType( MFT_PBRConfigMap, MFG_Texture, 8.0f, true); ImplementFeatureType( MFT_OrmMap, MFG_Texture, 8.0f, true);
ImplementFeatureType( MFT_PBRConfigVars, MFG_Texture, 8.0f, true); ImplementFeatureType( MFT_ORMConfigVars, MFG_Texture, 8.0f, true);
ImplementFeatureType( MFT_MatInfoFlags, MFG_Texture, 9.0f, true); ImplementFeatureType( MFT_MatInfoFlags, MFG_Texture, 9.0f, true);
ImplementFeatureType( MFT_NormalMap, MFG_Texture, 11.0f, true ); ImplementFeatureType( MFT_NormalMap, MFG_Texture, 11.0f, true );
ImplementFeatureType( MFT_DetailNormalMap, MFG_Texture, 12.0f, true ); ImplementFeatureType( MFT_DetailNormalMap, MFG_Texture, 12.0f, true );

View file

@ -124,9 +124,9 @@ DeclareFeatureType( MFT_VertLitTone );
DeclareFeatureType( MFT_StaticCubemap ); DeclareFeatureType( MFT_StaticCubemap );
DeclareFeatureType( MFT_CubeMap ); DeclareFeatureType( MFT_CubeMap );
DeclareFeatureType( MFT_InvertSmoothness ); DeclareFeatureType( MFT_InvertRoughness );
DeclareFeatureType( MFT_PBRConfigMap ); DeclareFeatureType( MFT_OrmMap );
DeclareFeatureType( MFT_PBRConfigVars ); DeclareFeatureType( MFT_ORMConfigVars );
DeclareFeatureType( MFT_GlowMap ); DeclareFeatureType( MFT_GlowMap );

View file

@ -485,27 +485,27 @@ void ProcessedMaterial::_setStageData()
if (mMaterial->mIsSRGb[i]) if (mMaterial->mIsSRGb[i])
profile = &GFXStaticTextureSRGBProfile; profile = &GFXStaticTextureSRGBProfile;
// PBRConfig // ORMConfig
if (mMaterial->mPBRConfigMapFilename[i].isNotEmpty()) if (mMaterial->mORMConfigMapFilename[i].isNotEmpty())
{ {
mStages[i].setTex(MFT_PBRConfigMap, _createTexture(mMaterial->mPBRConfigMapFilename[i], profile)); mStages[i].setTex(MFT_OrmMap, _createTexture(mMaterial->mORMConfigMapFilename[i], profile));
if (!mStages[i].getTex(MFT_PBRConfigMap)) if (!mStages[i].getTex(MFT_OrmMap))
mMaterial->logError("Failed to load PBR Config map %s for stage %i", _getTexturePath(mMaterial->mPBRConfigMapFilename[i]).c_str(), i); mMaterial->logError("Failed to load PBR Config map %s for stage %i", _getTexturePath(mMaterial->mORMConfigMapFilename[i]).c_str(), i);
} }
else else
{ {
if (mMaterial->mRoughMapFilename[i].isNotEmpty() && mMaterial->mMetalMapFilename[i].isNotEmpty()) if (mMaterial->mRoughMapFilename[i].isNotEmpty() && mMaterial->mMetalMapFilename[i].isNotEmpty())
{ {
U32 inputKey[4]; U32 inputKey[4];
inputKey[0] = mMaterial->mSmoothnessChan[i]; inputKey[0] = mMaterial->mAOChan[i];
inputKey[1] = mMaterial->mAOChan[i]; inputKey[1] = mMaterial->mRoughnessChan[i];
inputKey[2] = mMaterial->mMetalChan[i]; inputKey[2] = mMaterial->mMetalChan[i];
inputKey[3] = 0; inputKey[3] = 0;
mStages[i].setTex(MFT_PBRConfigMap, _createCompositeTexture(mMaterial->mRoughMapFilename[i], mMaterial->mAOMapFilename[i], mStages[i].setTex(MFT_OrmMap, _createCompositeTexture( mMaterial->mAOMapFilename[i], mMaterial->mRoughMapFilename[i],
mMaterial->mMetalMapFilename[i], "", mMaterial->mMetalMapFilename[i], "",
inputKey, profile)); inputKey, profile));
if (!mStages[i].getTex(MFT_PBRConfigMap)) if (!mStages[i].getTex(MFT_OrmMap))
mMaterial->logError("Failed to load PBR Config map %s for stage %i", _getTexturePath(mMaterial->mPBRConfigMapFilename[i]).c_str(), i); mMaterial->logError("Failed to load PBR Config map %s for stage %i", _getTexturePath(mMaterial->mORMConfigMapFilename[i]).c_str(), i);
} }
} }
if (mMaterial->mGlowMapFilename[i].isNotEmpty()) if (mMaterial->mGlowMapFilename[i].isNotEmpty())

View file

@ -59,8 +59,8 @@ void ShaderConstHandles::init( GFXShader *shader, CustomMaterial* mat /*=NULL*/)
mDiffuseColorSC = shader->getShaderConstHandle("$diffuseMaterialColor"); mDiffuseColorSC = shader->getShaderConstHandle("$diffuseMaterialColor");
mTexMatSC = shader->getShaderConstHandle(ShaderGenVars::texMat); mTexMatSC = shader->getShaderConstHandle(ShaderGenVars::texMat);
mToneMapTexSC = shader->getShaderConstHandle(ShaderGenVars::toneMap); mToneMapTexSC = shader->getShaderConstHandle(ShaderGenVars::toneMap);
mPBRConfigSC = shader->getShaderConstHandle(ShaderGenVars::pbrConfig); mORMConfigSC = shader->getShaderConstHandle(ShaderGenVars::ormConfig);
mSmoothnessSC = shader->getShaderConstHandle(ShaderGenVars::smoothness); mRoughnessSC = shader->getShaderConstHandle(ShaderGenVars::roughness);
mMetalnessSC = shader->getShaderConstHandle(ShaderGenVars::metalness); mMetalnessSC = shader->getShaderConstHandle(ShaderGenVars::metalness);
mGlowMulSC = shader->getShaderConstHandle(ShaderGenVars::glowMul); mGlowMulSC = shader->getShaderConstHandle(ShaderGenVars::glowMul);
mAccuScaleSC = shader->getShaderConstHandle("$accuScale"); mAccuScaleSC = shader->getShaderConstHandle("$accuScale");
@ -304,8 +304,8 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
// First we add all the features which the // First we add all the features which the
// material has defined. // material has defined.
if (mMaterial->mInvertSmoothness[stageNum]) if (mMaterial->mInvertRoughness[stageNum])
fd.features.addFeature(MFT_InvertSmoothness); fd.features.addFeature(MFT_InvertRoughness);
if ( mMaterial->isTranslucent() ) if ( mMaterial->isTranslucent() )
{ {
@ -429,12 +429,12 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
} }
// Deferred Shading : PBR Config // Deferred Shading : PBR Config
if (mStages[stageNum].getTex(MFT_PBRConfigMap)) if (mStages[stageNum].getTex(MFT_OrmMap))
{ {
fd.features.addFeature(MFT_PBRConfigMap); fd.features.addFeature(MFT_OrmMap);
} }
else else
fd.features.addFeature(MFT_PBRConfigVars); fd.features.addFeature(MFT_ORMConfigVars);
// Deferred Shading : Material Info Flags // Deferred Shading : Material Info Flags
fd.features.addFeature(MFT_MatInfoFlags); fd.features.addFeature(MFT_MatInfoFlags);
@ -450,7 +450,7 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
fd.features.addFeature(MFT_SkyBox); fd.features.addFeature(MFT_SkyBox);
fd.features.removeFeature(MFT_ReflectionProbes); fd.features.removeFeature(MFT_ReflectionProbes);
fd.features.removeFeature(MFT_PBRConfigVars); fd.features.removeFeature(MFT_ORMConfigVars);
fd.features.removeFeature(MFT_MatInfoFlags); fd.features.removeFeature(MFT_MatInfoFlags);
} }
@ -1109,7 +1109,7 @@ void ProcessedShaderMaterial::_setShaderConstants(SceneRenderState * state, cons
if ( !shaderConsts->wasLost() ) if ( !shaderConsts->wasLost() )
return; return;
shaderConsts->setSafe(handles->mSmoothnessSC, mMaterial->mSmoothness[stageNum]); shaderConsts->setSafe(handles->mRoughnessSC, mMaterial->mRoughness[stageNum]);
shaderConsts->setSafe(handles->mMetalnessSC, mMaterial->mMetalness[stageNum]); shaderConsts->setSafe(handles->mMetalnessSC, mMaterial->mMetalness[stageNum]);
shaderConsts->setSafe(handles->mGlowMulSC, mMaterial->mGlowMul[stageNum]); shaderConsts->setSafe(handles->mGlowMulSC, mMaterial->mGlowMul[stageNum]);

View file

@ -46,8 +46,8 @@ public:
GFXShaderConstHandle* mDiffuseColorSC; GFXShaderConstHandle* mDiffuseColorSC;
GFXShaderConstHandle* mToneMapTexSC; GFXShaderConstHandle* mToneMapTexSC;
GFXShaderConstHandle* mTexMatSC; GFXShaderConstHandle* mTexMatSC;
GFXShaderConstHandle* mPBRConfigSC; GFXShaderConstHandle* mORMConfigSC;
GFXShaderConstHandle* mSmoothnessSC; GFXShaderConstHandle* mRoughnessSC;
GFXShaderConstHandle* mMetalnessSC; GFXShaderConstHandle* mMetalnessSC;
GFXShaderConstHandle* mGlowMulSC; GFXShaderConstHandle* mGlowMulSC;
GFXShaderConstHandle* mParallaxInfoSC; GFXShaderConstHandle* mParallaxInfoSC;

View file

@ -633,16 +633,16 @@ void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum,
} }
newFeatures.addFeature( MFT_DiffuseColor ); newFeatures.addFeature( MFT_DiffuseColor );
if (mMaterial->mInvertSmoothness[stageNum]) if (mMaterial->mInvertRoughness[stageNum])
newFeatures.addFeature(MFT_InvertSmoothness); newFeatures.addFeature(MFT_InvertRoughness);
// Deferred Shading : PBR Config // Deferred Shading : PBR Config
if( mStages[stageNum].getTex( MFT_PBRConfigMap ) ) if( mStages[stageNum].getTex( MFT_OrmMap ) )
{ {
newFeatures.addFeature( MFT_PBRConfigMap ); newFeatures.addFeature( MFT_OrmMap );
} }
else else
newFeatures.addFeature( MFT_PBRConfigVars ); newFeatures.addFeature( MFT_ORMConfigVars );
if (mStages[stageNum].getTex(MFT_GlowMap)) if (mStages[stageNum].getTex(MFT_GlowMap))
{ {

View file

@ -204,7 +204,8 @@ RenderProbeMgr::RenderProbeMgr()
mHasSkylight(false), mHasSkylight(false),
mSkylightCubemapIdx(-1), mSkylightCubemapIdx(-1),
mCubeMapCount(0), mCubeMapCount(0),
mDefaultSkyLight(nullptr) mDefaultSkyLight(nullptr),
mBakeRenderTarget(nullptr)
{ {
mEffectiveProbeCount = 0; mEffectiveProbeCount = 0;
mMipCount = 0; mMipCount = 0;
@ -462,7 +463,7 @@ void RenderProbeMgr::_setupStaticParameters()
continue; continue;
U32 mips = mRegisteredProbes[i].mPrefilterCubemap.getPointer()->getMipMapLevels(); U32 mips = mRegisteredProbes[i].mPrefilterCubemap.getPointer()->getMipMapLevels();
mMipCount = mips != 0 && mips >= mMipCount ? mips : 0; mMipCount = (mips != 0 && mips >= mMipCount) ? mips : 0;
if (curEntry.mIsSkylight) if (curEntry.mIsSkylight)
{ {
@ -853,7 +854,7 @@ void RenderProbeMgr::render( SceneRenderState *state )
//PROFILE_END(); //PROFILE_END();
} }
void RenderProbeMgr::bakeProbe(ReflectionProbe *probe, bool writeFiles) void RenderProbeMgr::bakeProbe(ReflectionProbe* probe, bool writeFiles)
{ {
GFXDEBUGEVENT_SCOPE(RenderProbeMgr_Bake, ColorI::WHITE); GFXDEBUGEVENT_SCOPE(RenderProbeMgr_Bake, ColorI::WHITE);
@ -862,7 +863,7 @@ void RenderProbeMgr::bakeProbe(ReflectionProbe *probe, bool writeFiles)
String path = Con::getVariable("$pref::ReflectionProbes::CurrentLevelPath", "levels/"); String path = Con::getVariable("$pref::ReflectionProbes::CurrentLevelPath", "levels/");
U32 resolution = Con::getIntVariable("$pref::ReflectionProbes::BakeResolution", 64); U32 resolution = Con::getIntVariable("$pref::ReflectionProbes::BakeResolution", 64);
U32 prefilterMipLevels = mLog2(F32(resolution)); U32 prefilterMipLevels = mLog2(F32(resolution))+1;
bool renderWithProbes = Con::getIntVariable("$pref::ReflectionProbes::RenderWithProbes", false); bool renderWithProbes = Con::getIntVariable("$pref::ReflectionProbes::RenderWithProbes", false);
ReflectionProbe* clientProbe = nullptr; ReflectionProbe* clientProbe = nullptr;
@ -957,12 +958,13 @@ void RenderProbeMgr::bakeProbe(ReflectionProbe *probe, bool writeFiles)
clientProbe->mIrridianceMap->mCubemap->initDynamic(resolution, reflectFormat); clientProbe->mIrridianceMap->mCubemap->initDynamic(resolution, reflectFormat);
clientProbe->mPrefilterMap->mCubemap->initDynamic(resolution, reflectFormat); clientProbe->mPrefilterMap->mCubemap->initDynamic(resolution, reflectFormat);
GFXTextureTargetRef renderTarget = GFX->allocRenderToTextureTarget(false); if (mBakeRenderTarget == nullptr)
mBakeRenderTarget = GFX->allocRenderToTextureTarget(false);
else
mBakeRenderTarget->resurrect();
IBLUtilities::GenerateIrradianceMap(renderTarget, cubeRefl.getCubemap(), clientProbe->mIrridianceMap->mCubemap); IBLUtilities::GenerateIrradianceMap(mBakeRenderTarget, cubeRefl.getCubemap(), clientProbe->mIrridianceMap->mCubemap);
IBLUtilities::GeneratePrefilterMap(renderTarget, cubeRefl.getCubemap(), prefilterMipLevels, clientProbe->mPrefilterMap->mCubemap); IBLUtilities::GeneratePrefilterMap(mBakeRenderTarget, cubeRefl.getCubemap(), prefilterMipLevels, clientProbe->mPrefilterMap->mCubemap);
renderTarget->destroySelf();
U32 endMSTime = Platform::getRealMilliseconds(); U32 endMSTime = Platform::getRealMilliseconds();
F32 diffTime = F32(endMSTime - startMSTime); F32 diffTime = F32(endMSTime - startMSTime);
@ -975,12 +977,15 @@ void RenderProbeMgr::bakeProbe(ReflectionProbe *probe, bool writeFiles)
IBLUtilities::SaveCubeMap(clientProbe->getIrradianceMapPath(), clientProbe->mIrridianceMap->mCubemap); IBLUtilities::SaveCubeMap(clientProbe->getIrradianceMapPath(), clientProbe->mIrridianceMap->mCubemap);
IBLUtilities::SaveCubeMap(clientProbe->getPrefilterMapPath(), clientProbe->mPrefilterMap->mCubemap); IBLUtilities::SaveCubeMap(clientProbe->getPrefilterMapPath(), clientProbe->mPrefilterMap->mCubemap);
} }
mBakeRenderTarget->zombify();
} }
else else
{ {
Con::errorf("RenderProbeMgr::bake() - Didn't generate a valid scene capture cubemap, unable to generate prefilter and irradiance maps!"); Con::errorf("RenderProbeMgr::bake() - Didn't generate a valid scene capture cubemap, unable to generate prefilter and irradiance maps!");
} }
if (!renderWithProbes) if (!renderWithProbes)
RenderProbeMgr::smRenderReflectionProbes = probeRenderState; RenderProbeMgr::smRenderReflectionProbes = probeRenderState;

View file

@ -280,6 +280,8 @@ private:
GFXTexHandle mBRDFTexture; GFXTexHandle mBRDFTexture;
GFXTextureTargetRef mBakeRenderTarget;
public: public:
RenderProbeMgr(); RenderProbeMgr();
RenderProbeMgr(RenderInstType riType, F32 renderOrder, F32 processAddOrder); RenderProbeMgr(RenderInstType riType, F32 renderOrder, F32 processAddOrder);

View file

@ -841,8 +841,8 @@ Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
Var* pbrConfig = (Var*)LangElement::find("PBRConfig"); Var* ormConfig = (Var*)LangElement::find("ORMConfig");
if (!pbrConfig) if (!ormConfig)
{ {
Var* metalness = (Var*)LangElement::find("metalness"); Var* metalness = (Var*)LangElement::find("metalness");
if (!metalness) if (!metalness)
@ -852,17 +852,17 @@ Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
metalness->constSortPos = cspPotentialPrimitive; metalness->constSortPos = cspPotentialPrimitive;
} }
Var* smoothness = (Var*)LangElement::find("smoothness"); Var* roughness = (Var*)LangElement::find("roughness");
if (!smoothness) if (!roughness)
{ {
smoothness = new Var("smoothness", "float"); roughness = new Var("roughness", "float");
smoothness->uniform = true; roughness->uniform = true;
smoothness->constSortPos = cspPotentialPrimitive; roughness->constSortPos = cspPotentialPrimitive;
} }
pbrConfig = new Var("PBRConfig", "vec4"); ormConfig = new Var("ORMConfig", "vec4");
LangElement* colorDecl = new DecOp(pbrConfig); LangElement* colorDecl = new DecOp(ormConfig);
meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct pbrConfig, no ao darkening meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,@,@);\r\n", colorDecl, roughness, metalness)); //reconstruct ormConfig, no ao darkening
} }
Var* wsNormal = (Var*)LangElement::find("wsNormal"); Var* wsNormal = (Var*)LangElement::find("wsNormal");
@ -899,7 +899,7 @@ Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
if (!surface) if (!surface)
{ {
surface = new Var("surface", "Surface"); surface = new Var("surface", "Surface");
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, pbrConfig, meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, ormConfig,
wsPosition, wsEyePos, wsView)); wsPosition, wsEyePos, wsView));
} }
@ -1922,9 +1922,9 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
LangElement *texCube = NULL; LangElement *texCube = NULL;
Var* matinfo = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) ); Var* matinfo = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
Var *smoothness = (Var*)LangElement::find("smoothness"); Var *roughness = (Var*)LangElement::find("roughness");
if (smoothness) //try to grab smoothness directly if (roughness) //try to grab roughness directly
texCube = new GenOp("textureLod( @, @, min((1.0 - @)*@ + 1.0, @))", cubeMap, reflectVec, smoothness, cubeMips, cubeMips); texCube = new GenOp("textureLod( @, @, min((1.0 - @)*@ + 1.0, @))", cubeMap, reflectVec, roughness, cubeMips, cubeMips);
else if (glossColor) //failing that, try and find color data else if (glossColor) //failing that, try and find color data
texCube = new GenOp("textureLod( @, @, min((1.0 - @.b)*@ + 1.0, @))", cubeMap, reflectVec, glossColor, cubeMips, cubeMips); texCube = new GenOp("textureLod( @, @, min((1.0 - @.b)*@ + 1.0, @))", cubeMap, reflectVec, glossColor, cubeMips, cubeMips);
else //failing *that*, just draw the cubemap else //failing *that*, just draw the cubemap
@ -2219,7 +2219,7 @@ void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
Con::errorf("ShaderGen::RTLightingFeatGLSL() - failed to generate surface!"); Con::errorf("ShaderGen::RTLightingFeatGLSL() - failed to generate surface!");
return; return;
} }
Var *smoothness = (Var*)LangElement::find("smoothness"); Var *roughness = (Var*)LangElement::find("roughness");
Var *metalness = (Var*)LangElement::find("metalness"); Var *metalness = (Var*)LangElement::find("metalness");

View file

@ -64,7 +64,7 @@ void _initShaderGenGLSL( ShaderGen *shaderGen )
FEATUREMGR->registerFeature( MFT_DetailMap, new DetailFeatGLSL ); FEATUREMGR->registerFeature( MFT_DetailMap, new DetailFeatGLSL );
FEATUREMGR->registerFeature( MFT_StaticCubemap, new NamedFeatureGLSL( "Static Cubemap" ) ); FEATUREMGR->registerFeature( MFT_StaticCubemap, new NamedFeatureGLSL( "Static Cubemap" ) );
FEATUREMGR->registerFeature( MFT_CubeMap, new ReflectCubeFeatGLSL ); FEATUREMGR->registerFeature( MFT_CubeMap, new ReflectCubeFeatGLSL );
FEATUREMGR->registerFeature( MFT_InvertSmoothness, new NamedFeatureGLSL("Roughest = 1.0")); FEATUREMGR->registerFeature( MFT_InvertRoughness, new NamedFeatureGLSL("Roughest = 1.0"));
FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatGLSL ); FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatGLSL );
FEATUREMGR->registerFeature( MFT_IsTranslucent, new NamedFeatureGLSL( "Translucent" ) ); FEATUREMGR->registerFeature( MFT_IsTranslucent, new NamedFeatureGLSL( "Translucent" ) );
FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureGLSL( "Translucent ZWrite" ) ); FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureGLSL( "Translucent ZWrite" ) );
@ -99,8 +99,8 @@ void _initShaderGenGLSL( ShaderGen *shaderGen )
// Deferred Shading // Deferred Shading
FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureGLSL( "Deferred Material" ) ); FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureGLSL( "Deferred Material" ) );
FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapGLSL ); FEATUREMGR->registerFeature( MFT_OrmMap, new DeferredOrmMapGLSL );
FEATUREMGR->registerFeature( MFT_PBRConfigVars, new PBRConfigVarsGLSL ); FEATUREMGR->registerFeature( MFT_ORMConfigVars, new ORMConfigVarsGLSL );
FEATUREMGR->registerFeature( MFT_MatInfoFlags, new MatInfoFlagsGLSL ); FEATUREMGR->registerFeature( MFT_MatInfoFlags, new MatInfoFlagsGLSL );
FEATUREMGR->registerFeature( MFT_GlowMap, new GlowMapGLSL); FEATUREMGR->registerFeature( MFT_GlowMap, new GlowMapGLSL);
FEATUREMGR->registerFeature( MFT_isBackground, new NamedFeatureGLSL("Background Object")); FEATUREMGR->registerFeature( MFT_isBackground, new NamedFeatureGLSL("Background Object"));

View file

@ -155,9 +155,9 @@ void DebugVizHLSL::processPix(Vector<ShaderComponent*>& componentList,
Var* irradianceCubemapAR = (Var*)LangElement::find("irradianceCubemapAR"); Var* irradianceCubemapAR = (Var*)LangElement::find("irradianceCubemapAR");
Var* irradianceCubemapARTex = (Var*)LangElement::find("texture_irradianceCubemapAR"); Var* irradianceCubemapARTex = (Var*)LangElement::find("texture_irradianceCubemapAR");
Var* matinfo = (Var*)LangElement::find("PBRConfig"); Var* matinfo = (Var*)LangElement::find("ORMConfig");
Var* metalness = (Var*)LangElement::find("metalness"); Var* metalness = (Var*)LangElement::find("metalness");
Var* smoothness = (Var*)LangElement::find("smoothness"); Var* roughness = (Var*)LangElement::find("roughness");
Var* wsEyePos = (Var*)LangElement::find("eyePosWorld"); Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");

View file

@ -848,8 +848,8 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
Var* pbrConfig = (Var*)LangElement::find("PBRConfig"); Var* ormConfig = (Var*)LangElement::find("ORMConfig");
if (!pbrConfig) if (!ormConfig)
{ {
Var* metalness = (Var*)LangElement::find("metalness"); Var* metalness = (Var*)LangElement::find("metalness");
if (!metalness) if (!metalness)
@ -859,17 +859,17 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
metalness->constSortPos = cspPotentialPrimitive; metalness->constSortPos = cspPotentialPrimitive;
} }
Var* smoothness = (Var*)LangElement::find("smoothness"); Var* roughness = (Var*)LangElement::find("roughness");
if (!smoothness) if (!roughness)
{ {
smoothness = new Var("smoothness", "float"); roughness = new Var("roughness", "float");
smoothness->uniform = true; roughness->uniform = true;
smoothness->constSortPos = cspPotentialPrimitive; roughness->constSortPos = cspPotentialPrimitive;
} }
pbrConfig = new Var("PBRConfig", "float4"); ormConfig = new Var("ORMConfig", "float4");
LangElement* colorDecl = new DecOp(pbrConfig); LangElement* colorDecl = new DecOp(ormConfig);
meta->addStatement(new GenOp(" @ = float4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct matinfo, no ao darkening meta->addStatement(new GenOp(" @ = float4(0.0,1.0,@,@);\r\n", colorDecl, roughness, metalness)); //reconstruct matinfo, no ao darkening
} }
Var* normal = (Var*)LangElement::find("normal"); Var* normal = (Var*)LangElement::find("normal");
@ -902,7 +902,7 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
if (!surface) if (!surface)
{ {
surface = new Var("surface", "Surface"); surface = new Var("surface", "Surface");
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, pbrConfig, meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, ormConfig,
wsPosition, wsEyePos, wsView)); wsPosition, wsEyePos, wsView));
} }
@ -1327,7 +1327,7 @@ void LightmapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
lightMapTex->texture = true; lightMapTex->texture = true;
lightMapTex->constNum = lightMap->constNum; lightMapTex->constNum = lightMap->constNum;
// argh, PBRConfigMap should prob use this too // argh, ORMConfigMap should prob use this too
if( fd.features[MFT_NormalMap] ) if( fd.features[MFT_NormalMap] )
{ {
Var *lmColor = new Var; Var *lmColor = new Var;
@ -1985,11 +1985,11 @@ void ReflectCubeFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
LangElement *texCube = NULL; LangElement *texCube = NULL;
Var* matinfo = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) ); Var* matinfo = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
Var *smoothness = (Var*)LangElement::find("smoothness"); Var *roughness = (Var*)LangElement::find("roughness");
if (smoothness) //try to grab smoothness directly if (roughness) //try to grab roughness directly
{ {
texCube = new GenOp("@.SampleLevel( @, float3(@).rgb, min((1.0 - @)*@ + 1.0, @))", cubeMapTex, cubeMap, reflectVec, smoothness, cubeMips, cubeMips); texCube = new GenOp("@.SampleLevel( @, float3(@).rgb, min((1.0 - @)*@ + 1.0, @))", cubeMapTex, cubeMap, reflectVec, roughness, cubeMips, cubeMips);
} }
else if (glossColor)//failing that, try and find color data else if (glossColor)//failing that, try and find color data
{ {
@ -2287,7 +2287,7 @@ void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
Con::errorf("ShaderGen::RTLightingFeatHLSL() - failed to generate surface!"); Con::errorf("ShaderGen::RTLightingFeatHLSL() - failed to generate surface!");
return; return;
} }
Var *smoothness = (Var*)LangElement::find("smoothness"); Var *roughness = (Var*)LangElement::find("roughness");
Var *metalness = (Var*)LangElement::find("metalness"); Var *metalness = (Var*)LangElement::find("metalness");

View file

@ -65,7 +65,7 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
FEATUREMGR->registerFeature( MFT_StaticCubemap, new NamedFeatureHLSL( "Static Cubemap" ) ); FEATUREMGR->registerFeature( MFT_StaticCubemap, new NamedFeatureHLSL( "Static Cubemap" ) );
FEATUREMGR->registerFeature( MFT_CubeMap, new ReflectCubeFeatHLSL ); FEATUREMGR->registerFeature( MFT_CubeMap, new ReflectCubeFeatHLSL );
FEATUREMGR->registerFeature( MFT_ReflectionProbes, new ReflectionProbeFeatHLSL); FEATUREMGR->registerFeature( MFT_ReflectionProbes, new ReflectionProbeFeatHLSL);
FEATUREMGR->registerFeature( MFT_InvertSmoothness, new NamedFeatureHLSL( "Roughest = 1.0" ) ); FEATUREMGR->registerFeature( MFT_InvertRoughness, new NamedFeatureHLSL( "Roughest = 1.0" ) );
FEATUREMGR->registerFeature( MFT_IsTranslucent, new NamedFeatureHLSL( "Translucent" ) ); FEATUREMGR->registerFeature( MFT_IsTranslucent, new NamedFeatureHLSL( "Translucent" ) );
FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureHLSL( "Translucent ZWrite" ) ); FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureHLSL( "Translucent ZWrite" ) );
FEATUREMGR->registerFeature( MFT_Visibility, new VisibilityFeatHLSL ); FEATUREMGR->registerFeature( MFT_Visibility, new VisibilityFeatHLSL );
@ -102,8 +102,8 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
FEATUREMGR->registerFeature( MFT_ImposterVert, new ImposterVertFeatureHLSL ); FEATUREMGR->registerFeature( MFT_ImposterVert, new ImposterVertFeatureHLSL );
FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureHLSL( "Deferred Material" ) ); FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureHLSL( "Deferred Material" ) );
FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapHLSL); FEATUREMGR->registerFeature( MFT_OrmMap, new DeferredOrmMapHLSL);
FEATUREMGR->registerFeature( MFT_PBRConfigVars, new PBRConfigVarsHLSL); FEATUREMGR->registerFeature( MFT_ORMConfigVars, new ORMConfigVarsHLSL);
FEATUREMGR->registerFeature( MFT_MatInfoFlags, new MatInfoFlagsHLSL ); FEATUREMGR->registerFeature( MFT_MatInfoFlags, new MatInfoFlagsHLSL );
FEATUREMGR->registerFeature( MFT_GlowMap, new GlowMapHLSL); FEATUREMGR->registerFeature( MFT_GlowMap, new GlowMapHLSL);
FEATUREMGR->registerFeature( MFT_isBackground, new NamedFeatureHLSL("Background Object")); FEATUREMGR->registerFeature( MFT_isBackground, new NamedFeatureHLSL("Background Object"));

View file

@ -73,8 +73,8 @@ const String ShaderGenVars::vectorLightDirection("$vectorLightDirection");
const String ShaderGenVars::vectorLightColor("$vectorLightColor"); const String ShaderGenVars::vectorLightColor("$vectorLightColor");
const String ShaderGenVars::vectorLightBrightness("$vectorLightBrightness"); const String ShaderGenVars::vectorLightBrightness("$vectorLightBrightness");
const String ShaderGenVars::pbrConfig("$PBRConfig"); const String ShaderGenVars::ormConfig("$ORMConfig");
const String ShaderGenVars::smoothness("$smoothness"); const String ShaderGenVars::roughness("$roughness");
const String ShaderGenVars::metalness("$metalness"); const String ShaderGenVars::metalness("$metalness");
const String ShaderGenVars::glowMul("$glowMul"); const String ShaderGenVars::glowMul("$glowMul");

View file

@ -85,8 +85,8 @@ struct ShaderGenVars
const static String vectorLightColor; const static String vectorLightColor;
const static String vectorLightBrightness; const static String vectorLightBrightness;
const static String pbrConfig; const static String ormConfig;
const static String smoothness; const static String roughness;
const static String metalness; const static String metalness;
const static String glowMul; const static String glowMul;

View file

@ -49,7 +49,7 @@ namespace
FEATUREMGR->registerFeature( MFT_TerrainLightMap, new TerrainLightMapFeatGLSL ); FEATUREMGR->registerFeature( MFT_TerrainLightMap, new TerrainLightMapFeatGLSL );
FEATUREMGR->registerFeature( MFT_TerrainSideProject, new NamedFeatureGLSL( "Terrain Side Projection" ) ); FEATUREMGR->registerFeature( MFT_TerrainSideProject, new NamedFeatureGLSL( "Terrain Side Projection" ) );
FEATUREMGR->registerFeature( MFT_TerrainAdditive, new TerrainAdditiveFeatGLSL ); FEATUREMGR->registerFeature( MFT_TerrainAdditive, new TerrainAdditiveFeatGLSL );
FEATUREMGR->registerFeature( MFT_TerrainCompositeMap, new TerrainCompositeMapFeatGLSL ); FEATUREMGR->registerFeature( MFT_TerrainORMMap, new TerrainORMMapFeatGLSL );
FEATUREMGR->registerFeature( MFT_DeferredTerrainBlankInfoMap, new TerrainBlankInfoMapFeatGLSL ); FEATUREMGR->registerFeature( MFT_DeferredTerrainBlankInfoMap, new TerrainBlankInfoMapFeatGLSL );
} }
@ -142,22 +142,22 @@ Var* TerrainFeatGLSL::_getNormalMapTex()
return normalMap; return normalMap;
} }
Var* TerrainFeatGLSL::_getCompositeMapTex() Var* TerrainFeatGLSL::_getORMConfigMapTex()
{ {
String name(String::ToString("compositeMap%d", getProcessIndex())); String name(String::ToString("ormConfigMap%d", getProcessIndex()));
Var *compositeMap = (Var*)LangElement::find(name); Var *ormConfigMap = (Var*)LangElement::find(name);
if (!compositeMap) if (!ormConfigMap)
{ {
compositeMap = new Var; ormConfigMap = new Var;
compositeMap->setType("sampler2D"); ormConfigMap->setType("sampler2D");
compositeMap->setName(name); ormConfigMap->setName(name);
compositeMap->uniform = true; ormConfigMap->uniform = true;
compositeMap->sampler = true; ormConfigMap->sampler = true;
compositeMap->constNum = Var::getTexUnitNum(); ormConfigMap->constNum = Var::getTexUnitNum();
} }
return compositeMap; return ormConfigMap;
} }
Var* TerrainFeatGLSL::_getDetailIdStrengthParallax() Var* TerrainFeatGLSL::_getDetailIdStrengthParallax()
@ -1140,7 +1140,7 @@ void TerrainAdditiveFeatGLSL::processPix( Vector<ShaderComponent*> &componentLis
//.b = specular strength, a= spec power. //.b = specular strength, a= spec power.
void TerrainCompositeMapFeatGLSL::processVert(Vector<ShaderComponent*> &componentList, void TerrainORMMapFeatGLSL::processVert(Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd) const MaterialFeatureData &fd)
{ {
const S32 detailIndex = getProcessIndex(); const S32 detailIndex = getProcessIndex();
@ -1230,12 +1230,12 @@ void TerrainCompositeMapFeatGLSL::processVert(Vector<ShaderComponent*> &componen
output = meta; output = meta;
} }
U32 TerrainCompositeMapFeatGLSL::getOutputTargets(const MaterialFeatureData &fd) const U32 TerrainORMMapFeatGLSL::getOutputTargets(const MaterialFeatureData &fd) const
{ {
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1; return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1;
} }
void TerrainCompositeMapFeatGLSL::processPix(Vector<ShaderComponent*> &componentList, void TerrainORMMapFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd) const MaterialFeatureData &fd)
{ {
/// Get the texture coord. /// Get the texture coord.
@ -1243,7 +1243,7 @@ void TerrainCompositeMapFeatGLSL::processPix(Vector<ShaderComponent*> &component
Var *inTex = getVertTexCoord("texCoord"); Var *inTex = getVertTexCoord("texCoord");
const S32 compositeIndex = getProcessIndex(); const S32 compositeIndex = getProcessIndex();
Var *compositeMap = _getCompositeMapTex(); Var *ormConfigMap = _getORMConfigMapTex();
// Sample the normal map. // Sample the normal map.
// //
// We take two normal samples and lerp between them for // We take two normal samples and lerp between them for
@ -1253,28 +1253,28 @@ void TerrainCompositeMapFeatGLSL::processPix(Vector<ShaderComponent*> &component
if (fd.features.hasFeature(MFT_TerrainSideProject, compositeIndex)) if (fd.features.hasFeature(MFT_TerrainSideProject, compositeIndex))
{ {
texOp = new GenOp("lerp( tex2D( @, @.yz ), tex2D( @, @.xz ), @.z )", texOp = new GenOp("lerp( tex2D( @, @.yz ), tex2D( @, @.xz ), @.z )",
compositeMap, inDet, compositeMap, inDet, inTex); ormConfigMap, inDet, ormConfigMap, inDet, inTex);
} }
else else
texOp = new GenOp("tex2D(@, @.xy)", compositeMap, inDet); texOp = new GenOp("tex2D(@, @.xy)", ormConfigMap, inDet);
// search for material var // search for material var
Var * pbrConfig; Var * ormConfig;
OutputTarget targ = RenderTarget1; OutputTarget targ = RenderTarget1;
if (fd.features[MFT_isDeferred]) if (fd.features[MFT_isDeferred])
{ {
targ = RenderTarget2; targ = RenderTarget2;
} }
pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(targ)); ormConfig = (Var*)LangElement::find(getOutputTargetVarName(targ));
MultiLine * meta = new MultiLine; MultiLine * meta = new MultiLine;
if (!pbrConfig) if (!ormConfig)
{ {
// create color var // create color var
pbrConfig = new Var; ormConfig = new Var;
pbrConfig->setType("fragout"); ormConfig->setType("fragout");
pbrConfig->setName(getOutputTargetVarName(targ)); ormConfig->setName(getOutputTargetVarName(targ));
pbrConfig->setStructName("OUT"); ormConfig->setStructName("OUT");
} }
Var *detailBlend = (Var*)LangElement::find(String::ToString("detailBlend%d", compositeIndex)); Var *detailBlend = (Var*)LangElement::find(String::ToString("detailBlend%d", compositeIndex));
@ -1287,23 +1287,23 @@ void TerrainCompositeMapFeatGLSL::processPix(Vector<ShaderComponent*> &component
if (priorComp) if (priorComp)
{ {
meta->addStatement(new GenOp(" @ = @.rgb*@;\r\n", new DecOp(matinfoCol), texOp, detailBlend)); meta->addStatement(new GenOp(" @ = @.rgb*@;\r\n", new DecOp(matinfoCol), texOp, detailBlend));
meta->addStatement(new GenOp(" @.bga += @;\r\n", pbrConfig, matinfoCol)); meta->addStatement(new GenOp(" @.gba += @;\r\n", ormConfig, matinfoCol));
} }
else else
{ {
meta->addStatement(new GenOp(" @ = lerp(vec3(0,1,0),@.rgb,@);\r\n", new DecOp(matinfoCol), texOp, detailBlend)); meta->addStatement(new GenOp(" @ = lerp(vec3(1.0,1.0,0.0),@.rgb,@);\r\n", new DecOp(matinfoCol), texOp, detailBlend));
meta->addStatement(new GenOp(" @ = vec4(0.0,@);\r\n", pbrConfig, matinfoCol)); meta->addStatement(new GenOp(" @ = vec4(0.0,@);\r\n", ormConfig, matinfoCol));
} }
if (!fd.features[MFT_InvertSmoothness]) if (fd.features[MFT_InvertRoughness])
{ {
meta->addStatement(new GenOp(" @.b = 1.0-@.b;\r\n", pbrConfig, pbrConfig)); meta->addStatement(new GenOp(" @.b = 1.0-@.b;\r\n", ormConfig, ormConfig));
} }
output = meta; output = meta;
} }
ShaderFeature::Resources TerrainCompositeMapFeatGLSL::getResources(const MaterialFeatureData &fd) ShaderFeature::Resources TerrainORMMapFeatGLSL::getResources(const MaterialFeatureData &fd)
{ {
Resources res; Resources res;
res.numTex = 1; res.numTex = 1;
@ -1340,7 +1340,7 @@ void TerrainBlankInfoMapFeatGLSL::processPix(Vector<ShaderComponent*> &component
material->setStructName("OUT"); material->setStructName("OUT");
} }
meta->addStatement(new GenOp(" @ = vec4(0.0,0.0,1.0,0);\r\n", material)); meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,1.0,0.0);\r\n", material));
output = meta; output = meta;
} }

View file

@ -46,7 +46,7 @@ public:
Var* _getNormalMapTex(); Var* _getNormalMapTex();
Var* _getCompositeMapTex(); Var* _getORMConfigMapTex();
static Var* _getUniformVar( const char *name, const char *type, ConstantSortPosition csp ); static Var* _getUniformVar( const char *name, const char *type, ConstantSortPosition csp );
@ -162,7 +162,7 @@ public:
virtual String getName() { return "Terrain Additive"; } virtual String getName() { return "Terrain Additive"; }
}; };
class TerrainCompositeMapFeatGLSL : public TerrainFeatGLSL class TerrainORMMapFeatGLSL : public TerrainFeatGLSL
{ {
public: public:

View file

@ -49,7 +49,7 @@ namespace
FEATUREMGR->registerFeature( MFT_TerrainLightMap, new TerrainLightMapFeatHLSL ); FEATUREMGR->registerFeature( MFT_TerrainLightMap, new TerrainLightMapFeatHLSL );
FEATUREMGR->registerFeature( MFT_TerrainSideProject, new NamedFeatureHLSL( "Terrain Side Projection" ) ); FEATUREMGR->registerFeature( MFT_TerrainSideProject, new NamedFeatureHLSL( "Terrain Side Projection" ) );
FEATUREMGR->registerFeature( MFT_TerrainAdditive, new TerrainAdditiveFeatHLSL ); FEATUREMGR->registerFeature( MFT_TerrainAdditive, new TerrainAdditiveFeatHLSL );
FEATUREMGR->registerFeature( MFT_TerrainCompositeMap, new TerrainCompositeMapFeatHLSL ); FEATUREMGR->registerFeature( MFT_TerrainORMMap, new TerrainORMMapFeatHLSL );
FEATUREMGR->registerFeature( MFT_DeferredTerrainBlankInfoMap, new TerrainBlankInfoMapFeatHLSL ); FEATUREMGR->registerFeature( MFT_DeferredTerrainBlankInfoMap, new TerrainBlankInfoMapFeatHLSL );
} }
}; };
@ -141,22 +141,22 @@ Var* TerrainFeatHLSL::_getNormalMapTex()
return normalMap; return normalMap;
} }
Var* TerrainFeatHLSL::_getCompositeMapTex() Var* TerrainFeatHLSL::_getORMConfigMapTex()
{ {
String name(String::ToString("compositeMap%d", getProcessIndex())); String name(String::ToString("ormConfigMap%d", getProcessIndex()));
Var *compositeMap = (Var*)LangElement::find(name); Var *ormConfigMap = (Var*)LangElement::find(name);
if (!compositeMap) if (!ormConfigMap)
{ {
compositeMap = new Var; ormConfigMap = new Var;
compositeMap->setType("SamplerState"); ormConfigMap->setType("SamplerState");
compositeMap->setName(name); ormConfigMap->setName(name);
compositeMap->uniform = true; ormConfigMap->uniform = true;
compositeMap->sampler = true; ormConfigMap->sampler = true;
compositeMap->constNum = Var::getTexUnitNum(); ormConfigMap->constNum = Var::getTexUnitNum();
} }
return compositeMap; return ormConfigMap;
} }
Var* TerrainFeatHLSL::_getDetailIdStrengthParallax() Var* TerrainFeatHLSL::_getDetailIdStrengthParallax()
@ -1148,7 +1148,7 @@ void TerrainAdditiveFeatHLSL::processPix( Vector<ShaderComponent*> &componentLis
//standard matInfo map contains data of the form .r = bitflags, .g = (will contain AO), //standard matInfo map contains data of the form .r = bitflags, .g = (will contain AO),
//.b = specular strength, a= spec power. //.b = specular strength, a= spec power.
void TerrainCompositeMapFeatHLSL::processVert(Vector<ShaderComponent*> &componentList, void TerrainORMMapFeatHLSL::processVert(Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd) const MaterialFeatureData &fd)
{ {
const S32 detailIndex = getProcessIndex(); const S32 detailIndex = getProcessIndex();
@ -1238,12 +1238,12 @@ void TerrainCompositeMapFeatHLSL::processVert(Vector<ShaderComponent*> &componen
output = meta; output = meta;
} }
U32 TerrainCompositeMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const U32 TerrainORMMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const
{ {
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget; return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
} }
void TerrainCompositeMapFeatHLSL::processPix(Vector<ShaderComponent*> &componentList, void TerrainORMMapFeatHLSL::processPix(Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd) const MaterialFeatureData &fd)
{ {
/// Get the texture coord. /// Get the texture coord.
@ -1251,48 +1251,48 @@ void TerrainCompositeMapFeatHLSL::processPix(Vector<ShaderComponent*> &component
Var *inTex = getVertTexCoord("texCoord"); Var *inTex = getVertTexCoord("texCoord");
const S32 compositeIndex = getProcessIndex(); const S32 compositeIndex = getProcessIndex();
Var *compositeMap = _getCompositeMapTex(); Var *ormConfigMap = _getORMConfigMapTex();
// Sample the normal map. // Sample the normal map.
// //
// We take two normal samples and lerp between them for // We take two normal samples and lerp between them for
// side projection layers... else a single sample. // side projection layers... else a single sample.
LangElement *texOp; LangElement *texOp;
String name(String::ToString("compositeMapTex%d", getProcessIndex())); String name(String::ToString("ormConfigMapTex%d", getProcessIndex()));
Var *compositeMapTex = (Var*)LangElement::find(name); Var *ormConfigMapTex = (Var*)LangElement::find(name);
if (!compositeMapTex) if (!ormConfigMapTex)
{ {
compositeMapTex = new Var; ormConfigMapTex = new Var;
compositeMapTex->setName(String::ToString("compositeMapTex%d", getProcessIndex())); ormConfigMapTex->setName(String::ToString("ormConfigMapTex%d", getProcessIndex()));
compositeMapTex->setType("Texture2D"); ormConfigMapTex->setType("Texture2D");
compositeMapTex->uniform = true; ormConfigMapTex->uniform = true;
compositeMapTex->texture = true; ormConfigMapTex->texture = true;
compositeMapTex->constNum = compositeMap->constNum; ormConfigMapTex->constNum = ormConfigMap->constNum;
} }
if (fd.features.hasFeature(MFT_TerrainSideProject, compositeIndex)) if (fd.features.hasFeature(MFT_TerrainSideProject, compositeIndex))
{ {
texOp = new GenOp("lerp( @.Sample( @, @.yz ), @.Sample( @, @.xz ), @.z )", texOp = new GenOp("lerp( @.Sample( @, @.yz ), @.Sample( @, @.xz ), @.z )",
compositeMapTex, compositeMap, inDet, compositeMapTex, compositeMap, inDet, inTex); ormConfigMapTex, ormConfigMap, inDet, ormConfigMapTex, ormConfigMap, inDet, inTex);
} }
else else
texOp = new GenOp("@.Sample(@, @.xy)", compositeMapTex, compositeMap, inDet); texOp = new GenOp("@.Sample(@, @.xy)", ormConfigMapTex, ormConfigMap, inDet);
// search for material var // search for material var
Var * pbrConfig; Var * ormConfig;
OutputTarget targ = DefaultTarget; OutputTarget targ = DefaultTarget;
if (fd.features[MFT_isDeferred]) if (fd.features[MFT_isDeferred])
{ {
targ = RenderTarget2; targ = RenderTarget2;
} }
pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(targ)); ormConfig = (Var*)LangElement::find(getOutputTargetVarName(targ));
MultiLine * meta = new MultiLine; MultiLine * meta = new MultiLine;
if (!pbrConfig) if (!ormConfig)
{ {
// create color var // create color var
pbrConfig = new Var; ormConfig = new Var;
pbrConfig->setType("fragout"); ormConfig->setType("fragout");
pbrConfig->setName(getOutputTargetVarName(targ)); ormConfig->setName(getOutputTargetVarName(targ));
pbrConfig->setStructName("OUT"); ormConfig->setStructName("OUT");
} }
Var *detailBlend = (Var*)LangElement::find(String::ToString("detailBlend%d", compositeIndex)); Var *detailBlend = (Var*)LangElement::find(String::ToString("detailBlend%d", compositeIndex));
@ -1305,23 +1305,23 @@ void TerrainCompositeMapFeatHLSL::processPix(Vector<ShaderComponent*> &component
if (priorComp) if (priorComp)
{ {
meta->addStatement(new GenOp(" @ = @.rgb*@;\r\n", new DecOp(matinfoCol), texOp, detailBlend)); meta->addStatement(new GenOp(" @ = @.rgb*@;\r\n", new DecOp(matinfoCol), texOp, detailBlend));
meta->addStatement(new GenOp(" @.bga += @;\r\n", pbrConfig, matinfoCol)); meta->addStatement(new GenOp(" @.gba += @;\r\n", ormConfig, matinfoCol));
} }
else else
{ {
meta->addStatement(new GenOp(" @ = lerp(float3(0,1,0),@.rgb,@);\r\n", new DecOp(matinfoCol), texOp, detailBlend)); meta->addStatement(new GenOp(" @ = lerp(float3(1.0,1.0,0.0),@.rgb,@);\r\n", new DecOp(matinfoCol), texOp, detailBlend));
meta->addStatement(new GenOp(" @ = float4(0.0,@);\r\n", pbrConfig, matinfoCol)); meta->addStatement(new GenOp(" @ = float4(0.0,@);\r\n", ormConfig, matinfoCol));
} }
if (!fd.features[MFT_InvertSmoothness]) if (fd.features[MFT_InvertRoughness])
{ {
meta->addStatement(new GenOp(" @.b = 1.0-@.b;\r\n", pbrConfig, pbrConfig)); meta->addStatement(new GenOp(" @.b = 1.0-@.b;\r\n", ormConfig, ormConfig));
} }
output = meta; output = meta;
} }
ShaderFeature::Resources TerrainCompositeMapFeatHLSL::getResources(const MaterialFeatureData &fd) ShaderFeature::Resources TerrainORMMapFeatHLSL::getResources(const MaterialFeatureData &fd)
{ {
Resources res; Resources res;
res.numTex = 1; res.numTex = 1;
@ -1356,7 +1356,7 @@ void TerrainBlankInfoMapFeatHLSL::processPix(Vector<ShaderComponent*> &component
material->setStructName("OUT"); material->setStructName("OUT");
} }
meta->addStatement(new GenOp(" @ = float4(0.0,0.0,1.0,0);\r\n", material)); meta->addStatement(new GenOp(" @ = float4(0.0,1.0,1.0,0.0);\r\n", material));
output = meta; output = meta;
} }

View file

@ -46,7 +46,7 @@ public:
Var* _getInMacroCoord(Vector<ShaderComponent*> &componentList ); Var* _getInMacroCoord(Vector<ShaderComponent*> &componentList );
Var* _getNormalMapTex(); Var* _getNormalMapTex();
Var* _getCompositeMapTex(); Var* _getORMConfigMapTex();
static Var* _getUniformVar( const char *name, const char *type, ConstantSortPosition csp ); static Var* _getUniformVar( const char *name, const char *type, ConstantSortPosition csp );
@ -162,7 +162,7 @@ public:
virtual String getName() { return "Terrain Additive"; } virtual String getName() { return "Terrain Additive"; }
}; };
class TerrainCompositeMapFeatHLSL : public TerrainFeatHLSL class TerrainORMMapFeatHLSL : public TerrainFeatHLSL
{ {
public: public:

View file

@ -60,7 +60,7 @@ Vector<String> _initSamplerNames()
samplerNames.push_back(avar("$normalMap%d",i)); samplerNames.push_back(avar("$normalMap%d",i));
samplerNames.push_back(avar("$detailMap%d",i)); samplerNames.push_back(avar("$detailMap%d",i));
//samplerNames.push_back(avar("$macroMap%d", i)); //samplerNames.push_back(avar("$macroMap%d", i));
samplerNames.push_back(avar("$compositeMap%d", i)); samplerNames.push_back(avar("$ormConfigMap%d", i));
} }
return samplerNames; return samplerNames;
@ -151,9 +151,9 @@ void TerrainCellMaterial::_updateDefaultAnisotropy()
desc.samplers[sampler].minFilter = GFXTextureFilterLinear; desc.samplers[sampler].minFilter = GFXTextureFilterLinear;
} }
if (matInfo->compositeTexConst->isValid()) if (matInfo->ormTexConst->isValid())
{ {
const S32 sampler = matInfo->compositeTexConst->getSamplerRegister(); const S32 sampler = matInfo->ormTexConst->getSamplerRegister();
if (maxAnisotropy > 1) if (maxAnisotropy > 1)
{ {
@ -439,15 +439,15 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
features.addFeature(MFT_isDeferred, featureIndex); features.addFeature(MFT_isDeferred, featureIndex);
features.addFeature( MFT_TerrainDetailMap, featureIndex ); features.addFeature( MFT_TerrainDetailMap, featureIndex );
if (!(mat->getCompositeMap().isEmpty())) if (!(mat->getORMConfigMap().isEmpty()))
{ {
if (deferredMat) if (deferredMat)
features.addFeature(MFT_isDeferred, featureIndex); features.addFeature(MFT_isDeferred, featureIndex);
features.addFeature(MFT_TerrainCompositeMap, featureIndex); features.addFeature(MFT_TerrainORMMap, featureIndex);
features.removeFeature(MFT_DeferredTerrainBlankInfoMap); features.removeFeature(MFT_DeferredTerrainBlankInfoMap);
} }
if (mat->getInvertSmoothness()) if (mat->getInvertRoughness())
features.addFeature(MFT_InvertSmoothness); features.addFeature(MFT_InvertRoughness);
pass->materials.push_back( (*materials)[i] ); pass->materials.push_back( (*materials)[i] );
normalMaps.increment(); normalMaps.increment();
@ -638,16 +638,16 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
&GFXStaticTextureProfile, "TerrainCellMaterial::_createPass() - DetailMap" ); &GFXStaticTextureProfile, "TerrainCellMaterial::_createPass() - DetailMap" );
} }
matInfo->compositeTexConst = pass->shader->getShaderConstHandle(avar("$compositeMap%d", i)); matInfo->ormTexConst = pass->shader->getShaderConstHandle(avar("$ormConfigMap%d", i));
if (matInfo->compositeTexConst->isValid()) if (matInfo->ormTexConst->isValid())
{ {
GFXTextureProfile* profile = &GFXStaticTextureProfile; GFXTextureProfile* profile = &GFXStaticTextureProfile;
if (matInfo->mat->getIsSRGB()) if (matInfo->mat->getIsSRGB())
profile = &GFXStaticTextureSRGBProfile; profile = &GFXStaticTextureSRGBProfile;
matInfo->compositeTex.set(matInfo->mat->getCompositeMap(), matInfo->ormTex.set(matInfo->mat->getORMConfigMap(),
profile, "TerrainCellMaterial::_createPass() - CompositeMap"); profile, "TerrainCellMaterial::_createPass() - CompositeMap");
const S32 sampler = matInfo->compositeTexConst->getSamplerRegister(); const S32 sampler = matInfo->ormTexConst->getSamplerRegister();
desc.samplers[sampler] = GFXSamplerStateDesc::getWrapLinear(); desc.samplers[sampler] = GFXSamplerStateDesc::getWrapLinear();
desc.samplers[sampler].magFilter = GFXTextureFilterLinear; desc.samplers[sampler].magFilter = GFXTextureFilterLinear;
@ -859,8 +859,8 @@ bool TerrainCellMaterial::setupPass( const SceneRenderState *state,
GFX->setTexture( matInfo->macroTexConst->getSamplerRegister(), matInfo->macroTex ); GFX->setTexture( matInfo->macroTexConst->getSamplerRegister(), matInfo->macroTex );
if ( matInfo->normalTexConst->isValid() ) if ( matInfo->normalTexConst->isValid() )
GFX->setTexture( matInfo->normalTexConst->getSamplerRegister(), matInfo->normalTex ); GFX->setTexture( matInfo->normalTexConst->getSamplerRegister(), matInfo->normalTex );
if ( matInfo->compositeTexConst->isValid() ) if ( matInfo->ormTexConst->isValid() )
GFX->setTexture( matInfo->compositeTexConst->getSamplerRegister(), matInfo->compositeTex ); GFX->setTexture( matInfo->ormTexConst->getSamplerRegister(), matInfo->ormTex );
} }
pass.consts->setSafe( pass.layerSizeConst, (F32)mTerrain->mLayerTex.getWidth() ); pass.consts->setSafe( pass.layerSizeConst, (F32)mTerrain->mLayerTex.getWidth() );

View file

@ -59,7 +59,7 @@ protected:
MaterialInfo() MaterialInfo()
:mat(NULL), layerId(0), detailTexConst(NULL), macroTexConst(NULL), normalTexConst(NULL), :mat(NULL), layerId(0), detailTexConst(NULL), macroTexConst(NULL), normalTexConst(NULL),
compositeTexConst(NULL), detailInfoVConst(NULL), detailInfoPConst(NULL), macroInfoVConst(NULL), macroInfoPConst(NULL) ormTexConst(NULL), detailInfoVConst(NULL), detailInfoPConst(NULL), macroInfoVConst(NULL), macroInfoPConst(NULL)
{ {
} }
@ -79,8 +79,8 @@ protected:
GFXShaderConstHandle *normalTexConst; GFXShaderConstHandle *normalTexConst;
GFXTexHandle normalTex; GFXTexHandle normalTex;
GFXShaderConstHandle *compositeTexConst; GFXShaderConstHandle *ormTexConst;
GFXTexHandle compositeTex; GFXTexHandle ormTex;
GFXShaderConstHandle *detailInfoVConst; GFXShaderConstHandle *detailInfoVConst;
GFXShaderConstHandle *detailInfoPConst; GFXShaderConstHandle *detailInfoPConst;

View file

@ -36,4 +36,4 @@ ImplementFeatureType( MFT_TerrainSideProject, MFG_Texture, 106.0f, false );
ImplementFeatureType( MFT_TerrainAdditive, MFG_PostProcess, 999.0f, false ); ImplementFeatureType( MFT_TerrainAdditive, MFG_PostProcess, 999.0f, false );
//Deferred Shading //Deferred Shading
ImplementFeatureType( MFT_DeferredTerrainBlankInfoMap, MFG_Texture, 104.1f, false); ImplementFeatureType( MFT_DeferredTerrainBlankInfoMap, MFG_Texture, 104.1f, false);
ImplementFeatureType( MFT_TerrainCompositeMap, MFG_Texture, 104.2f, false); ImplementFeatureType( MFT_TerrainORMMap, MFG_Texture, 104.2f, false);

View file

@ -36,7 +36,7 @@ DeclareFeatureType( MFT_TerrainLightMap );
DeclareFeatureType( MFT_TerrainSideProject ); DeclareFeatureType( MFT_TerrainSideProject );
DeclareFeatureType( MFT_TerrainAdditive ); DeclareFeatureType( MFT_TerrainAdditive );
//Deferred Shading //Deferred Shading
DeclareFeatureType( MFT_TerrainCompositeMap ); DeclareFeatureType( MFT_TerrainORMMap );
DeclareFeatureType( MFT_DeferredTerrainBlankInfoMap ); DeclareFeatureType( MFT_DeferredTerrainBlankInfoMap );

View file

@ -69,7 +69,7 @@ TerrainMaterial::TerrainMaterial()
mMacroDistance( 500.0f ), mMacroDistance( 500.0f ),
mParallaxScale( 0.0f ), mParallaxScale( 0.0f ),
mIsSRGB(false), mIsSRGB(false),
mInvertSmoothness(false) mInvertRoughness(false)
{ {
initMapSlot(DiffuseMap); initMapSlot(DiffuseMap);
initMapSlot(NormalMap); initMapSlot(NormalMap);

View file

@ -49,13 +49,10 @@ protected:
F32 mDiffuseSize; F32 mDiffuseSize;
/// ///
FileName mNormalMap; DECLARE_TEXTUREMAP(NormalMap);
/// ///
FileName mDetailMap; DECLARE_TEXTUREMAP(DetailMap);
///
FileName mCompositeMap;
/// The size of the detail map in meters used /// The size of the detail map in meters used
/// to generate the texture coordinates for the /// to generate the texture coordinates for the
@ -68,13 +65,19 @@ protected:
/// ///
F32 mDetailDistance; F32 mDetailDistance;
///
DECLARE_TEXTUREMAP(ORMConfigMap);
bool mIsSRGB;
bool mInvertRoughness;
/// Normally the detail is projected on to the xy /// Normally the detail is projected on to the xy
/// coordinates of the terrain. If this flag is true /// coordinates of the terrain. If this flag is true
/// then this detail is projected along the xz and yz /// then this detail is projected along the xz and yz
/// planes. /// planes.
bool mSideProjection; bool mSideProjection;
FileName mMacroMap; DECLARE_TEXTUREMAP(MacroMap);
F32 mMacroSize; F32 mMacroSize;
F32 mMacroStrength; F32 mMacroStrength;
F32 mMacroDistance; F32 mMacroDistance;
@ -82,9 +85,6 @@ protected:
/// ///
F32 mParallaxScale; F32 mParallaxScale;
bool mIsSRGB;
bool mInvertSmoothness;
public: public:
TerrainMaterial(); TerrainMaterial();
@ -124,7 +124,7 @@ public:
bool getIsSRGB() const { return mIsSRGB; } bool getIsSRGB() const { return mIsSRGB; }
bool getInvertSmoothness() const { return mInvertSmoothness; } bool getInvertRoughness() const { return mInvertRoughness; }
}; };

View file

@ -195,8 +195,8 @@ void AssimpAppMaterial::initMaterial(const Torque::Path& path, Material* mat) co
if (rmName.isNotEmpty()) if (rmName.isNotEmpty())
{ {
mat->mRoughMapFilename[0] = cleanTextureName(rmName, cleanFile, path, false); // Roughness mat->mRoughMapFilename[0] = cleanTextureName(rmName, cleanFile, path, false); // Roughness
mat->mSmoothnessChan[0] = 1.0f; mat->mRoughnessChan[0] = 1.0f;
mat->mInvertSmoothness[0] = (floatVal == 1.0f); mat->mInvertRoughness[0] = (floatVal == 1.0f);
mat->mMetalMapFilename[0] = cleanTextureName(rmName, cleanFile, path, false); // Metallic mat->mMetalMapFilename[0] = cleanTextureName(rmName, cleanFile, path, false); // Metallic
mat->mMetalChan[0] = 2.0f; mat->mMetalChan[0] = 2.0f;
} }

View file

@ -64,9 +64,8 @@ ColladaAppMaterial::ColladaAppMaterial(const char* matName)
flags |= TSMaterialList::T_Wrap; flags |= TSMaterialList::T_Wrap;
diffuseColor = LinearColorF::ONE; diffuseColor = LinearColorF::ONE;
specularColor = LinearColorF::ONE;
smoothness = 0.0f; roughness = 0.0f;
metalness = 0.0f; metalness = 0.0f;
doubleSided = false; doubleSided = false;
} }
@ -74,8 +73,7 @@ ColladaAppMaterial::ColladaAppMaterial(const char* matName)
ColladaAppMaterial::ColladaAppMaterial(const domMaterial *pMat) ColladaAppMaterial::ColladaAppMaterial(const domMaterial *pMat)
: mat(pMat), : mat(pMat),
diffuseColor(LinearColorF::ONE), diffuseColor(LinearColorF::ONE),
specularColor(LinearColorF::ONE), roughness(0.0f),
smoothness(0.0f),
metalness(0.0f), metalness(0.0f),
doubleSided(false) doubleSided(false)
{ {
@ -100,37 +98,33 @@ ColladaAppMaterial::ColladaAppMaterial(const domMaterial *pMat)
if (commonProfile->getTechnique()->getConstant()) { if (commonProfile->getTechnique()->getConstant()) {
const domProfile_COMMON::domTechnique::domConstant* constant = commonProfile->getTechnique()->getConstant(); const domProfile_COMMON::domTechnique::domConstant* constant = commonProfile->getTechnique()->getConstant();
diffuseColor.set(1.0f, 1.0f, 1.0f, 1.0f); diffuseColor.set(1.0f, 1.0f, 1.0f, 1.0f);
resolveColor(constant->getReflective(), &specularColor); resolveFloat(constant->getReflectivity(), &metalness);
resolveFloat(constant->getReflectivity(), &smoothness);
resolveTransparency(constant, &transparency); resolveTransparency(constant, &transparency);
} }
else if (commonProfile->getTechnique()->getLambert()) { else if (commonProfile->getTechnique()->getLambert()) {
const domProfile_COMMON::domTechnique::domLambert* lambert = commonProfile->getTechnique()->getLambert(); const domProfile_COMMON::domTechnique::domLambert* lambert = commonProfile->getTechnique()->getLambert();
resolveColor(lambert->getDiffuse(), &diffuseColor); resolveColor(lambert->getDiffuse(), &diffuseColor);
resolveColor(lambert->getReflective(), &specularColor); resolveFloat(lambert->getReflectivity(), &metalness);
resolveFloat(lambert->getReflectivity(), &smoothness);
resolveTransparency(lambert, &transparency); resolveTransparency(lambert, &transparency);
} }
else if (commonProfile->getTechnique()->getPhong()) { else if (commonProfile->getTechnique()->getPhong()) {
const domProfile_COMMON::domTechnique::domPhong* phong = commonProfile->getTechnique()->getPhong(); const domProfile_COMMON::domTechnique::domPhong* phong = commonProfile->getTechnique()->getPhong();
resolveColor(phong->getDiffuse(), &diffuseColor); resolveColor(phong->getDiffuse(), &diffuseColor);
resolveColor(phong->getSpecular(), &specularColor); resolveFloat(phong->getShininess(), &roughness);
resolveFloat(phong->getShininess(), &metalness);
resolveTransparency(phong, &transparency); resolveTransparency(phong, &transparency);
} }
else if (commonProfile->getTechnique()->getBlinn()) { else if (commonProfile->getTechnique()->getBlinn()) {
const domProfile_COMMON::domTechnique::domBlinn* blinn = commonProfile->getTechnique()->getBlinn(); const domProfile_COMMON::domTechnique::domBlinn* blinn = commonProfile->getTechnique()->getBlinn();
resolveColor(blinn->getDiffuse(), &diffuseColor); resolveColor(blinn->getDiffuse(), &diffuseColor);
resolveColor(blinn->getSpecular(), &specularColor); resolveFloat(blinn->getShininess(), &roughness);
resolveFloat(blinn->getShininess(), &metalness);
resolveTransparency(blinn, &transparency); resolveTransparency(blinn, &transparency);
} }
// Normalize specularPower (1-128). Values > 1 are assumed to be // Normalize specularPower (1-128). Values > 1 are assumed to be
// already normalized. // already normalized.
if (smoothness <= 1.0f) if (roughness <= 1.0f)
smoothness *= 128; roughness *= 128;
smoothness = mClampF(smoothness, 1.0f, 128.0f); roughness = mClampF(roughness, 1.0f, 128.0f);
// Set translucency // Set translucency
if (transparency != 0.0f) { if (transparency != 0.0f) {
@ -218,7 +212,7 @@ Material *ColladaAppMaterial::createMaterial(const Torque::Path& path) const
newMat->mNormalMapFilename[0] = normalMap; newMat->mNormalMapFilename[0] = normalMap;
newMat->mDiffuse[0] = diffuseColor; newMat->mDiffuse[0] = diffuseColor;
newMat->mSmoothness[0] = smoothness; newMat->mRoughness[0] = roughness;
newMat->mMetalness[0] = metalness; newMat->mMetalness[0] = metalness;
newMat->mDoubleSided = doubleSided; newMat->mDoubleSided = doubleSided;

View file

@ -45,8 +45,7 @@ public:
String normalMap; String normalMap;
LinearColorF diffuseColor; LinearColorF diffuseColor;
LinearColorF specularColor; F32 roughness;
F32 smoothness;
F32 metalness; F32 metalness;
bool doubleSided; bool doubleSided;

View file

@ -30,22 +30,15 @@
// Charles de Rousiers - Electronic Arts Frostbite // Charles de Rousiers - Electronic Arts Frostbite
// SIGGRAPH 2014 // SIGGRAPH 2014
float pow5(float x) { // BRDF from Frostbite presentation:
float x2 = x * x; // Moving Frostbite to Physically Based Rendering
return x2 * x2 * x; // S´ebastien Lagarde - Electronic Arts Frostbite
} // Charles de Rousiers - Electronic Arts Frostbite
// SIGGRAPH 2014
float3 F_Schlick(in float3 f0, in float f90, in float u) float3 F_Schlick(float3 f0, float f90, float u)
{ {
return f0 + (f90 - f0) * pow5(1.f - u); return f0 + (f90 - f0) * pow(1.f - u, 5.f);
}
float3 F_Fresnel(float3 SpecularColor, float VoH)
{
float3 SpecularColorSqrt = sqrt(min(SpecularColor, float3(0.99, 0.99, 0.99)));
float3 n = (1 + SpecularColorSqrt) / (1 - SpecularColorSqrt);
float3 g = sqrt(n*n + VoH*VoH - 1);
return 0.5 * sqr((g - VoH) / (g + VoH)) * (1 + sqr(((g + VoH)*VoH - 1) / ((g - VoH)*VoH + 1)));
} }
float3 FresnelSchlickRoughness(float cosTheta, float3 F0, float roughness) float3 FresnelSchlickRoughness(float cosTheta, float3 F0, float roughness)
@ -61,57 +54,23 @@ float3 FresnelSchlickRoughness(float cosTheta, float3 F0, float roughness)
return ret; return ret;
} }
float Fr_DisneyDiffuse(float NdotV, float NdotL, float LdotH, float linearRoughness) float V_SmithGGXCorrelated(float NdotL, float NdotV, float alphaRoughnessSq)
{ {
float energyBias = lerp(0, 0.5, linearRoughness); float GGXV = NdotL * sqrt(NdotV * NdotV * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);
float energyFactor = lerp(1.0, 1.0 / 1.51, linearRoughness); float GGXL = NdotV * sqrt(NdotL * NdotL * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);
float fd90 = energyBias + 2.0 * LdotH*LdotH * linearRoughness;
float3 f0 = float3(1.0f, 1.0f, 1.0f);
float lightScatter = F_Schlick(f0, fd90, NdotL).r;
float viewScatter = F_Schlick(f0, fd90, NdotV).r;
return lightScatter * viewScatter * energyFactor; float GGX = GGXV + GGXL;
if (GGX > 0.0f)
{
return 0.5f / GGX;
}
return 0.f;
} }
float V_SmithGGXCorrelated(float NdotL, float NdotV, float roughness) float D_GGX(float NdotH, float alphaRoughnessSq)
{ {
// Original formulation of G_SmithGGX Correlated float f = (NdotH * alphaRoughnessSq - NdotH) * NdotH + 1;
// lambda_v = (-1 + sqrt(alphaG2 * (1 - NdotL2) / NdotL2 + 1)) * 0.5f; return alphaRoughnessSq / (M_PI_F * f * f);
// lambda_l = (-1 + sqrt(alphaG2 * (1 - NdotV2) / NdotV2 + 1)) * 0.5f;
// G_SmithGGXCorrelated = 1 / (1 + lambda_v + lambda_l);
// V_SmithGGXCorrelated = G_SmithGGXCorrelated / (4.0f * NdotL * NdotV);
// This is the optimized version
//float alphaG2 = alphaG * alphaG;
// Caution: the "NdotL *" and "NdotV *" are explicitely inversed , this is not a mistake.
//float Lambda_GGXV = NdotL * sqrt((-NdotV * alphaG2 + NdotV) * NdotV + alphaG2);
//float Lambda_GGXL = NdotV * sqrt((-NdotL * alphaG2 + NdotL) * NdotL + alphaG2);
//return 0.5f / (Lambda_GGXV + Lambda_GGXL);
float a2 = roughness * roughness;
float lambdaV = NdotL * sqrt((NdotV - a2 * NdotV) * NdotV + a2);
float lambdaL = NdotV * sqrt((NdotL - a2 * NdotL) * NdotL + a2);
float v = 0.5 / (lambdaV + lambdaL);
return v;
}
float D_GGX(float NdotH, float roughness)
{
// Divide by PI is apply later
//float m2 = m * m;
//float f = (NdotH * m2 - NdotH) * NdotH + 1;
//return m2 / (f * f);
float oneMinusNdotHSquared = 1.0 - NdotH * NdotH;
float a = NdotH * roughness;
float k = roughness / (oneMinusNdotHSquared + a * a);
float d = k * k * M_1OVER_PI_F;
return d;
} }
#endif #endif

View file

@ -30,22 +30,9 @@
// Charles de Rousiers - Electronic Arts Frostbite // Charles de Rousiers - Electronic Arts Frostbite
// SIGGRAPH 2014 // SIGGRAPH 2014
float pow5(float x) { vec3 F_Schlick(vec3 f0, float f90, float u)
float x2 = x * x;
return x2 * x2 * x;
}
vec3 F_Schlick(in vec3 f0, in float f90, in float u)
{ {
return f0 + (f90 - f0) * pow5(1.f - u); return f0 + (f90 - f0) * pow(1.f - u, 5.f);
}
vec3 F_Fresnel(vec3 SpecularColor, float VoH)
{
vec3 SpecularColorSqrt = sqrt(min(SpecularColor, vec3(0.99, 0.99, 0.99)));
vec3 n = (1 + SpecularColorSqrt) / (1 - SpecularColorSqrt);
vec3 g = sqrt(n*n + VoH*VoH - 1);
return 0.5 * sqr((g - VoH) / (g + VoH)) * (1 + sqr(((g + VoH)*VoH - 1) / ((g - VoH)*VoH + 1)));
} }
vec3 FresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness) vec3 FresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness)
@ -61,48 +48,23 @@ vec3 FresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness)
return ret; return ret;
} }
float Fr_DisneyDiffuse(float NdotV, float NdotL, float LdotH, float linearRoughness) float V_SmithGGXCorrelated(float NdotL, float NdotV, float alphaRoughnessSq)
{ {
float energyBias = lerp(0.0f, 0.5f, linearRoughness); float GGXV = NdotL * sqrt(NdotV * NdotV * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);
float energyFactor = lerp(1.0f, 1.0f / 1.51f, linearRoughness); float GGXL = NdotV * sqrt(NdotL * NdotL * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);
float fd90 = energyBias + 2.0 * LdotH*LdotH * linearRoughness;
vec3 f0 = vec3(1.0f, 1.0f, 1.0f);
float lightScatter = F_Schlick(f0, fd90, NdotL).r;
float viewScatter = F_Schlick(f0, fd90, NdotV).r;
return lightScatter * viewScatter * energyFactor; float GGX = GGXV + GGXL;
if (GGX > 0.0f)
{
return 0.5f / GGX;
}
return 0.f;
} }
float V_SmithGGXCorrelated(float NdotL, float NdotV, float roughness) float D_GGX(float NdotH, float alphaRoughnessSq)
{ {
// Original formulation of G_SmithGGX Correlated float f = (NdotH * alphaRoughnessSq - NdotH) * NdotH + 1;
// lambda_v = (-1 + sqrt(alphaG2 * (1 - NdotL2) / NdotL2 + 1)) * 0.5f; return alphaRoughnessSq / (M_PI_F * f * f);
// lambda_l = (-1 + sqrt(alphaG2 * (1 - NdotV2) / NdotV2 + 1)) * 0.5f;
// G_SmithGGXCorrelated = 1 / (1 + lambda_v + lambda_l);
// V_SmithGGXCorrelated = G_SmithGGXCorrelated / (4.0f * NdotL * NdotV);
// This is the optimized version
//float alphaG2 = alphaG * alphaG;
float a2 = roughness * roughness;
float lambdaV = NdotL * sqrt((NdotV - a2 * NdotV) * NdotV + a2);
float lambdaL = NdotV * sqrt((NdotL - a2 * NdotL) * NdotL + a2);
float v = 0.5f / (lambdaV + lambdaL);
return v;
}
float D_GGX(float NdotH, float roughness)
{
// Divide by PI is apply later
float oneMinusNdotHSquared = 1.0 - NdotH * NdotH;
float a = NdotH * roughness;
float k = roughness / (oneMinusNdotHSquared + a * a);
float d = k * k * M_1OVER_PI_F;
return d;
} }
#endif #endif

View file

@ -22,23 +22,24 @@
#include "./torque.glsl" #include "./torque.glsl"
#include "./brdf.glsl" #include "./brdf.glsl"
#include "./shaderModelAutoGen.glsl"
#ifndef TORQUE_SHADERGEN #ifndef TORQUE_SHADERGEN
#line 26 #line 26
// These are the uniforms used by most lighting shaders. // These are the uniforms used by most lighting shaders.
uniform vec4 inLightPos[3]; uniform vec4 inLightPos[4];
uniform vec4 inLightInvRadiusSq; uniform vec4 inLightConfigData[4];
uniform vec4 inLightColor[4]; uniform vec4 inLightColor[4];
#ifndef TORQUE_BL_NOSPOTLIGHT #ifndef TORQUE_BL_NOSPOTLIGHT
uniform vec4 inLightSpotDir[3]; uniform vec4 inLightSpotDir[4];
uniform vec4 inLightSpotAngle; uniform vec4 inLightSpotAngle;
uniform vec4 inLightSpotFalloff; uniform vec4 inLightSpotFalloff;
#endif #endif
uniform vec4 ambient; uniform vec4 ambient;
#define ambientCameraFactor 0.3 uniform float roughness;
uniform float smoothness;
uniform float metalness; uniform float metalness;
uniform vec4 albedo; uniform vec4 albedo;
@ -73,48 +74,53 @@ struct Surface
vec3 V; // world space view vector vec3 V; // world space view vector
vec4 baseColor; // base color [0 -> 1] (rgba) vec4 baseColor; // base color [0 -> 1] (rgba)
float metalness; // metalness [0:dielectric -> 1:metal] float metalness; // metalness [0:dielectric -> 1:metal]
float roughness; // roughness: [0:smooth -> 1:rough] (linear) float roughness; // material roughness: [0:smooth -> 1:rough]
float roughness_brdf; // roughness remapped from linear to BRDF float linearRoughness; // linear roughness (roughness^2)
float linearRoughnessSq; // (linearRoughness^2)
float depth; // depth: [0:near -> 1:far] (linear) float depth; // depth: [0:near -> 1:far] (linear)
float ao; // ambient occlusion [0 -> 1] float ao; // ambient occlusion [0 -> 1]
float matFlag; // material flag - use getFlag to retreive float matFlag; // material flag - use getFlag to retreive
float NdotV; // cos(angle between normal and view vector) float NdotV; // cos(angle between normal and view vector)
vec3 f0; // fresnel value (rgb) vec3 f0; // fresnel value (rgb)
float f90;
vec3 albedo; // diffuse light absorbtion value (rgb) vec3 albedo; // diffuse light absorbtion value (rgb)
vec3 R; // reflection vector vec3 R; // reflection vector
vec3 F; // fresnel term computed from f0, N and V vec3 F; // fresnel term computed from f0, N and V
float f90;
}; };
void updateSurface(inout Surface surface) void updateSurface(inout Surface surface)
{ {
surface.NdotV = abs(dot(surface.N, surface.V)) + 1e-5f; // avoid artifact surface.NdotV = abs(dot(surface.N, surface.V)) + 1e-5f; // avoid artifact
surface.albedo = surface.baseColor.rgb * (1.0 - surface.metalness); surface.linearRoughness = surface.roughness * surface.roughness;
surface.f0 = lerp(vec3(0.04f), surface.baseColor.rgb, surface.metalness); surface.linearRoughnessSq = surface.linearRoughness * surface.linearRoughness;
surface.albedo = surface.baseColor.rgb * (1.0f - surface.metalness);
surface.f0 = mix(0.04f, surface.baseColor.rgb, surface.metalness);
surface.R = -reflect(surface.V, surface.N); surface.R = -reflect(surface.V, surface.N);
surface.f90 = saturate(50.0 * dot(surface.f0, vec3(0.33,0.33,0.33))); surface.f90 = saturate(50.0 * dot(surface.f0, vec3(0.33,0.33,0.33)));
surface.F = F_Schlick(surface.f0, surface.f90, surface.NdotV); surface.F = F_Schlick(surface.f0, surface.f90, surface.NdotV);
} }
Surface createSurface(vec4 normDepth, sampler2D colorBuffer, sampler2D matInfoBuffer, in vec2 uv, in vec3 wsEyePos, in vec3 wsEyeRay, in mat4 invView) Surface createSurface(vec4 gbuffer0, sampler2D gbufferTex1, sampler2D gbufferTex2, in vec2 uv, in vec3 wsEyePos, in vec3 wsEyeRay, in mat4 invView)
{ {
Surface surface;// = Surface(); Surface surface;// = Surface();
vec4 gbuffer1 = texture(colorBuffer, uv); vec4 gbuffer1 = texture(gbufferTex1, uv);
vec4 gbuffer2 = texture(matInfoBuffer, uv); vec4 gbuffer2 = texture(gbufferTex2, uv);
surface.depth = normDepth.a; surface.depth = gbuffer0.a;
surface.P = wsEyePos + wsEyeRay * surface.depth; surface.P = wsEyePos + wsEyeRay * surface.depth;
surface.N = tMul(invView, vec4(normDepth.xyz,0)).xyz; surface.N = tMul(invView, vec4(gbuffer0.xyz,0)).xyz;
surface.V = normalize(wsEyePos - surface.P); surface.V = normalize(wsEyePos - surface.P);
surface.baseColor = gbuffer1; surface.baseColor = gbuffer1;
const float minRoughness=1e-4; surface.roughness = clamp(gbuffer2.b, 0.01f, 1.0f);
surface.roughness = 1.0 - (gbuffer2.b*0.8+0.1999); //t3d uses smoothness, so we convert to roughness.
surface.roughness_brdf = surface.roughness * surface.roughness;
surface.metalness = gbuffer2.a; surface.metalness = gbuffer2.a;
surface.ao = gbuffer2.g; surface.ao = gbuffer2.g;
surface.matFlag = gbuffer2.r; surface.matFlag = gbuffer2.r;
updateSurface(surface); updateSurface(surface);
return surface; return surface;
} }
@ -128,9 +134,7 @@ Surface createForwardSurface(vec4 baseColor, vec3 normal, vec4 pbrProperties, in
surface.N = normal; surface.N = normal;
surface.V = normalize(wsEyePos - surface.P); surface.V = normalize(wsEyePos - surface.P);
surface.baseColor = baseColor; surface.baseColor = baseColor;
const float minRoughness=1e-4; surface.roughness = clamp(pbrProperties.b, 0.01f, 1.0f);
surface.roughness = 1.0 - (pbrProperties.b*0.8+0.1999); //t3d uses smoothness, so we convert to roughness.
surface.roughness_brdf = surface.roughness * surface.roughness;
surface.metalness = pbrProperties.a; surface.metalness = pbrProperties.a;
surface.ao = pbrProperties.g; surface.ao = pbrProperties.g;
surface.matFlag = pbrProperties.r; surface.matFlag = pbrProperties.r;
@ -166,16 +170,15 @@ vec3 BRDF_GetDebugSpecular(in Surface surface, in SurfaceToLight surfaceToLight)
{ {
//GGX specular //GGX specular
vec3 F = F_Schlick(surface.f0, surface.f90, surfaceToLight.HdotV); vec3 F = F_Schlick(surface.f0, surface.f90, surfaceToLight.HdotV);
float Vis = V_SmithGGXCorrelated(surface.NdotV, surfaceToLight.NdotL, surface.roughness); float Vis = V_SmithGGXCorrelated(surface.NdotV, surfaceToLight.NdotL, surface.linearRoughnessSq);
float D = D_GGX(surfaceToLight.NdotH, surface.roughness); float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughnessSq);
vec3 Fr = D * F * Vis; vec3 Fr = D * F * Vis * M_1OVER_PI_F;
return Fr*M_1OVER_PI_F; return Fr;
} }
vec3 BRDF_GetDebugDiffuse(in Surface surface, in SurfaceToLight surfaceToLight) vec3 BRDF_GetDebugDiffuse(in Surface surface, in SurfaceToLight surfaceToLight)
{ {
vec3 Fd = surface.albedo.rgb; return surface.albedo.rgb * M_1OVER_PI_F;
return Fd*M_1OVER_PI_F;
} }
//attenuations functions from "moving frostbite to pbr paper" //attenuations functions from "moving frostbite to pbr paper"
@ -206,15 +209,15 @@ float getDistanceAtt( vec3 unormalizedLightVector , float invSqrAttRadius )
vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight) vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
{ {
//lambert diffuse //lambert diffuse
vec3 Fd = surface.albedo.rgb; vec3 Fd = surface.albedo.rgb * M_1OVER_PI_F;
//GGX specular //GGX specular
vec3 F = F_Schlick(surface.f0, surface.f90, surfaceToLight.HdotV); vec3 F = F_Schlick(surface.f0, surface.f90, surfaceToLight.HdotV);
float Vis = V_SmithGGXCorrelated(surface.NdotV, surfaceToLight.NdotL, surface.roughness); float Vis = V_SmithGGXCorrelated(surface.NdotV, surfaceToLight.NdotL, surface.linearRoughnessSq);
float D = D_GGX(surfaceToLight.NdotH, surface.roughness); float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughnessSq);
vec3 Fr = D * F * Vis; vec3 Fr = D * F * Vis;
return (Fd + Fr) * M_1OVER_PI_F; return Fd + Fr;
} }
vec3 getDirectionalLight(Surface surface, SurfaceToLight surfaceToLight, vec3 lightColor, float lightIntensity, float shadow) vec3 getDirectionalLight(Surface surface, SurfaceToLight surfaceToLight, vec3 lightColor, float lightIntensity, float shadow)
@ -235,6 +238,11 @@ float computeSpecOcclusion( float NdotV , float AO , float roughness )
return saturate (pow( abs(NdotV + AO) , exp2 ( -16.0f * roughness - 1.0f )) - 1.0f + AO ); return saturate (pow( abs(NdotV + AO) , exp2 ( -16.0f * roughness - 1.0f )) - 1.0f + AO );
} }
float roughnessToMipLevel(float roughness, float numMips)
{
return roughness * numMips;
}
vec4 compute4Lights( Surface surface, vec4 compute4Lights( Surface surface,
vec4 shadowMask, vec4 shadowMask,
vec4 inLightPos[4], vec4 inLightPos[4],
@ -340,7 +348,7 @@ vec3 boxProject(vec3 wsPosition, vec3 wsReflectVec, mat4 worldToObj, vec3 refBox
} }
vec4 computeForwardProbes(Surface surface, vec4 computeForwardProbes(Surface surface,
float cubeMips, float numProbes, mat4x4 worldToObjArray[MAX_FORWARD_PROBES], vec4 probeConfigData[MAX_FORWARD_PROBES], float cubeMips, int numProbes, mat4x4 worldToObjArray[MAX_FORWARD_PROBES], vec4 probeConfigData[MAX_FORWARD_PROBES],
vec4 inProbePosArray[MAX_FORWARD_PROBES], vec4 refBoxMinArray[MAX_FORWARD_PROBES], vec4 refBoxMaxArray[MAX_FORWARD_PROBES], vec4 inRefPosArray[MAX_FORWARD_PROBES], vec4 inProbePosArray[MAX_FORWARD_PROBES], vec4 refBoxMinArray[MAX_FORWARD_PROBES], vec4 refBoxMaxArray[MAX_FORWARD_PROBES], vec4 inRefPosArray[MAX_FORWARD_PROBES],
float skylightCubemapIdx, sampler2D BRDFTexture, float skylightCubemapIdx, sampler2D BRDFTexture,
samplerCubeArray irradianceCubemapAR, samplerCubeArray specularCubemapAR) samplerCubeArray irradianceCubemapAR, samplerCubeArray specularCubemapAR)
@ -401,11 +409,43 @@ vec4 computeForwardProbes(Surface surface,
} }
} }
#if DEBUGVIZ_ATTENUATION == 1
float contribAlpha = 1;
for (i = 0; i < numProbes; ++i)
{
contribAlpha -= contribution[i];
}
return vec4(1 - contribAlpha, 1 - contribAlpha, 1 - contribAlpha, 1);
#endif
#if DEBUGVIZ_CONTRIB == 1
vec3 probeContribColors[4];
probeContribColors[0] = vec3(1,0,0);
probeContribColors[1] = vec3(0,1,0);
probeContribColors[2] = vec3(0,0,1);
probeContribColors[3] = vec3(1,1,0);
vec3 finalContribColor = vec3(0, 0, 0);
float contribAlpha = 1;
for (i = 0; i < numProbes; ++i)
{
finalContribColor += contribution[i] *probeContribColors[i].rgb;
contribAlpha -= contribution[i];
}
//Skylight coloration for anything not covered by probes above
if(skylightCubemapIdx != -1)
finalContribColor += vec3(0.3, 0.3, 0.3) * contribAlpha;
return vec4(finalContribColor, 1);
#endif
vec3 irradiance = vec3(0, 0, 0); vec3 irradiance = vec3(0, 0, 0);
vec3 specular = vec3(0, 0, 0); vec3 specular = vec3(0, 0, 0);
// Radiance (Specular) // Radiance (Specular)
float lod = surface.roughness*cubeMips; float lod = roughnessToMipLevel(surface.roughness, cubeMips);
for (i = 0; i < numProbes; ++i) for (i = 0; i < numProbes; ++i)
{ {
@ -428,17 +468,182 @@ vec4 computeForwardProbes(Surface surface,
} }
//energy conservation //energy conservation
vec3 kD = 1.0f - surface.F; vec3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
vec3 kD = 1.0f - F;
kD *= 1.0f - surface.metalness; kD *= 1.0f - surface.metalness;
float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex) float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
vec2 envBRDF = textureLod(BRDFTexture, vec2(dfgNdotV, surface.roughness),0).rg; vec2 envBRDF = texture(BRDFTexture, vec4(dfgNdotV, surface.roughness,0,0)).rg;
specular *= surface.F * envBRDF.x + surface.f90 * envBRDF.y; specular *= F * envBRDF.x + surface.f90 * envBRDF.y;
irradiance *= kD * surface.baseColor.rgb; irradiance *= kD * surface.baseColor.rgb;
//AO //AO
irradiance *= surface.ao; irradiance *= surface.ao;
specular *= computeSpecOcclusion(surface.NdotV, surface.ao, surface.roughness); specular *= computeSpecOcclusion(surface.NdotV, surface.ao, surface.roughness);
return vec4(irradiance + specular, 0);//alpha writes disabled //http://marmosetco.tumblr.com/post/81245981087
float horizonOcclusion = 1.3;
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
horizon *= horizon;
return vec4((irradiance + specular) * horizon, 0);//alpha writes disabled
}
vec4 debugVizForwardProbes(Surface surface,
float cubeMips, int numProbes, mat4 worldToObjArray[MAX_FORWARD_PROBES], vec4 probeConfigData[MAX_FORWARD_PROBES],
vec4 inProbePosArray[MAX_FORWARD_PROBES], vec4 refBoxMinArray[MAX_FORWARD_PROBES], vec4 refBoxMaxArray[MAX_FORWARD_PROBES], vec4 inRefPosArray[MAX_FORWARD_PROBES],
float skylightCubemapIdx, sampler2D(BRDFTexture),
samplerCubeArray irradianceCubemapAR, samplerCubeArray specularCubemapAR, int showAtten, int showContrib, int showSpec, int showDiff)
{
int i = 0;
float alpha = 1;
float blendFactor[MAX_FORWARD_PROBES];
float blendSum = 0;
float blendFacSum = 0;
float invBlendSum = 0;
float probehits = 0;
//Set up our struct data
float contribution[MAX_FORWARD_PROBES];
for (i = 0; i < numProbes; ++i)
{
contribution[i] = 0;
if (probeConfigData[i].r == 0) //box
{
contribution[i] = defineBoxSpaceInfluence(surface.P, worldToObjArray[i], probeConfigData[i].b);
if (contribution[i] > 0.0)
probehits++;
}
else if (probeConfigData[i].r == 1) //sphere
{
contribution[i] = defineSphereSpaceInfluence(surface.P, inProbePosArray[i].xyz, probeConfigData[i].g);
if (contribution[i] > 0.0)
probehits++;
}
contribution[i] = max(contribution[i], 0);
blendSum += contribution[i];
invBlendSum += (1.0f - contribution[i]);
}
if (probehits > 1.0)
{
for (i = 0; i < numProbes; i++)
{
blendFactor[i] = ((contribution[i] / blendSum)) / probehits;
blendFactor[i] *= ((contribution[i]) / invBlendSum);
blendFactor[i] = saturate(blendFactor[i]);
blendFacSum += blendFactor[i];
}
// Normalize blendVal
if (blendFacSum == 0.0f) // Possible with custom weight
{
blendFacSum = 1.0f;
}
float invBlendSumWeighted = 1.0f / blendFacSum;
for (i = 0; i < numProbes; ++i)
{
blendFactor[i] *= invBlendSumWeighted;
contribution[i] *= blendFactor[i];
}
}
if(showAtten == 1)
{
float contribAlpha = 1;
for (i = 0; i < numProbes; ++i)
{
contribAlpha -= contribution[i];
}
return vec4(1 - contribAlpha, 1 - contribAlpha, 1 - contribAlpha, 1);
}
if(showContrib == 1)
{
vec3 probeContribColors[4];
probeContribColors[0] = vec3(1,0,0);
probeContribColors[1] = vec3(0,1,0);
probeContribColors[2] = vec3(0,0,1);
probeContribColors[3] = vec3(1,1,0);
vec3 finalContribColor = vec3(0, 0, 0);
float contribAlpha = 1;
for (i = 0; i < numProbes; ++i)
{
finalContribColor += contribution[i] *probeContribColors[i].rgb;
contribAlpha -= contribution[i];
}
//Skylight coloration for anything not covered by probes above
if(skylightCubemapIdx != -1)
finalContribColor += vec3(0.3, 0.3, 0.3) * contribAlpha;
return vec4(finalContribColor, 1);
}
vec3 irradiance = vec3(0, 0, 0);
vec3 specular = vec3(0, 0, 0);
// Radiance (Specular)
float lod = roughnessToMipLevel(surface.roughness, cubeMips);
if(showSpec == 1)
{
lod = 0;
}
for (i = 0; i < numProbes; ++i)
{
float contrib = contribution[i];
if (contrib > 0.0f)
{
int cubemapIdx = probeConfigData[i].a;
vec3 dir = boxProject(surface.P, surface.R, worldToObjArray[i], refBoxMinArray[i].xyz, refBoxMaxArray[i].xyz, inRefPosArray[i].xyz);
irradiance += textureLod(irradianceCubemapAR, dir, cubemapIdx, 0).xyz * contrib;
specular += textureLod(specularCubemapAR, dir, cubemapIdx, lod).xyz * contrib;
alpha -= contrib;
}
}
if(skylightCubemapIdx != -1 && alpha >= 0.001)
{
irradiance = mix(irradiance,textureLod(irradianceCubemapAR, surface.R, skylightCubemapIdx, 0).xyz,alpha);
specular = mix(specular,textureLod(specularCubemapAR, surface.R, skylightCubemapIdx, lod).xyz,alpha);
}
if(showSpec == 1)
{
return vec4(specular, 0);
}
if(showDiff == 1)
{
return vec4(irradiance, 0);
}
//energy conservation
vec3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
vec3 kD = 1.0f - F;
kD *= 1.0f - surface.metalness;
float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
vec2 envBRDF = textureLod(BRDFTexture, vec2(dfgNdotV, surface.roughness),0).rg;
specular *= F * envBRDF.x + surface.f90 * envBRDF.y;
irradiance *= kD * surface.baseColor.rgb;
//AO
irradiance *= surface.ao;
specular *= computeSpecOcclusion(surface.NdotV, surface.ao, surface.roughness);
//http://marmosetco.tumblr.com/post/81245981087
float horizonOcclusion = 1.3;
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
horizon *= horizon;
return vec4((irradiance + specular) * horizon, 0);//alpha writes disabled
} }

View file

@ -39,7 +39,7 @@ uniform float4 inLightColor[4];
#endif #endif
uniform float4 ambient; uniform float4 ambient;
uniform float smoothness; uniform float roughness;
uniform float metalness; uniform float metalness;
uniform float4 albedo; uniform float4 albedo;
@ -74,8 +74,9 @@ struct Surface
float3 V; // world space view vector float3 V; // world space view vector
float4 baseColor; // base color [0 -> 1] (rgba) float4 baseColor; // base color [0 -> 1] (rgba)
float metalness; // metalness [0:dielectric -> 1:metal] float metalness; // metalness [0:dielectric -> 1:metal]
float roughness; // roughness: [0:smooth -> 1:rough] (linear) float roughness; // material roughness: [0:smooth -> 1:rough]
float roughness_brdf; // roughness remapped from linear to BRDF float linearRoughness; // linear roughness (roughness^2)
float linearRoughnessSq; // (linearRoughness^2)
float depth; // depth: [0:near -> 1:far] (linear) float depth; // depth: [0:near -> 1:far] (linear)
float ao; // ambient occlusion [0 -> 1] float ao; // ambient occlusion [0 -> 1]
float matFlag; // material flag - use getFlag to retreive float matFlag; // material flag - use getFlag to retreive
@ -91,17 +92,18 @@ struct Surface
{ {
NdotV = abs(dot(N, V)) + 1e-5f; // avoid artifact NdotV = abs(dot(N, V)) + 1e-5f; // avoid artifact
albedo = baseColor.rgb * (1.0 - metalness); linearRoughness = roughness * roughness;
f0 = lerp(0.04.xxx, baseColor.rgb, metalness); linearRoughnessSq = linearRoughness * linearRoughness;
albedo = baseColor.rgb * (1.0f - metalness);
f0 = lerp(0.04f, baseColor.rgb, metalness);
R = -reflect(V, N); R = -reflect(V, N);
f90 = saturate(50.0 * dot(f0, 0.33)); f90 = saturate(50.0f * dot(f0, 0.33f));
F = F_Schlick(f0, f90, NdotV); F = F_Schlick(f0, f90, NdotV);
} }
}; };
inline Surface createSurface(float4 gbuffer0, TORQUE_SAMPLER2D(gbufferTex1), TORQUE_SAMPLER2D(gbufferTex2), in float2 uv, in float3 wsEyePos, in float3 wsEyeRay, in float4x4 invView) inline Surface createSurface(float4 gbuffer0, TORQUE_SAMPLER2D(gbufferTex1), TORQUE_SAMPLER2D(gbufferTex2), in float2 uv, in float3 wsEyePos, in float3 wsEyeRay, in float4x4 invView)
{ {
Surface surface = (Surface)0; Surface surface = (Surface)0;
@ -114,8 +116,7 @@ inline Surface createSurface(float4 gbuffer0, TORQUE_SAMPLER2D(gbufferTex1), TOR
surface.N = mul(invView, float4(gbuffer0.xyz,0)).xyz; surface.N = mul(invView, float4(gbuffer0.xyz,0)).xyz;
surface.V = normalize(wsEyePos - surface.P); surface.V = normalize(wsEyePos - surface.P);
surface.baseColor = gbuffer1; surface.baseColor = gbuffer1;
surface.roughness = 1.0 - (gbuffer2.b*0.8+0.1999); //t3d uses smoothness, so we convert to roughness. surface.roughness = clamp(gbuffer2.b, 0.01f, 1.0f);
surface.roughness_brdf = surface.roughness * surface.roughness;
surface.metalness = gbuffer2.a; surface.metalness = gbuffer2.a;
surface.ao = gbuffer2.g; surface.ao = gbuffer2.g;
surface.matFlag = gbuffer2.r; surface.matFlag = gbuffer2.r;
@ -133,8 +134,7 @@ inline Surface createForwardSurface(float4 baseColor, float3 normal, float4 pbrP
surface.N = normal; surface.N = normal;
surface.V = normalize(wsEyePos - surface.P); surface.V = normalize(wsEyePos - surface.P);
surface.baseColor = baseColor; surface.baseColor = baseColor;
surface.roughness = 1.0 - (pbrProperties.b*0.8+0.1999); //t3d uses smoothness, so we convert to roughness. surface.roughness = clamp(pbrProperties.b, 0.01f, 1.0f);
surface.roughness_brdf = surface.roughness * surface.roughness;
surface.metalness = pbrProperties.a; surface.metalness = pbrProperties.a;
surface.ao = pbrProperties.g; surface.ao = pbrProperties.g;
surface.matFlag = pbrProperties.r; surface.matFlag = pbrProperties.r;
@ -146,7 +146,7 @@ inline Surface createForwardSurface(float4 baseColor, float3 normal, float4 pbrP
struct SurfaceToLight struct SurfaceToLight
{ {
float3 L; // surface to light vector float3 L; // surface to light vector
float3 Lu; // un-normalized surface to light vector float3 Lu; // un-normalized surface to light vector
float3 H; // half-vector between view vector and light vector float3 H; // half-vector between view vector and light vector
float NdotL; // cos(angle between N and L) float NdotL; // cos(angle between N and L)
float HdotV; // cos(angle between H and V) = HdotL = cos(angle between H and L) float HdotV; // cos(angle between H and V) = HdotL = cos(angle between H and L)
@ -170,16 +170,15 @@ float3 BRDF_GetDebugSpecular(in Surface surface, in SurfaceToLight surfaceToLigh
{ {
//GGX specular //GGX specular
float3 F = F_Schlick(surface.f0, surface.f90, surfaceToLight.HdotV); float3 F = F_Schlick(surface.f0, surface.f90, surfaceToLight.HdotV);
float Vis = V_SmithGGXCorrelated(surface.NdotV, surfaceToLight.NdotL, surface.roughness); float Vis = V_SmithGGXCorrelated(surface.NdotV, surfaceToLight.NdotL, surface.linearRoughnessSq);
float D = D_GGX(surfaceToLight.NdotH, surface.roughness); float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughnessSq);
float3 Fr = D * F * Vis; float3 Fr = D * F * Vis * M_1OVER_PI_F;
return Fr*M_1OVER_PI_F; return Fr;
} }
float3 BRDF_GetDebugDiffuse(in Surface surface, in SurfaceToLight surfaceToLight) float3 BRDF_GetDebugDiffuse(in Surface surface, in SurfaceToLight surfaceToLight)
{ {
float3 Fd = surface.albedo.rgb; return surface.albedo.rgb * M_1OVER_PI_F;
return Fd*M_1OVER_PI_F;
} }
//attenuations functions from "moving frostbite to pbr paper" //attenuations functions from "moving frostbite to pbr paper"
@ -210,15 +209,15 @@ float getDistanceAtt( float3 unormalizedLightVector , float invSqrAttRadius )
float3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight) float3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight)
{ {
//lambert diffuse //lambert diffuse
float3 Fd = surface.albedo.rgb; float3 Fd = surface.albedo.rgb * M_1OVER_PI_F;
//GGX specular //GGX specular
float3 F = F_Schlick(surface.f0, surface.f90, surfaceToLight.HdotV); float3 F = F_Schlick(surface.f0, surface.f90, surfaceToLight.HdotV);
float Vis = V_SmithGGXCorrelated(surface.NdotV, surfaceToLight.NdotL, surface.roughness); float Vis = V_SmithGGXCorrelated(surface.NdotV, surfaceToLight.NdotL, surface.linearRoughnessSq);
float D = D_GGX(surfaceToLight.NdotH, surface.roughness); float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughnessSq);
float3 Fr = D * F * Vis; float3 Fr = D * F * Vis;
return (Fd + Fr) * M_1OVER_PI_F; return Fd + Fr;
} }
float3 getDirectionalLight(Surface surface, SurfaceToLight surfaceToLight, float3 lightColor, float lightIntensity, float shadow) float3 getDirectionalLight(Surface surface, SurfaceToLight surfaceToLight, float3 lightColor, float lightIntensity, float shadow)
@ -234,12 +233,16 @@ float3 getPunctualLight(Surface surface, SurfaceToLight surfaceToLight, float3 l
return evaluateStandardBRDF(surface,surfaceToLight) * factor; return evaluateStandardBRDF(surface,surfaceToLight) * factor;
} }
float computeSpecOcclusion( float NdotV , float AO , float roughness ) float computeSpecOcclusion( float NdotV , float AO , float roughness )
{ {
return saturate (pow( abs(NdotV + AO) , exp2 ( -16.0f * roughness - 1.0f )) - 1.0f + AO ); return saturate (pow( abs(NdotV + AO) , exp2 ( -16.0f * roughness - 1.0f )) - 1.0f + AO );
} }
float roughnessToMipLevel(float roughness, float numMips)
{
return roughness * numMips;
}
float4 compute4Lights( Surface surface, float4 compute4Lights( Surface surface,
float4 shadowMask, float4 shadowMask,
float4 inLightPos[4], float4 inLightPos[4],
@ -445,7 +448,7 @@ float4 computeForwardProbes(Surface surface,
float3 specular = float3(0, 0, 0); float3 specular = float3(0, 0, 0);
// Radiance (Specular) // Radiance (Specular)
float lod = surface.roughness*cubeMips; float lod = roughnessToMipLevel(surface.roughness, cubeMips);
for (i = 0; i < numProbes; ++i) for (i = 0; i < numProbes; ++i)
{ {
@ -468,19 +471,25 @@ float4 computeForwardProbes(Surface surface,
} }
//energy conservation //energy conservation
float3 kD = 1.0f - surface.F; float3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
float3 kD = 1.0f - F;
kD *= 1.0f - surface.metalness; kD *= 1.0f - surface.metalness;
float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex) float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(dfgNdotV, surface.roughness,0,0)).rg; float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(dfgNdotV, surface.roughness,0,0)).rg;
specular *= surface.F * envBRDF.x + surface.f90 * envBRDF.y; specular *= F * envBRDF.x + surface.f90 * envBRDF.y;
irradiance *= kD * surface.baseColor.rgb; irradiance *= kD * surface.baseColor.rgb;
//AO //AO
irradiance *= surface.ao; irradiance *= surface.ao;
specular *= computeSpecOcclusion(surface.NdotV, surface.ao, surface.roughness); specular *= computeSpecOcclusion(surface.NdotV, surface.ao, surface.roughness);
return float4(irradiance + specular, 0);//alpha writes disabled //http://marmosetco.tumblr.com/post/81245981087
float horizonOcclusion = 1.3;
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
horizon *= horizon;
return float4((irradiance + specular) * horizon, 0);//alpha writes disabled
} }
float4 debugVizForwardProbes(Surface surface, float4 debugVizForwardProbes(Surface surface,
@ -583,7 +592,7 @@ float4 debugVizForwardProbes(Surface surface,
float3 specular = float3(0, 0, 0); float3 specular = float3(0, 0, 0);
// Radiance (Specular) // Radiance (Specular)
float lod = surface.roughness*cubeMips; float lod = roughnessToMipLevel(surface.roughness, cubeMips);
if(showSpec == 1) if(showSpec == 1)
{ {
@ -621,17 +630,23 @@ float4 debugVizForwardProbes(Surface surface,
} }
//energy conservation //energy conservation
float3 kD = 1.0f - surface.F; float3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
float3 kD = 1.0f - F;
kD *= 1.0f - surface.metalness; kD *= 1.0f - surface.metalness;
float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex) float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(dfgNdotV, surface.roughness,0,0)).rg; float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(dfgNdotV, surface.roughness,0,0)).rg;
specular *= surface.F * envBRDF.x + surface.f90 * envBRDF.y; specular *= F * envBRDF.x + surface.f90 * envBRDF.y;
irradiance *= kD * surface.baseColor.rgb; irradiance *= kD * surface.baseColor.rgb;
//AO //AO
irradiance *= surface.ao; irradiance *= surface.ao;
specular *= computeSpecOcclusion(surface.NdotV, surface.ao, surface.roughness); specular *= computeSpecOcclusion(surface.NdotV, surface.ao, surface.roughness);
return float4(irradiance + specular, 0);//alpha writes disabled //http://marmosetco.tumblr.com/post/81245981087
float horizonOcclusion = 1.3;
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
horizon *= horizon;
return float4((irradiance + specular) * horizon, 0);//alpha writes disabled
} }

View file

@ -3,6 +3,7 @@
#include "../../../gl/torque.glsl" #include "../../../gl/torque.glsl"
#include "shadergen:/autogenConditioners.h" #include "shadergen:/autogenConditioners.h"
#include "../../../gl/lighting.glsl" #include "../../../gl/lighting.glsl"
#include "../../../gl/brdf.glsl"
#line 7 #line 7
@ -55,11 +56,11 @@ void main()
//early out if emissive //early out if emissive
if (getFlag(surface.matFlag, 0)) if (getFlag(surface.matFlag, 0))
{ {
discard; return texture(colorBuffer, IN_uv0.xy);
} }
#ifdef USE_SSAO_MASK #ifdef USE_SSAO_MASK
float ssao = 1.0 - texture( ssaoMask, viewportCoordToRenderTarget( uv0.xy, rtParams6 ) ).r; float ssao = 1.0 - texture( ssaoMask, viewportCoordToRenderTarget( IN_uv0.xy, rtParams6 ) ).r;
surface.ao = min(surface.ao, ssao); surface.ao = min(surface.ao, ssao);
#endif #endif
@ -166,7 +167,7 @@ void main()
// Radiance (Specular) // Radiance (Specular)
#if DEBUGVIZ_SPECCUBEMAP == 0 #if DEBUGVIZ_SPECCUBEMAP == 0
float lod = surface.roughness*cubeMips; float lod = roughnessToMipLevel(surface.roughness, cubeMips);
#elif DEBUGVIZ_SPECCUBEMAP == 1 #elif DEBUGVIZ_SPECCUBEMAP == 1
float lod = 0; float lod = 0;
#endif #endif
@ -177,7 +178,7 @@ void main()
float contrib = contribution[i]; float contrib = contribution[i];
if (contrib > 0.0f) if (contrib > 0.0f)
{ {
float cubemapIdx = probeConfigData[i].a; int cubemapIdx = probeConfigData[i].a;
vec3 dir = boxProject(surface.P, surface.R, worldToObjArray[i], refBoxMinArray[i].xyz, refBoxMaxArray[i].xyz, inRefPosArray[i].xyz); vec3 dir = boxProject(surface.P, surface.R, worldToObjArray[i], refBoxMinArray[i].xyz, refBoxMaxArray[i].xyz, inRefPosArray[i].xyz);
irradiance += textureLod(irradianceCubemapAR, vec4(dir, cubemapIdx), 0).xyz * contrib; irradiance += textureLod(irradianceCubemapAR, vec4(dir, cubemapIdx), 0).xyz * contrib;
@ -189,8 +190,8 @@ void main()
if (skylightCubemapIdx != -1 && alpha > 0.001) if (skylightCubemapIdx != -1 && alpha > 0.001)
{ {
irradiance += textureLod(irradianceCubemapAR, vec4(surface.R, skylightCubemapIdx), 0).xyz * alpha; irradiance = lerp(irradiance,textureLod(irradianceCubemapAR, surface.R, skylightCubemapIdx, 0).xyz,alpha);
specular += textureLod(specularCubemapAR, vec4(surface.R, skylightCubemapIdx), lod).xyz * alpha; specular = lerp(specular,textureLod(specularCubemapAR, surface.R, skylightCubemapIdx, lod).xyz,alpha);
} }
#if DEBUGVIZ_SPECCUBEMAP == 1 && DEBUGVIZ_DIFFCUBEMAP == 0 #if DEBUGVIZ_SPECCUBEMAP == 1 && DEBUGVIZ_DIFFCUBEMAP == 0
@ -203,17 +204,23 @@ void main()
//energy conservation //energy conservation
vec3 kD = 1.0f - surface.F; vec3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
vec3 kD = 1.0f - F;
kD *= 1.0f - surface.metalness; kD *= 1.0f - surface.metalness;
float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex) float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
vec2 envBRDF = textureLod(BRDFTexture, vec2(dfgNdotV, surface.roughness),0).rg; vec2 envBRDF = textureLod(BRDFTexture, vec2(dfgNdotV, surface.roughness),0).rg;
specular *= surface.F * envBRDF.x + surface.f90 * envBRDF.y; specular *= F * envBRDF.x + surface.f90 * envBRDF.y;
irradiance *= kD * surface.baseColor.rgb; irradiance *= kD * surface.baseColor.rgb;
//AO //AO
irradiance *= surface.ao; irradiance *= surface.ao;
specular *= computeSpecOcclusion(surface.NdotV, surface.ao, surface.roughness); specular *= computeSpecOcclusion(surface.NdotV, surface.ao, surface.roughness);
//http://marmosetco.tumblr.com/post/81245981087
float horizonOcclusion = 1.3;
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
horizon *= horizon;
OUT_col = vec4(irradiance + specular, 0);//alpha writes disabled OUT_col = vec4(irradiance + specular, 0);//alpha writes disabled
} }

View file

@ -2,6 +2,7 @@
#include "../../shaderModel.hlsl" #include "../../shaderModel.hlsl"
#include "../../shaderModelAutoGen.hlsl" #include "../../shaderModelAutoGen.hlsl"
#include "../../lighting.hlsl" #include "../../lighting.hlsl"
#include "../../brdf.hlsl"
TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0); TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0);
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 1); TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 1);
@ -159,7 +160,7 @@ float4 main(PFXVertToPix IN) : SV_TARGET
// Radiance (Specular) // Radiance (Specular)
#if DEBUGVIZ_SPECCUBEMAP == 0 #if DEBUGVIZ_SPECCUBEMAP == 0
float lod = surface.roughness*cubeMips; float lod = roughnessToMipLevel(surface.roughness, cubeMips);
#elif DEBUGVIZ_SPECCUBEMAP == 1 #elif DEBUGVIZ_SPECCUBEMAP == 1
float lod = 0; float lod = 0;
#endif #endif
@ -193,17 +194,23 @@ float4 main(PFXVertToPix IN) : SV_TARGET
#endif #endif
//energy conservation //energy conservation
float3 kD = 1.0f - surface.F; float3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
float3 kD = 1.0f - F;
kD *= 1.0f - surface.metalness; kD *= 1.0f - surface.metalness;
float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex) float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(dfgNdotV, surface.roughness,0,0)).rg; float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(dfgNdotV, surface.roughness,0,0)).rg;
specular *= surface.F * envBRDF.x + surface.f90 * envBRDF.y; specular *= F * envBRDF.x + surface.f90 * envBRDF.y;
irradiance *= kD * surface.baseColor.rgb; irradiance *= kD * surface.baseColor.rgb;
//AO //AO
irradiance *= surface.ao; irradiance *= surface.ao;
specular *= computeSpecOcclusion(surface.NdotV, surface.ao, surface.roughness); specular *= computeSpecOcclusion(surface.NdotV, surface.ao, surface.roughness);
return float4(irradiance + specular, 0);//alpha writes disabled //http://marmosetco.tumblr.com/post/81245981087
float horizonOcclusion = 1.3;
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
horizon *= horizon;
return float4((irradiance + specular) * horizon, 0);//alpha writes disabled
} }

View file

@ -409,7 +409,7 @@ function AssetBrowser::importMaterialAsset(%this, %assetItem)
else if(%childAssetItem.imageType $= "AO") else if(%childAssetItem.imageType $= "AO")
%mapFieldName = "AOMap"; %mapFieldName = "AOMap";
else if(%childAssetItem.imageType $= "Composite") else if(%childAssetItem.imageType $= "Composite")
%mapFieldName = "PBRConfigMap"; %mapFieldName = "ORMConfigMap";
%path = fileName(%childAssetItem.filePath); %path = fileName(%childAssetItem.filePath);
%file.writeline(" "@ %mapFieldName @ "[0] = \"" @ %path @"\";"); %file.writeline(" "@ %mapFieldName @ "[0] = \"" @ %path @"\";");

View file

@ -579,7 +579,7 @@
VertSizing = "bottom"; VertSizing = "bottom";
position = "9 4"; position = "9 4";
Extent = "72 16"; Extent = "72 16";
text = "Smoothness"; text = "Roughness";
Profile = "ToolsGuiTextProfile"; Profile = "ToolsGuiTextProfile";
}; };
@ -599,7 +599,7 @@
new GuiSliderCtrl() { new GuiSliderCtrl() {
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
internalName = "SmoothnessSlider"; internalName = "RoughnessSlider";
Enabled = "1"; Enabled = "1";
isContainer = "0"; isContainer = "0";
Profile = "ToolsGuiSliderProfile"; Profile = "ToolsGuiSliderProfile";
@ -610,10 +610,10 @@
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
Visible = "1"; Visible = "1";
Command = "MaterialEditorGui.updateActiveMaterial(\"Smoothness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, true);"; Command = "MaterialEditorGui.updateActiveMaterial(\"Roughness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, true);";
AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Smoothness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, false);"; AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Roughness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, false);";
tooltipprofile = "ToolsGuiDefaultProfile"; tooltipprofile = "ToolsGuiDefaultProfile";
ToolTip = "Sets Smoothness."; ToolTip = "Sets Roughness.";
hovertime = "1000"; hovertime = "1000";
range = "0 1"; range = "0 1";
ticks = "0"; ticks = "0";
@ -621,7 +621,7 @@
}; };
new GuiTextEditCtrl() { new GuiTextEditCtrl() {
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
internalName = "SmoothnessTextEdit"; internalName = "RoughnessTextEdit";
Enabled = "1"; Enabled = "1";
isContainer = "0"; isContainer = "0";
Profile = "ToolsGuiTextEditProfile"; Profile = "ToolsGuiTextEditProfile";
@ -632,7 +632,7 @@
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
Visible = "1"; Visible = "1";
Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Smoothness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());"; Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Roughness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());";
hovertime = "1000"; hovertime = "1000";
AnchorTop = "1"; AnchorTop = "1";
AnchorBottom = "0"; AnchorBottom = "0";
@ -724,7 +724,7 @@
}; };
new GuiCheckBoxCtrl() { new GuiCheckBoxCtrl() {
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
internalName = "invertSmoothnessCheckbox"; internalName = "invertRoughnessCheckbox";
Enabled = "1"; Enabled = "1";
isContainer = "0"; isContainer = "0";
Profile = "ToolsGuiCheckBoxProfile"; Profile = "ToolsGuiCheckBoxProfile";
@ -735,11 +735,11 @@
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
Visible = "1"; Visible = "1";
Command = "MaterialEditorGui.updateActiveMaterial(\"invertSmoothness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());"; Command = "MaterialEditorGui.updateActiveMaterial(\"invertRoughness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());";
tooltipprofile = "ToolsGuiDefaultProfile"; tooltipprofile = "ToolsGuiDefaultProfile";
ToolTip = "Treat as Roughest = 1.0, not 0.0"; ToolTip = "Treat as Roughest = 1.0, not 0.0";
hovertime = "1000"; hovertime = "1000";
text = "Invert Smoothness"; text = "Invert Roughness";
groupNum = "-1"; groupNum = "-1";
buttonType = "ToggleButton"; buttonType = "ToggleButton";
useMouseEvents = "0"; useMouseEvents = "0";
@ -772,7 +772,7 @@
new GuiBitmapCtrl() { new GuiBitmapCtrl() {
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
internalName = "PBRConfigMapDisplayBitmap"; internalName = "ORMConfigMapDisplayBitmap";
Enabled = "1"; Enabled = "1";
isContainer = "0"; isContainer = "0";
Profile = "ToolsGuiDefaultProfile"; Profile = "ToolsGuiDefaultProfile";
@ -806,7 +806,7 @@
AnchorBottom = "0"; AnchorBottom = "0";
AnchorLeft = "1"; AnchorLeft = "1";
AnchorRight = "0"; AnchorRight = "0";
text = "PBR Config Map"; text = "ORM(Config)Map";
maxLength = "1024"; maxLength = "1024";
}; };
new GuiBitmapButtonCtrl() { new GuiBitmapButtonCtrl() {
@ -821,9 +821,9 @@
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
Visible = "1"; Visible = "1";
Command = "MaterialEditorGui.updatePBRConfigMap(1);"; Command = "MaterialEditorGui.updateORMConfigMap(1);";
tooltipprofile = "ToolsGuiDefaultProfile"; tooltipprofile = "ToolsGuiDefaultProfile";
ToolTip = "Change the packed spec map for this layer. \n Smoothness (R), Ambient Occlusion (G), and Metalness(B))"; ToolTip = "Change the packed spec map for this layer. \n Roughness (R), Ambient Occlusion (G), and Metalness(B))";
hovertime = "1000"; hovertime = "1000";
groupNum = "-1"; groupNum = "-1";
buttonType = "PushButton"; buttonType = "PushButton";
@ -832,7 +832,7 @@
}; };
new GuiTextCtrl() { new GuiTextCtrl() {
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
internalName = "PBRConfigMapNameText"; internalName = "ORMConfigMapNameText";
Enabled = "1"; Enabled = "1";
isContainer = "0"; isContainer = "0";
Profile = "ToolsGuiTextProfile"; Profile = "ToolsGuiTextProfile";
@ -861,7 +861,7 @@
position = "134 34"; position = "134 34";
Extent = "40 16"; Extent = "40 16";
buttonType = "PushButton"; buttonType = "PushButton";
command="MaterialEditorGui.updatePBRConfigMap(1);"; command="MaterialEditorGui.updateORMConfigMap(1);";
}; };
new GuiBitmapButtonCtrl() { new GuiBitmapButtonCtrl() {
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
@ -875,7 +875,7 @@
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
Visible = "1"; Visible = "1";
Command = "MaterialEditorGui.updatePBRConfigMap(0);"; Command = "MaterialEditorGui.updateORMConfigMap(0);";
hovertime = "1000"; hovertime = "1000";
groupNum = "-1"; groupNum = "-1";
buttonType = "PushButton"; buttonType = "PushButton";
@ -1010,7 +1010,7 @@
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
new GuiTextCtrl() { new GuiTextCtrl() {
text = "Smoothness"; text = "Roughness";
maxLength = "1024"; maxLength = "1024";
margin = "0 0 0 0"; margin = "0 0 0 0";
padding = "0 0 0 0"; padding = "0 0 0 0";
@ -1051,7 +1051,7 @@
active = "1"; active = "1";
command = "MaterialEditorGui.updateroughMap(1);"; command = "MaterialEditorGui.updateroughMap(1);";
tooltipProfile = "GuiToolTipProfile"; tooltipProfile = "GuiToolTipProfile";
tooltip = "Change the Smoothness map for this layer."; tooltip = "Change the Roughness map for this layer.";
hovertime = "1000"; hovertime = "1000";
isContainer = "0"; isContainer = "0";
canSave = "1"; canSave = "1";

View file

@ -590,9 +590,9 @@ function MaterialEditorGui::convertTextureFields(%this)
for(%specI = 0; %specI < 4; %specI++) for(%specI = 0; %specI < 4; %specI++)
{ {
%PBRConfigMap = MaterialEditorGui.currentMaterial.PBRConfigMap[%specI]; %ORMConfigMap = MaterialEditorGui.currentMaterial.ORMConfigMap[%specI];
%PBRConfigMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %PBRConfigMap); %ORMConfigMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %ORMConfigMap);
MaterialEditorGui.currentMaterial.PBRConfigMap[%specI] = %PBRConfigMap; MaterialEditorGui.currentMaterial.ORMConfigMap[%specI] = %ORMConfigMap;
} }
for(%roughI = 0; %roughI < 4; %roughI++) for(%roughI = 0; %roughI < 4; %roughI++)
@ -914,17 +914,17 @@ function MaterialEditorGui::guiSync( %this, %material )
MaterialEditorPropertiesWindow-->toneMapDisplayBitmap.setBitmap( (%material).toneMap[%layer] ); MaterialEditorPropertiesWindow-->toneMapDisplayBitmap.setBitmap( (%material).toneMap[%layer] );
} }
MaterialEditorPropertiesWindow-->isSRGBCheckbox.setValue((%material).isSRGB[%layer]); MaterialEditorPropertiesWindow-->isSRGBCheckbox.setValue((%material).isSRGB[%layer]);
MaterialEditorPropertiesWindow-->invertSmoothnessCheckbox.setValue((%material).invertSmoothness[%layer]); MaterialEditorPropertiesWindow-->invertRoughnessCheckbox.setValue((%material).invertRoughness[%layer]);
if((%material).PBRConfigMap[%layer] $= "") if((%material).ORMConfigMap[%layer] $= "")
{ {
MaterialEditorPropertiesWindow-->PBRConfigMapNameText.setText( "None" ); MaterialEditorPropertiesWindow-->ORMConfigMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.setBitmap( "tools/materialEditor/gui/unknownImage" ); MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.setBitmap( "tools/materialEditor/gui/unknownImage" );
} }
else else
{ {
MaterialEditorPropertiesWindow-->PBRConfigMapNameText.setText( (%material).PBRConfigMap[%layer] ); MaterialEditorPropertiesWindow-->ORMConfigMapNameText.setText( (%material).ORMConfigMap[%layer] );
MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.setBitmap( (%material).PBRConfigMap[%layer] ); MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.setBitmap( (%material).ORMConfigMap[%layer] );
} }
if((%material).roughMap[%layer] $= "") if((%material).roughMap[%layer] $= "")
@ -988,8 +988,8 @@ function MaterialEditorGui::guiSync( %this, %material )
MaterialEditorPropertiesWindow-->colorTintSwatch.color = (%material).diffuseColor[%layer]; MaterialEditorPropertiesWindow-->colorTintSwatch.color = (%material).diffuseColor[%layer];
MaterialEditorPropertiesWindow-->specularColorSwatch.color = (%material).specular[%layer]; MaterialEditorPropertiesWindow-->specularColorSwatch.color = (%material).specular[%layer];
MaterialEditorPropertiesWindow-->SmoothnessTextEdit.setText((%material).Smoothness[%layer]); MaterialEditorPropertiesWindow-->RoughnessTextEdit.setText((%material).Roughness[%layer]);
MaterialEditorPropertiesWindow-->SmoothnessSlider.setValue((%material).Smoothness[%layer]); MaterialEditorPropertiesWindow-->RoughnessSlider.setValue((%material).Roughness[%layer]);
MaterialEditorPropertiesWindow-->MetalnessTextEdit.setText((%material).Metalness[%layer]); MaterialEditorPropertiesWindow-->MetalnessTextEdit.setText((%material).Metalness[%layer]);
MaterialEditorPropertiesWindow-->MetalnessSlider.setValue((%material).Metalness[%layer]); MaterialEditorPropertiesWindow-->MetalnessSlider.setValue((%material).Metalness[%layer]);
MaterialEditorPropertiesWindow-->glowMulTextEdit.setText((%material).glowMul[%layer]); MaterialEditorPropertiesWindow-->glowMulTextEdit.setText((%material).glowMul[%layer]);
@ -1065,7 +1065,7 @@ function MaterialEditorGui::guiSync( %this, %material )
MaterialEditorPropertiesWindow-->accuCheckbox.setValue((%material).accuEnabled[%layer]); MaterialEditorPropertiesWindow-->accuCheckbox.setValue((%material).accuEnabled[%layer]);
%this.getRoughChan((%material).SmoothnessChan[%layer]); %this.getRoughChan((%material).RoughnessChan[%layer]);
%this.getAOChan((%material).AOChan[%layer]); %this.getAOChan((%material).AOChan[%layer]);
%this.getMetalChan((%material).metalChan[%layer]); %this.getMetalChan((%material).metalChan[%layer]);
%this.getGlowChan((%material).glowChan[%layer]); %this.getGlowChan((%material).glowChan[%layer]);
@ -1276,7 +1276,7 @@ function MaterialEditorGui::updateDetailNormalStrength(%this,%newStrength)
MaterialEditorGui.updateActiveMaterial("detailNormalMapStrength[" @ %layer @ "]", %detailStrength); MaterialEditorGui.updateActiveMaterial("detailNormalMapStrength[" @ %layer @ "]", %detailStrength);
} }
function MaterialEditorGui::updatePBRConfigMap(%this,%action) function MaterialEditorGui::updateORMConfigMap(%this,%action)
{ {
%layer = MaterialEditorGui.currentLayer; %layer = MaterialEditorGui.currentLayer;
@ -1287,20 +1287,20 @@ function MaterialEditorGui::updatePBRConfigMap(%this,%action)
{ {
MaterialEditorGui.updateActiveMaterial("pixelSpecular[" @ MaterialEditorGui.currentLayer @ "]", 0); MaterialEditorGui.updateActiveMaterial("pixelSpecular[" @ MaterialEditorGui.currentLayer @ "]", 0);
MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.setBitmap(%texture); MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.setBitmap(%texture);
%bitmap = MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.bitmap; %bitmap = MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.bitmap;
%bitmap = strreplace(%bitmap,"tools/materialEditor/scripts/",""); %bitmap = strreplace(%bitmap,"tools/materialEditor/scripts/","");
MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.setBitmap(%bitmap); MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.setBitmap(%bitmap);
MaterialEditorPropertiesWindow-->PBRConfigMapNameText.setText(%bitmap); MaterialEditorPropertiesWindow-->ORMConfigMapNameText.setText(%bitmap);
MaterialEditorGui.updateActiveMaterial("PBRConfigMap[" @ %layer @ "]","\"" @ %bitmap @ "\""); MaterialEditorGui.updateActiveMaterial("ORMConfigMap[" @ %layer @ "]","\"" @ %bitmap @ "\"");
} }
} }
else else
{ {
MaterialEditorPropertiesWindow-->PBRConfigMapNameText.setText("None"); MaterialEditorPropertiesWindow-->ORMConfigMapNameText.setText("None");
MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.setBitmap("tools/materialEditor/gui/unknownImage"); MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.setBitmap("tools/materialEditor/gui/unknownImage");
MaterialEditorGui.updateActiveMaterial("PBRConfigMap[" @ %layer @ "]",""); MaterialEditorGui.updateActiveMaterial("ORMConfigMap[" @ %layer @ "]","");
} }
MaterialEditorGui.guiSync( materialEd_previewMaterial ); MaterialEditorGui.guiSync( materialEd_previewMaterial );
@ -2524,7 +2524,7 @@ function MaterialEditorGui::updateAccuCheckbox(%this, %value)
// channel in selectors // channel in selectors
function MaterialEditorGui::setRoughChan(%this, %value) function MaterialEditorGui::setRoughChan(%this, %value)
{ {
MaterialEditorGui.updateActiveMaterial("SmoothnessChan[" @ MaterialEditorGui.currentLayer @ "]", %value); MaterialEditorGui.updateActiveMaterial("RoughnessChan[" @ MaterialEditorGui.currentLayer @ "]", %value);
MaterialEditorGui.guiSync( materialEd_previewMaterial ); MaterialEditorGui.guiSync( materialEd_previewMaterial );
} }
@ -2573,13 +2573,12 @@ function MaterialEditorGui::saveCompositeMap(%this)
%metalMap = %material.metalMap[%layer]; %metalMap = %material.metalMap[%layer];
%glowMap = %material.glowMap[%layer]; %glowMap = %material.glowMap[%layer];
%smooth = %material.SmoothnessChan[%layer]; %roughness = %material.RoughnessChan[%layer];
%ao = %material.AOChan[%layer]; %ao = %material.AOChan[%layer];
%metal = %material.metalChan[%layer]; %metal = %material.metalChan[%layer];
%glow = %material.glowChan[%layer];
%channelKey = %smooth SPC %ao SPC %metal SPC %glow; %channelKey = %roughness SPC %ao SPC %metal SPC 0;
error("Storing: \"" @ %roughMap @"\" \""@ %aoMap @"\" \""@ %metalMap @"\" \""@ %channelKey @"\" \""@ %saveAs @"\""); error("Storing: \"" @ %roughMap @"\" \""@ %aoMap @"\" \""@ %metalMap @"\" \""@ %channelKey @"\" \""@ %saveAs @"\"");
saveCompositeTexture(%roughMap,%aoMap,%metalMap,%glowMap,%channelKey, %saveAs); saveCompositeTexture(%roughMap,%aoMap,%metalMap,"",%channelKey, %saveAs);
%dlg.delete(); %dlg.delete();
} }

View file

@ -2,7 +2,7 @@ singleton Material(ReflectProbePreviewMat)
{ {
mapTo = "ReflectProbePreviewMat"; mapTo = "ReflectProbePreviewMat";
diffuseColor[0] = "1 1 1 1"; diffuseColor[0] = "1 1 1 1";
smoothness[0] = "1"; roughness[0] = "0";
metalness[0] = "1"; metalness[0] = "1";
translucentBlendOp = "None"; translucentBlendOp = "None";
}; };

View file

@ -767,12 +767,12 @@
tooltipProfile = "ToolsGuiToolTipProfile"; tooltipProfile = "ToolsGuiToolTipProfile";
hovertime = "1000"; hovertime = "1000";
isContainer = "0"; isContainer = "0";
internalName = "pbrConfigTexCtrl"; internalName = "ormConfigTexCtrl";
canSave = "1"; canSave = "1";
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
new GuiTextCtrl() { new GuiTextCtrl() {
text = "PBR Config"; text = "ORM Config";
maxLength = "1024"; maxLength = "1024";
margin = "0 0 0 0"; margin = "0 0 0 0";
padding = "0 0 0 0"; padding = "0 0 0 0";
@ -812,9 +812,9 @@
profile = "ToolsGuiDefaultProfile"; profile = "ToolsGuiDefaultProfile";
visible = "1"; visible = "1";
active = "1"; active = "1";
command = "TerrainMaterialDlg.changePBRConfig();"; command = "TerrainMaterialDlg.changeormConfig();";
tooltipProfile = "ToolsGuiDefaultProfile"; tooltipProfile = "ToolsGuiDefaultProfile";
tooltip = "Change the active PBR Config Map for this layer."; tooltip = "Change the active ORM Config Map for this layer.";
hovertime = "1000"; hovertime = "1000";
isContainer = "0"; isContainer = "0";
canSave = "1"; canSave = "1";
@ -856,7 +856,7 @@
profile = "ToolsGuiButtonProfile"; profile = "ToolsGuiButtonProfile";
visible = "1"; visible = "1";
active = "1"; active = "1";
command = "TerrainMaterialDlg.changePBRConfig();"; command = "TerrainMaterialDlg.changeormConfig();";
tooltipProfile = "ToolsGuiToolTipProfile"; tooltipProfile = "ToolsGuiToolTipProfile";
hovertime = "1000"; hovertime = "1000";
isContainer = "0"; isContainer = "0";
@ -881,7 +881,7 @@
profile = "ToolsGuiDefaultProfile"; profile = "ToolsGuiDefaultProfile";
visible = "1"; visible = "1";
active = "1"; active = "1";
command = "TerrainMaterialDlg-->pbrConfigTexCtrl.setBitmap(\"tools/materialEditor/gui/unknownImage\");"; command = "TerrainMaterialDlg-->ormConfigTexCtrl.setBitmap(\"tools/materialEditor/gui/unknownImage\");";
tooltipProfile = "ToolsGuiToolTipProfile"; tooltipProfile = "ToolsGuiToolTipProfile";
hovertime = "1000"; hovertime = "1000";
isContainer = "0"; isContainer = "0";
@ -909,7 +909,7 @@
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
new GuiCheckBoxCtrl() { new GuiCheckBoxCtrl() {
text = " Invert Smoothness"; text = " Invert Roughness";
groupNum = "-1"; groupNum = "-1";
buttonType = "ToggleButton"; buttonType = "ToggleButton";
useMouseEvents = "0"; useMouseEvents = "0";
@ -924,7 +924,7 @@
tooltipProfile = "ToolsGuiToolTipProfile"; tooltipProfile = "ToolsGuiToolTipProfile";
hovertime = "1000"; hovertime = "1000";
isContainer = "0"; isContainer = "0";
internalName = "invertSmoothness"; internalName = "invertRoughness";
canSave = "1"; canSave = "1";
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };

View file

@ -307,9 +307,9 @@ function TerrainMaterialDlg::changeNormal( %this )
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
function TerrainMaterialDlg::changePBRConfig( %this ) function TerrainMaterialDlg::changeormConfig( %this )
{ {
%ctrl = %this-->pbrConfigTexCtrl; %ctrl = %this-->ormConfigTexCtrl;
%file = %ctrl.bitmap; %file = %ctrl.bitmap;
if( getSubStr( %file, 0 , 6 ) $= "tools/" ) if( getSubStr( %file, 0 , 6 ) $= "tools/" )
%file = ""; %file = "";
@ -417,10 +417,10 @@ function TerrainMaterialDlg::setActiveMaterial( %this, %mat )
}else{ }else{
%this-->baseTexCtrl.setBitmap( %mat.diffuseMap ); %this-->baseTexCtrl.setBitmap( %mat.diffuseMap );
} }
if (%mat.pbrConfigMap $= ""){ if (%mat.ormConfigMap $= ""){
%this-->pbrConfigTexCtrl.setBitmap( "tools/materialEditor/gui/unknownImage" ); %this-->ormConfigTexCtrl.setBitmap( "tools/materialEditor/gui/unknownImage" );
}else{ }else{
%this-->pbrConfigTexCtrl.setBitmap( %mat.pbrConfigMap ); %this-->ormConfigTexCtrl.setBitmap( %mat.ormConfigMap );
} }
if (%mat.detailMap $= ""){ if (%mat.detailMap $= ""){
%this-->detailTexCtrl.setBitmap( "tools/materialEditor/gui/unknownImage" ); %this-->detailTexCtrl.setBitmap( "tools/materialEditor/gui/unknownImage" );
@ -449,7 +449,7 @@ function TerrainMaterialDlg::setActiveMaterial( %this, %mat )
%this-->macroDistanceCtrl.setText( %mat.macroDistance ); %this-->macroDistanceCtrl.setText( %mat.macroDistance );
%this-->isSRGB.setValue( %mat.isSRGB ); %this-->isSRGB.setValue( %mat.isSRGB );
%this-->invertSmoothness.setValue( %mat.invertSmoothness ); %this-->invertRoughness.setValue( %mat.invertRoughness );
%this.activateMaterialCtrls( true ); %this.activateMaterialCtrls( true );
} }
@ -483,10 +483,10 @@ function TerrainMaterialDlg::saveDirtyMaterial( %this, %mat )
}else{ }else{
%newNormal = %this-->normTexCtrl.bitmap; %newNormal = %this-->normTexCtrl.bitmap;
} }
if (%this-->pbrConfigTexCtrl.bitmap $= "tools/materialEditor/gui/unknownImage"){ if (%this-->ormConfigTexCtrl.bitmap $= "tools/materialEditor/gui/unknownImage"){
%newPBRConfig = ""; %newormConfig = "";
}else{ }else{
%newPBRConfig = %this-->pbrConfigTexCtrl.bitmap; %newormConfig = %this-->ormConfigTexCtrl.bitmap;
} }
if (%this-->detailTexCtrl.bitmap $= "tools/materialEditor/gui/unknownImage"){ if (%this-->detailTexCtrl.bitmap $= "tools/materialEditor/gui/unknownImage"){
%newDetail = ""; %newDetail = "";
@ -510,7 +510,7 @@ function TerrainMaterialDlg::saveDirtyMaterial( %this, %mat )
%macroDistance = %this-->macroDistanceCtrl.getText(); %macroDistance = %this-->macroDistanceCtrl.getText();
%isSRGB = %this-->isSRGB.getValue(); %isSRGB = %this-->isSRGB.getValue();
%invertSmoothness = %this-->invertSmoothness.getValue(); %invertRoughness = %this-->invertRoughness.getValue();
// If no properties of this materials have changed, // If no properties of this materials have changed,
// return. // return.
@ -519,7 +519,7 @@ function TerrainMaterialDlg::saveDirtyMaterial( %this, %mat )
%mat.diffuseMap $= %newDiffuse && %mat.diffuseMap $= %newDiffuse &&
%mat.normalMap $= %newNormal && %mat.normalMap $= %newNormal &&
%mat.detailMap $= %newDetail && %mat.detailMap $= %newDetail &&
%mat.pbrConfigMap $= %newPBRConfig && %mat.ormConfigMap $= %newormConfig &&
%mat.macroMap $= %newMacro && %mat.macroMap $= %newMacro &&
%mat.detailSize == %detailSize && %mat.detailSize == %detailSize &&
%mat.diffuseSize == %diffuseSize && %mat.diffuseSize == %diffuseSize &&
@ -531,7 +531,7 @@ function TerrainMaterialDlg::saveDirtyMaterial( %this, %mat )
%mat.macroDistance == %macroDistance && %mat.macroDistance == %macroDistance &&
%mat.parallaxScale == %parallaxScale && %mat.parallaxScale == %parallaxScale &&
%mat.isSRGB == %isSRGB && %mat.isSRGB == %isSRGB &&
%mat.invertSmoothness == %invertSmoothness) %mat.invertRoughness == %invertRoughness)
return; return;
// Make sure the material name is unique. // Make sure the material name is unique.
@ -555,7 +555,7 @@ function TerrainMaterialDlg::saveDirtyMaterial( %this, %mat )
%mat.diffuseMap = %newDiffuse; %mat.diffuseMap = %newDiffuse;
%mat.diffuseMapAsset = ""; %mat.diffuseMapAsset = "";
%mat.normalMap = %newNormal; %mat.normalMap = %newNormal;
%mat.pbrConfigMap = %newPBRConfig; %mat.ormConfigMap = %newormConfig;
%mat.detailMap = %newDetail; %mat.detailMap = %newDetail;
%mat.macroMap = %newMacro; %mat.macroMap = %newMacro;
%mat.detailSize = %detailSize; %mat.detailSize = %detailSize;
@ -568,7 +568,7 @@ function TerrainMaterialDlg::saveDirtyMaterial( %this, %mat )
%mat.useSideProjection = %useSideProjection; %mat.useSideProjection = %useSideProjection;
%mat.parallaxScale = %parallaxScale; %mat.parallaxScale = %parallaxScale;
%mat.isSRGB = %isSRGB; %mat.isSRGB = %isSRGB;
%mat.invertSmoothness = %invertSmoothness; %mat.invertRoughness = %invertRoughness;
// Mark the material as dirty and needing saving. // Mark the material as dirty and needing saving.
@ -607,7 +607,7 @@ function TerrainMaterialDlg::snapshotMaterials( %this )
internalName = %mat.internalName; internalName = %mat.internalName;
diffuseMap = %mat.diffuseMap; diffuseMap = %mat.diffuseMap;
normalMap = %mat.normalMap; normalMap = %mat.normalMap;
pbrConfigMap = %mat.pbrConfigMap; ormConfigMap = %mat.ormConfigMap;
detailMap = %mat.detailMap; detailMap = %mat.detailMap;
macroMap = %mat.macroMap; macroMap = %mat.macroMap;
detailSize = %mat.detailSize; detailSize = %mat.detailSize;
@ -620,7 +620,7 @@ function TerrainMaterialDlg::snapshotMaterials( %this )
useSideProjection = %mat.useSideProjection; useSideProjection = %mat.useSideProjection;
parallaxScale = %mat.parallaxScale; parallaxScale = %mat.parallaxScale;
isSRGB = %mat.isSRGB; isSRGB = %mat.isSRGB;
invertSmoothness = %mat.invertSmoothness; invertRoughness = %mat.invertRoughness;
}; };
} }
} }
@ -644,7 +644,7 @@ function TerrainMaterialDlg::restoreMaterials( %this )
%mat.setInternalName( %obj.internalName ); %mat.setInternalName( %obj.internalName );
%mat.diffuseMap = %obj.diffuseMap; %mat.diffuseMap = %obj.diffuseMap;
%mat.normalMap = %obj.normalMap; %mat.normalMap = %obj.normalMap;
%mat.pbrConfigMap = %obj.pbrConfigMap; %mat.ormConfigMap = %obj.ormConfigMap;
%mat.detailMap = %obj.detailMap; %mat.detailMap = %obj.detailMap;
%mat.macroMap = %obj.macroMap; %mat.macroMap = %obj.macroMap;
%mat.detailSize = %obj.detailSize; %mat.detailSize = %obj.detailSize;
@ -657,7 +657,7 @@ function TerrainMaterialDlg::restoreMaterials( %this )
%mat.useSideProjection = %obj.useSideProjection; %mat.useSideProjection = %obj.useSideProjection;
%mat.parallaxScale = %obj.parallaxScale; %mat.parallaxScale = %obj.parallaxScale;
%mat.isSRGB = %obj.isSRGB; %mat.isSRGB = %obj.isSRGB;
%mat.invertSmoothness = %obj.invertSmoothness; %mat.invertRoughness = %obj.invertRoughness;
} }
} }