Git Product home page Git Product logo

deform's Introduction

Header

Unity Version GitHub PRs Welcome openupm

Twitter Discord

A fully-featured deformer system for Unity. Deform is multi-threaded with the Job System, compiled with Burst and calculations are done using the Mathematics library.

Also available on the Asset Store.

Features

โšก Lightning fast!
๐Ÿงถ Fully multi-threaded!
โญ 40+ deformers!
๐Ÿ’พ Meshes can be saved!
๐Ÿ”ง Easily extendable!
๐ŸŒ Works in worldspace!
๐ŸŽจ Custom editors and handles!

FAQ

Does Deform work with the new prefab system?

Yes. Deform works seamlessly with nested prefabs and prefab variants.

Are skinned mesh renderers supported?

Yes. However because of how Unity handles skinned mesh renderers; the mesh cannot be modified after its bones are animated. This means that animations to the skinned mesh renderer are applied after Deform modifies the mesh; which is often not the desired effect. Read more here.

I'm getting an error about read/write permissions. How do I fix it?

This means you have a Deformable component on a mesh that doesn't have read/write permissions enabled. The offending Deformable component should have a "Fix It" button in the inspector that will change the import settings, but on older versions of Deform you'll have to select the offending mesh in your Project window and enable Read/Write permissions in its import settings manually.

Do deformers have to be on the object they are deforming?

No. Because deformables require deformers be added manually, they can be anywhere in the scene and on any game object.

Can deformables share deformers?

Yes. You can create a single deformer and add it to multiple deformables.

How do deformables handle instancing?

Each deformable has it's own unique mesh.

Limitations

Deform runs on the CPU. While it is incredibly fast, you should not expect to get performance comparable to vertex shaders. Because meshes are modified on the CPU each mesh has to be unique. This means that, unless dynamically batched (which comes with its own performance costs), each mesh will require a new draw call. Deform is not meant to be used at a massive scale. If you need to deform an entire world, tons of meshes, or an incredibly high poly model use vertex shaders.

tldr: Use shaders if you need speed, use Deform if you need modularity and ease-of-use.

Acknowledgments

Additional massive thanks to the following contributors for helping develop Deform into the best tool it can be:
sabresaurus, Brullworfel, favoyang, and HitCache

I love seeing creative and cool uses of this tool. If you make something you're proud of I'd be honored if you showed it to me!

You can find me on the interwebs at these addresses:
email | twitter | website
Feel free to reach out about anything!

If you like Deform, please consider donating!

Donate Donate Itch

deform's People

Contributors

brullworfel avatar favoyang avatar keenanwoodall avatar vertxxyz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deform's Issues

Decrease matrix multiplication by having deformable store mesh data in worldspace

Might have big implications I can't foresee, but almost every deformer runs in worldspace and roughly follows these steps:

  1. Transform required mesh data into worldspace
  2. Modify worldspace data
  3. Transform back to local space
  4. Apply

If every deformer is doing these transformations, we could increase perf a lot by having the Deformable transform its data into worldspace once before the deformers process it and then once more to transform back to local space after the deformers are done. That way deformers can operate on mesh data in worldspace without any overhead

Before After
image image

Better incorrect read/write import setting UX

If a mesh does not have read/write enabled it can not be modified by Deform. Right now the Deformable will show an error help box explaining what to do. As the person who has likely used Deform the most, I still forget to enable read/write on meshes. Selecting the mesh and enabling feels tedious and I'd prefer to have a "Fix it" button on the Deformable inspector that does it for me.

(If this happens to be impossible for some reason, a good middle ground would be a button that pings the mesh asset in the project to make tracking down the easier)

Jitter on deformed mesh when rolling

When using a deformer on a mesh that is rotating the deformed mesh jitters. I'm trying to apply a deformer to a rolling sphere and am seeing a lot of jittering at higher angular vels. Has anyone else seen this?

Create Point Cache Deformer

Different point cache file types should all be converted into a single custom point cache file type (probably a ScriptableObject) from a custom window. It may be easier to repurpose Keijiro's importer than to write one from scratch.

The Point Cache deformer should have controls for speed, loop mode and interpolation.

Melt Deformer still applies Noise when Factor is 0

Seems other Deformers (that I tried) follow the (useful) convention that Factor basically allows fading the Deformer in and out. Melt doesn't do that, but "jumps" on Factor 0 (Factor 0.0001 already applies full Noise).

20190708-005947

[Feature Request] Polygon/ N-gon deformer

Hello! I was thinking it would be incredible if a polygon deformer with straight edges was available. This would not be too dissimilar from the already provided star deformer. I have attached SS showing what I mean:

Screenshot 2021-06-17 at 2 02 47 PM

OBJ export is broken on locales with comma instead of dot

