PointSprote Size limitation

Hello!

I found that Point Sprite Size is limited in 3d Viewport.
Even if i set in a shader
gl_PointSize = 500.0;

I’ll get size about 100pixels on the viewport. Is there a way to increase the point size limitation in OpenGL/JME?

Thanks.

@mifth said: Hello!

I found that Point Sprite Size is limited in 3d Viewport.
Even if i set in a shader
gl_PointSize = 500.0;

I’ll get size about 100pixels on the viewport. Is there a way to increase the point size limitation in OpenGL/JME?

Thanks.

This is the down side of points sprites. Some GPUs limit the on-screen pixel size of sprites. Some as low as 64 pixels. There is no way around it except to buy a different card.

This means that for sprites that will be large on screen you have to implement them as shader-billboarded quads either instead of or as a fallback to point sprites.

“Only size 1 is guaranteed to be supported; others depend on the implementation”

http://www.opengl.org/sdk/docs/man2/xhtml/glPointSize.xml

From what I hear some Android devices only support 1. Desktop is like pspeed said.

1 Like
@jmaasing said: "Only size 1 is guaranteed to be supported; others depend on the implementation"

http://www.opengl.org/sdk/docs/man2/xhtml/glPointSize.xml

From what I hear some Android devices only support 1. Desktop is like pspeed said.


Exactly.
You can’t rely on point sprite except if you really want a “sprite of one point”

Guys!
I have done something impossible! I forced PointSprites to be the VERY VERY VERY BIG!!!

Here is the simplest code:
[java]

gl_PointSize = max(1.0, (SIZE_MULTIPLIER * inSize) / spriteDist); // like in particle shader

gl_Position = g_WorldViewProjectionMatrix * modelSpacePos;
gl_Position.w *= ftransform().w; // THIS IS THE MAGIC!!!
[/java]

It works like a charm! Am I cheater? Can you test it too?

Here is my screenshots (the PointSprite is VERY BIG):


@pspeed said: This is the down side of points sprites. Some GPUs limit the on-screen pixel size of sprites. Some as low as 64 pixels. There is no way around it except to buy a different card.

Btw, this is a Sprotte in Germany :smiley:

1 Like

It seems there is no issue with pointsprites. At least, on nVidia cards.
Here is final code:

[java]
const float SIZE_MULTIPLIER = 300.0;
attribute float inSize;
uniform vec2 g_Resolution;

vec4 modelSpacePos = vec4(inPosition, 1.0);
vec4 position = g_WorldViewProjectionMatrix * modelSpacePos;
#ifdef POINT_SPRITE
// vec4 worldPos = modelSpacePos * modelSpacePos;
float spriteDist;

if (position.w == 0.0) {
  spriteDist = 0.00001;
} else {
  spriteDist = position.w;
}

gl_PointSize = (((inSize * SIZE_MULTIPLIER * (g_Resolution.x/g_Resolution.y)) / spriteDist) * (g_Resolution.x/g_Resolution.y));

#endif
[/java]

It’s ATI cards that often have the issue, I guess… though I have seen it on at least one nVidia, I think (on a Mac). I used to use point sprites for lots of big effects but they have their down sides for big things (not the least of which is that on some cards they won’t be drawn if their center is not on screen).

Here is the first relevant google hit I found:

I investigated this before. It’s best if you pretend that point sprites will never be bigger than 64 pixels if they are supported at all.

It sounds like your previous size problems were related to something else but you will certainly hit this one eventually also.

@pspeed said: It's ATI cards that often have the issue, I guess... though I have seen it on at least one nVidia, I think (on a Mac). I used to use point sprites for lots of big effects but they have their down sides for big things (not the least of which is that on some cards they won't be drawn if their center is not on screen).

Here is the first relevant google hit I found:

I investigated this before. It’s best if you pretend that point sprites will never be bigger than 64 pixels if they are supported at all.

It sounds like your previous size problems were related to something else but you will certainly hit this one eventually also.

On your link last answers were pretty ok.
Especialy this one " If you use shaders to define your point sprite size, then they’re basically quads."

Need ATI tester. Anybody has ATI card?

But i guess you are right. They should not be used heavily.

