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
0
Question by unity_20hy8tc1LSZG4Q · Jun 11, 2019 at 08:49 PM · renderingtransparencycolors

How to render certain colors of GameObject as transparent?

I have a 3D mesh in .fbx format that I've already pre-segmented into 3 colors. For example, the parts of the mesh are already colored (using vertex RGB colors) as red, blue, or green. I'd like the user to be able to 'turn off' the rendering of the blue parts of the GameObject once they're done interacting with it, but still be able to see the red and green parts.

How can I accomplish this?,I have an imported 3D mesh in .fbx format. In this mesh, I've already pre-segmented it into 3 different colors (vertex RGB). Certain parts are highlighted in red, green, or blue. I'd like to be able to see all of the colors until the user is done interacting with the mesh. Once they're done, they should be able to turn off the blue part of the mesh.

How can I accomplish this?

Comment
Add comment · Show 2
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 Cornelis-de-Jager · Jun 11, 2019 at 09:47 PM 0
Share

Checkout the post below for creating custom shaders where one colour is transparent:

https://answers.unity.com/questions/1041383/set-one-color-transparent-in-texture-shader.html

avatar image Owen-Reynolds · Jun 12, 2019 at 07:03 PM -1
Share

It might be simpler to break it into a submesh for each color. Or else create 7 textures, with each combination of active colors (which also enables you to draw a nice "this part is finished" image for each). You could even modify the texture in code: newTexture=removeColorFrom(oldTexture, color).

Unless this is a project to learn shader-writing.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Pangamini · Jun 12, 2019 at 01:17 PM

Write a shader that reads the vertex colors and clip pixels that match your filtering condition (eg. clip(IN.color.r - 0.5) will discard any pixel whose interpolated vertex color is less than 0.5) You could even have those pixels fade out, but that'd mean you have to render your object as trasnaprent, which has other disadvantages

Comment
Add comment · Show 5 · 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 unity_20hy8tc1LSZG4Q · Jun 12, 2019 at 02:56 PM 0
Share

Thanks for your response, I appreciate it.

I've already written a shader that reads the vertex colors. You can see it here.

https://gist.github.com/$$anonymous$$ichaelZhou/c3056f5efed0129171fc4e84770062e7

Could you help me by elaborating more on how to code the filtering condition? For example, if I have an .fbx file with RGB vertex colors, how do I deter$$anonymous$$e the individual interpolated vertex colors?

Thanks again

avatar image Pangamini unity_20hy8tc1LSZG4Q · Jun 12, 2019 at 02:59 PM 1
Share

This is your fragment

 void surf(Input IN, inout SurfaceOutput o) {
             o.Albedo = IN.vertColor.rgb;
         }

fragment input is already the interpolated data from verts. So just do what i wrote above clip(IN.vertColor.r - 0.5)

avatar image unity_20hy8tc1LSZG4Q Pangamini · Jun 12, 2019 at 03:38 PM 0
Share

The part that I'm having trouble understanding is what having an interpolated vertex color less than 0.5 actually means. For example, what colors would have an interpolated vertex color less than 0.5? Is there a way to deter$$anonymous$$e a color's interpolated vertex color?

What if had a partially uncolored .fbx mesh and wanted to discard only the uncolored portions?

Cheers

Show more comments

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

128 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 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

Help understanding transparency in Deferred Rendering? 0 Answers

Transparency Sort Axis on Y with Pivot instead of Center of object? 1 Answer

Fading in/out SVGs without showing the half-transparent SVG-layers 1 Answer

DrawProcedural() in OnPostRender() drawing over transparent objects 1 Answer

Standard shader's Fade rendering mode won't allow full opacity with a textured material 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