Hi, only three things:
1. Someone could explain a practical application for the filterstep function?
2. I notice that texture func has a filter implemented, so how to filter an incomming color, for example a pattern.(maybe with filterstep?)
3. It?Ls possible to get the output of a composite node and put into vexbuilder or vex code to use as texture?
Thanks a lot in advance.
SoFoThEn
Javi.
FilterStep help
3419 1 1- RED OCTOBER
- Member
- 7 posts
- Joined: July 2005
- Offline
- Mario Marengo
- Member
- 941 posts
- Joined: July 2005
- Offline
RED OCTOBERSay you're doing stripes on a plane based on s. Say you want white when s>=0.5 and black when s<0.5. You've just created a region of “infinite frequency” (a discontinuity) at s=0.5 – the function jumps instantly from black to white over a 0-length range. A wonderful source of our beloved friend “The Jaggie”
1. Someone could explain a practical application for the filterstep function?
We can define our function like this:
float f(float s) { return (abs(s)>=0.5); }
And a little shader to test it:surface test_fs( float frequency = 100)
{
float ss = (s*frequency)%1.0;
Cf = f(ss);
}
Assign this shader to a NURBs or mesh grid and place the camera so the plane vanishes into the horizon – an infinite “floor” – and render. See the jaggies? If not; then increment the frequency until you do.
The jump that our function has at s=0.5 is exactly the kind of “step” that the filterstep() function is designed to deal with. Mantra can approximate how much a parameter like ‘s’ can change at each shading step using surface derivatives, and filterstep() then uses this information to “average out” the region straddling that “step” at 0.5. – “blurs” the boundary by the “right” amount.
So here's an antialiased version of our function using filterstep instead of a raw conditional:float faa(float s) { return filterstep(0.5,abs(s)); }
And we modify our shader to use it as an option like this:#pragma hint antialiased toggle
surface test_fs( float frequency = 100; int antialiased = 1)
{
float ss = (s*frequency)%1.0;
Cf = antialiased?faa(ss):f(ss);
}
Still not perfect since we're only taking care of one side of the stripes, but that side should look a lot smoother now. Also note that close to the horizon, and with a high enough frequency, the filter size will likely be bigger than a single stripe, and so *that* has to be dealt with as well.
Also note that if ‘s’ is both negative and positive (i.e: goes from -.5 to 1.0, say; then you'll see your stripes flip – this is a sideffect of using the modulus operator ‘%’ (I just *had* to throw that one in there, didn't I :lol
Anyway; this should give you an idea of what filterstep() does, I hope
RED OCTOBERThe filtering works fine for the texture() function (as for filterstep()); but you're not going to see any effect unless you user .rat textures (instead of .pic or .tif or whatever).
2. I notice that texture func has a filter implemented, so how to filter an incomming color, for example a pattern.(maybe with filterstep?)
-
- Quick Links