lodCube.ts 861 B

123456789101112131415161718192021222324252627282930313233
  1. import { Effect } from "babylonjs/Materials/effect";
  2. let name = 'lodCubePixelShader';
  3. let shader = `
  4. varying vec2 vUV;
  5. uniform samplerCube textureSampler;
  6. uniform float lod;
  7. void main(void)
  8. {
  9. vec2 uv=vUV*2.0-1.0;
  10. #ifdef POSITIVEX
  11. gl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x),lod);
  12. #endif
  13. #ifdef NEGATIVEX
  14. gl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x),lod);
  15. #endif
  16. #ifdef POSITIVEY
  17. gl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x),lod);
  18. #endif
  19. #ifdef NEGATIVEY
  20. gl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x),lod);
  21. #endif
  22. #ifdef POSITIVEZ
  23. gl_FragColor=textureCube(textureSampler,vec3(uv,1.001),lod);
  24. #endif
  25. #ifdef NEGATIVEZ
  26. gl_FragColor=textureCube(textureSampler,vec3(uv,-1.001),lod);
  27. #endif
  28. }`;
  29. Effect.ShadersStore[name] = shader;
  30. /** @hidden */
  31. export var lodCubePixelShader = { name, shader };