The same way we moved from DOM to VDOM with react, We can move from tedious WebGL setup code to a productive, descriptive and functional abstraction, without hiding the underneath technology.
<Blur> <NegativeColor> <video ... /> </NegativeColor> </Blur>
Each pipeline brick is a function from pixels to colors...
...implemented in a Fragment Shader.
<Add> <HelloGL blue={0.5} /> <HelloGL blue={0.5} /> </Add>
const helloGL = <HelloGL blue={0.5} />; <Add width={w} height={h}> {helloGL} {helloGL} </Add>
factorizing the render tree minimizes the render cost.
(Most of the time, you don't have to use a variable)
Referencial transparency of VDOM elements: If the reference of a VDOM element is found multiple time in the tree, algorithm factorizes it to render it once.
optimization not built-in in React (DOM). Only makes sense in WebGL context: factorizing 2 branchs of the tree saves extra computation time.
Native Implementation for iOS and Android!
Both uses OpenGL ES.
A crazy demo that runs at 60 FPS. (on iOS)
We can rasterize native views to texture.
Too bad we can't do this with DOM...
split GL.View into GL.Surface and GL.Node.
Status: Implemented, but eagerly waiting React Native to depends on React.
To be released soon!!!
gl-react-inspector: Work in Progress
see issues created on Github:
We focused on 2D effects with hardcoded Vertex Shader.
We can try to be more generic, but this involves a bit of work especially for the React Native implementation.
For more advanced use-cases like 3D models, we recommend to directly use the OpenGL / WebGL API.
WebGL is a very low level imperative API... but fundamentally uses functional bricks.
How to draw things in WebGL:
a wrapper that hides WebGL complexity.
like how React hides the stateful imperative DOM API
<Blur> <NegativeColor> <video ... /> </NegativeColor> </Blur>
WebGL as easy as composing React components.
Our current focus: making (2D) effects.
The same wrapper on top of OpenGL for React Native.
Write universal effects for both the Web and Native.
working at Project September.