Created
December 28, 2013 19:15
-
-
Save kig/8163093 to your computer and use it in GitHub Desktop.
sky shader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vec3 lightPos_ = vec3( | |
-cos(iGlobalTime*0.1)*-8.5, | |
3.5+sin(iGlobalTime*0.05)*3.0, | |
-(sin(iGlobalTime*0.1)*4.0-5.4) | |
); | |
vec3 bgLight = normalize(lightPos_); | |
vec3 lightPos = bgLight * 9999.0; | |
vec3 sun = vec3(5.0, 3.5, 2.0)*4.0; | |
vec3 shadeBg(vec3 dir, vec3 nml) | |
{ | |
vec3 bgCol = vec3(0.2, 0.15, 0.1); | |
float bgDiff = dot(nml, vec3(0.0, 1.0, 0.0)); | |
float sunPow = dot(nml, bgLight); | |
bgCol += bgDiff*vec3(0.25, 0.5, 0.5); | |
bgCol += sun*(0.1*pow( max(sunPow, 0.0), 2.0) + pow( max(sunPow, 0.0), abs(bgLight.y)*256.0)); | |
bgCol += bgCol*(2.0*pow( max(-sunPow, 0.0), 2.0)+ pow( max(sunPow, 0.0), abs(bgLight.y)*128.0)); | |
return max(vec3(0.0), bgCol); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment