- Home /
Adding normal map to Sprite shader
Hello, I would really like to add a normal map to the Default Sprite shader. Right now i'm using the Default Diffuse Sprite shader, with point lighting. It looks nice, but not nearly as nice as this:
Which is accomplished using a normalmap on a sprite. My question is how to implement normalmapping into the Default Diffuse Sprite shader. I've searched for a finished shader asset on the asset store but to no avail. Is this a very difficult thing to do? I have no prior experience in shaderLab or with creating shaders.
Thanks
Answer by KellyThomas · Aug 03, 2014 at 12:25 PM
I suggest having a read of Writing a SpriteLamp Shader in Unity.
Edit:
First of all a small disclaimer, I have no prior experience using thisshader. I skimmed over the blog when it was posted on reddit a while back but that is all.
Today I dropped it into unity (windows) and it was throwing a few incorrect number of arguments to numeric-type constructor
errors. I was able to fix them by modifying line 72.
old:
output.uv = float2(input.uv);
new:
output.uv = input.uv;
At that point it all seems to work as expected.
I borrowed a few textures from here and created this test scene:
While these textures produce an output that is pretty ugly, it responds correctly when I move the light source and seems to be working as advertised.
I read through that article, in the end, there's a download link for the shader (exactly what I was looking for). However, when I applied the shader to a material, it only becomes purple, and it says "$$anonymous$$aterial does not have a $$anonymous$$ainTex texture property. It is required for SpriteRenderer." I've checked, there is a texture property called "$$anonymous$$ainTex" in the shader. Could you please have a look at this and give me your two cents?
Thanks!
@$$anonymous$$annek I've added some more details above.
Hmm, tried to change line 72, but it didn't help. I've attached the unity project file. Could you take a look?
https://dl.dropboxusercontent.com/u/23965156/New%20Unity%20Project%202.rar