-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sharing depth buffer between targets #15440
Comments
I don't think so... How do you think the API for this should be? |
I'm not entirely sure. Not to open the old can of worms :) but it seems worth while mentioning that this problem seems similar to the chunk one I've been boring everyone with. As I see it, there are many things private to the renderer that maps to low level Webgl api/state and some times you need access to it. When you want to modify the shader code, it doesn't exist until the renderer does the init. If you then want to modify it, you're given a hook. So in line with that approach, each one of these private methods could have a hook. They might not have to be as granular, but more abstract The API I might favor, is similar to the chunks I proposed, and the hack in the snippet. For every property This could be left kinda open, hacky and raw where you would call:
Or
And then the internals would still call the The third way would maybe be to just expose all of the state of the renderer. It would allow for more hacking. If you could access this cache, and understand what happens when, between two targets that Three set's up, you could nuke one buffer, and link the second one. All of these have some overlaps. Exposing all of the internals may be the most flexible. If there isn't a hook, you can monkey patch your own method or class with a hook if you need it. For example, instead of waiting for the next frame or something to check The The |
Here's an example of how I'm using this: https://raw.githack.com/pailhead/three.js/depth-peel-stencil/examples/webgl_materials_depthpeel.html The little quads kinda show what's going on, but I want to try to visualize it better. There are two targets being flip flopped, so the same scene is being drawn to both of them. But with each pass, I do some stencil logic, and I keep it around for the next one. Because each pass needs to write something to it, I need to keep the same buffer between both targets. |
Wow, sharing between the final composition target as well made it run at 60fps at half rez on an iphone. I think this would be a useful feature. Unfortunately i'm running into some depth precision issues there. |
@pailhead Can you explain a bit more about why using DepthTexture wouldn't work? At least on the surface it seems to be what you're interested in, granted it requires an extension to work. |
Closing in favor of #15490. |
Well, if both more or less contain the same discussion I think it's okay. Especially since the initial post (#15490 (comment)) is very detailed and contains all relevant information. Besides, we don't need for each PR a corresponding issue. |
I'm experimenting with an effect that uses the stencil buffer. I'd like to be able to share the depth/stencil render buffer between different targets.
It seems like i've been able to do what i want by changing this:
three.js/src/renderers/webgl/WebGLTextures.js
Line 814 in b2ca569
to:
and creating the buffer myself on the render target.
I am unable to find a way to do this without modifying the library. The super private caching internals seem to be in the way, since
createRenderbuffer()
is both called and stored inside the renderer.I don't understand what exactly
depthTexture
is, but it seems like it is something similar to this, and can be provided from outside. Is there a way to achieve what i'm doing here without the hack?The text was updated successfully, but these errors were encountered: