2013-09-23 05:15:01 +00:00
|
|
|
/* Shader for approximating the way RMXP does bitmap
|
|
|
|
* blending via DirectDraw */
|
2013-09-01 14:27:21 +00:00
|
|
|
|
|
|
|
uniform sampler2D source;
|
|
|
|
uniform sampler2D destination;
|
|
|
|
|
|
|
|
uniform vec4 subRect;
|
|
|
|
|
|
|
|
uniform float opacity;
|
|
|
|
|
2013-09-23 05:15:01 +00:00
|
|
|
varying vec2 v_texCoord;
|
|
|
|
|
2013-09-01 14:27:21 +00:00
|
|
|
void main()
|
|
|
|
{
|
2013-09-23 05:15:01 +00:00
|
|
|
vec2 coor = v_texCoord;
|
2013-09-01 14:27:21 +00:00
|
|
|
vec2 dstCoor = (coor - subRect.xy) * subRect.zw;
|
|
|
|
|
|
|
|
vec4 srcFrag = texture2D(source, coor);
|
|
|
|
vec4 dstFrag = texture2D(destination, dstCoor);
|
|
|
|
|
|
|
|
vec4 resFrag;
|
|
|
|
|
|
|
|
float ab = opacity;
|
2013-10-02 13:00:17 +00:00
|
|
|
float as = srcFrag.a;
|
|
|
|
float ad = dstFrag.a;
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2013-10-02 13:00:17 +00:00
|
|
|
float at = ab*as;
|
2013-09-01 14:27:21 +00:00
|
|
|
resFrag.a = at + ad - ad*at;
|
|
|
|
|
2013-12-20 06:39:11 +00:00
|
|
|
// Sigh...
|
|
|
|
if (ad == 0.0)
|
|
|
|
resFrag.rgb = srcFrag.rgb;
|
|
|
|
else
|
|
|
|
resFrag.rgb = as*srcFrag.rgb + (1.0-at) * ad * dstFrag.rgb;
|
2013-09-01 14:27:21 +00:00
|
|
|
|
|
|
|
gl_FragColor = resFrag;
|
|
|
|
}
|