Search Unity

Edge Detection Shadow Shader

Discussion in 'Shaders' started by jforder, Mar 31, 2014.

  1. jforder

    jforder

    Joined:
    Jun 30, 2012
    Posts:
    22
    Hello all,

    I'm a bit stuck on creating the shader I want. The effect I'm trying to achieve is an Outline shader but with shadow/lighting detail also highlighted by outlines.

    Here is an example of the effect below:

    $stencil_shader_with_lightinfo.jpg

    I've tried the Images Effects (Edge Detect) script but it doesn't give the right results, plus I've tried some of the asset store bundles but still no luck!

    Would really appreciate some help or even a point in the right direction.

    Thanks in advance!
     
  2. WhiskyJoe

    WhiskyJoe

    Joined:
    Aug 21, 2012
    Posts:
    143
    I'm not sure of this will be better than the edge detect unity provides, which should already be solid, but you can try porting this one: http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html#scene_lineDraw it might even be the same technique, I didn't check.

    The thing with image effects and shadows/lighting, is that it is likely you are going to "draw over" the existing frame buffer, disregarding any shading already done. In that case, you must calculate it in screen space, of which I am sure there will be some references to be found online if it exists.

    If you want to do it on a per object base, you will have to fiddle around with the normals of the mesh and the viewing angle. You will likely have to alter or make an outline like shader.
     
  3. jforder

    jforder

    Joined:
    Jun 30, 2012
    Posts:
    22
    Thanks for the reply! I think I'm looking to go down the shader route, just need to find out how to do it! I'll look into the normals and viewing angle and see what I get from that.

    Thanks
     
  4. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,880
    I dont remember how unity edge detection exactly works now, but i assume it uses scene normals to detect edges.
    You need edge detection with pixel color differences as far as i understand.

    Check out my aubergines post process effects, it does have several variations like sobel edge and charcoal.