- Home /
Need box with clear walls on the outside, visible on the inside, but not see through.
I'm looking for a way to construct a box such that from the outside you would not be able to see it, but from in the inside you would be able to see all of the walls. I don't want to simply flip the normals because then that would result in being able to see through one wall and seeing the inside of the other wall.
The origin for this problem is that I'm using the String Augmented Reality plugin and I'm trying to make it look like I have a hatch in my desk where the lid can be removed and you can see the contents of the containers by looking through the fake hole in my desk. Very similar to the this video here which shows the top of the table moving down into the box. I'm not sure how they managed to make the table occlude everything but the top of the box, but that doesn't come easy. Anyone have any ideas?
I'm not sure what you really need here - I was thinking that you could wait until the camera is inside the box to render it (normals flipped), but I'm not so sure now I've watched the video.
Very cool video btw, presumably the plugin is doing the motion tracking based on the reference image they are placing on the surface?
Can you elaborate on the issue as I don't think it's clear enough, at least not for me to be able to help...
The problem is that they have a box that appears sunk in to the surface. I have the box showing when the camera sees the marker, but it draws on top of the video feed, I'm thinking they are using some kind of occlusion to prevent the box from being seen unless you're looking through the top
$$anonymous$$aybe they're using a custom shader or something, that's what I'm trying to figure out. What kind of trick might they be using? I'll post a photo tomorrow showing what $$anonymous$$e looks like.
Ahh I think I get it... I've had a glass of wine, so I'll mull it over and post of I have anything concrete.
yh if you find anything out let us know, ive never done anything with using the camera could be a bit of fun
There's a thread here on writing a shader that clips:
http://forum.unity3d.com/threads/11832-Shader-for-Clipping-plane
Which is essentially what you want to do. I don't see anywhere to setup an arbitrary clip plane, but you might be able to hook into the render pipeline with some C plugin and setup a clip-plane - it's fraught with complications of course.
To do what is described in the video, shaders might be the way to go.
$$anonymous$$aybe something like:
Camera A draws a transparent box with no top (i.e. no colour values, writing to the Z buffer, but not writing over the colour values already rendered).
Camera B, later in the draw order does not clear the Z buffer but draws the garage geometry.
The first drawing is to set values in the Z buffer so that subsequent drawing will not write into the Z buffer. As such it could be triangles that describe the table top (for instance) sans the area described by the garage 'floor' - you could even draw a plane facing the camera. Achieving the right Z values might be a case of setting the near and far clipping planes appropriately and you could tweak these live I imagine to see if the garage 'shows through' correctly. You'll probably need a shader for the first bit of geometry but it ought to be relatively simple and Strumpy Shader Editor ought to help here.
The problems will be Z-fighting if the depth information is not fine-grained enough, which is why it would be best to draw something very close to the camera, and in fact, you'll probably find by doing so that using the same near and far clipping planes will be enough.
If Unity does have some clipping plane functionality built in, this would be easier and may be cheaper, but you'll need to set the planes to track the intersection of the camera's position with the near edges of the garage 'floor'.
This is largely off the top of my head thinking, so someone with more experience might have a better solution.
Cheers Bovine
Your answer
Follow this Question
Related Questions
Checking camera distance between object in a AR game 1 Answer
Augmented Reality in Unity Basic 1 Answer
[Augmented Reality] How to import object on the user defined marker? 0 Answers
Vuforia Virtual buttons question 1 Answer
how can i create a count down AR object that depends on a variable of remainnig stock? 1 Answer