Live data from Hacker News

Rendering my (billiard) balls in a fragment shader

getlazarus.org

61–70 of 88 posts

Re: Rendering my (billiard) balls in a fragment shader

#62
post #7

From the HN guidelines: please use the original title, unless it is misleading or linkbait; don't editorialize. The correct title is Rendering Pool Balls , not "Rendering my balls in a fragment shader".

Fixed.

Not to pee on your party, but I wouldn't want to the users who click on that title expecting...something else, to be disappointed. Therefore I have made the minimum viable edit.

(For anyone wondering: the submitted title was "Rendering my balls in a fragment shader" and the article title was changed from "Rendering pool balls" to that.)

Re: Rendering my (billiard) balls in a fragment shader

#64
post #47
post #30

I'm just getting my feet wet with shaders myself. Could this fragment shader be used in a "real" 3D game? At the moment, the sphere is orthographicly projected onto the screen so the sphere will always appear as a circle rather than an ellipse. How easy would it be to use this shader in place of a spherical mesh as you might find in a typical geometry based 3D render? I.e. could you use the same technique and render…

It can be incorporated into a 3D scene as long as you can make a square billboard . You may have problems with clipping that' you need to address manually, but it might be worth it as you can get better visuals, assuming you are trying to render spheres. As far as I know there shouldn't be any distortion issues. A sphere will always look like a circle from any perspective. Well that is unless it's really really big o…

Parent may or may not know this, but "billboards" are textured quads that always face the camera in a 3D scene. Trees and foliage are things that usually turn into billboards in a typical game if they are far away.

Re: Rendering my (billiard) balls in a fragment shader

#65
post #15

Earlier quoted context omitted.

Lol, wow what a find. You notice the details. I corrected it. Thank you.

At school, I somehow talked myself into a dumb competition with my math geek about memorizing digits of pi. I won, with 35 digits memorized (he gave up early; that's also around where the first '0' occurs in pi). I don't miss any opportunities to test that I still remember them correctly, to this day. ;)

I had a hard time getting past the "399" out about 43. I wanted to round it to "4".

But these days I would rather memorize tau:

  6.28318530717958647692528676655900576839433879875021
It has that "00" at 27 digits in that must be got past.

Re: Rendering my (billiard) balls in a fragment shader

#66
post #27
post #22

Earlier quoted context omitted.

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?

I was around and writing OpenGL when we started getting the first programmable cards. Nvidia shot out first with their Cg language, but I held back and waited for the "Orange Book" to come up. I bought it right away and learned from it and by looking at other peoples shaders. https://duckduckgo.com/?q=opengl+orange+book Also the quick reference card helps https://duckduckgo.com/?q=glsl+quick+reference&t=h_&ia=web

So you are a veteran, compared to me, just started this year, really reminded why I should have been more observant in math class :)

The resources are really good, hadn’t found something like that yet!

Re: Rendering my (billiard) balls in a fragment shader

#67

I happened to notice that PI is #define'd to 3.1415926538, which isn't the correctly rounded off value of 3.14159265358... Seems like they missed a '5'.

Interesting point if it had been apparent it would have been an issue, at what point does a poor Pi become an issue? What would a Pi of 3.0 do?

A professor comes around and criticizes it as it is about to become law:

- https://en.wikipedia.org/wiki/Indiana_Pi_Bill

- https://www.straightdope.com/21341975/did-a-state-legislatur...

Re: Rendering my (billiard) balls in a fragment shader

#68

I happened to notice that PI is #define'd to 3.1415926538, which isn't the correctly rounded off value of 3.14159265358... Seems like they missed a '5'.

Interesting point if it had been apparent it would have been an issue, at what point does a poor Pi become an issue? What would a Pi of 3.0 do?

In this case not a lot happens since it's only used for Z rotation.

Re: Rendering my (billiard) balls in a fragment shader

#69
In the 90's, texture maps were a luxury for anything. As a result shaders (for offline rendering, realtime shading languages didn't exist yet) were doing everything procedurally.

Here is the only image I could find of the RenderMan Shading Language VIDI SPORTS SHADERS Makina Works sold at the time (you got no source, just bytecode understood by Pixar's implementation at the time, AFAIK):

https://web.cs.wpi.edu/~matt/courses/cs563/talks/renderman/S...

What is interesting here is that the shaders did everything on a sphere primitive. All RenderMan implementations at the time (there were more than just Pixar's) were micropolygon renderers. I.e. displacement was almost free in terms of compute overhead.

Even the football operated on a sphere that the shader deformed into the resp. shape. All patterns, stripes etc. were procedurally generated. Each shader had texture slots to apply custom logos.

Re: Rendering my (billiard) balls in a fragment shader

#70
Even after 10 years I still have anxiety looking at OpenGL code. I still don't understand why we needed to write ray-tracing during a BSc course starting from a blinking cursor. The professor tried to defend that at the time, but I firmly believe that it is the wrong curriculum for a 20 year old CS student. Computer graphics were and are niche programming, and should not be taught main-stream. Out of 100 graduates maybe one will ever use this, why not use some common sense and teach something useful?
Post reply on HN