Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird light behaviour on Unity 2017.1 #5

Open
vncastanheira opened this issue Sep 30, 2017 · 4 comments
Open

Weird light behaviour on Unity 2017.1 #5

vncastanheira opened this issue Sep 30, 2017 · 4 comments

Comments

@vncastanheira
Copy link

First I would like to thank the creator of this shader, because it's amazing! It really gives the game a nice retro feel.

So I ran into issue where some lights stops illuminating a vertexlit material depending on the angle. I'm not sure why , as it doesn't happen with all the lights and not in all environments. Tried with default options and nothing changes.

Examples:
https://streamable.com/jdq4n
https://streamable.com/a8t3f

Any tips?

@DannN7
Copy link

DannN7 commented Sep 30, 2017

Hmm, This is not happening to me, if you have alot of lights maybe you should check the light importance from Auto to Important may fix you issue.

@oxysoft
Copy link

oxysoft commented Sep 30, 2017

This happens because there is only a fixed, hard-coded amount of lights that can be processed. Therefore, you have too many lights in the same area and they clash. I believe the vertex lighting is actually a single line in the shaders because it's using one of Unity's std shader functions for that. You can find the source for that function by searching for it on google, and then copy and paste that into your shader and modifying it to account for more lights. However beware of performance hits, there is a reason vertex lighting was quickly dismissed for better methods in the past, like deferred lighting.

@vncastanheira
Copy link
Author

vncastanheira commented Oct 1, 2017

Yeah, that's exactly it! I found the line you was talking about, it's the ShadeVertexLightsFull. The third parameter accepts the lightCount, currently set to 4 in the vertexlit shader. However, there's a loop inside that function based this lightCount and it will raise an error if set above 8 or 9. So, I'm not a shader expert, so it was probably the best to leave the function untouched and set the ``lightCount` to 7.
No problems with the performance, as it doesn't had any framedrop.

Also, the game level is a giant big mesh. Do you think that splitting this mesh into small areas and setting about 4 or 5 lights on each of them would help?

@oxysoft
Copy link

oxysoft commented Oct 1, 2017

Splitting your giant level mesh will help A LOT for all kinds of reasons, frustum culling being a big one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants