Leadwerks Engine 2.3 has been released. This major update includes a new editor, Lua script integration, forest rendering, roads, and more.
Lua Script Integration: Write object scripts and write your game in any programming language, or you can write your entire game in Lua.
New Editor: Leadwerks Editor is our new tool for creating enormous terrains, placing objects, and creating worlds. You can even edit scripts and see the results instantly.
Forest Rendering: An advanced new rendering algorithm makes it possible to render hundreds of thousands of trees and plants, at playable framerates. Make dense forests that stretch for miles.
Roads: Build spline-based roads and paths in the editor. Roads can branch, stretch, and fade out. You can even go for a drive on your highways and byways in the editor.
Terrain Holes: Remove patches of terrain and go underground with caves and bunkers. This feature brings a new subterranean dimension to your games.
High Dynamic Range (HDR): Brights are brighter, and darkness is darker. High dynamic range allows a greater range of color to be displayed, with automatic iris adjustment to correct for the ambient lighting environment.
Animation Improvements: Characters can have up to 256 bones, with fast hardware skinning performed on the graphics card.
Rendering Framework: It's easy to toggle advanced effects on and off, in any combination, with commands like SetBloom() and SetHDR().
Like many programmers, I used to consider scripting languages to be a "toy": They are nice and easy to use, but ultimately I thought it was just programming for people who don't want to install Visual Studio. I started playing with Lua back in June of 2009, and the potential for this wonderful language quickly became apparent. Our integration of Lua allows script to be written on both a global and per-object basis; You can write your entire program in Lua, like you would with C++ or another language, or you can write a script specifically for one object class, with different predefined functions to be called during the program. There are functions that can be called when an object hits something, when it is created, or once every frame to update the object. Object scripts can be used together with C++ or another programming language. This means that anyone who uses Leadwerks Engine, with any language, can download a scripted object, drop it into their program, and have the same behavior working in their own game. The implications of this are immense.
Suddenly we found that instead of being a collection of a few hundred individual programmers, the community suddenly became a collaborative, collective group. If one developer writes a script for a scary monster and posts it online, another user can download it, drop it into the editor, and see the results, with no code changes. You can even edit the script in Leadwerks Editor, save it, and instantly see the results. For the first time, developers could easily work together and share their creations, and still use whatever programming language they preferred. Lua has changed the whole feel of the community to a more social and cooperative group.
Keeping it Real-time
Our design philosophy for Leadwerks Engine is that everything should run in real-time, and thus be editable in real-time. Lighting and physics are already editable in real-time with instant feedback, but it took some time before I realized we can extend this approach to something else: programming. The new editor has an integrated script editor. To edit an object's script, you simply double-click on its node in the scene tree. You can view all the code that makes the object to whatever it is doing. You can also make changes to the script, save it, and the object's behavior is instantly updated! The lack of a compiling phase allows you to fine-tune behavior to get it just the way you want. Plus, it's a just lot of fun to use. For an in-depth description of our Lua implementation, see here:
The Road to Perfection
Roads look nice, but the reason I really like them is they allow new dimensions of gameplay. When I started off writing the road editor, I had a few requirements. I wanted the roads to be written entirely with Lua object scripts. This was a challenge, and forced me to add several features to the script integration to make it work. I also wanted roads that aligned perfectly to the terrain, like they do in Crysis. First I wrote the mesh generation routine that makes a spline-based road. This is fairly simple, but it is only part of the problem. The biggest challenge was slicing the road up by the terrain grid, so that every vertex on the road lined up along the terrain, and the whole road lay perfectly snug. UV mapping the tessellated road was another major challenge, but a clever solution was found after many attempts. The resulting roads look great and conform perfectly to the terrain. And they're fun to go driving on!
Seeing the Forest for the Trees
The forest rendering algorithm is my favorite new rendering feature. The bulk of this was written in the spring of last year, but there were a few details I didn't complete until recently. I spent hours playing with the Crysis editor and trying to figure out how they heck they were able to render so much foliage. I read article after article, but no one seemed to have a good approach. Most of the forum discussions on graphics development sites seemed to amount to just saying "use billboards". The problem is that rendering 100,000 billboards is still a major challenge. The solution was found by analyzing what format data the GPU will render most efficiently, and then working backwards to find a way to get the vegetation in that format. The solution is elegant, and seamless to the end user. There's no baking or pre-processing. You paint as many trees and plants on the terrain as you want, and it just works. I still have some more ideas to implement, like destructable trees and even better efficiency, but I am quite happy with how it turned out.