read-from-texture.glsl 424 B

12345678910111213
  1. /**
  2. * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. vec4 readFromTexture (const in sampler2D tex, const in float i, const in vec2 size) {
  7. float x = mod(i, size.x);
  8. float y = floor(i / size.x);
  9. vec2 uv = (vec2(x, y) + 0.5) / size;
  10. return texture2D(tex, uv);
  11. }
  12. #pragma glslify: export(readFromTexture)