apply method

void apply(
  1. FragmentShader shader
)

Implementation

void apply(FragmentShader shader) {
  int indexFloat = startFloatIndex;
  int indexImage = startImageIndex;
  for (var item in values) {
    if (item is SetterDouble) {
      shader.setFloat(indexFloat, item.value);
      indexFloat++;
    }
    if (item is SetterImage) {
      shader.setImageSampler(indexImage, item.value);
      indexImage++;
    }

    if (item is SetterVector2) {
      shader.setFloat(indexFloat, item.value.x);
      indexFloat++;
      shader.setFloat(indexFloat, item.value.y);
      indexFloat++;
    }

    if (item is SetterColor) {
      final color = item.value;
      shader.setFloat(indexFloat, color.red / 255 * color.opacity);
      indexFloat++;
      shader.setFloat(indexFloat, color.green / 255 * color.opacity);
      indexFloat++;
      shader.setFloat(indexFloat, color.blue / 255 * color.opacity);
      indexFloat++;
      shader.setFloat(indexFloat, color.opacity);
      indexFloat++;
    }
  }
}