{"action":"created","issue":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/4221","labels_url":"https://api.github.com/repos/mrdoob/three.js/issues/4221/labels{/name}","comments_url":"https://api.github.com/repos/mrdoob/three.js/issues/4221/comments","events_url":"https://api.github.com/repos/mrdoob/three.js/issues/4221/events","html_url":"https://github.com/mrdoob/three.js/issues/4221","id":24435978,"number":4221,"title":"Proposal: Decoupling WebGLRenderer from ThreeJS Scene graph","user":{"login":"bhouston","id":588541,"avatar_url":"https://avatars.githubusercontent.com/u/588541?v=3","gravatar_id":"","url":"https://api.github.com/users/bhouston","html_url":"https://github.com/bhouston","followers_url":"https://api.github.com/users/bhouston/followers","following_url":"https://api.github.com/users/bhouston/following{/other_user}","gists_url":"https://api.github.com/users/bhouston/gists{/gist_id}","starred_url":"https://api.github.com/users/bhouston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhouston/subscriptions","organizations_url":"https://api.github.com/users/bhouston/orgs","repos_url":"https://api.github.com/users/bhouston/repos","events_url":"https://api.github.com/users/bhouston/events{/privacy}","received_events_url":"https://api.github.com/users/bhouston/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mrdoob/three.js/labels/Suggestion","name":"Suggestion","color":"ffffcf"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":32,"created_at":"2013-12-17T17:19:20Z","updated_at":"2015-08-11T19:54:19Z","closed_at":null,"body":"Hey all,  I've been a bit absent from contributing recently, maybe that can change a bit...\r\n\r\nThis might seem like a radical idea and I admit that I am little worried that I am proposing that I take this one, but I think it is something that needs to be done.  Let me explain.\r\n\r\n* First, there is this idea of shader batching, it is a means of getting the fastest performance possible from a GPU.  It involves the reordering of scene data so that you group it by shaders to minimize costly state changes in the render pipeline:\r\n\r\nhttp://home.comcast.net/~tom_forsyth/blog.wiki.html#%5B%5BRenderstate%20change%20costs%5D%5D\r\n\r\nI think ThreeJS needs this for maximum speed.\r\n\r\n* The second issue is the high complexity of the WebGLRenderer class.  While it is easy to use, it is actually fairly complex internally.  I think that we could separate it out so that the GPU renderable Mesh, Particle and Line data isn't built and maintained in the renderer, but rather as separate classes.  Thus there is WebGLMesh, WebGLParticles and WebGLLine that are self-contained generally rather than being implicit classes withing the WebGLRenderer.\r\n\r\n* The third issue is that I would like to separate out the traversal of the ThreeJS scene graph from WebGLRenderer.  If we are going to allow reordering of the renderable items, I think it is best to separate out the traversal of the ThreeJS Scene to be a separate class.  This we could have standard separate WebGLSceneTraverser that basically goes over the scene and converts the data to WebGLMesh, WebGLParticles and WebGLLine and submits these to the shader batching core.  This last issue would allow for people to write things that do not use the standard ThreeJS Scene graph in the standard way, the could write their own algorithm that submits WebGLMeshes, WebGLParticles and WebGLLines to the renderer in any fashion they want.\r\n\r\nOverall, I think this could speed things up (via shader batching), reduce the complexity of the WebGLRenderer class (by separating out the WebGLMesh, WebGLParticles and WebGLLines as well as the SceneTraverser), and increase the usefulness of ThreeJS's WebGLRenderer outside of strict ThreeJS Scene rendering.\r\n\r\nI will have some time over the Christmas break to make an attempt at implementing this if it could possibly be desired.  I think that these changes can be limited to just the WebGL components so that the other renderers can stay the same.  I think I can even keep the main interface to the new WebGLRendererX class the same as the other renderers.\r\n\r\nI've written a shader batcher before as well as a scene traverser, just not for WebGL, rather DirectX 10.  Thus I do have a workable design that I can merge together with ThreeJS.\r\n\r\nLet me know if I shouldn't attempt this or what other improvements I should try to work in if you think this is a good idea.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/comments/130044336","html_url":"https://github.com/mrdoob/three.js/issues/4221#issuecomment-130044336","issue_url":"https://api.github.com/repos/mrdoob/three.js/issues/4221","id":130044336,"user":{"login":"titansoftime","id":6549763,"avatar_url":"https://avatars.githubusercontent.com/u/6549763?v=3","gravatar_id":"","url":"https://api.github.com/users/titansoftime","html_url":"https://github.com/titansoftime","followers_url":"https://api.github.com/users/titansoftime/followers","following_url":"https://api.github.com/users/titansoftime/following{/other_user}","gists_url":"https://api.github.com/users/titansoftime/gists{/gist_id}","starred_url":"https://api.github.com/users/titansoftime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/titansoftime/subscriptions","organizations_url":"https://api.github.com/users/titansoftime/orgs","repos_url":"https://api.github.com/users/titansoftime/repos","events_url":"https://api.github.com/users/titansoftime/events{/privacy}","received_events_url":"https://api.github.com/users/titansoftime/received_events","type":"User","site_admin":false},"created_at":"2015-08-11T19:54:19Z","updated_at":"2015-08-11T19:54:19Z","body":"I've gotta ask.. what's up with all this? Is the current dev build working towards this?"}}