Controlling OSL shader colors

Maxon Cinema 4D (Export script developed by abstrax, Integrated Plugin developed by aoktar)

Moderators: ChrisHekman, aoktar

Post Reply
User avatar
SKY2SART
Licensed Customer
Posts: 2
Joined: Sat Oct 25, 2025 6:51 am

Hello ! I'm trying to find a way to control the colors of the "PaintColors" OSL shader, but so far everything i tried didnt work out.

What i'm trying to do is to remove some of the colors, only to keep blue/pink hues; is that possible or do i have to find a workaround in post ?

So far I tried to remove the colors I dont want by driving the OSL shader into an octane gradient, but it doesnt give any good result as it usually make the gradient less "smooth"

Thanks in advance !

Code: Select all

//reference: http://glslsandbox.com/e#43216.0

shader paintColors(
		float tm=0[[float min=0, float max=100]],
	  float offX=0.175[[float min=0, float max=0.5]],
	  float offY=0.275[[float min=0, float max=0.5]],
	  float offZ=0.25[[float min=0, float max=0.5]],
    output color c = 0)
{
    int   complexity      = 47;    // More points of color.
    float fluid_speed     = 108.0;  // Drives speed, higher number will make it slower.
    float clrInt = 0.8;

    vector p=vector(u,v,0);
    p=P;
    for(int i=1;i<complexity;i++)
    {
        vector newp = p + tm*0.001;
        float s=i;
        newp[0]+=0.6/s*sin(s*p[2]+tm/fluid_speed+0.3*s) + offX; // + mouse[1]/mouse_factor+mouse_offset;
        newp[1]+=0.6/s*sin(s*p[0]+tm/fluid_speed+0.3*(i+10)) - offY; // - mouse[0]/mouse_factor+mouse_offset;
        newp[2]+=0.6/s*sin(s*p[1]+tm/fluid_speed+0.3*s) + offZ;
        p=newp;
    }
    c=vector(clrInt*sin(3.0*p[0])+clrInt, clrInt*sin(3.0*p[1])+clrInt, clrInt*sin(p[0]+p[2])+clrInt);
}
Attachments
wrong colors.jpg
desired colors.png
User avatar
bepeg4d
Octane Guru
Posts: 10444
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy
Contact:

Hi,

A solution can be to multiply or divide each single RGB component in the final c vector color.
In the following example, I have multiplied the Red and Blue components by 4, and divided the Green component by 100:

Code: Select all

//reference: http://glslsandbox.com/e#43216.0

shader paintColors(
		float tm=0[[float min=0, float max=100]],
	  float offX=0.175[[float min=0, float max=0.5]],
	  float offY=0.275[[float min=0, float max=0.5]],
	  float offZ=0.25[[float min=0, float max=0.5]],
    output color c = 0)
{
    int   complexity      = 47;    // More points of color.
    float fluid_speed     = 108.0;  // Drives speed, higher number will make it slower.
    float clrInt = 0.8;

    vector p=vector(u,v,0);
    p=P;
    for(int i=1;i<complexity;i++)
    {
        vector newp = p + tm*0.001;
        float s=i;
        newp[0]+=0.6/s*sin(s*p[2]+tm/fluid_speed+0.3*s) + offX; // + mouse[1]/mouse_factor+mouse_offset;
        newp[1]+=0.6/s*sin(s*p[0]+tm/fluid_speed+0.3*(i+10)) - offY; // - mouse[0]/mouse_factor+mouse_offset;
        newp[2]+=0.6/s*sin(s*p[1]+tm/fluid_speed+0.3*s) + offZ;
        p=newp;
    }
    c=vector((clrInt*sin(3.0*p[0])+clrInt)*4, (clrInt*sin(3.0*p[1])+clrInt)/10, (clrInt*sin(p[0]+p[2])+clrInt)*4);
}
ciao,
Beppe
User avatar
SKY2SART
Licensed Customer
Posts: 2
Joined: Sat Oct 25, 2025 6:51 am

Hi ! Thanks for your reply.

This is going in the right direction definitely, but i'm realizing that since white is the combination of the 3 primary colors, it won't work that way...

Maybe I should just look for another OSL shader to realize that effect, or just do it in post by removing green and yellow hues directly there

Thanks anyway !
Post Reply

Return to “Maxon Cinema 4D”