Enhanced iPhone Renderers

During the last week most of my work was focused on enhancing the iPhone renderers to support real-time lighting and material colors.

The following screenshots show the OpenGL ES 1.x renderer in action, with both real-time lighting and diffuse colors enabled:

The OpenGL ES 2 renderer was upgraded as well. GLSL support was improved in order to handle light and material attributes. Here are some screenshots:

 

Per-vertex lighting

 

 

Simple lighting and material colors

 

 

Per-pixel lighting

 

But, what’s the point of implementing a shader-based renderer if we’re going to obtain the same results as with a fixed-function one? The next picture shows the same scene rendered with a non-photorealistic shader in order to achieve a cartoon-like effect known as Toon Shading:

 

Toon Shading

 

I also created a simple application in order to testing different effects without having to recompile everything. The app presents a basic menu that lets you choose what OpenGL ES version to use (either 1.x or 2.x), what models and textures to render (from a predefined list) and finally what kind of effect you want to use (which are only valid if you chose the GLES 2.x renderer).

Advertisements

Let there be light (with the appropriated shading)

A couple of days ago I managed to fix a bug in the COLLADA importer related with normal vectors that was causing some artifacts when using dynamic lighting on imported models. It turns out I wasn’t reading normal data in the correct way.

Here are some screenshots for your to compare:

 

Before

 

 

After

 

 

 

Before

 

 

After

 

Notice how the layers of color in the old version are now smoother and more realistic.

 

Before and After

 

One interface to implement them all…

Last week I mentioned I was planning to develop a new rendering pipeline based on shaders. Let me give you some more details about it.

I’m currently working on four different implementations for OpenGL-based renderers. Two of them are targeted to platforms that support either OpenGL 2 or 3 (i.e. Mac or PC) while the other two are based on OpenGL ES 1 and 2 and are specifically designed for iOS devices (iPhone, iPod Touch and iPad).

The OpenGL 2.1 Renderer implementation is the default one for PC and Mac. It has been constantly updated during the last couple of years and I recently added support for shader programs using GLSL, but for the moment there is no plan on supporting multi-pass effects like rendering to textures, bloom or shadows.

Here are a couple of screenshots. They where rendered using a shader program implementing specular lighting.

(Disclaimer: The ED-209 model has been downloaded from TurboSquid. My Blender skills are not that good yet).

Concerning the OpenGL 3 implementation, there’s still a lot of work to do. Unfortunately, the main issue I’m facing at this point is that I’m using a Macbook Pro as my default development environment and I don’t have the appropriated hardware that can handle the newest additions to OpenGL 3.

Now let me talk a bit about the iPhone renderers. As I said before, I’m working on two implementations, both of them are being rewritten from scratch.

One renderer is based on OpenGL ES 1.x, suitable for first and second generations iPhones and iPod Touches. This renderer is pretty similar to the OpenGL 2.1 implementation, except that it doesn’t support shaders, of course. Still, I managed to add support for dynamic lighting using the fixed-function pipeline. The result can be seen in the following images:

The OpenGL ES 2.x based renderer is completely shader based, at the point of not using the fixed-pipeline at all. Alas, at the time of this writing I haven’t finished the lighting support, but I will publish some screenshots during next week.

My closing comments have to do with the tile. All four renderers are implemented from the same Renderer interface (part of Crimild.Core library), meaning that they are able to support whatever feature is available on the target platform without causing any impact on the rest of the engine features.

As an example, I deliberated used the same model for all the screenshots in this post. Depending on what renderer implementation is being used, the model may be renderer with or without colors (the model is using render states to simulate materials). The same is true for shaders (although it cannot be appreciated in the pictures). If the renderer does not support them (as in the case of the OpenGL ES 1.x implementation), they are completely ignored but the scene is still drawn.