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. Dismiss Notice

Some help with Shaders for Unity AR project

Discussion in 'General Discussion' started by cre8or, Jan 26, 2016.

  1. cre8or

    cre8or

    Joined:
    Nov 6, 2015
    Posts:
    3
    Hello All,
    I'm not sure where to post my question, so please forgive me if this is not the place.

    I am a graphic designer, with very little programming knowledge (but a desire to learn). I have created AR scenarios before using a product called Metaio Creator, which was purchased by Apple and is no longer available. I am now using Unity and an asset called Vuforia.

    What I want to do is:
    Create an augmentation which involves an.FBX model with a human and a monster. when the trigger image is detected, the human will walk into the camera view then a monster will reach up from the floor and grab him and pull him under the floor.

    What I have done is:
    I have created a scene with the trigger image, my models and a plane that separates the human from the monster - this plane represents the floor. This plane should be transparent, (invisible in the camera) AND it should hide the monster. So, when the augmentation plays out it appears as though the monster is coming out of the floor.

    I have attached a shader with the following code to my plane:

    Shader"DepthMask"{
    SubShader{
    Tags{"Queue"="Geometry-10"}
    LightingOff
    ZTestLEqual
    ZWriteOn
    ColorMask0
    Pass {}
    }
    }

    Unfortunately, when I preview my scene, using the Unity player and my Mac's camera, the plane renders as a large black rectangle.

    I have asked for help on the Vuforia forum, but I have been told that it is a Unity issue not an AR issue and that I should ask here.

    Would someone here more knowledgeable than myself be so kind as to help me out?
    Please keep in mind I am new, so I would appreciate very specific instruction in plain English if you would.

    I am attaching an image of what I'm trying to describe - there is a sketch of what I intend, and a screen shot of what is happening.

    I look forward to a reply, and thankyou kindly in advance for your time.
    Kimber
     

    Attached Files:

  2. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    You shouldn't need a shader for this. You could just have two models, one for a solid floor another for the floor with a monster sized hole in it. Then just hide one and show the other.
     
  3. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,301
    He wants to hide monster model behind data visible through the web-camera. He needs a shader for it.

    Remove "ColorMask" line from the shader and try adding
    "Blend Zero One" instead of it.
     
    Ryiah and Arowx like this.
  4. cre8or

    cre8or

    Joined:
    Nov 6, 2015
    Posts:
    3
    Thank you kindly, both of you for your help, I really appreciate it.

    Neginfinity, for the record, I am a "she" ;) But you got the gist of exactly what I wanted to do.

    Anyway, we figured out how to accomplish this with the tools provided in the Qualcomm Augmented Reality Materials folder supplied with the asset. Now, my plane is invisible, and when the camera is pointed at the floor, the monster appears to come up from the ground.

    I'll probable have a lot more questions in the future, as I'm just starting on my Unity journey, and I appreciate all the help I can get.

    Thank you kindly,
    Kimber
     
  5. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    On a side note it could look really cool for a hole and debris to be left after the monster breaks out of the floor.