Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding effects in three.js while using stereo-effect #2

Open
tjoen opened this issue Jul 19, 2017 · 3 comments
Open

Adding effects in three.js while using stereo-effect #2

tjoen opened this issue Jul 19, 2017 · 3 comments

Comments

@tjoen
Copy link

tjoen commented Jul 19, 2017

First of all, thanks for the great software,
I will probably make a tutorial on how to use it in opentoonz later.

Right now I'm coding a VR app in three.js, and I am using your excellent library. I've implemented it into my game, and it seems to work pretty good. I am having a bit of trouble with changing mesh textures, when the effects are running though, but I already found a fix for that. (Using sprites seems to work, so I changed the textured meshes into sprites.)

My biggest problem lies in the fact that when I use the stereo effect of three.js the effekseer effects are only visible in just one of the two render windows. In my case the right renderwindow.

example

Do you have a suggestion for a fix for that problem?

Kind regards, Theun

@ueshita
Copy link
Collaborator

ueshita commented Jul 20, 2017

Hello Theun.
I glad to you use our library!

This problem is a little difficult.
I guess you are using StereoEffect.js.

Effekseer needs to draw() two times in VR apps.
However, StereoEffect.js has no function that render hook....

Could you modify StereoEffect.js?
Please try following change.

Original StereoEffect.js code

this.render = function ( scene, camera ) {

Modified StereoEffect.js code

this.render = function ( scene, camera, onpostrender ) {

Original StereoEffect.js code

renderer.setScissor( 0, 0, _width, _height );
renderer.setViewport( 0, 0, _width, _height );
renderer.render( scene, _cameraL );

renderer.setScissor( _width, 0, _width, _height );
renderer.setViewport( _width, 0, _width, _height );
renderer.render( scene, _cameraR );

Modified StereoEffect.js code

renderer.setScissor( 0, 0, _width, _height );
renderer.setViewport( 0, 0, _width, _height );
renderer.render( scene, _cameraL );
onpostrender( _cameraL );         // Added

renderer.setScissor( _width, 0, _width, _height );
renderer.setViewport( _width, 0, _width, _height );
renderer.render( scene, _cameraR );
onpostrender( _cameraR );         // Added

Original your code (maybe)

effect.render( scene, camera );
effekseer.draw();

Modified your code

effect.render( scene, camera, function( camera ) {
  effekseer.setProjectionMatrix(camera.projectionMatrix.elements);
  effekseer.setCameraMatrix(camera.matrixWorldInverse.elements);
  effekseer.draw();
} );

Thanks.

@tjoen
Copy link
Author

tjoen commented Jul 25, 2017

Thank you for your reply!

But I seem to be missing the onpostrender function you are using?
That function is not in my effekseer.min.js, three.js or other js files.
I suppose it is a unity3d function.

@ueshita
Copy link
Collaborator

ueshita commented Jul 25, 2017

onpostrender is your variable added to arguments at "render" function in StereoEffect.js.
It is called after each renders (two times).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants