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[] = {
"Albedo",
"Normal",
"PBRConfig",
"ORMConfig",
"GUI",
"Roughness",
"AO",

View file

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

View file

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

View file

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

View file

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

View file

@ -1028,26 +1028,45 @@ GFXTextureObject *GFXTextureManager::createCompositeTexture(const Torque::Path &
GFXTextureObject *cacheHit = _lookupTexture(resourceTag, profile);
if (cacheHit != NULL) return cacheHit;
Torque::Path lastValidPath = "";
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())
{
bitmap[1] = loadUncompressedTexture(pathG, profile);
lastValidPath = pathG;
}
else
bitmap[1] = NULL;
if (!pathB.isEmpty())
{
bitmap[2] = loadUncompressedTexture(pathB, profile);
lastValidPath = pathB;
}
else
bitmap[2] = NULL;
if (!pathA.isEmpty())
{
bitmap[3] = loadUncompressedTexture(pathA, profile);
lastValidPath = pathA;
}
else
bitmap[3] = NULL;
Path realPath;
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);
@ -1087,26 +1106,45 @@ void GFXTextureManager::saveCompositeTexture(const Torque::Path &pathR, const To
cacheHit->dumpToDisk("png", saveAs.getFullPath());
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())
{
bitmap[1] = loadUncompressedTexture(pathG, profile);
lastValidPath = pathG;
}
else
bitmap[1] = NULL;
if (!pathB.isEmpty())
{
bitmap[2] = loadUncompressedTexture(pathB, profile);
lastValidPath = pathB;
}
else
bitmap[2] = NULL;
if (!pathA.isEmpty())
{
bitmap[3] = loadUncompressedTexture(pathA, profile);
lastValidPath = pathA;
}
else
bitmap[3] = NULL;
Path realPath;
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);
if (retTexObj != NULL)
@ -1130,9 +1168,16 @@ DefineEngineFunction(saveCompositeTexture, void, (const char* pathR, const char*
GFXTextureObject *GFXTextureManager::createCompositeTexture(GBitmap*bmp[4], U32 inputKey[4],
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;
}
@ -1145,11 +1190,11 @@ GFXTextureObject *GFXTextureManager::createCompositeTexture(GBitmap*bmp[4], U32
U8 rChan, gChan, bChan, aChan;
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
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]);

View file

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

View file

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

View file

@ -27,7 +27,7 @@
#include "shaderGen/GLSL/bumpGLSL.h"
// Specular Outputs
class PBRConfigMapGLSL : public ShaderFeatureGLSL
class DeferredOrmMapGLSL : public ShaderFeatureGLSL
{
public:
virtual String getName() { return "Deferred Shading: PBR Config Map"; }
@ -60,7 +60,7 @@ public:
virtual U32 getOutputTargets(const MaterialFeatureData& fd) const;
};
class PBRConfigVarsGLSL : public ShaderFeatureGLSL
class ORMConfigVarsGLSL : public ShaderFeatureGLSL
{
public:
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 );
return;
}
else if (!fd.features[MFT_PBRConfigMap] )
else if (!fd.features[MFT_OrmMap] )
{
Var *bumpSample = (Var *)LangElement::find( "bumpSample" );
if( bumpSample == NULL )
@ -428,7 +428,7 @@ ShaderFeature::Resources DeferredBumpFeatHLSL::getResources( const MaterialFeatu
return Parent::getResources( fd );
Resources res;
if(!fd.features[MFT_PBRConfigMap])
if(!fd.features[MFT_OrmMap])
{
res.numTex = 1;
res.numTexReg = 1;
@ -471,7 +471,7 @@ void DeferredBumpFeatHLSL::setTexData( Material::StageData &stageDat,
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]) )
{
passData.mTexType[ texIndex ] = Material::Bump;

View file

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

View file

@ -26,7 +26,7 @@
#include "shaderGen/HLSL/shaderFeatureHLSL.h"
#include "shaderGen/HLSL/bumpHLSL.h"
class PBRConfigMapHLSL : public ShaderFeatureHLSL
class DeferredOrmMapHLSL : public ShaderFeatureHLSL
{
public:
virtual String getName() { return "Deferred Shading: PBR Config Map"; }
@ -59,7 +59,7 @@ public:
virtual U32 getOutputTargets(const MaterialFeatureData& fd) const;
};
class PBRConfigVarsHLSL : public ShaderFeatureHLSL
class ORMConfigVarsHLSL : public ShaderFeatureHLSL
{
public:
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 );
mDiffuseMapSRGB[i] = true;
mSmoothness[i] = 0.0f;
mRoughness[i] = 1.0f;
mMetalness[i] = 0.0f;
mIsSRGb[i] = true;
mInvertSmoothness[i] = false;
mInvertRoughness[i] = false;
mSmoothnessChan[i] = 0;
mRoughnessChan[i] = 0;
mAOChan[i] = 1;
mMetalChan[i] = 2;
@ -265,11 +265,11 @@ void Material::initPersistFields()
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." );
addField("smoothness", TypeF32, Offset(mSmoothness, Material), MAX_STAGES,
"The degree of smoothness when not using a PBRConfigMap." );
addField("roughness", TypeF32, Offset(mRoughness, Material), MAX_STAGES,
"The degree of roughness when not using a ORMConfigMap." );
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,
"glow mask multiplier");
@ -295,11 +295,11 @@ void Material::initPersistFields()
addField("isSRGb", TypeBool, Offset(mIsSRGb, Material), MAX_STAGES,
"Substance Designer Workaround.");
addField("invertSmoothness", TypeBool, Offset(mInvertSmoothness, Material), MAX_STAGES,
"Treat Smoothness as Roughness");
addField("invertRoughness", TypeBool, Offset(mInvertRoughness, Material), MAX_STAGES,
"Treat Roughness as Roughness");
addField("smoothnessChan", TypeF32, Offset(mSmoothnessChan, Material), MAX_STAGES,
"The input channel smoothness maps use.");
addField("roughnessChan", TypeF32, Offset(mRoughnessChan, Material), MAX_STAGES,
"The input channel roughness maps use.");
addField("AOChan", TypeF32, Offset(mAOChan, Material), MAX_STAGES,
"The input channel AO maps use.");

View file

@ -211,11 +211,11 @@ public:
DECLARE_TEXTUREARRAY(ToneMap, MAX_STAGES);
DECLARE_TEXTUREARRAY(DetailMap, MAX_STAGES);;
DECLARE_TEXTUREARRAY(NormalMap, MAX_STAGES);
DECLARE_TEXTUREARRAY(PBRConfigMap, MAX_STAGES);
DECLARE_TEXTUREARRAY(ORMConfigMap, MAX_STAGES);
bool mIsSRGb[MAX_STAGES];
DECLARE_TEXTUREARRAY(RoughMap, MAX_STAGES);
bool mInvertSmoothness[MAX_STAGES];
F32 mSmoothnessChan[MAX_STAGES];
bool mInvertRoughness[MAX_STAGES];
F32 mRoughnessChan[MAX_STAGES];
DECLARE_TEXTUREARRAY(AOMap, MAX_STAGES);
F32 mAOChan[MAX_STAGES];
DECLARE_TEXTUREARRAY(MetalMap, MAX_STAGES);
@ -240,7 +240,7 @@ public:
/// the diffuse texture color.
LinearColorF mDiffuse[MAX_STAGES];
F32 mSmoothness[MAX_STAGES];
F32 mRoughness[MAX_STAGES];
F32 mMetalness[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_DiffuseVertColor, MFG_Texture, 6.0f, true );
ImplementFeatureType( MFT_AlphaTest, MFG_Texture, 7.0f, true );
ImplementFeatureType( MFT_InvertSmoothness, U32(-1), -1, true);
ImplementFeatureType( MFT_PBRConfigMap, MFG_Texture, 8.0f, true);
ImplementFeatureType( MFT_PBRConfigVars, MFG_Texture, 8.0f, true);
ImplementFeatureType( MFT_InvertRoughness, U32(-1), -1, true);
ImplementFeatureType( MFT_OrmMap, MFG_Texture, 8.0f, true);
ImplementFeatureType( MFT_ORMConfigVars, MFG_Texture, 8.0f, true);
ImplementFeatureType( MFT_MatInfoFlags, MFG_Texture, 9.0f, true);
ImplementFeatureType( MFT_NormalMap, MFG_Texture, 11.0f, true );
ImplementFeatureType( MFT_DetailNormalMap, MFG_Texture, 12.0f, true );

View file

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

View file

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

View file

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

View file

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

View file

@ -633,16 +633,16 @@ void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum,
}
newFeatures.addFeature( MFT_DiffuseColor );
if (mMaterial->mInvertSmoothness[stageNum])
newFeatures.addFeature(MFT_InvertSmoothness);
if (mMaterial->mInvertRoughness[stageNum])
newFeatures.addFeature(MFT_InvertRoughness);
// 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
newFeatures.addFeature( MFT_PBRConfigVars );
newFeatures.addFeature( MFT_ORMConfigVars );
if (mStages[stageNum].getTex(MFT_GlowMap))
{

View file

@ -204,7 +204,8 @@ RenderProbeMgr::RenderProbeMgr()
mHasSkylight(false),
mSkylightCubemapIdx(-1),
mCubeMapCount(0),
mDefaultSkyLight(nullptr)
mDefaultSkyLight(nullptr),
mBakeRenderTarget(nullptr)
{
mEffectiveProbeCount = 0;
mMipCount = 0;
@ -462,7 +463,7 @@ void RenderProbeMgr::_setupStaticParameters()
continue;
U32 mips = mRegisteredProbes[i].mPrefilterCubemap.getPointer()->getMipMapLevels();
mMipCount = mips != 0 && mips >= mMipCount ? mips : 0;
mMipCount = (mips != 0 && mips >= mMipCount) ? mips : 0;
if (curEntry.mIsSkylight)
{
@ -853,7 +854,7 @@ void RenderProbeMgr::render( SceneRenderState *state )
//PROFILE_END();
}
void RenderProbeMgr::bakeProbe(ReflectionProbe *probe, bool writeFiles)
void RenderProbeMgr::bakeProbe(ReflectionProbe* probe, bool writeFiles)
{
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/");
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);
ReflectionProbe* clientProbe = nullptr;
@ -957,12 +958,13 @@ void RenderProbeMgr::bakeProbe(ReflectionProbe *probe, bool writeFiles)
clientProbe->mIrridianceMap->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::GeneratePrefilterMap(renderTarget, cubeRefl.getCubemap(), prefilterMipLevels, clientProbe->mPrefilterMap->mCubemap);
renderTarget->destroySelf();
IBLUtilities::GenerateIrradianceMap(mBakeRenderTarget, cubeRefl.getCubemap(), clientProbe->mIrridianceMap->mCubemap);
IBLUtilities::GeneratePrefilterMap(mBakeRenderTarget, cubeRefl.getCubemap(), prefilterMipLevels, clientProbe->mPrefilterMap->mCubemap);
U32 endMSTime = Platform::getRealMilliseconds();
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->getPrefilterMapPath(), clientProbe->mPrefilterMap->mCubemap);
}
mBakeRenderTarget->zombify();
}
else
{
Con::errorf("RenderProbeMgr::bake() - Didn't generate a valid scene capture cubemap, unable to generate prefilter and irradiance maps!");
}
if (!renderWithProbes)
RenderProbeMgr::smRenderReflectionProbes = probeRenderState;

