Page 1 of 2
billboard scene node : constant size ?
Posted: Mon Mar 14, 2011 7:26 am
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?
Posted: Mon Mar 14, 2011 11:56 am
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
Posted: Mon Mar 14, 2011 1:29 pm
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
Posted: Mon Mar 14, 2011 2:08 pm
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

Re: billboard scene node : constant size ?
Posted: Mon Mar 14, 2011 3:33 pm
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??

Re: billboard scene node : constant size ?
Posted: Mon Mar 14, 2011 4:47 pm
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
Re: billboard scene node : constant size ?
Posted: Mon Mar 14, 2011 5:23 pm
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???
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?
Re: billboard scene node : constant size ?
Posted: Mon Mar 14, 2011 5:32 pm
by serengeor
random wrote:
what do you think he meant???
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??
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.
Posted: Mon Mar 14, 2011 6:26 pm
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.
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.
Posted: Mon Mar 14, 2011 6:39 pm
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
Posted: Mon Mar 14, 2011 8:39 pm
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

) could start ?
Posted: Mon Mar 14, 2011 9:10 pm
by Radikalizm
serengeor wrote:Maybe you have some links or know good e-books where he(also I

) 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
Posted: Mon Mar 14, 2011 9:20 pm
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.
Re: billboard scene node : constant size ?
Posted: Mon Mar 14, 2011 9:32 pm
by random
Random you drunk again??
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:)
Posted: Mon Mar 14, 2011 9:36 pm
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