Lua Logo

An Optimization for Lua Scripts

Lua is a powerful, lightweight, scripting language, and is often used in video games due to fast execution and a short learning curve. World of Warcraft, Angry Birds and Mafia II all use Lua script. Today, Chief Scientist at ROBLOX, Erik Cassel, discusses a way to optimize Lua.

A Short Lesson

Any programming language has its little tricks for squeezing out better performance. Today, we will show you a way to make some Lua code faster. This guide is intended for more advanced scripting. I’ll also discuss the pro’s and con’s of code optimization.

Continue reading →

Dagger of Shattered Dimensions

Tech Note: Scripted tools and weapons

Dagger of Shattered DimensionsOur head gear programmer Deepak Chandrasekaran explains the steps that went into creating The Dagger of Shattered Dimensions.

The ROBLOX creative team meets regularly to plan new items for publication in the Catalog. Recently they were inspired to create an Arabian Nights collection which included a Flying Magic Carpet, Arabian Knight Scimitar, Magic LampDesert King hat, and the technically advanced Dagger of Shattered Dimensions. Once ideas have been selected, our team of 3D artists creates the item and hat models using Maya, Blender and 3DS Max.  The models are then delivered to the gear programmers.

Continue reading →

A Brief History of Physics in Video Games

Objects in the real world operate under the laws of physics – so it seems quite intuitive that everything in video games (console, PC, online, mobile, arcade) should as well. The graphics world has evolved towards hardware acceleration on dedicated chips with better and better realism. The physics world is a long ways behind. There aren’t many video games today (in fact there aren’t any!) where you can take out a hack saw, cut off a piece of metal from a scrap heap, weld it to your car, and then have the metal bend when your car wrecks! Today I will review some of the phases in video game physics here and talk a bit about the future. Continue reading →

ROBLOX Secrets Revealed: Fog Blog

RobloxApp 2011-12-09 14-03-21-24

A new ROBLOX release went out late last night. It contained a lot of important performance improvements, but it also included a secret feature that some ROBLOXians have already discovered… atmospheric fog!

How to Add Fog to Your Place

Currently our default is that fog is turned off in your place until you turn it on. Luckily, enabling fog in your place is super easy.

  1. Open you place in ROBLOX Studio (ROBLOX Studio Help)
  2. Select the Lighting service in the Explorer Pane
  3. Adjust the fog properties (there are 3 – to see something all you need to do is set FogEnd to 100. Now you have a ton of fog.)

FogSettings

What the properties do:

FogColor – This is the color of the fog. For best results, use light grey or the background color of your skybox.

FogEnd – This is the distance at which the scene is 100% fogged.

FogStart – This is the distance at which the fog begins. Inside this distance you will not see fog.

Fog Settings: Getting Technical

A lot of ROBLOXians out there are programmers, so for those of you who are curious, let’s get technical for a second. To remain compatible with older graphics cards that use a fixed-function rendering pipeline, ROBLOX’s fog uses linear interpolation between FogStart and FogEnd. Other fog falloff functions are possible if you are using shaders; some of these are show in the graph below. ROBLOX is using GL_LINEAR – the red line. FogStart on this graph is 10 and FogEnd is 20. At a distance of 15, fog is at 50%. This means that a pixel in your scene that is 15 distance from the camera will be 50% it’s normal color blended with 50% of the fog color.

graph

 

Fog Settings: Getting Artistic

Builderman, the ROBLOX client team, and I decided to expose the lowest level fog properties to users, allowing them maximum customizability in their places. We hope place builders will get really creative. Here’s one effect you can achieve if you make it night time in your place and set the fog color to black..

RobloxApp 2011-12-09 14-05-28-08

Dark levels can be really fun. I whipped up a quick demo based on the original Sword Fight on the Heights – check it out!

- Telamon

A Brief History of Physics in Video Games

Objects in the real world operate under the laws of physics – so it seems quite intuitive that everything in video games (console, PC, online, mobile, arcade) should as well. The graphics world has evolved towards hardware acceleration on dedicated chips with better and better realism. The physics world is a long ways behind. There aren’t many video games today (in fact there aren’t any!) where you can take out a hack saw, cut off a piece of metal from a scrap heap, weld it to your car, and then have the metal bend when your car wrecks! Today I will review some of the phases in video game physics here and talk a bit about the future.

Early Phase – Special Purpose Physics Engines

PONG

