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 rustyruss1985 · Jul 18, 2018 at 04:36 AM · meshpointlinesfragment

how to quickly disable vertices from rendering in a Mesh?

Hello, i am using a mesh to speed the rendering of my lines (there are over 10,000 lines), but i would also like to quickly activate and deactivate individual lines within the mesh from rendering. is there a quick way to do this, provided, the mesh indices of the specific lines are known?

right now i'm setting the transparency to 0 on the lines i don't want to render, but it is giving strange opacity effects, and i think it would be much better to directly inactivate the points.

Comment
Add comment · Show 1
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 rustyruss1985 · Jul 18, 2018 at 05:14 AM 0
Share

i think i have found a way to do this, i just set all the vertices i don't want to be on some far away location, so they don't show anymore. i guess its the same as setting their transparency to 0, but the shader i was using didn't like that approach.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Zarenityx · Jul 29, 2018 at 03:18 AM

Unfortunately, it isn't possible to remove specific vertices in a shader. There are, however, a couple things you can do:

  • Modify the mesh procedurally

  • Use Alpha Testing in a shader



The first option is the probably the best one if you are modifying these lines rather infrequently. If the indices of the line's vertices are known, you can just remove the vertices those indices refer to, and remove the indices themselves from the Mesh. If you are rendering lines, you know that there will be 2 indices for each line. Assuming the vertices aren't shared between segments, that's 2 vertices per line as well. So if you want to delete line, say, 4, you would be removing indices 6 and 7, and their corresponding vertices. If you are sharing vertices, you can just get rid of the indices (Sure, you're wasting vertices, but it's faster than going through and checking if another index references them).

If you already have a solution for changing transparency and want to stick with that, or if you are calculating what lines get shown in a compute shader and want to avoid a round-trip, you can use Alpha testing. This is a bit different from blending, as rather than blend between two pixels, you just completely kill a pixel who's alpha is too low. This is how all of the Alpha Cutoff shaders work to render grass for instance. The solution is the clip function, or its close relative, the discard statement. Clip will kill a pixel if it is given a negative value, so you can feed it your alpha minus a cutoff. If you have a lot of calculations to do, you might want to do a dynamic branch, where you use Discard on one side, and your long, complex calculations on the other. For short calculations, use Clip to avoid a branch. Then, setting your transparency to 0, assuming your cutoff is above zero, will cause your line to be clipped out.

Comment
Add comment · Show 1 · 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 rustyruss1985 · Jul 29, 2018 at 06:10 PM 0
Share

thanks for the response. right now, i think i'm using #1 (modifying the mesh procedurally), here is my code:

     bundle$$anonymous$$esh.SetVertices(newVertices);
     bundle$$anonymous$$esh.RecalculateBounds();

it works for one time only effects like changing the color map of all my vertices, but i get the feeling when i need to do more real time effects like updating the mesh every frame, this will not be feasible, so i guess i'll use the alpha testing, you think this will work on effects where i need to modify the mesh on every frame?

thanks again

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

98 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

Related Questions

how to increase thickness of points? 1 Answer

Weird Text mesh artifacts 1 Answer

Rendering Mesh Points on Mobile 0 Answers

is there any way to track the position of a certain point in the mesh of a capsule object? 1 Answer

Using CombineMesh with point topology? 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