beta
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            Guide to VR in cables            WebGL1 and WebGL2

WebGL1 and WebGL2

A little overview

The underlying interface that allows 3D graphics on the web to be rendered natively is called WebGL. WebGL was first released in 2011 with WebGL1. WebGL2, the next iteration of WebGL, was made availible in 2017. WebGL2 features new features. If you are interested in the details of the specification & differences, have a look here.

Why would this matter to you, the user?

WebGL2 has been adopted by most of modern browsers (Chrome, Firefox, Opera, Edge).

There are two platforms that still use WebGL1: macOS (Safari) and iOS (every browser). If you plan on making your patch functional for these platforms, there are a few things to keep in mind:

MipMapping & Power of Two Textures

WebGL1 only supports mipmapping for power of two textures. What does that mean?

First off, what is mipmapping?

Put simply, mipmapping saves your texture in different resolutions internally so the graphics card can choose which resolution is optimal to display your texture without artifacts. See the following picture for a visual explanation:

mipmapping

As you can see, there are moiré artefacts in the background without mipmapping. These disappear when mipmapping is enabled.
When using the Texture op, mipmapping is enabled automatically.

Mipmapping in WebGL1

WebGL1 allows mipmapping only for textures that have dimensions that are a power of two.

What does that mean?

Here are the powers of two: 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, ...

Mipmap filtering will only work if the dimensions, the width and the height, of the texture are one of these numbers. Width and height do not need to be the same size, but both values need to be a power of two.

Texture dimension examples that work: 1024 by 1024, 256 by 2048, 512 by 128 and so on.

Texture dimension examples that do not work: 1038 by 2030, 540 by 1300, ...

Scaling a texture to the next power of two

Fortunately, cables allows you to resize a texture to the closest power of two within the application:

If you open the file browser and click on the texture you desire to resize, the following options will appear:

resize_start

If you look at the bottom of the screenshot, you can see marked in yellow the current size of your image. At the bottom right of your dimensions, there are a few buttons that allow you to process your image through cables. The relevant button to resize to the next power of two is marked in bright green.

After clicking it, a dialogue appears and asks you if you want to resize the texture. If you do that, the following dialogue will appear:

resize_start

Your texture is now resized to the next power of two and usable for mipmapping in WebGL1.

Mipmapping in WebGL2

Mipmapping in WebGL2 works for every resolution.


help cables get better and edit this file on github