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

Input ports may be declared as abstract GLSL functions #352

Merged
merged 14 commits into from
Mar 18, 2021
Merged

Conversation

xian
Copy link
Member

@xian xian commented Feb 28, 2021

Example transition shader below. Note that the functions channelA and channelB below have no body, so they become input ports. If arguments are passed to them, those values will be injected (by content type) into any shaders routed through that port. That is, the value supplied for uv will override any injected uv-coordinate value requested by shaders via that input port.

// @param uv uv-coordinate
// @return color
vec4 channelA(vec2 uv);

// @param uv uv-coordinate
// @return color
vec4 channelB(vec2 uv);

uniform float fade; // @type float

// @return color
vec4 main() {
    if (1. - gl_FragCoord.x > fade) {
        return channelA(gl_FragCoord + vec2(fade, 0));
    } else {
        return channelB(gl_FragCoord + vec2(fade - 1., 0));
    }
}
Screen.Recording.2021-03-12.at.5.19.16.PM.mov

See also related subject matter:

@xian xian linked an issue Mar 12, 2021 that may be closed by this pull request
2 tasks
@xian xian changed the title Transitions Input ports may be declared as abstract GLSL functions Mar 12, 2021
@xian xian marked this pull request as ready for review March 13, 2021 01:45
@xian xian merged commit 895d9d6 into main Mar 18, 2021
@xian xian deleted the transitions branch March 18, 2021 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Cross-fade transition when switching between patches
1 participant