That's usually a job for the fragment shader.