Skip to content

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

@xian

Description

@xian

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));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions