Download

Is there a way to fit the UV to the Mesh proportions?

At the moment I’m calculating the U and V with respect to the X and Y of a cube.
But what if I want to make the texture looking good when a mesh is changing it’s proportions from a cube to say something like this?
Untitled.jpg
Is there a math equation I can use for it or something?..

Probably not dynamically if you are using a pixel image, the pixels will just stretch with the mesh. Main problem being that you have two triangles and they are distorting differently. You would probably get better results if the cube was subdivided (more triangles to more evenly distribute the distortion). Either way if it’s a highly detailed texture it could look weird.
Adding one pixel in the center so you have 4 tris would even minimize distortion to a degree.

Might be a way to figure it out with vector art. But how that would work on a mesh in game would probably be more costly rendering than worth it.

But mainly the less detail the texture has the better off you will be. If you just use solid material colors the distortion wouldn’t matter.

Perhaps unwrapping to active quads might help (blender)

Greetings,

Exactly what Jay said. You have to keep in mind that everything becomes triangles under the hood, and distorting triangles will distort the texture. Just like this:

2cc4fc3106a6bdf9dc1e2f6159ec1e798842ce12.jpeg

It’s just something you have to plan for when modelling and texturing, or deal with if you’re doing something dynamic like it sounds.

I’m not entirely sure about your problem but I believe this is what you are looking for is to access the Object Radius inside the Material Editor, this tutorial explains very well the concept as well as the solution: https://www.youtube.com/watch?v=YMvg8dHet5E It’s in UDK but you can still follow along.

Also: https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/ExpressionReference/Coordinates/index.html#objectradius

Thanks everyone but the issue is that I’m using it to my ingame mapbuilder, so I need unreal to figure out the new uv dynamically ( I actually need unreal to project a new UV on the mesh’s face ).
Is it possible in any way?

Mauriccio, that’s a very cool video, I had no idea that kind of stuff was even possible.

However that only accounts for tileable textures on objects with ‘even’ scales. ie: 1,1,1 or 0.5, 0.5, 0.5.

Sahkan is looking for a solution to distortion, so I don’t think it counts.


An image of the intended texture MIGHT help pin point the solution, though I don’t think there is one. Say the texture on the square is a crate, if you change that square to the shape shown above, a square side of a crate just couldn’t fit into that shape.

If it’s a generic tiling texture (like the rocks in the video - normal map) the solution would be more like always projecting a square texture onto the surface and not distorting as the perimeter changed. But that would have the texture ‘rolling’ off the edges so the texture itself always stayed square.

Basically you’d be looking at continually real time projecting a planar map onto the surface.
If Unreal can do what the images in the video show, then it SHOULD be possible to project a planar map in such a way, at least in the editor. Game run time might be an entirely different beast though.

Thanks, I hope someone can confirm and show how to do this inside the material editor.

Do your objects have a custom texture? If not, you could use world aligned texture.
Else if you have a texture with painted in details that need to be preserved you are going to have a bad day. Depending upon how complex the details are, you might be able to set up masks to preserve features while allowing a world aligned texture to tile across the bulk of the surface.

Thanks man it looks like this is exactly what i need! :slight_smile:

I love hearing that! Good luck :cheers: