Layer contribution to optical signals of van der Waals heterostructures