The New "import" keyword in H13

   6367   11   1
User Avatar
Member
13 posts
Joined: 1月 2014
Offline
Hello all!

I've noticed that in Houdini 13, within the directlighting VOP node, the outer code reads:

import directlighting;

Rather than the old way of specifying the whole function.

This is good.

But how do I import functions? Whenever I place “import directlighting;” in the outer code of any of my nodes, I get the following error:
Failed to import function ‘directlighting’. (30,1:21)

In addition, I get an identical error when trying to import it within a header. Importing it in a header is what I actually want to do: my main aim is to call directlighting() from within a header.

What do I need to do to get imports working?

Thanks!
User Avatar
Member
4271 posts
Joined: 7月 2005
Offline
Possibly a dumb question, but are you importing directlighting into a Surface shader?

You can only import shaders from a matching context.
if(coffees<2,round(float),float)
User Avatar
Member
13 posts
Joined: 1月 2014
Offline
Hi there Wolfwood,

Well I have a VOP node that I've made, that I use within a material builder in the SHOP. I've created it as a vex builder operator. Purely as a test, I'm trying to import it within that. I suppose that would work? Directlighting is a surface shader itself isn't it.

Are you also implying that as a header itself doesn't have any context per se, I won't be able to import anything into it? I am ultimately using the header in a shading context…
User Avatar
Member
4271 posts
Joined: 7月 2005
Offline
Hmm. Seems like it should work. Can you post a simple hip file?

The issue I was referring to is if you had wired it into a displacement shader, you'd get an error like this-

Warning: Errors or warnings encountered during VEX compile:
/shop/vopmaterial1: Failed to import function ‘directlighting’ for context ‘displace’. Only available in the ‘surface’ context. (21,1:21).
if(coffees<2,round(float),float)
User Avatar
Member
13 posts
Joined: 1月 2014
Offline
Well that actually looks like a useful error!

No, in my error lines there's no mention of contextual problems.

I'll throw together a quick scene and post it up asap. Thanks!
User Avatar
Member
13 posts
Joined: 1月 2014
Offline
So when building a test scene from scratch, the error about the “import” keyword never appears but it seems to think the directlighting() call is undefined, despite the fact that I have imported it:


opshop/vopmaterial1:32:5-18: Error 1066: Call to undefined function directlighting(string; bsdf; string; void; string; void; string; void; string; int; string; float; string; string; string; int; string; int; string; int; string; string; string; int; string; vector; string; vector; string; vector; string; float; string; int; string; vector). Candidates are: void directlighting(; … )
opshop/vopmaterial1:34:13-18: Error 1031: Invalid implicit cast from vector to void.
opshop/vopmaterial1:35:12-17: Error 1031: Invalid implicit cast from vector to void.
opshop/vopmaterial1:36:12-17: Error 1031: Invalid implicit cast from vector to void.
opshop/vopmaterial1:51:21-26: Warning 2018: Using uninitialized variable: direct

mantra: Could not find VEX shader ‘opshop/vopmaterial1’ (either .vfl or .vex)



Despite this, I've attached the file I used. The otl i created should be embedded. I've duplicated the directlighting node.

This time round it's like the “import” line is just being ignored…

Attachments:
importBug_v02.hip (182.5 KB)

User Avatar
Member
4271 posts
Joined: 7月 2005
Offline
Well well.

The code generated by the built-in VOP results in-

// Code produced by: directlighting1
directlighting(
“inF”, f,
“inOf”, { 1, 1, 1 },
“inP”, vector(),
“inI”, vector(),

vs the same asset that has been copied to a different type name.

// Code produced by: importTest1
directlighting(
“inF”, f,
“inOf”, vector(),
“inP”, vector(),
“inI”, vector(),

Notice the inOf.

What I don't get is if the asset was copied directly why it would behave differently.
if(coffees<2,round(float),float)
User Avatar
Member
13 posts
Joined: 1月 2014
Offline
Ah interesting.

So the importTest node was actually create from scratch manually. I duplicated the code, params and node details from the directlighting node. So the importTest isn't a direct copt of directlighting.

Seems I missed off that default value for inOf. ops:

Still, it doesn't seem to be complaining about it. Just that the function doesn't exist.
User Avatar
Member
4271 posts
Joined: 7月 2005
Offline
I'd also grab a newer build of Houdini if possible. It appears you are using 13.0.224, which is kinda old.
if(coffees<2,round(float),float)
User Avatar
Member
13 posts
Joined: 1月 2014
Offline
Thanks, I'll try a more recent version and see where that gets me.

Just to verify, did this actually work for you or not?
User Avatar
Member
4271 posts
Joined: 7月 2005
Offline
abvariant
Thanks, I'll try a more recent version and see where that gets me.

Just to verify, did this actually work for you or not?

Taking you scene, once I fixed the importTest VOP, so that it had a hidden Of parameter defaulted to 1, like the directlighting VOP, it then worked. No compiler errors and rendered a white sphere.
if(coffees<2,round(float),float)
User Avatar
Member
13 posts
Joined: 1月 2014
Offline
Thanks for confirming!
  • Quick Links