View file

@ -280,6 +280,8 @@ private:
GFXTexHandle mBRDFTexture;
GFXTextureTargetRef mBakeRenderTarget;
public:
RenderProbeMgr();
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* pbrConfig = (Var*)LangElement::find("PBRConfig");
if (!pbrConfig)
Var* ormConfig = (Var*)LangElement::find("ORMConfig");
if (!ormConfig)
{
Var* metalness = (Var*)LangElement::find("metalness");
if (!metalness)
@ -852,17 +852,17 @@ Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
metalness->constSortPos = cspPotentialPrimitive;
}
Var* smoothness = (Var*)LangElement::find("smoothness");
if (!smoothness)
Var* roughness = (Var*)LangElement::find("roughness");
if (!roughness)
{
smoothness = new Var("smoothness", "float");
smoothness->uniform = true;
smoothness->constSortPos = cspPotentialPrimitive;
roughness = new Var("roughness", "float");
roughness->uniform = true;
roughness->constSortPos = cspPotentialPrimitive;
}
pbrConfig = new Var("PBRConfig", "vec4");
LangElement* colorDecl = new DecOp(pbrConfig);
meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct pbrConfig, no ao darkening
ormConfig = new Var("ORMConfig", "vec4");
LangElement* colorDecl = new DecOp(ormConfig);
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");
@ -899,7 +899,7 @@ Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
if (!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));
}
@ -1922,9 +1922,9 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
LangElement *texCube = NULL;
Var* matinfo = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
Var *smoothness = (Var*)LangElement::find("smoothness");
if (smoothness) //try to grab smoothness directly
texCube = new GenOp("textureLod( @, @, min((1.0 - @)*@ + 1.0, @))", cubeMap, reflectVec, smoothness, cubeMips, cubeMips);
Var *roughness = (Var*)LangElement::find("roughness");
if (roughness) //try to grab roughness directly
texCube = new GenOp("textureLod( @, @, min((1.0 - @)*@ + 1.0, @))", cubeMap, reflectVec, roughness, cubeMips, cubeMips);
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);
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!");
return;
}
Var *smoothness = (Var*)LangElement::find("smoothness");
Var *roughness = (Var*)LangElement::find("roughness");
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_StaticCubemap, new NamedFeatureGLSL( "Static Cubemap" ) );
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_IsTranslucent, new NamedFeatureGLSL( "Translucent" ) );
FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureGLSL( "Translucent ZWrite" ) );
@ -99,8 +99,8 @@ void _initShaderGenGLSL( ShaderGen *shaderGen )
// Deferred Shading
FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureGLSL( "Deferred Material" ) );
FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapGLSL );
FEATUREMGR->registerFeature( MFT_PBRConfigVars, new PBRConfigVarsGLSL );
FEATUREMGR->registerFeature( MFT_OrmMap, new DeferredOrmMapGLSL );
FEATUREMGR->registerFeature( MFT_ORMConfigVars, new ORMConfigVarsGLSL );
FEATUREMGR->registerFeature( MFT_MatInfoFlags, new MatInfoFlagsGLSL );
FEATUREMGR->registerFeature( MFT_GlowMap, new GlowMapGLSL);
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* 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* smoothness = (Var*)LangElement::find("smoothness");
Var* roughness = (Var*)LangElement::find("roughness");
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* pbrConfig = (Var*)LangElement::find("PBRConfig");
if (!pbrConfig)
Var* ormConfig = (Var*)LangElement::find("ORMConfig");
if (!ormConfig)
{
Var* metalness = (Var*)LangElement::find("metalness");
if (!metalness)
@ -859,17 +859,17 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
metalness->constSortPos = cspPotentialPrimitive;
}
Var* smoothness = (Var*)LangElement::find("smoothness");
if (!smoothness)
Var* roughness = (Var*)LangElement::find("roughness");
if (!roughness)
{
smoothness = new Var("smoothness", "float");
smoothness->uniform = true;
smoothness->constSortPos = cspPotentialPrimitive;
roughness = new Var("roughness", "float");
roughness->uniform = true;
roughness->constSortPos = cspPotentialPrimitive;
}
pbrConfig = new Var("PBRConfig", "float4");
LangElement* colorDecl = new DecOp(pbrConfig);
meta->addStatement(new GenOp(" @ = float4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct matinfo, no ao darkening
ormConfig = new Var("ORMConfig", "float4");
LangElement* colorDecl = new DecOp(ormConfig);
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");
@ -902,7 +902,7 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
if (!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));
}
@ -1327,7 +1327,7 @@ void LightmapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
lightMapTex->texture = true;
lightMapTex->constNum = lightMap->constNum;
// argh, PBRConfigMap should prob use this too
// argh, ORMConfigMap should prob use this too
if( fd.features[MFT_NormalMap] )
{
Var *lmColor = new Var;
@ -1985,11 +1985,11 @@ void ReflectCubeFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
LangElement *texCube = NULL;
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
{
@ -2287,7 +2287,7 @@ void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
Con::errorf("ShaderGen::RTLightingFeatHLSL() - failed to generate surface!");
return;
}
Var *smoothness = (Var*)LangElement::find("smoothness");
Var *roughness = (Var*)LangElement::find("roughness");
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_CubeMap, new ReflectCubeFeatHLSL );
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_IsTranslucentZWrite, new NamedFeatureHLSL( "Translucent ZWrite" ) );
FEATUREMGR->registerFeature( MFT_Visibility, new VisibilityFeatHLSL );
@ -102,8 +102,8 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
FEATUREMGR->registerFeature( MFT_ImposterVert, new ImposterVertFeatureHLSL );
FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureHLSL( "Deferred Material" ) );
FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapHLSL);
FEATUREMGR->registerFeature( MFT_PBRConfigVars, new PBRConfigVarsHLSL);
FEATUREMGR->registerFeature( MFT_OrmMap, new DeferredOrmMapHLSL);
FEATUREMGR->registerFeature( MFT_ORMConfigVars, new ORMConfigVarsHLSL);
FEATUREMGR->registerFeature( MFT_MatInfoFlags, new MatInfoFlagsHLSL );
FEATUREMGR->registerFeature( MFT_GlowMap, new GlowMapHLSL);
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::vectorLightBrightness("$vectorLightBrightness");
const String ShaderGenVars::pbrConfig("$PBRConfig");
const String ShaderGenVars::smoothness("$smoothness");
const String ShaderGenVars::ormConfig("$ORMConfig");
const String ShaderGenVars::roughness("$roughness");
const String ShaderGenVars::metalness("$metalness");
const String ShaderGenVars::glowMul("$glowMul");

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -59,7 +59,7 @@ protected:
MaterialInfo()
: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;
GFXTexHandle normalTex;
GFXShaderConstHandle *compositeTexConst;
GFXTexHandle compositeTex;
GFXShaderConstHandle *ormTexConst;
GFXTexHandle ormTex;
GFXShaderConstHandle *detailInfoVConst;
GFXShaderConstHandle *detailInfoPConst;

