Would anyone be able to tell me how to transform an unlit shader to lit? I am experimenting with a liquid shader that was created by some one else, but I am trying to figure out how to make it stop glowing in the dark. Would anyone be able to tell me how to do so and help me with their expertise? This is the shader I am playing around with https://pastebin.com/ppbzx7mn
Ah, a MinionsArt shader. https://www.patreon.com/posts/quick-game-art-18245226 So, adding lighting to the sides of the liquid isn't too hard. It'll take a bit to properly translate how she's calculating the top cutoff from a vertex fragment shader to a Surface Shader, which is the easiest way to add support for lighting to a shader (including support for multiple lights and shadows). The problem is the "top" surface is an illusion. Really that's just the back face of the mesh with a solid color. If you add shadows and lighting to that, it'll very clearly not be a top surface. To handle everything correctly you have to override the normal to be facing "up", which is possible though non-trivial to do with Surface Shaders, and override the per pixel depth ... which is not possible with a Surface Shader. To do that means hand writing several custom passes that do some (minimal) in shader raytracing to compute the surface depth of that not-actually there top surface.
Hmm... dang... Is it possible to go around it in another way perhaps? Like... less ambient light = more black tint? Something like that would be possible? Because that could also solve it in a way
If you don't need shadow receiving or multiple lights, you can look at the vertex fragment shader examples which have some basic lit shader examples: https://docs.unity3d.com/Manual/SL-VertexFragmentShaderExamples.html The main trick will be doing that backface check to change the world space normal used to something like float3(0,1,0). It won't be quite right if you're doing the wobble, but you can probably get something usable with normalize(float3(_WobbleX, 1, _WobbleZ)). It won't be correct, but it'll at least change as the surface wobbles.
Where would I insert this? Tbh I am a code dunce and wouldn't even know how to implement what you just explained.
Well no matter where I tried to plug it in the code it always ended up breaking the code except one spot, it didn't seem to do anything sadly