Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by aledander · Jun 09, 2012 at 02:51 PM · augmented realityinvisibletranslucent

Making game objects invisble behind other objects

Hi,

is it possible to make a game object invisible behind another certain object?

I need this because I want to build an augmented reality animation, where a stickman climbs out of a hole in the floor. The floor must be transparent, because it should look like the stickman comes out of a card, or something.

So how to make the floor transparent but don't render any objects beyond it.

Thanks Alex

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by whydoidoit · Jun 09, 2012 at 05:56 PM

There is this shader that masks other objects.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Winterblood · Jun 09, 2012 at 03:22 PM

What you need is some geometry that renders only to the Z-buffer. Off the top of my head, you can probably force that using a transparent texture, setting the Z-write to stencil and the threshold to 0 (so it always writes to the Z-buffer no matter what the alpha value is).

Can't check for you as I'm in the middle of installing the latest update, sorry :)

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image aledander · Jun 09, 2012 at 04:00 PM 0
Share

$$anonymous$$hh, okay.

Theoretically I understand, what you suggest. But practically I don't have a clue what to do ;-)

I'm totally new to Unity and made only one scene, yet. So if you could give me a direction, where to read on or where to get more informations on creating those geometry, I will try to go ahead reading and learning :-)

Thanks $$anonymous$$

avatar image Winterblood · Jun 09, 2012 at 09:48 PM 0
Share

It's all in the material settings, but the ready-made shader @whydoidoit linked to below is probably much easier!

avatar image Bunny83 · Jun 09, 2012 at 11:54 PM 0
Share

@aledander: I guess you wanted to reply to winterblood's answer, so i converted your answer into a comment.

Answers should answer the question.

avatar image
0

Answer by Piflik · Jun 09, 2012 at 05:42 PM

You need a matte material. I tried to create a shader that does that once, but the result was not working (instead of showing the background, nothing was rendered where the object was) and I don't know how I would make it work...but maybe someone else can help...

 Shader "Matte" {
     Properties {
     }
     
     SubShader {
         Tags {
             "Queue"="Geometry-500"
             "IgnoreProjector"="False"
             "RenderType"="Opaque"
         }
 
         
         Cull Back
         ZWrite On
         ZTest LEqual
         ColorMask RGBA
         Blend Zero One
         Fog {
         }
 
 
         CGPROGRAM
         #pragma surface surf BlinnPhongEditor  vertex:vert
         #pragma target 2.0
 
 
 
             struct EditorSurfaceOutput {
                 half3 Albedo;
                 half3 Normal;
                 half3 Emission;
                 half3 Gloss;
                 half Specular;
                 half Alpha;
                 half4 Custom;
             };
             
             inline half4 LightingBlinnPhongEditor_PrePass (EditorSurfaceOutput s, half4 light) {
                 half3 spec = light.a * s.Gloss;
                 half4 c;
                 c.rgb = (s.Albedo * light.rgb + light.rgb * spec);
                 c.a = s.Alpha;
                 return c;
             }
 
             inline half4 LightingBlinnPhongEditor (EditorSurfaceOutput s, half3 lightDir, half3 viewDir, half atten) {
                 half3 h = normalize (lightDir + viewDir);
                 
                 half diff = max (0, dot ( lightDir, s.Normal ));
                 
                 float nh = max (0, dot (s.Normal, h));
                 float spec = pow (nh, s.Specular*128.0);
                 
                 half4 res;
                 res.rgb = _LightColor0.rgb * diff;
                 res.w = spec * Luminance (_LightColor0.rgb);
                 res *= atten * 2.0;
 
                 return LightingBlinnPhongEditor_PrePass( s, res );
             }
             
             struct Input {
                 float4 color : COLOR;
             };
 
             void vert (inout appdata_full v, out Input o) {
             float4 VertexOutputMaster0_0_NoInput = float4(0,0,0,0);
             float4 VertexOutputMaster0_1_NoInput = float4(0,0,0,0);
             float4 VertexOutputMaster0_2_NoInput = float4(0,0,0,0);
             float4 VertexOutputMaster0_3_NoInput = float4(0,0,0,0);
             }
             
 
             void surf (Input IN, inout EditorSurfaceOutput o) {
                 o.Normal = float3(0.0,0.0,1.0);
                 o.Alpha = 1.0;
                 o.Albedo = 0.0;
                 o.Emission = 0.0;
                 o.Gloss = 0.0;
                 o.Specular = 0.0;
                 o.Custom = 0.0;
                 
                 float4 Master0_0_NoInput = float4(0,0,0,0);
                 float4 Master0_1_NoInput = float4(0,0,1,1);
                 float4 Master0_2_NoInput = float4(0,0,0,0);
                 float4 Master0_3_NoInput = float4(0,0,0,0);
                 float4 Master0_4_NoInput = float4(0,0,0,0);
                 float4 Master0_5_NoInput = float4(1,1,1,1);
                 float4 Master0_7_NoInput = float4(0,0,0,0);
                 float4 Master0_6_NoInput = float4(1,1,1,1);
 
                 o.Normal = normalize(o.Normal);
             }
         ENDCG
     }
     Fallback "Diffuse"
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I keep objects invisible when vuforia ImageTarget is lost and found again? 1 Answer

Renderer on object disabled after level reload 1 Answer

Solutions for iOs camera body tracking? 0 Answers

The archive is invalid. /var/folders/_k/9jd5s_9d1h59l72f3bfs018r0000gn/T/XCodeDistPipeline.9UU/Unity-iPhone.ipa does not exist 2 Answers

Using a wireless camera with iPhone/Android 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges