mrRay / vvopensource

OSC and MIDI frameworks for OS X and iOS, a framework for managing and rendering to GL textures in OS X, and a functional ISF (interactive shader format) implementation for OS X.
231 stars 33 forks source link

Premultiplied alpha in multipass sampling #33

Open bananoid opened 4 years ago

bananoid commented 4 years ago

When I sample a vec4 from an other pass buffer I get a vector where XYZ are multiplied by W. This make it impossible to use the W.

/*{
    "CATEGORIES": [
        "XXX"
    ],
    "CREDIT": "by gosub7777777",
    "DESCRIPTION": "",
    "INPUTS": [
        {
            "NAME": "inputImage",
            "TYPE": "image"
        }
    ],
    "ISFVSN": "2",
    "PASSES": [
        {
            "FLOAT": true,
            "HEIGHT": "$HEIGHT",
            "PERSISTENT": true,
            "TARGET": "first",
            "WIDTH": "$WIDTH"
        },
        {
        }
    ]
}
*/

void main() {
    if(PASSINDEX == 0){
        gl_FragColor = vec4(0.1, 0.0, 0.0, 10.);
    }
    if(PASSINDEX == 1){
        // gl_FragColor = vec4(0.1, 0.0, 0.0, 10.);
        gl_FragColor = IMG_PIXEL(first, isf_FragNormCoord.xy);  
    }
}