HelloRacer Unity

HelloRacer Unity

Our first piece for the Unity Web Player is called HelloRacer Unity and follows the racing tradition that started almost three years ago and still lives in my personal website carlosulloa.com.

We began playing with Unity during the summer with the intention of building iPhone apps. We released HelloRacer iPhone and had a lot of fun in the process, so we decided to dedicate a bit of time to the web player.

The Unity Web Player is the most powerful 3D platform we’ve worked on, and it certainly was a challenge to make good use of it. We focused our work on building a highly detailed experience, paying particular attention to the shaders and the physics.

We have found the Unity Web Player an excellent option for high-end 3D in the browser. While plug-in adoption is still very low, the quality of the experiences make installation worthwhile for most users. We don’t believe interactive 3D is just for games, as it has so much potential in other fields such as data visualization and advertising.

Shaders

We used separate materials for the different surfaces of the car. Body matte, body shinny, brake light, brake light glass, decals, driver, front light, interior, steering wheel, vents and windows are individually recreated with distinct textures and shaders.

While Unity comes with a great library of shaders, we chose to develop custom versions to achieve the look we wanted with a maximum performance. This approach also enabled us to create specific shaders for the reflection as simpler and faster variations of the originals.

Shader programming is incredibly powerful and gives the developer precise control of how each pixel is rendered.

We also have three shadows, one for the car and rear wheels, and a separate shadow for each front wheel. From a geometric point of view, they are planes positioned at ground level, but their texture is what makes a difference. Baked in Maya using ambient occlusion, the shadows are subtle, but serve to add depth to the scene.

Racing Physics

Unity includes the powerful PhysX physics engine, but to achieve a realistic experience you need to understand the forces involved in your simulation.

Just as it happens in real life, the weight distribution of a car determines its handling. The weight is divided between each of the four wheels, but this distribution varies as the driver accelerates, brakes and turns. For example, when braking the weight is shifted to the front wheels.

Finding the ideal center of gravity is necessary to create a realistic racing simulation. Front-heavy cars tend to understeer and rear-heavy cars to oversteer, but most important is the center of gravity height, relative to the track, that determines load transfer from side to side.

When cornering, centrifugal force acts at the center of gravity to lean the car toward the outside of the curve, increasing downward force on the outside tires. Sport car designers aim for a low center of gravity to minimize the load transfer from side to side and maximize grip.

Tyre friction and slip are another relationship to understand when adjusting vehicle dynamics. The overall friction force is usually separated into a forward component (to accelerate and brake) and a lateral component (to steer the car). In both directions, when the force acting at the tyre exceeds the grip limit, the wheel starts to spin or slide.

Since cars behave differently at different speeds, it’s necessary to monitor the vehicle’s velocity and adjust the physics parameters accordingly. A dynamic setup improves handling in a similar way as electronics are used to enhance the safety of road cars.

If you are interested in the subject, I would recommend reading the Physics of Racing Series by Brian Beckman. Even if you are not going to write your own racing engine, I always find very helpful to understand how it works.

15 Comments

  1. The quality of helloRacer is amazing. This give me inspiration to learn more about shaders. Thanks for share your experience.

  2. diamondTearz

    Amazing work! I love the reflection of the car off the ground and the cuteness of the car as well as the handling. Thanks for sharing your learning resources with us as well!

  3. Hi, would be nice to know how may polys you´re using? Is antialiasing activated? Thanks for the infos..joe

  4. Awesomeness! Very cool to see all the little details that you guys put into it. I need to set aside time to look into Unity over the holiday.

  5. Really nice and smooth, though I think that ask to the user to download an extra plugin it’s a big limitation…

  6. Holy christ, that’s some plugin you’ve got there! Beautiful, and those physics! You’re definitely going to make it with this

  7. thank you very very more realtime CAR UNITY REALISTIC

  8. Please can you tell me which version of unity did you make this, 2.5 or 2.6?

    I am running vista64x and its really glitchy on there.

    On vista86x and windows7 64x it purrs.

    Beautiful.

  9. It was initially created in Unity Indie 2.5, but recompiled later on 2.6 Pro.

  10. Great project! I wrote a couple of lines about it on my blog :)

  11. So Smooth and bling ;) I just decided to learn unity because of this demo ,albeit Im uneducated in regards to customizing shaders etc.. I have put forward a request at our agency to get the unity book ordered on amazon.

Trackbacks/Pingbacks

  1. [...] HelloRacer Unity: Our first piece for the Unity Web Player and the most technically advanced I’ve produced to date. [...]

  2. [...] own impressive Far Cry style tech demo I would have to say that my favorite right now has to be the HelloRacer demo from Carlos Ulloa of HelloEnjoy and Papervision3D. The quality of the graphics and the realism and [...]

  3. [...] Cars and driving games have been a hot topic recently,espescially with all of the Hello Racer buzz. [...]

Leave a Comment