GLSL built-in function

cosh()

Returns the hyperbolic cosine, a catenary-shaped curve.

Demo version: GLSL ES 3.00 / WebGL 2Demo stage: Fragment

Syntax

genType cosh(genType x)

genType means float / vec2 / vec3 / vec4; matching placeholders use the same type.

Parameters

x
Input value or left-hand vector

Return value

A floating-point value at least 1 for every component: (exp(x) + exp(-x)) / 2.

Live example

Edit the code and the preview updates as you type.

What cosh does

Returns the hyperbolic cosine, a catenary-shaped curve.

Read the preview

Subtracting 1.0 in cosh(x)-1.0 puts the lowest point at zero. Remove that subtraction and the minimum moves to y = 1, near the top edge.

Core call

cosh(x)-1.0;

It is not periodic and is not cos expressed in another angle unit.

Experiment

Change cosh(x)-1.0 to cosh(x*2.0)-1.0. The bowl becomes steeper and its outer sections leave the displayed height range.

Specification

GLSL ES 3.00 built-in functions, chapter 8

Related functions