View file

@ -36,4 +36,4 @@ ImplementFeatureType( MFT_TerrainSideProject, MFG_Texture, 106.0f, false );
ImplementFeatureType( MFT_TerrainAdditive, MFG_PostProcess, 999.0f, false );
//Deferred Shading
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_TerrainAdditive );
//Deferred Shading
DeclareFeatureType( MFT_TerrainCompositeMap );
DeclareFeatureType( MFT_TerrainORMMap );
DeclareFeatureType( MFT_DeferredTerrainBlankInfoMap );

View file

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

View file

@ -49,13 +49,10 @@ protected:
F32 mDiffuseSize;
///
FileName mNormalMap;
DECLARE_TEXTUREMAP(NormalMap);
///
FileName mDetailMap;
///
FileName mCompositeMap;
DECLARE_TEXTUREMAP(DetailMap);
/// The size of the detail map in meters used
/// to generate the texture coordinates for the
@ -68,13 +65,19 @@ protected:
///
F32 mDetailDistance;
///
DECLARE_TEXTUREMAP(ORMConfigMap);
bool mIsSRGB;
bool mInvertRoughness;
/// Normally the detail is projected on to the xy
/// coordinates of the terrain. If this flag is true
/// then this detail is projected along the xz and yz
/// planes.
bool mSideProjection;
FileName mMacroMap;
DECLARE_TEXTUREMAP(MacroMap);
F32 mMacroSize;
F32 mMacroStrength;
F32 mMacroDistance;
@ -82,9 +85,6 @@ protected:
///
F32 mParallaxScale;
bool mIsSRGB;
bool mInvertSmoothness;
public:
TerrainMaterial();
@ -124,7 +124,7 @@ public:
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())
{
mat->mRoughMapFilename[0] = cleanTextureName(rmName, cleanFile, path, false); // Roughness
mat->mSmoothnessChan[0] = 1.0f;
mat->mInvertSmoothness[0] = (floatVal == 1.0f);
mat->mRoughnessChan[0] = 1.0f;
mat->mInvertRoughness[0] = (floatVal == 1.0f);
mat->mMetalMapFilename[0] = cleanTextureName(rmName, cleanFile, path, false); // Metallic
mat->mMetalChan[0] = 2.0f;
}

View file

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

View file

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