Download

Mesh velocity in shader?

hello! i’m pretty new to UE4, and i was wondering if its possible to somehow use dynamic mesh velocity and rotation inside material (can be just the pivot point, or bounding box center)? lets say i have a box that is simulated and i would like it to be black when its still, but get brighter the faster it moves. Or when its suddenly rotated. I noticed there is a block called object orientation, which can give me the current rotation, but is there a way to get the difference between current rotation and the one from previous frame?

One way to do this would be to make a scalar parameter that controls the brightness of the material and set that parameter dynamically from the Blueprint of whatever the moving object is based on its velocity.

To get movement speed: Get Physics Linear Velocity | Unreal Engine Documentation
To get rotation speed: https://docs.unrealengine.com/latest/INT/BlueprintAPI/Physics/GetPhysicsAngularVelocity/index.html

The first reply is right but perhaps need to clarify:

Learn how to use dynamic material instances.

You make a material, which has parameters (right click and change to paramter)

In the BP you create a dynamic instance of that material, and then with that instance you can change those paramteres in game time. There is more to it than that, but the possibilties are endless.

I use this ALL the time. I create virtually all the materials in my game dynamically in the construction script because I like being able to change values. For example, a BP that creates a wall. I have the colour editable from in the editor now, without having to create a new material instance. Or use this to animate things. Or change colour based on X

Also the Map float node is really handy for converting velocities to values relevant to your material, just FYI

Thanks for all the answers! ill try them today after work.