cancel
Showing results for 
Search instead for 
Did you mean: 

Background image instead of ovrScene file

leoburnettaus
Honored Guest
Hi Guys,

Is it possible to use background image used in previous SDK's instead of ovrScene file in 360 Videos project or is it possible to use sphere instead of skybox or cube?

Regards,
13 REPLIES 13

warvr
Honored Guest
Hello.

The background OvrScene is hardcoded in the application currently as "assets/stars.ovrscene". An easy way to load your own custom OvrScene would be to simply save it over stars.ovrscene. Alternatively you could change the file path in the application. Another option would be to do what VrScene does and pass the file path to the scene into the app via an intent (which would involve a bit more work).

Regarding using a background panorama instead of an OvrScene, this was indeed the case before we switched to using the OvrScene. A bit more work is necessary to make that work again. The basic idea would be to render your background equirectangular panorama onto the globe. This is what we do in 360 Photos for example. If you're interested, I could send you a modified Oculus360Videos.cpp where I have it working.

Regards,
War

leoburnettaus
Honored Guest
Thanks for quick replay warvr,

Yes, we definitely need that project where we can use panoramic image instead of ovrscene file. Can you please also confirm that the project which you are going to send is using the latest SDK?

Regards,
Farhan

warvr
Honored Guest
Hi Farhan,

I had offered to send just the cpp. However, I'll just go over the changes you need to make to the current version of Oculus360VideosSDK to get the background panorama rendering as it's quite straightforward. All the following changes are for Oculus360Videos.cpp -- the main cpp of the project.

Starting at line 271 to 281, we want to disable loading the background scene as we will not be using it. #define out or erase the following:

// Optimize for 16 bit depth in a modest theater size
Scene.Znear = 0.1f;
Scene.Zfar = 200.0f;
MaterialParms materialParms;
materialParms.UseSrgbTextureFormats = ( app->GetVrParms().colorFormat == COLOR_8888_sRGB );

BackgroundScene = LoadModelFileFromApplicationPackage( "assets/stars.ovrscene",
Scene.GetDefaultGLPrograms(),
materialParms );

Scene.SetWorldModel( *BackgroundScene );

The next change is in the DrawEyeView function. Here we are going to edit the code which handles rendering when we are not playing a video -- ie. the code that currently renders the star scene and change it to render the background panorama instead. Starting at line 586, replace everything within the first block of the if statement:

if ( MenuState != MENU_VIDEO_PLAYING )
{
const float fadeColor = CurrentFadeLevel;
glActiveTexture( GL_TEXTURE0 );
glBindTexture( GL_TEXTURE_2D, BackgroundTexId );

GlProgram & prog = SingleColorTextureProgram;

glUseProgram( prog.program );
glUniform4f( prog.uColor, fadeColor, fadeColor, fadeColor, 1.0f );

glUniformMatrix4fv( prog.uMvp, 1, GL_FALSE, mvp.Transposed().M[ 0 ] );

Globe.Draw();

glBindTexture( GL_TEXTURE_2D, 0 ); // don't leave it bound
}

This should be all you need to render the background panorama which is loaded on line 259.

Regards,
War

leoburnettaus
Honored Guest
Thanks for the code War,

I am getting compile error on following lines

1. GlProgram & prog = SingleColorTextureProgram;
2. glUniformMatrix4fv( prog.uMvp, 1, GL_FALSE, mvp.Transposed().M[ 0 ] );

because SingleColorTextureProgram and mvp are not declared. I replaced the code with the following but it's not loading the image. It only shows the black background.

const float fadeColor = CurrentFadeLevel;
glActiveTexture( GL_TEXTURE0 );
glBindTexture( GL_TEXTURE_2D, BackgroundTexId );

GlProgram & prog = ( BackgroundWidth == BackgroundHeight ) ? FadedPanoramaProgram : PanoramaProgram;;

glUseProgram( prog.program );
glUniform4f( prog.uColor, fadeColor, fadeColor, fadeColor, 1.0f );

// Videos have center as initial focal point - need to rotate 90 degrees to start there
const Matrix4f view = Scene.ViewMatrixForEye( 0 ) * Matrix4f::RotationY( M_PI / 2 );
const Matrix4f proj = Scene.ProjectionMatrixForEye( 0, fovDegrees );

glUniformMatrix4fv( prog.uMvp, 1, GL_FALSE, ( proj * view ).Transposed().M[ 0 ] );

Globe.Draw();

glBindTexture( GL_TEXTURE_2D, 0 ); // don't leave it bound

Regards,
Farhan

leoburnettaus
Honored Guest
Hi War,

I am attaching the Oculus360Videos.cpp if that helps.

Regards,
Farhan

warvr
Honored Guest
Hi Farhan,

It seems the problem is the version of the SDK you are using. The changes I suggested specifically need a shader I added to the current version of the SDK's 360 Videos (It was released on the 23rd). This explains the compile errors you are getting as your version is missing the SingleColorTextureProgram shader program. Please get the latest and the changes should work.

Regards,
War

leoburnettaus
Honored Guest
Thanks War,

I will let you know if I have any other issues.

Thanks a lot for your help.

Regards,
Farhan

leoburnettaus
Honored Guest
Hi War,

I have another question which I asked earlier in different post but never got an answer.

We used 8 .wav files for 360 effect in earlier versions of the SDK but in latest version I couldn't find that code. Is it still possible to have that effect in latest SDK?

Regards,
Farhan

warvr
Honored Guest
Hi Farhan,

We don't use that code anymore hence why it was stripped out. I believe it was self contained so you could still use it if you wanted to.

We currently play the ui sounds in 360 Videos using the SoundManager class in VRLib. It's a pretty simple class and the header should explain how it works if you want to use it.

Regards,
War