Getting a billboard unaffected by perspective
Getting a billboard unaffected by perspective
I want to draw a 2D image that looks the same size no matter how far away it is, but still has depth as if 3D (like a billboard ).
I tried to do this with a billboard node, and just updated the image size based on the distance to the camera. It flickers from being imprecise, and I'm sure there's a cleaner, more efficient way to do it.
Any suggestions?
Thx
I tried to do this with a billboard node, and just updated the image size based on the distance to the camera. It flickers from being imprecise, and I'm sure there's a cleaner, more efficient way to do it.
Any suggestions?
Thx
I don't understand. If it doesn't change size then how is depth perceived?
Maybe getScreenCoordinatesFrom3DPosition will help but I'm unsure how you want to show "depth".
Maybe getScreenCoordinatesFrom3DPosition will help but I'm unsure how you want to show "depth".
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
I think he meanth correct position x&y on screen.
I'd probally know a way, but since I'm fairly new to irrlicht I would solve it the difficult way...
(get the direction to the point, place a billboard a fixed distance in that point. find out about drawing order later on. Do (almost) everything with the math.h libary...)
I'd probally know a way, but since I'm fairly new to irrlicht I would solve it the difficult way...
(get the direction to the point, place a billboard a fixed distance in that point. find out about drawing order later on. Do (almost) everything with the math.h libary...)
That's exactly what I first thought.Blindside wrote:I don't understand. If it doesn't change size then how is depth perceived?
Then I understood.. I think!
As an example, he wants some text to appear above every character (e.g. their name) in a 3D world.
He doesn't want the billboard to shrink as it moves in distance. He wants it the same size. The character may be smaller but the billboard should not be affected by depth. He wants a static size billboard.
I haven't even used billboards, I didn't actually know what they were before. But that's the only way I could understand it.
So actually, I suppose he needs the billboard to get large as it moves deeper.
So, what Abraxas) was saying is the answer.
I can hear birds chirping

I live in the Eye of Insanity.
I live in the Eye of Insanity.
If that's the case then he should go with draw2DImage and getScreenCoordinatesFrom3DPosition.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Sorry for my being confusing.
I seem to be that way when it comes to forum stuff.
Anyway, ur right Ulf about the size thing. My thinking was, I wanted it to have static size, but also be occluded by walls and such - so a brick wall in front would block it. 2D wouldn't do that. Unless it could use depth buffer or something. That's why I wanted to go with billboards, they're simpler.
I reckon Abraxas)'s idea is right - that's what I was thinking initially anyway, to scale the billboard based on distance to make it look like it's a static size. Guess I just need to improve the maths on it to stop it from "flickering" the scale of the image as I move or look around.
Sorry, that probably still doesn't make sense. This is a really annoying problem to explain.
I might just have to live with the "flicker", it's not that bad.
Thx for suggestions, and helping me think about the problem more clearly. I'll keep watching this post just incase there are any new ideas.
I seem to be that way when it comes to forum stuff.
Anyway, ur right Ulf about the size thing. My thinking was, I wanted it to have static size, but also be occluded by walls and such - so a brick wall in front would block it. 2D wouldn't do that. Unless it could use depth buffer or something. That's why I wanted to go with billboards, they're simpler.
I reckon Abraxas)'s idea is right - that's what I was thinking initially anyway, to scale the billboard based on distance to make it look like it's a static size. Guess I just need to improve the maths on it to stop it from "flickering" the scale of the image as I move or look around.
Sorry, that probably still doesn't make sense. This is a really annoying problem to explain.
I might just have to live with the "flicker", it's not that bad.
Thx for suggestions, and helping me think about the problem more clearly. I'll keep watching this post just incase there are any new ideas.
It makes sense.EvilDavo wrote:Sorry, that probably still doesn't make sense. This is a really annoying problem to explain.
Your original quote
So I suppose you had the right idea, but we forgot the real problem is flickering.I tried to do this with a billboard node, and just updated the image size based on the distance to the camera. It flickers from being imprecise, and I'm sure there's a cleaner, more efficient way to do it.
Maybe that is true in some way.Guess I just need to improve the maths on it to stop it from "flickering" the scale of the image as I move or look around.
But how do you mean flickering.
When the perspective is not moving and the objects (billboards) are stationary, do you get flickering of all the billboards?
I can hear birds chirping

I live in the Eye of Insanity.
I live in the Eye of Insanity.
No. It's not a technical problem. It's the small inaccuracy. So moving camera a little, it might suddenly appear 1 pixel bigger. Then moving again makes it return to the right size. It flickers between the two when moving or looking around with camera. I have a suspicion it can't be calculated in a way that doesn't have this effect.When the perspective is not moving and the objects (billboards) are stationary, do you get flickering of all the billboards?
The whole reason I wanted this was for something remotely like the way Blender draws vertex points. They seem to be billboards, as they intersect geometry. I just looked closer again, and realised that they "flicker" too in a similar way. Suddenly I don't feel so bad about the flickering.
On the bright side
For larger images, the flicker effect is negligible, just using
Code: Select all
float x;
x = camera->getPosition().distanceFrom( billboard->getPosition() );
x *= 0.005; // make it smaller
billboard->setSize( dimension2d<f32> (x,x) );You have a 3D position for your vertex. Put it through the World*View*Projection matrix to obtain a clipspace coord. Set the Z of each corner of your 2D screenspace billboard to clipspace Z and the billboard will then always be the same size on-screen but will effectively be placed at the same clipspace Z position in the scene as the vertex it is attached to and should therefore be (almost) correctly depth-tested against the scene.remotely like the way Blender draws vertex points. They seem to be billboards, as they intersect geometry
If you're happy with your current solution then maybe you should stick to that. My solution requires a bit of messsing about with mesh vertices, maybe your own billboard shader, and setting correct device state.
Irrlicht Demos: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=6&t=45781
Something like this?
Well... that's as far as I got. Bit confused with:
Code: Select all
vector3df point( 5,5,2 );
matrix4 viewMatrix;
viewMatrix = driver->getTransform( ETS_VIEW ); // get view projection matrix
viewMatrix.transformVect( point ); // transform the point by the view matrix.
// point is now in viewspace
...
How do you affect the 2D screenspace of some 3D geometry?Set the Z of each corner of your 2D screenspace billboard to clipspace Z