uniform vec2 u_sunCenter;
uniform vec2 u_sunSize;
uniform vec2 u_uvSize;
uniform int u_sun;
//Sample the texture to see if the sun is occluded or not
void main()
{
    vec2 s1, s2, s3, s4, s5, s6;
    
    
    if(u_sun == 1){
    
        
        
        s1 = u_sunCenter - (vec2(0.5 - 0.389105058,0.5 - 0.6875 )  * u_sunSize ) ;
        s2 = u_sunCenter -(vec2(0.5 - 0.544747082,0.5 - 0.6875 )  * u_sunSize );
        s3 = u_sunCenter -(vec2(0.5 - 0.544747082,0.5 - 0.296875 )  * u_sunSize );
        s4 = u_sunCenter -(vec2(0.5 - 0.389105058,0.5 - 0.296875 )  * u_sunSize );
        s5 = u_sunCenter -(vec2(0.5 - 0.26459144,0.5 - 0.4921875 )  * u_sunSize );
        s6 = u_sunCenter -(vec2(0.5 - 0.653696498,0.5 - 0.4921875 )  * u_sunSize );
       
    
    }else{
        
     
        s1 = u_sunCenter -(vec2(0.5 - 0.346303502,0.5 - 0.5625 )  * u_sunSize ) ;
        s2 = u_sunCenter -(vec2(0.5 - 0.3307393,0.5 - 0.453125 )  * u_sunSize ) ;
        s3 = u_sunCenter -(vec2(0.5 - 0.416342412,0.5 - 0.4453125 )  * u_sunSize ) ;
        s4 = u_sunCenter -(vec2(0.5 - 0.392996109,0.5 - 0.359375 )  * u_sunSize ) ;
        s5 = u_sunCenter -(vec2(0.5 - 0.53307393,0.5 - 0.34375 )  * u_sunSize ) ;
        s6 = u_sunCenter -(vec2(0.5 - 0.587548638,0.5 - 0.296875 )  * u_sunSize ) ;
        
    }
    
    float top = texture2D(CC_Texture1, s1 ).a;
    float bottomLeft= texture2D(CC_Texture1, s2  ).a;
    float bottomRight = texture2D(CC_Texture1, s3).a;
    
    float bottom = texture2D(CC_Texture1, s4).a;
    float topRight= texture2D(CC_Texture1, s5).a;
    float topLeft = texture2D(CC_Texture1, s6).a;

    float val = (top + bottomLeft + bottomRight + bottom + topRight + topLeft) / 6.0 / 0.3;
    
    gl_FragColor = vec4(val,val,val,val);

}
