mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-08 21:24:34 +00:00
Updates ImageAsset usage to utilize AssetRef, and standardizes the setter/getter functions and naming conventions, as well as the ability to use and bind named targets.
This commit is contained in:
parent
a858d8624e
commit
34e3f78a22
82 changed files with 1451 additions and 951 deletions
|
|
@ -556,8 +556,15 @@ void PostEffect::initPersistFields()
|
|||
addField( "targetViewport", TYPEID< PFXTargetViewport >(), Offset( mTargetViewport, PostEffect ),
|
||||
"Specifies how the viewport should be set up for a target texture." );
|
||||
|
||||
addProtectedField("Texture", TypeImageFilename, Offset(mTextureAsset, PostEffect), _setTextureData, &defaultProtectedGetFn, NumTextures, "Input textures to this effect(samplers).\n", AbstractClassRep::FIELD_HideInInspectors);
|
||||
INITPERSISTFIELD_IMAGEASSET_ARRAY(Texture, NumTextures, PostEffect, "Input textures to this effect ( samplers ).\n"
|
||||
ADD_FIELD("texture", TypeImageAssetRef, Offset(mTextureAssetRef, PostEffect))
|
||||
.elements(NumTextures)
|
||||
.withFlags(AbstractClassRep::FIELD_HideInInspectors | AbstractClassRep::FIELD_DontWriteToFile)
|
||||
.doc("Input textures to this effect ( samplers ).\n"
|
||||
"@see PFXTextureIdentifiers");
|
||||
|
||||
ADD_FIELD("textureAsset", TypeImageAssetRef, Offset(mTextureAssetRef, PostEffect))
|
||||
.elements(NumTextures)
|
||||
.doc("Input textures to this effect ( samplers ).\n"
|
||||
"@see PFXTextureIdentifiers");
|
||||
|
||||
addField("textureSRGB", TypeBool, Offset(mTexSRGB, PostEffect), NumTextures,
|
||||
|
|
@ -609,18 +616,16 @@ bool PostEffect::onAdd()
|
|||
for (S32 i = 0; i < NumTextures; i++)
|
||||
{
|
||||
mTextureType[i] = NormalTextureType;
|
||||
if (mTextureAsset[i].notNull()) {
|
||||
String texFilename = mTextureAsset[i]->getImageFile();
|
||||
|
||||
// Skip empty stages or ones with variable or target names.
|
||||
if (texFilename.isEmpty() ||
|
||||
texFilename[0] == '$' ||
|
||||
texFilename[0] == '#')
|
||||
continue;
|
||||
StringTableEntry texAssetId = mTextureAssetRef[i].assetId;
|
||||
|
||||
mTextureProfile[i] = (mTexSRGB[i]) ? &PostFxTextureSRGBProfile : &PostFxTextureProfile;
|
||||
_setTexture(texFilename, i);
|
||||
}
|
||||
// Skip empty stages or ones with variable or target names.
|
||||
if (dStrIsEmpty(texAssetId) ||
|
||||
texAssetId[0] == '$' ||
|
||||
texAssetId[0] == '#')
|
||||
continue;
|
||||
|
||||
mTextureProfile[i] = (mTexSRGB[i]) ? &PostFxTextureSRGBProfile : &PostFxTextureProfile;
|
||||
}
|
||||
|
||||
// Is the target a named target?
|
||||
|
|
@ -1149,7 +1154,7 @@ void PostEffect::_setupConstants( const SceneRenderState *state )
|
|||
|
||||
void PostEffect::_setupTexture( U32 stage, GFXTexHandle &inputTex, const RectI *inTexViewport )
|
||||
{
|
||||
const String &texFilename = mTextureAsset[stage].notNull() ? mTextureAsset[stage]->getImageFile() : "";
|
||||
const String texFilename = mTextureAssetRef[stage].assetId;
|
||||
|
||||
GFXTexHandle theTex;
|
||||
NamedTexTarget *namedTarget = NULL;
|
||||
|
|
@ -1188,8 +1193,8 @@ void PostEffect::_setupTexture( U32 stage, GFXTexHandle &inputTex, const RectI *
|
|||
{
|
||||
theTex = mTexture[stage];
|
||||
|
||||
if (!theTex && mTextureAsset[stage].notNull())
|
||||
theTex = mTextureAsset[stage]->getTexture(mTextureProfile[stage]);
|
||||
if (!theTex)
|
||||
theTex = getTexture(stage, mTextureProfile[stage]);
|
||||
|
||||
if ( theTex )
|
||||
viewport.set( 0, 0, theTex->getWidth(), theTex->getHeight() );
|
||||
|
|
@ -1670,8 +1675,8 @@ void PostEffect::setTexture( U32 index, const String &texFilePath )
|
|||
return;
|
||||
|
||||
mTextureProfile[index] = (mTexSRGB[index])? &PostFxTextureSRGBProfile : &PostFxTextureProfile;
|
||||
_setTexture(texFilePath, index);
|
||||
mTexture[index] = mTextureAsset[index]->getTexture(mTextureProfile[index]);
|
||||
mTextureAssetRef[index] = texFilePath.c_str();
|
||||
mTexture[index] = getTexture(index, mTextureProfile[index]);
|
||||
mTextureType[index] = NormalTextureType;
|
||||
}
|
||||
|
||||
|
|
@ -1866,21 +1871,18 @@ void PostEffect::_checkRequirements()
|
|||
{
|
||||
if (mTextureType[i] == NormalTextureType)
|
||||
{
|
||||
if (mTextureAsset[i].notNull())
|
||||
StringTableEntry texAssetId = mTextureAssetRef[i].assetId;
|
||||
|
||||
if (!dStrIsEmpty(texAssetId) && texAssetId[0] == '#')
|
||||
{
|
||||
const String& texFilename = mTextureAsset[i]->getImageFile();
|
||||
|
||||
if (texFilename.isNotEmpty() && texFilename[0] == '#')
|
||||
NamedTexTarget* namedTarget = NamedTexTarget::find(texAssetId + 1);
|
||||
if (!namedTarget)
|
||||
{
|
||||
NamedTexTarget* namedTarget = NamedTexTarget::find(texFilename.c_str() + 1);
|
||||
if (!namedTarget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Grab the macros for shader initialization.
|
||||
namedTarget->getShaderMacros(¯os);
|
||||
return;
|
||||
}
|
||||
|
||||
// Grab the macros for shader initialization.
|
||||
namedTarget->getShaderMacros(¯os);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue