Irrlicht 1.9SVN changes in setRenderTarget...

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Irrlicht 1.9SVN changes in setRenderTarget...

Post by christianclavet »

Hi, I've been using a post process framework, and now with the last update of Irrlicht, got a compilation error because the parameters to define the render target have somewhat changed.

Here of what I'm using to update the post process framework:

Code: Select all

void CPostProcessManager::update()
{
    // render the scene into the framebuffer after postprocessing
    RenderToScreen->getMaterial().setTexture(0, RenderTargetMap["auxOut"]);
    Device->getVideoDriver()->setRenderTarget(video::ERT_FRAME_BUFFER, true, true);
    RenderToScreen->render();
}
I get the error in this line:
Device->getVideoDriver()->setRenderTarget(video::ERT_FRAME_BUFFER, true, true);
Seem video::ERT_FRAME_BUFFER is no longer supported and now require a ITexture pointer.

What do I have to change in my code to make it work again?
I've tried this:

Code: Select all

Device->getVideoDriver()->setRenderTarget(RenderTargetMap["auxOut"], true, true);
But still the rendering is still full black.

NOTE: The postprocessing framework I'm using is this one: http://irrlicht.sourceforge.net/forum/v ... =9&t=43743
Was working recently, until I updated the trunk version to the last one. (SVN 1.9 Trunk rev 5104)
archmagus
Posts: 25
Joined: Sat May 30, 2015 4:18 am
Location: Australia

Re: Irrlicht 1.9SVN changes in setRenderTarget...

Post by archmagus »

OK, using your download link from here and Irrlicht 1.9 (SVN 5107) , I... could not compile either. :(
I get bunch of Warnings about deprecated shader calls (setPixelShaderConstant, setVertexShaderConstant, etc) and 3 errors (!).
I'll deal with your error first:
I am unsure if you have modified the PostProcessing framework because your pasted code doesn't match up with the code in the framework but I think this is what happened:

In PostProcessManager.cpp:85 in void CPostProcessManager::render (just above update() in my unmodified version linked to above)

Code: Select all

 
// bind output buffer
if( !postProcess->getRenderTarget().empty())
    Device->getVideoDriver()->setRenderTarget(RenderTargetMap[postProcess->getRenderTarget()]);
else
    Device->getVideoDriver()->setRenderTarget(video::ERT_FRAME_BUFFER, true, true);
 
It appears to check if the output buffer is empty, if it is not 'empty' then sets the render target (ie: binds output buffer) using RenderTargetMap as an argument.
If it is 'empty' then it sets the Frame Buffer as the render target.
Device->getVideoDriver()->setRenderTarget(video::ERT_FRAME_BUFFER, true, true); gives me an error that *ITexture or *IRenderTarget should be the first arg, (no possible conversion yadayada) so this must be the error that you are seeing.
Either comment the offending line out (if you are using the unmodified version) or if you are using a modified version change it to:

Code: Select all

 
Device->getVideoDriver()->setRenderTarget(RenderTargetMap[postProcess->getRenderTarget()]);
 
TBH this is a wild stab in the dark as I would rather not download the 255MB IrrRPG + sources (or wherever this code is from) just to try this. :roll:
It would be nice if you could upload your modified (?) version PostProcessing framework somewhere, since I get other errors as well. :)

I also cannot compile (even after doing the above) because of an error associated with irrMap.h:

These are the relevant errors (including the above error mind):
Compiler is clang++ 3.6 on Ubuntu 15.04 64-bit (I get the same error from g++)

Code: Select all

 
In file included from PostProcessManager.cpp:1:
In file included from ./PostProcessManager.h:4:
In file included from ../../trunk/include/irrlicht.h:130:
../../trunk/include/irrMap.h:622:8: error: cannot define the implicit copy assignment operator for 'irr::core::map<irr::core::string<wchar_t, irr::core::irrAllocator<wchar_t> >, irr::video::ITexture
      *>::AccessClass', because non-static reference member 'Tree' can't use copy assignment operator
        class AccessClass
              ^
../../trunk/include/irrMap.h:653:8: note: declared here
                map& Tree;
                     ^
