Ok, so essentially the opposite of what I got from reading - which makes more sense.
Still, the behavior and how to achieve this is kind of similar.
You can go several ways about it.
the most “free form” one will be to turn the cube into a blueprint and run the followign things on it.
On construction create a dynamic material instance from its material and save it to a variable.
Subsequently, change a color parameter of the material with “Set Vector Parameter Value”. Pass the scale information of the cube to it - Get Actor Scale 3D, or Get actor Relative Scale 3D depending.
The material will now have that information and can use it to offset your textures - depending on how you code the material. (It’s kind of unnecessary at a base level - so I agree not the BEST solution).
The second way is to just create several Material instances and scale them individually on a cube by cube basis.
This will also illustrate the code for the material.
Let’s start with UV0. press U and click in the material to create that.
From that, let’s Isolate X and Y.
Drag and type Mask. Under math select the Component Mask.
In the details panel uncheck G.
Copy the mask, In the details panel check G and Uncheck R. Connect this back to the TextCoord node.
Drag off either channel and type Multiply
Drag off the B pin and type Scalar (in parameters) This will create a scalar value.
Copy the Multiply to the other Mask node
Create another scalar (name them as you please).
From one of the 2 multiply nodes output drag and type Append. Select append Vector (I think, going by memory).
Plug the other multipy into B.
This output can be used on the texture - UVs pin.
NOTE default parameters generate with a value of 0. 1x0 = 0 Meaning the UV is null. Change the default values to 1.
This is one way to scale the texture indipendently on X and Y axis to match the extent of an object. You decide how much by changing the scalar parameter values.
Third way. (possibly the best).
Right click on the material graph and type Object.
Find Object Scale.
From X or Y drag off and find ADD. - connect both X and Z to the add.
With the code from before put the ADD node into the multiplier for the R mask, and the Z off the objectscale node into the multiplier for G.
This will get the texture to start scaling based on object size.
If you go the BP way, create a Color parameter, add the pins from R and G, and use these as the multiply on the R of the texture coordinate node, and B as the multiplier for G
Once you are done tweaking your material - for performance sake since you mention you’ll have a lot of objects - let’s move the calculations to a custom UV.
Click the material node and type Custom.
In Number of Customized UVs type 1.
Alt click the UV pin inside the texture sample and drag off from the Append Node to the Customized UV0 pin in the material.
Then for the textures create a new TextCoord node (U and click on graph). connect it, and save. <- you don’t even need to, since the UV0 will be used by default, but I like keeping materials organized and ready for change.
Hope that helps.
*** Super important PS ***
Your UVS on the model will matter. Extra shader work will be required with the base cube to include the Y scale. If you just map the cube correctly in a 3d program the scaling of the texture is easier and can work this way.
I’m actually looking into a way to include Y atm, since this can be beneficial for my project as well.
Best way to isolate X Y and Z on the object is to split them into different UVs from the 3d program.
You could even control each face independently this way, by setting up different options for the different UVs.
vertex paint is a decent option, but painting the default cube is challenging at best (seems like vertices are some times shared by the faces, some times not).
Object rotation cross to object position may get me somewhere. Attempting some math around those ideas.