美文网首页
GLSL常用函数

GLSL常用函数

作者: hjm1fb | 来源:发表于2020-11-26 19:30 被阅读0次
  • genType abs (genType x) 绝对值 Returns x if x >= 0, otherwise it returns –x.
  • genType sign (genType x) 符号 Returns 1.0 if x > 0, 0.0 if x = 0, or –1.0 if x < 0
  • genType floor (genType x) 向下取整 Returns a value equal to the nearest integer that is less than or equal to x
  • genType ceil (genType x) 向上取整 Returns a value equal to the nearest integer that is greater than or equal to x
  • genType fract (genType x) 正数取小数,负数取(小数部分+1)Returns x – floor (x)
  • genType mod (genType x, genType y) 取模 Modulus. Returns x – y ∗ floor (x/y)
如果要对参数截断到[0.0,1.0], 正确的表达式是factor = mod(factor, 1.0 + EQUAL_THRESHOLD);
测试发现,shader精度为highp时,EQUAL_THRESHOLD为1e-8无效,至少要1e-7 
  • genType min (genType x, genType y) 最小值 Returns y if y < x, otherwise it returns x
  • genType max (genType x, genType y) 最大值 Returns y if x < y, otherwise it returns x.
  • genType clamp (genType x,genType minVal, genType maxVal) 截断 Returns min (max (x, minVal), maxVal) Results are undefined if minVal > maxVal.
  • genType mix (genType x,genType y,genType a) 混合(1-alpha) Returns the linear blend of x and y: x(1-a)+y*a
  • genType step (genType edge, genType x) 是阶梯或平地则返回1 Returns 0.0 if x < edge, otherwise it returns 1.0
  • genType smoothstep (genType edge0,genType edge1,genType x)
    顺滑返回0~1的值 Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1. This is useful in cases where you would want a threshold function with a smooth transition. This is equivalent to: genType t; t = clamp ((x – edge0) / (edge1 – edge0), 0, 1); return t * t * (3 – 2 * t); Results are undefined if edge0 >= edge1.

相关文章

  • GLSL常用函数

    genType abs (genType x) 绝对值 Returns x if x >= 0, otherwis...

  • GLSL常用内建函数

    genType可以理解为泛型 genType pow(genType x)genType有点像面向对象中泛型,即如...

  • GLSL常用内建函数

    1. dot 点乘 返回两个单位向量之间夹角的cos值 2. cross 叉乘 3. texture2D 用于纹理...

  • GLSL 语言

    GLSL 语言 GLSL中提供了许多内建的函数,来方便我们的使用。可以在官方手册中查找相关的函数GLSL官方手册[...

  • 安卓OpenGLES环境搭建(十)

    前言 前面学习了opengl es的基础知识,包括GLSL语言,常用函数等等,由于opengl es是基于夸平台的...

  • IOS渲染图片OpenGLES(五)

    前言 前面学习了opengl es渲染管线,可编程语言GLSL,常用的opengl es函数,有了这些基础,现在就...

  • 常用函数介绍OpenGLES(四)

    前言 前面介绍了GLSL的基础语法,接下来介绍下opengl es的常用函数,了解这些函数的基本原理和前面的gls...

  • 五、GLSL 常用内建函数

    OpenGL + OpenGL ES +Metal 系列文章汇总[https://www.jianshu.com/...

  • shader自学资源

    GLSL:GLSL中提供了许多内建的函数,来方便我们的使用。可以在官方手册中查找相关的函数http://www.o...

  • OpenGL ES学习之路(2.1) 顶点着色程序与片元着色程

    关于gltLoadShaderPairWithAttributes函数的底层实现分析 由于GLSL的编译是需要我们...

网友评论

      本文标题:GLSL常用函数

      本文链接:https://www.haomeiwen.com/subject/yhyziktx.html