Steps to reproduce:

  • create Sphere object
  • add Deformable
  • press "Export OBJ" in little Deformable menu
  • note that Unity throws an import error
  • see the obj file in Windows 3D Viewer:
    image

Expected: sphere exports as sphere and is able to re-import in Unity.

Probable cause: exported OBJ is written with current Locale instead of CultureInvariant.

There's an easier way to install

Just add this to packages.json (just after the "dependencies" line):

"com.beans.deform": "https://github.com/keenanwoodall/Deform.git",

Initializing Deforms before Rendering

This is a question, not an issue (I think).
Using Deformable in a prefab. When the PF is instantiated, the original mesh is briefly rendered (single frame) before the deform is applied. For example, the CylindrifyDeformer. Is there a method of forcing the initialization the Deformable before the first rendering? For example, triggered by Awake or whatever?
Thanks
Mike

Add keyboard navigation to creator window

When typing to filter the displayed deformers in the Creator window, it would be nice to be able to press the down arrow key to select the next element in the list and up for the previous. Pressing enter would be the equivalent of clicking the selected button.

Ocean breaking wave using Twirl defromer [Help wanted]

I am trying to create a breaking wave using the Twirl deformer.

Below is the current output using the Twirl deformer:

Deform plugin

Required output:

Required output

Below are the differences between the current and the required output:

  1. Smooth blending with the ocean surface
  2. No depression below the crest

I am looking for suggestions or thoughts which can help in achieving the required output. Thank you.

Rename "Axis" to "Origin" (or something else better)

Almost all deformers have an "Axis" property that contains the transform the deformer will perform vertex calculations relative to. "Axis" is pretty terrible name as it doesn't really describe that functionality. Unfortunately this field/property is everywhere in the project and changing the name could be a pain and potentially a breaking change. Not sure if it's worth it, but I'd like to at least try the change.

Git Installation Issues : error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version

Hi! I previously commented this on a different issue but thought it deserved it's own separate issue so people can find it easier in the future.

I ran into a problem installing dependencies from git. An SSL issue can appear with a bad version of git when pulling remote from github. I was receiving an error along the lines of the one's in this thread.

Ultimately what fixed the issue for me was updating my git version from 1.9.5 to 2.21.0 and running this command:
git config --global --add http.sslVersion tlsv1.2

Hope this helps. Also thanks for your work on the project! :^)

Error opening Creator Window

We installed Deform as a package in both Unity 2019.2 and 2019.3. The Creator Window says "No deformers found." and throws an exception:

ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.
System.Reflection.Assembly.GetTypes () (at <437ba245d8404784b9fbab9b439ac908>:0)
DeformEditor.CreatorWindow+d__18.MoveNext () (at Library/PackageCache/com.beans.deform@5c7ccda4236aec3ff1e7ada04879bca945eba466/Code/Editor/CreatorWindow.cs:317)
System.Collections.Generic.EnumerableHelpers.ToArray[T] (System.Collections.Generic.IEnumerable1[T] source, System.Int32& length) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0) System.Linq.Buffer1[TElement]..ctor (System.Collections.Generic.IEnumerable1[T] source) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0) System.Linq.OrderedEnumerable1[TElement].ToArray () (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
System.Linq.Buffer1[TElement]..ctor (System.Collections.Generic.IEnumerable1[T] source) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
System.Linq.OrderedEnumerable1[TElement].ToList () (at <351e49e2a5bf4fd6beabb458ce2255f3>:0) System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable1[T] source) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
DeformEditor.CreatorWindow.UpdateDeformerAttributes () (at Library/PackageCache/com.beans.deform@5c7ccda4236aec3ff1e7ada04879bca945eba466/Code/Editor/CreatorWindow.cs:62)
DeformEditor.CreatorWindow.OnEnable () (at Library/PackageCache/com.beans.deform@5c7ccda4236aec3ff1e7ada04879bca945eba466/Code/Editor/CreatorWindow.cs:69)
UnityEditor.EditorWindow:GetWindow(String, Boolean)
DeformEditor.CreatorWindow:ShowWindow() (at Library/PackageCache/com.beans.deform@5c7ccda4236aec3ff1e7ada04879bca945eba466/Code/Editor/CreatorWindow.cs:56)

Paused Deformable's have their mesh data reset when entering play mode

