Help animating W value of noise texture from tutorial

I followed the above tutorial to animate the W value by putting in #frame/3000 properties in the W value. I have no idea what this does but I press play on the time line nothing happens. i am using UPBGE 4.4.3

here is my project file
waterShaderTest.blend (559.3 KB)

Drivers only work with an animated time line (via python script).
You can also delete the driver and set the value directly via script.

0.44_waterShaderTest_script.blend (546.0 KB)
Since the fps are so low in 0.44 that it’s a slideshow here the same for 0.3:
0.3_waterShaderTest_script.blend (871.1 KB)

thanks for you help so far. I am trying to understand the code here. Why is there a speed property. why not just use a constant. is this property referenced anywhere else. also, i usually see cont.owner declared with a get controller code. is this because the module pass the value to the function.

yes, exactly, module passes cont so I had to type less :slight_smile:
And property just for easier setting.

If you happen to also use UPBGE 0.36 you can try this file (UPBGE 0.44 is so sloooow)
(Excuse the massive file size, it’s by Michael from discord and he used an enormous water normal animation texture)
I added the grab and planks swimming code and 2d filter.


Here for a short time until link expires:

i downloaded the file but i am using UPBGE 4.4.3. I am not sure if it’s running properly. I pressed the P button nothin happens. something happens but i am not getting the ocean wave effect.

I don’t know how to fix it for 0.44.

The driver is not correct.

You can not write #frame in the driver editor, delete the # symbol and it will work.

OR (to start again as in the tut) delete the driver in the shader editor, click the value of W, delete the number and write #frame/3000 directly there.

The # symbol tells blender that you want to create a driver in the value field (it is like a shortcut that creates a driver automatically) but it is not part of the driver expression in the driver editor.

If you write #frame/3000 directly in the value field the driver it creates looks like this;

yeah, i think that fixed it. i appreciate your help. a further question if you would indulge me. what exactly does putting the string “frame” /3000 mean. how does blender interpret that expression. so far, i just copied tutorials and don’t understand the finer aspect of what i am doing.

Frame gets the current frame number and /3000 divides it by 3000.
It slows down the effect. If you write just frame it would go really fast, or if you write frame*3000 (multiply by 3000) it would be extremely fast.

Drivers take an input value (in this case the frame number) and the expression is a mathematical calculation that you can change that value with.

Drivers can have more that one input value, the input values are called “Input Variables”,
the expression can use more than one Input Variable, like algebra “(a+b)/(c*36)” where a, b and c are your Input Variables.

Blender will warn you if your expression is not accepted (as in the first screenshot I posted, note it gives an error)

what if input a constant value there, does that do anything or it have to associate itself with a variable like frame rate

You can write a simple value with no variables but it does not make much sense, it is the same as writing the number directly into the value field. With the difference that you will not be able to edit that value without editing the driver.

The interesting thing about drivers is that they give you the ability to use variables. Those variables can come from other objects, scene values shader values and almost anywhere. You can use the rotation of one object to control the location of another or many other things.

thanks for the help

Great stuff! Lots of possibilities with right click “edit driver”.
Here is the water with a driver that takes the z-rotation of an empty.
A logic brick rotates the empty in game.
0.3_waterShaderTest_driver_empty.blend (847.9 KB)

i am using this technique to do a water animation for a game. the logic brick has an end frame rate for action editor animation. for example from frame 1 to 50 but it loop stops resets which is kinda jerky. you seem knowledgeable in the area, can you can give me some pointers on how to achieve a smooth animation. from what i can tell, there is no way of setting the frame rate to infinite so it will play. here is my project file revised without hash tags thanks to your suggestion

waterShaderTest.blend (533.1 KB)

Hmm

tricky, the only thing that occurs to me is to make the w value seamless over the frame range.

One way would be like this but the downside is that the animation goes forwards then backwards (from the middle frame.)

There are probably other ways to do this.

Here I just used “frame” in the driver (no division).

The first map range takes the frame number (0-50) and maps it from 0-49, (if not frame 50 would be the same as frame 1), to 0-1 for the colour ramp factor.

The colour ramp inverts the values so that they go from 0 to 1 then back to 0.
I am sure there is a more mathematical way to do this maybe with a sign and modulo or something similar but I am more “visual” than mathematical.

The multiply node controls the speed (smaller values slow it down.)

here is the file
waterShaderTestLoop.blend (119.8 KB)

I originally made the file in Blender 5 which breaks comparability but have back-ported.

Simply don’t use frame. use an empty or set value by code.

I completely overlooked your solution. I actually have your project file. Setting the value by code definitely solve the animation reset problem.

question, you tick up the W value using your example. i learned in variable type is a value like long and int has a maximum character length like a long number. float can hold more. would it throw an error if it go beyond what the variable is capable of holding. like for example, the W value is equal to 10^12 or something. would the game just crash then.

I’m not sure what would happen.
When setting the w value in the node then there is a limit at 1000.
I remember I reset the value to 0 in a game when at this limit.

… ok, at 32768 it stops working (without error)