I'm currently working on a physical water system for Unreal. To represent the water surface, I have a simple flat grid mesh that I then apply a material to which has a formula for world position offset.

The formula currently is pretty simple, I just have a simple sine wave powered by world X position and elapsed time, however despite both formulas being, as far as I can tell, the same, they give different outputs.

As you can see below, both formulas perform the same operations, and both are powered by the same input, world position and Game Time in Seconds. In theory, the material (second-last image) should be dividing X position by 2000 and multiplying time by 0.1, just as those values are in the material, however instead the closest I could get to having both values line up is 314* and 0.625.

It's important that these values line up, as the blueprint version is meant to be used for buoyant objects to make sure they stay on the surface of the water, and probably other calculations as I progress.

Does anyone know why these formulas don't line up like they should? Does math work differently in the material editor? Does Absolute World Position give values in a different scale compared to Actor Position?

*I thought this might be 100 * PI, but that doesn't seem to line up exactly either so may be a coincidence.

Material Formula The final result here is piped directly into World Position Offset.

Material Formula 2 Time parameter is updated every frame to match the blueprint version.

Blueprint Formula Blueprint function that I need to match the material formula for accurate buoyancy and such.

Blueprint Formula 2 Included for completeness, an example of how the water height function is used.


Other than the obviously different constants in both screenshots you posted, what might not be so obvious is that the input of the blueprint sin function is expected to be in radians, while the input of the material graph sin function is expected to be from 0 to 1.

To match between them, you should divide your material graph input to sin by 2*PI

  • 1
    \$\begingroup\$ Thank you, this was the issue. I'll multiply by 2pi in the blueprint instead to save calculations in the material, but the formulas are lining up perfectly now. \$\endgroup\$
    – AgentPaper
    Oct 1 '19 at 3:16
  • \$\begingroup\$ Spent half a day once banging my head against the desk because of the same issue :) \$\endgroup\$
    – Rotem
    Oct 1 '19 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.