-
Notifications
You must be signed in to change notification settings - Fork 262
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
Feature Request: More Fine-Grained Control Over Texture Units #189
Comments
I'm not really sure this can be handled in a good way in twgl. You're free to mix twgl and raw WebGL as twgl doesn't keep any state. I do that often. As for this case I can think of 2 ways, both with issues.
Further, what are you doing that this level of optimization matters? Yes, you could make less calls into WebGL by organizing which texture units are used but are you doing this operation 5000 times per frame or just 1, 2 or 3 times per frame? If it's like normal, just a few times a frame, then if it was me I wouldn't worry about it and just set all the uniforms every time. |
Thanks so much for the quick and comprehensive answer! I didn't know about the |
Just to clarify
It's not a pattern. I was a possible solution but has issues so I didn't implement it
I'm not sure what this means. You can render just fine if the current program is not using the texture that is in the current framebuffer. Example: https://jsgist.org/?src=ac918fbac37047b5170bac55361eaa8d Note: branching in a program so that the the texture is not accessed does not count as "not using". |
Oh, misunderstanding then, I thought this pattern is already implemented. So I got some errors and thought it's because I can't have the framebuffer I'm rendering to bound to some texture unit at the same time, but probably the errors were just because I used an unsupported pattern. Regarding a solution, maybe I don't understand WebGL well enough, but would it be possible to have some optional parameter in |
Hi, I often have the situation where there is a texture which should be available to all programs at all times and then I have two framebuffers between which I play ping-pong. My understanding is that in vanilla WebGL I would bind the texture to the first texture unit and the framebuffers to the second and third texture unit and then only call
uniform1i
to tell the programs which framebuffers they should be using. Or, if I have program A which reads from FB 0 and writes to FB 1 and then program B which reads from FB 1 and writes to FB 0, I wouldn't even need to change any uniforms in the render loop. Yet with TWGL, I haven't found a method to achieve this, as it will always put the first texture I add as a uniform in the first texture unit, and so on, with this process repeated for each program I set the uniforms, so I need to rebind textures in the render loop instead of just resetting uniforms. Again, that's just my understanding, maybe I'm wrong though.The text was updated successfully, but these errors were encountered: