jeromeetienne / tquery

extension system for three.js
http://jeromeetienne.github.io/tquery/
MIT License
652 stars 119 forks source link

more efficient glow - single render #292

Open jeromeetienne opened 11 years ago

jeromeetienne commented 11 years ago

TODO to do a single render, which output color + depth + stencil. in this render, i fill stencil with the pixel which should glow, then i do a pass with this output to do the blur, get i merge with the original color texture ?

lmg: renderer.clear() has 3 flags
[3:55pm] lmg: .clear( color, depth, stencil )
[3:55pm] jetienne: https://github.com/mrdoob/three.js/blob/master/src/renderers/WebGLRenderTarget.js#L32 <- 'this.shareDepthFrom = null;' it looks like it may be possible to share depth
[3:55pm] jetienne: lmg: got it
[3:55pm] jetienne: (btw i dunno stencil either) 
[3:55pm] lmg: it might be just what you need, stencil
[3:56pm] lmg: if you manage to fill it in render1
[3:56pm] lmg: unfortunatly I don't know enough about threejs' internals to be of real help here 
[3:57pm] lmg: prolly only used for shadows.
[3:57pm] jetienne: describe the process, i will try to do the three.js support part later 
[3:57pm] jetienne: thinking bokeh may have stuff like that… is it crazy
[3:57pm] lmg: well it's much like lighting, just the other way round
[3:58pm] lmg: every glowing face that is visible from the camera needs to set its stencilbuffer "pixel" to, say, white
[4:00pm] jetienne: ok
[4:00pm] • jetienne is searching the web to find an 'stencil buffer' intro 
[4:02pm] jetienne: http://en.wikibooks.org/wiki/OpenGL_Programming/Stencil_buffer seems cool
[4:05pm] jetienne: this is a very good page even
[4:06pm] jetienne: oh i think i get it
[4:07pm] jetienne: lmg: you want me to do a single render, which output color + depth + stencil. in this render, i fill stencil with the pixel which should glow, then i do a pass with this output to do the blur, get i merge with the original color texture ?
[4:07pm] lmg: exactly, saving you the extra render
[4:07pm] jetienne: thus i do only one pass of rendering geometry
[4:07pm] • lmg nods
[4:07pm] jetienne: lmg: cool! i got it 
[4:07pm] jetienne: thanks a bunch