Skip to content

Main: TUS - split camera based from controller based effects #3295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions OgreMain/include/OgreTextureUnitState.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,14 @@ namespace Ogre {
*/
struct TextureEffect {
TextureEffectType type;
float arg1, arg2;
float arg1;
int subtype;
WaveformType waveType;
float base;
float frequency;
float phase;
float amplitude;
ControllerFloat* controller;
const Frustum* frustum;
};

/** Texture effects in a multimap paired array.
Expand Down Expand Up @@ -1098,6 +1097,9 @@ namespace Ogre {
/// The index of the referenced texture if referencing an MRT in a compositor.
uint32 mCompositorRefMrtIndex;

const Frustum* mProjectiveTexturingFrustum;
TexCoordCalcMethod mTexCoordCalcMethod;

//-----------------------------------------------------------------------------
// Complex members (those that can't be copied using memcpy) are at the end to
// allow for fast copying of the basic members.
Expand Down
65 changes: 25 additions & 40 deletions OgreMain/src/OgreTextureUnitState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ namespace Ogre {
, mTextureLoadFailed(false)
, mRecalcTexMatrix(false)
, mTextureCoordSetIndex(0)
, mProjectiveTexturingFrustum(0)
, mTexCoordCalcMethod(TEXCALC_NONE)
, mFramePtrs(1)
, mSampler(TextureManager::getSingletonPtr() ? TextureManager::getSingleton().getDefaultSampler() : DUMMY_SAMPLER)
, mParent(parent)
Expand Down Expand Up @@ -673,13 +675,25 @@ namespace Ogre {
{
if (enable)
{
TextureEffect eff = {ET_ENVIRONMENT_MAP};
eff.subtype = envMapType;
addEffect(eff);
switch (envMapType)
{
case ENV_CURVED:
mTexCoordCalcMethod = TEXCALC_ENVIRONMENT_MAP;
break;
case ENV_PLANAR:
mTexCoordCalcMethod = TEXCALC_ENVIRONMENT_MAP_PLANAR;
break;
case ENV_REFLECTION:
mTexCoordCalcMethod = TEXCALC_ENVIRONMENT_MAP_REFLECTION;
break;
case ENV_NORMAL:
mTexCoordCalcMethod = TEXCALC_ENVIRONMENT_MAP_NORMAL;
break;
}
}
else
{
removeEffect(ET_ENVIRONMENT_MAP);
mTexCoordCalcMethod = TEXCALC_NONE;
}
}
//-----------------------------------------------------------------------
Expand Down Expand Up @@ -1160,25 +1174,19 @@ namespace Ogre {
{
if (enable)
{
TextureEffect eff = {ET_PROJECTIVE_TEXTURE};
eff.frustum = projectionSettings;
addEffect(eff);
mProjectiveTexturingFrustum = projectionSettings;
mTexCoordCalcMethod = TEXCALC_PROJECTIVE_TEXTURE;
}
else
{
removeEffect(ET_PROJECTIVE_TEXTURE);
mProjectiveTexturingFrustum = 0;
mTexCoordCalcMethod = TEXCALC_NONE;
}

}
const Frustum* TextureUnitState::getProjectiveTexturingFrustum() const
{
EffectMap::const_iterator i = mEffects.find(ET_PROJECTIVE_TEXTURE);
if (i != mEffects.end())
{
return i->second.frustum;
}

return 0;
return mProjectiveTexturingFrustum;
}
//-----------------------------------------------------------------------
void TextureUnitState::setName(const String& name)
Expand Down Expand Up @@ -1218,28 +1226,5 @@ namespace Ogre {
return mSampler;
}

TexCoordCalcMethod TextureUnitState::_deriveTexCoordCalcMethod() const
{
TexCoordCalcMethod texCoordCalcMethod = TEXCALC_NONE;
for (const auto& effi : mEffects)
{
switch (effi.second.type)
{
case ET_ENVIRONMENT_MAP:
texCoordCalcMethod = (TexCoordCalcMethod)effi.second.subtype;
break;
case ET_UVSCROLL:
case ET_USCROLL:
case ET_VSCROLL:
case ET_ROTATE:
case ET_TRANSFORM:
break;
case ET_PROJECTIVE_TEXTURE:
texCoordCalcMethod = TEXCALC_PROJECTIVE_TEXTURE;
break;
}
}

return texCoordCalcMethod;
}
}
TexCoordCalcMethod TextureUnitState::_deriveTexCoordCalcMethod() const { return mTexCoordCalcMethod; }
} // namespace Ogre
Loading