Högni and Amy's game project

Thought in deed

Ogre3D issues

leave a comment »

I’ve been poking at the texturing and graphics part of things for the last couple of days after slaying the physics/networking dragon. In the course of things I’m running into the biggest issue I find with using the Ogre3D rendering engine. The issue revolves around shaders.

There are several good shader authoring utilities out there. One of the more prominent is FX Composer from nVidia, another is ShaderFX, a plugin for 3ds Max developed by Luminox. There is also one from ATI, RenderMonkey. These work in different formats, FX Composer primarily works with cgfx which ShaderFX also supports. ShaderFX also has limited support for DXSAS, a format from Microsoft for their Direct3D API. RenderMonkey works with glsl as far as I can tell. RenderMonkey seems to have been designed by aliens for use by unknown other entities, and I have been unable to penetrate its obtuse user interface.

After a bit of research and testing we decided – when I say we, I really mean me – to use ShaderFX as it integrates  nicely into Max and manages to export fairly clean DXSAS code. RenderMonkey, as mentioned, seems not to be designed for use by mere mortals, and FX Composer seems to be developed for those who are not really creating shaders but are more playing around. At least converting shader programs from FX Composer to a usable format, e.g. hlsl or glsl, takes too much work. It’s preview function is also too finicky and hard to debug.

So ShaderFX. When I export from there, I “only” need to do the following:

  • Register the texture maps to be used in the texture units.
  • Change the vertex program input struct by actually populating the binormal property. Yay for cross(In.tangent, In.normal).
  • Remove a bunch of extra code that is not neccesary, e.g. lots of variable declarations in the script itself.

Not so bad. But then I need to create the Ogre3D program and material definition scripts. This drives me nuts – every time. Through a series of obscure and less than satisfactorily documented definitions and assignments I get a usable pair of scripts. This involves binding things like teh world view projection matrix, the world matrix, inverse world matrix, inverse transpose world view projection matrix – seriously, that’s a real term – and bind various scene variables to the shader defined variables. Joy.

There really needs to be an easier, i.e. less time-consuming as it is not really all that complicated once accomplished the first time. In other engines there are tools to export directly from FX Composer and also from ShaderFX and use the techniques both generate directly, without all this confumbleness along the way. I’m looking into a method to convert the scripts generated by ShaderFX to program/material files directly at this time. I’m not going to spend a lot of time on it though, as the various options would take months to account for in any conversion software. I can see myself creating support for constants, texture units and lights, but I doubt I’d go further than that.

I was quite happy using Ogre3D up until this point, and I’m pretty sure we’ll finish the current iteration of our game using it as our renderer, but I am very happy that I kept Ogre3D’s event system out of the main message loop and kept to a more standard process flow control. This means I can plug another renderer in without much trouble at a future date.

As it stands, the advantages (replaceable scene manager, decent quality, FREE) outweigh the disadvantages (cumbersome content tool chain, poor documentation), but I continue to look around for a replacement.


Written by Högni Gylfason

21.07.09 at 16:59

Posted in Programming

Tagged with , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: