mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 17:18:12 -05:00
42 lines
1.1 KiB
Text
42 lines
1.1 KiB
Text
struct v2f_vertex_lit {
|
|
vec2 uv;
|
|
vec4 diff;
|
|
vec4 spec;
|
|
};
|
|
struct v2f_img {
|
|
vec4 pos;
|
|
vec2 uv;
|
|
};
|
|
struct appdata_img {
|
|
vec4 vertex;
|
|
vec2 texcoord;
|
|
};
|
|
uniform vec4 _AdaptParams;
|
|
uniform sampler2D _CurTex;
|
|
uniform sampler2D _MainTex;
|
|
vec4 frag( in v2f_img i );
|
|
vec4 frag( in v2f_img i ) {
|
|
vec2 valAdapted;
|
|
vec2 valCur;
|
|
vec2 delta;
|
|
vec4 valNew;
|
|
valAdapted = texture2D( _MainTex, i.uv).xy ;
|
|
valCur = texture2D( _CurTex, i.uv).xy ;
|
|
delta = ((valCur - valAdapted) * _AdaptParams.x );
|
|
delta.x = (sign( delta.x ) * max( 0.00392157, abs( delta.x )));
|
|
delta.y = (sign( delta.y ) * max( 0.00392157, abs( delta.y )));
|
|
valNew.xy = (valAdapted + delta);
|
|
valNew.x = max( valNew.x , _AdaptParams.z );
|
|
valNew.y = min( valNew.y , _AdaptParams.y );
|
|
valNew.z = ((valNew.x - valNew.y ) + 0.0100000);
|
|
valNew.w = (valNew.y / valNew.z );
|
|
return valNew;
|
|
}
|
|
void main() {
|
|
vec4 xl_retval;
|
|
v2f_img xlt_i;
|
|
xlt_i.pos = vec4(0.0);
|
|
xlt_i.uv = vec2( gl_TexCoord[0]);
|
|
xl_retval = frag( xlt_i);
|
|
gl_FragData[0] = vec4( xl_retval);
|
|
}
|