Optical properties of BN in cubic and layered hexagonal phases