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 rayvonsmith38 · Aug 02, 2018 at 05:30 PM · charactervisibilityuntiy3dclothing

adding multiple clothes to character,equipting multiple clothes to character problems

Hi, i am trying to add multiple clothes to my character in unity 2018.2.1f1 which works kinda ok, the problem is that the clothes underneath continuously stick through the one on top. for example i add a bra then i add a blouse, the frills from the bra keeps sticking through the blouse. if i add a pants then add a skirt over the pants, parts of the pants keeps sticking through the skirt. can anyone tell me how to fix this problem please. i'm using the clothes as prefabs. thank you in dvance,hi, I am trying to add multiple pieces of clothes to the character in unity 2018.2.1f1, the clothes actually goes onto the character but keeps sticking through each other. for example if the character has on a bra and i add a blouse, the frills from the bra sticks through the blouse. Also if i add for example a pants under a skirt, parts of the pants bulges through the skirt. can someone please assist me with a fix for this? im using the clothes as prefabs.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Zarenityx · Aug 02, 2018 at 08:16 PM

You can do this using the Stencil Buffer. It's a bit like the depth buffer, only you can write custom values and make custom tests to it.

First, Disclaimers:
This requires a separate shader, but you'll probably want that for fabric anyway (the standard shader doesn't do a great job on cloth). This also requires that you have some way to guarantee the order of clothing. A slotting system is good for this, as you can simply say that the undergarments slot is always under the pants slot, which is always under the shirt slot, which is always under the armor slot, which is always under the jacket slot, etc. Additionally, if you are using the Legacy Deferred, Legacy Light Prepass ('Legacy legacy deferred') or HDRP render pipelines, there are some reserved stencil buffer bits. You can get around this with Camera.clearStencilAfterLightingPass. If you are using the Legacy Forward, LWRP or a custom SRP that doesn't utilize stencil, you need not be concerned with this. This technique also won't work for transparent clothing, as you will just see through your entire character.

The Technique:
You'll also need to reserve a stencil value for this purpose. What you use is up to you, so I'll just call it X. Your fabric shader should include this snippet:

 Ref X
 Comp NotEqual
 Pass Replace

This tells the shader:
---Using the value X,
---Check if the current value is not equal. If it isn't equal, render, otherwise, fail.
---If the stencil check passes, replace the value with X, therefore causing future checks to fail

Next, you will need to use Material.renderQueue to set the order in which the materials get rendered. Outer layers should get rendered first, then inner layers. This is where a slotting system comes in handy. Now, if you have a blouse, it gets rendered first, and sets a flag on the stencil buffer that says 'don't render what's underneath'. When the bra gets rendered, any pixels that the bra rendered to first won't get rendered, regardless of depth.


Reasons why this is a good option:
This has an added advantage: Stencil buffers always get checked before shading, and won't render if they fail. This saves expensive per-pixel calculations on anything that's obscured. By contrast, the usual depth buffer is sometimes checked after the fragment shader (depending on renderer and hardware), so sometimes these computations can occur for unseen pixels. As such, using this technique all over your character can help speed up rendering. Stencil buffer checks on skin, hair, props, accessories, items, etc. can all be used to make highly customizable and performant characters.

Comment
Add comment · 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

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

123 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

Related Questions

How to add different clothes to rigged character 1 Answer

Changing my character's clothes and environment in 2D 1 Answer

Animate Clothing Meshes With Mecanim? 1 Answer

How to fix character mesh going through clothes? 1 Answer

Can I import clothing attached to a character that has already been imported into Unity? 2 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