Jump to content

Custom Specular Shader


Recommended Posts

Hello

I am writing a supershader for myself using VEX builder. One thing I found is that I need to create my own specular shader, as the one in the lighting model I dont like. How can I create a custom node for VEX builder? Is it even possible?

Link to comment
Share on other sites

Hello

I am writing a supershader for myself using VEX builder. One thing I found is that I need to create my own specular shader, as the one in the lighting model I dont like. How can I create a custom node for VEX builder? Is it even possible?

You'll want to have a look at the illuminace loop vop. It basically acts a as a "for" loop the iterates over all the

lights in your scene.

Luca

Link to comment
Share on other sites

You'll want to have a look at the illuminace loop vop. It basically acts a as a "for" loop the iterates over all the

lights in your scene.

Luca

Thanks!

But how do I create a custom node for VEX builder though - this is where I have the most trouble!

Link to comment
Share on other sites

Thanks!

But how do I create a custom node for VEX builder though - this is where I have the most trouble!

Ah, now I see what you're asking.

File>New Operator Type

In the dialogue that pops up choose vex builder type and you should be ready to go.

Luca

Link to comment
Share on other sites

Ah, now I see what you're asking.

File>New Operator Type

In the dialogue that pops up choose vex builder type and you should be ready to go.

Luca

Okey that seams to work. The only problem is that I don't understand how to create one. Is there a sample which I can look at? I don't really know where to go from there. =(

Just to make sure - I am not trying to creatr a VEX builder node from MANY nodes. I just need to have a custom node that I would code.

I see that I can type in VEX code in that window, but what I don't understand is how to create input and out put parameters .... well I dont really understand how to make a node. I have a full understanding of the illum loop that I have to use for spec highlights, its just wrapping it around some more VEX code to have a custom node what's stopping me.

Link to comment
Share on other sites

Создав новый VOP оператор прыгай сразу в input/output менюшку...

там позадавай необходимые входы - выходы своего оператора.

Потом прыгай в VEX менюшку и кодь как обычно с той лиш разницей

что в вексе используй имена входов выходов с префиксом $

Например

Создай вход типа float c именем input1

и выход типа vector с именем output2

В векс пропиши чтонить типа

$output1 = {1,1,0};

$output1 += $input1;

в догонку....

inner code - это место где кодится сам оператор

outer code - это место где кодятся всякие константы и функции которые могут быть использованы этим оператором.

Edited by AndrewVK
Link to comment
Share on other sites

Создав новый VOP оператор прыгай сразу в input/output менюшку...

там позадавай необходимые входы - выходы своего оператора.

Потом прыгай в VEX менюшку и кодь как обычно с той лиш разницей

что в вексе используй имена входов выходов с префиксом $

Например

Создай вход типа float c именем input1

и выход типа vector с именем output2

В векс пропиши чтонить типа

$output1 = {1,1,0};

$output1 += $input1;

в догонку....

inner code - это место где кодится сам оператор

outer code - это место где кодятся всякие константы и функции которые могут быть использованы этим оператором.

This looks interesting...any chance we can get it in English? :D

Link to comment
Share on other sites

Okey that seams to work. The only problem is that I don't understand how to create one. Is there a sample which I can look at? I don't really know where to go from there. =(

Hi Dennis,

go into vops and create a surface shader network.

dive in it and lay down a "lighting model" vop.

rmb on the node and bring up the "type properties"

go to the tab labeled vex code and you'll see two tabs one labeled "inner code"

and one labeled "outer code"

this is the vex code required to make this vex builder node.

you can use this as a starting point.

You'll notice that there are functions(starting with "vop_") that you can't find in the vex

documentation. this is because they are defined in the header files voptype.h and voplib.h

Which is why they are included in the outer code.

You don't need to use these functions, of course. you can create

your own header and uses those functions.

If you run into trouble let me know.

Luca

Link to comment
Share on other sites

Thanks alot. BTW, where do I found those .h files?

Hi Dennis,

go into vops and create a surface shader network.

dive in it and lay down a "lighting model" vop.

rmb on the node and bring up the "type properties"

go to the tab labeled vex code and you'll see two tabs one labeled "inner code"

and one labeled "outer code"

this is the vex code required to make this vex builder node.

you can use this as a starting point.

You'll notice that there are functions(starting with "vop_") that you can't find in the vex

documentation. this is because they are defined in the header files voptype.h and voplib.h

Which is why they are included in the outer code.

You don't need to use these functions, of course. you can create

your own header and uses those functions.

If you run into trouble let me know.

Luca

Link to comment
Share on other sites

Thanks alot. BTW, where do I found those .h files?

It should be somewhere in your $HOUDINI_PATH.

I found mine in:

/net/apps/rhel40/hfs8.0.370/houdini/vex/include

If you go to $HFS (where houdini is installed) and look for the directory ./houdini/vex/include

you should be able to find it.

L

Link to comment
Share on other sites

Okey, found those and it all came down to this

clr = amb * ambient() + diff * diffuse(nf) + 
		  spec * blinn(nf, -ii, urough);

Obviously I need to write my own blinn() func. So now I guess I should check that illum loop that cycles through all the lights in the scene, Where do I find example of it

Sorry for too many questions, this is fist time using VEX for me (actually about 2-3 weeks of Houdini as well=)

It should be somewhere in your $HOUDINI_PATH.

I found mine in:

/net/apps/rhel40/hfs8.0.370/houdini/vex/include

If you go to $HFS (where houdini is installed) and look for the directory ./houdini/vex/include

you should be able to find it.

L

Edited by Dennis Sedov
Link to comment
Share on other sites

okey . found it in Anisotropic shader: The only problem is I have not found illuminance in houdini's help. I dont understand input params of this function

illuminance (P, nn, M_PI/2, LIGHT_SPECULAR)
		{
		LL = normalize(L);
		cos_i = dot(LL , nn);
			if (cos_i > 0.0)
			{
		 H = normalize (V + LL);
		 uval = dot(tanU, H);
		 vval = dot(tanV, H);
		 rz = cos_i*exp(-2.*(uval*uval + vval*vval) / 
					(1.0 + dot(H, nn))); 
		 rz /= nml_term * sqrt(cos_i*cos_r); 
		 lclr += Cl * rz; 
		}
	}

Edited by Dennis Sedov
Link to comment
Share on other sites

okey . found it in Anisotropic shader: The only problem is I have not found illuminance in houdini's help.

here's where you can find the docs on the illuminance loop:

hdox://houdini/content/vex/statements/illuminance.html

Luca

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...