Search Unity

Subdividing a mesh through Shaders

Discussion in 'Shaders' started by dann96, Apr 11, 2018.

  1. dann96

    dann96

    Joined:
    Dec 6, 2014
    Posts:
    113
    I am currently working on a water shader that has animated waves (based on a sin wave) made through the shader itself, but in order to get the motion to look fluid enough, The mesh that will be used as the water will need to have quite a bit of polygons so as not to look too rigid. Is there a way to subdivide the mesh through the shader and apply the sin wave to those subdivisions?
     
  2. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    Yes, that's what the tessellation stage is meant for.

    https://docs.unity3d.com/Manual/SL-SurfaceShaderTessellation.html
    http://catlikecoding.com/unity/tutorials/advanced-rendering/tessellation/
     
  3. einKnuffy

    einKnuffy

    Joined:
    Feb 27, 2021
    Posts:
    5
    But how would you do it with URP? Since Surface Shaders aren't supported for URP.
     
  4. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
  5. einKnuffy

    einKnuffy

    Joined:
    Feb 27, 2021
    Posts:
    5
    But how do I get that working? I copied all the code but the material would remain pink... And the hlsl file's icon is a simple texticon and not one of the shaders.
    So, if you don't mind I would love to get the code from you and a more decent explanation cause it just won't work if even after trying for days.

    And like what type of shader does it need to be?