bgfx/3rdparty/glsl-optimizer/tests/fragment/zun-currently_adapted-in.txt
2012-10-07 20:41:18 -07:00

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);
}