fixed shadow bug and added flat gen