Jump to content
peliosis

Illuminance Loop Question

Recommended Posts

In sig02.course16.pdf page 57 we read:

"the illuminance loop corresponding to the built-in diffuse() function.

normal Nf = normalize(faceforward(N, I));
illuminance (P, Nf, PI/2) {
Ci += Cl * (Nf . normalize(L));
}

Which is a very easy stuff.

I wrote in vex :

#include <math.h>

surface
k_pharr_mattefalloff( vector mycolor = 0.2)

{
vector Nf = normalize(frontface(N,I));
illuminance(P,Nf,PI/2)
Cf = mycolor + Cl * dot(Nf,normalize(L));
}

Which works but leaves the unlit areas (PI/2 to PI I guess) constant white!

Does illuminance loops differ between vex and rsl?

What to do to correct it not using built-in functions ofcourse?

I have similar problems with other examples from the paper (listings 3.2, 3.4, 3.7...)

I hope this is not one of my stupid errors.

Share this post


Link to post
Share on other sites

I know next to nothing about shading but some odd things occur to me in your code:

- Do you need braces around your illuminance loop contents?

- I don't see you accumulating the light colours. Do you mean to set Cf to mycolor outside the illuminance loop and then accumulate the the lighting results within?

Share this post


Link to post
Share on other sites

In help illuminance loop looks like

 illuminance(){}

, so in the shader it should look like

surface mysurface()
{
illuminance(){
}
}

but it works exactly as my example.

About the colour: In rman example there is "Cf +=" because it adds calculated Cf to default surface color (from rib?). AFAIK for light color there is "Cl" in illuminance loops in both rsl and vex.

What I'm trying to do with "Cf = mycol + Cl*(blah)" is exactly to take some colour (instead of default surface) and add light colour multiplied by dot(Nf,L).

Please explain me if this is wrong.

There has to be an error because the result is as I wrote.

Share this post


Link to post
Share on other sites

Goal of illuminance is:

loop through ALL lights and GATHER illumination...

#include <math.h>

surface
k_pharr_mattefalloff( vector mycolor = 0.2)

{
vector Nf = normalize(frontface(N,I));

//set global illumination = 0
vector lcol = 0;


//loop through all lights
illuminance(P,Nf,PI/2){
  //add illumination of current light to global illumination 
  lcol += Cl * dot(Nf,normalize(L));
  }

Cf = lcol * mycolor;
}

EDIT

illuminance(P,Nf,PI/2)

Cf = mycolor + Cl * dot(Nf,normalize(L));

}

This means:

Skip all lights except last, get illumination of last light and ???ADD??? some color.

Share this post


Link to post
Share on other sites

Help me please. In my simple example neither frontface VOP nor frontface() VEX function work with illuminance loop. Maybe it's some bug with my version of houdini...

fronFace_problem.hipc.hip

Edited by thx1138

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×