Jump to content

lightmask


puma.snyder

Recommended Posts

Hi Achim,

Well.... it's a half-bug-half user-error thing :huh:

The good news: it's got nothing to so with the light mask :)

The general idea in an illuminance() loop is that you accumulate into some variable, and what you're feeding it is a constant (i.e: a "number"). And if we were talking VEX, then that would be the end of the story -- your code, would look something like this:

#define light 0
illuminance(....) {
   light = light + Cl;
}
Cf = light;

Don't try that at home! It makes no sense and furthermore, won't even compile.

But this is the equivalent of what you're asking VexBuilder to make sense out of, and the best it can come up with is something like:

vector light = 0;
vector sum1 = 0;
illuminance(...) {
   sum1 = light + Cl;
   sum = sum1;
}
Cf = sum;

Everytime through the loop, you're adding Cl to a constant (whose value is 0.0), so the result after the loop is simply the color of the last light that was sampled (red in this case). And VexBuilder treats "light" as though it were a constant by assigning the addition to a third variable (sum1).

But here's the "bug" part of it: you only get this problem if you have an angle wired into the illuminance vop. If you disconnect the angle input, you get the behaviour you're expecting (even though the way you're using it is still wrong). This is because we're in the wonderful and crazy land of VOPs, and VexBuilder is trying to make sense of your inputs (even when they don't), and because the "Constant" VOP is not really a constant at all, and.... well; let's say you're confusing the heck out of it ;)

So; to recap: you shouldn't be feeding it a constant as an accumulator to begin with. But, by accident, VexBuilder will work as expected even with a constant, as long as nothing else is connected (again, this is by accident -- it could have gotten confused before that). Use a variable instead. (unfortunately, in VOPs, you don't create a variable, you create a parameter -- hehe; your turn to be confused :P )

Here's the file with all three versions:

1. "bla" -- your original

2. "bla_FixedButWrong" -- should-be-broken-but-isn't

3. "bla_Fixed" -- fixed using a variable

lightmask.zip

Link to comment
Share on other sites

:D thanks a lot Mario!!

one question regarding your fixed version.

Why do you wire a constant vop into the paramter vop instead of just using the parameter vop?

And, in the help for the illuminance vop it says

If no input is specified, the light mask specified in the parameters for the object being rendered is used.

So I disconnected the lightmask parameter vop (which then allways screws up the connections inside the illuminance loop), set the objects lightmask value to red, but still all lights are used.

Is this again a user error?

Link to comment
Share on other sites

Hey Achim,

Why do you wire a constant vop into the paramter vop instead of just using the parameter vop?

Just so it doesn't show up in the parameter dialog (set to "use input if connected"...). In your original you had used a constant (i.e: non user-editable quantity), so I figured I'd keep the spirit of the original and change as little as possible. In a "real" context though, yes, I'd likely use a global (which is still a variable and not a constant).

And, in the help for the illuminance vop it says

If no input is specified, the light mask specified in the parameters for the object being rendered is used.

So  I disconnected the lightmask parameter vop (which then allways screws up the connections inside the illuminance loop), set the objects lightmask value to red, but still all lights are used.

Is this again a user error?

Nope; that'd be what we call a bug... errr... how about "misdocumentation".... OK; how about: "the help is wrong". :o

If you look at the code ("view code" from RMB menu), you'll see that what it defaults to when no input is given is actually "*" (i.e. all lights); where it really should be the empty string "" (i.e. don't override the settings in the object).....

Nope.... mmmmmnnnope..... no sir... uh-uh .... I don't use VOPs much, no.... :ph34r:(Just kidding; they *are* cool!)

Cheers!

Link to comment
Share on other sites

so if I wire a constant vop into a parameter vop, it becomes a variable, hmm   :o

Yes because you're telling it to use the input as its value. And that in itself doesn't suddenly turn it into a constant -- i.e: it's getting its value from a constant but it remains a parameter.

Hey; nobody said it had to be intuitive! :D

Cheers.

Link to comment
Share on other sites

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