Topic: Problems with rendering camera layers

Hey community!

I was implementing a new camera layer system similar to the standard one for my post effects plugin.
I noticed that my old rendering code from a previous version does not work anymore (it did previously).
Currently it just renders the layer when selecting and then deselecting the scene in the editor.

My code: http://pastebin.com/YjZmdNEC

Well, everything else still works. The main scene is rendered correctly.

Sponk

Re: Problems with rendering camera layers

try this at the beginning of Render :

unsigned int currentFrameBuffer = 0;
render->getCurrentFrameBuffer(&currentFrameBuffer);

and replace :

render->bindFrameBuffer(0);

by :

render->bindFrameBuffer(currentFrameBuffer);

Re: Problems with rendering camera layers

Thank you, but this did not work either. I tried to switch to the scene with

level->setCurrentSceneId(m_CameraLayersFX[i]);

and after drawing switching back. It renders the active scene only. That means, if I enable the gui scene for example without reenabling the main scene, only the gui scene is being drawn.

Sponk

Re: Problems with rendering camera layers

what do you call inside MGame::draw and ::update ?
I taught it was a conflict with the current frame buffer but could it be the update of the scene ?

Re: Problems with rendering camera layers

I'm calling this method from MGame::draw which falls back to the standard method when post processing is not available or enabled.

You can find the stable and working code here:
https://github.com/Sponk/post-effects-p … Plugin/src

Sponk

PS: I did not change update in any serious way. Just handling some window resize events and flushing stdout before calling MGame::update

Re: Problems with rendering camera layers

I don't see something obvious popping out,
did you update the SDK includes in your "Includes/" directory ?

I noticed the lines :

#ifdef WIN32
    MVector4 clearColor = *camera->getClearColor();
#else
    MVector3 clearColor = camera->getClearColor();
#endif // WIN32

This is not system dependent, "camera->getClearColor();" was returning a pointer in previous version of the SDK
but it was modified to return a copy, the same thing was done for other objects.

Re: Problems with rendering camera layers

Thank you for pointing this out smile

It was a fast hack I used to compile the code on Windows with a different SDK version and forgot to revert it later.
The includes are the most recent ones from SVN. I'm getting the updates on a daily basis via my little helper tool.

Well, I will see what changed in the engine since when it worked. Maybe a regression somewhere. Who knows wink

Sponk

EDIT: I think it is a bug in the engine since I can't use the standard enableCameraLayer anymore without crashing the application (Linux and Windows).

Last edited by Sponk (2014-03-23 13:58:21)

Re: Problems with rendering camera layers

Hi Sponk,
I'm having a look at it, it's totally possible.

Re: Problems with rendering camera layers

I compiled the latest version from svn on mac, and the lua enableRenderToTexture and  enableCameraLayer worked.

You should double check that the SDK includes and the MCore.dll/lib and MEngine.dll/lib are the same version, because it sounds like a library address access crash.

If I have some time I'll compile your plugin to see what happens.

Re: Problems with rendering camera layers

Sorry that I answer so late. My hard drive died and I had to purchase a new one. I reinstalled everything and restored my data from my backup drive (I made a backup one day before the crash big_smile)

anael: As I have no choice now, I will reinstall Maratis from SVN wink

Sponk

Re: Problems with rendering camera layers

Ok, I have now reinstalled everything and was able to stop the crashes. I think it was because the executable file of the editor was corrupt on my old disk and produced some unwanted behavior. Now everything runs without crashing (with the same headers).
The layer is not being rendered though.

Sponk

EDIT: I created a new project without C++ plugin to test this
EDIT 2: It does not work with the "new" headers as well...

PS: 100 posts! YAY! big_smile

Last edited by Sponk (2014-03-28 20:36:55)

Re: Problems with rendering camera layers

EDIT 2: It does not work with the "new" headers as well...

you know that you have to use the exact same headers and libraries that was used to compile Maratis,
otherwise it is normal that it crashes.

Re: Problems with rendering camera layers

I know. I used the headers from the SVN version I used to compile the editor/player so everything should be ok.
They are "new" because it was from the latest SVN version I downloaded for a fresh compilation.

Sponk

Re: Problems with rendering camera layers

what happen when you run the "Render to texture" example : http://www.maratis3d.org/?page_id=53

Re: Problems with rendering camera layers

This example works without any problems.

Re: Problems with rendering camera layers

Ok, I tested the (built-in) camera layer thing on Windows and came to the same result. It just does not render.

Can anyone confirm that?

Sponk

Re: Problems with rendering camera layers

I found something. If you use a camera from another scene it will not render. That means that:

guiScene = getScene("guiScene")
enableCameraLayer(getObject(guiScene, "Camera0"), guiScene)

does not work whereas

enableCameraLayer(getObject("Camera0"), guiScene)

will render at least something. You'll see no lights though.

Sponk

EDIT: I found a workaround. Everything is now in the main scene and rendering correctly.

Last edited by Sponk (2014-04-02 12:47:07)

Re: Problems with rendering camera layers

I did some camera layer stuff just now I do it this way:

cam_main = getObject("Cam_Main")

gui = getScene("GUI")

enableCameraLayer(cam_main,gui)

This way I can change the camera explicitly, or overlay the stuff on other cameras:

enableCameraLayer(cam_ortho,gui)

Re: Problems with rendering camera layers

I found something. If you use a camera from another scene it will not render. That means that:
guiScene = getScene("guiScene")
enableCameraLayer(getObject(guiScene, "Camera0"), guiScene)
does not work whereas
enableCameraLayer(getObject("Camera0"), guiScene)

enableCameraLayer needs to receive a camera from the current scene,
and to see something it should be the current camera (the one that is active in the scene).

Re: Problems with rendering camera layers

Ah, ok.
Thank you for clarifying that.

I think the engine should give at least a warning when this function is called with invalid parameters and the wiki page should not just say

"object : object to operate on"

since this is quite a small description (so small that it does not tell you anything about this parameter).

Everything works now as expected! Thank you for your help! big_smile

Sponk