Interplay of the emission from thermal and direct sources in relativistic heavy ion collisions