[1.9]Animating shader parameter with a NumericAnimationTrack

Problems building or running the engine, queries about how to use features etc.
Post Reply
def87
Halfling
Posts: 90
Joined: Wed Sep 19, 2012 1:41 pm
x 1

[1.9]Animating shader parameter with a NumericAnimationTrack

Post by def87 »

Hi,

I am trying to animate a shader parameter with animation keyframes.
Unfortunately I could not find any examples how to do this.

So far I am getting an exception

Code: Select all

OGRE EXCEPTION(9:UnimplementedException):  in  at d:\developer\ogre\1.9.0_x64\ogre\ogremain\include\OgreAnimable.h (line 153)
line 153 defines the virtual void setValue(Real) function which I do have implemneted in my AnimableValue Class:

Code: Select all

	class ShaderValue : public Ogre::AnimableValue
	{
	protected:
		Ogre::GpuProgramParametersSharedPtr m_Params;
		Ogre::Real m_Value;
	public:
		ShaderValue(Ogre::GpuProgramParametersSharedPtr p);

		void setValue(Ogre::Real& val);
		void applyDeltaValue(Ogre::Real& val);
		void setCurrentStateAsBaseValue(void);
	};
I am trying to pass a ShaderValue object to the animation object:

Code: Select all

Ogre::NumericAnimationTrack* numericTrack = animation->createNumericTrack(animation->getNumNumericTracks(), Ogre::AnimableValuePtr(myShaderValue));
Am I generally doing the right things?
If there are any source examples doing something similar (except OgreLight.h) I would be grateful for any hints.
def87
Halfling
Posts: 90
Joined: Wed Sep 19, 2012 1:41 pm
x 1

Re: [1.9]Animating shader parameter with a NumericAnimationT

Post by def87 »

Ok, I've made some progress.
I have the Real AnimableValue class working, but a ColourValue and a Vector4 version of the class give me the same exception.

The ColorValue AnimableValue is supposed to drive a shaders rgba color values.
The Vector4 AnimableValue is supposed to drive a TextureUniteStates uv-scrolling and uv-scaling.

The constructor of each derived class is called, but the setValue() method is being called on the base class.

So, I guess, there is a bug somewhere in Ogre, or a problem on my side somewhere I am not aware of to check.


Please, if you have any ideas what I might check/debug, help would be appreciated.
def87
Halfling
Posts: 90
Joined: Wed Sep 19, 2012 1:41 pm
x 1

Re: [1.9]Animating shader parameter with a NumericAnimationT

Post by def87 »

Since my AnimableValue class of type REAL is working I need to assume that an AnimableObject class is not needed.

As far as I understand the Ogre::Light class an AnimableObject class is just a generic interface to know about the AnimableValues available in a Ogre::MovableObject class. If I can create the AnimableValue directly, an AnimableObject is not needed.

Is this correct?
def87
Halfling
Posts: 90
Joined: Wed Sep 19, 2012 1:41 pm
x 1

[SOLVED][1.9]Animating shader parameter with a NumericAnimat

Post by def87 »

Ok, I solved the problem.
My derived AnimableValue class was expecting ColorValue and Vector4 variables, but actually they needed a pointer. Just missed the "&".
That also explains the different behavior because the int and Real functions do not pass pointers.
Post Reply