You should be able to pause deformables and not have to update them again when entering play mode. This is a bit tough, because native arrays have to be disposed when changing between edit and play mode. A possible solution would be to serialize MeshData.dynamicManaged and copy that into MeshData.DynamicNative when initialized, but that would counteract any attempts at solving the mesh serialization issues (#10) and would bloat scene sizes even more.

Change Mesh On The Fly

Hello. I have a Build() process in my project where I need at one point, to change the current Mesh of the GameObject (and theire is an ElasticDeformable on it. How do I do it correctly without breaking everything ?

`
Deformable deformable = gameObject.GetComponent();

            deformable.ChangeMesh(ModelData.Mesh);
            deformable.ResetDynamicData();

`

And it work, but then I have a lot of errors: "A Native Collection has not been disposed, resulting in a memory leak. Enable Full StackTraces to get more details."

It seems to work thought, but I don't like those errors :/
My Goal is to "Reset" the ElasticDeformable, then Change the Mesh of the MeshFilter, and then "Enable" Again the ElasticDeformable. One note thought: Doing so while enabling/Disabling the ElasticDeformable Component doesn't seams to work.

Putting a Deformable in "DontDestroyOnLoad" and then loading a new scene causes the Deformers to no longer be able to make changes

Think I found a bug! ๐Ÿ›

  • Create a Deformable object and give it a Deformer
  • Call DontDestroyOnLoad(), passing in the Deformable gameObject
  • Load a scene using UnityEngine.SceneManagement.SceneManager.LoadScene() - be sure to use LoadSceneMode.Single, because this doesn't seem to be an issue when you use LoadSceneMode.Additive
  • When the scene is loaded, observe that the Deformable remains deformed, BUT making changes to the Deformer no longer updates the deformation :(

Apply Deformable to all MeshFilter Childs

Hello, I would like to know if it's currently possible. I have a prefab with +10 mesh inside.
I saw that if I create for each child's gameObjects an Deformable Components, it obviously work if I setup for each of them the same deformer.

But I wonder if we could have an option in the Deformable to say "Apply to childs" or something. I wonder if the way I do is the good way.

Also: when I'm adding a Deformer from the Creator Window, selected on a gameObject, I would like it to add itself to EVERY deformable childs.

How to move an object Transform (no mesh) ?

Hi,
I would like to transform the position + rotation of a GameObject (a camera) along with the deformation of a mesh. Is there a way to do that?

Thank you for this ++ asset!

Optimize mesh serialization

Every deformable has its dynamic mesh serialized as a unique mesh. This bloats scene file size. It's unnecessary because the dynamic mesh can be generated from the original mesh. MeshData.DynamicMesh isn't serialized, but the target (Mesh Filter or Skinned Mesh Renderer) uses it and is serialized. Somehow the targets mesh reference needs to be overridden when serialized, to point to the original mesh. Then at runtime the dynamic mesh can be generated.

Installing Problem

I use the first option to install this package to Unity.

Install via UPM
Navigate to your project's Packages folder and open the manifest.json file.
Add this line below the "dependencies": { line
"com.beans.deform": "https://github.com/keenanwoodall/Deform.git",
UPM should now install Deform and it's dependencies.
Don't want to use git? Just download and unzip the repository into the Packages folder.

When I installed this package, I took these errors:

  1. Library\PackageCache\[email protected]\Runtime\SharedStatic.cs(114,47): error CS0117: 'BurstCompilerService' does not contain a definition for 'GetOrCreateSharedMemory'
  2. Library\PackageCache\[email protected]\Runtime\BurstCompiler.cs(42,49): error CS0117: 'BurstCompilerService' does not contain a definition for 'SetCurrentExecutionMode'
  3. Library\PackageCache\[email protected]\Runtime\BurstCompiler.cs(50,83): error CS0117: 'BurstCompilerService' does not contain a definition for 'GetCurrentExecutionMode'

Does anybody help me to fix these errors?

Triplanar Shader & Deform Plugin

Hello! a video is better than words so here it is:
https://youtu.be/hxlDRrMjSiY

As you can see, the Black Noise stay visually still, while the deform plugin apply deformation to the mesh. (it appen when deforming, but if we move or rotate the object without deform, it works fine.
We are using a Trilanar Shader for the Black Noise. We are using shadergraph.

A triplanar shader works by creating three planes along each axis in object space (object space is important). Once we have those we want to render our texture on each of the planes. Then, we project those rendered images onto our object using the normal of the object to map things.

the question is : how to stick the texture to the surface while deforming the surface with the deform plugin (with a triplanar shader because whe also need to change some values dynamically)

Here the shader used:
Shader.zip

Is managed data still needed?

@keenanwoodall Since latest versions of Unity support Mesh.SetVertices, Mesh.SetNormals, etc with native arrays I was wondering if we still need to do this step?

From MeshData.cs:

// Copy the native data into the managed data for efficient transfer into the actual mesh.
DataUtils.CopyNativeDataToManagedData(dynamicManaged, DynamicNative, dataFlags);

I have tried bypassing it and doing this instead and it works fine, I think it might be more efficient since we can skip the managed overhead entirely?

if ((dataFlags & DataFlags.Vertices) != 0)
				DynamicMesh.SetVertices(DynamicNative.VertexBuffer);
			if ((dataFlags & DataFlags.Normals) != 0)
				DynamicMesh.SetNormals(DynamicNative.NormalBuffer);
			if ((dataFlags & DataFlags.Tangents) != 0)
				DynamicMesh.SetTangents(DynamicNative.TangentBuffer);
			if ((dataFlags & DataFlags.UVs) != 0)
				DynamicMesh.SetUVs(0,DynamicNative.UVBuffer);
			if ((dataFlags & DataFlags.Colors) != 0)
				DynamicMesh.SetColors(DynamicNative.ColorBuffer);
...etc...

If not then there is separate optimization I'd like to propose/implement that will be faster than MemCpy (see bottom of this page if curious: https://jacksondunstan.com/articles/4713 where CopyFromFast and CopyToFast is discussed)

Just want to get some thoughts on this in case I'm missing something, otherwise I'm thinking about stripping out the managed data stuff and submitting a pull request!

Deformables with Custom update mode still get updated by Deformable Manager

Setting a deformable's update mode to custom doesn't stop the deformable from getting updated by the deformable manager.

To Reproduce

  1. Create a deformable
  2. Set the update mode to custom
  3. Press play

Expected behavior
When the update mode is custom it shouldn't be processed by the deformable manager. The mesh shouldn't be changed unless the user does it manually through code.

  • OS: Windows 10
  • Unity: 2019.2.12
  • Deform version: 1.0.4

Scriptimporter hangs up

I tried, to use this git-repository in an external folder and import it in unity 2019.3f5 as an package. It turns out, it goes in an endless loop trying to create the settings asset:

In the Editor.log of unity it loops through that:
`
Start importing Assets/Deform/EditorResources/DeformSettings.asset using Guid(3fd6d0f0be206104d92b623fbdfdddac) Importer(-1,00000000000000000000000000000000)
Done importing asset: 'Assets/Deform/EditorResources/DeformSettings.asset' (target hash: '004dc9a8bef873adffdb5497b92c9620') in 0.005325 seconds
Import parameters got modified during import
UnityEditor.AssetDatabase:CreateAsset(Object, String)
DeformEditor.DeformEditorResources:CreateAsset(Object, String) (at ThirdParty\Deform\Code\Editor\DeformEditorResources.cs:52)
DeformEditor.DeformEditorSettings:EnsureSettingsAsset() (at ThirdParty\Deform\Code\Editor\DeformEditorSettings.cs:16)

[C:\buildslave\unity\build\Modules/AssetDatabase/Editor/V2/AssetImportManager.cpp line 332]
(Filename: ThirdParty/Deform/Code/Editor/DeformEditorResources.cs Line: 52)
`

It seems, there are hardcoded paths, in the creation, that forces the user to use it in the Assets/Deform folder and not as a package :(

unable to write to mesh

https://imgur.com/a/FLin4vP

using an fbx, it gave me errors of non writeable mesh, so i copied the mesh out, used that in the explorer, but it still wont take it, what should i do to be able to use your deform plugin in these meshes?
i tried it in the default meshes from unity and they do work

Need help making overlaying bends [Help wanted]

Hi,
I'm using multiple bends in one mesh in order to have an image like a cream flowing (think soft-serve ice cream). In order to have this imagery, I add one bend deformer to the mesh, move the deformer's transform with the bend angle set to some angle <90, and then set the angle to 180, and do the same move again in the opposite direction with another bend. My problem here is the second layer's bend also affects the first layer.

Here is an image of the problem:
image

Icon mode on Creator Window

My post is more like enhancement.
In ProBuilder, when you right-click the Tab, there is "Use Icon Mode".

A similar thing can be implemented to "Creator Window" so there will be more space?

Bend Deformers only deform certain meshes on mobile devices

I am using set of bend deformers whose angles I update in runtime to create a deformation animation sequence. It works fine in editor but on mobile devices, only certain deformable meshes are affected.

  • OS: Android / iOS
  • Unity: 2019.3b
  • Deform version: [e.g 1.0.3]

While this bug was being reproduced on android device, I checked log to find the following error being thrown repeatedly.

Cannot copy data as the managed data is invalid

While loading the scene with this deformation animation, the build also crashes sometimes.

Add bounds to Sine deformer

The sine deformer should have a limited and unlimited mode like some of the other deformers (bend, twist, twirl etc)

Create FFD/Lattice Deformer

Multiple variations of the deformer with different resolutions is fine (FFD2x2, FFD4x4 etc), but ideally there will be a single deformer that lets you change the number of control points on each axis.

Ideally you can also change the interpolation type.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.