3 ms·
Author here. The caustics in this demo are computed entirely on the GPU and are approximated with a mesh. The shader for the caustics needs the ratio of the pro
by constexpr 13y ago
Author here. The caustics in this demo are computed entirely on the GPU and are approximated with a mesh. The shader for the caustics needs the ratio of the projected area to the original area for each triangle to compute the brightness. You're right that a vertex shader can't access whole triangles (you usually use a geometry shader for that, which WebGL doesn't have) but you can still get the ratio of the triangle areas in this case by using the screen-space derivative functions dFdx() and dFdy() in the fragment shader. Reflections and refractions can also be done in entirely in the fragment shader for simple scenes like this one with standard raytracing intersection tests.