unity3d-jp / UnityChanToonShaderVer2_Project

UnityChanToonShaderVer2 Project / v.2.0.9 Release
3.82k stars 811 forks source link

Baked-lights-only optimization and vrchat light enhancement #2

Closed ACIIL closed 6 years ago

ACIIL commented 6 years ago
ACIIL commented 6 years ago

May have over bright problems in certain light intensity situations. Up to further debug

Nobuyuki-Kobayashi commented 6 years ago

Many vr-chat users already use defaultLightDirection as float3(0.0,0.1,0.1) in the scene without light object. Perhaps, your new setting will turn their characters' looks changed in such scenes. So, I want to take back your setting to default one.

Nobuyuki-Kobayashi commented 6 years ago

I think it is better for DecodeLightProbe_Cubed to be treated in _GI_Intensity, as same as DecodedLightProbe. So you can select to use or not of this effect. In this case, I wonder if your implement of DecodeLightProbe_Cubed function is affected from another Light Probes. Is it OK?

ACIIL commented 6 years ago

_GI_Intensity has been difficult for me to understand as the math does not appear to use the texture color, the results is a solid color range being added and making the model texture washed out. Can _GI_Intensity be replaced and combined into my new region for lightColor GI adding?

The defaultLightDirection can be rotated as so. I never tried to make it a shader property and anything can be done to improve the code for light direction. My edit from any() is a speed optimization as any() does appear to have the GPU cost of using if conditional checks that GPUs are not quick to do.

Nobuyuki-Kobayashi commented 6 years ago

●Your implementation of GI /DecodeLightProbe_Cubed always affects the light color now. The basic concept of UTS2 is always to be able for users to select to do or not, and so I want to change selecting it. By the way, DecodeLightProbe_Cubed uses always N as a fixed vector (0,1,0), is it derived form VR Chat's implementation? I have no information about it. Is there any way to know this implementation, if I need?

●For my concept, the implementation of default light vector is for VR Chat only. UTS2 is used in many projects now, but there is very rare case where is not any light object in the scene, and so I want not to be public the value of default light vector as one of the shader properties.

float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz + float3(0.0, 0.0000001, 0.0));

This code changes the looks of characters from UTS v.2.0.4 if there is not any light objects in VR Chat. This is efficient for GPU I understand, but these changes are the more problem for users. I worry about it.

ACIIL commented 6 years ago

Its true there are many problems with this push. I will reflect on edits and try again. Our talk here i think has helped each other in some way. When i edit these new light direction and GI light intensity values as user settings i will be ready to pull request again.

As a additional edit, i can include a fix to the "light clipping" issue what occurs when a dynamic light boundary touches the mesh, would you like me to include that edit?

It is true all my code edits are to solved a problem with unity scenes being baked lights only, which is counter intuitive as UTC works best with dynamic lights. It is true the edits connect for Vrchat use as vrchat for VR performance reasons prefers to design world in "mobile quality", or to say never guarantee a "directional light" source in the scene and instead light the world with baked lights and light probes. I have the motivation make UTC match the color of this light environment.

Correct, DecodeLightProbe_Cubed() is how the most popular vrchat shader, Cubed shader, and its derivatives for vrchat handle sampling the GI lights, they always use the static color sample in the (0, 1, 0) vector. I observe the light probe system is directional, so sending in the normal vector means anime shading may look incorrect as surfaces will light to the angle of the baked lights. I have seen other toon shaders try different ways to blend the light probes direction with smoothing equations.

Cubed shader can be found here: https://github.com/cubedparadox/Cubeds-Unity-Shaders it is maintained by one of the developers for vrchat, you might like to contact him, i occasionally find myself talking to him.