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
0
Question by FatWednesday · Oct 15, 2013 at 02:43 PM · shaderrenderingalphaspecular

Shader alpha setting being ignored?

Hey folks, got a shader problem that im not sure of the cause.

We have some items in a project that have the possibility of being alive or dead remains, for the live object we use a texture with the alpha channel for specularity (we did try to move the spec to the alpha of the normal map using the shader found here http://pastebin.com/GDHBMYDN, but for reasons that I cant work out this only seemed to supply general specular, irrespective of the map (this was tested by embedding various words into the alpha channel and looking for them in the highlights...they were not found).

Anyway the dead remains use the same texture with a shader that essentially just has a saturation and tint control. (http://pastebin.com/fvWqQx3P) The problem is, that regardless of my setting the alpha to 1 in that shader, and targeting the opaque render type, unity renders the object as semi transparent using the Alpha chanel of the main texture as an alpha map.

Would anyone be able to take a look at either of these shaders and tell me what I'm doing wrong with them? If the first one can be fixed then we'll just move the spec to the normal, But if the second can be fixed then that will probably help in the long run as its likely an issue that will arise in the future.

Any information / help is appreciated, thanks folks.

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
1
Best Answer

Answer by Owen-Reynolds · Oct 16, 2013 at 05:14 PM

For the second shader, you're telling it to use the main texture alpha:

 result.a = 1;
 return lerp(result, tex, _Saturation);

Lerp means blend, so it blends result alpha of 1 with whatever the texture has (based on Saturation. More visible texture = more alpha.) Just set alpha to 1 afterwards:

 result = lerp(result, tex, _Saturation);
 result.a=1;
 return result;

Alternatively, seem like you could just delete the line Blend SrcAlpha... and then there would be no transparency, so alpha wouldn't matter anyway.

For the first shader, ummm... does BlinnPhong even use a spec map? You might look at the builtin specMap shader to see how it works.

Comment
Add comment · Show 1 · 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 FatWednesday · Oct 16, 2013 at 05:21 PM 0
Share

Oh man how did I miss that! of course moving the lerp up like that does the job.

As for the first shader, I'm not entirely sure what the lighting function for BlinnPhong does, I guess I made the assumption that setting the value for specular would be the value that got used, unless BlinnPhong ignores the per pixel specular value that gets assigned and just does its own thing. I guess I'll just have to find some more time to dig into that one.

Thanks for the fresh eyes.

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

15 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

Related Questions

Unity Shader: Specular reflection as Alpha Value. 2 Answers

specular shader alpha not working? 0 Answers

How to: vertex colored mesh shader that doesn't break Sprite Manager. 1 Answer

Making the Specular map separate in a shader (not as alpha)? 2 Answers

How to make a specular shader fully transparent 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