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

Shaders can inject parameters into other shaders #334

Closed
xian opened this issue Dec 29, 2020 · 1 comment
Closed

Shaders can inject parameters into other shaders #334

xian opened this issue Dec 29, 2020 · 1 comment

Comments

@xian
Copy link
Member

xian commented Dec 29, 2020

In the example below, imageA and imageB both become color input ports; for whatever is wired to those ports, any uv-coordinate input port will be satisfied with the value passed to the corresponding function.

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

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

// @return color
// @param position uv-coordinate
vec4 main(vec2 uv, float progress) {
    if (uv.x < progress) {
        return imageA(vec2(uv.x - 1. + progress, uv.y));
    } else {
        return imageB(vec2(uv.x + progress, uv.y));
    }
}

This could, e.g. be used to create an effect where one image slides off to one side as another slides in from the other.

@xian xian changed the title Shaders can inject parameters into other shaders: Shaders can inject parameters into other shaders Dec 29, 2020
@xian
Copy link
Member Author

xian commented May 18, 2021

Oops, this was implemented in #352.

@xian xian closed this as completed May 18, 2021
@xian xian moved this to Done in sparklemotion Jul 25, 2023
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

No branches or pull requests

1 participant