Fixed shader bug.

This commit is contained in:
Bryce Covert
2017-01-24 07:20:46 -08:00
parent 943b1ad8a1
commit 1806cf4259
3 changed files with 16 additions and 18 deletions

View File

@@ -93,7 +93,7 @@ uniform float hue_amount;
uniform sampler2D u_texture;
float Epsilon = 1e-10;
float Epsilon = 1e-3;
vec3 RGBtoHCV (vec3 RGB)
{
@@ -151,27 +151,25 @@ void main ()
vec2 sz = vec2 (2048.0, 2048.0);
vec3 step = vec3 (1.0 / 4.0, 1.0 / 4.0, 0.0);
vec2 tex_pixel = sz * v_texCoords - step.xy / 2.0;
float a = texture2D (u_texture, v_texCoords).w;
vec2 corner = floor (tex_pixel) + 1.0;
vec2 frac = min ((corner - tex_pixel) * vec2 (4.0, 4.0), vec2 (1.0, 1.0));
vec2 corner = floor (tex_pixel) + 1.0;
vec2 frac = min ((corner - tex_pixel) * vec2 (4.0, 4.0), vec2 (1.0, 1.0));
vec4 c1 = texture2D (u_texture, (floor (tex_pixel + step.zz) + 0.5) / sz);
vec4 c2 = texture2D (u_texture, (floor (tex_pixel + step.xz) + 0.5) / sz);
vec4 c3 = texture2D (u_texture, (floor (tex_pixel + step.zy) + 0.5) / sz);
vec4 c4 = texture2D (u_texture, (floor (tex_pixel + step.xy) + 0.5) / sz);
vec4 c1 = texture2D (u_texture, (floor (tex_pixel + step.zz) + 0.5) / sz);
vec4 c2 = texture2D (u_texture, (floor (tex_pixel + step.xz) + 0.5) / sz);
vec4 c3 = texture2D (u_texture, (floor (tex_pixel + step.zy) + 0.5) / sz);
vec4 c4 = texture2D (u_texture, (floor (tex_pixel + step.xy) + 0.5) / sz);
c1 *= frac.x * frac.y;
c2 *= (1.0 - frac.x) * frac.y;
c3 *= frac.x * (1.0 - frac.y);
c4 *= (1.0 - frac.x) * (1.0 - frac.y);
vec4 scaledColor = (c1 + c2 + c3 + c4);
c1 *= frac.x * frac.y;
c2 *= (1.0 - frac.x) * frac.y;
c3 *= frac.x * (1.0 - frac.y);
c4 *= (1.0 - frac.x) * (1.0 - frac.y);
vec4 scaledColor = (c1 + c2 + c3 + c4);
vec4 multiplied = mix(scaledColor.rgba, v_color.rgba * scaledColor.rgba, multiply_amount * 0.67 );
vec4 hued = mix(multiplied, BlendHue(multiplied.rgba, v_color.rgba), hue_amount * 0.67);
vec4 final = hued;
vec4 multiplied = mix(scaledColor.rgba, v_color.rgba * scaledColor.rgba, multiply_amount * 0.67 );
vec4 hued = mix(multiplied, BlendHue(multiplied.rgba, v_color.rgba), hue_amount * 0.67);
gl_FragColor = vec4(final.xyz, a);
gl_FragColor = vec4(hued.xyz, scaledColor.a);
}
")

View File

@@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>19</string>
<string>29</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<key>LSRequiresIPhoneOS</key>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 144 KiB