函数说明
abs-取绝对值acos-反余弦函数acosh-反双曲余弦函数all-返回一个bool值,指示是否所有的值都为真any-返回一个bool值,指示是否有任何一个值为真asin-反正弦函数asinh-反双曲正弦函数atan-反正切函数atanh-反双曲正切函数ceil-向上取整clamp-将值限制在指定的范围内cos-余弦函数cosh-双曲余弦函数cross-计算向量叉积dFdx-返回一个向量或标量的x分量的导数dFdy-返回一个向量或标量的y分量的导数degrees-将弧度转换为角度determinant-计算矩阵的行列式distance-计算两个向量之间的距离dot-计算两个向量的点积equal-检查两个参数是否相等exp-计算自然指数函数的值exp2-计算2的幂次方faceforward-返回表面法线朝向floatBitsToInt-将浮点数转换为带符号整数floatBitsToUint-将浮点数转换为无符号整数floor-返回小于等于输入值的最大整数fract-返回输入值的小数部分fwidth-返回函数对输入值的x和y方向导数的绝对值之和gl_FragCoord-获取像素坐标信息gl_FragDepth-获取像素深度值gl_FrontFacing-判断面的方向gl_InstanceID-获取实例IDgl_PointCoord-获取点的纹理坐标gl_PointSize-获取点的大小gl_Position-获取顶点位置gl_VertexID-获取顶点IDgreaterThan-比较两个向量的大小greaterThanEqual-比较两个向量的大小intBitsToFloat-转换整型位表示的浮点数为单精度浮点数inverse-求逆矩阵inversesqrt-求倒数的平方根isinf-判断浮点数是否为正或负无穷大isnan-判断浮点数是否为NaNlength-返回向量长度lessThan-逐元素比较两个向量并返回bool向量lessThanEqual-逐元素比较两个向量并返回bool向量,小于或等于返回truelog-计算以e为底的对数log2-计算以2为底的对数matrixCompMult-Matrix元素逐一相乘max-返回两个数的较大值min-返回两个数的较小值mix-线性混合两个值mod-计算浮点数除法的余数modf-返回浮点数的整数和小数部分normalize-向量单位化not-按位求反notEqual-按位不等outerProduct-向量外积packHalf2x16-将两个浮点数压缩成半精度packSnorm2x16-将两个浮点数压缩成符号化半精度packUnorm2x16-将两个浮点数压缩成无符号半精度pow-幂函数radians-角度转弧度reflect-计算反射向量refract-计算折射向量round-四舍五入roundEven-根据奇偶性舍入sign-符号函数sin-正弦函数sinh-双曲正弦函数smoothstep-平滑阶梯函数sqrt-平方根step-阶梯函数tan-正切函数tanh-双曲正切函数texelFetch-获取纹素的颜色值texelFetchOffset-获取偏移量纹素的颜色值texture-对纹理进行采样textureGrad-对纹理进行采样,包括Mipmap层级计算textureGradOffset-对纹理进行采样,包括Mipmap层级计算和偏移量textureLod-根据给定的Mipmap层级对纹理进行采样textureLodOffset-根据给定的Mipmap层级和偏移量对纹理进行采样textureOffset-对纹理进行采样,包括偏移量textureProj-对投影纹理进行采样textureProjGrad-对投影纹理进行采样,包括Mipmap层级计算textureProjGradOffset-对投影纹理进行采样,包括Mipmap层级计算和偏移量textureProjLod-根据给定的Mipmap层级对投影纹理进行采样textureProjLodOffset-根据给定的Mipmap层级和偏移量对投影纹理进行采样textureProjOffset-对投影纹理进行采样,包括偏移量textureSize-获取纹理的尺寸transpose-矩阵转置trunc-向零舍入取整uintBitsToFloat-将32位无符号整数解释为浮点数unpackHalf2x16-解压缩单精度浮点数unpackSnorm2x16-解压缩单精度浮点数unpackUnorm2x16-解压缩单精度浮点数

GLSL Equal Function Documentation

Function Name

equal

Parameters

The equal function takes two arguments of any basic type, that is, any scalar or vector type of bool, int, uint or float.

bool equal(T x, T y)

Return Value

The return value of the equal function is a bool that is true if x and y are equal or false otherwise. The function tests for exact equality between the values of x and y.

Description

The equal function performs an exact numeric comparison between x and y. For float values, the function simply tests whether the values are bit-for-bit identical. For integer values, the function tests whether they are exactly equal.

For vector types, the comparison is performed component-wise. That is, each component of x is compared with the corresponding component of y, and if all components are equal, the function returns true. Otherwise, it returns false.

Example

The following example demonstrates the use of the equal function to compare two float values and two vec3 vectors:

float a = 2.5;
float b = 2.5;
vec3 v1 = vec3(1.0, 2.0, 3.0);
vec3 v2 = vec3(1.0, 2.0, 3.0);
bool c = equal(a, b); // returns true
bool d = equal(v1, v2); // returns true

Notes

  • The equal function is a built-in function in GLSL, so it does not need to be declared or defined.
  • NaN values are not considered equal to any other value, including themselves. Therefore, NaN values will always result in false when used with the equal function.