Search Unity

Question What is the best way to edit shadows and create a "watercolor" effect on them?

Discussion in 'Shaders' started by Albertomelladoc, May 25, 2020.

  1. Albertomelladoc

    Albertomelladoc

    Joined:
    Aug 1, 2017
    Posts:
    12
    Hi!

    I have been trying to replicate the effects done by the shadows in this sketchfab scene.



    As you can see the shadows seem to have a hand painted effect. I want to achieve this effect with a shader but I am not 100% sure on what would be the best approach.

    1. Soft Shadows
    I have tried realtime soft shadows with a custom lighting function. I used the shadow intensity as an indicator of where the edges of the shadows are and applied a noise to them to create a "watercolor" effect there. But it's quite difficult to work with it since soft shadows seem to be quite limited and not really reliable.

    2. Lightmaps
    The other approach I can think of is using baked lighting and creating that "watercolor" effect over the lightmap texture. But I am kind off clueless on how to achieve the effect. I tried to recreate this effect https://www.deviantart.com/namito111/art/Blender-Watercolor-Effect-499610440 on my shader. But I have not been able to make it work. Also I am not sure if using a gaussian blur over a lightmap is a good idea since I would have to sample it multiple times with different uvs and maybe this is not efficient ¿? I have never worked with lightmaps so I have no idea. I would also rather not work with baked lighting since I would like to have dynamic character shadows, but I will If I have to.

    3. Grabpass
    I also found this effect https://forum.unity.com/threads/watercolour-shadow-shader-effect.379102/ which is similar to what I want to achieve. It uses a GrabPass, but I am not sure on how should I work with it to detect the shadows. Maybe I am not understanding correctly how the effect works. What I think he does is render the lighting info. Grab it with the pass and use it as a texture where he applies the distortion. ¿?

    Hope someone can shed some light to me in this shadowy problem. (Pun intended)
     
  2. FlyingOreos

    FlyingOreos

    Joined:
    Mar 24, 2014
    Posts:
    12
    Well, when you read the light attenuation when receiving shadows in the fragment shader, this is your opportunity to use the atten value as you see fit.
    For example, some would create simple toon shadows by stepping or smoothstepping the atten value. Maybe there are other operations you could do that would get you closer to your visual target?
    Maybe a combination of soft shadows, and a noise texture for the values that are above 0, but below a certain threshold?
     
  3. Albertomelladoc

    Albertomelladoc

    Joined:
    Aug 1, 2017
    Posts:
    12
    Hi Flying Oreos!

    I have tried using the attenuation and creating effects with it. It's what I explained on my first option. I have tried using soft shadows but they generate a lot of artifacts since I have to lower the shadow quality in order to have a neat gradient to work with. Here you can check it -> https://gyazo.com/eb168e2b2947ad7eb963c5ca67e46521

    Thanks for your answer