fs_texture_cube.sc 508 B

123456789101112131415161718192021
  1. $input v_texcoord0, v_color0
  2. /*
  3. * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
  4. * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
  5. */
  6. #include <bgfx_shader.sh>
  7. SAMPLERCUBE(s_texColor, 0);
  8. uniform mat4 u_mtx;
  9. uniform vec4 u_params;
  10. #define u_textureLod u_params.x
  11. void main()
  12. {
  13. vec3 dir = vec3( (v_texcoord0*2.0 - 1.0) * vec2(1.0, -1.0), 1.0);
  14. dir = normalize(mul(u_mtx, vec4(dir, 0.0) ).xyz);
  15. gl_FragColor = textureCubeLod(s_texColor, dir, u_textureLod) * v_color0;
  16. }