vertexshaderart: rendering issue? vertexCount problem? not sure what to call this
Just started looking at the tutorials, there’s a weird issue with rendering the grid though. Copied your code exactly to be sure I wasn’t doing something silly (though I might still be) - attached an image for you to see - note the bottom left corner… the line is incomplete

Seems the vertexCount doesn’t get fed correctly - either of the commented out solutions below work:
void main() {
float down = floor(sqrt(vertexCount));
float across = floor(vertexCount/down);
// SOLUTION-1
//down = floor(sqrt(200.));
//across = floor(200./down);
// SOLUTION-2
//float c = 200.;
//down = floor(sqrt(c));
//across = floor(c/down);
float x = mod(vertexId, across);
float y = floor(vertexId / across);
float u = x/(across-1.);
float v = y/(across-1.);
float ux = u*2.-1.;
float vy = v*2.-1.;
gl_Position = vec4(ux, vy, 0.,1.);
gl_PointSize = 10.;
gl_PointSize *= 20./across;
gl_PointSize *= resolution.x/600.;
v_color = vec4(1., 0., 0., 1.);
}
Hope this isn’t me being silly and overlooking something - been trying to figure this out for some time now! (actually its probably better if its me and not a bug 😉 )
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 16 (8 by maintainers)
I see the GL_ES wrapper as including C/C++ in my JavaScript.
I wouldn’t do this
So similarly I don’t put non-WebGL in my WebGL shaders. It’s misleading IMO to most WebGL devs who are unlikely to ever touch OpenGL (there’s several orders of magnitude more JS programmers than C/C++ programmers) so rather than clutter my code with stuff they’ll never use I try to keep it as clean as possible.
It gets worse in WebGL2. The first line of the shader must be
And there is no way to
#ifit out for desktop. Since It’s going to have to be a WebGL only shader then I keep the non-WebGL stuff out.but of course you’re free to do whatever you want, just explaining my reasoning.