Mar
24
2015

Mesh Melt shader test

mesh_melt_shader

Quick test for melting mesh effect using vertex extrusion shader

Gif anim preview:
http://pasteboard.co/1QARh81p.gif

Forum topic: http://forum.unity3d.com/threads/has-anyone-ever-written-a-mesh-melter.311135/

Info:
– C# Script adjusts mesh vertex colors, based on the distance to heat point gameobject
– Then shader pushes(extrudes) vertices based on that vertex color (alpha)
– Would be probably better to do everything from script (to allow splitting the object, avoid intersecting faces etc..)

Instructions:
– Download sources below
– Add sphere to scene
– Add Melter.cs script to that sphere
– Create new material “meltmat” and assign it to that sphere
– Assign Custom/MeshMelt2 shader to that material
– Add empty gameobject to scene (this is the heat source)
– Assign heatsource gameobject into Melter.cs “HeatPoint” field in inspector
– Hit play, then inside scene view move heat source near to sphere to see effect

Customizations:
– Melter.cs has public bool, [x] Restore Color, this slowly restores vertex colors
– MeshMelt2.shader, see line 23 & 24 for different effects (melt in normal direction or melt downwards)
– Adjust Extrusion amount in shader material

Shader source: MeshMelt2.shader

Script source: Melter.cs

 


8 Comments + Add Comment

  • wa~sounds cool!

  • […] across a deformation shader which was easy and fun to use on a bunch of objects lying around (original inspiration). We discussed a bit about what can be done with it and what features were missing before we could […]

  • I am getting Array errors at 46 if Restore Color is enabled, and 50 if it is not.
    I have checked these lines and cannot find anything wrong with either.

    I am using Unity 5.

    • Yeah getting the same thing, any idea how to fix this?

    • Does it work if you try with default unity sphere? (works here atleast)

      • No, using a default sphere here is an image of the errors I’m getting:

        http://i.imgur.com/j8iENP8.png

        • Script updated, for some reason it didnt get the vertex colors from mesh, even though it worked before.
          (maybe I had modified the builtin sphere vertex colors during that unity session, so it had them, while in default there are no colors).

  • GAME DEVELOPER

Leave a comment

@unitycoder_com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.