googlevr / cardboard

Open source Cardboard SDK and samples
Other
1.48k stars 253 forks source link

Access to eyes render textures #279

Open dipaw opened 3 years ago

dipaw commented 3 years ago

Hi, is it possible to reassign the texture render format? At the moment, due to the resolution, their size is very large, which affects the bandwitch. As I understand it, there are two textures, temporary and XR texture, for each eye. By default, they are created in ARGB 32 format. Can i configure this in CardboardXR plugin or somewhere in XR Plugin Managment to create an ARGB4444 for example?

22ba88fcb3209e4c51af6bd36132dc4f

dipaw commented 3 years ago

Also I checked the scene render load using render docks with XR turned off. The 10ms difference is quite large, while the rendering itself does not take much time. b8f00bce8a47abf14328e00d76c50e54 cardboardxr.txt f569996e66f5c0a8b5b173e935f9941f wihtoutxrdrawcalls.txt I also attached a txt with drawings for comparison, you can see bottlenecks on them. Such as glClear at the very beginning and PlayerEndOfFrame at the end, which take about 6ms in total. I need to put a render thread at 16 ms for a stable picture of 60 frames, but this does not work, even with the empty scene with a few objects, the number of frames can drop to 45-50. Perhaps you know how to shorten this pre-render and post-render time. I couldn't think of anything other than lowering the screen resolution and changing the format (which I'm sure of only in theory).

Sorry if this question is in the wrong place. Perhaps this is more related to the XP Plugin, but since you are working closer with it, you may to know.

dipaw commented 3 years ago

@jballoffet please. 🙏 It is very important.

dipaw commented 3 years ago

By the way, XRSettings.eyeTextureResolutionScale doesn't work too, so I can't reduce the render resolution.

jballoffet commented 3 years ago

Thanks @dipaw for reaching out. You should be able to change the texture format by changing the colorFormat field of the Unity XR texture descriptors. See possible values here. You'll also need to change the XR provider source code (including the shaders) to make it suitable for the new format.

Please bear in mind that this has not been tested by us, so we cannot guarantee that the integration with Unity using a different texture format will work.

Thanks! HTH.

dipaw commented 3 years ago

Thanks @dipaw for reaching out. You should be able to change the texture format by changing the colorFormat field of the Unity XR texture descriptors. See possible values here. You'll also need to change the XR provider source code (including the shaders) to make it suitable for the new format.

Thanks for the answer! Looks exactly like what I need. Especially kUnityXRRenderTextureFormatReference, which, as I understand it, does not create unnecessary Render Textures. But I don’t know what to do with it. Is it possible to add this selection to Google.XR.Cardboard.Api in future versions? Changing the resolution of the render texture via XRSettings.eye Texture Resolution Scale would be useful too.

jballoffet commented 3 years ago

A ticket for adding this feature has been added to our backlog and will be prioritized along with other tickets. Please bear in mind that given that this is not strictly a bug but instead a performance improvement, it will have less priority than other tickets in the backlog. Thanks!