Toastmastern said:
Right now it seems that where the sun disk is supose to be I see the skybox texture, but all other places it is just pitch black
Looking at your code:
I'm not familiar with the “distance” function--I'm guessing that it returns the angle between two vectors?
Presuming as much, I take it that you're measuring the angle between the sun-direction and the view-direction, and then applying smooth-step to have that fade from 0 to 1. Or something to similar effect.
But since you're using “sunAmount” in calculating “sun”, why apply it again when you calculate the final colour?
Otherwise, the issue that you're seeing suggests that the value of “sunAmount” is inverted: you're getting zero where the sun should be and one where it shouldn't be. I'm guessing that this is related to the use of the “distance" function, but since I am, as mentioned, not familiar with it, I'm not sure of what the problem might be.
The fact that you're seeing blackness outside of the expected sun-area further suggests that the line that includes the smooth-step is producing zero, or close to it. Why this might be I'm not sure, I'm afraid--have you checked the value of “radiance”, perhaps?
All this, however, is largely conjecture I'm afraid.
It might be worth outputting some of the values that you're taking as inputs, and the values that you're calculating along the way, to see whether they're as you expect them to be.