Because of limitations in computing power, early games that used physics were based on special purpose physics solvers. The first version of Pong used a physics engine that could only solve one thing – a white bouncing pixel!

Vehicle Physics

Early driving games had solid vehicle physics engines, but the rest of the environments were static. Special purpose physics engines could be found for character rag-doll effects, marbles in pinball and marble madness simulators, and space vehicle simulators in games like Asteroids or Lunar Lander.

Asteroids

Evolution of General Purpose Physics Environments

General purpose physics simulators offer the dream of environments where everything is physically simulated and any piece of the world can be taken apart, or put back together again.

General purpose simulators were first used in mechanical engineering. The only problem was they didn’t have user interfaces – all of the simulation objects and parameters had to be entered as text! One of the more popular mechanical simulators is ADAMS  – here’s a video of it in action.

In the graphics community, a pivotal paper was written by David Barraff describing a general purpose rigid body collision and contact simulator. Here are some pictures from early simulations that were presented as SIGGRAPH papers. For those that are interested, here is some of the math behind rigid body simulation.

One of the first general purpose physics simulators integrated with an intuitive user interface was a program I wrote called Interactive Physics back in 1989.

Interactive Physics

Interactive Physics was a 2d simulated physics laboratory originally written for the Macintosh Plus. Users could drag parts, hinges, ropes, and springs to create and measure physics experiments. The simulator in Interactive Physics was so good that many problems in physics textbooks could be modeled and the answers would compare with analytic solutions. Interactive Physics was translated to nine languages and sold millions of copies.

Here’s a video of a simple Jack-in-the-Box made with Interactive Physics more than 10 years ago.

After creating Interactive Physics, Knowledge Revolution went on build a 3D simulator called Working Model. Working Model could simulate complex mechanical devices like motorcycles or copy machines, and it went on to become a volume leader in mechanical engineering simulation.

Working Model

An early general purpose physics simulator in video games was the simple 2D ballistics simulator (without rotation) in the game Incredible Machine, where some of the objects would fly or bounce against other objects in the environment.

Incredible Machine

The Future – Everything is a General Purpose Physics Environment

Just as most video games today use a general purpose graphics engine, in the future all video games will be based on general purpose physics simulators. This is the dream of ROBLOX, where every piece of the game participates in physics simulation. The big chasm all games will cross is an evolution from “some” parts being physically simulated, to “all parts” being physically simulated.

Today you can find many 2D games built on general purpose simulators. Angry Birds is based on a general purpose 2D physics engine.

Angry Birds

Kudos here to Erin Catto who wrote the open source 2d physics simulator that Angry Birds uses.

You can find 1000’s of casual 2D physics games online. On the PS3, the 3D game Little Big Planet uses the cell processor to simulate graphics and physics, providing intuitive physically simulated worlds.

ROBLOX is built on a general purpose physics simulator that is designed to scale to thousands and thousands of parts. Here is a demo created by Telamon of the ROBLOX physics engine in action right after we first released ROBLOX.

General purpose physics simulation takes enormous computing resources. It’s very exciting to see more and more ROBLOXians with two and now four core CPU’s. We will soon fully harvest these computing resources, resulting in realistic simulation of thousands of characters, vehicles, buildings, airplanes, and of course, explosions!

David Baszucki – Founder and CEO of ROBLOX (“Builderman”)

Personal Build Servers Running Hot

The overwhelming success of personal build servers is evident – more than 200 of them are running on ROBLOX as I write this.

ROBLOXians in these servers are building so much stuff it is pushing the limits of ROBLOX to the max and beyond.

The ROBLOX team has identified an issue that will prevent personal servers with a ton of blocks from saving – things start to get shaky around 20,000-25,000 parts. Places above this size may not save correctly. You may lose work. As such Personal Servers should be considered a Beta feature at this point. We’re going to leave them on for users to experiment with.

For techies, the problem we are encountering seems to be related to the fact that the ROBLOX server is a 32 bit process. This means it can address 4 GB of RAM (2^32 bytes). Depending on the OS, half of that is usually reserved for system allocations, leaving 2 GB for user memory. We’re finding that personal servers fit within this memory envelope of 2 GB with up to 36,000 parts. However, the additional memory required to persist these places to disk fails to allocate and the save operation does not complete. There are several things we can work on to fix this issue – most of which will make ROBLOX run faster in general and are a huge win for our players. We will start attacking these next week.

Our ultimate vision has always been having 100 players building in a level that supports millions of parts. We will get there. It’s going to be a wild ride.

- Telamon