A few words about setcurrentlight (int lightID)

   2718   4   1
User Avatar
Member
71 posts
Joined: June 2008
Offline
Hi,
I have recently looked through included libraries and I have found undocumented function. Its name is “setcurrentlight”. I think that it's vex (build-in) function. Perhaps, can you tell me a few words about setcurrentlight? I would like to know a little bit more about it.
Alexey Mazurenko
User Avatar
Member
71 posts
Joined: June 2008
Offline
Hi,
I have written some code to show my surprise:

int nsamples = 1;
int isarealight = 0;
lights = getlights();
nlights = arraylength(lights);
for (ilight = 0; ilight < nlights; ++ilight) {
if (setcurrentlight(lights)){
renderstate(“light:arealight”, isarealight);
if (isarealight){
renderstate(“light:maxraysamples”, nsamples);
nsamples = max(1, nsamples);
}
}
}

You can see that I'm sending a query for the value of “light:arealight” and then for the value of “light:maxraysamples”, but “renderstate” can't process the data correct for custom loop without using “setcurrentlight”. Perhaps, the query of light properties is correct for illuminance loops only.
Alexey Mazurenko
User Avatar
Member
8567 posts
Joined: July 2007
Offline
so it seems that setcurrentlight() sets kind of global variable “light” to be the light passed to it
because queries like light:arealight and so on, have no clue about what “light” you have in mind unless you set it first
or unless you are in illuminance loop which sets it for you

but this is my understanding from what i see in the code, i have no experience with it
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
71 posts
Joined: June 2008
Offline
Hello Tomas,
I think that you are right.
The common problem which I would like to understand that there is difference between the illuminance loop and a custom loop through getlights() and there is a lot of questions for me in this problem.
For example, how well do shading components work together if they have different ways of calculation of light (illuminance loop and getlights) or how well do work light masks or light categories for those components?
What are the advantages or disadvantages of these methods. For example, the illuminance loops are always computed at time = $Time, but the custom loop can computed at any time.
Alexey Mazurenko
User Avatar
Member
71 posts
Joined: June 2008
Offline
Hello,
I think that I have received answers to most of my questions and I'm a little bit disappointed
I have created a file where I have presented two models (the illuminance loop and the custom loop through getlights()). You can look at them.
The Common conclusions:
1) Usually the custom loop used for high quality sampling of area lights.
2) If you use only one sample (a parameter “Sampling Quality” should be set 0 in my shader) than the quality of shading will be similar to illuminance loop.
3) Since function calls such as shadow_light and sample_light requires an argument “time”to send the ray at, then you can set any fraction of time.
I hoped that this will affect the speed of calculation of motion blur for trace engine. Unfortunately there is not! The speed of calculation has not changed. But this affects the quality of ray-traced shadows (no motion blur in ray-traced shadow). If you need the motion blur in ray-traced shadow, you should set “Use Shading Time” to enable (for my shader of course).
It's all conclusions. In any case the illuminance loop will be faster than custom loop (just a little bit).

If developers or users can add something to my words, I will be glad to read this.

Attachments:
models.hipnc (260.1 KB)

Alexey Mazurenko
  • Quick Links