Common-Compute.cginc 620 B

12345678910111213141516171819202122232425262728293031
  1. #include "UnityCG.cginc"
  2. #if defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2)
  3. #define PCX_COPY_FOG(o, i) o.fogCoord = i.fogCoord;
  4. #else
  5. #define PCX_COPY_FOG(o, i)
  6. #endif
  7. half4 UnpackColor32(uint c)
  8. {
  9. return (uint4(c, c >> 8, c >> 16, c >> 24) & 0xff) / 255.0;
  10. }
  11. half3 UnpackColor(float p)
  12. {
  13. uint i = asuint(p);
  14. return half3(
  15. ((i ) & 0x7ff) / 256.0,
  16. ((i >> 11) & 0x7ff) / 256.0,
  17. ((i >> 22) & 0x3ff) / 128.0
  18. );
  19. }
  20. float PackColor(half3 rgb)
  21. {
  22. uint r = rgb.r * 256;
  23. uint g = rgb.r * 256;
  24. uint b = rgb.r * 256;
  25. return r | (g << 11) | (b << 22);
  26. }