diff options
Diffstat (limited to 'examples/models/resources/shaders/glsl330/irradiance.fs')
| -rw-r--r-- | examples/models/resources/shaders/glsl330/irradiance.fs | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/examples/models/resources/shaders/glsl330/irradiance.fs b/examples/models/resources/shaders/glsl330/irradiance.fs deleted file mode 100644 index 4b74916d..00000000 --- a/examples/models/resources/shaders/glsl330/irradiance.fs +++ /dev/null @@ -1,50 +0,0 @@ -#version 330 - -// Input vertex attributes (from vertex shader) -in vec3 fragPosition; - -// Input uniform values -uniform samplerCube environmentMap; - -// Constant values -const float PI = 3.14159265359; - -// Output fragment color -out vec4 finalColor; - -void main() -{ - // The sample direction equals the hemisphere's orientation - vec3 normal = normalize(fragPosition); - - vec3 irradiance = vec3(0.0); - - vec3 up = vec3(0.0, 1.0, 0.0); - vec3 right = cross(up, normal); - up = cross(normal, right); - - float sampleDelta = 0.025; - float nrSamples = 0.0; - - for (float phi = 0.0; phi < 2.0*PI; phi += sampleDelta) - { - for (float theta = 0.0; theta < 0.5*PI; theta += sampleDelta) - { - // Spherical to cartesian (in tangent space) - vec3 tangentSample = vec3(sin(theta)*cos(phi), sin(theta)*sin(phi), cos(theta)); - - // tangent space to world - vec3 sampleVec = tangentSample.x*right + tangentSample.y*up + tangentSample.z*normal; - - // Fetch color from environment cubemap - irradiance += texture(environmentMap, sampleVec).rgb*cos(theta)*sin(theta); - nrSamples++; - } - } - - // Calculate irradiance average value from samples - irradiance = PI*irradiance*(1.0/float(nrSamples)); - - // Calculate final fragment color - finalColor = vec4(irradiance, 1.0); -} |
