Light export

   4795   9   0
User Avatar
Member
282 posts
Joined: Jan. 2006
Offline
Hi! I try to export individual lights contribution to separate passes. I set the name of the light to the light export field and set vex variable to Cf. But all the lights are rendered. I'm trying to export Cl instead of Cf but got a black square.
Houdini is great! O'right?
User Avatar
Member
12467 posts
Joined: July 2005
Offline
Hi Wish,

I'm afraid that any of the standard shipped shaders, or any you create yourself in VOPS or VEX with the shipped diffuse(), specular(), etc functions are NOT written with any capability to export values per light. What it takes is for you to write your own illumination functions using the illuminance() construct- so unfortunately it's not really for the general user or faint-of-heart but rather for shader-writers and such.

It's a little unfortunate that the standard illumination functions and shaders don't sport a default configuration to make it work out of the box for new users, but if you're still curious then process is not too terribly difficult for an enthusiast; and can be a real benefit for for any production if you have the resources to do it for yourself.
Jason Iversen, Technology Supervisor & FX Pipeline/R+D Lead @ Weta FX
also, http://www.odforce.net [www.odforce.net]
User Avatar
Member
282 posts
Joined: Jan. 2006
Offline
Hi, Jason. Thanks for the reply. It's not a problem for me to rewrite illuminance loops.
Houdini is great! O'right?
User Avatar
Member
282 posts
Joined: Jan. 2006
Offline
Ok. I modified my diffuse but the result is the same black. Everything is ok without light export. But it renders the black square with light export
Houdini is great! O'right?
User Avatar
Staff
2591 posts
Joined: July 2005
Offline
Wish
Ok. I modified my diffuse but the result is the same black. Everything is ok without light export. But it renders the black square with light export

Try the attached. You probably need to ensure that the export variable is assigned within the illuminance loop, right?

Attachments:
lexport.tgz (24.9 KB)

User Avatar
Member
35 posts
Joined: July 2005
Offline
Hi Mark.
Your example works perfect. But what should i do if i want to do the same thing using VEX builder?
For example i have my custom vop operator for diffuse calculations. I use Outer Code section to define subroutine that contains illuminance loop, and i use Inner Code section where i call my subroutine.
You said that export variable must be assigned inside illuminance loop. Can i declare some variable as exported in shader parameter list and assign its value not inside main code block but inside some subroutine?
User Avatar
Staff
2591 posts
Joined: July 2005
Offline
sanchez79
Hi Mark.
Your example works perfect. But what should i do if i want to do the same thing using VEX builder?
For example i have my custom vop operator for diffuse calculations. I use Outer Code section to define subroutine that contains illuminance loop, and i use Inner Code section where i call my subroutine.
You said that export variable must be assigned inside illuminance loop. Can i declare some variable as exported in shader parameter list and assign its value not inside main code block but inside some subroutine?

My quick experiments show that this works.

By declaring the parameter in the illuminance construct and turning on the “Use This Node To Set Parameter Attributes”, then you should be able to pipe values into the input of the parameter definition in the illuminance loop.

You can inspect the VEX code to ensure that this happens for you. If you really need an example, let me know :-)
User Avatar
Member
35 posts
Joined: July 2005
Offline
Yep. It woks when i use illuminance loop VOP.
I mean another case.
There is simplified version of my code


void do_diffuse(vector Nn; vector diffuse, cl, shd)
{
cl = {0,0,0};
vector clr = {1,1,1};
shd = {1,1,1};

illuminance(P,Nn,PI/2,LIGHT_DIFFUSE) {
clr = Cl * dot(Nn,normalize(L));
cl += clr;
shadow(shd);
}
diffuse = cl * shd;
}

surface
mysurface(export vector clr = { 0, 0, 0 })
{
vector diff;
vector light;
vector shad;

vector nn = (0 != 0) ? { 0, 0, 0 } : normalize(N);
do_diffuse(nn,diff,light,shad);
Cf = diff;
}


I expect to get value of clr variable for different lights.
But it doesn`t work.
User Avatar
Staff
2591 posts
Joined: July 2005
Offline
sanchez79
Yep. It woks when i use illuminance loop VOP.
I mean another case.
There is simplified version of my code


I expect to get value of clr variable for different lights.
But it doesn`t work.

You're writing to a local variable in do_diffuse(), parameters in VEX
are passed by reference, so the following should work…


void do_diffuse(vector Nn; vector diffuse, cl, shd, clr) {


surface
mysurface(export vector clr = { 0, 0, 0 })

do_diffuse(nn,diff,light,shad, clr);

if you remove the local definition of clr. Hope this makes sense.

P.S. The stuff should obviously be stripped out of the actual code :-)
User Avatar
Member
35 posts
Joined: July 2005
Offline
Eah!
It works.
Thank you Mark.
  • Quick Links