cubedparadox/Cubeds-Unity-Shaders

Flat Lit Toon Lite is not affected by Point Light

Closed this issue · 6 comments

image
(The scarf uses Flat Lit Toon, image is taken with a very low intensity Directional Light and a normal intensity Point Light)

Materials on Flat Lit Toon set to Fade will not be affected by Point Light as well-
image

Furthermore, on high-intensity Point Lights, a terrifying afterimage will appear on the center of the screen
image

I've been having a lot of similar issues lately, i've witnessed the after image, and light issues... I've tried modifying a lot of stuff to make the point light to illuminate it, which i did manage to accomplish successfully once, but it broke the transparency. Been fighting with this shader for 2 days at least, as this has been plaguing all my avatars.

The fade mode broke a lot of things, so i'd been attempting a manually written transparency with alpha blending so i can leave the mode as opaque, which worked better to a point, but not fixed.

The results are different between Unity and VRChat... When i use unmodified flat lit toon with shadow and lines off etc, set to opaque, the point light illuminates it, but as soon as set to fade, poof lighting ingame. I am getting the lighting issues with regular flat lit toon as well as lite.

A friend of mine is using this and some people have tried to kick him. We believe it's cause it hides nameplates sometimes causing people to think he's going around crashing people.

I've got the afterimage issue (or a similar issue) with my model when I was in the boats on the JP Fireworks world.

lyuma commented

I think the real bug here is the afterimage because from what I've heard, when it shows for you it also shows on the screen for everybody. A good place to test this effect is to go to Avatar testing and walk down the stairs into the pond. Some other worlds with pretty skyboxes will have this effect too like the OP shows.

So after bashing my head with this issue for a week I managed to get a version of the shader that does not have the afterimage. I probably disabled too much code but I have narrowed it down to one of the following things:

  1. the (I think) mistaken include #include "FlatLitToonCore.cginc" instead of #include "FlatLitToonCoreLite.cginc" during the second pass that I think pulls in the non-lite version.
  2. some bug during the ShadowCaster pass
  3. some bug related to UNITY_APPLY_FOG.

My money is actually on number 1 but I haven't tested just that yet. I kind of "fixed" that by mistake when trying to rename the file.

Anyway you can find a patch here and apply it yourself for testing (I made a new file named "Fixed". If you want you can delete the word Fixed everywhere in the patch and just edit the Lite shader). I might put this as a proper pull request but I feel like I deleted too much code so I want to figure out first what actually needs to go to fix the issue.

https://gist.github.com/lyuma/c9cc4570300db0205c9538284d636879

@lyuma I tested just replacing the include with the correct one and that got rid of the after image for me.

This issue is fixed in version 0.25.