GeneRacing – Surfaces will be detected in 2 different ways:
- Detection for surface will be defined on an object. A stone, an ice-plate, a curb (as an object), a tyre or whatever could have custom “surface parameters”
- The affected pixel-color will be defined by a special surface parameters
Both ways in detail:
1. Object surfaces
Every object can hold a custom configuration of surface parameters which effect the car directly if a collission between those are detected. Therefore its possible to give every object an different surface behaviour, which is at the moment not open or configurable.
2. Pixel detection
To enable the maximum of compatibility for textures, we decided to use pixel detection instead of layer-detection for the first. Its possible to integrate texture-layer detection too, its prepared but not used yet. To enable a usage of external textures, like photoshop drawned textures, its the suitable way of doing.
How does it work?
Every frame the car will check, if its on ground, the existing texture on the surface, read the pixels around the center point and store it for a further process.
Depending on the texture resolution the area for detection is slightly different because of an other detail grade.
The car receive now, each frame, following info:
1st: the center pixel color
2nd: all surrounding pixels, to ensure a stability of color and avoid pixel spots
3rd: the average color of all detected pixels
The result is a RGB-Color for the average of all detected colors in Format: RGB(0,0,0,0) which results in the format: RGB(red,green,blue,alpha).
This average color will be compared now with a pre-defined list of colors, which is:
//grey
Color(38 / 255f, 38 / 255f, 38 / 255f, 255);
Color(124 / 255f, 124 / 255f, 124 / 255f, 255);
Color(185 / 255f, 185 / 255f, 185 / 255f, 255); //#B9B9B9FF
Color(224 / 255f, 224 / 255f, 224 / 255f, 255); //E0E0E0FF
Color(230 / 255f, 230 / 255f, 230 / 255f, 255);
Color(73 / 255f, 74 / 255f, 83 / 255f, 255); //rgb(73, 74, 83) / 494A53FF
//black
Color(0 / 255f, 0 / 255f, 0 / 255f, 255);
Color(8 / 255f, 8 / 255f, 8 / 255f, 255);
Color(16 / 255f, 16 / 255f, 16 / 255f, 255); //101010FF
//white
Color(248 / 255f, 248 / 255f, 248 / 255f, 255); //F8F8F8FF
Color(255 / 255f, 255 / 255f, 255 / 255f, 255);
//green
Color(200 / 255f, 255 / 255f, 200 / 255f, 255);
Color(0 / 255f, 255 / 255f, 0 / 255f, 255);
Color(0 / 255f, 102 / 255f, 0 / 255f, 255);
Color(89 / 255f, 119 / 255f, 29 / 255f, 255);
Color(95 / 255f, 134 / 255f, 43 / 255f, 255);
Color(130 / 255f, 159 / 255f, 68 / 255f, 255); //#829F44FF
//SandGrass
Color(190 / 255f, 200 / 255f, 128 / 255f, 255);
//Sand
Color(230 / 255f, 223 / 255f, 203 / 255f, 255);
Color(197 / 255f, 180 / 255f, 135 / 255f, 255); //#C5B487FF
Color(222 / 255f, 212 / 255f, 186 / 255f, 255); //#ded4ba
Color(149 / 255f, 140 / 255f, 100 / 255f, 255); //#958c64
Color(200 / 255f, 158 / 255f, 121 / 255f, 255); //#C89E79FF – rgb(200, 158, 121)
Color(236 / 255f, 208 / 255f, 169 / 255f, 255); //ECD0A9FF
Color(218 / 255f, 188 / 255f, 149 / 255f, 255); //DABC95FF
//Snow
Color(251 / 255f, 251 / 255f, 251 / 255f, 255); //FBFBFBFF
Color(251 / 255f, 251 / 255f, 251 / 255f, 255);
Color(255 / 255f, 250 / 255f, 250 / 255f, 255);
Color(222 / 255f, 212 / 255f, 186 / 255f, 255);
Color(225 / 255f, 224 / 255f, 241 / 255f, 255); //rgb(225, 224, 241)
Color(236 / 255f, 235 / 255f, 253 / 255f, 255); //rgb(236, 235, 253) ECEBFDFF
Color(246 / 255f, 246 / 255f, 254 / 255f, 255); //F6F6FEFF
//curbs – red
Color(184 / 255f, 71 / 255f, 77 / 255f, 255);
Color(255 / 255f, 0 / 255f, 0 / 255f, 255);
Color(225 / 255f, 112 / 255f, 77 / 255f, 255);
Color(225 / 255f, 0/ 255f, 0/ 255f, 255); //pure red, #E10000FF
//yellow
Color(236 / 255f, 238 / 255f, 76 / 255f, 255); //#ECEE4CFF
The clostest average color to this list, is the result and will be taken place for the stored surface parameters behind.
Surface Parameters:
At the moment, the physics values could be adjusted with modifiers at runtime while detection the current surface under the car.
The existing parameters are:
steeringMultiplier = 1f;
accelerationMultiplier = 1f;
speedMultiplier = 1f;
forwardFrictionMultiplier = 1f;
lateralFrictionMultiplier = 1f;
Every main-color, from the list, and every object could have a different parameter-set to adjust the physics to a more realistic behaviour.
Status: 05.03.2021 / Version: 0.0.7j
Current surface parameters
Curb
steeringMultiplier = 1f;
accelerationMultiplier = 1f;
speedMultiplier = 1f;
forwardFrictionMultiplier = 1.05f;
lateralFrictionMultiplier = 1.3f;
Sand
steeringMultiplier = 0.8f;
accelerationMultiplier = 0.2f;
speedMultiplier = 0.8f;
forwardFrictionMultiplier = 0.4f;
lateralFrictionMultiplier = 0.4f;
Grass
steeringMultiplier = 0.8f;
accelerationMultiplier = 0.7f;
speedMultiplier = 0.8f;
forwardFrictionMultiplier = 0.5f;
lateralFrictionMultiplier = 0.5f;
Tarmac
steeringMultiplier = 1.1f;
accelerationMultiplier = 1.1f;
speedMultiplier = 1.1f;
forwardFrictionMultiplier = 1f;
lateralFrictionMultiplier = 1.1f;
Bright Tarmac
steeringMultiplier = 1f;
accelerationMultiplier = 1f;
speedMultiplier = 1f;
forwardFrictionMultiplier = 1f;
lateralFrictionMultiplier = 1f;
White
steeringMultiplier = 1f;
accelerationMultiplier = 1f;
speedMultiplier = 1f;
forwardFrictionMultiplier = 1f;
lateralFrictionMultiplier = 1f;
Yellow
steeringMultiplier = 1f;
accelerationMultiplier = 1f;
speedMultiplier = 1f;
forwardFrictionMultiplier = 1f;
lateralFrictionMultiplier = 1f;
Oil
steeringMultiplier = 1.5f;
accelerationMultiplier = 0.3f;
speedMultiplier = 0.2f;
forwardFrictionMultiplier = 1f;
lateralFrictionMultiplier = 1.4f;
Snow
steeringMultiplier = 0.8f;
accelerationMultiplier = 0.5f;
speedMultiplier = 0.5f;
forwardFrictionMultiplier = 0.8f;
lateralFrictionMultiplier = 0.2f;
default:
steeringMultiplier = 1f;
accelerationMultiplier = 1f;
speedMultiplier = 1f;
forwardFrictionMultiplier = 1f;
lateralFrictionMultiplier = 1f;
Leave A Comment
You must be logged in to post a comment.