Friends link: exam 70-450 cert 9a0-125 Adobe 9A0-127 exam Apple 9l0-410 Certification a00-202 Exam dumps IBM a2010-570 Exam dumps Pass A2160-669 Exam asc-029 Exam Dumps BCP-240 Actual Exam ISEB bh0-006 exam
GLOW » Three.js and GLOW
Parajumpers sale Parajumpers sale canada goose sale Canada Goose jas

Three.js and GLOW

One of the coolest features of GLOW is that you can use it in conjunction with all existing WebGL 3D frameworks out there. As I’ve worked a lot with Three.js and it’s one of the best, the examples here uses Three.js but could easily be transfered to other frameworks.

This time I wanted to explore how to use GLOW to make post-effects on a scene rendered by Three.js. It turned out to be quite easy, with one little exception.

You simply create an ordinary Three camera and scene with meshes and lights. Then you create your GLOW.Context like this…

var cntx = new GLOW.Context( { context: renderer.getContext() } );

The GLOW.Context can actually just take another, already created context and use that instead of creating a new one. This is key to making it work with other frameworks. Then you just create a new GLOW.FBO and a post-shader, as in the Hello FBO tutorial.

Now comes the tricky part: Three’s WebGLRenderer have an internal cache for shader programs, which you can’t invalidate. The problem is that we need to switch program to draw the post shader, and this program will be used in the next WebGLRender call, causing it to crash.

But there’s a trick, you can use the global GL-object and do the following…

var currentProgram = GL.getParameter( GL.CURRENT_PROGRAM );

…which will give you a render loop that looks something like…

myThreeRenderer.render( scene, camera );
var currentProgram = GL.getParameter( GL.CURRENT_PROGRAM );
GL.useProgram( currentProgram );

You simply read back what program is currently loaded and put it back in when you’re done with your GLOW calls. A bit hackish, but it works.