PostProcessManager.cpp:54:27: note: implicit copy assignment operator for 'irr::core::map<irr::core::string<wchar_t, irr::core::irrAllocator<wchar_t> >, irr::video::ITexture *>::AccessClass' first required
      here
        RenderTargetMap["auxIn"] = RenderTargetMap["auxOut"];
                                 ^
In file included from PostProcessManager.cpp:1:
In file included from ./PostProcessManager.h:4:
In file included from ../../trunk/include/irrlicht.h:130:
../../trunk/include/irrMap.h:622:8: error: cannot define the implicit copy assignment operator for 'irr::core::map<irr::core::string<wchar_t, irr::core::irrAllocator<wchar_t> >, irr::video::ITexture
      *>::AccessClass', because non-static reference member 'Key' can't use copy assignment operator
        class AccessClass
              ^
../../trunk/include/irrMap.h:654:18: note: declared here
                const KeyType& Key;
                               ^
PostProcessManager.cpp:54:27: note: implicit copy assignment operator for 'irr::core::map<irr::core::string<wchar_t, irr::core::irrAllocator<wchar_t> >, irr::video::ITexture *>::AccessClass' first required
      here
        RenderTargetMap["auxIn"] = RenderTargetMap["auxOut"];
                                 ^
PostProcessManager.cpp:89:31: error: no matching member function for call to 'setRenderTarget'
                                Device->getVideoDriver()->setRenderTarget(video::ERT_FRAME_BUFFER, true, true);
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
../../trunk/include/IVideoDriver.h:591:16: note: candidate function not viable: no known conversion from 'irr::video::E_RENDER_TARGET' to 'video::ITexture *' for 1st argument
                virtual bool setRenderTarget(video::ITexture* texture,
                             ^
../../trunk/include/IVideoDriver.h:546:16: note: candidate function not viable: requires at least 5 arguments, but 3 were provided
                virtual bool setRenderTarget(IRenderTarget* target, const core::array<u32>& activeTextureID, bool clearBackBuffer,
                             ^
../../trunk/include/IVideoDriver.h:550:8: note: candidate function not viable: requires at least 5 arguments, but 3 were provided
                bool setRenderTarget(IRenderTarget* target, u32 activeTextureID, bool clearBackBuffer, bool clearDepthBuffer,
 
 
I admit I am also eager for a solution to this problem(s) because this looks like a very good Postprocesser...
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: Irrlicht 1.9SVN changes in setRenderTarget...

Post by christianclavet »

Hi,

Ok. I'm trying to use as most of possible "addons" as they are when I've added them into the project as it's easier to update if the author create a new version.

I'll give you a link for the post process manager that TBW made and I updated for Irrlicht SVN 1.9. Before the dev updated something in Irrlicht it was working with 1.9SVN before they changed the parameters of the setRenderTarget command.

So the current problem is that I don't know how to set this command since they changed the parameters. I've put the old command that worked before they changed the parameters in comments in the code and tried my own parameters to see but still fail and give me a black output.

Here is the link: http://irrrpgbuilder.sourceforge.net/fi ... rocess.zip 10k Be aware that this was just updated for openGL and could give strange results in DX.

Here is also the modified sources that work for XEffect in 1.9. Again this is only checked for OPENGL (This work on 1.9, but your model should not contain any transparent/alpha. There was some changes since 1.8, and this happen since then. I issued a report for this also). Got reports that this work fine in DX (Surely because the DX driver was not that updated since 1.7.3)

Link: http://irrrpgbuilder.sourceforge.net/files/XEffects.zip 18k

You might have to check for the shader loader path as they might not be the same.
archmagus
Posts: 25
Joined: Sat May 30, 2015 4:18 am
Location: Australia

Re: Irrlicht 1.9SVN changes in setRenderTarget...

Post by archmagus »

Ok I just tried out the Postprocess and it compiles and I can fly around the map, then when I press 'm' to see the postprocess effects it segfaults.

This works for me:
(From CPostProcessManager::update - Some commented lines removed)

Code: Select all

 
    // render the scene into the framebuffer after postprocessing
    RenderToScreen->getMaterial().setTexture(0, RenderTargetMap["auxOut"]);
    RenderToScreen->render();
 
As does this (did you try this?):

Code: Select all

 
    // render the scene into the framebuffer after postprocessing
    //RenderToScreen->getMaterial().setTexture(0, RenderTargetMap["auxOut"]);
    Device->getVideoDriver()->setRenderTarget(0, true, true, 0);
    RenderToScreen->render();
 
But I can't use the postprocessor, it segfaults when I press 'm' (which enables pp effects):
(gcc 4.9 on Ubuntu, compiled with '-g' flag and run in gdb)

Code: Select all

 
Please select the driver you want for this example:
 (a) OpenGL 1.5
 (b) Direct3D 9.0c
 (otherKey) exit
 
a
Irrlicht Engine version 1.9.0
Linux 3.16.0-33-generic #44-Ubuntu SMP Thu Mar 12 12:19:35 UTC 2015 x86_64
Creating X window...
Visual chosen: : 39
Using renderer: OpenGL 4.5.0
GeForce GTX 750/PCIe/SSE2: NVIDIA Corporation
OpenGL driver version is 1.2 or better.
Dedicated video memory (kB): 2097152
Total video memory (kB): 2097152
Available video memory (kB): 1936336
GLSL version: 4.5
compiling material Final Pass
compiling material Depth
Loaded texture: 032-03a.jpg
 
-snip- Irrlicht loads everything OK and runs the example until i enable the postprocess effects:
 
Program received signal SIGSEGV, Segmentation fault.
0x000000000040e684 in irr::core::map<irr::core::string<wchar_t, irr::core::irrAllocator<wchar_t> >, irr::video::ITexture*>::AccessClass::operator irr::video::ITexture* (this=0x7fffffffde90)
    at ../../trunk/include/irrMap.h:644
644             return node->getValue();
(gdb) finish
Run till exit from #0  0x000000000040e684 in irr::core::map<irr::core::string<wchar_t, irr::core::irrAllocator<wchar_t> >, irr::video::ITexture*>::AccessClass::operator irr::video::ITexture* (
    this=0x7fffffffde90) at ../../trunk/include/irrMap.h:644
 
Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
 
I admit I have no idea what is going on here. Notably, I get the same error from Irrlicht 1.8. :? Confuzzled

I haven't tried XEffects yet.
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: Irrlicht 1.9SVN changes in setRenderTarget...

Post by christianclavet »

Hi! Thanks!

Your command seem to have worked. I have the POSTFX shaders working again in openGL it's not black anymore. I will have to check for a new bug that I did not see before (postFX enabled, stop game and then no render, could be me playing with something)

Before that line was

Code: Select all

Device->getVideoDriver()->setRenderTarget(video::ERT_FRAME_BUFFER, true, true);
and now should be this:

Code: Select all

Device->getVideoDriver()->setRenderTarget(0, true, true, 0);
Have you tried to rebuild/clean before compiling the source? I did not have a SEGFAULT (tested with MSVC Community 2013 on Win7)
So perhaps the segfault could come from your own code? (Memleak or something similar)?

I still have to check why I don't have any rendering when I stop the game and the postProcess shader, but you could check that the paths for the shaders are fine (I think they could be because your output show that the shader were precompiled.)
archmagus
Posts: 25
Joined: Sat May 30, 2015 4:18 am
Location: Australia

Re: Irrlicht 1.9SVN changes in setRenderTarget...

Post by archmagus »

It's probably an error on my part, I actually haven't looked at the main.cpp in the package you provided. :shock:
My Makefile probably wasn't that good either, but hey, it caught the error. :)
I'll play around with it and get it to work for me latter.
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: Irrlicht 1.9SVN changes in setRenderTarget...

Post by christianclavet »

Hi, Fixed the problem with the no rendering issue. Once the PostFX is enabled, you cannot render without updating the PostFX manager. My fault on this. One thing I don't understand, while the POST FX seem, there is a yellowish tint into the picture.

Here is IRB with NO POST FX enabled:
Image

Here with the POST FX named "Embossed": Notice the yellow tint. It work, but I see that yellow tint over all the resulting renders.
This should be render as a embossed version of the picture, so grey.
Image
EDIT: Done a fallback check, on IRB 0.21 (use Irrlicht 0.8), the rendering is OK. But since I started using Irrlicht 1.9SVN something changed the rendering. (0.3, 0.31)
This has nothing to do with the changes of parameters.

EDIT: Found out that the Blue channel doesn't have any informations. (0) For some reason the RTT does not keep the blue channel.
Post Reply