Skip to content
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

After calling WebGLRenderer.resetState() subsequent render does not setup VertexAttributes #23688

Closed
boourns opened this issue Mar 9, 2022 · 1 comment · Fixed by #23691
Closed

Comments

@boourns
Copy link
Contributor

boourns commented Mar 9, 2022

Describe the bug

After calling renderer.resetState(), the next three.js render does not call enableVertexAttribArray, or vertexAttribPointer.

To Reproduce

In a situation where three.js is being used in conjunction with other webgl shaders on the same webgl context, if another shader calls gl.enableVertexAttribArray or gl.vertexAttribPointer, three.js does not reset that state on subsequent render calls even if renderer.resetState() is being called.

See live demo of the issue on the jsfiddle below. The webgl shader is not actually doing anything, it is just there to demonstrate the effect of calling gl.enableVertexAttribArray.

Comment/uncomment lines 93-94 to demonstrate the issue.

https://jsfiddle.net/tom3000/us0bh6v1/127/

One workaround is to clear and re-create the scene every render call but obviously that's terrible for performance, so hopefully I can find a way to get three.js to re-set the vertex array bindings.

Expected behavior

WebGLRenderer.resetState() should clear the cached state for these buffers and make the necessary webgl calls on subsequent render.

I opened PR #23689 in an attempt to fix this myself, but the e2e testing caught two issues so I've closed it for now.

Platform:

  • Device: Desktop
  • OS: MacOS
  • Browser: Firefox
  • Three.js version: 0.138.0
@boourns
Copy link
Contributor Author

boourns commented Mar 9, 2022

Looks like perhaps this has been discussed already in #20549

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant