{"action":"created","issue":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/12144","repository_url":"https://api.github.com/repos/mrdoob/three.js","labels_url":"https://api.github.com/repos/mrdoob/three.js/issues/12144/labels{/name}","comments_url":"https://api.github.com/repos/mrdoob/three.js/issues/12144/comments","events_url":"https://api.github.com/repos/mrdoob/three.js/issues/12144/events","html_url":"https://github.com/mrdoob/three.js/issues/12144","id":255718823,"node_id":"MDU6SXNzdWUyNTU3MTg4MjM=","number":12144,"title":"Render object direct","user":{"login":"pailhead","id":4681282,"node_id":"MDQ6VXNlcjQ2ODEyODI=","avatar_url":"https://avatars0.githubusercontent.com/u/4681282?v=4","gravatar_id":"","url":"https://api.github.com/users/pailhead","html_url":"https://github.com/pailhead","followers_url":"https://api.github.com/users/pailhead/followers","following_url":"https://api.github.com/users/pailhead/following{/other_user}","gists_url":"https://api.github.com/users/pailhead/gists{/gist_id}","starred_url":"https://api.github.com/users/pailhead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pailhead/subscriptions","organizations_url":"https://api.github.com/users/pailhead/orgs","repos_url":"https://api.github.com/users/pailhead/repos","events_url":"https://api.github.com/users/pailhead/events{/privacy}","received_events_url":"https://api.github.com/users/pailhead/received_events","type":"User","site_admin":false},"labels":[{"id":58673,"node_id":"MDU6TGFiZWw1ODY3Mw==","url":"https://api.github.com/repos/mrdoob/three.js/labels/Question","name":"Question","color":"dad9ff","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-09-06T19:37:36Z","updated_at":"2018-07-17T01:19:32Z","closed_at":"2018-07-17T01:18:55Z","author_association":"CONTRIBUTOR","body":"What i originally wanted to do with `onBeforeRender()` was something like this:\r\n\r\n```\r\nfoo.onBeforeRender = ( renderer , scene , camera )=>{\r\n\r\n\t\r\n\t _gl.enable(_gl.STENCIL_TEST)\r\n\r\n\t_gl.clearStencil( 0 )\r\n\t_gl.clear( _gl.STENCIL_BUFFER_BIT )\r\n\t_gl.stencilFunc( _gl.ALWAYS , 1 , 1 )\r\n\t_gl.stencilOp( _gl.REPLACE , _gl.REPLACE , _gl.REPLACE )\r\n        ....\r\n       \r\n        renderer.render( foo, overrideMaterial, camera ) \r\n}\r\n```\r\n\r\nI used to piggyback on a hack of `renderBufferDirect`, but i had to pass all the stuff that it wanted so i had to expose all of its arguments in `onBeforeRender`,\r\n\r\nI've updated to r87 to actually use the official onBeforeRender but i'm baffled and not sure what to do. \r\n\r\nI wanted all of this logic to happen in the callback, either onBeforeRender or onAfterRender on last on the first (or last) thing i want to draw in sequence.\r\n\r\nMy scene graph looks something like this:\r\n\r\n```\r\n  ├ ObjBravo\r\n     ├ meshA\r\n     └ meshB\r\n```\r\n\r\nwhat i want to happen is:\r\n\r\n0. render stuff\r\n1. set stencil\r\n2. draw A with shader FOO\r\n3. stencil op\r\n4. draw B\r\n5. stencil op\r\n6. draw A with shader BAR\r\n7. clear stencil\r\n8. render other stuff\r\n\r\nI'm about to try making another mesh C, with the geometry from A but a different shader and change the render order. I'm concerned though that render order doesn't play well with transparency, and that i have to set a unique number for each one of these if i render multiple. \r\n\r\nIs there a better way of doing this? Could another method on the renderer help?\r\n\r\n##### Three.js version\r\n\r\n- [ ] Dev\r\n- [x ] r87\r\n- [ ] ...\r\n\r\n##### Browser\r\n\r\n- [x] All of them\r\n- [ ] Chrome\r\n- [ ] Firefox\r\n- [ ] Internet Explorer\r\n\r\n##### OS\r\n\r\n- [x] All of them\r\n- [ ] Windows\r\n- [ ] macOS\r\n- [ ] Linux\r\n- [ ] Android\r\n- [ ] iOS\r\n\r\n##### Hardware Requirements (graphics card, VR Device, ...)\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/comments/405428761","html_url":"https://github.com/mrdoob/three.js/issues/12144#issuecomment-405428761","issue_url":"https://api.github.com/repos/mrdoob/three.js/issues/12144","id":405428761,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNTQyODc2MQ==","user":{"login":"pailhead","id":4681282,"node_id":"MDQ6VXNlcjQ2ODEyODI=","avatar_url":"https://avatars0.githubusercontent.com/u/4681282?v=4","gravatar_id":"","url":"https://api.github.com/users/pailhead","html_url":"https://github.com/pailhead","followers_url":"https://api.github.com/users/pailhead/followers","following_url":"https://api.github.com/users/pailhead/following{/other_user}","gists_url":"https://api.github.com/users/pailhead/gists{/gist_id}","starred_url":"https://api.github.com/users/pailhead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pailhead/subscriptions","organizations_url":"https://api.github.com/users/pailhead/orgs","repos_url":"https://api.github.com/users/pailhead/repos","events_url":"https://api.github.com/users/pailhead/events{/privacy}","received_events_url":"https://api.github.com/users/pailhead/received_events","type":"User","site_admin":false},"created_at":"2018-07-17T01:19:32Z","updated_at":"2018-07-17T01:19:32Z","author_association":"CONTRIBUTOR","body":"This got addressed in the meantime. The issue was referring to the responsibilities of `renderBufferDirect`\r\n\r\nhttps://github.com/mrdoob/three.js/blob/c318c586881d8ece16fe26de55bd0090e2df53ad/src/renderers/WebGLRenderer.js#L665-L693"}}
{"actor":{"display_login":"pailhead"}}