AWS Thinkbox Discussion Forums

UVW derivatives

Is there a way to get UVW derivatives from an object?

Can you explain what you are trying to achieve?

I want to get a vector pointing in the V direction in UV space translated to world space.

oops, posted that not logged in…

Here is one approach using the Gradient operator. The Gradient gives you a vector field from a scalar field with vectors pointing in the direction of the increasing value. So if you dump the V of your UVs onto a Grid, and then calculate the Gradient, you will get a Vector field of the derivatives (the direction in which the V is growing relative to the current sampling point).

I took a Geosphere and created a Stoke Field Magma around it.
In the Magma, I used a NearestPoint to sample the surface of the GeoSphere and acquire the TextureCoord (Mapping 1) channel’s UVW.
I used Breaktout to split the V from the UVW and dumped it on a regular Grid, thus creating a cached Scalar Field of Vs.
Then I calculated the Gradient of this Grid, Normalized it to produce unit vectors, and output it as Velocity to visualize it.

You could skip the Normalization if you are interested in the magnitude in addition to the direction of the vector.

Hope this helps…

Perfect!

That is exactly what I was after!
I had found the gradient operator but hadn’t figured out the grid part.

Thanks Bobo!

R

You are welcome!

It kinda works without the Grid operator, but the results won’t be as clean, because the Gradient has to evaluate multiple samples, and some samples can produce unexpected results in edge cases. With the Grid in between, the V samples are first cached on the grid, then the Scalar Field is processed by the Gradient to find which way the values are increasing, so most (in my test all) problem samples disappear.

Privacy | Site terms | Cookie preferences