/usr/share/fs-uae/shaders/testbloom-2.shader is in fs-uae 2.4.1+ds-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | <?xml version="1.0" encoding="UTF-8"?>
<shader language="GLSL">
<vertex><![CDATA[
void main(void) {
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
}
]]></vertex>
<fragment><![CDATA[
uniform sampler2D texture;
#define glarebasesize 0.896
#define power 0.40 // 0.50 is good
uniform vec2 rubyTextureSize;
void main()
{
vec4 sum = vec4(0.0);
vec4 bum = vec4(0.0);
vec2 texcoord = vec2(gl_TexCoord[0]);
int j;
int i;
vec2 glaresize = vec2(glarebasesize) / rubyTextureSize;
for(i = -2; i < 2; i++)
{
for (j = -1; j < 1; j++)
{
sum += texture2D(texture, texcoord + vec2(-i, j)*glaresize) * power;
bum += texture2D(texture, texcoord + vec2(j, i)*glaresize) * power;
}
}
if (texture2D(texture, texcoord).r < 2.0)
{
gl_FragColor = sum*sum*sum*0.001+bum*bum*bum*0.0080 + texture2D(texture, texcoord);
}
}
]]></fragment>
<fragment scale="1.0" filter="nearest"><![CDATA[
uniform sampler2D rubyTexture;
uniform vec2 rubyTextureSize;
const float MIX_ALPHA = 0.4;
void main(void) {
vec4 rgb = texture2D(rubyTexture, gl_TexCoord[0].xy);
vec4 rgb2;
if (int(gl_FragCoord.x) == 0) {
rgb2 = rgb;
}
else {
rgb2 = texture2D(rubyTexture, gl_TexCoord[0].xy +
vec2(-1.0 / rubyTextureSize.x, 0));
}
gl_FragColor = mix(rgb, rgb2, MIX_ALPHA);
}
]]></fragment>
<fragment outscale="1.0"><![CDATA[
uniform sampler2D rubyTexture;
const float STRENGTH = 160.0;
const float STRENGTH2 = 250.0;
float Hue_2_RGB(float v1, float v2, float vH )
{
float ret;
if ( vH < 0.0 )
vH += 1.0;
if ( vH > 1.0 )
vH -= 1.0;
if ( ( 6.0 * vH ) < 1.0 )
ret = ( v1 + ( v2 - v1 ) * 6.0 * vH );
else if ( ( 2.0 * vH ) < 1.0 )
ret = ( v2 );
else if ( ( 3.0 * vH ) < 2.0 )
ret = ( v1 + ( v2 - v1 ) * ( ( 2.0 / 3.0 ) - vH ) * 6.0 );
else
ret = v1;
return ret;
}
void main(void) {
const float istrength = 255.0 - STRENGTH;
const float istrength2 = 255.0 - STRENGTH2;
const float max_brightness = 245.0;
vec4 rgb = texture2D(rubyTexture, gl_TexCoord[0].xy);
float Cmax, Cmin;
float D;
float H, S, L;
float R, G, B;
R = rgb.r;
G = rgb.g;
B = rgb.b;
Cmax = max (R, max (G, B));
Cmin = min (R, min (G, B));
// calculate lightness
L = (Cmax + Cmin) / 2.0;
if (Cmax == Cmin) { // it's grey
H = 0.0; // it's actually undefined
S = 0.0;
}
else {
D = Cmax - Cmin; // we know D != 0 so we cas safely divide by it// calculate lightness
// calculate Saturation
if (L < 0.5)
{
S = D / (Cmax + Cmin);
}
else
{
S = D / (2.0 - (Cmax + Cmin));
}
// calculate Hue
if (R == Cmax)
{
H = (G - B) / D;
} else {
if (G == Cmax)
{
H = 2.0 + (B - R) /D;
}
else
{
H = 4.0 + (R - G) / D;
}
}
H = H / 6.0;
}
float line = float(int(gl_FragCoord.y));
if (int(mod(line, 3.0)) < 1) {
//float ia = (istrength - (255.0 - max_brightness)) / 255.0 +
// ((rgb.r + rgb.g + rgb.b) / 3.0) / (255.0 / STRENGTH);
//gl_FragColor = rgb * vec4(ia, ia, ia, 1.0);
float ia = (istrength - (255.0 - max_brightness)) / 255.0 +
(L) / (255.0 / STRENGTH);
L = L * ia;
}
else if (int(mod(line, 3.0)) < 2) {
//float ia = (istrength2 - (255.0 - max_brightness)) / 255.0 +
// ((rgb.r + rgb.g + rgb.b) / 3.0) / (255.0 / STRENGTH2);
//gl_FragColor = rgb * vec4(ia, ia, ia, 1.0);
//L = L * 0.95 + 0.05;
float ia = (istrength - (255.0 - max_brightness)) / 255.0 +
(L) / (255.0 / STRENGTH2);
L = L * ia;
}
else {
//gl_FragColor = mix(rgb,
// vec4(1.0, 1.0, 1.0, 1.0), 0.05);
//L = L * 0.95 + 0.05;
}
//float gamma = 10.0;
//S = pow(S, 1.0 / gamma);
//S = 1.0;
//S = 1.0 - S;
//S = S * (1.0 - S);
//S = 0.5 + S * 0.5;
//S = 1.0 - S;
if (H < 0.0)
{
H = H + 1.0;
}
// clamp H,S and L to [0..1]
H = clamp(H, 0.0, 1.0);
S = clamp(S, 0.0, 1.0);
L = clamp(L, 0.0, 1.0);
float var_2, var_1;
if (S == 0.0)
{
R = L;
G = L;
B = L;
}
else
{
if ( L < 0.5 )
{
var_2 = L * ( 1.0 + S );
}
else
{
var_2 = ( L + S ) - ( S * L );
}
var_1 = 2.0 * L - var_2;
R = Hue_2_RGB( var_1, var_2, H + ( 1.0 / 3.0 ) );
G = Hue_2_RGB( var_1, var_2, H );
B = Hue_2_RGB( var_1, var_2, H - ( 1.0 / 3.0 ) );
}
gl_FragColor = vec4(R,G,B, rgb.a);
}
]]></fragment>
</shader>
|