fand / veda

⚡VJ / Live Coding on Atom⚡
http://veda.gl/
MIT License
509 stars 34 forks source link

When using multipass in multiple shaders, the buffers will persist between shaders if they share the same name. #240

Open sp4ghet opened 4 years ago

sp4ghet commented 4 years ago

I think the behaviour we expect is for the buffers to reset when we change shaders, so that a buffer write from one shader doesn't persist in the next shader. If this is expected behaviour, feel free to close.

I'll try and fix it and send a PR within the week but if it's a no-brainer also feel free to fix it for me :p

fand commented 4 years ago

ah, I wasn't aware that buffers don't reset on changing shaders... The expected behavior is exactly that you wrote above.

sp4ghet commented 4 years ago

Unfortunately, I can't seem to replicate the issue I was having enough to pinpoint what the cause is...

Essentially, when I was writing the ray tracing code, occasionally a shader that I hadn't modified would render very differently than it usually does because I was using a different shader for a while, which had normals pointing the wrong way. Thus, my assumption was that the "accumulate" pass buffer was persisting between shaders. I'm unsure what the actual problem was, but I solved it by reloading the window whenever that happened.

It might have something to do with filling buffers with NaNs, but I'm not really sure what caused it. In any case, under normal use, it seems like the buffers don't persist, but I definitely experienced some cases where it did persist (I also had a shader which purely played vided, and another shader which would render raytracing, and the accumulate buffer would show the video)