Files
cocos4/editor/assets/chunks/common.chunk
T
jk20012001 eb883997a1 Fix #10538: Android+WebGL PS struct variables has mediump precision (#9863)
* Fix #10538: Android+WebGL PS struct variables has mediump precision

* update compiled shaders

* review modification

* update compiled shaders
2021-12-24 11:01:54 +08:00

49 lines
1.8 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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
// runtime constants
#pragma define CC_DEVICE_SUPPORT_FLOAT_TEXTURE default(1)
#pragma define CC_DEVICE_MAX_FRAGMENT_UNIFORM_VECTORS default(1024)
#pragma define CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS default(1024)
#pragma define CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS default(128)
#pragma define CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS default(128)
#pragma define CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT default(0)
#pragma define CC_PLATFORM_ANDROID_AND_WEBGL default(0)
#pragma define CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES default(0)
// use cluster shading or not
#pragma define CC_ENABLE_CLUSTERED_LIGHT_CULLING default(0)
// When sampling RTs, Y-flip is needed if the screen space sign Y is positive (pointing upwards)
#define CC_HANDLE_RT_SAMPLE_FLIP(uv) uv = cc_cameraPos.w > 1.0 ? vec2(uv.x, 1.0 - uv.y) : uv
#define CC_HANDLE_GET_CLIP_FLIP(uv) uv = cc_cameraPos.w == 0.0 ? vec2(uv.x, -uv.y) : uv
#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;
}
float isNan(float val)
{
return (val <= 0.0 || 0.0 <= val) ? 0.0 : 1.0;
}