cables is under heavy development.
There might be one or another bug, please let us know about it!
cables Documentation      How To Use            Working with files            Keyboard Shortcuts            User Interface Walkthrough      Beginner Tutorial            Beginner 1: Drawing A Circle            Beginner 2: Transformations            Beginner 3: Color            More Transformations      intermediate            Image Compositions            Post-Processing 3D Scenes      communication            cables API            Communication with an Arduino via Serial            Communicating with Arduino over MQTT      Exporting And Embedding            How to serve files externally and fix CORS headers            Embedding Patches            External triggers / functions            Embedding Patches            Previewing / uploading exported cables patches      coding ops            Creating Attachments            General op/Port Callbacks            Ports                  Dynamic Ports                  Array Ports                  Boolean ports                  Integer Number Ports                  Object Ports                  String ports                  Trigger Ports                  Floating Point Number Ports            GUI/UI attributes            Hello Op - Part 1            Libraries            Developing Ops            Guidelines            Object Ports            Writing Shaders            Web Audio Op Development      HTML and CSS in cables      Lighting            Lights            Shadows      FAQ            Embedding                  How to remove grey rectangles on touch (mobile)?                  Why doesn't the DownloadTexture op work on iOS?                  How to disable page scrolling on mobile?                  Transparent Canvas            Features and Support                  Will there be support for (animated) GIFs?            General questions            Licences and payment                  What licence do i need to use cables?                  Will I have to pay for it in the future?                  How is my work licenced when using cables?            Does cables support midi and OSC?            Shadertoy            Technical questions            UI / Editor            WebGL1 and WebGL2

Writing Shaders

Parameter Qualifiers

for better compatibility between webgl 1.x and 2.x, or GLSL v1 and v3 we use predefined qualifiers.

In GLSL >=3.0 you do not use qualifiers like attribute or varying, but in and out.

In cables we use IN, OUT and UNI, then your shader can be compiled for both GLSL versions used in webgl.

Vertex Shader Qualifiers

GLSL 1.0 GLSL 3.0 cables
varying out OUT
attribute in IN
uniform uniform UNI

Fragment Shader Qualifiers

GLSL 1.0 GLSL 3.0 cables
varying in IN
uniform uniform UNI

default cables inputs

vertex shader

vec3 vPosition;         - vertex position in object space
vec2 attrTexCoord;        - vertex texture coordinates
vec3 attrVertNormal;   - vertex normal

mat4 projMatrix;       - projection matrix
mat4 mvMatrix;         - modelview matrix
mat4 modelMatrix;      - model matrix
mat4 viewMatrix        - view matrix
mat4 inverseViewMatrix - inverted view matrix

fragment shader

IN vec2 texCoord;      - texture coordinate
IN vec3 norm;          - normal


Ops.Gl.Shader.ShaderMaterial can be used to live-edit shaders and see the results immediately.
You can use shaderMaterial with any kind of mesh and the mesh will be drawn using your custom shader.


You can edit Fragment and Vertex Shader Code.

Uniforms are automatically added as Ports of the ShaderMaterial Op. (Currently float and sampler2D)



You can always use Ops.Gl.Shader.ShowShader to view the source code of the current shader.

help cables get better and edit this file on github