Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return type not correct? #166

Open
alvarotrigo opened this issue Jun 14, 2021 · 0 comments
Open

Return type not correct? #166

alvarotrigo opened this issue Jun 14, 2021 · 0 comments

Comments

@alvarotrigo
Copy link

alvarotrigo commented Jun 14, 2021

I found this shader online and I was wondering how to implement it using gl-transitions.

uniform float mixer;
uniform sampler2D tDiffuse;
uniform sampler2D tSphere;
varying vec2 vUv;
//idea
//https://www.decarpentier.nl/lens-distortion
//distort method from 
// https://www.imaginationtech.com/blog/speeding-up-gpu-barrel-distortion-correction-in-mobile-vr/
vec2 distort(vec2 st, float alpha, float expo ){
    vec2 p1 = vec2(2.0 * st - 1.0);
    vec2 p2 = p1 / (1.0 - alpha * length( p1 ) * expo );
    return (p2 + 1.0) * 0.5;
}
void main() {
    float t = mixer;
    float tr = smoothstep( 0.75,1., t );
    float e = t * 4.;
    
    //stretch out city scene
    vec2 uv = distort( vUv, -10. * pow( .5 + t * .5, 32. ), e );
    vec4 city = texture2D( tDiffuse, uv );
    
    //pinch in sphere scene
    uv = distort( vUv, -10. * ( 1. - tr ), e );
    vec4 sphere = texture2D( tSphere, uv );
    //blend    
    gl_FragColor = mix( city, sphere, tr );
}

I've tried replacing the function content on the gl-transition editor for the noise function's content but it keeps on saying return type is not correct:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant