I’m trying to implement some kind of scaling of an image displayed on a billboard.

The logic is that from a certain distance the image (quad) size should be constrained. When it’s close to the camera, the image can’t be bigger than, let’s say “32 pixels” and when the camera is zoomed out the image should be expanded so it won’t (pretty much) disappear until it’s at the minimum x pixel wide.

Question is, is there a way to bypass a spatial’s “size” conversion to screen coordinates and then resize? There’s got to be an easier way to do this. Maybe @pspeed has some dot matrix multiplied by the inverse pi of the universe trick up his sleeve.

Honestly, I might do it in a .vert shader depending on how often it is used, etc…

Hm, depending on the usage, i would simply abuse the guiNode for that and implement a simple control which updates the position and size.

There’s something similar I’ve done with what I call an info bubble but I’d also like to change that to use a billboard because billboards are usually at a proper depth. Doing it in the guiNode means if the user has 3D glasses on, the effect won’t be disorienting or just plain weird.

As for the shader way. Hm. Maybe I’m not in the right frame of mind, but I don’t see how.

There's something similar I've done with what I call an info bubble but I'd also like to change that to use a billboard because billboards are usually at a proper depth. Doing it in the guiNode means if the user has 3D glasses on, the effect won't be disorienting or just plain weird.

As for the shader way. Hm. Maybe I'm not in the right frame of mind, but I don't see how.

I've implemented a few billboard-like effects in shader. Each vertex has the center location and some indication of which corner it is then I calculate its actual position in the .vert shader. In a way, it's a like a point sprite except done with real geometry.
1 Like

I think I see what you mean. (not at all)

It’s all good though, at least after re-reading 12-15 times I will eventually get it. On the off-chance you’d be tempted to throw some code this way, give me at least 30 mins to lose a couple of hundred thousand brain cells first.

Oh and thanks too.

I think I see what you mean. (not at all)
It's all good though, at least after re-reading 12-15 times I will eventually get it. On the off-chance you'd be tempted to throw some code this way, give me at least 30 mins to lose a couple of hundred thousand brain cells first. ;)

Oh and thanks too. :)

Some of my stuff is a little to purpose-built at the moment and while it's straight forward to describe at a high level, the devil is in the details beyond that.

I use point sprites for lots of things like flames, flowers, etc... but when I was doing my waterfall tests (that also used point sprites) I discovered that some graphics cards limit the maximum on-screen pixel size of a point sprite. This makes my flames look really funny when some users get close and it made the waterfall stuff look super-stupid. So at some point, I will write an alternative to point sprites that uses shader oriented quads as a fallback on cards with a max sprite size.

Here is a slightly more specific general idea, though:
-make a 0,0 Quad positioned in the center of what you want
-have a custom .vert shader that uses the texture coordinate to offset the corners from the original vertex location in screen space. Basically, go ahead and transform the vertex normally as you would for any other regular shader... and then offset .x and .y by some scaled value based on the texture coordinates. Something like vPos.x += -0.5 + scale * texCoord.x and so on.
-calculate scale based on distance and whatever other limits you want.
@pspeed said:
I use point sprites for lots of things like flames, flowers, etc... but when I was doing my waterfall tests (that also used point sprites) I discovered that some graphics cards limit the maximum on-screen pixel size of a point sprite. This makes my flames look really funny when some users get close and it made the waterfall stuff look super-stupid. So at some point, I will write an alternative to point sprites that uses shader oriented quads as a fallback on cards with a max sprite size.

Not to hijack a thread... but I find the subject interesting (especially the use of the gui node and the use of point sprites). If any of you get a chance would you post some screen shots of your usage of point sprites? I haven't even gotten to playing around with these yet (yeah... I'm a late bloomer)
@t0neg0d said:
Not to hijack a thread... but I find the subject interesting (especially the use of the gui node and the use of point sprites). If any of you get a chance would you post some screen shots of your usage of point sprites? I haven't even gotten to playing around with these yet (yeah... I'm a late bloomer)

The flames in this picture are animated point sprites:

The flowers in this picture are point sprites:

The stars in this picture are point sprites... using JME's smoke texture actually. :)
2 Likes

You can kind of see the animated flames here:

1 Like
@pspeed said:

The flames in this picture are animated point sprites:

The flowers in this picture are point sprites:

The stars in this picture are point sprites... using JME's smoke texture actually. :)

OMG... that waterfall is freakin' SICK!! freakin' wasn't the actual word that came out of my mouth when I saw it! How is performance using point sprites like this?
@pspeed said:
You can kind of see the animated flames here:

Hah.. I never told you how much I like the music for your game. Sooo... now I told you!

I definitely need to look into how to properly use point sprites.

I take it from what you’ve said before, that “textures” are static to one “size” and don’t really act out the way billboard objects are. (Moot point since I know they’re not; yes, I only wanted to post a reply :P)

I take it from what you've said before, that "textures" are static to one "size" and don't really act out the way billboard objects are. (Moot point since I know they're not; yes, I only wanted to post a reply :P)

You can make them behave however you want based on "scale". If you don't change scale with distance then the textures will always be the same pixel size on screen.
@t0neg0d said:
OMG... that waterfall is freakin' SICK!! freakin' wasn't the actual word that came out of my mouth when I saw it! How is performance using point sprites like this?