guest    Login  Signup

search 

home news about media forums community download
Forums . Development Blogs . Technical Blog #2 - A New Rendering Pipeline

Development Blogs

Design and Technical Posts from the Development Team

Currently: 8 Topics, 42 Posts

Technical Blog #2 - A New Rendering Pipeline

jeff
Lead Developer
Jen: M
One aspect of the Toi Engine that's always needed more attention is rendering performance. While the final builds of the Anitlia MMO included some improvements, they still fell short of the framerates a pure C++ engine should be capable of.

Over the past couple months Toi's rendering system finally received many of the improvements I've long wanted to make. One component of the engine that needed such attention was the "Scene" class, which is the portion of the engine that keeps track of all the visual stuff within range of the player and how to render it. Games that include large open-world scenes come with specific rendering challenges, and in solving those problems for Antilia, it really made a mess of the Scene system.

The new system is a huge improvement over the old, not just because it tidies up some messy code, but because it cleanly separates scene management from how that scene gets rendered. The new scene system is only concerned with managing objects in 3D space, and can be optimized for different types of scenes. Scene management for Antilia is now made much simpler thanks to an optimized "PagedScene" system, which finally makes the dynamic loading and unloading of large worlds a core engine feature.

On the other side of these improvements is the new flexible rendering pipeline. Rendering is no longer done via a single complicated function, but instead by a set of "Render Stages" that can be stacked up in any order and customized as needed per camera.

This new flexibility allows me to implement a more modern rendering technique:

Deferred Rendering


While the previous rendering pipeline had some capability to scale to various hardware capabilities, it was limited to a single rendering approach based on the lowest-end hardware. This created limits that were sometimes easily noticed, such as the limit on the maximum number of active lights. If there were a lot of players in-game, it wasn't difficult to see lights flicker on/off when that limit was hit, especially if you were standing near someone that insisted on equipping three light sources. For any object in the scene, only a maximum of 8 or 4 lights could affect it, depending on if Medium or High quality shaders were used.

Now for some really, really primitive demo graphics. Textures are turned off in some of these renderings, which helps highlight the number of lights and their impact on the scene.

Here is a scene rendered via the standard technique with a light limit of 8 lights affecting a single object. While the lights are not indicated, they all have a random color. In this scene, there is one light above each cube or sphere.



Unfortunately, in a scene with a lot of lights and objects like Antilia's - this results in terrible performance. For each object rendered, the engine has to sort dozens, possibly hundreds of lights and figure out which 8 are closest to each object. Eventually we disabled per-object lighting in Antilia entirely, and used an even simpler approach - only the 8 lights closest to the camera would be rendered.



This helps performance, but is even less visually interesting. Lights also tend to flicker more, as players move around and the nearest set of lights is constantly changing.

Fortunately there is a more modern technique to light rendering that solves the problems, a technique known as "deferred rendering". Instead of rendering each object fully lit into the scene, we render the scene to multiple intermediate textures. These textures can then be used to render as many lights as wanted in a very fast post-process.



Not only does this technique eliminate the tedious need to sort lights - it eliminates the limit on how many lights can affect an object entirely. Suddenly the entire scene not only looks much better without the light limits, but it renders much faster as well.

In this final shot, I've enabled one of my debugging tools, which illustrates how the scene is actually rendered before the final lighting and composition phase. For those that are curious, the scene is rendered to four render targets - position, normal, color, and attributes (which includes channels for specular highlighting, self-illumination, and backlighting).

Saturday, August 15, 2015 5:12pm
Jeff Leigh - Lead Developer - Right Brain Games
WWWWWWWW
Jen: 44
Cool! I always wondered why light wouldn't show up correctly when a bunch of us were around a camp fire, all holding our own colorful bugs. So now if we have many friends all waving lights around that we will be able to see them properly... Does this benefit the magic system then?
Saturday, August 15, 2015 10:14pm
jeff
Lead Developer
Jen: M
Exactly. Being able to use more lights will be great when it comes time to design the night-time look of the cities and magical ruins.
Saturday, August 15, 2015 10:33pm
Jeff Leigh - Lead Developer - Right Brain Games
Myka
Jen: 13
Quote by WWWWWWWW:
Cool! I always wondered why light wouldn't show up correctly when a bunch of us were around a camp fire, all holding our own colorful bugs.

I always thought it was kinda funny, how you could spin the camera around the campfires, and the lighting would go ballistic
Monday, August 17, 2015 9:45am
WWWWWWWW
Jen: 44
Not exactly related but have you seen this article about intel's new "Inverse-Hyperthreading"? I am very, very, excited if it actually works!
Thursday, August 20, 2015 7:00pm
jeff
Lead Developer
Jen: M
Quote by WWWWWWWW:
Not exactly related but have you seen this article about intel's new "Inverse-Hyperthreading"? I am very, very, excited if it actually works!


Wow, interesting. I'd be curious to see comparisons of single-threaded tasks (including both tasks that are easily made parallel and those that are not) that had been re-engineered to be multi-threaded vs. how the "Inverse Hyperthreading" processor performs.

And it figures this would become available after I just built a new PC.
Thursday, August 20, 2015 8:45pm
Jeff Leigh - Lead Developer - Right Brain Games
Good Dog

Jen: 23
((Man... It's been a while since the last update, I'm glad to hear some good news on the project!))

Sounds great and looks like a much needed improvement! Good job!
Just keep plugging along Jeff. (Try to not tackle everything on your own?)

I know once things get settled well enough, there'll be plenty of people to make mods and/or third party dev.
While I know I wouldn't have much time to work on stuff, I'm really looking forward to TOI Studio (assuming that's still going to happen?).
Thursday, August 20, 2015 11:36pm
jeff
Lead Developer
Jen: M
Quote by Good Dog:
((Man... It's been a while since the last update, I'm glad to hear some good news on the project!))

Sounds great and looks like a much needed improvement! Good job!
Just keep plugging along Jeff. (Try to not tackle everything on your own?)

I know once things get settled well enough, there'll be plenty of people to make mods and/or third party dev.
While I know I wouldn't have much time to work on stuff, I'm really looking forward to TOI Studio (assuming that's still going to happen?).

Thanks, Good Dog!

Toi Studio is indeed still part of the plan. I suspect the next update will be about the improvements I'm currently making to the terrain editor.
Friday, August 21, 2015 9:29am
Jeff Leigh - Lead Developer - Right Brain Games
JF049
Jen: 11
I wonder if Toi Engine would still use Direct3D 9. There are facts that nvidia (or microsoft) implemented 4gb VRAM limit for D3D9, preventing using lots of high resolution textures when rendering a scene (it could be also mods), and it is not known if this would be fixed.
https://forums.geforce.com/default/topic/863242/geforce-drivers/-request-remove-4gb-limit-of-vram-for-dx9-games/
Friday, August 21, 2015 1:40pm
jeff
Lead Developer
Jen: M
Quote by JF049:
I wonder if Toi Engine would still use Direct3D 9.

Currently Toi is still using DirectX 9, yes. I'd like to implement a DX11 or DX12 rendering plugin for Toi sometime, but I'll hold off on that until we have the game running again.
Friday, August 21, 2015 2:31pm
Jeff Leigh - Lead Developer - Right Brain Games
Page: 1 2   Next

You are not currently logged in. You must first log in to post a reply.
Frequently Asked Questions Development Team

Antilia - Copyright © 2017 right brain games