Arrays in ISF

Sun Apr 25, 2021 5:28 am

I'm writing something in ISF to output a color based on two lists (color and shade) and I ran into some trouble getting an array to work. Can someone please tell me if it is possible to create an array and read back from it in ISF?

Found this on shader toy for example which has a palette and sub palette array, but was unable to get anything happening in ISF without syntax errors. Testing the shadertoy example on the BookofShaders editor gives me a warning about GLSL3.0 so I'm wondering if it's even possible in ISF.

In the end, I created an alternate solution to determine an output color based on two menus (color and shade), but it's a bit messy. If there is a better way to do it, would be good to know.

The solution was to create constants for all the colors, create two lists (colorList and shadeList) and then read out the color with some if logic:
Code: Select all
int tableIndex = int((colorList * 10) + shadeList);

Code: Select all
if (tableIndex==0){selectedColor = red10;}

Would prefer to create an array like in the shader toy example:
Code: Select all
 //16-Color C64 color palette.
   palette = vec3[](
        RGB(  0,  0,  0),
        RGB(152, 75, 67),


Any tips appreciated as to how to create and read back from an array using ISF syntax would be appreciated. Thanks in advance.
Posts: 48
Joined: Mon Nov 30, 2020 2:15 pm

Re: Arrays in ISF

Wed Apr 28, 2021 6:01 am

Solved: Found an example that's working

Code: Select all
void mainImage( out vec4 fragColor, in vec2 fragCoord )
    //Define points used for partitioning the plane
    vec2 points[10];
    points[0] = vec2(0.028, 0.259);
   points[1] = vec2(0.459, 0.233);
   points[2] = vec2(0.386, 0.556);
   points[3] = vec2(0.847, 0.868);
   points[4] = vec2(0.437, 0.718);
   points[5] = vec2(0.095, 0.558);
   points[6] = vec2(0.513, 0.680);
   points[7] = vec2(0.013, 0.865);
   points[8] = vec2(0.163, 0.653);
   points[9] = vec2(0.891, 0.721);
Posts: 48
Joined: Mon Nov 30, 2020 2:15 pm

Return to General Discussion

© 2022 Color & Music, LLC • This web site is mobile-friendly