I haven't used the fixed-function texture environment shading in many years, but I think you should be able to do this with ARB_texture_env_combine (or OpenGL 1.3+). ATI_fragment_shader and NV_register_combiners are two other, vendor-specific, options.