[Final] Deformation Shader (Update – new deform, multi-deforms against single axis)

Home Forum Development User Code & Projects [Final] Deformation Shader (Update – new deform, multi-deforms against single axis)

This topic contains 24 replies, has 8 voices, and was last updated by  t0neg0d 2 years, 2 months ago.

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
  • #24253


    EDIT: I replaced this with the GPUAnimationFactory shader (far more useful, as it does texture animations as well), which can be found here:


    Here is the final mesh deformation shader coupled with JME’s lighting fragment shader.

    Ripple, Wave, Swell, Pulse, Warble

    Speed, Size, Depth, Direction, Polar Mirror, Rotation, Offset1 & 2

    New features:
    * You can now compound deforms against a single axis… for instance: ripple, wave & warble all against the Y axis
    * You can set the rotation of the wave deform
    * You can set the origin of the ripple deform

    * When using deformations against a Y-axis plane (for example), mixing some x-axis, z-axis deformation can have undesired effects in the normals recalculation. I could have set a param for defining use with planes and the axis the plane is on, but some of the “undesired” effects can be quite cool, so I left it well enough alone.
    * Using polar mirroring on a flat plane will produce “undesired” effect with normals recalculation. Reason being, it is impossible to mirror an effect on a flat surface. Go figure… ;)
    * Using mirroring on spheres with a high depth setting will create flipped face at the horizon line. This is not an error… it is simply the results of deforming vertices that close to the horizon line. This produces cool effects when back-face culling is turned off.
    * FIXED – Using offsets to place the ripple origin does not work properly with normals recalculation atm. – FIXED

    New sample vid:

    Anyways, here is a sample video of some of the effects.

    Updated the j3md & vert files below. Feel free to use it as is as the usage will not be changed, only added to.


    Normen Hansen

    Great job :)



    Here is the j3md:



    Here is the .vert



    Thank you very much. This will definitely be useful :)



    @t0neg0d , you are cool!!!! Really nice!

    Can you provide a simple examples? I’ll add you shader to the shader library.



    @mifth I sure can. I’ll also finally post the GPU version of the other shader for moving textures as well. I think I’m going to revisit this current one and break it into separate shaders for each deformation so I can extend them easier.

    The ripple effect… it should be able to clamp the origin to any side or corner (well virtual corner on 3d meshes)..

    You should be able to do the same for the wave effect, or have it originate from the center (heh… and I spent so much time trying to figure out how to NOT have it centered). Also, you should be able to adjust X, Z frequencies separately to (or randomize them) to create a more natural effect.

    Speaking of that, you should be able to set a global tolerance for randomization and enable/disable it to produce slight variances on every effect.

    The pulse and swell effects are not taking size into account atm either. You should be able to divide the effect across the mesh to double, triple, etc, etc the swell or pulse.

    And once they are all extended to a more usable form for animations, I’ll recompile them back into a single shader for animating.

    The reason I am going to do this (and this is only a for-instance)… using the ripple effect to animate the top portion of a jellyfish requires a center clamp… however, the tentacles… or a snake for that matter… would require a side clamp. Hair blowing in the wind would require a corner clamp.

    Once all of this is completed (which shouldn’t take very long… a week maybe), producing realistic mesh animations just using the shader should be completely possible.



    ok, man! I’ll be waiting. )



    This is really a great work.
    Kudos @t0neg0d



    @mifth Sorry for the delay, however, it will be worth while! I’m adding a new deform (warble). But, more importantly, I’m adding the ability to compound multiple deforms against a single axis. Oh… and the ability to set the rotation on wave and the anchor point on ripple.

    Multiple transforms against a single axis works like this:

    mat.setBoolean(“DeformX_Wave”, true);
    mat.setBoolean(“DeformX_Ripple”, true);
    mat.setBoolean(“DeformX_Warble”, true);

    This would have the effect of (not actually producing separate meshs… just how the transforms are compounded)
    mesh + wave = deformedmesh1
    deformedmesh1 + ripple = deformedmesh2
    deformedmesh2 + warble = finaldeform

    If you modify the order, you get varying results. This makes for some absolutely AWESOME water chop deformation. And if you use different compounds for different axis’ on a 3d model… it is just trippy what you can do with it.

    Oh… I also noticed a few bugs in what I posted here (not recalcing the normals for anything other than ripple and wave… etc).

    Anyways… won’t be long now.


    Wesley Shillingford

    very nice! thx for this



    No problem man! you are making good stuff. This defenetely will be used by JME Community.



    Updated topic with new features & vid.
    Updated j3md & vert.

    One last issue to resolve with one of the new features and then I’ll upload a sample project.



    @mifth Ok… this one is ready to go as well. Being able to commit the source myself probably isn’t a bad idea, as it will save you time… plus, I was thinking about extending JME’s lighting.frag with texture deforms as well, so I probably will have more useful stuff soonish. I think it would be cool to be able to apply both mesh and texture deforms to create more realistic liquid effects.

    I can create versions that extend the lighting shaders you have in the repository. Those are seriously cool.

    Anyways, let me know.



    Really nice work there @t0neg0d I like!

    Got a Q for you though.

    I was thinking of doing something similar for my game but with a twist….

    Here’s the thing:
    What I’d like to have is a deformed sphere based on certain points surrounding an origin point. But, and here’s the twist, once that’s set, I want it to remain static; unmoving, until there’s a change. When (if) that happens then a new deformed sphere should be used.

    I intend to use this as a frontier delimiter for each race at their home world at location of X/Y/Z. By using that race’s home world as an origin and feeding it the farthest points to it, I should be able to deform a sphere enough so it includes each system inside it.

    It’s really late here and I haven’t checked the code, only the videos, but how hard do you think it would be to modify the above .vert/.frag to accommodate for this kind of thing?

    Thanks. :)

Viewing 15 posts - 1 through 15 (of 25 total)

You must be logged in to reply to this topic.