protot/3rdparty/bgfx/tools/texturev/common.sh

29 lines
618 B
Bash
Raw Normal View History

2018-02-03 17:39:28 +01:00
/*
* Copyright 2011-2018 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include <bgfx_shader.sh>
uniform vec4 u_params;
#define u_textureLod u_params.x
#define u_textureLayer u_params.y
#define u_inLinear u_params.z
#define u_ev u_params.w
vec3 toLinear(vec3 _rgb)
{
return pow(abs(_rgb), vec3_splat(2.2) );
}
vec3 toGamma(vec3 _rgb)
{
return pow(abs(_rgb), vec3_splat(1.0/2.2) );
}
vec4 toEv(vec4 _color)
{
vec3 rgb = mix(toLinear(_color.xyz), _color.xyz, u_inLinear);
return vec4(toGamma(rgb * pow(2.0, u_ev) ), _color.w);
}