spv.sparseTextureClamp.frag 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #version 450
  2. #extension GL_ARB_sparse_texture_clamp: enable
  3. uniform sampler2D s2D;
  4. uniform sampler3D s3D;
  5. uniform sampler2DShadow s2DShadow;
  6. uniform samplerCubeShadow sCubeShadow;
  7. uniform sampler2DArrayShadow s2DArrayShadow;
  8. uniform sampler2DRectShadow s2DRectShadow;
  9. uniform samplerCubeArrayShadow sCubeArrayShadow;
  10. uniform isamplerCube isCube;
  11. uniform isampler2DArray is2DArray;
  12. uniform usamplerCubeArray usCubeArray;
  13. uniform usampler2DRect us2DRect;
  14. in vec2 c2;
  15. in vec3 c3;
  16. in vec4 c4;
  17. in float lodClamp;
  18. out vec4 outColor;
  19. void main()
  20. {
  21. int resident = 0;
  22. vec4 texel = vec4(0.0);
  23. ivec4 itexel = ivec4(0);
  24. uvec4 utexel = uvec4(0);
  25. resident |= sparseTextureClampARB(s2D, c2, lodClamp, texel);
  26. resident |= sparseTextureClampARB(s3D, c3, lodClamp, texel, 2.0);
  27. resident |= sparseTextureClampARB(isCube, c3, lodClamp, itexel);
  28. resident |= sparseTextureClampARB(s2DShadow, c3, lodClamp, texel.x);
  29. resident |= sparseTextureClampARB(sCubeArrayShadow, c4, 1.0, lodClamp, texel.x);
  30. texel += textureClampARB(s2D, c2, lodClamp);
  31. texel += textureClampARB(s3D, c3, lodClamp, 2.0);
  32. itexel += textureClampARB(isCube, c3, lodClamp);
  33. texel.x += textureClampARB(s2DShadow, c3, lodClamp);
  34. texel.x += textureClampARB(sCubeArrayShadow, c4, 1.0, lodClamp);
  35. resident |= sparseTextureOffsetClampARB(s3D, c3, ivec3(2), lodClamp, texel, 2.0);
  36. resident |= sparseTextureOffsetClampARB(us2DRect, c2, ivec2(3), lodClamp, utexel);
  37. resident |= sparseTextureOffsetClampARB(s2DArrayShadow, c4, ivec2(5), lodClamp, texel.z);
  38. texel += textureOffsetClampARB(s3D, c3, ivec3(2), lodClamp, 2.0);
  39. utexel += textureOffsetClampARB(us2DRect, c2, ivec2(3), lodClamp);
  40. texel.z += textureOffsetClampARB(s2DArrayShadow, c4, ivec2(5), lodClamp);
  41. resident |= sparseTextureGradClampARB(s3D, c3, c3, c3, lodClamp, texel);
  42. resident |= sparseTextureGradClampARB(sCubeShadow, c4, c3, c3, lodClamp, texel.y);
  43. resident |= sparseTextureGradClampARB(usCubeArray, c4, c3, c3, lodClamp, utexel);
  44. texel += textureGradClampARB(s3D, c3, c3, c3, lodClamp);
  45. texel.y += textureGradClampARB(sCubeShadow, c4, c3, c3, lodClamp);
  46. utexel += textureGradClampARB(usCubeArray, c4, c3, c3, lodClamp);
  47. resident |= sparseTextureGradOffsetClampARB(s2D, c2, c2, c2, ivec2(5), lodClamp, texel);
  48. resident |= sparseTextureGradOffsetClampARB(s2DRectShadow, c3, c2, c2, ivec2(6), lodClamp, texel.w);
  49. resident |= sparseTextureGradOffsetClampARB(is2DArray, c3, c2, c2, ivec2(2), lodClamp, itexel);
  50. texel += textureGradOffsetClampARB(s2D, c2, c2, c2, ivec2(5), lodClamp);
  51. texel.w += textureGradOffsetClampARB(s2DRectShadow, c3, c2, c2, ivec2(6), lodClamp);
  52. itexel += textureGradOffsetClampARB(is2DArray, c3, c2, c2, ivec2(2), lodClamp);
  53. outColor = sparseTexelsResidentARB(resident) ? texel : vec4(itexel) + vec4(utexel);
  54. }