Turbo Game Engine Beta Update
A big update for the beta of the upcoming Turbo Game Engine is now available, adding support for VR and Lua script!
VR Rendering
Turbo Game Engine now supports VR rendering, with support for true single-pass stereoscopic rendering on Nvidia GPUs. Other hardware will use a double-rendering path that is still faster than Leadwerks. To turn VR on simply call EnableVR(). Controllers are not yet supported, just rendering.
Lua Scripting
Lua script is now supported in Turbo! The amount of classes and functions is limited, but the foundation for full Lua support is in. Here are some of the great features in the new system.
No Script Object
All scripts operate on the entity itself. Instead of this:
function Script:Update() self.entity:Turn(1,0,0) end
You type this:
function Object:Update() self:Turn(1,0,0) end
This is especially nice when it comes to functions that retrieve another entity since you don't have to type "entity.script" to get Lua values and functions:
function Object:Collision(entity,position,normal,speed) entity:Kill() end
Smart Pointers
Lua garbage collection now works together with C++11 smart pointers. You will never have to deal with invalid pointers or object deletion again. There is no Release() anymore. Just set your variable to nil to delete an object:
local box = CreateBox(world) box = nil
If you want the object to be collected immediately, you can force a GC step like this:
local box = CreateBox(world) box = nil collectgarbage()
Best of all, because Lua runs on the game logic thread separate from the rendering thread, it's perfectly fine to use Lua high-performance applications, even in VR. A pause in the game execution for Lua garbage collection will not pause the rendering thread.
Multiple Scripts
You can add any number of scripts to an object with the AddScript command:
entity->AddScript("Scripts/Object/test.lua")
Scripts on Any Object (Experimental)
Now all object types can have scripts, not just entities:
material->AddScript("Scripts/Object/Appearance/Pulse.lua")
Set and Get Script Values in C++
You can easily set and get values on any object, whether or not it has had a script added to it:
entity->SetValue("health",100); Print(entity->GetNumberValue("health"));
Vector Swizzle
Using getters and setters I was able to implement vector swizzles. If you write shaders with GLSL you will be familiar with this convenient feature:
local a = Vec3(1,2,3) local b = a.xz --equivalent to Vec2(a.x,a.z)
In Lua you can now return any combination of vector elements, using the XYZW or RGBA names. The code below will swap the red and blue elements of a color:
local color = Vec4(1,0,0.5,1) local color = color.bgra
Not only can you retrieve a value, but you can assign values using the swizzle:
local v = Vec3(1,2,3) v.zy = Vec2(1,2) Print(v) --prints 1,2,1
Note there are presently only two engine script hooks that get called, Start() and Update().
Simpler Uber Shaders
I decided to do away with the complicated #ifdef macros in the shaders and use if statements within a single shader:
//Diffuse Texture if (texturebound[0]) { color *= texture(texture0,texcoords0); }
This makes internal shader management MUCH simpler because I don't have to load 64 variations of each shader. I am not sure yet, but I suspect modern GPUs will handle the branching logic with no performance penalty. It also means you can do things like have a material with just a color and normal map, with no need for a diffuse map. The shader will just adjust to whatever textures are present.
A C++ Turbo program now looks like this:
#include "Turbo.h" using namespace Turbo; int main(int argc, const char *argv[]) { //Create a window auto window = CreateWindow("MyGame", 0, 0, 1280, 720); //Create a rendering context auto context = CreateContext(window); //Create the world auto world = CreateWorld(); //This only affects reflections at this time world->SetSkybox("Models/Damaged Helmet/papermill.tex"); shared_ptr<Camera> camera; auto scene = LoadScene(world, "Maps/start.map"); //Create a camera if one was not found if (camera == nullptr) { camera = CreateCamera(world); camera->Move(0, 1, -2); } //Set background color camera->SetClearColor(0.15); //Enable camera free look and hide mouse camera->SetFreeLookMode(true); window->HideMouse(); while (window->KeyHit(KEY_ESCAPE) == false and window->Closed() == false) { //Camera movement if (window->KeyDown(KEY_A)) camera->Move(-0.1, 0, 0); if (window->KeyDown(KEY_D)) camera->Move(0.1, 0, 0); if (window->KeyDown(KEY_W)) camera->Move(0, 0, 0.1); if (window->KeyDown(KEY_S)) camera->Move(0, 0, -0.1); //Update the world world->Update(); //Render the world world->Render(context); } return 0; }
If you would like to try out the new engine and give feedback during development, you can get access now for just $5 a month.
I am now going to turn my attention to Leadwerks 4.6 and getting that ready for the Christmas season.
The next step in Turbo development will probably be physics, because once that is working we will have a usable game engine.
- 2
- 1
- 1
10 Comments
Recommended Comments