smoothstep函数_OpenGL-Built–In Math Functions(内置数学函数)

周一到周五,每天一篇,北京时间早上7点准时更新~

跟着我们一起一天天进步,一步一步变成业界大佬。当别人在炫技术的时候,我们来手把手教你那些技术怎么实现。

GLSL supports many built-in functions to perform mathematical operations and to manipulate data in variables. The common math functions include abs(), sign(), ceil(), floor(), trunc(), round(), roundEven(), fract(), mod(), modf(), min(), and max(). For the most part, these functions operate on vectors as well as scalars, but otherwise behave like their counter parts in the C standard libraries. The roundEven() function doesn’t have a direct equivalent in C—this function rounds its argument to the nearest integer, but breaks ties when there is a fractional part of 0.5 by rounding to the nearest even number. That is, 7.5 and 8.5 will both round to 8, 42.5 will round to 42 and 43.5 will round to 44.

GLSL支持很多内置的执行数学操作的函数。这些就包括常用的abs(), sign(),ceil(), floor(), trunc(), round(), roundEven(), fract(), mod(),modf(), min(), 以及 max()。大部分时候,这些函数都可以用来操作 向量以及标量,但是他们计算的时候会表现得跟C语言的库很相似。

Two implicit declarations of the clamp() function are

两个隐式申明的clamp函数如下所示:

vec4 clamp(vec4 x, float minVal, float maxVal);
vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal);

This function clamps the incoming vector x to the range specified by minVal and maxVal (which may be scal

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值