Initial commit

This commit is contained in:
Jonas Kulla 2013-09-01 16:27:21 +02:00
commit ff25887f41
119 changed files with 24901 additions and 0 deletions

31
shader/bitmapBlit.frag Normal file
View file

@ -0,0 +1,31 @@
uniform sampler2D source;
uniform sampler2D destination;
uniform vec4 subRect;
uniform float opacity;
void main()
{
vec2 coor = gl_TexCoord[0].xy;
vec2 dstCoor = (coor - subRect.xy) * subRect.zw;
vec4 srcFrag = texture2D(source, coor);
vec4 dstFrag = texture2D(destination, dstCoor);
vec4 resFrag;
float ab = opacity;
const float as = srcFrag.a;
const float ad = dstFrag.a;
const float at = ab*as;
resFrag.a = at + ad - ad*at;
resFrag.rgb = mix(dstFrag.rgb, srcFrag.rgb, ab*as);
// resFrag.rgb /= (resFrag.a);
resFrag.rgb = mix(srcFrag.rgb, resFrag.rgb, ad*resFrag.a);
gl_FragColor = resFrag;
}

40
shader/hue.frag Normal file
View file

@ -0,0 +1,40 @@
uniform sampler2D inputTexture;
uniform float hueAdjust;
void main ()
{
const vec4 kRGBToYPrime = vec4 (0.299, 0.587, 0.114, 0.0);
const vec4 kRGBToI = vec4 (0.596, -0.275, -0.321, 0.0);
const vec4 kRGBToQ = vec4 (0.212, -0.523, 0.311, 0.0);
const vec4 kYIQToR = vec4 (1.0, 0.956, 0.621, 0.0);
const vec4 kYIQToG = vec4 (1.0, -0.272, -0.647, 0.0);
const vec4 kYIQToB = vec4 (1.0, -1.107, 1.704, 0.0);
// Sample the input pixel
vec4 color = texture2D (inputTexture, gl_TexCoord [ 0 ].xy);
// Convert to YIQ
float YPrime = dot (color, kRGBToYPrime);
float I = dot (color, kRGBToI);
float Q = dot (color, kRGBToQ);
// Calculate the hue and chroma
float hue = atan (Q, I);
float chroma = sqrt (I * I + Q * Q);
// Make the user's adjustments
hue += hueAdjust;
// Convert back to YIQ
Q = chroma * sin (hue);
I = chroma * cos (hue);
// Convert back to RGB
vec4 yIQ = vec4 (YPrime, I, Q, 0.0);
color.r = dot (yIQ, kYIQToR);
color.g = dot (yIQ, kYIQToG);
color.b = dot (yIQ, kYIQToB);
// Save the result
gl_FragColor = color;
}

43
shader/sprite.frag Normal file
View file

@ -0,0 +1,43 @@
uniform sampler2D texture;
uniform vec4 tone;
uniform float opacity;
uniform vec4 color;
uniform vec4 flash;
uniform float bushDepth;
uniform float bushOpacity;
const vec3 lumaF = { .299, .587, .114 };
void main()
{
vec2 coor = gl_TexCoord[0].xy;
/* Sample source color */
vec4 frag = texture2D(texture, coor);
/* Apply gray */
const float luma = dot(frag.rgb, lumaF);
frag.rgb = mix(frag.rgb, vec3(luma), tone.w);
/* Apply tone */
frag.rgb += tone.rgb;
/* Apply opacity */
frag.a *= opacity;
/* Apply color */
frag.rgb = mix(frag.rgb, color.rgb, color.a);
/* Apply flash */
frag.rgb = mix(frag.rgb, flash.rgb, flash.a);
/* Apply bush alpha by mathematical if */
float underBush = float(coor.y < bushDepth);
frag.a *= clamp(bushOpacity + underBush, 0, 1);
gl_FragColor = frag;
}

23
shader/trans.frag Normal file
View file

@ -0,0 +1,23 @@
/* Fragment shader dealing with transitions */
uniform sampler2D currentScene;
uniform sampler2D frozenScene;
uniform sampler2D transMap;
/* Normalized */
uniform float prog;
/* Vague [0, 512] normalized */
uniform float vague;
void main()
{
vec2 texCoor = gl_TexCoord[0].st;
float transV = texture2D(transMap, texCoor).r;
float cTransV = clamp(transV, prog, prog+vague);
float alpha = (cTransV - prog) / vague;
vec4 newFrag = texture2D(currentScene, texCoor);
vec4 oldFrag = texture2D(frozenScene, texCoor);
gl_FragColor = mix(newFrag, oldFrag, alpha);
}

13
shader/transSimple.frag Normal file
View file

@ -0,0 +1,13 @@
uniform sampler2D frozenScene;
uniform sampler2D currentScene;
uniform float prog;
void main()
{
vec2 texCoor = gl_TexCoord[0].st;
vec4 newPixel = texture2D(currentScene, texCoor);
vec4 oldPixel = texture2D(frozenScene, texCoor);
gl_FragColor = mix(oldPixel, newPixel, prog);
}