No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CustomTextureGraph.hlsl 788B

1234567891011121314151617181920212223242526272829
  1. #ifndef CUSTOM_TEXTURE_GTRAPH
  2. #define CUSTOM_TEXTURE_GTRAPH
  3. float4 SRGBToLinear( float4 c ) { return c; }
  4. float3 SRGBToLinear( float3 c ) { return c; }
  5. // Unpack normal as DXT5nm (1, y, 1, x) or BC5 (x, y, 0, 1)
  6. // Note neutral texture like "bump" is (0, 0, 1, 1) to work with both plain RGB normal and DXT5nm/BC5
  7. float3 UnpackNormalmapRGorAG(float4 packednormal)
  8. {
  9. // This do the trick
  10. packednormal.x *= packednormal.w;
  11. float3 normal;
  12. normal.xy = packednormal.xy * 2 - 1;
  13. normal.z = sqrt(1 - saturate(dot(normal.xy, normal.xy)));
  14. return normal;
  15. }
  16. inline float3 UnpackNormal(float4 packednormal)
  17. {
  18. #if defined(UNITY_NO_DXT5nm)
  19. return packednormal.xyz * 2 - 1;
  20. #else
  21. return UnpackNormalmapRGorAG(packednormal);
  22. #endif
  23. }
  24. #endif // CUSTOM_TEXTURE_GTRAPH