gl_PointSize - point size based on screen height?

Most of my images are point sprites and I’ve written a shader to scale the point size based on distance. However, I now need to rotate a quad around my point - all good. Except, when the resolution changes the difference between the size of the point sprite and the size of the quad changes (I’ve tied it to the height of the screen). My quad becomes too small to rotate around the sprite. So I’m thinking my scaling of my point sprite must be based somehow on the resolution of the screen, but I’m not quite sure how to fix it since I’m a complete noob. Help :slight_smile:

Here is part of my vertex shader…

uniform float pointSize;
vec4 modv = vec4( gl_ModelViewMatrix * gl_Vertex );
gl_PointSize = 200.0 * pointSize/ -modv.z;

As a temporary work around, I’ve done this… but I don’t know the rhyme or reason for it. I’m sure there is something simple I must be missing.

Instead of a static 200.0 * pointSize/ -modv.z;
I now divide the screen height by 6. So 1200/6 = 200, 1000/6 = 166, 800/6 = 133.

So if the screen resolution was 1280x800, my gl_PointSize would be this:
gl_PointSize = 133.3 * pointSize/ -modv.z;

This gets around the issue, but again, I’m hoping someone can shine some light on this and give me a more accurate method instead of passing in a scaling value.

To clarify… It’s not screen height, but frame or container height of the program. Since I was in full screen, it equaled screen height.

its in direct3d but u can do the same in opengl.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.