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