Thursday, January 6, 2022

Idea: Procedural Stage Generator

Introduction:

Rather than making an individual stage, I model a large area and procedurally connect random start and finish points to make stages.

The end goal is to have a large library of RBR stages that can be pulled up at random.


E.g. A tournament is using my stage "HEUVELLAND". The members competing have no idea what the actual route will look like, it is chosen at random from the library of various stages made with procedural routes. This lightens the competitive nature of the game and allows for casual and serious players to compete on a slightly more level playing field.


This may be an idea that deserves implementation BEYOND rbr. Perhaps my own game?

I'm not nearly experienced enough as a developer to take on a task like that right now, however. I will continue forward making the RBR arena stage. I need to come up with a better name than that.

Below are some days of testing this idea:

1-6-22: Test 1

To save some time making the setting I had an idea to procedurally generate terrain, houses, and roads.

Generate a large area using the following methodology:
  • Generate some random terrain (later maybe use LIDAR data)
  • Vertex paint the desired population density
  • Geometry nodes do the following:
    • distribute points according to density map
    • connect the points at also according to density map
      • fully painted areas are cities, all cities can only be connected by 1 line
    • smooth the curves and use array modifier to put roads along the paths
    • place houses and other objects along the road according to density map

Test 1 was unsuccessful due to the limited implementation of geometry nodes in blender at the moment, which is what I half expected.

I have done some research into areas that would be good for this, I would like to do something similar to the Czech stages, they really are the most memorable stages and I love the setting. Many of them consist of doing some wacky turns through a small town, then taking a narrow, poorly-maintained, link road at 200kmh to another small town to do some more wacky turns. It really is great fun, challenging, and consistently good. I've decided to go with an approximately 10 sq km area of Belgium used in the Ypres Rally Belgium

I think a big part of the memorability of these stages is how well they're made, I will have to keep this in mind as I embark on this project.

I would really like to use this project to familiarize myself further with the stage creation process, efficient workflows, and techniques to make a beautiful stage. With the blender tools being developed for RBR modders it is possible to make stages that look great and are engaging. If I'm going to put the work in I don't want to half-ass it.


That's all for now, I'll check back in with some updates on a setting I've chosen.

1-9-22: Test 2

Today I evaluated the 1m accurate lidar data I got from the Flanders government. Super cool! I've never worked with point clouds this big before and I crashed blender and cloud compare quite a few times.

Ultimately I ended up importing the geotiff into QGIS, filtering out the extra data, saving it as a geotiff, and loading it into blender with the GIS addon. I did have to make sure that I imported it with the proper Belge-Lambert 1972 projection, and covert it to the Web-Geodata projection.

Some progress picture of my work with the "A" region of Heuvelland:


This is the area I've decided to look at, the "road" as shown on the map are 30m wide segments that will eventually become the "near geometry" in a RBR stage.

Before jumping into any serious modelling endeavors I want to explore some procedurally generated routes first. I would like to explore 2 options for route generation:

  • A to B - path finding
    • Place a point at random (with some exceptions) on a road anywhere on the map.
      • This is the start line
    • Place a second random point (with some different exceptions) on a road anywhere on the map.
      • This is the finish line
    • Given parameters "Length" and "curviness" find routes that go from A to B and approximately fit those requirements
    • Each junction is given a unique name, as is each road that links junction to junction.
      • Each road has characteristics "Length" and "Curviness"
      • Each road will also have predefined pacenotes
    • Find all paths that connect the two points and meet the parameters given some margin for error 
      • e.g. length and curviness parameters will have say a +/- 10% margin

  • A until B - natural growth
    • Place a point at random (with some exceptions) on a road anywhere on the map.
      • This is the start line
    • Each junction is given a unique name, as is each road that links junction to junction.
      • Each road has characteristics "Length" and "Curviness"
      • Each road will also have predefined pacenotes
    • Given this starting point, find all routes that match the length requirement with no double backing or crossing
    • Filter out any routes that don't meet the curviness requirement (+/- 10%)
    • If there are multiple routes that meet the requirements, choose one at random

I'd like to do some programming in python to see if this is semi-feasible within blender. I don't think it should be horribly complex, but still, I want to see if this is a viable option before modelling like 7 square km of Belgium.

That's all for now!

1-16-22: Procedural Stage Generator

1. Using Rallymaps.com I created a map based on roads used in stages from the Ypres Rally Belgium and recreated the map in Blender.





2. From this network I made a spreadsheet with information about the roads
    • The spreadsheet has 2 pages each with specific information
      • Junctions
        • list of roads connected to the junction
        • junction index
      • Roads
        • list of junctions at each end of the road
        • road's length in km
        • road index

3. I then wrote a program in python that would generate routes given a random start and desired length:
  • See the program and files here

4. Next, I added a few parameters that allowed the code to run in blender and generate routes. Below are a few examples of some 5km generated stage routes. open in new tab to see full resolution.




This is where I am right now, below are my thoughts on what I'd like to do moving forward:



Next Steps:
  • Given the route generated from the python script, blender needs to create a Driveline object that 
    • Each road will have a set of pre-written pacenotes and a collection of "Near Geometry" that will be revealed when the road is added to the stage route

  • With this a large number of random stages can be created with relative ease. Much like some of the Czech stages use different routes within a similar arena / collection of roads. Or similar to how stages in the DIRT games take place in the same location and use the same roads. This method however can produce much more variety.

  • I can see the ability to generate random stages being useful in two ways:
    • Option A: 1 or 2 stages exist for tournament play
      • e.g. a "Long" and "Short" version
      • When selecting the stage, RBR randomly selects a stage from a list of pre-generated routes.
        • A script that executes when the stage is selected assigns the randomly selected stage to the game in the tracksettings.ini (or whichever file allows you to change stage access)
      • This introduces a level of randomness and prevents drivers from completely memorizing and treating the stage like a "Hill-Climb"
    • Option B: Many normal stages
      • This method could also just be an easy way to generate a few interesting routes across the same area

This is where I can see the idea going in the future. That being said it still is very early and not necessarily something I can fully commit to at the moment. I would like to return to this idea when I have more skills modelling stages.

Shane

No comments:

Post a Comment

About Me

Hi! my name is Shane Howell. I'm a mechanical engineering / music double-major student studying at Western Michigan University in the US...