mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-01 03:23:52 +00:00
all DECLARE_IMAGEASSET refactored
This commit is contained in:
parent
24b374f545
commit
fa8110ce8f
44 changed files with 248 additions and 306 deletions
|
|
@ -374,7 +374,7 @@ bool TerrainCellMaterial::_initShader(bool deferredMat,
|
|||
|
||||
// We only include materials that
|
||||
// have more than a base texture.
|
||||
if (!(mat->DetailMapValid() && mat->getDetailSize() > 0 && mat->getDetailDistance()>0))
|
||||
if (!(mat->getDetailMap() && mat->getDetailSize() > 0 && mat->getDetailDistance()>0))
|
||||
continue;
|
||||
|
||||
if (deferredMat)
|
||||
|
|
@ -382,12 +382,12 @@ bool TerrainCellMaterial::_initShader(bool deferredMat,
|
|||
features.addFeature(MFT_TerrainDetailMap, featureIndex);
|
||||
|
||||
// check for macro detail texture
|
||||
if (mat->MacroMapValid() && mat->getMacroSize() > 0 && mat->getMacroDistance() > 0)
|
||||
if (mat->getMacroMap() && mat->getMacroSize() > 0 && mat->getMacroDistance() > 0)
|
||||
{
|
||||
features.addFeature(MFT_TerrainMacroMap, featureIndex);
|
||||
}
|
||||
|
||||
if (mat->ORMConfigMapValid())
|
||||
if (mat->getORMConfigMap())
|
||||
{
|
||||
features.addFeature(MFT_TerrainORMMap, featureIndex);
|
||||
}
|
||||
|
|
@ -401,12 +401,12 @@ bool TerrainCellMaterial::_initShader(bool deferredMat,
|
|||
|
||||
|
||||
// Skip normal maps if we need to.
|
||||
if (!disableNormalMaps && mat->NormalMapValid())
|
||||
if (!disableNormalMaps && mat->getNormalMap())
|
||||
{
|
||||
normalMaps.increment();
|
||||
features.addFeature(MFT_TerrainNormalMap, featureIndex);
|
||||
|
||||
normalMaps.last() = mat->getNormalMapResource();
|
||||
normalMaps.last() = mat->getNormalMap();
|
||||
|
||||
GFXFormat normalFmt = normalMaps.last().getFormat();
|
||||
if (normalFmt == GFXFormatBC3)
|
||||
|
|
@ -632,7 +632,7 @@ bool TerrainCellMaterial::_initShader(bool deferredMat,
|
|||
|
||||
// We only include materials that
|
||||
// have more than a base texture.
|
||||
if (!(mat->DetailMapValid() && mat->getDetailSize() > 0 && mat->getDetailDistance() > 0))
|
||||
if (!(mat->getDetailMap() && mat->getDetailSize() > 0 && mat->getDetailDistance() > 0))
|
||||
continue;
|
||||
|
||||
mMaterialInfos[i]->mBlendDepthConst = mShader->getShaderConstHandle(avar("$blendDepth%d", i));
|
||||
|
|
@ -676,7 +676,7 @@ void TerrainCellMaterial::_updateMaterialConsts( )
|
|||
if (mat == NULL)
|
||||
continue;
|
||||
|
||||
if (!(mat->DetailMapValid() && mat->getDetailSize() > 0 && mat->getDetailDistance() > 0))
|
||||
if (!(mat->getDetailMap() && mat->getDetailSize() > 0 && mat->getDetailDistance() > 0))
|
||||
continue;
|
||||
|
||||
detailMatCount++;
|
||||
|
|
@ -704,7 +704,7 @@ void TerrainCellMaterial::_updateMaterialConsts( )
|
|||
if (mat == NULL)
|
||||
continue;
|
||||
|
||||
if (!(mat->DetailMapValid() && mat->getDetailSize() > 0 && mat->getDetailDistance() > 0))
|
||||
if (!(mat->getDetailMap() && mat->getDetailSize() > 0 && mat->getDetailDistance() > 0))
|
||||
continue;
|
||||
|
||||
F32 detailSize = matInfo->mat->getDetailSize();
|
||||
|
|
|
|||
|
|
@ -81,11 +81,6 @@ TerrainMaterial::TerrainMaterial()
|
|||
mIsSRGB(false),
|
||||
mInvertRoughness(false)
|
||||
{
|
||||
INIT_ASSET(DiffuseMap);
|
||||
INIT_ASSET(NormalMap);
|
||||
INIT_ASSET(DetailMap);
|
||||
INIT_ASSET(ORMConfigMap);
|
||||
INIT_ASSET(MacroMap);
|
||||
}
|
||||
|
||||
TerrainMaterial::~TerrainMaterial()
|
||||
|
|
@ -97,10 +92,10 @@ FRangeValidator hardnessValidator(0.0f, 0.999f);
|
|||
void TerrainMaterial::initPersistFields()
|
||||
{
|
||||
docsURL;
|
||||
INITPERSISTFIELD_IMAGEASSET(DiffuseMap, TerrainMaterial,"Base Albedo stretched over the whole map");
|
||||
INITPERSISTFIELD_IMAGEASSET_REFACTOR(DiffuseMap, TerrainMaterial,"Base Albedo stretched over the whole map");
|
||||
addField( "diffuseSize", TypeF32, Offset( mDiffuseSize, TerrainMaterial ), "Used to scale the diffuse map to the material square" );
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET(NormalMap, TerrainMaterial,"NormalMap");
|
||||
INITPERSISTFIELD_IMAGEASSET_REFACTOR(NormalMap, TerrainMaterial,"NormalMap");
|
||||
addField( "parallaxScale", TypeF32, Offset( mParallaxScale, TerrainMaterial ), "Used to scale the height from the normal map to give some self "
|
||||
"occlusion effect (aka parallax) to the terrain material" );
|
||||
|
||||
|
|
@ -113,7 +108,7 @@ void TerrainMaterial::initPersistFields()
|
|||
addFieldV("blendHeightHardness", TypeF32, Offset(mBlendHardness, TerrainMaterial), &hardnessValidator, "How sharply this layer blends with other textures."
|
||||
"0->1, soft->hard.");
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET(DetailMap, TerrainMaterial, "Raises and lowers the RGB result of the Base Albedo up close.");
|
||||
INITPERSISTFIELD_IMAGEASSET_REFACTOR(DetailMap, TerrainMaterial, "Raises and lowers the RGB result of the Base Albedo up close.");
|
||||
addField( "detailSize", TypeF32, Offset( mDetailSize, TerrainMaterial ), "Used to scale the detail map to the material square" );
|
||||
addField( "detailStrength", TypeF32, Offset( mDetailStrength, TerrainMaterial ), "Exponentially sharpens or lightens the detail map rendering on the material" );
|
||||
addField( "detailDistance", TypeF32, Offset( mDetailDistance, TerrainMaterial ), "Changes how far camera can see the detail map rendering on the material" );
|
||||
|
|
@ -121,12 +116,12 @@ void TerrainMaterial::initPersistFields()
|
|||
addField( "useSideProjection", TypeBool, Offset( mSideProjection, TerrainMaterial ),"Makes that terrain material project along the sides of steep "
|
||||
"slopes instead of projected downwards");
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET(ORMConfigMap, TerrainMaterial, "AO|Roughness|metalness map (uses DetailMap UV Coords)");
|
||||
INITPERSISTFIELD_IMAGEASSET_REFACTOR(ORMConfigMap, TerrainMaterial, "AO|Roughness|metalness map (uses DetailMap UV Coords)");
|
||||
addField("isSRGB", TypeBool, Offset(mIsSRGB, TerrainMaterial), "Is the PBR Config map's image in sRGB format?");
|
||||
addField("invertRoughness", TypeBool, Offset(mInvertRoughness, TerrainMaterial), "Should the roughness channel of the PBR Config map be inverted?");
|
||||
|
||||
//Macro maps additions
|
||||
INITPERSISTFIELD_IMAGEASSET(MacroMap, TerrainMaterial, "Raises and lowers the RGB result of the Base Albedo at a distance.");
|
||||
INITPERSISTFIELD_IMAGEASSET_REFACTOR(MacroMap, TerrainMaterial, "Raises and lowers the RGB result of the Base Albedo at a distance.");
|
||||
addField( "macroSize", TypeF32, Offset( mMacroSize, TerrainMaterial ), "Used to scale the Macro map to the material square" );
|
||||
addField( "macroStrength", TypeF32, Offset( mMacroStrength, TerrainMaterial ), "Exponentially sharpens or lightens the Macro map rendering on the material" );
|
||||
addField( "macroDistance", TypeF32, Offset( mMacroDistance, TerrainMaterial ), "Changes how far camera can see the Macro map rendering on the material" );
|
||||
|
|
@ -228,8 +223,8 @@ TerrainMaterial* TerrainMaterial::findOrCreate( const char *nameOrPath )
|
|||
//material.getDiffuseMap(); //returns the raw file referenced
|
||||
//material.getDiffuseMapAsset(); //returns the asset id
|
||||
//material.setDiffuseMap(%texture); //tries to set the asset and failing that attempts a flat file reference
|
||||
DEF_ASSET_BINDS(TerrainMaterial, DiffuseMap);
|
||||
DEF_ASSET_BINDS(TerrainMaterial, NormalMap);
|
||||
DEF_ASSET_BINDS(TerrainMaterial, DetailMap);
|
||||
DEF_ASSET_BINDS(TerrainMaterial, ORMConfigMap);
|
||||
DEF_ASSET_BINDS(TerrainMaterial, MacroMap);
|
||||
DEF_ASSET_BINDS_REFACTOR(TerrainMaterial, DiffuseMap)
|
||||
DEF_ASSET_BINDS_REFACTOR(TerrainMaterial, NormalMap)
|
||||
DEF_ASSET_BINDS_REFACTOR(TerrainMaterial, DetailMap)
|
||||
DEF_ASSET_BINDS_REFACTOR(TerrainMaterial, ORMConfigMap)
|
||||
DEF_ASSET_BINDS_REFACTOR(TerrainMaterial, MacroMap)
|
||||
|
|
|
|||
|
|
@ -38,24 +38,17 @@ class TerrainMaterial : public SimObject
|
|||
protected:
|
||||
|
||||
///
|
||||
//FileName mDiffuseMap;
|
||||
|
||||
//AssetPtr<ImageAsset> mDiffuseAsset;
|
||||
|
||||
DECLARE_IMAGEASSET(TerrainMaterial, DiffuseMap, onDiffuseMapChanged, GFXStaticTextureSRGBProfile);
|
||||
DECLARE_ASSET_SETGET(TerrainMaterial, DiffuseMap);
|
||||
DECLARE_IMAGEASSET_REFACTOR(TerrainMaterial, DiffuseMap, GFXStaticTextureSRGBProfile)
|
||||
|
||||
/// The size of the diffuse base map in meters
|
||||
/// used to generate its texture coordinates.
|
||||
F32 mDiffuseSize;
|
||||
|
||||
///
|
||||
DECLARE_IMAGEASSET(TerrainMaterial, NormalMap, onNormalMapChanged, GFXNormalMapProfile);
|
||||
DECLARE_ASSET_SETGET(TerrainMaterial, NormalMap);
|
||||
DECLARE_IMAGEASSET_REFACTOR(TerrainMaterial, NormalMap, GFXNormalMapProfile)
|
||||
|
||||
///
|
||||
DECLARE_IMAGEASSET(TerrainMaterial, DetailMap, onDetailMapChanged, GFXStaticTextureProfile);
|
||||
DECLARE_ASSET_SETGET(TerrainMaterial, DetailMap);
|
||||
DECLARE_IMAGEASSET_REFACTOR(TerrainMaterial, DetailMap, GFXStaticTextureProfile)
|
||||
|
||||
/// The size of the detail map in meters used
|
||||
/// to generate the texture coordinates for the
|
||||
|
|
@ -69,8 +62,7 @@ protected:
|
|||
F32 mDetailDistance;
|
||||
|
||||
///
|
||||
DECLARE_IMAGEASSET(TerrainMaterial, ORMConfigMap, onORMConfigMapChanged, GFXStaticTextureProfile);
|
||||
DECLARE_ASSET_SETGET(TerrainMaterial, ORMConfigMap);
|
||||
DECLARE_IMAGEASSET_REFACTOR(TerrainMaterial, ORMConfigMap, GFXStaticTextureProfile)
|
||||
|
||||
bool mIsSRGB;
|
||||
bool mInvertRoughness;
|
||||
|
|
@ -81,8 +73,8 @@ protected:
|
|||
/// planes.
|
||||
bool mSideProjection;
|
||||
|
||||
DECLARE_IMAGEASSET(TerrainMaterial, MacroMap, onMacroMapChanged, GFXStaticTextureProfile);
|
||||
DECLARE_ASSET_SETGET(TerrainMaterial, MacroMap);
|
||||
DECLARE_IMAGEASSET_REFACTOR(TerrainMaterial, MacroMap, GFXStaticTextureProfile)
|
||||
|
||||
F32 mMacroSize;
|
||||
F32 mMacroStrength;
|
||||
F32 mMacroDistance;
|
||||
|
|
@ -146,12 +138,6 @@ public:
|
|||
|
||||
bool getInvertRoughness() const { return mInvertRoughness; }
|
||||
|
||||
void onDiffuseMapChanged() {}
|
||||
void onNormalMapChanged() {}
|
||||
void onDetailMapChanged() {}
|
||||
void onORMConfigMapChanged() {}
|
||||
void onMacroMapChanged() {}
|
||||
|
||||
};
|
||||
|
||||
#endif // _TERRMATERIAL_H_
|
||||
|
|
|
|||
|
|
@ -96,19 +96,19 @@ void TerrainBlock::_updateMaterials()
|
|||
{
|
||||
TerrainMaterial *mat = mFile->mMaterials[i];
|
||||
|
||||
if (mat->getDiffuseMap() != StringTable->EmptyString())
|
||||
if (mat->getDiffuseMapAsset().notNull())
|
||||
{
|
||||
mBaseTextures[i] = mat->getDiffuseMapResource();
|
||||
mBaseTextures[i] = mat->getDiffuseMap();
|
||||
}
|
||||
else
|
||||
mBaseTextures[ i ] = GFXTexHandle();
|
||||
|
||||
// Find the maximum detail distance.
|
||||
if ( mat->getDetailMap() != StringTable->EmptyString() &&
|
||||
if ( mat->getDetailMapAsset().notNull() &&
|
||||
mat->getDetailDistance() > mMaxDetailDistance )
|
||||
mMaxDetailDistance = mat->getDetailDistance();
|
||||
|
||||
if ( mat->getMacroMap() != StringTable->EmptyString() &&
|
||||
if ( mat->getMacroMapAsset().notNull() &&
|
||||
mat->getMacroDistance() > mMaxDetailDistance )
|
||||
mMaxDetailDistance = mat->getMacroDistance();
|
||||
}
|
||||
|
|
@ -126,19 +126,19 @@ void TerrainBlock::_updateMaterials()
|
|||
{
|
||||
TerrainMaterial* mat = mFile->mMaterials[i];
|
||||
|
||||
if (mat->getDetailMap() != StringTable->EmptyString())
|
||||
detailTexArray[i] = mat->getDetailMapResource();
|
||||
if (mat->getMacroMap() != StringTable->EmptyString())
|
||||
macroTexArray[i] = mat->getMacroMapResource();
|
||||
if (mat->getNormalMap() != StringTable->EmptyString())
|
||||
normalTexArray[i] = mat->getNormalMapResource();
|
||||
if (mat->getDetailMapAsset().notNull())
|
||||
detailTexArray[i] = mat->getDetailMap();
|
||||
if (mat->getMacroMapAsset().notNull())
|
||||
macroTexArray[i] = mat->getMacroMap();
|
||||
if (mat->getNormalMapAsset().notNull())
|
||||
normalTexArray[i] = mat->getNormalMap();
|
||||
|
||||
//depending on creation method this may or may not have been shoved into srgb space eroneously
|
||||
GFXTextureProfile* profile = &GFXStaticTextureProfile;
|
||||
if (mat->getIsSRGB())
|
||||
profile = &GFXStaticTextureSRGBProfile;
|
||||
if (mat->getORMConfigMap() != StringTable->EmptyString())
|
||||
ormTexArray[i] = TEXMGR->createTexture(mat->getORMConfigMap(), profile);
|
||||
if (mat->getORMConfigMapAsset().notNull())
|
||||
ormTexArray[i] = mat->getORMConfigMapAsset()->getTexture(profile);
|
||||
}
|
||||
|
||||
if (mDetailTextureArray.isNull())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue