Rendering my (billiard) balls in a fragment shader
21–30 of 88 posts
Re: Rendering my (billiard) balls in a fragment shader
#22Here is a summary I wrote on my attempt to render balls using only a fragment shader. I am pretty happy with the result, and I've included a breakdown of the creation process.
Where or how did you learn GLSL?
Re: Rendering my (billiard) balls in a fragment shader
#23What's the benefit of rendering using this technique over a regular sphere rendered with the usual pipeline?
Well first of you get infinite smoothness and better lighting (and reflections if you add them) because there is no underlying geometry. It's just math. It's also much faster, as you're only giving the GPU four vertices defining the square. This can even be sped up further by using point sprites which consume only one vertex.
I've found a mechanism that uses the "interleaved attribs" feature of transform feedbacks to spit out 4 verts at a time (as six to draw two GL_TRIANGLES) into a buffer that a quad-drawing shader program consumes.
Using GL_POINTS/gl_PointCoord is probably better though just for teaching children fundamentals, I just wish that it actually worked properly in practice.
Re: Rendering my (billiard) balls in a fragment shader
#24Here is a summary I wrote on my attempt to render balls using only a fragment shader. I am pretty happy with the result, and I've included a breakdown of the creation process.
In understanding how the rotation was implemented, it took me longer than it probably should have to realize that the normal map (which I think of in terms of lighting) is actually a radial position on the sphere.
I had to go back and forth with the final and original code a few times, and finally noted that "n" gets renamed to "point" when it becomes an argument to colorLookup.
This dual usage of the normal for lighting brightness calculation and as a radial position on the sphere surface for looking up the color makes sense in retrospect but is also a somewhat subtle aspect that you might want to address more explicitly in your text instead of just silently renaming the variable in the code.
Re: Rendering my (billiard) balls in a fragment shader
#25Earlier quoted context omitted.
What was it originally? Hard to get more amusing than the actual article title...
The actual article was titled "Rendering Pool Balls". He fixed it by updating the article title rather than the HN submission(which I don't think you even can).
Re: Rendering my (billiard) balls in a fragment shader
#26Earlier quoted context omitted.
I fixed it. Thanks.
What was it originally? Hard to get more amusing than the actual article title...
Re: Rendering my (billiard) balls in a fragment shader
#27Here is a summary I wrote on my attempt to render balls using only a fragment shader. I am pretty happy with the result, and I've included a breakdown of the creation process.
Cool, I recently started with GLSL, and it’s interesting there are many roads that lead to a similar solution (how I draw circles or make a center is tad different) Where or how did you learn GLSL?
https://duckduckgo.com/?q=opengl+orange+book
Also the quick reference card helps