Hey guys, I'm sure I am not the only person completely enamored with the game Kentucky Route Zero:
[ame="
http://www.youtube.com/watch?v=l5zwtIExdIM"]First 40 - Kentucky Route Zero (Gameplay) - YouTube[/ame]
I would like to ask you how you think the did the dynamic light?
I already know that they have done the environments with vertex colors, and I am asuming it is something along the same lines with the light!
It is just so sexy and I would love to find out how they did it.
Best Regards,
Replies
atten = step( atten, _LightCutoff );
Or something like that?
Although it's "forced" in some places (it quickly gets reeled right in when you get to where the dice is) so I'm thinking it's altered based on some other values too.
Could really easily just be some simple 2D planes and a bit of trickery to mask/unmask them. It's a very carefully crafted game, could be one of a whole bunch of methods.
atten = step( atten, _LightCutoff );
means, I am very new with Unity shadering
So I'm assuming you mean that it chanes the way the light behaves on the surface...?
atten = attenuation?
What does step do/mean? and the _LightCutoff would that just be a float var?
Thanks again
Basically it will make a linear curve into a stepped one; a steep drop instead of a gradual fade.
atten is the float value supplied to the lighting function within Unity's Surface Shader system. It contains the attenuation value of the current light (multiplied by the shadow value if the light casts shadows). It ranges from 1 (fully lit) to 0 (unlit).
step (x, y) returns a float that's either 1 or 0 depending on whether value x is bigger or smaller than y.
_LightCutoff would be a value you give to the shader via a property, so yeah, just a float. Combined with the step() function, anything less than this value would force the lighting to 0 (unlit) and anything above it would force the lighting to 1 (fully lit).
On closer inspection, I'm not convinced that's how they're doing it - the light's not quite binary on/off - it has a gradient to it. Could well just be a texture plane that gets masked somehow.
I actually asked the developers and just got an answer to what they have done;
"to elaborate on the custom shaders, there is no normal-based
shading. It only uses the light's attenuation to illuminate the
geometry and that's how all the faces get that flat, even lighting."
Does that make sense to you? I must say it makes a bit more sense after your explanation, but as you said they do have this gradient to them...
Thanks again!
atten = step(atten, _LightCutoff) * atten;
That would give the gradient in the centre (because it acts like regular light attenuation) but then the step gives a hard cutoff after the _LightCutoff threshold is reached.
I ended up having to change it around so it was atten = step(_LightCutoff, atten) * atten; for it not to be... inverted, but it works
Edit: SO it seems it does not display light on blacks, which is very unfortunate for the kind of game I'm making... Is it even possible to do?
This is my shader code, if it makes for any help...
You can ignore the Albedo portion in the lighting calculations. However, this will result in less saturated final colors than you might be used to (in effect you're taking the Albedo and just adding the lighting). The colorAdjust bit in the following code attempts to counter this:
As for the banding, you can do an alternate way (this will get you banding throughout the range of your lighting, instead of a smooth gradient and a hard cutoff). Depends on which effect you are looking for:
Under "Properties":
modified atten:
The whole thing:
Really thanks for taking time to explain the changes
I've just stumbled on this thread, turns out it's really useful for what I'm trying to do right now.
So I tried the shader in Unity, but I cannot seem to make it work in the right way. Right now the shader only outputs a single color, with no shadow or gradient effect.
Is this how it's meant to be? Right now for me looks like just a regular unlit shader, so I'm clearly missing something.
Unfortunately I've just started learning shaders, so I'm a bit lost here. Could you help me?
Thanks!
I've tried it, but it still looks like it's an unlit shader to me. Here's what I get on two test meshes:
Shouldn't I get at least some shadows when the light cutoff is below a threshold?
Thanks!
This works best with point and spot lights.