mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
3375a5cf15
* toon receives shadow * fix gfx state cache * 背面消影 * merge cc_ShadowPCF && cc_ShadowMapSize to cc_ShadowInfo; add bias to shader and editor * update * merge pr #7452 https://github.com/cocos-creator/engine/pull/7452 * reomve atten; use NL Co-authored-by: Yun Hsiao Wu <inheritorofgalaxy@gmail.com>
28 lines
819 B
Plaintext
28 lines
819 B
Plaintext
// 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;
|
|
}
|