Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Scene Depth

Discussion in 'Scripting' started by Serejka, Dec 23, 2015.

  1. Serejka

    Serejka

    Joined:
    Oct 20, 2015
    Posts:
    6
    Hi! Have some simple questions:

    1. Is it possible to get the scene depth without any lighting and shadows in your scene?
    2. I have a specific camera with position too far from the objects, can I use a different camera instead of current to get the depth?
    3. And the last one what is the way do this on mobile?
    Thanks!
     
  2. Nigey

    Nigey

    Joined:
    Sep 29, 2013
    Posts:
    1,129
    1. Yes. Any object you add give it an unlit shader/material.
    2. Yes. Click on the camera. Look at the camera settings. You'll see an option called 'Clipping Planes'. Adjust the 'Far' to how far you want to be able to see.
    3. The same as you would with anything else. All you need to do is go to the build settings (Control + Shift 'B'), and select the platform you want. When you build, it'll be building for that platform.
     
  3. Serejka

    Serejka

    Joined:
    Oct 20, 2015
    Posts:
    6
    Hm, when I turn off my shadows

    o.zref = ComputeScreenPos(o.position);
    COMPUTE_EYEDEPTH(o.zref.z);
    half sceneZ = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(IN.zref)));
    half rim = 1 - saturate(_FoamStrength * (sceneZ - objectZ));

    But when I turn off the shadows I cant get what I want.
    w1.jpg w2.jpg
    This is a void surf(Input IN, inout SurfaceOutput o) so based on Surface. Mat is standard, what,s wrong?
     
  4. Serejka

    Serejka

    Joined:
    Oct 20, 2015
    Posts:
    6
    The same effect if I use unlit shaders..
     
  5. Nigey

    Nigey

    Joined:
    Sep 29, 2013
    Posts:
    1,129
    You need to delete all lights in the scene. You won't need them if everything is unlit and the world has no shadows. For good measure, go to Window/Lighting, and look at the first section. Set ambient color to black and ambient intensity to 0. If there's any objects that you can't see after that, they're using a shader that supports lighting and you'll need to change that.
     
  6. Serejka

    Serejka

    Joined:
    Oct 20, 2015
    Posts:
    6
    When I delete my lighting I can get the zdepth using what I wrote before.