GFX upgrade to Torque2d
by Paul Jan · 05/01/2013 (11:10 am) · 10 comments
Switching out dgl and the fixed pipeline of MIT torque2d is coming along nicely.
I've subclassed GFX to GFXOpenGL, and subclassed that to GFXOpenGL32 (Opengl 3.2) and GFXOpenGLES (OpenGL ES 2.0). This opens the door to shaders, lighting and all that fun stuff, but for now I'm keeping things similar to regular T2D.
One thing I've noticed is that the background objects are rendering differently, but I'm not sure its something I should fix.
Base torque2d (iPad3)

GFX torque2d (iPad3)

The original texture on the back

Bugs and things to do:
*ios fonts aren't loading properly
*reconfiguring inputs to use ios touch gestures
*currently running on iOS and OSX, not windows
*airplay and multiwindow support
My GFX T2D fork:
github.com/pchan126/Torque2D/tree/feature/gfx
I've subclassed GFX to GFXOpenGL, and subclassed that to GFXOpenGL32 (Opengl 3.2) and GFXOpenGLES (OpenGL ES 2.0). This opens the door to shaders, lighting and all that fun stuff, but for now I'm keeping things similar to regular T2D.
One thing I've noticed is that the background objects are rendering differently, but I'm not sure its something I should fix.
Base torque2d (iPad3)

GFX torque2d (iPad3)

The original texture on the back

Bugs and things to do:
*ios fonts aren't loading properly
*reconfiguring inputs to use ios touch gestures
*currently running on iOS and OSX, not windows
*airplay and multiwindow support
My GFX T2D fork:
github.com/pchan126/Torque2D/tree/feature/gfx
About the author
#2
05/02/2013 (6:37 am)
Epic is right... The latter looks more accurate to me compared to the original background.
#3
I second Patrick`s comment : the second one looks more accurate
If we look in TruckToy`s script, though, it seems like the stock T2D screenshot is the correct one.
My guess (without having looked at your code) is that your code doesn't take BlendColor into account yet.
05/02/2013 (10:25 am)
Keep it up, Paul; this is a great step forward for T2D!I second Patrick`s comment : the second one looks more accurate
If we look in TruckToy`s script, though, it seems like the stock T2D screenshot is the correct one.
%obj.BlendColor = DarkGray;
My guess (without having looked at your code) is that your code doesn't take BlendColor into account yet.
#4
05/02/2013 (12:01 pm)
seems to me, without looking at anyones code, that both are displaying the sprite correctly, but your background screen colour is lighter than the T2D's?
#5
Found that mixing the row-major MatrixF in torque and the column-major GLKMatrix in GLKit has made a bit of a mess. After some cleaning and removal of some GLKit functions from the iOS build, its starting to look good again.
05/02/2013 (10:38 pm)
Ah. There we go. Blending in fixed pipeline is done through the GL state machine, while here it has to get passed into the shader, so functions need to include color info.Found that mixing the row-major MatrixF in torque and the column-major GLKMatrix in GLKit has made a bit of a mess. After some cleaning and removal of some GLKit functions from the iOS build, its starting to look good again.
#6
I guess a pixel shader would have to be written, some sort of light source SceneObject created, expand ImageAssets to support normal maps, etc?
05/02/2013 (11:07 pm)
This is really great stuff. Just out of curiosity, what sort of effort is needed to enable lighting after GFX is working in T2D?I guess a pixel shader would have to be written, some sort of light source SceneObject created, expand ImageAssets to support normal maps, etc?
#7
What I'd probably do in the first round would be to use vertex shading and expand sprites into multi-vertex meshes. Its a bit more work since right now we still operate under the illusion of sprites as the atomic unit.
It could still take a while before I'm in a position to go there. I finally got the sandbox buttons working again in iOS, which only exposes all the gui crash bugs i couldn't reach.
05/03/2013 (1:10 am)
The most basic lighting wouldn't need normal maps.What I'd probably do in the first round would be to use vertex shading and expand sprites into multi-vertex meshes. Its a bit more work since right now we still operate under the illusion of sprites as the atomic unit.
It could still take a while before I'm in a position to go there. I finally got the sandbox buttons working again in iOS, which only exposes all the gui crash bugs i couldn't reach.
#8

Slowly getting there...
05/05/2013 (10:04 am)
So I found and fixed a couple of bugs in the font rendering this weekend. I still prefer using .fnt files rather than .uft or generating them.
Slowly getting there...
#9
05/07/2013 (9:35 am)
Great work. I'm glad that you separated the opengl paths into it's separate components. Would make it easier to port to other platforms.
#10
I'm probably going to have to do even more subclassing once I get things functional.
What I want to end up with is a platform specific GFX subclass after each type. Like GFXOpenGLESiOS and GFXOpenGL32OSX. That way GFXOpenGLESAndroid and GFXOpenGL32Windows could follow.
05/08/2013 (9:04 pm)
At the same time my work is always biased towards the platform I'm working on (mac/ios).I'm probably going to have to do even more subclassing once I get things functional.
What I want to end up with is a platform specific GFX subclass after each type. Like GFXOpenGLESiOS and GFXOpenGL32OSX. That way GFXOpenGLESAndroid and GFXOpenGL32Windows could follow.

Employee Michael Perry
ZombieShortbus
The issue with the background is strange. I would say it's because of the fact that it is a Scroller, but then again, so is the ground. Perhaps the texture has a different alpha channel value?