2014-02-14 08:46:34 +04:00
|
|
|
$input v_dir
|
|
|
|
|
|
|
|
/*
|
2016-02-29 03:15:12 +03:00
|
|
|
* Copyright 2014-2016 Dario Manesku. All rights reserved.
|
2016-01-01 11:11:04 +03:00
|
|
|
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
|
2014-02-14 08:46:34 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../common/common.sh"
|
2016-02-29 03:15:12 +03:00
|
|
|
#include "uniforms.sh"
|
2014-02-14 08:46:34 +04:00
|
|
|
|
2015-06-07 03:12:29 +03:00
|
|
|
SAMPLERCUBE(s_texCube, 0);
|
2016-02-29 03:15:12 +03:00
|
|
|
SAMPLERCUBE(s_texCubeIrr, 1);
|
2014-02-14 08:46:34 +04:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
vec3 dir = normalize(v_dir);
|
|
|
|
|
2016-02-29 03:15:12 +03:00
|
|
|
vec4 color;
|
|
|
|
if (u_bgType == 7.0)
|
|
|
|
{
|
|
|
|
color = toLinear(textureCube(s_texCubeIrr, dir));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float lod = u_bgType;
|
|
|
|
dir = fixCubeLookup(dir, lod, 256.0);
|
|
|
|
color = toLinear(textureCubeLod(s_texCube, dir, lod));
|
|
|
|
}
|
2014-02-14 08:46:34 +04:00
|
|
|
color *= exp2(u_exposure);
|
|
|
|
|
|
|
|
gl_FragColor = toFilmic(color);
|
|
|
|
}
|