// Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd. // common module // constant value #define PI 3.14159265359 #define PI2 6.28318530718 #define EPSILON 1e-6 #define LOG2 1.442695 // common function #define saturate(a) clamp(a, 0.0, 1.0) #define FP_MAX 65504.0 #define FP_SCALE 0.0009765625 #define FP_SCALE_INV 1024.0 #define STEP_FINT_128(v) (step(128.0, (v) + 0.5)) #define MOD_FINT_128(v) (mod(float(int((v) + 0.5)), 128.0)) highp float decode32 (highp vec4 rgba) { rgba = rgba * 255.0; highp float Sign = 1.0 - STEP_FINT_128(rgba[3]) * 2.0; highp float Exponent = 2.0 * MOD_FINT_128(rgba[3]) + STEP_FINT_128(rgba[2]) - 127.0; highp float Mantissa = MOD_FINT_128(rgba[2]) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0; return Sign * exp2(Exponent - 23.0) * Mantissa; }