nekocode / CameraFilter

📷 Realtime camera filters on android.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Texture2D compatibility issue

paulapithon opened this issue · comments

I was using ShaderToy to create a filter of my own and when I put it on the app, it seems to be a compatibility issue involving the texture class.

It appears that ShaderToy has the new version in which Texture2D was replaced by only texture and that's how I built my shader on the online tool:

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 uv = fragCoord.xy;
    int id = 5;
    vec3 s = texture(iChannel0, fragCoord.xy / iResolution.xy).xyz;

    vec3 c = vec3(50, 50, 50);
    vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
    vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
    vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
    float d = q.x - min(q.w, q.y);
    float e = 1.0e-10;
    vec3 dest = vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);

    vec3 color = max(s,dest);
    fragColor = vec4(color,1.0);
}

If I put the code like this on the app, the screen turns black, that because of the texture that is not supported. If I simply change from texture to texture2D in line 4, is like the entire screen in only one huge pixel that changes color as I move my camera.

Do you have any idea how I can change this code or the one on MyGLUtils class so it will work properly?

Change the line 4 to:

vec3 s = texture2D(iChannel0, fragCoord.xy).xyz;

And then have a try.

It worked! Thank you so much 😄