Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by alexanderflink · Aug 02, 2014 at 12:18 PM · 2dshaderspriteshaderlabnormalmap

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: alt text

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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: alt text

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.


coin.png (56.9 kB)
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image alexanderflink · Aug 03, 2014 at 01:08 PM 0
Share

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!

avatar image KellyThomas · Aug 03, 2014 at 03:37 PM 0
Share

@$$anonymous$$annek I've added some more details above.

avatar image alexanderflink · Aug 03, 2014 at 06:17 PM 0
Share

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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Getting horizontal gradient in unlit sprite shader even sprite is rotated 0 Answers

Sprite cropping 3 Answers

Apply overlay effect in an area just on specific objects (2D underwater) 0 Answers

How to fix this kind of shader error? 0 Answers

Custom shader of sprite results in black alpha. 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges