|
@@ -508,10 +508,6 @@ PostEffect::PostEffect()
|
|
dMemset( mTexSizeSC, 0, sizeof( GFXShaderConstHandle* ) * NumTextures );
|
|
dMemset( mTexSizeSC, 0, sizeof( GFXShaderConstHandle* ) * NumTextures );
|
|
dMemset( mRenderTargetParamsSC, 0, sizeof( GFXShaderConstHandle* ) * NumTextures );
|
|
dMemset( mRenderTargetParamsSC, 0, sizeof( GFXShaderConstHandle* ) * NumTextures );
|
|
|
|
|
|
- for (U32 i = 0; i < NumTextures; i++)
|
|
|
|
- {
|
|
|
|
- INIT_IMAGEASSET_ARRAY(Texture, PostFxTextureProfile, i);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
PostEffect::~PostEffect()
|
|
PostEffect::~PostEffect()
|
|
@@ -556,7 +552,8 @@ void PostEffect::initPersistFields()
|
|
addField( "targetViewport", TYPEID< PFXTargetViewport >(), Offset( mTargetViewport, PostEffect ),
|
|
addField( "targetViewport", TYPEID< PFXTargetViewport >(), Offset( mTargetViewport, PostEffect ),
|
|
"Specifies how the viewport should be set up for a target texture." );
|
|
"Specifies how the viewport should be set up for a target texture." );
|
|
|
|
|
|
- INITPERSISTFIELD_IMAGEASSET_ARRAY(Texture, NumTextures, PostEffect, "Input textures to this effect ( samplers ).\n"
|
|
|
|
|
|
+ addProtectedField("Texture", TypeImageFilename, Offset(mTextureAsset, PostEffect), _setTextureData, &defaultProtectedGetFn, NumTextures, "Input textures to this effect(samplers).\n", AbstractClassRep::FIELD_HideInInspectors);
|
|
|
|
+ INITPERSISTFIELD_IMAGEASSET_ARRAY_REFACTOR(Texture, NumTextures, PostEffect, "Input textures to this effect ( samplers ).\n"
|
|
"@see PFXTextureIdentifiers");
|
|
"@see PFXTextureIdentifiers");
|
|
|
|
|
|
addField("textureSRGB", TypeBool, Offset(mTexSRGB, PostEffect), NumTextures,
|
|
addField("textureSRGB", TypeBool, Offset(mTexSRGB, PostEffect), NumTextures,
|
|
@@ -608,22 +605,24 @@ bool PostEffect::onAdd()
|
|
for (S32 i = 0; i < NumTextures; i++)
|
|
for (S32 i = 0; i < NumTextures; i++)
|
|
{
|
|
{
|
|
mTextureType[i] = NormalTextureType;
|
|
mTextureType[i] = NormalTextureType;
|
|
- String texFilename = getTexture(i);
|
|
|
|
|
|
+ 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;
|
|
|
|
|
|
+ // Skip empty stages or ones with variable or target names.
|
|
|
|
+ if (texFilename.isEmpty() ||
|
|
|
|
+ texFilename[0] == '$' ||
|
|
|
|
+ texFilename[0] == '#')
|
|
|
|
+ continue;
|
|
|
|
|
|
- mTextureProfile[i] = (mTexSRGB[i]) ? &PostFxTextureSRGBProfile : &PostFxTextureProfile;
|
|
|
|
- _setTexture(texFilename, i);
|
|
|
|
|
|
+ mTextureProfile[i] = (mTexSRGB[i]) ? &PostFxTextureSRGBProfile : &PostFxTextureProfile;
|
|
|
|
+ _setTexture(texFilename, i);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// Is the target a named target?
|
|
// Is the target a named target?
|
|
if ( mTargetName.isNotEmpty() && mTargetName[0] == '#' )
|
|
if ( mTargetName.isNotEmpty() && mTargetName[0] == '#' )
|
|
{
|
|
{
|
|
- mNamedTarget.registerWithName( mTargetName.substr( 1 ) );
|
|
|
|
|
|
+ mNamedTarget.registerWithName(mTargetName.substr(1));
|
|
mNamedTarget.getTextureDelegate().bind( this, &PostEffect::_getTargetTexture );
|
|
mNamedTarget.getTextureDelegate().bind( this, &PostEffect::_getTargetTexture );
|
|
}
|
|
}
|
|
if ( mTargetDepthStencilName.isNotEmpty() && mTargetDepthStencilName[0] == '#' )
|
|
if ( mTargetDepthStencilName.isNotEmpty() && mTargetDepthStencilName[0] == '#' )
|
|
@@ -1136,7 +1135,7 @@ void PostEffect::_setupConstants( const SceneRenderState *state )
|
|
|
|
|
|
void PostEffect::_setupTexture( U32 stage, GFXTexHandle &inputTex, const RectI *inTexViewport )
|
|
void PostEffect::_setupTexture( U32 stage, GFXTexHandle &inputTex, const RectI *inTexViewport )
|
|
{
|
|
{
|
|
- const String &texFilename = getTexture( stage );
|
|
|
|
|
|
+ const String &texFilename = mTextureAsset[stage].notNull() ? mTextureAsset[stage]->getImageFile() : "";
|
|
|
|
|
|
GFXTexHandle theTex;
|
|
GFXTexHandle theTex;
|
|
NamedTexTarget *namedTarget = NULL;
|
|
NamedTexTarget *namedTarget = NULL;
|
|
@@ -1173,7 +1172,11 @@ void PostEffect::_setupTexture( U32 stage, GFXTexHandle &inputTex, const RectI *
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- theTex = mTexture[ stage ];
|
|
|
|
|
|
+ theTex = mTexture[stage];
|
|
|
|
+
|
|
|
|
+ if (!theTex && mTextureAsset[stage].notNull())
|
|
|
|
+ theTex = mTextureAsset[stage]->getTexture(mTextureProfile[stage]);
|
|
|
|
+
|
|
if ( theTex )
|
|
if ( theTex )
|
|
viewport.set( 0, 0, theTex->getWidth(), theTex->getHeight() );
|
|
viewport.set( 0, 0, theTex->getWidth(), theTex->getHeight() );
|
|
}
|
|
}
|
|
@@ -1640,7 +1643,6 @@ void PostEffect::reload()
|
|
void PostEffect::setTexture( U32 index, const String &texFilePath )
|
|
void PostEffect::setTexture( U32 index, const String &texFilePath )
|
|
{
|
|
{
|
|
// Set the new texture name.
|
|
// Set the new texture name.
|
|
- mTextureName[index] = texFilePath;
|
|
|
|
mTexture[index].free();
|
|
mTexture[index].free();
|
|
|
|
|
|
// Skip empty stages or ones with variable or target names.
|
|
// Skip empty stages or ones with variable or target names.
|
|
@@ -1651,14 +1653,13 @@ void PostEffect::setTexture( U32 index, const String &texFilePath )
|
|
|
|
|
|
mTextureProfile[index] = (mTexSRGB[index])? &PostFxTextureSRGBProfile : &PostFxTextureProfile;
|
|
mTextureProfile[index] = (mTexSRGB[index])? &PostFxTextureSRGBProfile : &PostFxTextureProfile;
|
|
_setTexture(texFilePath, index);
|
|
_setTexture(texFilePath, index);
|
|
-
|
|
|
|
|
|
+ mTexture[index] = mTextureAsset[index]->getTexture(mTextureProfile[index]);
|
|
mTextureType[index] = NormalTextureType;
|
|
mTextureType[index] = NormalTextureType;
|
|
}
|
|
}
|
|
|
|
|
|
void PostEffect::setTexture(U32 index, const GFXTexHandle& texHandle)
|
|
void PostEffect::setTexture(U32 index, const GFXTexHandle& texHandle)
|
|
{
|
|
{
|
|
// Set the new texture name.
|
|
// Set the new texture name.
|
|
- mTextureName[index] = StringTable->EmptyString();
|
|
|
|
mTexture[index].free();
|
|
mTexture[index].free();
|
|
|
|
|
|
// Skip empty stages or ones with variable or target names.
|
|
// Skip empty stages or ones with variable or target names.
|
|
@@ -1847,18 +1848,21 @@ void PostEffect::_checkRequirements()
|
|
{
|
|
{
|
|
if (mTextureType[i] == NormalTextureType)
|
|
if (mTextureType[i] == NormalTextureType)
|
|
{
|
|
{
|
|
- const String &texFilename = mTextureName[i];
|
|
|
|
-
|
|
|
|
- if (texFilename.isNotEmpty() && texFilename[0] == '#')
|
|
|
|
|
|
+ if (mTextureAsset[i].notNull())
|
|
{
|
|
{
|
|
- NamedTexTarget *namedTarget = NamedTexTarget::find(texFilename.c_str() + 1);
|
|
|
|
- if (!namedTarget)
|
|
|
|
|
|
+ const String& texFilename = mTextureAsset[i]->getImageFile();
|
|
|
|
+
|
|
|
|
+ if (texFilename.isNotEmpty() && texFilename[0] == '#')
|
|
{
|
|
{
|
|
- return;
|
|
|
|
|
|
+ NamedTexTarget* namedTarget = NamedTexTarget::find(texFilename.c_str() + 1);
|
|
|
|
+ if (!namedTarget)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Grab the macros for shader initialization.
|
|
|
|
+ namedTarget->getShaderMacros(¯os);
|
|
}
|
|
}
|
|
-
|
|
|
|
- // Grab the macros for shader initialization.
|
|
|
|
- namedTarget->getShaderMacros(¯os);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|