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

Custom Pixel Shader not properly showing in camera depth normals

Discussion in 'Shaders' started by Frostbite23, Dec 13, 2015.

  1. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    Hello, I created a custom pixel shader for my game. It works nicely but it does not have an ambient term to it and thats fine. To resolve the small problem I created an image effect that has a simple dot(n, float3(0,1,0) * 0.5 + 0.5 to represent the ambient lighting term. Im doing this because I want all of the objects to have a consistent ambient lighting term.

    So anyway, made the image effect but as soon as I checked the depth normals for fun, I found out that objects that were using my custom shader were only a solid color which means the normals weren't properly showing. I changed the shader and found that normals were fine once i used a unity-built-in-shader.

    Heres the image, object on the left is the object with the shader, objects on the right are objects with units legacy specular shader. For some reason my shader isn't being properly written into the depth normals.

    Screen Shot 2015-12-12 at 6.01.10 PM.png

    How can i fix this? heres the shader
    http://pastebin.com/0euUCwcp

    EDIT: I checked the mesh normals, they are fine, I wrote the render type and queue tags too. Both didn't help at all.
     
    Last edited: Dec 13, 2015