OSL - simple UV things and frac fract alternative
Here is a shoddy OSL shader that follow on from some of my GLSL experiments of yesteryear. I couldn't seem to find a frac or fract function, but fmod-ing (it's like modulo) against 1 does the same thing.
I don't put any input parameters in this shader.
EDIT - just saw someone else's code that use x-floor(x) for fract, which could be faster..who knows!
Variables Lame an Cat are assigned to u and v, I then multiply them by different values and fmod them so they repeat 3 and 4 times. It seems like u and v will be taken automatically, which is nice.
After that I do a bit of if statement colour assignment.
shader use_uv(output color resultRGB = 0)
{
float lame=u;
float cat=v;
cat=fmod(v*3,1);
lame=fmod(u*4,1);
resultRGB = color(lame, v, 1);
if(lame>0.5){
resultRGB+=color(0.3,0.4,0);
}
if(v<0.1){
resultRGB+=color(0,0,1);
}
if(lame<0.5){
resultRGB+=color(0,lame,0);
}
}
Comments
Post a Comment