Shader help for my game
Hi guys
I recently started looking into using shaders to simulate lighting and shadows for Grave Days. I found this pretty cool package on the Unity asset store for $15:
https://www.assetstore.unity3d.com/en/#!/content/3787
I bet I would've been able to make this had I taken the time to learn shaders with the rest of you guys and saved some money, but the package looks nice, and maybe I can learn something from it now.
The issue I have with it though, is that the light from this package is fading my textures, and I believe it is a simple shader issue. This is what I expect (and get from normal Unity Lighting):
This is what the package produces (Unity lighting switched off) - ignore the tree, just look at the grass and dirt path:
The image here seems to be over-bright and faded. The light shouldn't really over-ride the colour of the textures too much, it should just make it "brighter" or darker. Don't know if I'm using the right terminology here, but I think the above pictures explain what I mean.
I had to attach this shader to my background objects (grass and dirt):
And this to my game object that acts as a light source:
I'll owe anyone who can help me out with this even a bit a Wookie life debt. Even just a point in the right direction so that maybe I can figure this out myself.
I recently started looking into using shaders to simulate lighting and shadows for Grave Days. I found this pretty cool package on the Unity asset store for $15:
https://www.assetstore.unity3d.com/en/#!/content/3787
I bet I would've been able to make this had I taken the time to learn shaders with the rest of you guys and saved some money, but the package looks nice, and maybe I can learn something from it now.
The issue I have with it though, is that the light from this package is fading my textures, and I believe it is a simple shader issue. This is what I expect (and get from normal Unity Lighting):
This is what the package produces (Unity lighting switched off) - ignore the tree, just look at the grass and dirt path:
The image here seems to be over-bright and faded. The light shouldn't really over-ride the colour of the textures too much, it should just make it "brighter" or darker. Don't know if I'm using the right terminology here, but I think the above pictures explain what I mean.
I had to attach this shader to my background objects (grass and dirt):
Shader "2DVLS/Diffuse" { Properties { _MainTex ("Base (RGB) Trans. (Alpha)", 2D) = "white" { } } Category { ZWrite On Cull Back Lighting Off SubShader { Pass { ColorMask 0 } Pass { Blend DstColor DstAlpha SetTexture [_MainTex] { combine texture } } } } Fallback "Diffuse" }
And this to my game object that acts as a light source:
Shader "2DVLS/Light" { Properties { _MainTex ("SelfIllum Color (RGB) Alpha (A)", 2D) = "white" {} } Category { Lighting Off ZWrite Off Fog { Mode Off } Blend One One BindChannels { Bind "Color", color Bind "Vertex", vertex Bind "TexCoord", texcoord } SubShader { Pass { SetTexture [_MainTex] { Combine texture * primary } } } } }
I'll owe anyone who can help me out with this even a bit a Wookie life debt. Even just a point in the right direction so that maybe I can figure this out myself.
normal_bright.jpg
700 x 500 - 389K
dull.jpg
700 x 500 - 291K
Comments
I changed the blend in the diffuse shader to
Not really sure why this worked though. I was just messing around using this: http://docs.unity3d.com/Manual/SL-Blend.html as reference.
EDIT: I managed to get it completely black by removing the blending from the lighting shader. It feels like a silly thing to do since I'm not sure why it was there in the first place, or what the intended purpose for it is. But hey, if the end result is fine, then I suppose all is good. I suppose it might be necessary for multiple lights or something.