Max Frai
Max Frai

Reputation: 64266

Change color component

I'm writing graphic shader program. I wrote everything I need except the color changing. In cycle there is passing some counter variable to the shader and I have to change it's color from white to orange shade. What I have change to achive this?

Upvotes: 1

Views: 262

Answers (1)

Kos
Kos

Reputation: 72241

I'm not sure I've got you right, but my guess is you need something like this:

uniform float counter; // assumed range 0 .. 1

const vec3 WHITE = vec3(1,1,1);
const vec3 ORANGE = vec3(1,0.6,0.2);

void main() {

    vec3 mixedColor = mix(WHITE,ORANGE,counter);
    // will be white for counter < 0,
    //         orange for counter > 1,
    //         shaded in between
}

Upvotes: 2

Related Questions