ianmackenzie / elm-3d-scene

A high-level 3D rendering engine for Elm, with support for lighting, shadows, and realistic materials.
https://package.elm-lang.org/packages/ianmackenzie/elm-3d-scene/latest/
Mozilla Public License 2.0
207 stars 27 forks source link

Implement optimized sphere mesh #33

Open ianmackenzie opened 4 years ago

ianmackenzie commented 4 years ago

Should be possible to have a sphere mesh where every vertex is just pair of U and V values, and the center point/radius are passed in as uniforms. Then the vertex shader could calculate vertex position, normal, tangent vector etc. (and you have texture coordinates for free!).

You could even share a given "UV grid" mesh among several different shapes as long as they have 2D parameterizations - spheres, cylindrical surfaces, toruses, spline surfaces...

ianmackenzie commented 4 years ago

Might need to have central frame as a uniform instead of just a point - this would be important if the sphere was textured. In that case you'd need to make sure that the sphere actually rotated properly!