GUI Draw calls and GUI texture coordinate mapping?
by pilotcap232 · in Torque 3D Professional · 06/14/2012 (7:15 am) · 10 replies
was wondering if there is a way or a resource to use 1 big dds texture sheet for all my gui images stuff and just map coordinates of that to my needs.
not sure how everyone calls this technique:
atlases textures?
gui texture coordinate mapping?
so instead of using 20 png images to use in my guis, just to marge them into 1 large 2048x2048 dds texture sheet and just map the coordinates in all my guis
anyway to achieve this in T3D?? or a resource to do that??
or did i just miss this feature from gui editor?
thanks in advanced
not sure how everyone calls this technique:
atlases textures?
gui texture coordinate mapping?
so instead of using 20 png images to use in my guis, just to marge them into 1 large 2048x2048 dds texture sheet and just map the coordinates in all my guis
anyway to achieve this in T3D?? or a resource to do that??
or did i just miss this feature from gui editor?
thanks in advanced
#2
so I take it T3D dos not support texture coordinate mapping for GUI elements, like most other engines.
right??
it is strange this feature has been overlooked in this nice engine, has anyone tried it before? or a work around??
mostly due for reducing GUI drawcalls and not having to deal with dozens if not hundreds of individual single texture images
06/14/2012 (1:13 pm)
thanks steve,so I take it T3D dos not support texture coordinate mapping for GUI elements, like most other engines.
right??
it is strange this feature has been overlooked in this nice engine, has anyone tried it before? or a work around??
mostly due for reducing GUI drawcalls and not having to deal with dozens if not hundreds of individual single texture images
#3
If your in-game GUI is utilizing hundreds of images/controls and drawcalls are a concern then that's a very busy HUD!
06/14/2012 (2:20 pm)
With the source you could rewrite the Gui Profile system to use a texture containing all of your image elements per profile, and then have each control grab a specified coordinate from the desired profile depending on type of control. Steve's suggestion of one image populated with dynamic elements is a common approach. Alternatively you don't have to use images at all. If your in-game GUI is utilizing hundreds of images/controls and drawcalls are a concern then that's a very busy HUD!
#4
06/17/2012 (11:14 am)
Take a look at how the unifiedShell gui is set up, talk about totally overlooking the obvious! So yeah, to answer the question, it does.
#5
some sort of bitmap array mapping.
and not today's standard texture coordinate mapping.
i think this comes from or since tge 5.1 is some sort of bitmap array system.
but more like a preset order on bitmap array will need to follow.
something like the images need to be placed in a preset spot, order, size and or configuration in order to torque can read them and use them as array.
how or which order??? who knows, :-)
there is no documentation as usual from GG, :-(
unless i missed it.
06/17/2012 (4:19 pm)
i think this is a very unusual way,some sort of bitmap array mapping.
and not today's standard texture coordinate mapping.
i think this comes from or since tge 5.1 is some sort of bitmap array system.
but more like a preset order on bitmap array will need to follow.
something like the images need to be placed in a preset spot, order, size and or configuration in order to torque can read them and use them as array.
how or which order??? who knows, :-)
there is no documentation as usual from GG, :-(
unless i missed it.
#6
As for the delimiter color (in my example it is #FF0000) Torque will use the exact color used at pixel position 0,0 which is the far top left side of the image for the array delimiter/separator. Just be sure to never use that same color for anything else, just for the delimiter pixels. As for alpha value, I believe it ignores the alpha value as that's a completely separate image layer such as the case for PNG and GIF images for the case of the delimiter.
06/18/2012 (11:54 am)
If it helps I created a cheat sheet for how the buttom skin images work: TorqueButtonSkin.pngAs for the delimiter color (in my example it is #FF0000) Torque will use the exact color used at pixel position 0,0 which is the far top left side of the image for the array delimiter/separator. Just be sure to never use that same color for anything else, just for the delimiter pixels. As for alpha value, I believe it ignores the alpha value as that's a completely separate image layer such as the case for PNG and GIF images for the case of the delimiter.
#7
great info,
Now, where does that info come from, is it documented somewhere on the engine? T3D?? tge??
one thing that is not clear to me is, the actual image sheet dimensions
512x512?
1024x1024?
etc...
you mentioned the visual states, normal, selected etc...
is that the actual order the button images need to be placed on the single image sheet?
i guess i am still confused.
also does this array applies for buttons only, ive seen tge had like other images sheets array like for scroll buttons etc.. and they have different setups
will appreciate if you can clarify, or point me to the right documentation link for it.
thank you again
06/19/2012 (10:16 am)
thanks Nathan,great info,
Now, where does that info come from, is it documented somewhere on the engine? T3D?? tge??
one thing that is not clear to me is, the actual image sheet dimensions
512x512?
1024x1024?
etc...
you mentioned the visual states, normal, selected etc...
is that the actual order the button images need to be placed on the single image sheet?
i guess i am still confused.
also does this array applies for buttons only, ive seen tge had like other images sheets array like for scroll buttons etc.. and they have different setups
will appreciate if you can clarify, or point me to the right documentation link for it.
thank you again
#8
That image array structure as described in my cheat sheet is only for the GuiButtonCtrl. It is different for GuiRadioCtrl, GuiCheckBoxCtrl, GuiWindowCtrl, etc.. As far as I know of these image array layouts haven't been documented anywhere.
I try to find some time this weekend to go through all the controls' sources and create a single document that details how each control's image array is suppose to be layed out. As far as I know of those who have changed the theme for their games pretty much used existing images found in game/core/art/gui/images as template examples with some trial and error to get it right.
06/19/2012 (11:57 am)
I derived that cheat sheet from looking through the GuiButtonCtrl source code of how it handles the profile/datablock specified image file. My cheat sheet is lacking in several details now that I've read over your questions and realized I'll need to rework it sometime this weekend. Basically, your image can be any size, and today's graphics cards do support non-power of two textures and so does the game engine. On hardware that does not support power of two the engine will create textures big enough to hold non-power of two images.That image array structure as described in my cheat sheet is only for the GuiButtonCtrl. It is different for GuiRadioCtrl, GuiCheckBoxCtrl, GuiWindowCtrl, etc.. As far as I know of these image array layouts haven't been documented anywhere.
I try to find some time this weekend to go through all the controls' sources and create a single document that details how each control's image array is suppose to be layed out. As far as I know of those who have changed the theme for their games pretty much used existing images found in game/core/art/gui/images as template examples with some trial and error to get it right.
#9
On further look at the UnifiedShell, which I usually remove, it's actually using a listMenu array to define it's buttons, icons, etc, so it isn't quite the composite array I had thought it was.
06/19/2012 (12:45 pm)
Yeah, it's all still undocumented, but it is rather obvious what the different parts of the arrays are. As noted, size of the image is unimportant and the delimiter color can be anything. So long as it is the first pixel in the image and that color is not used for anything else within the image.On further look at the UnifiedShell, which I usually remove, it's actually using a listMenu array to define it's buttons, icons, etc, so it isn't quite the composite array I had thought it was.
#10
A nice resource will come handy for this feature,
something like creating the feature to coordinate mapping images
in this case one can just create a big single image sheet with all gui and let gui editor select which part of the image sheet to map for that single button or gui etc...
something like grabbing the 4 corners pixel coordinates to map the image inside of the sheet.
ie: lets say to pixel map a 40x40 square pic inside of a image file sheet
Coords:
topleft = x 20px y 20px
botleft = x 20px y 60px
topright = x 60px y 20px
botright = x 60px y 60px
that is how most other game engines are using to map coordinates on single sheet gui images , mostly the mmo engines usually use this a lot to minimize the gui draw calls to improve performance for game play.
I am not that skilled to be able to come up with a resource like that, so i guess I will have to live with the existing pre defined image array already setup on torque. :-(
06/19/2012 (8:49 pm)
Thanks,A nice resource will come handy for this feature,
something like creating the feature to coordinate mapping images
in this case one can just create a big single image sheet with all gui and let gui editor select which part of the image sheet to map for that single button or gui etc...
something like grabbing the 4 corners pixel coordinates to map the image inside of the sheet.
ie: lets say to pixel map a 40x40 square pic inside of a image file sheet
Coords:
topleft = x 20px y 20px
botleft = x 20px y 60px
topright = x 60px y 20px
botright = x 60px y 60px
that is how most other game engines are using to map coordinates on single sheet gui images , mostly the mmo engines usually use this a lot to minimize the gui draw calls to improve performance for game play.
I am not that skilled to be able to come up with a resource like that, so i guess I will have to live with the existing pre defined image array already setup on torque. :-(
Associate Steve Acaster
[YorkshireRifles.com]