VEX bias function?

   7235   14   1
User Avatar
Member
1004 posts
Joined: April 2017
Offline
Hi! I'm trying to bias a gradient in VEX.

I've checked the bias node in a vop to see its vex code and it looks like this:

bias = vop_bias(age1, 0.5);

But when I type bias in vex, nothing magical happens… it doesn't seam to recognize bias as a function.

(I'm very new to VEX)

-Olivier
User Avatar
Member
419 posts
Joined: Feb. 2012
Online
Look at “Lerp”

http://www.sidefx.com/docs/houdini/vex/functions/lerp.html [www.sidefx.com]
User Avatar
Member
419 posts
Joined: Feb. 2012
Online
Look at “Lerp”

http://www.sidefx.com/docs/houdini/vex/functions/lerp.html [www.sidefx.com]
User Avatar
Member
2036 posts
Joined: Sept. 2015
Offline
Or make your own bias.

Help on vop_bias states how they calculate the value:

The Bias VOP is based on Perlin’s section in Texture & Modeling, and is currently only used in some of the older materials.

The basic process is to take:

result = amount / ( ((1/value) - 2) * (1 - amount) + 1);

Where value is the Input, and amount is the Bias.
User Avatar
Member
1004 posts
Joined: April 2017
Offline
I tried the result = amount / ( ((1/value) - 2) * (1 - amount) + 1); but the curve is not what I'm looking for. Actually, I'd like something that looks more like a gamma curve. I thought bias would give the same result but it doesn't.

-Olivier
User Avatar
Member
1737 posts
Joined: May 2006
Offline
Often its easier to do this with a channel ramp; if you can get your incoming values into a range between 0 and 1, set the default ramp type to have bezier interpolation, then click a new point in the middle, you can control the curvature pretty easily.

Attachments:
chramp_bias.gif (536.1 KB)

http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
7737 posts
Joined: Sept. 2011
Offline
Has no one heard of #include?

Include voplib.h, it's a gold mine!

For more treasures, checkout $HH/vex/include
Edited by jsmack - Feb. 18, 2018 20:28:06
User Avatar
Member
4189 posts
Joined: June 2012
Offline
// gamma function

@P.y = @P.y/pow((@P.x),chf(“gamma”));
Edited by anon_user_37409885 - Feb. 19, 2018 05:02:22

Attachments:
GammaFunction.hiplc (69.6 KB)

User Avatar
Member
1004 posts
Joined: April 2017
Offline
mestela: Thanks for the example but I was looking for a simple float value that I would stamp later on.

jsmack: I have no idea what you are talking about. Don't forget I'm a super noob in houdini. I just started.

fuos: Thanks! Your example sounds like what I'm looking for. I'll check it out as soon as I can.

-Olivier aka super-noob
User Avatar
Member
1004 posts
Joined: April 2017
Offline
Works nicely!

Sadly, stamping the gamma value is slower than I expected. Oh well!

Thanks anyway!

-Olivier
User Avatar
Member
8525 posts
Joined: July 2007
Offline
olivierth
jsmack: I have no idea what you are talking about. Don't forget I'm a super noob in houdini. I just started.
jsmack meant this, exactly what VOPs do:
#include <voplib.h>
@P.y = vop_bias(@P.x, 0.25);
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
171 posts
Joined: Oct. 2016
Offline
Hello
I meet this recommendation by jsmack for the second time
but don't understand - how we use it?
just read it as a text document or we somehow call this info from Houdini?
is this #include - explanation/ additional information to the help docs?
i'm nervous and afraid that can't figure out something important

in this topic e.g.
for vop bias node it's written so in help docs >
result = amount / ( ((1/value) - 2) * (1 - amount) + 1);
Where value is the Input, and amount is the Bias.

in voplib >
float
vop_bias(float base, bias)
{
float val;
if (base <= 0)
val = 0;
else if (base >= 1)
val = 1;
else
val = bias / (((1.0 / base) - 2) * (1 - bias) + 1);
return val;
}

and how tamte realized from this how it should look like?
feel lost and don't understand how to take sense from it
would be great if someone can point/ explain
Edited by RyuKu - Feb. 28, 2018 14:28:45
User Avatar
Member
8525 posts
Joined: July 2007
Offline
voplib.h is just a library/module containing the functions

by doing
#include <voplib.h>
you are including all the functions from within that library to your code
so then just simply calling the function
@P.y = vop_bias(@P.x, 0.25);
would be able to find it and execute

it's like importing functions from a module in Python without a namespace:
from somemodule import *
which will enable to directly call included functions
Edited by tamte - Feb. 28, 2018 14:49:37
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
171 posts
Joined: Oct. 2016
Offline
tamte

if we don't write #include <xxx.h> above the code - Houdini doesn't look inside this library (and wrangle e.g. with your example gives a mistake saying i call undefined function), and if we do - we tell him to go to the mentioned library to find information about code executing?
how do you understand you need to call this? you knew that formula's contained there? you've read it as a text document? we can write the same without #include but longer or for some functions we need to use only this way?
for Python with this code we tell to import everything from module from lib/ standard library? or you mean something else i miss? it's awfully i didn't touch it for a couple of weeks though it's so taking and maybe i tell something absolutely incorrect, but
import random
return(random.random())
should be written seems differently with
from random import *
cause it doesn't do the same, or maybe i tell about something wrong and without needed understaning
User Avatar
Member
8525 posts
Joined: July 2007
Offline
Ryu Ku
tamte

if we don't write #include <xxx.h> above the code - Houdini doesn't look inside this library (and wrangle e.g. with your example gives a mistake saying i call undefined function), and if we do - we tell him to go to the mentioned library to find information about code executing?
how do you understand you need to call this? you knew that formula's contained there? you've read it as a text document? we can write the same without #include but longer or for some functions we need to use only this way?
for Python with this code we tell to import everything from module from lib/ standard library? or you mean something else i miss? it's awfully i didn't touch it for a couple of weeks though it's so taking and maybe i tell something absolutely incorrect, but
import random
return(random.random())
should be written seems differently with
from random import *
cause it doesn't do the same, or maybe i tell about something wrong and without needed understaning
as I mentioned
from random import *
would import all functions to the main body, which possibly can cause conflicts if there are already functions/variables with the same name, so instead of
import random
print(random.random())
you'd have
from random import *
print(random())
or if you want just function named random then you can import just that one
from random import random
print(random())

however I would not generally recommend importing functions without namespace in Python
however VEX doesn't support namespaces, so #include imports functions to the main body and potentially causes conflicts, that's why some functions in supporting .h libraries have pretty creative names, like even all voplib are prefixed with vop_ to lessen the chance of conflicts, not very elegant

anyway, how you can find out
just do something in Attrib VOP, then RMB/VEXVOP Options/View VEX code, you'll see what's included and called
Edited by tamte - Feb. 28, 2018 19:09:56
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links