@mifth said: On your link last answers were pretty ok. Especialy this one " If you use shaders to define your point sprite size, then they're basically quads."

…which was referring to an nVidia card’s behavior.

Guys!

It seems you are all right.

I tested on nVidia GTS250 and nVidia GTX560.

GTS250 - can make sprites as big as you want.
GTX560 - is limited to 64 pixels of size.

PointSpriites are really unusable. I take all my words back.

Thanks.

@mifth said: But i guess you are right. They should not be used heavily.

It depends on if you want them to work on only your machine :wink:

The only guarantee is that they are 1 px size and they are not drawn when their center is off-screen (which is also in the spec). So if you want to draw HW-accelerated anti-aliased points they are perfect, it is what they are intended to be and why they are called PointSprites :slight_smile:

It seems i need to have a try this http://en.wikibooks.org/wiki/GLSL_Programming/Unity/Billboards

@jmaasing said: It depends on if you want them to work on only your machine :wink:

The only guarantee is that they are 1 px size and they are not drawn when their center is off-screen (which is also in the spec). So if you want to draw HW-accelerated anti-aliased points they are perfect, it is what they are intended to be and why they are called PointSprites :slight_smile:

Yeah, Thank you a lot.

@jmaasing said: It depends on if you want them to work on only your machine :wink:

The only guarantee is that they are 1 px size and they are not drawn when their center is off-screen (which is also in the spec). So if you want to draw HW-accelerated anti-aliased points they are perfect, it is what they are intended to be and why they are called PointSprites :slight_smile:

Well, my nvidia cards will still draw the sprite if any of it is on the screen… but you can’t count on that since it’s rare. It was nice while it lasted, though. :slight_smile:

@mifth said: It seems i need to have a try this http://en.wikibooks.org/wiki/GLSL_Programming/Unity/Billboards

Emulating point sprites in a shader using quads is really easy. The only thing that made it complicated in that other thread is that you wanted it bound to the y-axis and varied sizes. When you want them to behave exactly like point sprites then it’s much easier. It just takes more data than point sprites.

If you want atlasing like in some of JME’s particle stuff then you have to add extra float to your texture coordinates (for the tile index). I can explain if you need me to.

@pspeed said: Emulating point sprites in a shader using quads is really easy. The only thing that made it complicated in that other thread is that you wanted it bound to the y-axis and varied sizes. When you want them to behave exactly like point sprites then it's much easier. It just takes more data than point sprites.

If you want atlasing like in some of JME’s particle stuff then you have to add extra float to your texture coordinates (for the tile index). I can explain if you need me to.

I always appreciate your help! :slight_smile:

So, i tried to make a Quad aligned to camera. Here is my first result.

Code:
[java]
gl_Position = (g_WorldViewProjectionMatrix * vec4(0.0, 0.0, 0.0, 1.0) + (g_ProjectionMatrix * vec4(inPosition.x * m_ModelScale, inPosition.y * m_ModelScale, 0.0, 0.0)));
[/java]

Model in Blender:

JME:

The only issue i fount that i cannot scale model in java like:
[java]spatial.setLocalScale(scale);[/java]

I did a variable m_ModelScale to scale in a shader.

Did I make everything right?

Hmmm… why would you make a quad in blender?

…maybe I can’t help. :slight_smile:

@pspeed said: Hmmm... why would you make a quad in blender?

…maybe I can’t help. :slight_smile:

It does not matter. I even can make a quad in java.

Btw, i found how to stick to Y-axys.

Simplest Vertex code:
[java]gl_Position = (g_WorldViewProjectionMatrix * vec4(0.0, inPosition.y, 0.0, 1.0) + (g_ProjectionMatrix * vec4(inPosition.x, 0.0, 0.0, 0.0)));[/java]

Test Model:

Result:
[video]http://www.youtube.com/watch?v=WajKYiJGn1A&feature=youtu.be[/video]

In this way i can make positioning like your fire shader. :slight_smile:
[java]gl_Position = (g_WorldViewProjectionMatrix * vec4(0.0, inPosition.y * 0.5, 0.0, 1.0) + (g_ProjectionMatrix * vec4(inPosition.x, inPosition.y * 0.5, 0.0, 0.0)));[/java]

Nice. Seems simpler than what I did.