Jump to content

Illuminance Loop Question


peliosis

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.

Link to comment
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?

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

  • 10 years later...

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...