Axial billboards

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Luke923
Posts: 59
Joined: Wed Nov 05, 2003 5:26 am

Axial billboards

Post by Luke923 »

Hello all,

What I want to do is create a laser for my game, but I seem to be hitting a wall. I know that the best way to handle this would be to create an 'axial billboard,' otherwise known as a billboard that rotates on one axis. What I'm having trouble with is trying to figure out which axis I would want to rotate. Right now, I'm assuming that rotating on the Y-Axis would be the best way to go; however, something seems to be missing at least on a conceptual level. If anyone has any assistance - code, pseudocode, mathematical formulae, etc. - this humble coder would be eternally grateful.
"Object-oriented programming is an exceptionally bad idea which could only have originated in California."
- E.W. Dijkstra
qwe
Posts: 112
Joined: Sun Dec 28, 2003 12:54 am
Location: Oregon, USA

Post by qwe »

So you're going to have it spinning rapidly in order to look like a laser? sorry, I don't quite get what you're trying to accomplish...
Luke923
Posts: 59
Joined: Wed Nov 05, 2003 5:26 am

Post by Luke923 »

It made sense when I wrote it, but I can easily understand where someone could be confused by my prior statement.

I guess we have to go over the mechanics of the billboard. And, I'm bound to make mistakes in the description, so feel free to jump in and correct me. The way billboards work is by applying a texture to a square, whose Z dimension is infinitely thin, in 3D space. The issue found with billboards is that if you move the camera without rotating the billboard, the thinness of the billboard shows, which would make whatever illusion - whether it be smoke, a muzzle flash, or any other particle type that would benefit from the use of this technique - seem more like a texture slapped onto a square and less like smoke, muzzle flash, rain, etc. The way most 3D engines fix this, from what I gather, is take a transpose of the camera->world matrix, and apply matrix multiplication to the billboard->world matrix to assure that the billboard is always looking straight at the camera.

Now, the problem that I have is that I would not want the laser billboard to rotate on all three axes, yet the technique described above will perform such rotations despite my best intentions. What I need is a way to make sure that my laser billboard is aligned with the camera on one axis, maybe two, but not on all three.

Does that make any sense, or have I muddied the water further?
"Object-oriented programming is an exceptionally bad idea which could only have originated in California."
- E.W. Dijkstra
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

A billboard is a box with no Z axis ( I think in terms of programming, it is set to 0 ). All a billboard does is always look like it's facing the camera, no matter what angle you walk to. There are also axis dependant billboards ( not implemented ) that don't rotate to face the camera on a certain axis. If the billboards in Irrlicht aren't facing the camera then they ain't billboards :)

An example of a billboard would be a Sun in the sky, rather than having a mesh you just have a picture of the sun that always faces the camera.

An example of an axis dependant billboard would be a muzzle flash, where the flash wouldn't look the same on the X axis ( I think it's the X axis, I can't remember now ). Another example is for grass ( I believe they used a complex system of billboards in Unreal 2 for grass ).
qwe
Posts: 112
Joined: Sun Dec 28, 2003 12:54 am
Location: Oregon, USA

Post by qwe »

I think I get it... you want the laser to look like a beam from two axes, but not when viewing it "straight-on," so to speak... you may have to edit the CBillboardSceneNode class or derive your own class (like CAxialBillboardSceneNode) to do that.
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

Creating a billboard is one way of creating a laser, another ( better way IMO ) is to create a small cylinder that is slightly thicker at one end. You put the thinner end towards the barrel end and the thinner end towards the target. You make this cylinder completely transparent, then apply a fog to it. Red is usually the colour of choice, tho it's your call. Radiosity also looks good from what I've seen and there are other effects you can apply if Niko implements the CG shader language. IMO this looks much better than a billboard and allows allows for different looks to the beam without having to use any 2D graphics.
LordNaikon
Posts: 164
Joined: Wed May 05, 2004 5:34 pm
Location: Germany Berlin
Contact:

Post by LordNaikon »

cool idea !
if you considers that laserbeams(or that beam that we see) are reflections from the particles in fog
q|^.^|p beeing every time friendly to everyone
sys: 2500+Barton 512MB 6600GT WinXP
Luke923
Posts: 59
Joined: Wed Nov 05, 2003 5:26 am

Post by Luke923 »

Tyn wrote:Creating a billboard is one way of creating a laser, another ( better way IMO ) is to create a small cylinder that is slightly thicker at one end. You put the thinner end towards the barrel end and the thinner end towards the target. You make this cylinder completely transparent, then apply a fog to it. Red is usually the colour of choice, tho it's your call. Radiosity also looks good from what I've seen and there are other effects you can apply if Niko implements the CG shader language. IMO this looks much better than a billboard and allows allows for different looks to the beam without having to use any 2D graphics.
That's not a bad idea! Might actually be faster than billboarding to code. I'll have to give that a shot.

Thanks, everybody.
"Object-oriented programming is an exceptionally bad idea which could only have originated in California."
- E.W. Dijkstra
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

Well, I'd like to claim credit for it but I found it on the net when I did a little researching before starting my game. I think that's the method they used for C&C Generals to show the rocket trail, it works well because it is easier to scale a rectangle than a billboard ( and looks much better ).

To make this effective however, the fog system needs a little rewriting. There needs to be a way of having several different fog instances ( for example, one fog that is red and one that is blue ) so that you can still have general fog in the scene, different colour lasers etc.

If I was you I would also research how the light sabers in Jedi Knight were created, the newest ones look pretty cool ( I think it was called Acadamy? )

Edit: After some investigation I found out the effect is created with Radiosity, which isn't supported by the engine. I could use this as well, I'm gonna start a new post about it.
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

Hmm, it seems radiosity is supported but under a different name. It's called EmissiveColor in the engine but I think it would have the same effect, you would have to try it.
Post Reply