I am trying to change materials applied to meshes. I created a 4x4x4 Rubik’s cube. The outer faces on each block will be one of 6 colors, just like a physical cube. Each of my textures includes a hexadecimal number. My project assigns materials to block faces at random when the execution starts.
I show the corner of a rendered cube below. In the picture, the orange is in front, red is the right side, & yellow is the top. As you can see, depending on the face, the hex number might be properly centered (front) or skewed horizontally or vertically. The back face, 2nd photo, actually shrinks & tiles the texture.
I converted each texture into a material before applying to the meshes. Each mesh, one of the six block faces, is structurally the same. The blueprint diagram below shows how I solved the off-center material for the Blue 5 front face. Each other face needs different adjustments for the Hshift & Vshiift variables. Also, the back face needs different UTiling & VTiling values. So, applying a Blue 5 to a right, top, bottom, left, or back face needs different numbers in those parameters.
I noticed that the left & right faces only shift horizontally, the top & bottom faces shift on both dimensions, while the back face shrinks & tiles the material. The edges of each block are beveled to smooth them out just like the blocks in a physical Rubik’s cube.
The simple solution would be if the material would apply the same way to each face. I’ve never found a solution for that. The next simplest solution would be a function that applies meshes using passed variables, but executable blueprints make material & mesh manipulation incredibly difficult. This is my first Unreal Engine project, so I thought I was going with a simple task. Any ideas?
Aloha, & thank you for the quick response. I didn’t see the test pattern you had below in any UE content. I copied you image into the texture folder & converted it directly to a material. I made no changes in its material blueprint. This is what a corner block looked like.
There is still an obvious shift in the hexagon positions. Also, the image is rotated 90° counterclockwise. This is the same case with my numbered face materials as well. When I modify the material blueprint, I can set UTiling & VTiling so that the image fits better onto the mesh. It is still off-center though, & the difference varies according to the block face being painted by the material. This is the new “zoomed out” tile.
I keep experimenting with different solutions. The results are the same whether I bake the blocks into the scene or create them on start-up. I can experiment with different scales on the meshes, but that won’t solve the shifted image. What is so frustrating is how inconsistent these material applications are.
Here is the FBX of the block used to create the cube. I made the block in Blender because options like beveling edges are easier there. Since the cube is 4x4x4, it uses a total of 64 blocks.
I also tried making a simple cube in UE. I then created material elements for each face. I made no changes to UV nor horizontal/vertical shifts. What I got is the picture below. The image on each face is still not consistent.
You might try to export it to blender and assign material to the faces like you did with yours (it’s probably faster than fixing the UVs in the other one)
So, I recreated the Rubik’s cube block using only UE. I still beveled the edges so that the blocks look like an actual Rubik’s cube. They don’t have sharp edges. If I place a static block in the scene & assign the materials to it, it actually looks spot-on perfect. That’ the single block with all blue faces. I set UTiling & VTiling to 2.0; that seems the perfect size. However, if I create each block dynamically & dynamically assign material, the materials become skewed. On the 4x4x4 colored cube, the numbers are off-center & rotated 90° counterclockwise. Also, UTiling & VTiling need to be set to 10.0. I only modified the tiling on the blue 0-5 materials to 2.0 for this illustration.
At least I now know that to concentrate on the dynamic meshes & material application. Still not sure what went wrong, but it lets me focus on my blueprint for this level. Thanks for the advice, any more help is appreciated.
So, in the end, the solution was pretty much as Ares9323 described. I recreated the basic block using a UE box from the modeling mode. Then I beveled the edges using a boolean subtract. This was a good bit more involved than a Blender model, but it worked. Next, I assigned material elements to each face, a total of 7 elements when counting the edge areas that remain as the “whole” cube.
Part of my problem was legacy references to the old Blender cube that remained in the blueprint. Once I changed all of them to the new UE block, all I had to do was change the materials to have UTiling & VTiling set to 2.0. Fortunately, this was fairly simple in the material blueprints. Here is the result.
I see diagonal creases on the bottom face, so I still need to clean that up. But for now, I’ll celebrate the win. Thanks to all who helped, especially Ares9323 with the advice to go all-UE even on the 3D modeling.