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 superbsumit · Mar 22, 2013 at 12:34 PM · shaderstransparencyalpha-channel

Shader Transperency issue

Hi all,

I have a model of human leg and I want to create an opacity factor for muscles and bones, by playing with their's alpha channel. And currently I am using Transparent/VertexLit with Z shader.......

The problem occours when I try to fade off muscle(which is kept in front of bones), it then create this issue, and as per my thinking it is the shader issue.

alt text

I've tried these shaders from the forums also, but no luck till now :

http://forum.unity3d.com/threads/102785-Z-Sorting-Alpha-shader

http://forum.unity3d.com/threads/93189-Two-sided-cutout-shader-for-U3-wanted

Please help me from this issue, I'm just kinda stuck here

Thanks in advance....

EDIT : uploaded a new file for more clarification

Also image desc : 1. when there is nothing applied(normal models, one above another), 2&3 when alpha channel is reduced(along with rotation).

untitled-1-1.png (408.0 kB)
Comment
Add comment · Show 4
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 whydoidoit · Mar 22, 2013 at 12:57 PM 0
Share

I can't see your picture for some reason - can you try again?

Do your muscle/bone etc models have separate meshes/renderers?

avatar image superbsumit · Apr 01, 2013 at 01:32 PM 0
Share

Hi, sorry for very late response, but I was preparing the rest of my build.... I've uploaded the png file again.

As you can see above, the problem here is generated from shader only. Here my muscle's opacity is reduced but it affects the bone also, I can't see my bone clearly.

And yes, my muscle/bones have seperate mesh renderers.

avatar image TimBorquez · Apr 05, 2013 at 09:15 AM 0
Share

well i know the opacity of a shader can make the entire model go see-through (even the parts where the alpha is completely white)

if you have 1 shader on them both try making 1 shader for the bone with no opacity, and putting a completely different shader on the muscles and changing the opacity of that shader

avatar image superbsumit · Apr 08, 2013 at 07:02 AM 0
Share

Hi Tim,

Actually I want something like two bars, one which controls the opacity of muscles and another of bones. And if muscles opacity would be 50% , i should see the bones clearly(and vise versa)

So for achieving this, I've to add an opacity shader to bones also. Correct me if i m wrong here...? Also if there is another better way of doing this, please explain that too.......

Also I've uploaded a new png for my problem.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by mrmadprofessor · Apr 08, 2013 at 08:53 AM

This is always the issue with alpha blend sorting between objects. The issue is that you have bones in the middle and muscles around and therefor Unity doesn't know what is supposed to be in front. It can't sort in the bones inside the muscles.

A way you could do this is if you only faded one of them down at a time. So if you fade down the muscles the bones is set to a opaque shader and if you fade the bones the muscles is set to a opaque shader. This way you can only fade down one at a time but it will solve the problem.

Comment
Add comment · Show 4 · 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 superbsumit · Apr 08, 2013 at 11:04 AM 0
Share

Hi @mrmadprofessor, could you just tell me which opaque shader are you talking about here. I mean which shader should I choose to replace?

Also I don't think this will work for me. As this would be an iOS app, so two button events(both the slider bars) could takes place together.

avatar image mrmadprofessor · Apr 08, 2013 at 12:04 PM 0
Share

I would create two materials per object, one diffuse and one transparent. If the object isn't faded it would be set to the diffuse material and when the user starts fading it the material would be set to the transparent one.

Note that only one object can use their transparent material at the same time or you will end up with strange sorting. So if object1 is faded you would have to lock object2´s fading slider.

avatar image superbsumit · Apr 08, 2013 at 01:07 PM 0
Share

ok..noted!!, but if I reduces the opacity of bones first, let's say at 30%, and then when I come back to the muscle slider, the bones shader then turn to diffuse?(as per your statement), and this in turn , (Correct me if I am wrong) will cause bone as normal mesh(without any fade out effect) at that time?

And also the diffuse shader cannot be used for making an object transparent, if we wanted this to store the previous bone mesh shader values to itself(Correct me here too cuz I don't know anything about shader :( )

avatar image mrmadprofessor · Apr 08, 2013 at 01:30 PM 0
Share

Yes in this case the bones would pop to non-transparent as soon as the muscle slider is changed. Correct, the diffuse shader can't be faded since it doesn´t use alpha/transparency.

The issue you are struggling with is that unity renders two objects and one of them is wrapped around the other one so unity can't sort them the way you want. One object will always be in front or behind the other.

One way you could do this (i think) is if both the bones and muscles use the same material (and texture of course) and were asigned a vertex color shader. Then you could modify the mesh.color (vertex color) for each mesh. Then Unity would render both objects at the same time and be able to sort them together back to front.

Here is someones question about just that, be sure to use a vertex color shader if you try this since the standard transparent shader doesn't take vertex color into account:

http://answers.unity3d.com/questions/13709/changing-the-alpha-of-specific-vertexes.html

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

13 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

Related Questions

Getting transparency issue on android build 1 Answer

How would I add transparency to an outline shader? 2 Answers

Prefab's High poly mesh VS lower poly transparency cutout 2 Answers

Shader Constants - Lighting Params require Queue=Geometry? 1 Answer

How to properly set alpha transparency in PSD's to work with Unity 1 Answer


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