filbs111 / webgl-reflections

0 stars 0 forks source link

direct rendering of reflection/portal #2

Open filbs111 opened 7 years ago

filbs111 commented 7 years ago

currently drawing to cubemap texture, then rendering portal object using that texture. This looks fine, but means low framerates on weaker hardware. see #1

An alternative method is to draw the view "through" the portal direct to the screen, performing "warping" in the vertex shader. Such a method worked well in filbs111.github.com/webgl-wideanglecamera , provided objects are composed of sufficiently small triangles (edges are short enough).

Initial implementation - aim to reproduce current cubemap result, with approximate reflection. Position of vertices shown on screen in each version should match. Not sure what z value should be. Initially just use something that gives the right drawing order. Later can choose ideal func such that tex mapping works best, ordering problems minimised for large objects etc. Guess want to z values consistent with surface of portal in final cam, for objects just inside/on surface of portal.

Not sure what to do about vertices not reflected to the viewer. Edges with one vert reflected and on vert not should ideally look OK.