OpenGL color interpolation using cosine function?

I want to display an ATV, I want one side of the square to be white and the other black. Instead of a simple linear color interpolation for the pixels between them, I need to simulate the cosine function.

What is a good way to approach this?

+3
source share
1 answer

You can do this in the fragment shader. I.e:.

gl_FragColor = vec4( vec3( cos( in_TexCoord.x ) ), 1.0 );

You can adjust the exact values ​​of the amplitude and phase as you like for each color channel.

+5
source

All Articles