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 MaeniAck · Nov 22, 2014 at 03:04 AM · shaderspriteshaderstransparencyglobal

Global Transparency for sprite shader

Usually when we have transparency in a shader we ensure that it shows everything behind it, thus performing correctly. But what I want is a shader that works like this: All objects that uses this specific shader share the same transparency.

Let's say I have rings that overlap that are completely white with alpha=0.5 on a black background. I would want to go from what we see to the left in the following image to what we see to the right.

alt text

Hereby I would be able to make transparent objects seem like they were a part of a great object, instead of on top of one another.

The intention is to use it together with the built in sprite shader.

Can anybody provide me with a way to achieve this?

Any suggestions would be helpful, I would like to stay away from using an extra camera and a render texture. I guess this could be achieved through a grab pass as well, but I just think there's a simpler way.

Last note: I'm currently working in the 4.6 beta, and thus would like to see the solution working for Unity Free. If you have the solution, providing what general devices the solution works for would be appreciated as well.

The built in sprite shader: http://pastebin.com/sWrugau8

Same Issue as seen here: http://gamedev.stackexchange.com/questions/73181/possible-to-create-transparency-shader-which-doesnt-stack-alpha-values

untitled-2.png (17.4 kB)
Comment
Add comment · Show 11
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 MrSoad · Nov 24, 2014 at 10:44 PM 0
Share

Hi, I don't know if your pic above is representative or not of what you actually want to do this for, if you need objects to move and merge then this idea won't work :

Have two almost identical circle images, one with a couple of small sections cut out of it, like these :

link text

Then place the on two quads with the the "Particles/Additive Soft" shader used on each, and you can get a result like below :

alt text

circles.zip (9.0 kB)
joined circles.png (15.6 kB)
avatar image MrSoad · Nov 24, 2014 at 10:50 PM 0
Share

I have had another idea about how you might do something like this, will let you know if it works in a bit.

avatar image MaeniAck · Nov 24, 2014 at 10:59 PM 0
Share

Thank you for the suggestion, but I do indeed intent for them to be moving, as well as having them animated. The first step is tho' is to figure out how to achieve the correct variation of transparency.

due to the nature of how I want to make these circles to behave, I might have 20 of these overlapping, making that area visually obscured.

avatar image MrSoad · Nov 24, 2014 at 11:23 PM 0
Share

Ok here is the other option, but again it does have limitations that may be too problematic for use. This uses the Depth $$anonymous$$ask shader setup from this link :

http://wiki.unity3d.com/index.php?title=Depth$$anonymous$$ask

And has one circle setup with the depth mask, and one without. If you have two depth mask circles overlapping then it does not work, they have to overlap none depth mask circles. Also this is setup with a circle mesh rather than a quad with a sprite, so again this may not do what you need at all... :S

Here is what the end result looks like(you can move these but must obey the rule I stated above) :

alt text

And here is a package that contains this scene for you to have a play with and keep if you want to :

https://www.dropbox.com/s/xm65705uozorqbo/Depth_Shader_Circle_Overlap.unitypackage?dl=0

On a slightly cheeky note, I did not have to rewrite the rendering engine to do this :D

depth_mask_linking_circles.png (49.0 kB)
avatar image MrSoad · Nov 24, 2014 at 11:27 PM 0
Share

Oh, just to prove they are transparent :

alt text

depth_circles_with_cube_ref.png (45.8 kB)
Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
-1

Answer by RadioactiveTechnologies · Nov 22, 2014 at 05:38 PM

It is not possible without rewriting the rendering engine.

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 flaviusxvii · Nov 22, 2014 at 06:58 PM 0
Share

That's a statement that requires some explanation. I seriously doubt you know that to be true.

avatar image RadioactiveTechnologies · Nov 23, 2014 at 04:52 AM 0
Share

I know it to be true. What is the basis that you downvoted me for?

avatar image MaeniAck · Nov 24, 2014 at 10:07 PM 0
Share

Like flavius stated, that statement requires some explanation. I guess that is why he down-voted you. Though this is technically an answer, it's not a full answer. To believe such a statement we need to see the reason, and I like flavius remain doubtful for now.

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

28 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 avatar image avatar image avatar image avatar image

Related Questions

Is it possible to have multiple stencil reference values in one shader? 0 Answers

Simplest Unlit Instanced shader - how to enable switching it on/off (with AlphaTest)? 0 Answers

Rendering transparent objects back to back (HDRP Lit shader) 0 Answers

Shader on 3D model not seen over 2D sprites 0 Answers

How to illuminate sprite's back and front face but display result of lighting only on the front face? 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