work on programmatic DTS billboards
by Geom · 05/30/2007 (7:23 pm) · 16 comments
A while back I mentioned I had been experimenting with adding billboards to DTS shapes, programmatically. This is the idea where your game code can add billboards to any DTS shape, without involving an art tool (Blender, Max, etc.) exporter. You'd simply write Torquescript calls (or something) to add the billboards at run-time. This seems like something that would make a useful resource.

So finally, I've gotten around to working on this idea in earnest.
The good news is, I've got it working - in certain cases. It works when the DTS shape is used by Player / AIPlayer objects, or by RTSUnit objects (from the RTS-Starter Kit).
The bad news is, this resource doesn't work for all cases. The biggest problem is that it doesn't work when the DTS is used by a TSStatic. That's a pretty big drawback, if I understand the purpose of TSStatics correctly. TSStatics are for when you've got lots of a certain kind of object in a game, like trees. Unfortunately, that's exactly the situation where billboards are most likely to be wanted.
The resource can also crash if the billboard is for a Player object, and the Player object has shadows turned on.
I think I know what the problem is (or at least one of them) with TSStatics, so I'm going to keep trying to get this resource working with TSStatics.
Despite its current limitations, I thought I'd go ahead and post the code I have, so that anyone who wants to can play with it or comment on it can do that. I should note that the code *sometimes* works with TSStatics. In fact the example below uses TSStatics from the Stronghold mission; by luck those don't seem to crash it. But it's definitely not guaranteed to be stable.
For more info about DTS billboards in general, check out e.g. the docs on the Blender .dts exporter.
Here's what I've got so far for the resource. Again, this is only a prototype, hopefully in the future there'll be a more bulletproof version.
--------
Programmatic DTS billboards
Summary:
This resource allows you to programmatically add billboards to a DTS shape. The DTS shape does not need to have been exported with billboards.
Article:
Torque DTS shapes support a nifty feature called "billboards". A billboard is a 2-D representation of what the DTS shape looks like when viewed from a long way away. If a DTS shape has billboards turned on, then Torque will render the DTS as a 2-D bitmap (billboard) when the DTS reaches it's lowest detail level. This can can result in huge speed-ups, since rendering a 2-D bitmap is much faster than rendering a 3-D shape.
Until now, billboards had to be turned on or off at the time the DTS was exported from the art tool (Blender, Max, etc) that created the DTS. With this resource, you can now turn on billboards in your game rather than in the art tool. This can be done for any DTS shape that doesn't already have billboards. The programmatic API supports all the same parameters that the art tool exporters support (and, arguably, slightly more).
API:
This resource adds a single Torquescript function (brackets denote optional params):
setupBillboards(shapeName, numEquatorSteps, numPolarSteps, bitmapSize, detailSize [, polarAngle [, includePoles [, bitmapDetailLevel ]]] )
For more info on the parameters, see the Blender DTS exporter docs.
Code
snipped - see comments below
Example
You can test this resource using the starter.fps example in Torque 1.5. Run Starter.FPS.bat, and start the mission "A Stronghold". Once in the mission, bring down the console window (~) and type
setupBillboards("starter.fps/data/shapes/Winter/TreeNoSnow03.dts",8,4,32,64);
setupBillboards("starter.fps/data/shapes/Winter/TreeNoSnow04.dts",8,4,32,64);
setupBillboards("starter.fps/data/shapes/Winter/TreeNoSnow05.dts",8,4,32,64);
That'll create billboards for three of the tree models. As you run around the mission area you should notice some of the trees transition between 3-D shapes and billboards. The billboards will be pretty ugly, but that's intentional to make them more noticable. (normally, of course, you'd select the billboard parameters to make the transition as invisible as possible).
up-close: 3-D shapes.

step back a bit: they become billboards.


So finally, I've gotten around to working on this idea in earnest.
The good news is, I've got it working - in certain cases. It works when the DTS shape is used by Player / AIPlayer objects, or by RTSUnit objects (from the RTS-Starter Kit).
The bad news is, this resource doesn't work for all cases. The biggest problem is that it doesn't work when the DTS is used by a TSStatic. That's a pretty big drawback, if I understand the purpose of TSStatics correctly. TSStatics are for when you've got lots of a certain kind of object in a game, like trees. Unfortunately, that's exactly the situation where billboards are most likely to be wanted.
The resource can also crash if the billboard is for a Player object, and the Player object has shadows turned on.
I think I know what the problem is (or at least one of them) with TSStatics, so I'm going to keep trying to get this resource working with TSStatics.
Despite its current limitations, I thought I'd go ahead and post the code I have, so that anyone who wants to can play with it or comment on it can do that. I should note that the code *sometimes* works with TSStatics. In fact the example below uses TSStatics from the Stronghold mission; by luck those don't seem to crash it. But it's definitely not guaranteed to be stable.
For more info about DTS billboards in general, check out e.g. the docs on the Blender .dts exporter.
Here's what I've got so far for the resource. Again, this is only a prototype, hopefully in the future there'll be a more bulletproof version.
--------
Programmatic DTS billboards
Summary:
This resource allows you to programmatically add billboards to a DTS shape. The DTS shape does not need to have been exported with billboards.
Article:
Torque DTS shapes support a nifty feature called "billboards". A billboard is a 2-D representation of what the DTS shape looks like when viewed from a long way away. If a DTS shape has billboards turned on, then Torque will render the DTS as a 2-D bitmap (billboard) when the DTS reaches it's lowest detail level. This can can result in huge speed-ups, since rendering a 2-D bitmap is much faster than rendering a 3-D shape.
Until now, billboards had to be turned on or off at the time the DTS was exported from the art tool (Blender, Max, etc) that created the DTS. With this resource, you can now turn on billboards in your game rather than in the art tool. This can be done for any DTS shape that doesn't already have billboards. The programmatic API supports all the same parameters that the art tool exporters support (and, arguably, slightly more).
API:
This resource adds a single Torquescript function (brackets denote optional params):
setupBillboards(shapeName, numEquatorSteps, numPolarSteps, bitmapSize, detailSize [, polarAngle [, includePoles [, bitmapDetailLevel ]]] )
For more info on the parameters, see the Blender DTS exporter docs.
Code
snipped - see comments below
Example
You can test this resource using the starter.fps example in Torque 1.5. Run Starter.FPS.bat, and start the mission "A Stronghold". Once in the mission, bring down the console window (~) and type
setupBillboards("starter.fps/data/shapes/Winter/TreeNoSnow03.dts",8,4,32,64);
setupBillboards("starter.fps/data/shapes/Winter/TreeNoSnow04.dts",8,4,32,64);
setupBillboards("starter.fps/data/shapes/Winter/TreeNoSnow05.dts",8,4,32,64);
That'll create billboards for three of the tree models. As you run around the mission area you should notice some of the trees transition between 3-D shapes and billboards. The billboards will be pretty ugly, but that's intentional to make them more noticable. (normally, of course, you'd select the billboard parameters to make the transition as invisible as possible).
up-close: 3-D shapes.

step back a bit: they become billboards.

About the author
My email address is my GG handle, at redbrickgames.com.
Recent Blogs
• Orcs vs. Martians - updated video• Orcs vs. Martians November update
• Milestone!
• The Burninating
• Victory flags
#2
Good work!
05/31/2007 (5:33 am)
Awesome code work there Geom. Very useful overall, and quite clever. Alan has a point, though. I'd yank out the code from this blog and put it in as a resource and just provide a link to it from here.Good work!
#3
thanks guys, for the heads-up about posting code. Sorry GG! Code yanked. I'll try to get the idea shaped up and resourced soon.
05/31/2007 (7:54 am)
@Alan, Michaelthanks guys, for the heads-up about posting code. Sorry GG! Code yanked. I'll try to get the idea shaped up and resourced soon.
#4
Short version:
Sweeeet! Should go in HEAD when all the bugs have been straighted out.
Will test with TGEA when I get home.
Post link to resource here too pls.
05/31/2007 (8:22 am)
Post got swallowed again... GrrrrrShort version:
Sweeeet! Should go in HEAD when all the bugs have been straighted out.
Will test with TGEA when I get home.
Post link to resource here too pls.
#5
If you happen to have a polished setup done, I'd be interested in knowing what a good quality transition between dts/billboard looked like. Nothing huge though -- I'm sure a lot more people are waiting on the code as a resource.
06/01/2007 (11:19 am)
Looks really good! Fantastic job!If you happen to have a polished setup done, I'd be interested in knowing what a good quality transition between dts/billboard looked like. Nothing huge though -- I'm sure a lot more people are waiting on the code as a resource.
#6
Thanks! Yeah it'd be cool if it eventually got into HEAD.
I think this will be most helpful to people who like buying art packs, like myself. For those people it makes more sense to allow the developer to tinker with the billboard parameters rather than the artist doing it. Lots of people buy the same art pack, but different people are going to want different billboard setups depending on how they use the art (or none at all, since billboards can be such memory hogs). I think it makes a lot of sense to allow the programmer to control them.
@Clint
Thanks! I don't currently have any screenshots of polished transitions, I'm working through a number of issues atm that prevent getting them. iirc the demo of Dark Horizons: Lore Invasion has some good transistions with some of their trees.
06/01/2007 (2:48 pm)
@JamesThanks! Yeah it'd be cool if it eventually got into HEAD.
I think this will be most helpful to people who like buying art packs, like myself. For those people it makes more sense to allow the developer to tinker with the billboard parameters rather than the artist doing it. Lots of people buy the same art pack, but different people are going to want different billboard setups depending on how they use the art (or none at all, since billboards can be such memory hogs). I think it makes a lot of sense to allow the programmer to control them.
@Clint
Thanks! I don't currently have any screenshots of polished transitions, I'm working through a number of issues atm that prevent getting them. iirc the demo of Dark Horizons: Lore Invasion has some good transistions with some of their trees.
#7
06/04/2007 (5:03 pm)
w00t! The issue with TSStatics is now fixed. I had to go with a different approach, but the code should be really robust now. Resource is submitted and I'll post a link if it gets approved.
#8
Can't wait to go test the new code!
06/05/2007 (1:01 am)
Yeah! That is good news! You can post the link, dont need to wait for it to get approved. That can take weeks. Can't wait to go test the new code!
#9
06/05/2007 (7:29 am)
how would I find that link?
#10
Maybe try searching for it... or check your history?
06/05/2007 (11:23 pm)
Hehe...You lost it? :-/Maybe try searching for it... or check your history?
#11
06/05/2007 (11:33 pm)
Btw... I'm unable to get this working with TGEA (yet)... I'll see if can spot anything.
#12
06/06/2007 (5:36 am)
Have you sorted out the Shadow Crash bug with the resource?
#13
Yeah, let us know if it works in TGEA! I don't own it so I can't test with it.
Shadow crash is still there...I think it's a bug/limitation with billboards, that doesn't have anything to do with this resource.
06/06/2007 (7:50 am)
After I posted it, I remember seeing this message about "If you want to see your resource while it's pending moderation, turn on such-and-such an option in your profile". But I can't find any option like that (and searching doesn't turn it up either). If you want, I can email it to you.Yeah, let us know if it works in TGEA! I don't own it so I can't test with it.
Shadow crash is still there...I think it's a bug/limitation with billboards, that doesn't have anything to do with this resource.
#14
To view your resources, click on "My Account", "My Posts, Resources, ...", then look for "You have submitted xx resources..." Click there, and you should see it. :)
06/06/2007 (1:22 pm)
I'm playing a bit more with it now, but I can only test it on StaticShapes, without initial success. The model Just dissapears atm.To view your resources, click on "My Account", "My Posts, Resources, ...", then look for "You have submitted xx resources..." Click there, and you should see it. :)
#15
06/18/2007 (8:04 am)
Geom... Still waiting for that link ;-)
#16
Ok. I've re-submitted it now. And this time, it is actually showing up , so I think all's good this time.
06/19/2007 (6:25 pm)
Argh. I think the GG website ate my original resource submission. I remember clearly being told "Submission successful", but then, the unapproved resource never showed up on my account page.Ok. I've re-submitted it now. And this time, it is actually showing up , so I think all's good this time.

Torque Owner Alan James
Really Really Good Things Studio
Really cool work may eventually save everyone quite a bit of work on the art pipeline end with some tweaking, but I'd suggest submitting this right away as a resource considering you've posted snipets of source code in a public blog and I would imagine GG is going to pull this very quickly.