Multiple Image Trackers with Alpha

I want to use multiple image targets with videos containing alpha layered on top of each other (similar to Magic Photos template but with videos that have transparency and two videos layered on top of each other).

I have used the Green Screen Video template as a base for my code and just duplicated the section that specifies the video files. One chroma key is set to green and one is set to black. Please see my code further down for explanation.

My problem is that the videos don’t load correctly. When the phone first finds a target, it directly displays all videos at once (iPhone 13) instead of the two once I have selected. The second time it displays it correctly on Iphone but on android it does not even seem to open the experience even. See screen shots.


Can someone please help me?

My body.html so far:



<video
  id="alpha-video_2"
  muted
  autoplay
  playsinline
  crossorigin="anonymous"
  loop="true"
  src="./assets/A_green_v011.mp4"></video>

<video
  id="alpha-video_3"
  muted
  autoplay
  playsinline
  crossorigin="anonymous"
  loop="true"
  src="./assets/alpaca.mp4"></video>

The template I have used: Green Screen Video | 8th Wall | 8th Wall

Hi, Welcome to the forums!

Can you share your project with the support workspace and ensure all changes are landed so I can review the most up to date version?

It should be shared now

I’m taking a look at the project now. Here’s a video I recorded of the experience on my device, is this the expected behavior that you’re not seeing on other devices?

Thats indeed the behavior I would expect. What phone are you using?

For me the problem occurs the first time the phone finds a target image (see video here: RPReplay_Final1736975348.mov - Google Drive). When the camera sees a target tracker initially, it will play all three of the videos at once instead of the once selected (as shown in your example).

All the following times the camera sees a target image the videos seem to play the videos correctly. On Android it does not seem to load the project at all though.

I am new to coding so wondering if there is anything wrong in the naming or structuring of the target-video section? I noticed that in the template Magic Photos template they use:

instead of:


Thank you for the help!

I’m using an iPhone 15 Pro Max using Google Chrome. What phone(s) are you testing with where you’re seeing the problems? Can you test with Google Chrome and see if you still see the issue?

It seems to me like your code is correct and there might be a problem with the shader’s device compatibility.

I am using iphone 13 and sadly the problem persists in Chrome. As for the other two Androids they are older than 3 years (waiting to get the exact models to be confirmed).

Do you know if there is any other way to structure the project so it works for multiple target trackers with alpha videos for more devices?

Could one potentially use other ways than chroma keying to displace the videos transparency?

I’ll be able to look into this tomorrow when I can get my hands on an iPhone 13 to test. Once I’m able to test, we can explore alternative solutions as well.

Thank you, this is really much appreciated George!

Hi!

I added a line of code to set the video content to be hidden when the experience first loads on line 64 of target-video.js:

hideImage({})

My guess is that the content wasn’t be hidden before becoming lost thus you were seeing all the videos at once.

I’ve tested your project with an iphone 13 and this is what I see, which seems to be correct.

1 Like

Hey!

Thank you for getting back to me so quickly. That looks about right. Did you land the code? When I try the experience I still have the same issue (all videos are still showing on the first load).

How exactly should I implement the hideImage? I am new to code so sorry if it is a stupid question :slight_smile:

Yes, it’s landed! Make sure to sync.

Screenshot 2025-01-16 at 11.29.36 AM

Screenshot 2025-01-16 at 11.28.31 AM

Thank you for landing the changes. It still seems like it is a problem with the loading of the videos though.

Now, when you load the videos there is a black box that appears for a few seconds on the initial time the target-videos are loaded (see video attatched). Is there a way to correct this?

You could try adding t=0.001 to the end of the asset path to force it to render the 1st frame of the video instead of the 0th:

<video ... src="./assets/alpaca.mp4#t=0.001"></video>

Thank you for the tip Evan. I landed your changes but sadly, the black screen still appears when the video first loads. See screen shot attached. Is there any other way I can use transparency in videos?


Thank you for your help!

Does your phone happen to be in low power mode?

No it is not. But when it is, it doesn’t even allow me to see anything

Do you have any alternative suggestions on how to resolve this? :slight_smile:

Hey!

Interesting I didn’t see this on our test device but I do have a suspicion that this could be related to the speed at which the content is fetched over the network and then the shader takes some amount of time to process the video texture. If you want to test this you could try with a really small green screen video file.

I would work around this by loading the videos and positioning them out of view of the camera and then moving them to where they should be when the image target becomes visible.