The erotic sense traces to Song Yu's
《高唐赋》 (c. 3rd century BCE): King Huai of Chu dreams of a goddess on Mount Wu (
巫山) who tells him she is 'morning clouds, evening rain' (
旦为朝云,暮为行雨). Ever since,
巫山云雨 has been the classical Chinese euphemism for lovemaking - softer and more poetic than direct vocabulary.