0
\$\begingroup\$

I'm aiming to make a racing game in Unity. Please take a look at the image provided below, and suggest me the best technique to achieve something like it. (Keeping the performance as optimized as possible)

enter image description here

How I'd do it:- Make a large model in blender, texture it inside a software like Substance Painter, then import it into unity with one texture.

Problem with my method:- The model will be destructive, means it'll be really hard to make changes to it once I'm done texturing. Secondly, It'll likely have very large resolution (4k or 8k) which is not desirable for mobile devices (what I'm aiming for).

Solution I can think of:- I can think of having the road divided into small pieces, but I just can't figure out how will I join them together? While still keeping the surrounding environment in sync. Thanks.

\$\endgroup\$
6
  • \$\begingroup\$ You could create your road with a mix of curves and splines and add a mesh afterwards to it, there are a lot of tutorals for that or editor extensions (plus the already stuff that is there) \$\endgroup\$
    – Zibelas
    Jan 19, 2022 at 13:27
  • \$\begingroup\$ There is no best technique. Only the technique which works best for you and your project. There is a rather new feature in Unity called splines. Perhaps that can help you? \$\endgroup\$
    – Philipp
    Jan 19, 2022 at 13:31
  • \$\begingroup\$ Thanks a lot guys, I'll look into splines. \$\endgroup\$
    – Haseeb Ali
    Jan 19, 2022 at 13:33
  • \$\begingroup\$ @HaseebAli Don't thank me too early. Splines just by themselves are just invisible bezier curves you can draw in the editor. It's up to you to create your own tools which make use of that curve data. \$\endgroup\$
    – Philipp
    Jan 19, 2022 at 13:55
  • \$\begingroup\$ github.com/vvrvvd/Unity-Spline-Editor looks like a start, there are a lot of assets as well that do exactly what you describe. And it will make it easier to make changes to a created track already \$\endgroup\$
    – Zibelas
    Jan 19, 2022 at 14:48

1 Answer 1

0
\$\begingroup\$

This is an answer about how not to do it. Don't make the whole track as a single mesh.

I worked on a racing game for mobile a few years ago where the artist had faced a similar dilemma. The tracks themselves were offroad courses made with Unity's terrain feature, but each track had a barrier around it that the artist made as a single large mesh.

The problem with using a single large mesh is that the engine can't perform frustum culling. Frustum culling is when the engine skips rendering an object that is not within the camera view. This is one of the most basic ways that 3D engines are optimized for performance - there's no point in rendering anything that isn't visible on screen.

At least some part of the barrier was on-screen at all times. Because it was all a single mesh, the engine couldn't perform any frustum culling, so it was always rendering the entire barrier, which was typically several hundred thousand polygons. This was enough to severely impact framerate on low-end and mid-range mobile devices.

Another common optimization that doesn't work with large meshes is Level of Detail (LOD) models. If your entire track or barrier is one mesh, the player will always be near some part of the mesh, so you can't use lower-polygon LOD models for distant parts of the track.

Building your track, and other parts like barriers, in pieces allows you to take advantage of frustum culling and LOD models for maximum performance.

As for texturing, I think generally you create textures that cover a small section of the track and tile these across the track. Here's a very simple, sloppy example: Very sloppy example of road with tiled texture

You may need variations for turns or to prevent the texture from looking too repetitive. Details such as skid marks and oil slicks can be added with decals as another way to prevent the road from looking repetitive.

\$\endgroup\$
1
  • \$\begingroup\$ Excellent answer, I didn't think about that Frustum culling, thanks for the heads up. \$\endgroup\$
    – Haseeb Ali
    Jan 21, 2022 at 20:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .