|
Thomas Weiss, Jr. Member
Posted: 22 December 2012 03:06 AM Total Posts: 35
Hi there,
I’m currently trying to prototype some Augmented Reality usage of Away3D.
When doing AR, you sometimes need to display 3D objects that would ‘ghost’ real objects and enable these real objects to appear in front of virtual objects.
Having worked with Ogre before, I usually did this by specifying “lighting off” and “colour_write off” in the pass of the ‘ghost’ material. This would allow the related objects to actually display the scene background (which is the video capture in AR applications) on top of other virtual objects.
I’m not a material specialist, so I wonder how I would achieve the same result with Away3D materials…
Thanks for your help!
|
loth, Sr. Member
Posted: 23 December 2012 09:49 AM Total Posts: 236
[ # 1 ]
hello you can use
_nullMaterial = new TextureMaterial(Cast.bitmapTexture(new BitmapData(4, 4, true, 0x00000000)));
_nullMaterial.alphaBlending = true;
don’t miss remove shadows of your mesh like that
mesh.castsShadows = false;
|
Qbrain, Member
Posted: 23 December 2012 04:40 PM Total Posts: 92
[ # 2 ]
or even easier:
_nullMaterial = new ColorMaterial(0x000000,0);
mesh.castsShadows = false;
you practically make the object invisible because of the 0 alpha.
-Q
|
Thomas Weiss, Jr. Member
Posted: 24 December 2012 06:47 AM Total Posts: 35
[ # 3 ]
Hi!
Thanks for your replies, but I think that with the materials you described, the ‘ghost’ object would only be transparent and objects behind it would still be drawn, right? Whereas I would need the ‘ghost’ object to virtually ‘erase’ the objects behind from the scene and display the background (i.e. the View3D’s background texture) instead.
|
|
Qbrain, Member
Posted: 24 December 2012 01:17 PM Total Posts: 92
[ # 5 ]
only thing that pops in my mind is to use a raycast from the camera trough the object with the transparant material, and then make the mesh.visible = false when the ray collides with the mesh?
|
Thomas Weiss, Jr. Member
Posted: 27 December 2012 08:40 AM Total Posts: 35
[ # 6 ]
Mmh doesn’t sound easy to apply but I’ll give it a try, thanks!
|
Thomas Weiss, Jr. Member
Posted: 13 January 2013 04:54 AM Total Posts: 35
[ # 7 ]
Hi guys,
Back on this topic, I think that the easiest way to go would be to use a custom fragment shader that would sample the background texture (the video from the camera) at each fragment’s screen space coordinates. Thus, the ‘ghost’ object would just look like a see-through.
What do you think?
I know a little bit about shaders but have never dealt with AGAL before. Does anyone know how to get these screen-space coordinates in the fragment shaders?
Thanks again.
|
Thomas Weiss, Jr. Member
Posted: 01 February 2013 05:50 AM Total Posts: 35
[ # 8 ]
For those of you who would be looking for the same thing, the answer is here
|