Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How can I get view Dir and light dir at screen post-processing?

Discussion in 'Shaders' started by Isaac_1993, May 24, 2020.

  1. Isaac_1993

    Isaac_1993

    Joined:
    May 1, 2020
    Posts:
    7
    I want to do some cel-shader at screen post-processing.
    Now I get the normal from the _CameraDepthNormalsTexture, it looks like correct.
    But I failed to get the LightDir and ViewDir that I need them to calculate the Specular.
    Somehow I have a voice in my brain that
    Code (ShaderLab):
    1. o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
    2. normalize(UnityWorldSpaceLightDir(i.worldPos));
    can't get the right value, but I don't know how to get the correct one.
    Could you give me any hint?