I'm making conveyor belts to test out a game idea. Straight belts are animated with moving UV.y with a scalar value and TIME and I've gotten them to work just fine. I have been zoning out trying to find a way to make the texture in corner conveyor pieces rotate and match up with straight belts that can be placed next to them. It seems like applying a rotation matrix is a step in the right direction, but I'm not sure if that's going to be able to stretch the texture around the corner to connect to both sides. I'm not even sure if what I have here is fixable so.... I'd really just like to reach out to ask others how they'd approach this problem or if there's a particular set of key words I should be searching for.

Sorry to have to post from SUPER RUBBER dot com, but they've got the best rubber conveyor look I was going for. If you were to recreate this, would the rotating texture around the corner belt be achievable through a shader and good old math? Or is this something you'd make separate textures for?

You can do the corners the same way with animating a UV. The trick is to model the corner in Blender (or whatever) but fold the plane in on one corner. So make a plane object, with a decent amount of divisions (as least in the direction you are flowing). Then take all the vertices from 2 adjacent slide, and collapse them into a single vertex (this is your corner). That should be the easiest and lowest cost method in terms of performance.

You could probably do this with a lattice (in Maya, not sure if it's called the same in Blender).

I'd keep it simple, actually model the geometry and then just UV unwrap it. The geo would curve like the reference image. But the UV for the curved geometry would be mapped straight left to right or up to down.

The shader material would be a simple UV scroll shader used on each of the conveyor belt segments. Note that I only mean the moving part by that. As far as each module of the conveyor system they would be multi-material objects with 2 material slots assigned in your DCC. One for the belt the other for the rest of the geometry.

@cybereality said: You could probably do this with a lattice (in Maya, not sure if it's called the same in Blender).

Yep lattices in blender as well.

Thank you two for your suggestions. The takeaway keyword I got was "UV unwrapping". It took some guesswork, but ultimately I found a good selection of edges to choose as seams. This had the effect of warping the material in a 90 degrees arc which was exactly what I needed. An added benefit of this method is that the shader works exactly the same as the straight conveyor belts- scaling UV.y with time and a speed. Unfortunately my end result (for today), even after playing with the scale and offset of the UV map, does not allow for a seamless transition for the material transitioning from a straight to curved piece. That's alright for now, I am ecstatic that I've gotten this far!


Try unwrapping the top faces using project from view or by marking seams just along the top edge. Then UV just those top faces. Position and scale the UV so the curve goes from edge to edge on two of the edges/one-corner. Then sides can then be unwrapped separately (deselect the top, then UV) so they are positioned on the correct edges relative to the curve.

I believe this should give a seamless texture wrap with straight pieces. :smile: If you want, I can see about quickly making a Blender file with the UVs if it would help.

@TwistedTwigleg said: Try unwrapping the top faces using project from view or by marking seams just along the top edge. Then UV just those top faces.

No that is exactly what they don't want! :lol:

Ideally for the texture to not be so warped you'd want the polygons perfect right angles and all edges on each triangle to be as equal in length as possible(2 of 3 would be equal to each other) and the mesh to be more even in density. But this is the practical world and you have to be willing to be a bit messy just to get the job done.

@Megalomaniak said:

@TwistedTwigleg said: Try unwrapping the top faces using project from view or by marking seams just along the top edge. Then UV just those top faces.

No that is exactly what they don't want! :lol:

Oh, my bad! That's what I get for replying before coffee in the morning :lol:

TBH I wouldn't put it past me to have maybe misunderstood what you were actually going for either...

I was thinking something very similar, looking at it again. Though my UV isn't as clean looking :smile:

The orange is the UV on the sides of the belt, the white is the top and bottom of the belt. I also included the Blender file, in case its helpful.

Right then I did understand the previous post correct. The idea my screenshot shows is how to model and UV it so that on the godot side the UV scrolling shader could be as simple as possible.

The UV vertices need be straight grid and take up the full space (in a square) to properly tile and match up with the other sides.. The model itself needs to be "bent", originally a subdivided plane and then modified to rotate. Meaning they start on one edge and flow to the adjacent edge in a right angle. Here is a sample I put together with my method. View the image in a new tab so you can see the layout.

I also attached the Blender file and the Godot project. In Blender I applied the Simple Deform modifier with a Bend (and used an Empty Plain Axis to get the curve right), see this page on how you can do that with your own model.

https://blender.stackexchange.com/questions/147404/how-to-bend-a-plane-bend-wont-bend

Hope that helps.

Took me quite some time, but I can confirm that Cyberreality's suggestion totally works! I had no idea this would consume a week of my off-time. It's a little disheartening that something that seems so simple can take so much time, but on the other hand ya'll made me feel better in that it seems to have turned out to be a somewhat complicated problem. TwistedTwigleg's UV didn't line up for me unfortunately. I'm super grateful for the help guys, this was way more direction than I possibly could have hoped for.

To get rigid bodies to follow the texture and move in a curved fashion, I used an Area with a box shape collider to track objects on the belt. I had to set the area's space-override property to "combine-replace" to keep objects from accelerating. The area seemed to mainly override gravity, but I needed a constant push on the objects instead of acceleration. During the area's physics process: 1. For each rigid body found in the area: 2. Find vector v from the conveyor's inner corner to the object. 3. Find the clockwise pointing tangent r vector from v. 4. Normalize r and multiply by belt speed. 5. Subtract from r the body's linear velocity. (to prevent acceleration) 6. Save the force to the body with the intended speed.

To prevent the object "popping" in speed when getting pushed by multiple conveyors, it only calls add_central_force with force f once per physics process. Once used, f is reset to 0,0,0. On adding a new force from a conveyor: 1. Set f to the new force if f is all zeros, else: 2. Ignore the new force if it is equal to f, else: 3. Add the forces together, normalize them, and multiply by the intended speed.

This worked out just fine and rigid bodies are pushed around the corners very smoothly. I mainly am posting all this in case someone down the line is curious, and in case my logic throws up red flags to a more experienced developer.

Those kinds of physics problems are always a tough nut to crack. Even lots of released games have issues with elevators and that sort of thing. Cool you figured it out.

2 months later

Along the topic of "How would you do conveyor belts". I'm curious if anyone has a better idea for a conveyor "overpass". With, of course, the added constraint that it has to be the same size (w*h) of the other grid conveyor components. I first thought of under and over ramps, but spheres would get stuck. I settled on this silly thing I call a flipper. It fits in the grid space and works hilariously enough. At high speeds though it fails completely. Also, hilariously, if a belt pushes objects to the wrong side it turns from a "flipper" into a "masher" mashing objects through the collider. It basically needs to allow two lanes to cross in the size shown with a orange line.

a year later