I want to create a material in which there is a smooth vertical gradient from the lowest vertex to the highest.
I also want the flexibility of being able to scale and rotate the mesh, with the gradient looking the same.
I’ve sort of created this effect by using the pixel position, masking Z, and dividing by a height then lerping the color. This would require me to make a new material or instance for every single object though, which would make me cry.
As you can see, the limitation of my current material is that I want the gradient to be static, and as you can see pushing the Z down (object on the right) results in half the mesh becoming darker, instead of looking like the one on the left.
Material:
I’ve thought about subtracting the actor position Z (set to the bottom of the object) from the pixel position Z, but I couldn’t get it to work… and I’d still have to create a new mesh with corrected origin every time as UE4 doesn’t seem to let you change the origin permanently… which is NOT something I want to do…
Vertex colors are definitely not what I want.