Jump to content
  • entries
    943
  • comments
    5,899
  • views
    924,416

Turbo Game Engine Beta Update


Josh

5,235 views

 Share

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.

  • Like 2
  • Thanks 1
  • Sad 1
 Share

10 Comments


Recommended Comments

8 minutes ago, Thirsty Panther said:

So will Leadwerks 4.6 be the final version of Leadwerks?

Aside from bug fixes, probably. At least, I don't have any other features planned after that.

  • Like 1
Link to comment

I would really like to see some Portalesque VR game by spring! :D I'm not sure if I am getting a GDC booth this year but if I do that is something I would like to showcase.

Link to comment
54 minutes ago, Josh said:

I would really like to see some Portalesque VR game by spring! :D I'm not sure if I am getting a GDC booth this year but if I do that is something I would like to showcase.

My plan was to port Vectronic to Turbo. I still have to work on the assets and if you can get physics in, we can work something out. 

Link to comment

Yeah, that other project you posted would be pretty interesting too, but if you got stuck on the up/down cycle it would be instant puking for VR! :D

Link to comment

Oh the platforms? Yeah it's possible to do but idk most people would be able to stomach it, probably not worth the effort. I would just make the platforms enable a teleport path upward. 

Since scripting is now in the engine, I might experiment with porting my existing system in. The ball shooting stuff should work well in VR

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...