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 johnmph · Jul 28, 2017 at 01:11 AM · shadertexturemeshvertexdeformation

Simple mesh deformation : Mesh.vertices or vertex shader with displacement texture ?

Hello, I have a simple "2D grid" that I want to deform and I have implemented this by modifying vertices positions and applying them to the Mesh via Mesh.vertices and that works well.

But wouldn't be better to calculate positions and save them to a texture that a vertex shader will read to move the vertices ?

In both cases, some data must be send from the CPU to the GPU (vertices in the first case and texture in the second) so I don't know if one solution is better than the other or even if there is another better solution to do that ?

Thanks

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 bobisgod234 · Jul 28, 2017 at 02:38 AM 0
Share

Is it possible to do the "calculate positions" step in the GPU ins$$anonymous$$d of the CPU?

avatar image johnmph bobisgod234 · Jul 28, 2017 at 03:11 AM 0
Share

I don't think it's possible because deformation needs to store data for its calculation. Unless there is a way to store data in shader (it's for mobile so at least compatible with OpenGL ES 2.0) ?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by kalanadis · Jul 28, 2017 at 01:23 AM

hope this helps https://myunitynotes.wordpress.com/2014/11/11/magic-candle-deforming-object-with-unity-shader/ in this deforming data is stored in vertices.

Comment
Add comment · Show 3 · 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 johnmph · Jul 28, 2017 at 03:13 AM 0
Share

Thanks but the deformation data is not constant so I can't use this method. But $$anonymous$$esh.vertices do the job, it was just to know if using a displacement texture ins$$anonymous$$d was a better option.

avatar image kalanadis johnmph · Jul 28, 2017 at 03:50 AM 0
Share

Actually if you check the shader deformation data is not a constant.In the above shader deformation data is sent thru variables to the shader, inside the shader it uses vertex data to filter and apply the data from the script.

avatar image johnmph kalanadis · Jul 28, 2017 at 01:34 PM 0
Share

Yes but my deformation data is actually +- 1300 floats so I can't pass it as variables to the shader because there is a limit of 1024 uniforms (When I pass an array of size X with setFloatArray, it's considered as X uniforms float, in fact it's considered as X * 4 uniforms float, I don't know if it's a bug from Unity ?).

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

126 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

Related Questions

Raycast on mesh deformed by shader 0 Answers

How does appdata_base work? 0 Answers

How to set float or float4 UV in Mesh. 1 Answer

How to get a sphere surface with a solid angle through script? 1 Answer

Mesh Clipping / Cross Sections 1 Answer


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