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

🐛 Patch mod applied to filtered shader content shouldn't flow downstream #501

Open
xian opened this issue Sep 26, 2022 · 0 comments
Open

Comments

@xian
Copy link
Member

xian commented Sep 26, 2022

If a patch's output content type matches the content type of one of its inputs, it's considered a filter, and will automatically be inserted upstream of other patches that use the same content type.

For example, 'Ripple' is a filter, because it takes a U/V coordinate as input, and returns a U/V coordinate:

uniform float time;
uniform float rippleAmount; // @type float

// @return uv-coordinate
// @param uvIn uv-coordinate
vec2 main(vec2 uvIn) {
    vec2 p = -1.0 + 2.0 * uvIn;
    float len = length(p);
    return uvIn + (p/len)*sin(len*12.0-time*4.0)*0.1 * rippleAmount;
}

It's possible to offset the coordinate system of Ripple using the Position and Scale patch mod on the uv input port, which will cause the center of the ripple effect to move. But, since the output U/V includes that offset, every downstream patch will also move along with the ripple's center.

To fix: the output's offset should be reversed, comme ça:

vec2 rippleOut = undoPositionShift(ripple_main(applyPositionShift(uv));
@xian xian changed the title Patch mod applied to filtered shader content shouldn't flow downstream 🐛 Patch mod applied to filtered shader content shouldn't flow downstream Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To do
Development

No branches or pull requests

1 participant