Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
2
Question by allenwp · Jul 04, 2016 at 01:21 PM · shadervrtransparency

VR: Possible to render a multiple mesh/material model transparent without seeing innards?

I would like to render a model in VR. This model consists of multiple meshes, some with different materials. I would like this entire model to fade in and out without having depth sorting issues and being able to see the innards of the model.

If there was only one mesh in the model, I could use a technique like this, this, or this. But these multi-pass methods don't seem to work with multiple meshes in the model that should all fade together. (I get depth sorting issues between meshes, etc.)

If I was not in VR, I could render the model as opaque to a render texture and then apply that render texture, alpha blended, on top of the existing scene... But doing this in VR seems tricky, since I don't seem to have easy access to the two cameras. I expect this will get even more difficult with rendering changes in Unity 5.4. (Unity only seems to expose one camera object that renders both eyes.)

Any ideas on how to achieve this effect in VR?

Comment
Add comment · Show 7
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 _dns_ · Jul 04, 2016 at 03:01 PM 0
Share

Hi, some techniques to do this are close to the second link you provided: first, render all objects with a shader that will only write to the Z buffer = with a totally transparent color. Then, render the objects a second time, this time with their regular shaders. The first pass will write to the Z buffer, removing the "overdraw" effect that transparency has. The second will render the transparent colors only where there is a Z equal. I don't think it's possible to do this with a multiple pass shader in unity as the first Z pass must be done before the color pass (Z pass in geometry queue and color pass in transparent queue).

avatar image allenwp _dns_ · Dec 06, 2016 at 08:45 PM 0
Share

Hi dns. Actually, it is possible to do what you described in a multipass shader, as shown in the second link and also shown in the Unity documentation. But as I mentioned in my question, this only works for a single-mesh object. Also, if I wrote to the z-buffer without writing any colour in the opaque queue, this would simply result in the camera's clear colour showing behind where the object is, rather than blending with the world that should be behind the transparent object -- Ins$$anonymous$$d I tried your method, but writing to the z-buffer with a second renderer in the Transparent-1 queue. This resulted in transparency only being drawn where z-fighting was happening (ZTest Equal): http://imgur.com/a/prHxJ.

Good attempt, but ZTest Equal doesn't seem to cut it for this type of work.

avatar image _dns_ allenwp · Dec 06, 2016 at 09:04 PM 0
Share

I don't understand exactly what you mean by "only works for a single mesh object" ? About the shader in the Unity documentation: cool, didn't find this one :) and yes, the Z write pass is supposed to be in the transparent queue. I don't understand the z fight: is the z writing pass and color writing pass the same object ? What do you want to achieve with this image of a book/paper pile + some transparent object on it ?

Show more comments
avatar image _dns_ · Dec 06, 2016 at 11:36 PM 0
Share

(Adding a comment coz can't reply anymore) So, if I understand well, you want multiple objects that can each be transparent at the same time and with "sorted" transparency. $$anonymous$$aybe if you can cut the objects into parts small enough so that you can sort them yourself and draw them front to back using the 2 pass transparent shader you already have (so the closer to the cam would hide the transparent objects under them). But that wouldn't work with any shape and could Z fight. To sort them, it should be possible to use the SortingLayer, assigning dynamically objects to layers at each frame, but then with 2 VR cameras.... Have you tried describe the problem in the graphic/shader section of the forum ?

avatar image Garrett_orious · Jan 16, 2017 at 06:22 AM 0
Share

I'm struggling with this right now. We are in AR, so transparency sorting is our everyday hell.

I specifically have a bunch of brain chunks. I've already implemented the solution from number two, a multi pass transparency shader with depth writing, but as stated it obviously fails across multiple meshes.

I'm thinking one solution might be to render all objects with that material into a single buffer, but I'm uncertain how that might be done. Did anyone have any luck solving this problem?

Here's my example, for the record:

alt text

brain.jpg (157.3 kB)
avatar image allenwp Garrett_orious · Jan 16, 2017 at 05:26 PM 0
Share

After looking into this for a while, I believe that the correct answer is change your artwork to be a single mesh and use skinned animations so that the z-write depth pass method actually works.

...So no, I still haven't found an answer. It's seems to be a fundamentally very difficult problem that is best "solved" by changing the way that you render (modifying art to combine the entire virtual object into one mesh.)

Please post back if you find a different solution!

0 Replies

· Add your reply
  • Sort: 

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

72 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 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 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 there a way to have a transparent vertex shader recieve and cast Shadows? 0 Answers

transparent object, so everything behind it appears in grayscale 1 Answer

How to see both sides of transparrent mesh? 1 Answer

Adding Transparency to Custom Unity Shader 1 Answer

Adding transparency to vertex shader? 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