Animated materials / textures grief…

Hi all,

I’m seriously struggling with this aspect, and would appreciate some advice more than I can say…

My (simple?) requirements are to have 2 materials:

  1. Opaque / Shaded / with a GPU-accelerated function to scroll a repeated texture at a given speed in a given direction. (For a river)
  2. Translucent / Shaded / with a GPU-accelerated function to move a repeated texture back and forth along a sine wave (For waves going in and out of a shoreline)

    Seems pretty reasonable, but I’ve met a dead end at every path I’ve taken…

    a. I’ve searched forums for info on shaders and for animated textures (so I don’t have to write one from scratch),

    b. The closest, most informative, or most recent examples I could find are:
  1. Shader flickers terribly from some angles (ok, may be my objects or something, but they looked ok with standard lighting.j3md… still investigating)

  2. It doesn’t use lighting, so the colours look completely out-of-whack with the rest of my scene. So I had a look at copying & modifying the jme3 illuminated shader, but it’s orders of magnitude more complex than this one, and I don’t know where to begin adding the movement routines…

    and the showstopper…

  3. Crashes on Android, with the following error

    “Exception thrown in thread[GLThread 12,5,main]

    com.jme3.renderer.RendererException: compile error in:

    ShaderSource[name=Shaders/MoivingTexture.vert, defines, type=Vertex] error:


    …and I simply don’t have the time to learn how to debug GLSL on Android just to get a simple friggn’ texture to move!! (Nor do I even know where to start!!)

    Can anyone please please point me in the direction of a shader which fits all the criteria, or at least offer some advice? I’m not even that fussed about the GPU aspect (unless it is awfully slower). Is there a better solution? Can I just use lighting.j3md and manipulate the texture manually, if that’s easier? Or what?! Please help!!!

    P.S. Here’s a screenshot of the offending scene, just in case evidence of a game under way lends any weight to my plaintive cries…


Hi in this old post 6 months + I posted a shader that uses lighting and supports uv-offset.

I only dont know if its still compatible / up-to-date. But you can always try it :slight_smile:

Your game really looks nice btw!

Hi in this old post 6 months + I posted a shader that uses lighting and supports uv-offset.
I only dont know if its still compatible / up-to-date. But you can always try it :)


I'm about to go to bed right now, but I'll try it tomorrow and let you know how it goes.



By coincidence I had to use this shader too and as expected it didn’t work anymore with the current beta release. so I’ve updated it.

to use it :


Box b = new Box();

Geometry g = new Geometry(“testCube”, b);

Material offset_mat = new Material(assetManager, “MatDefs/UVOffsetLighting.j3md”);


offset_mat.setBoolean(“TranslateUV”, true);

offset_mat.setVector2(“TranslateAmount”, new Vector2f(0.5f, 0.5f));



in the update loop you can keep updating the uv_offset with : offset_mat.setVector2(“TranslateAmount”, new Vector2f(new_x, new_y));

I advice you make a material first with the material editor and use UVOffsetLighting.j3md as Material Definition

and then enable TranslateUV in there by default.

Here are the updated sources :



put them in the right folders in your assets and you should be ready to go.

Now I’m going to sleep :wink:

good luck


Still working on this, by the way. I’ve got your material to load (thanks again!), but it’s not reflecting ambient light at all. Then I noticed lighting.j3md itself isn’t reflecting ambient in my scene; only materials imported from Blender are. Still investigating, but I’ll let you know how it goes one way or the other.

@jonmonnkey, cool…I really don’t know much about lighting. But I think ambient light just works, in my scenes anyway…or did you mean reflecting in this way :

This post explained a lot to me about different kinds of light shading : post

else it should just work :S

1 Like

hey danison,

Thanks, I got it working perfectly… flowing water and waves lapping up on the shores. Even doing the animation in the update() loops (as opposed to GPU) didn’t seem to make a noticeable difference to the framerate, which was a bonus, and it ported to Anrdoid without a hitch (although he quality’s not quite as nice on Android, but that’s to be expected I suppose).

The ambient lighting problem (and other related issues) were solved for me in this thread.

The solution was to select “UseMaterialColors=true”, and to apply Diffuse & Ambient colours to the material as well.

Thanks again!

Great to hear that :D.

Also nice to hear that the shader runs on android.

Thanks for the status update!

I hope to see more from your project in a further stage!