mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
mipwork, laregly courtesy of @mmarauder2k9-torque
This commit is contained in:
parent
81504fb089
commit
cacd8a6064
8 changed files with 128 additions and 128 deletions
|
|
@ -151,7 +151,13 @@ void GFXD3D11TextureTarget::attachTexture( RenderSlot slot, GFXTextureObject *te
|
|||
mTargetSize.set( tex->getSize().x, tex->getSize().y );
|
||||
mTargetFormat = tex->getFormat();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mGenMips)
|
||||
{
|
||||
mTargetSRViews[slot] = d3dto->getSRView();
|
||||
mTargetSRViews[slot]->AddRef();
|
||||
}
|
||||
}
|
||||
|
||||
// Update surface size
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ void GFXD3D11TextureManager::_innerCreateTexture( GFXD3D11TextureObject *retTex,
|
|||
}
|
||||
|
||||
if( !forceMips && !retTex->mProfile->isSystemMemory() &&
|
||||
numMipLevels == 0 &&
|
||||
(numMipLevels == 0 || numMipLevels > 1)&&
|
||||
!(depth > 0) )
|
||||
{
|
||||
miscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS;
|
||||
|
|
|
|||
|
|
@ -1414,13 +1414,13 @@ void GFXTextureManager::_validateTexParams( const U32 width, const U32 height,
|
|||
{
|
||||
inOutNumMips = 1;
|
||||
}
|
||||
else if( !isPow2( width ) || !isPow2( height ) )
|
||||
else if (!isPow2(width) || !isPow2(height))
|
||||
{
|
||||
// If a texture is not power-of-2 in size for both dimensions, it must
|
||||
// have only 1 mip level.
|
||||
inOutNumMips = 1;
|
||||
inOutNumMips = mFloor(mLog2(mMax(width, height))) + 1;
|
||||
}
|
||||
|
||||
|
||||
// Check format, and compatibility with texture profile requirements
|
||||
bool autoGenSupp = ( inOutNumMips == 0 );
|
||||
|
||||
|
|
|
|||
|
|
@ -142,25 +142,23 @@ IMPLEMENT_CONOBJECT(PostEffect);
|
|||
|
||||
GFX_ImplementTextureProfile( PostFxTextureProfile,
|
||||
GFXTextureProfile::DiffuseMap,
|
||||
GFXTextureProfile::Static | GFXTextureProfile::PreserveSize | GFXTextureProfile::NoMipmap,
|
||||
GFXTextureProfile::Static | GFXTextureProfile::PreserveSize,
|
||||
GFXTextureProfile::NONE );
|
||||
|
||||
GFX_ImplementTextureProfile( PostFxTextureSRGBProfile,
|
||||
GFXTextureProfile::DiffuseMap,
|
||||
GFXTextureProfile::Static | GFXTextureProfile::PreserveSize | GFXTextureProfile::NoMipmap | GFXTextureProfile::SRGB,
|
||||
GFXTextureProfile::Static | GFXTextureProfile::PreserveSize | GFXTextureProfile::SRGB,
|
||||
GFXTextureProfile::NONE);
|
||||
|
||||
GFX_ImplementTextureProfile( VRTextureProfile,
|
||||
GFXTextureProfile::DiffuseMap,
|
||||
GFXTextureProfile::PreserveSize |
|
||||
GFXTextureProfile::RenderTarget |
|
||||
GFXTextureProfile::NoMipmap,
|
||||
GFXTextureProfile::RenderTarget,
|
||||
GFXTextureProfile::NONE );
|
||||
|
||||
GFX_ImplementTextureProfile( VRDepthProfile,
|
||||
GFXTextureProfile::DiffuseMap,
|
||||
GFXTextureProfile::PreserveSize |
|
||||
GFXTextureProfile::NoMipmap |
|
||||
GFXTextureProfile::ZTarget,
|
||||
GFXTextureProfile::NONE );
|
||||
|
||||
|
|
@ -501,7 +499,8 @@ PostEffect::PostEffect()
|
|||
mInvCameraTransSC(NULL),
|
||||
mMatCameraToScreenSC(NULL),
|
||||
mMatScreenToCameraSC(NULL),
|
||||
mIsCapturingSC(NULL)
|
||||
mIsCapturingSC(NULL),
|
||||
mMipCap(1)
|
||||
{
|
||||
dMemset( mTexSRGB, 0, sizeof(bool) * NumTextures);
|
||||
dMemset( mActiveTextures, 0, sizeof( GFXTextureObject* ) * NumTextures );
|
||||
|
|
@ -509,7 +508,7 @@ PostEffect::PostEffect()
|
|||
dMemset( mActiveTextureViewport, 0, sizeof( RectI ) * NumTextures );
|
||||
dMemset( mTexSizeSC, 0, sizeof( GFXShaderConstHandle* ) * NumTextures );
|
||||
dMemset( mRenderTargetParamsSC, 0, sizeof( GFXShaderConstHandle* ) * NumTextures );
|
||||
|
||||
dMemset(mMipCountSC, 0, sizeof(GFXShaderConstHandle*) * NumTextures);
|
||||
}
|
||||
|
||||
PostEffect::~PostEffect()
|
||||
|
|
@ -538,6 +537,9 @@ void PostEffect::initPersistFields()
|
|||
|
||||
addField( "targetScale", TypePoint2F, Offset( mTargetScale, PostEffect ),
|
||||
"If targetSize is zero this is used to set a relative size from the current target." );
|
||||
|
||||
addField("mipCap", TypePoint2F, Offset(mMipCap, PostEffect),
|
||||
"generate up to this many mips. 0 = all, 1 = none, >1 = as specified max."); //todo: de-stupid
|
||||
|
||||
addField( "targetSize", TypePoint2I, Offset( mTargetSize, PostEffect ),
|
||||
"If non-zero this is used as the absolute target size." );
|
||||
|
|
@ -760,6 +762,7 @@ void PostEffect::_setupConstants( const SceneRenderState *state )
|
|||
{
|
||||
mTexSizeSC[i] = mShader->getShaderConstHandle(String::ToString("$texSize%d", i));
|
||||
mRenderTargetParamsSC[i] = mShader->getShaderConstHandle(String::ToString("$rtParams%d",i));
|
||||
mMipCountSC[i] = mShader->getShaderConstHandle(String::ToString("$mipCount%d", i));
|
||||
}
|
||||
|
||||
mTargetViewportSC = mShader->getShaderConstHandle( "$targetViewport" );
|
||||
|
|
@ -843,6 +846,11 @@ void PostEffect::_setupConstants( const SceneRenderState *state )
|
|||
texSizeConst.y = (F32)mActiveTextures[i]->getHeight();
|
||||
mShaderConsts->set( mTexSizeSC[i], texSizeConst );
|
||||
}
|
||||
|
||||
if (mMipCountSC[i]->isValid())
|
||||
{
|
||||
mShaderConsts->set(mMipCountSC[i], (S32)mActiveTextures[i]->getMipLevels());
|
||||
}
|
||||
}
|
||||
|
||||
for ( U32 i = 0; i < NumTextures; i++ )
|
||||
|
|
@ -1265,7 +1273,7 @@ void PostEffect::_setupTarget( const SceneRenderState *state, bool *outClearTarg
|
|||
mTargetTex.getWidthHeight() != targetSize )
|
||||
{
|
||||
mTargetTex.set( targetSize.x, targetSize.y, mTargetFormat,
|
||||
&PostFxTargetProfile, "PostEffect::_setupTarget" );
|
||||
&PostFxTargetProfile, "PostEffect::_setupTarget", mMipCap);
|
||||
|
||||
if ( mTargetClear == PFXTargetClear_OnCreate )
|
||||
*outClearTarget = true;
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ protected:
|
|||
|
||||
GFXShaderConstHandle *mTexSizeSC[NumTextures];
|
||||
GFXShaderConstHandle *mRenderTargetParamsSC[NumTextures];
|
||||
GFXShaderConstHandle* mMipCountSC[NumTextures];
|
||||
|
||||
GFXShaderConstHandle *mViewportOffsetSC;
|
||||
|
||||
|
|
@ -176,6 +177,7 @@ protected:
|
|||
|
||||
String mTargetName;
|
||||
GFXTexHandle mTargetTex;
|
||||
S32 mMipCap;
|
||||
|
||||
String mTargetDepthStencilName;
|
||||
GFXTexHandle mTargetDepthStencil;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue