Skip to content

Instantly share code, notes, and snippets.

@shirish47
Last active October 24, 2015 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirish47/b2136bde5d58bf3b3cf8 to your computer and use it in GitHub Desktop.
Save shirish47/b2136bde5d58bf3b3cf8 to your computer and use it in GitHub Desktop.
#version 150
in vec3 v3LightDirection;
in vec3 v3Direction;
in vec3 c0;
in vec3 c1;
out vec4 color;
float getMiePhase(float fCos, float fCos2, float g, float g2)
{
return 1.5 * ((1.0 - g2) / (2.0 + g2)) * (1.0 + fCos2) / pow(1.0 + g2 - 2.0 * g * fCos, 1.5);
}
// Calculates the Rayleigh phase function
float getRayleighPhase(float fCos2)
{
return 0.75 + 0.75 * fCos2;
}
void main()
{
float g= -0.85;
float g2=g*g;
float fCos = dot(v3LightDirection, v3Direction) / length(v3Direction);
float fCos2 = fCos * fCos;
vec3 ccolor = getRayleighPhase(fCos2) * c0 +
getMiePhase(fCos, fCos2, g, g2) * c1;
color = vec4(ccolor, 1.0);
color.a = color.b;
//color= vec4(0,length(c0),length(c1),1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment