Changing shape of a 3D node projected into 2D while maintaining relative size

Godot Version

Godot 4.5.1

Question

Hi there, I’m pretty new to Godot (but not to programming in general) and I’ve run into a roadblock that I haven’t been able to overcome so far. I’m creating a Transport Tycoon-esque game, and my game objects are 3D models projected into isometric 2D. That part is fine, I’ve got that working based on a Camera3D pointing to a SubViewport. But I’d like my railroad tracks to follow arbitrary paths (rather than being based on individual sprites or a grid) and that’s presented me an issue because it means that when the tracks get longer they can expand outside of the bounds of the camera. The obvious answer is to grow the camera size, but when I do that the projection of the tracks appears to shrink in the other dimension (because the other axis is remaining a constant size within a larger camera, so it appears smaller). Here are some screenshots to show what I mean:

Here’s the setup for my base track visuals. Eventually the camera will be pointed at them at an angle, but I’m keeping it straight down for now for simplicity’s sake:

And here’s what the projection looks like without any modifications:

Here’s that same scene at the same zoom level, but with the path extended rightward and the camera scaled to fit the new track. As you can see, the width of the tracks is narrower than it was previously:

And here’s that same thing represented in 3D, where it’s easier to see the issue:

A couple of potential solutions I’ve thought of/tried and why they didn’t work:

  • Scale the SubViewport size proportionally with the camera - fixes the uneven scaling, but causes the tracks to appear very very small because they take up such a relatively small space in the viewport
  • Same as above but also scale the mesh in the opposite axis - can’t do it, scaling the mesh itself is not supported by Godot as far as I’ve found
  • Use a custom projection on the camera to exactly fit the tracks - also unsupported by Godot

I feel like there’s gotta be a solution out there, but at this point I’m getting stumped on what it could be. Does anybody have any ideas on how I could do this? Thank you!

Make the whole game 3d. Render with ortho camera.

I wanted to avoid that so I could keep the groundwork I’ve already done in 2D, but maybe that really is the best solution lol

If I understood your setup correctly, you could compensate by adapting the viewport resolution to track’s bounding box. That’d also require scaling the texture rect that displays the texture accordingly. This is technically bad though. If your tracks bounding box can get arbitrarily large, you’ll hit the hardware texture size limit sooner or later.