In this paper, we present a new method to calculate interface warping functions for the analysis of beams with geometric and material discontinuities in the longitudinal direction. The classical Saint Venant torsion theory is extended to a three-dimensional domain by considering the longitudinal direction. The interface warping is calculated by considering both adjacent cross-sections of a given interface. We also propose a finite element procedure to simultaneously calculate the interface warping function and the corresponding twisting center. The calculated interface warping functions are employed in the continuum-mechanics based beam formulation to analyze arbitrary shape cross-section beams with longitudinal discontinuities. Compared to the previous work by Yoon and Lee (2014a), both geometric and material discontinuities are considered with fewer degrees of freedom and higher accuracy in beam finite element analysis. Through various numerical examples, the effectiveness of the proposed interface warping function is demonstrated.