Topic locked

How to use Unity Render Textures with Vuforia?

April 30, 2014 - 6:59am #11

Hi, I'm having a problem using unity's Render Textures.

I have a working scene with an AR Camera (camera1), all works fine here, both in unity player and android devices.

but then I add a second Camera (camera2) which outputs to a Render Texture.. it works just fine in unity player, but when I try it on android device, the background (smartphone's video-feed) is all black, augmentation still works fine .... BUT.... here comes the maddness:

I add a cube to which I applied the Render Texture... what I see there in the cube, instead of viewing camera2's output, I see a crop of the android camera's video feed .. now, I add a third camera (camera3) that also outputs to a new Render Texture, and also apply that new render texture to a new cube... and that texture and cube does work fine, showing the output of camera3.... but why is the first Render Texture intercepting the background video feed instead?

can someone give a detailed insight on this issue?

as a workaround, I suppose I could use the Vuforia's Background Texture Access sample to restablish the background video feed, but... what should I do with the first render texture that allways fails? create more than one, and don't use the firts one at all? but why does that happen???

to be clear:

1) the first bug is that video feed on background gets lost..
2) the second bug is that the first unity camera to outputs to a render texture, captures a crop of the video feed instead of unity camera's output.

any hints on why it happens, and how to work around it?
 

How to use Unity Render Textures with Vuforia?

May 1, 2014 - 8:23am #10

I've tried to use the Background Tetxure Access as a starter, but I still can't get any render texture to show up correctly, the new cameras I add do output to render textures, but all those textures looks all messed up, as when you open a broken jpg/gif image that you see lots of color nonsense and a bit of video feed background on it too..

 

Is it me the only one who wants to use render textures with vuforia or the only one that is having this problem?

please help!

How to use Unity Render Textures with Vuforia?

May 1, 2014 - 11:25am #9

How to use Unity Render Textures with Vuforia?

May 2, 2014 - 9:36am #8

Thanks Allesandro,

I was having a bunch of different issues, I've finally solved them all, but there's still one that occurs and is not described in the article you refered:

let me explain it:

1) Take Background Texture Access sample as a start

2) add a new camera and make that camera the only one to see a cube gameobject and nothing else (using layers and culling mask) and set its clear flags set to "depth only", finally choose a "target texture" on the camera, so it creates a render texture.

the resulting Rendered Texture will have a problem when it runs on android (I didnt check ios): the pixels that should be "transparent" are all filled up with noise (it looks random pixel information taken from the device's vram).

the workaround I use, is set the camera clear flag to "solid color" and then use a shader that cuts it out with the "alpha cutoff" slider.

note that this bug doesn't reproduce in the unity player... so I guess it must be a bug, should I report it, or is that a known behaviour?

just let me know, I can provide all needed information

How to use Unity Render Textures with Vuforia?

May 4, 2014 - 11:53am #7

Is the camera that you use for the "render to texture" an AR Camera, or a normal Unity camera ?

 

How to use Unity Render Textures with Vuforia?

May 4, 2014 - 1:41pm #6

AlessandroB wrote:

Is the camera that you use for the "render to texture" an AR Camera, or a normal Unity camera ?

 

it's just a normal Unity camera.

How to use Unity Render Textures with Vuforia?

May 4, 2014 - 11:18pm #5

Ok. So, could it be that this is an issue with Unity (and not with Vuforia), or am I missing something ?

 

How to use Unity Render Textures with Vuforia?

May 5, 2014 - 6:19am #4

AlessandroB wrote:

Ok. So, could it be that this is an issue with Unity (and not with Vuforia), or am I missing something ?

The RenderTexture Camera is not a Vuforia One, but the moment I remove vuforia out of the project, everything works as expected in the smartphone.

For instance: I removed the ARCamera, and replace it with a standard camera, just to see how the RenderTexture looks like without augmentation, and it works just fine both in player and android smartphone.

vuforia is obviously messing it up with the vram/textures or something.

 

How to use Unity Render Textures with Vuforia?

May 5, 2014 - 7:34am #3

Ok, could you explain exact setup of your project (possibly step-by-step or in sufficient detail) so that I can try to reproduce this and take a look ?

 

How to use Unity Render Textures with Vuforia?

May 5, 2014 - 8:49am #2

AlessandroB wrote:

Ok, could you explain exact setup of your project (possibly step-by-step or in sufficient detail) so that I can try to reproduce this and take a look ?

 

my Mistake!

I was reproducing it from scratch for making the instructions, and the bug also happens on unity without vuforia, this one is not a vuforia issue, sorry about that!

 

 

How to use Unity Render Textures with Vuforia?

May 5, 2014 - 12:02pm #1

No problem, thanks for your confirmation.

 

Topic locked