Arrays in ISF
Posted: 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 https://www.shadertoy.com/view/MtjGRd 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:
Would prefer to create an array like in the shader toy example:
Any tips appreciated as to how to create and read back from an array using ISF syntax would be appreciated. Thanks in advance.
Found this on shader toy for example https://www.shadertoy.com/view/MtjGRd 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;}
Code: Select all
//16-Color C64 color palette.
palette = vec3[](
RGB( 0, 0, 0),
RGB(255,255,255),
RGB(152, 75, 67),
RGB(121,193,200),
);