"complicated" texture tiling across spline meshes

I’m somewhat new to materials. more of a programmer myself. so these may seem simple but i’ve googled around for days trying to find solutions and have had no success
first question
I have a static mesh that is 1400x200 on the side that needs textured (its 1400x200x50 if thats important.) i have a texture i feed into a material that is the exact same aspect ratio.
But when i apply the material it scales it to 1400x1400 essentially. so i did TexCoord and scaled the uv. pretty simple but this may need to be changed for what i want to do long term. also it seemed like a ridiculous step to have to take. i made the static mesh in unreal. its just a simple cube.
second question
so the static mesh is being pushed through a spline mesh spawner. it could essentially be scaled from 1400x200 to 1400x5000 if needed. no sense in putting multiple meshes down when 1 stretched mesh does the job. so the issue here is now it stretches the texture instead of tiling it.
how do i tile it so it lines up properly across multiple segments of the mesh along a spline?

Did you try using a ‘world aligned’ material?

I don’t think world aligned would work.
but I should have said that basically only the UTiling needs to be tiled as the VTiling will always be the perfect width across the spline. It’s a road.

I’m not home to test it and I did assume world aligned would not work based on my understanding of world aligned.

Ah, road, then WA probably would not work.

the best possible solution i’ve came up with is to somehow send the calculated distance and length from pcg to the material. but i haven’t been able to figure out how to do that with spline meshes, only with instanced static meshes, from pcg. but also i wanted to avoid instanced materials. which i think may make it impossible unless there some way for the material graph to read properties from a blueprint.
but my avoidance of instanced materials stems from me not knowing how much overhead that actually comes with.

Why are you trying to avoid material instances?

For a road, one typically doesn’t tile the texture across a long skinny mesh. Instead you add spline mesh components to a spline at a distance along spine in construction script of a bp (or use the landscape spline editor if you’re working with landscape).

And yes, you can feed info to a material from blueprint by making a dynamic material instance in the bp and setting parameters on it. Material instances are relatively cheap since the texture lookups and such basically only happen once when the base mat is loaded.

it just seemed logical to have 1 mesh cover a straight distance instead of 50 tiny ones seeing how spline meshes dont take advantage of instanced meshes.

it just seems like instancing something 1000 times comes with more overhead than not doing that. i could be wrong.

but after thinking about this and not having any luck… im just going to use solid yellow lines instead of dotted. solves everything.

Here’s a decent tut for spline mesh. It’s kind of a roller coaster track, but a road would work the same way.

But yea, it would be cheaper to have one long mesh on a long straight section, but you could always just delete long straight segments of spline and drag a straight section onto level to fill in the gaps. In theory you could use get actor bounds or some such in material and do math to bump up uv tiling as needed for longer mesh instead of mucking around with setting dynamic parameters in a bp.

You can also use Custom Primitive Data to store parameter values on a mesh and access that in a material.

get actor bounds doesn’t work very well due to how it morphs the mesh for curves. it also doesn’t change the scale so that doesn’t work.

hmmm. could one write to custom primitive data from a pcg graph?

I meant you could use bounds to fix uv on large straight sections plugged in between curves. If curves are made of multiple spline meshes, they probably shouldn’t need uvs stretched.

And, yes, you can output custom prim data from a pgc graph. There’s an Add Attributes node in pgc editor for that which you would plug into a Mesh Spawner input. Mesh Spawner node has a couple of options to set up per instance data packing so it knows what to do with the Add Attributes node.

But. i’m not using instances. i’m using the spline mesh spawner. the spline mesh spawners spawns a different static mesh for every piece. not instances. and its not lots of mini pieces in the straight stretches. each straight strettch is 1 mesh no matter how long it is.
does the add attribute still work?

I think add attribute should work on any mesh spawned by pgc. Is your pgc graph automaticallly scaling the straight pieces to match the spline segment length? If so, you could probably do some quick math on the scale number to set a custom primitive data attribute the material can use to scale uv coords.

Please be more specific. But remember I am using Spawn Spline Mesh not Static Mesh Spawner.

Yes, the Spawn Spline Mesh does all of that automatically based on your spline. Tho it doesn’t use the scale parameter to do anything.
To get the data I need for the UV, I will use the Calculate Distance flag. Calculate distance gives u the distance of each point compared to the first point. So, the numbers accumulate. 0, 200, 500, 700, 900
The distance would let me calculate where the uv would start. (the position of the UV)
Then to get the length of each mesh along the spline. I use the distance calculated, then make a copy of that distance. but. i delete the first point of the copied distances.
0, 200, 500, 700, 900 becomes 200, 500, 700, 900.
then subtract the original distances from the copied distances.
so it would be 200-0, 500-200, 700-500, 900-nothing.
not sure if it will ignore the 900-nothing or throw an error or give me 900. but that will be easy to fix once i know what it will do. I assume it will ignore it.
that will let me assign a length to each point in the spline data. which i use to scale the UV

i have all the data ready, i just dont know how to get it to my material.

It appears you can’t use the standard per instance data packing method with spline mesh spawner. But you could probably use a post-process function in a pgc actor to loop thru the components and apply custom primitive data to them.

I don’t know the specific series of nodes to use, but here’s a tut showing how to use post proc to to randmize the spline meshes:

I would imagine in the place he sets mesh, you would set custom prim data on mesh.

drats. i was hoping it would be something like add attribute target $StaticMesh.CustomPrimitiveData or something.
But i will look into doing it this way.