|
Hey, I'm trying to have the Toon Lighted Shader increase/decrease the size of the ramp depending on the main light's intensity. Any ideas how I'd go about this? I'm considering changing the line below to multiply by something, but I'm not sure what. ^ This line because when I mess with the 0.5 numbers, it increases/decreases the ramp size.
(comments are locked)
|
|
You're on the right track. If you know what the old code was doing, makes it easier to modify. The code above looks up a 0-1 ramp value from the White/Black Ramp texture. You're allowed to not look it up, and instead just compute the ramp. In the old code, these two lines compute ramp: The dot-product of your normal and the lightDir computes the percent of light you should get: 1 if you are facing, 0.7 for 45 degree angled away, 0 for an edge, and -1 for facing away. The range is -1 to 1. It's a really common value in lighting math. Texture lookups think 0 is the left side and 1 is the right. So, DP*0.5+0.5 scales the -1 to 1 dot-prod into a 0-1 for the lookup. Since we aren't doing a texture lookup, we can ignore that. In math, a ramp looks like this (imagine low is black and high is white, so this represents black on the left, a short ramp to white, then white on the right): Assume we have the raw -1 to 1: For CENTER, 0 means the lightwise edge, positive (up to one) brings it towards the light, negative (down to -1) brings it to the unlit side. Interesting numbers for SPEED are 1 (very wide) to huge. Of course, anything more than about 20 will be almost an instant change between colors. The 0.5 makes CENTER be the center (without it, CENTER is the left edge, and changing SPEED makes it grow to the right. With the 0.5, changing SPEED grows both ways.) For example, Okay, that helps a bit. I'm guessing I'd do something like: Now the problem is what to multiply it by. Any ideas?
Jan 22 '12 at 10:09 PM
Xatoku
Not that exactly -- that's just DOT*0.8*light. The trick is to compute a new value for the ramp variable, using dot(...) times something and plus something. Times grows/shrinks it, plus shifts it. As to get the light intensity? There isn't nomrally such a thing. You'd have to set up zones (like in the smokey tavern, it's 1/2.)
Jan 23 '12 at 06:48 AM
Owen Reynolds
How about the colour of the light? Would that be more conventional?
Jan 23 '12 at 12:25 PM
Xatoku
When you wrote "main light" I assumed you meant the one direction light. It's always got the same stats everywhere. It you want to check the closest point light...seems doable, but not my area. The other thing you could do is simply make different ramp textures. One is for most everywhere. A few triggerboxes (the boss zone?) swap the texture in/out when you enter/leave.
Jan 23 '12 at 05:44 PM
Owen Reynolds
Hah, again I overlook the simplest solution. That will more than suffice, and thanks for the information none the less!
Jan 23 '12 at 05:54 PM
Xatoku
(comments are locked)
|
