Forum Discussion
gwzn
10 months agoHonored Guest
Is there a way to use a video source as a texture on imported (GLTF/GLXF) geometry?
Wondering if there is a way to assign a video source as a texture to an object that has been added to the scene either through the Meta Spatial Editor or imported as GLTF/GLB at runtime?
Hi!
Yes, this should be possible. You can see an example in our Media Player Sample where we attach a video texture to light up (emissive texture) some of the surroundings: https://github.com/meta-quest/Meta-Spatial-SDK-Samples/blob/main/MediaPlayerSample/app/src/main/java/com/meta/spatial/samples/mediaplayersample/MediaPlayerSampleActivity.kt#L372
The steps for your case you will want to take are:
1. When authoring your glTF model, create a specific material attached to only your screen (let's say you name it "screen")
2. Make sure your screen mesh has UVs such that it will display an image attached to it correctly (i.e. (0, 0) in one corner and (1, 1) in the other). If you are using a box in Blender, it should probably already have these set up already.
3. Next we can jump back into app code. This part will roughly follow the GitHub sample code linked earlier. You first need to load a panel in the standard way (inside registerPanels()). From there, in the panel callback, you can get a reference to the panel texture using getTexture().
4. Once you have access to the panel texture, you can get access to the model geometry. You can do this via systemManager.findSystem<SceneObjectSystem>().getSceneObject(myModelEntity)?.thenAccept { myModel -> ... }
5. Next, you need a reference to your material you authored in the glTF. You can do this with myModel.mesh?.getMaterial("screen") (assuming you named your material "screen").
6. Finally, you can assign the texture to the material with myMaterial.setAlbedoTexture(myPanelTexture)
One caveat here is it will probably take a lot more customizing if you want to use layers as well.
We are looking at ways of improving this flow to make it easier for these custom scenarios.
1 Reply
Replies have been turned off for this discussion
- dav-sMeta Employee
Hi!
Yes, this should be possible. You can see an example in our Media Player Sample where we attach a video texture to light up (emissive texture) some of the surroundings: https://github.com/meta-quest/Meta-Spatial-SDK-Samples/blob/main/MediaPlayerSample/app/src/main/java/com/meta/spatial/samples/mediaplayersample/MediaPlayerSampleActivity.kt#L372
The steps for your case you will want to take are:
1. When authoring your glTF model, create a specific material attached to only your screen (let's say you name it "screen")
2. Make sure your screen mesh has UVs such that it will display an image attached to it correctly (i.e. (0, 0) in one corner and (1, 1) in the other). If you are using a box in Blender, it should probably already have these set up already.
3. Next we can jump back into app code. This part will roughly follow the GitHub sample code linked earlier. You first need to load a panel in the standard way (inside registerPanels()). From there, in the panel callback, you can get a reference to the panel texture using getTexture().
4. Once you have access to the panel texture, you can get access to the model geometry. You can do this via systemManager.findSystem<SceneObjectSystem>().getSceneObject(myModelEntity)?.thenAccept { myModel -> ... }
5. Next, you need a reference to your material you authored in the glTF. You can do this with myModel.mesh?.getMaterial("screen") (assuming you named your material "screen").
6. Finally, you can assign the texture to the material with myMaterial.setAlbedoTexture(myPanelTexture)
One caveat here is it will probably take a lot more customizing if you want to use layers as well.
We are looking at ways of improving this flow to make it easier for these custom scenarios.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 7 months ago
- 5 months ago
- 8 months ago