Skip to content
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

Devel #3195

Merged
merged 4 commits into from
Aug 20, 2024
Merged

Devel #3195

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
57 changes: 34 additions & 23 deletions OgreMain/include/OgreTextureUnitState.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,13 @@ namespace Ogre {
*/
struct TextureEffect {
TextureEffectType type;
float arg1, arg2;
int subtype;
Real arg1, arg2;
WaveformType waveType;
Real base;
Real frequency;
Real phase;
Real amplitude;
float base;
float frequency;
float phase;
float amplitude;
ControllerFloat* controller;
const Frustum* frustum;
};
Expand Down Expand Up @@ -547,6 +547,8 @@ namespace Ogre {
void setUnorderedAccessMipLevel(int mipLevel) { mUnorderedAccessMipLevel = mipLevel; }
int getUnorderedAccessMipLevel() const { return mUnorderedAccessMipLevel; }

/// @name Texture coordinate transformation
/// @{
/** Sets a matrix used to transform any texture coordinates on this layer.

Texture coordinates can be modified on a texture layer to create effects like scrolling
Expand Down Expand Up @@ -585,31 +587,31 @@ namespace Ogre {
@param v
The amount the texture should be moved vertically (v direction).
*/
void setTextureScroll(Real u, Real v);
void setTextureScroll(float u, float v);

/** As setTextureScroll, but sets only U value.
*/
void setTextureUScroll(Real value);
void setTextureUScroll(float value);
/// Get texture uscroll value.
Real getTextureUScroll(void) const;
float getTextureUScroll(void) const;

/** As setTextureScroll, but sets only V value.
*/
void setTextureVScroll(Real value);
void setTextureVScroll(float value);
/// Get texture vscroll value.
Real getTextureVScroll(void) const;
float getTextureVScroll(void) const;

/** As setTextureScale, but sets only U value.
*/
void setTextureUScale(Real value);
void setTextureUScale(float value);
/// Get texture uscale value.
Real getTextureUScale(void) const;
float getTextureUScale(void) const;

/** As setTextureScale, but sets only V value.
*/
void setTextureVScale(Real value);
void setTextureVScale(float value);
/// Get texture vscale value.
Real getTextureVScale(void) const;
float getTextureVScale(void) const;

/** Sets the scaling factor applied to texture coordinates.

Expand All @@ -622,7 +624,7 @@ namespace Ogre {
@param vScale
The value by which the texture is to be scaled vertically.
*/
void setTextureScale(Real uScale, Real vScale);
void setTextureScale(float uScale, float vScale);

/** Sets the anticlockwise rotation factor applied to texture coordinates.

Expand All @@ -633,6 +635,7 @@ namespace Ogre {
void setTextureRotate(const Radian& angle);
/// Get texture rotation effects angle value.
const Radian& getTextureRotate(void) const;
/// @}

/// get the associated sampler
const SamplerPtr& getSampler() const { return mSampler; }
Expand Down Expand Up @@ -847,6 +850,8 @@ namespace Ogre {
Real arg2 = 1.0,
Real manualBlend = 0.0);

/// @name Dynamic texture coordinate generation
/// @{
/** Generic method for setting up texture effects.

Allows you to specify effects directly by using the #TextureEffectType enumeration. The
Expand All @@ -856,7 +861,7 @@ namespace Ogre {
This method is used internally by Ogre but it is better generally for applications to use the
more intuitive specialised methods such as #setEnvironmentMap and #setTextureScroll.
*/
void addEffect(TextureEffect& effect);
void addEffect(TextureEffect effect);

/** Turns on/off texture coordinate effect that makes this layer an environment map.

Expand Down Expand Up @@ -889,15 +894,15 @@ namespace Ogre {
@param vSpeed
The number of vertical loops per second (+ve=moving up, -ve= moving down).
*/
void setScrollAnimation(Real uSpeed, Real vSpeed);
void setScrollAnimation(float uSpeed, float vSpeed);

/** Sets up an animated texture rotation for this layer.

Useful for constant rotations (for varying rotations, see Ogre::TextureUnitState::setTransformAnimation).
@param speed
The number of complete anticlockwise revolutions per second (use -ve for clockwise)
*/
void setRotateAnimation(Real speed);
void setRotateAnimation(float speed);

/** Sets up a general time-relative texture modification effect.

Expand All @@ -917,7 +922,7 @@ namespace Ogre {
Scales the output so that instead of lying within 0..1 it lies within 0..1*amplitude for exaggerated effects.
*/
void setTransformAnimation( const TextureTransformType ttype,
const WaveformType waveType, Real base = 0, Real frequency = 1, Real phase = 0, Real amplitude = 1 );
const WaveformType waveType, float base = 0, float frequency = 1, float phase = 0, float amplitude = 1 );


/** Enables or disables projective texturing on this texture unit.
Expand All @@ -942,6 +947,10 @@ namespace Ogre {
*/
void setProjectiveTexturing(bool enabled, const Frustum* projectionSettings = 0);

/** Gets the Frustum which is being used to derive projective texturing parameters.
*/
const Frustum* getProjectiveTexturingFrustum(void) const;

/** Removes all effects applied to this texture layer.
*/
void removeAllEffects(void);
Expand All @@ -953,6 +962,10 @@ namespace Ogre {
*/
void removeEffect( const TextureEffectType type );

/// Get texture effects in a multimap paired array.
const EffectMap& getEffects(void) const;
/// @}

/** Determines if this texture layer is currently blank.
@note
This can happen if a texture fails to load or some other non-fatal error. Worth checking after
Expand All @@ -972,8 +985,6 @@ namespace Ogre {
*/
void retryTextureLoad() { mTextureLoadFailed = false; }

/// Get texture effects in a multimap paired array.
const EffectMap& getEffects(void) const;
/// Get the animated-texture animation duration.
Real getAnimationDuration(void) const;

Expand Down Expand Up @@ -1070,8 +1081,8 @@ namespace Ogre {

LayerBlendModeEx mAlphaBlendMode;
Real mGamma;
Real mUMod, mVMod;
Real mUScale, mVScale;
float mUMod, mVMod;
float mUScale, mVScale;
Radian mRotate;
mutable Matrix4 mTexModMatrix;

Expand Down
3 changes: 1 addition & 2 deletions OgreMain/src/OgreRenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,7 @@ namespace Ogre {
auto calcMode = tl._deriveTexCoordCalcMethod();
if(calcMode == TEXCALC_PROJECTIVE_TEXTURE)
{
auto frustum = tl.getEffects().find(TextureUnitState::ET_PROJECTIVE_TEXTURE)->second.frustum;
_setTextureCoordCalculation(texUnit, calcMode, frustum);
_setTextureCoordCalculation(texUnit, calcMode, tl.getProjectiveTexturingFrustum());
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions OgreMain/src/OgreSceneManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,10 +812,9 @@ const Pass* SceneManager::_setPass(const Pass* pass, bool shadowDerivation)
{
// Manually set texture projector for shaders if present
// This won't get set any other way if using manual projection
auto effi = pTex->getEffects().find(TextureUnitState::ET_PROJECTIVE_TEXTURE);
if (effi != pTex->getEffects().end())
if (auto frustum = pTex->getProjectiveTexturingFrustum())
{
mAutoParamDataSource->setTextureProjector(effi->second.frustum, unit);
mAutoParamDataSource->setTextureProjector(frustum, unit);
}
}
if (pTex->getContentType() == TextureUnitState::CONTENT_COMPOSITOR)
Expand Down Expand Up @@ -2055,6 +2054,7 @@ Animation* SceneManager::createAnimation(const String& name, Real length)
}

Animation* pAnim = OGRE_NEW Animation(name, length);
pAnim->_notifyContainer(this);
mAnimationsList[name] = pAnim;
return pAnim;
}
Expand Down
Loading