I just emphasize that this is not a settled question. Shame can be thought of as a necessary feeling. We then learned to have thoughts about that feeling , our own personal reaction to that feeling. I have learned that it is the feeling that we all get when we can't get what we want. Reaction to that moment , when we feel hurt, is learned and can be unlearned.