Jump to content

COP2 VEX Filter using ninput does not work

Recommended Posts

Hello houdini-community!

I'm trying to create an outline filter using vex. You can find the code below, I copied it from the SideFX-Forum. I put the code in a vfl file and compiled it to a hda-file using vcc. Then, I imported the HDA into a simple project, got a Render compositing node and wired its output into my custom outline-node. As a result I just get a completely black image. I've looked into the components of the matrix3 that ninput returns and they are always just 0, although my render-output has almost no black pixels.

Is there anyone who has an idea what I might be missing? Any help is highly appreciated!

Edit: I fogot to mention that I tried to get the same result using a Convolve Compositing Node with the same kernel as used in the code. That works. However, this is just an experiment for me I really want to know how to implement such a filter using VEX.

cop2 outlines(float effect = 1)
matrix3 kernel;
matrix3 pixels;
vector4 col;
float result;
int i, x, y;

col = 0.0;

// this builds a kernel with -1/8 in all elements but the center, which is
// +1 (an edge detect kernel, sums to 0); for sharpen, use effect+1
// for the center pixel
kernel = 0;
for(x=0; x<3; x++)
for(y=0; y<3; y++)
setcomp(kernel, -effect/8, x,y);
setcomp(kernel, effect, 1,1);

// iterate over all components in the current plane (PL)
for(i=0; i<4; i++)
pixels = ninput(0, PL, 0, i, IX, IY, FR);

// sum the results of the kernel x pixels
result = 0;
for(x=0; x<3; x++)
for(y=0; y<3; y++)
result += getcomp(pixels,x,y) * getcomp(kernel,x,y);

setcomp(col, result, i);

assign(Cr, Cg, Cb, C4, col);


Edited by jonklein

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now