-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Objective `prepare_uinodes` creates a new `UiBatch` whenever the texture changes, when most often it's just queuing untextured quads. Instead of switching textures, we can reduce the number of batches generated significantly by adding a condition to the fragment shader so that it only multiplies by the `textureSample` value when drawing a textured quad. # Solution Add a `mode` field to `UiVertex`. In `prepare_uinodes` set `mode` to 0 if the quad is textured or 1 if untextured. Add a condition to the fragment shader that only multiplies by the `color` value from `textureSample` if `mode` is set to 1. --- ## Changelog * Added a `mode` field to `UiVertex`, and added an extra `u32` vertex attribute to the shader and vertex buffer layout. * In `prepare_uinodes` mode is set to 0 for the vertices of textured quads, and 1 if untextured. * Added a condition to the fragment shader in `ui.wgsl` that only multiplies by the `color` value from `textureSample` if the mode is equal to 0.
- Loading branch information
Showing
3 changed files
with
44 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters