feat: Materials can now use the screen texture #2849
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
===:clipboard: PR Checklist :clipboard:===
==================
water-material.mp4
This PR adds a new feature for materials that allows them to reference the screen texture. They way it works is it's the screen's framebuffer RIGHT before the material draw call (if you include the complete drawing you get the infinite mirror artifact which is pretty unusable)
2 new uniforms
u_screen_texture
- This is the texture of the screen right before the material draw callu_time_ms
- This is the milliseconds since page navigation (performance.now()
under the hood)2 new attribute/varyings
a_screenuv
- The vertex attribute corresponding to the screen uv relative to the current graphicv_screenuv
- The fragment varying corresponding to the screen uv relative to the current graphicFinally there is a new convenience api for updating shader values in materials.
.update(shader => {...})