mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24:41 +00:00
review notes from Az
Should render fallback for namedTarget if namedTarget fails Add safety around namedtarget getTexture to stop assert Missing assets should revert to fallback image and print a warning to console Remove REFACTOR tag from all macros.
This commit is contained in:
parent
b707b2e2b7
commit
73ad92b757
60 changed files with 189 additions and 164 deletions
|
|
@ -242,28 +242,28 @@ void Material::initPersistFields()
|
|||
addArray("Stages", MAX_STAGES);
|
||||
|
||||
addGroup("Basic Texture Maps");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(DiffuseMap, MAX_STAGES, Material, "Albedo");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(DiffuseMap, MAX_STAGES, Material, "Albedo");
|
||||
addField("diffuseColor", TypeColorF, Offset(mDiffuse, Material), MAX_STAGES,
|
||||
"This color is multiplied against the diffuse texture color. If no diffuse texture "
|
||||
"is present this is the material color.");
|
||||
addField("diffuseMapSRGB", TypeBool, Offset(mDiffuseMapSRGB, Material), MAX_STAGES,
|
||||
"Enable sRGB for the diffuse color texture map.");
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(NormalMap, MAX_STAGES, Material, "NormalMap");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(NormalMap, MAX_STAGES, Material, "NormalMap");
|
||||
endGroup("Basic Texture Maps");
|
||||
|
||||
addGroup("Light Influence Maps");
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(ORMConfigMap, MAX_STAGES, Material, "AO|Roughness|metalness map");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(ORMConfigMap, MAX_STAGES, Material, "AO|Roughness|metalness map");
|
||||
addField("isSRGb", TypeBool, Offset(mIsSRGb, Material), MAX_STAGES,
|
||||
"Substance Designer Workaround.");
|
||||
addField("invertRoughness", TypeBool, Offset(mInvertRoughness, Material), MAX_STAGES,
|
||||
"Treat Roughness as Roughness");
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(AOMap, MAX_STAGES, Material, "AOMap");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(RoughMap, MAX_STAGES, Material, "RoughMap (also needs MetalMap)");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(MetalMap, MAX_STAGES, Material, "MetalMap (also needs RoughMap)");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(GlowMap, MAX_STAGES, Material, "GlowMap (needs Albedo)");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(AOMap, MAX_STAGES, Material, "AOMap");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(RoughMap, MAX_STAGES, Material, "RoughMap (also needs MetalMap)");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(MetalMap, MAX_STAGES, Material, "MetalMap (also needs RoughMap)");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(GlowMap, MAX_STAGES, Material, "GlowMap (needs Albedo)");
|
||||
|
||||
addFieldV("AOChan", TypeRangedS32, Offset(mAOChan, Material), &bmpChanRange, MAX_STAGES,
|
||||
"The input channel AO maps use.");
|
||||
|
|
@ -281,18 +281,18 @@ void Material::initPersistFields()
|
|||
endGroup("Light Influence Maps");
|
||||
|
||||
addGroup("Advanced Texture Maps");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(DetailMap, MAX_STAGES, Material, "DetailMap");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(DetailMap, MAX_STAGES, Material, "DetailMap");
|
||||
addField("detailScale", TypePoint2F, Offset(mDetailScale, Material), MAX_STAGES,
|
||||
"The scale factor for the detail map.");
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(DetailNormalMap, MAX_STAGES, Material, "DetailNormalMap");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(DetailNormalMap, MAX_STAGES, Material, "DetailNormalMap");
|
||||
addFieldV("detailNormalMapStrength", TypeRangedF32, Offset(mDetailNormalMapStrength, Material), &CommonValidators::PositiveFloat, MAX_STAGES,
|
||||
|
||||
"Used to scale the strength of the detail normal map when blended with the base normal map.");
|
||||
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(OverlayMap, MAX_STAGES, Material, "Overlay");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(LightMap, MAX_STAGES, Material, "LightMap");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(ToneMap, MAX_STAGES, Material, "ToneMap");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(OverlayMap, MAX_STAGES, Material, "Overlay");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(LightMap, MAX_STAGES, Material, "LightMap");
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(ToneMap, MAX_STAGES, Material, "ToneMap");
|
||||
endGroup("Advanced Texture Maps");
|
||||
|
||||
addGroup("Accumulation Properties");
|
||||
|
|
@ -807,15 +807,15 @@ bool Material::_setAccuEnabled(void* object, const char* index, const char* data
|
|||
//material.getDiffuseMap(%layer); //returns the raw file referenced
|
||||
//material.getDiffuseMapAsset(%layer); //returns the asset id
|
||||
//material.setDiffuseMap(%texture, %layer); //tries to set the asset and failing that attempts a flat file reference
|
||||
DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, DiffuseMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, NormalMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, DetailNormalMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, OverlayMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, LightMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, ToneMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, DetailMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, ORMConfigMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, RoughMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, AOMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, MetalMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS_REFACTOR(Material, GlowMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, DiffuseMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, NormalMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, DetailNormalMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, OverlayMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, LightMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, ToneMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, DetailMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, ORMConfigMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, RoughMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, AOMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, MetalMap, Material::Constants::MAX_STAGES)
|
||||
DEF_IMAGEASSET_ARRAY_BINDS(Material, GlowMap, Material::Constants::MAX_STAGES)
|
||||
|
|
|
|||
|
|
@ -208,18 +208,18 @@ public:
|
|||
//-----------------------------------------------------------------------
|
||||
// Data
|
||||
//-----------------------------------------------------------------------
|
||||
DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, DiffuseMap, GFXStaticTextureSRGBProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, NormalMap, GFXNormalMapProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, DetailNormalMap, GFXNormalMapProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, OverlayMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, LightMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, ToneMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, DetailMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, ORMConfigMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, AOMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, RoughMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, MetalMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY_REFACTOR(Material, GlowMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY(Material, DiffuseMap, GFXStaticTextureSRGBProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY(Material, NormalMap, GFXNormalMapProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY(Material, DetailNormalMap, GFXNormalMapProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY(Material, OverlayMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY(Material, LightMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY(Material, ToneMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY(Material, DetailMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY(Material, ORMConfigMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY(Material, AOMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY(Material, RoughMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY(Material, MetalMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
DECLARE_IMAGEASSET_ARRAY(Material, GlowMap, GFXStaticTextureProfile, MAX_STAGES)
|
||||
|
||||
bool mDiffuseMapSRGB[MAX_STAGES]; // SRGB diffuse
|
||||
bool mIsSRGb[MAX_STAGES]; // SRGB ORM
|
||||
|
|
|
|||
|
|
@ -875,13 +875,14 @@ void ProcessedShaderMaterial::setTextureStages( SceneRenderState *state, const S
|
|||
case Material::TexTarget:
|
||||
{
|
||||
texTarget = rpd->mTexSlot[i].texTarget;
|
||||
texObject = mMaterial->getDiffuseMapAsset(0)->getTexture(&GFXStaticTextureSRGBProfile);
|
||||
if ( !texTarget )
|
||||
{
|
||||
// try again.
|
||||
texTarget = mMaterial->getDiffuseMapAsset(0)->getNamedTarget();
|
||||
if (!texTarget)
|
||||
{
|
||||
GFX->setTexture(i, NULL);
|
||||
GFX->setTexture(i, texObject);
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
|
@ -889,8 +890,6 @@ void ProcessedShaderMaterial::setTextureStages( SceneRenderState *state, const S
|
|||
rpd->mTexSlot[i].texTarget = texTarget;
|
||||
}
|
||||
}
|
||||
|
||||
texObject = texTarget->getTexture();
|
||||
|
||||
// If no texture is available then map the default 2x2
|
||||
// black texture to it. This at least will ensure that
|
||||
|
|
@ -1281,35 +1280,35 @@ void ProcessedShaderMaterial::setNodeTransforms(const MatrixF *transforms, const
|
|||
|
||||
void ProcessedShaderMaterial::setCustomShaderData(Vector<CustomShaderBindingData> &shaderData, const U32 pass)
|
||||
{
|
||||
PROFILE_SCOPE(ProcessedShaderMaterial_setCustomShaderData);
|
||||
PROFILE_SCOPE(ProcessedShaderMaterial_setCustomShaderData);
|
||||
|
||||
GFXShaderConstBuffer* shaderConsts = _getShaderConstBuffer(pass);
|
||||
ShaderConstHandles* handles = _getShaderConstHandles(pass);
|
||||
GFXShaderConstBuffer* shaderConsts = _getShaderConstBuffer(pass);
|
||||
ShaderConstHandles* handles = _getShaderConstHandles(pass);
|
||||
|
||||
for (U32 i = 0; i < shaderData.size(); i++)
|
||||
{
|
||||
//roll through and try setting our data!
|
||||
for (U32 h = 0; h < handles->mCustomHandles.size(); ++h)
|
||||
{
|
||||
if (handles->mCustomHandles[h].handleName == shaderData[i].getHandleName())
|
||||
{
|
||||
if (handles->mCustomHandles[h].handle->isValid())
|
||||
{
|
||||
CustomShaderBindingData::UniformType type = shaderData[i].getType();
|
||||
for (U32 i = 0; i < shaderData.size(); i++)
|
||||
{
|
||||
//roll through and try setting our data!
|
||||
for (U32 h = 0; h < handles->mCustomHandles.size(); ++h)
|
||||
{
|
||||
if (handles->mCustomHandles[h].handleName == shaderData[i].getHandleName())
|
||||
{
|
||||
if (handles->mCustomHandles[h].handle->isValid())
|
||||
{
|
||||
CustomShaderBindingData::UniformType type = shaderData[i].getType();
|
||||
|
||||
if (type == CustomShaderBindingData::Float)
|
||||
shaderConsts->setSafe(handles->mCustomHandles[h].handle, shaderData[i].getFloat());
|
||||
else if (type == CustomShaderBindingData::Float2)
|
||||
shaderConsts->setSafe(handles->mCustomHandles[h].handle, shaderData[i].getFloat2());
|
||||
else if (type == CustomShaderBindingData::Float3)
|
||||
shaderConsts->setSafe(handles->mCustomHandles[h].handle, shaderData[i].getFloat3());
|
||||
else if (type == CustomShaderBindingData::Float4)
|
||||
shaderConsts->setSafe(handles->mCustomHandles[h].handle, shaderData[i].getFloat4());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type == CustomShaderBindingData::Float)
|
||||
shaderConsts->setSafe(handles->mCustomHandles[h].handle, shaderData[i].getFloat());
|
||||
else if (type == CustomShaderBindingData::Float2)
|
||||
shaderConsts->setSafe(handles->mCustomHandles[h].handle, shaderData[i].getFloat2());
|
||||
else if (type == CustomShaderBindingData::Float3)
|
||||
shaderConsts->setSafe(handles->mCustomHandles[h].handle, shaderData[i].getFloat3());
|
||||
else if (type == CustomShaderBindingData::Float4)
|
||||
shaderConsts->setSafe(handles->mCustomHandles[h].handle, shaderData[i].getFloat4());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessedShaderMaterial::setSceneInfo(SceneRenderState * state, const SceneData& sgData, U32 pass)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue