jonathanolson / tesserace

3D and 4D path tracing experiments by Jonathan Olson
https://jonathanolson.net/tesserace/tests/3d.html
Other
124 stars 10 forks source link

Soccer Material #1

Open GUI-Graphics opened 7 years ago

GUI-Graphics commented 7 years ago

Hi, sorry for disturbing, I have send a email to you but get no response, so i take the liberty to ask you some question here :). I'm reading your glsl code for soccer material, but i get stucked. image I don't know what thoes two functions do. Really appreciate if you can give me a brife guidance. And really nice job, I learn a lot from this project.

jonathanolson commented 7 years ago

This is for rendering the soccer ball. If you look at the soccer ball shape, the centers of the white patches are at the vertices of a dodecahedron, and the centers of the black patches are at the vertices of an icosahedron.

So to figure out (a) what color should a point on a spherical soccer ball be, and (b) how close to the center of a patch, or edge between patches it is, we need to find out what patch it is on. We find the closest black (icosahedron) and white (dodecahedron) patch centers, and see which is closest.

We don't need to do the distance computation with all of the polyhedron points, since the signs of certain points will always be closer (e.g. if the x point of our position on the ball is negative, we don't want to compare with points on the x-positive side of the ball).

This lets us choose just a limited set of points to compare distances with, and then we return the patch center that has the shortest distance to our input point.

Then we can continue shading the ball once we know the location of the nearest patch center relative to our position on the ball (manipulating normals, shading, base color, etc.)

GUI-Graphics commented 7 years ago

Hi, very brief and clear guide, really helps a lot, thanks very much for taking time offer me a help. however I still get stucked in somewhere. Now I have a point p on a shpere and two closest center point of black & white patch, how can I confirm p is in black patch?

image

I stucked in here. I'm not sure what the tileNormal means.

GUI-Graphics commented 7 years ago

Hi, jonathan. It's me again. I'm not sure whether you check your college email frequently, so i come here. I'm really confused about your dof implementation. the effect is excellent, but the code is quite simple! I love it! However i'm not sure the theory behind the implementation. It looks like that you enlarge the pin hole using dofOffset to cause blur effect. But it's kind of abstract for me to understand why -dofOffset / focalLength leads to a adjustable focal length effect. Can you give me a brief guide on this? image And I asked another question about soccer material on github couple weeks ago, realy appreciate if you can give me some clue or hit.

Your project is really excellent! I do some rewrite to make the code more focused on glsl shading and much more easy for read and learn. I hope this could do some help for your teaching:)

Sorry for my poor english. Thanks very much for reading.