Live data from Hacker News

Rendering my (billiard) balls in a fragment shader

getlazarus.org

31–40 of 88 posts

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

#34
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 could be used as a sprite that looks like real geometry with some tweaking.

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

#35

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'.

That’s a little bit more accuracy than what is needed for this post, but good catch :-) https://www.jpl.nasa.gov/edu/news/2016/3/16/how-many-decimal...

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

#36

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'.

I'm surprised you'd have to define pi in a fragment shader at all. Surely such a commonly used constant would be defined in the language/headers already?

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

#39
post #32

This reminds me of the same rendering technique described in Hustle Kings for the PS3. There was a write up done, however shader code was not included. https://web.archive.org/web/20130913033312/http://www.voofoo...

That's very interesting. Thank you for the link. From what I read and see in the images, I gather he's done the same thing I have, as you guessed as well. Obviously he's going much further. The author is using a subtle bump map (simulating balls scratches and imperfections), a reflection map with a gradient and indecent angle, what looks to be a faux sub surface scattering effect.

Also he is placing his balls in a 3D environment with nice shadows that really help to sell the illusion.

That's a good find and an interesting read. Thank you.

Post reply on HN