billboard scene node : constant size ?

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!
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

billboard scene node : constant size ?

Post by agamemnus »

I need a billboard scene node that remains constant in size (in terms of the overall screen) regardless of how close I am to it.

Has anyone made something like this, or does anyone have any ideas on how to do it? (I am not keen on re-scaling the billboard scene node every frame to keep the screen size constant.)


Alternatively: Is there a way to make a 2D image (ie, via "draw2DImage") recognize the z-buffer?
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

Your best option would probably be to write a shader for this, you can use simple transformations to get it to act as a billboard, and you can then make sure it stays on the near-plane so its size will stay constant
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

Actually u can do this without a shader maybe even faster dunno.

you simply set the view,projection and world matrix to identiy and then render a simple rect to the screen. The position of the rec has to be between -1,-1,0 and 1,1,0
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

Sudi wrote:Actually u can do this without a shader maybe even faster dunno.

you simply set the view,projection and world matrix to identiy and then render a simple rect to the screen. The position of the rec has to be between -1,-1,0 and 1,1,0
That would work too, but I'm just a shader-minded guy :D
random
Posts: 158
Joined: Wed Aug 11, 2010 6:01 am

Re: billboard scene node : constant size ?

Post by random »

agamemnus wrote: Alternatively: Is there a way to make a 2D image (ie, via "draw2DImage") recognize the z-buffer?
this would be much easier..

http://irrlicht.sourceforge.net/docu/example009.html

just type in "logo" into the browser search :)

never thought of how the Irrlicht logo is drawn??

;)
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Re: billboard scene node : constant size ?

Post by polylux »

random wrote:
agamemnus wrote: Alternatively: Is there a way to make a 2D image (ie, via "draw2DImage") recognize the z-buffer?
this would be much easier..

http://irrlicht.sourceforge.net/docu/example009.html

just type in "logo" into the browser search :)

never thought of how the Irrlicht logo is drawn??

;)
Sorry, but what you mean is drawn screen-aligned, not world aligned, what agamemnus tries to achieve.

Two simple approaches (if that's what you're looking for):
- Use the distance cam<->obj to determine the scaling of the node to achieve the intended impression
- draw a quad with the texture on it and assign it to an IMeshSceneNode
beer->setMotivationCallback(this);
random
Posts: 158
Joined: Wed Aug 11, 2010 6:01 am

Re: billboard scene node : constant size ?

Post by random »

Sorry, but what you mean is drawn screen-aligned, not world aligned, what agamemnus tries to achieve.
I need a billboard scene node that remains constant in size (in terms of the overall screen)
...
Alternatively: Is there a way to make a 2D image (ie, via "draw2DImage") recognize the z-buffer?
what do you think he meant???

:lol:

why else would he ask about whether a billboard that fills the whole screen or an image(which is screen aligned) and reminds of the z-buffer?
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: billboard scene node : constant size ?

Post by serengeor »

random wrote: what do you think he meant???

:lol:

why else would he ask about whether a billboard that fills the whole screen or an image and reminds of the z-buffer?
Random you drunk again?? :shock:
Can't you read?
I need a billboard scene node that remains constant in size (in terms of the overall screen) regardless of how close I am to it.
Scene node FYI is a thing that lies in 3D space, if you had forgotten about it.
And when he said about z-buffer is i think he wants it to be partially behind some objects(that are in front of it).

I think he need something like player nick name(tough maybe, it will be an image or sth else. idk) over player node.Tough I don't know how as I haven't worked with this stuff, tough It might be good to know for me too as I would like to have something like this for when I'm going to build my level editor.
Working on game: Marrbles (Currently stopped).
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

Thanks for the responses,

The size of each node should stay constant relative to the screen size.
The position should be an in-world position.
The rotation should be facing the camera.
It should be blocked by other 3D objects if they are closer to the camera.

:D

Radikalizm: Simple transformations not simple enough for me. Never did a shader so I wouldn't really know where to start with any of that.

Sudi: That's what I'm doing right now -- I'm rendering a set of rects, but there's no z-buffering in that so it looks bad at certain angles where a rect is seen through models that are closer to the camera than the rect.

random: Like polylux said, I need z-buffering (as if it was a 3D object) and world positioning. That logo just stays in one place, drawing over everything else.

serengeor: On the money! It's actually flags that are over models to represent what player they belong to.

---

I have a feeling that what I'm looking to achieve might be computationally expensive (re-scaling the nodes every frame). If there's no easy solution I might just have a combination: 2D drawRect flags if I'm at the bird's eye view zoom level, switching to all 3D flags closer.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

agamemnus wrote: Simple transformations not simple enough for me. Never did a shader so I wouldn't really know where to start with any of that.
Well, maybe it's time to learn, shaders and transformations aren't hard at all, you just have to take some time to get used to them ;)
It'll make your programming life a lot easier, trust me
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

Radikalizm wrote:
agamemnus wrote: Simple transformations not simple enough for me. Never did a shader so I wouldn't really know where to start with any of that.
Well, maybe it's time to learn, shaders and transformations aren't hard at all, you just have to take some time to get used to them ;)
It'll make your programming life a lot easier, trust me
Maybe you have some links or know good e-books where he(also I :oops: ) could start ?
Working on game: Marrbles (Currently stopped).
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

serengeor wrote:Maybe you have some links or know good e-books where he(also I :oops: ) could start ?
I learned about shaders from different resources

First of all there are a lot of good tutorials available online, I can't remember which ones I used specifically, but googling for them should give some nice results

The MSDN database gives a good reference for using HLSL, I don't work in GLSL that much so I can't give you any programming references, although it's not too different from writing shaders in HLSL

I also used to examine source code of existing shaders to find out what they did, it might not be an ideal solution but it worked for me

Once you get familiar with the vertex shader -> pixel shader workflow and matrix and vector operations (which are really easy in HLSL/GLSL because of the provided functions for working with them) it all becomes rather easy
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

I taught that you might know some starter friendly tutorials, but eh, I will google them up when I need, its not like it would be hard for me :)

Oh, and GLSL is for opengl, and hlsl is for directx right? If so, than I'll need to search for glsl tutorials, even if the difference is small, I want to be able to test them on my machine, since I'm working on linux.
Working on game: Marrbles (Currently stopped).
random
Posts: 158
Joined: Wed Aug 11, 2010 6:01 am

Re: billboard scene node : constant size ?

Post by random »

Random you drunk again?? :shock:
I dont drink, don´t compare me to yourself pls:)

Anyway i better go on with porting project code from Irrlicht to OGRE:) that´s less waste of time:)
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

serengeor wrote:I taught that you might know some starter friendly tutorials, but eh, I will google them up when I need, its not like it would be hard for me :)

Oh, and GLSL is for opengl, and hlsl is for directx right? If so, than I'll need to search for glsl tutorials, even if the difference is small, I want to be able to test them on my machine, since I'm working on linux.
Yes, GLSL is for OpenGL, HLSL is for DirectX

The syntax for both is mostly the same, except for some different names for basic types (like float3 in HLSL = vec3 in GLSL) and the managing of shader input/output

I'm sorry I can't be of more help, but it's a long time ago since I was learning how to write shaders so I can't exactly remember the tutorials I used

EDIT:
You also have the option to write your shaders in Cg, a language resembling HLSL designed by Nvidia which can be used for both OpenGL and DirectX
I believe an irrlicht implementation for Cg shaders exists if you're interested
Post Reply