Jump to content
Sign in to follow this  
B.Walters

Filtering Texture Maps In Vex

Recommended Posts

No matter how extreme I set the values to, my image doesn't seem to blur. Neither am I seemingly able to change the filter method ("box", "point", etc), so I assume something is wrong with my code despite the fact that I don't get any errors and the shader successfully renders with a texture map:

Cf= texture(texmap, uv.x, uv.y, "filter", filter, "width", width);

Another related question: if I only wanted a specific channel (say the alpha channel), how would I access that?

Share this post


Link to post
Share on other sites

Hi,

You have to convert your image to .rat format for filtering to work.

I don't know the exact answer to your second question off the top of my head but you want to use a vector4 to represent RGBA then convert it to a vector3 (RGB) and a float(A).

Hope the above helps!

Cheers!

steven

Share this post


Link to post
Share on other sites

Absolutely, thanks steven!

And if anybody knows of a more efficient way to get a specific channel from an image, please let me know as I'm still looking.

Share this post


Link to post
Share on other sites
And if anybody knows of a more efficient way to get a specific channel from an image, please let me know as I'm still looking.

I don't know about more efficient, but, AFAIK, in VEX (and in H8), you can access the individual members of a compound type (like vector and vector4) with the "dot" operator. The predefined names for the four members of a vector4 type are {x,y,z,w} or {r,g,b,a}, so something like this should be possible:

// fetch the RGBA texture color
vector4 tx  = texture(...);

// or with an explicit cast, though it shouldn't be necessary 
// in a simple assignment:
// vector4 tx  = vector4(texture(...));

// then do stuff with the elements
vector  RGB = set(tx.r,tx.g,tx.b);
float   R   = tx.r;
float   G   = tx.g;
float   B   = tx.b;
float   A   = tx.a;

(untested...)

Share this post


Link to post
Share on other sites
Please use Mario's suggestion as he knows what he's talking about. :)

Thanks, but so do you! :)

...however, in all cases, I recommend we all give the last word to crunch's "little bird"...

Share this post


Link to post
Share on other sites
...however, in all cases, I recommend we all give the last word to crunch's "little bird"...

Too easy.

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
Sign in to follow this  

×