Forum Discussion
PointyLlama5273
8 months agoExplorer
How to update contents of SceneTexture in SpatialSDK?
I'm working with a SceneTexture instance passed to a shader for rendering in this fashion:
val videoTexture = SceneTexture(Color.valueOf(0f, 0f, 1f, 1f))
videoMaterial = SceneMaterial.custom("myShader", arrayOf(
SceneMaterialAttribute("videoTexture", SceneMaterialDataType.Texture2D)
)).apply {
setTexture("videoTexture", videoTexture)
}Is there any way to update the videoTexture without creating a new SceneTexture instance? I've tried the following:
frame?.copyPixelsToBuffer(copyBuffer!!)
videoTexture.update(copyBuffer!!, frame!!.width, frame.height, 4)
videoMaterial!!.setTexture("videoTexture", videoTexture)where frame is a Bitmap with a per pixel byte count of 4 (format ARGB_8888). It results in no visible changes to the texture, even if copyBuffer is empty. It's hard to tell if this is the correct usage or if this update function even does anything at all considering the the lack of information on the official documentation. I've also tried looking through the official samples, but found no mentions of this function.
Figured it out.
Turns out the strideInBytes parameter refers the number of bytes between rows in a bitmap, so the correct version would look like this:videoTexture?.update(copyBuffer!!, frame.width, frame.height, frame.rowBytes)
1 Reply
Replies have been turned off for this discussion
- PointyLlama5273Explorer
Figured it out.
Turns out the strideInBytes parameter refers the number of bytes between rows in a bitmap, so the correct version would look like this:videoTexture?.update(copyBuffer!!, frame.width, frame.height, frame.rowBytes)
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
- 3 months ago