use gl_PointSize in shader
I'd like to make use of the gl_PointSize within a shader, but I have had no luck. I'm trying to use this to size individual vertices by overriding the global @point_size attribute in a jit.gl.mesh.
I've seen mention that this can be enabled with a call to glEnable( GL_VERTEX_PROGRAM_POINT_SIZE) and glEnable(GL_POINT_SPRITE), which I guessed could be done via jit.gl.sketch. I tried doing this but haven't seen any change in the mesh appearance.
I've attached example maxpat and jxs files to illustrate. Any thoughts?
feature request noted. i'll see what i can do.
currently i believe geometry shaders might be your best bet for this.
Much appreciated Rob!
Hi Rob - did anything ever come of this?
unfortunately not yet, but it's still on my radar for max 8.
I still would rec geometry shaders for this. if you need an example patch i've got something i can dig up.
I would appreciate that when you have a chance. Thanks
here's a very basic example that uses the factory billboard shader to draw the points, and the Z position to change the size. you could improve on this in many ways, such as adding in a custom vertex attribute (as in your patch above) that you pass to the geometry shader via a varying attribute, using that in place of the uniform scale attribute (in the same way that texdim is passed from vertex to geometry in the billboard shader).
you could also draw the circle in the fragment shader instead of using the texture, using something like this:
float circle(in vec2 _st, in float _radius){
vec2 dist = _st-vec2(0.5);
return 1.-smoothstep(_radius-(_radius*0.01),
_radius+(_radius*0.01),
dot(dist,dist)*4.0);
}
void main(){
vec2 st = gl_FragCoord.xy/u_resolution.xy;
vec3 color = vec3(circle(st,0.9));
gl_FragColor = vec4( color, 1.0 );
}
Thanks Rob, I'll take a look!