- Home /
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.
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
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 :
Then place the on two quads with the the "Particles/Additive Soft" shader used on each, and you can get a result like below :
I have had another idea about how you might do something like this, will let you know if it works in a bit.
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.
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) :
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
Answer by RadioactiveTechnologies · Nov 22, 2014 at 05:38 PM
It is not possible without rewriting the rendering engine.
That's a statement that requires some explanation. I seriously doubt you know that to be true.
I know it to be true. What is the basis that you downvoted me for?
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
Follow this Question
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