Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by Assault · Aug 01, 2014 at 01:02 PM · meshgeneration

How to find vertice points for "lid generation"

Hello.

I need to "cut" mesh in real-time. I have made a shader that discards all drawing above given world y-coordinate. The y-coordinate is passed to the shader as an attribute. This works fine, but of course this leaves a hole to the top of the mesh. I was thinking of generating "a lid" to the mesh hole from a script. My question is how could I find the points for the vertices? I have attached a screenshot of 2 cubes standing on one corner and marked the points for the vertices with red color. As you can see, the number of vertices depends on where the "cut plane" is located.

The lid generation should works also if I rotate the mesh. And it would be awesome if the solution would work also more complex meshes than a cube (but I'm not talking about organic/spherical objects, as that would require tons of vertices for the lid)

Alternative solutions on how to achieve this kind of behavior are welcome too. Unity doesn't have any boolean operations for mesh, but I'm pretty sure those would be very performance hungry if done on real-time.

The purpose of this is to mimic simplified liquid in a closed tank and I must be able to adjust the liquid level.

alt text

howtofindpoints.png (22.0 kB)
Comment
Add comment · Show 3
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 Assault · Aug 01, 2014 at 01:50 PM 0
Share

ChrisHP at #Unity3D gave me a very interesting and completely different solution to the problem - I should flatten all vertices in a vertex shader ins$$anonymous$$d of discarding pixels in the pixel shaders. This should be also very cheap performance wise. Im on it now, will post the solution here if it works (not really sure how to write such shader, and also a bit concerned how it will look).

avatar image Scribe · Aug 01, 2014 at 03:10 PM 0
Share

That is the method I was trying, moving the verticies is quite simple I think however I was struggling to get diffuse lighting and shadows to work. I would be interested to see what you come up with! :)

avatar image Assault · Aug 12, 2014 at 05:11 PM 0
Share

As afaik I cannot answer my own question, heres what I did: I gave up on the idea to find vertices and generating mesh. I also tried moving the vertices, but could not get the results I wanter (pretty obviously moving the top vertice in the above example would not give a slicing effect, but rather would look like the mesh is squashed). The solution was (thanks to ChrisHP again!) to add another pass to the shader that renders the backfacing polygons (dark blue areas of the above pictures) with solid color (+ ignoring lightning). This creates an illusion of a lid.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Flat shading procedural generated mesh? 1 Answer

Don't we love roads? 0 Answers

Odd shadow behaviour from generated mesh 1 Answer

Generating Normals 1 Answer

How can I generate a up facing quad mesh with variable resolution? 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