Skip to content

Commit

Permalink
feat(webgl): set shader float precision conditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
JMaio committed Dec 28, 2020
1 parent 330ccdf commit 1b15116
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/shaders/newSmoothJuliaShader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ const newSmoothJuliaShader = ({
#define MAXI ${maxI}
#define B ${B.toFixed(1)}
// set high float precision (lower than this may break colours on mobile)
precision highp float;
// https://webglfundamentals.org/webgl/lessons/webgl-precision-issues.html
// prefer high float precision (lower than this may break colours on mobile)
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
// need to know the resolution of the canvas
uniform vec2 resolution;
Expand Down
9 changes: 7 additions & 2 deletions src/shaders/newSmoothMandelbrotShader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ const newSmoothMandelbrotShader = (
#define cross_stroke ${crosshairShape.stroke.toFixed(1)}
#define cross_radius ${crosshairShape.radius.toFixed(1)}
// set high float precision (lower than this may break colours on mobile)
precision highp float;
// https://webglfundamentals.org/webgl/lessons/webgl-precision-issues.html
// prefer high float precision (lower than this may break colours on mobile)
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
// need to know the resolution of the canvas
uniform vec2 resolution;
Expand Down

0 comments on commit 1b15116

Please sign in to comment.