Archive 17/01/2023.

Moving a texture across a model surface

claudeHasler

Hi, im using urhosharp ( the c# bindings of Urho3d) and im trying to get a material to move acros the surface of the model im applying it to. I’ve tried to use an animation of the uvoffset but it hasnt worked, all that happened is that my texture was stretched, no animation occurs.

Does anyone have a c++ code example for this? I can translate it to c# by myself.

This is what ive tried:

Material mushroomMat = ResourceCache.GetMaterial("Materials/StoneTiled.xml");

ValueAnimation uvShiftAnimation = new ValueAnimation();
uvShiftAnimation.SetKeyFrame(0.0f, new Vector2(0.0f, 0.0f));
uvShiftAnimation.SetKeyFrame(1.0f, new Vector2(0.0f, 1.0f));

mushroomMat.Scene=scene;
mushroomMat.SetShaderParameterAnimation("VOffset", uvShiftAnimation/*, WrapMode.Loop, 1.0f*/);
1vanK

Basic material effects for rendering

claudeHasler

Thanks alot!

This worked for me (adapted from the UvSequencer class in the link)

ValueAnimation uvShiftAnimation = new ValueAnimation();
uvShiftAnimation.SetKeyFrame(0.0f, new Vector4(1.0f,0.0f, 0.0f,0.0f));  
uvShiftAnimation.SetKeyFrame(1.0f, new Vector4(1.0f, 0.0f, 0.0f, 1.0f));

material.SetShaderParameterAnimation("UOffset", uvShiftAnimation, WrapMode.Loop, 1.0f);

Is there any documentation as to what i can control with SetShaderParameter? For example what paramer names exist, and what parameters can be passed to them? I passed float, Vector2, and Vector4 objects all with varying results, but without errors.

I’ve read this page but couldnt find any other information