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

Allow mixing of static and dynamic selector values #24

Open
katamartin opened this issue Oct 11, 2021 · 0 comments
Open

Allow mixing of static and dynamic selector values #24

katamartin opened this issue Oct 11, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@katamartin
Copy link
Member

For array-based selector values, we currently assume that the values of the array are fixed and directly map the all elements of the array to generate shader variables. In practice, this means that if you want to dynamically reference elements of the array, extra logic and uniforms must be used to handle dynamic selection within the fragment shader. This is less-than-ideal for a number of reasons:

  • subject to 16 variable limit for texture definitions in the fragment shader
  • loading unused data onto GPU
  • requires some gymnastics with additional uniforms (see example)

We should consider undoing this assumption and updating the selector prop to accommodate this type of "mixed" selection.

Example of current integration

Consider an example where multiple variables (in this case multiple measures of the same variable, prec) can be averaged over area).

in Map definition

uniforms={{measureUniform}}
selector={{
  band: ['area', 'prec_measure_1', 'prec_measure_2', 'prec_measure_3', ...],
}}

in fragment shader:

float prec;
if (measureUniform == 1.0) {
  prec = prec_measure_1;
}
if (measureUniform == 2.0) {
  prec = prec_measure_2;
}
  ...

float value = prec / area;

Potential integration

in Map definition

selector={{
  band: ['area', {prec: `prec_measure_${measurementId}`}],
}}

in fragment shader:
(no custom shader code for measure selection required, prec can be used directly)

float value = prec / area;
@katamartin katamartin added the enhancement New feature or request label Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant