(Solved)Question about BlendOperation(SOLVED)

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Question about BlendOperation

Post by The_Glitch »

Wish we had the traffic Ogre3d does minus the Ogre3d.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Question about BlendOperation

Post by CuteAlien »

That's the kind of problems that are hard to impossible to solve without running them and experimenting with the results. Posting code-snippets is sometimes just not enough - at some point people need code that actually allows them to reproduce the problem directly.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Question about BlendOperation

Post by The_Glitch »

I'll post the small source file and the shader and see what happens from their.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Question about BlendOperation

Post by The_Glitch »

Okay here's the file in zip. It's the main source which is basically Irrlicht's Render To Texture example so it's really short. I even Included the one shader that refuse to work with Irrlicht.
All you have to do is point the directory to the Include hlsl shader file it's named saturation.


http://www.filedropper.com/main_2
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Question about BlendOperation

Post by CuteAlien »

OK, still can't test (as I don't have your textures and don't know what it should actually do), but one thing I noticed on a quick view - you don't do anything with your rendertargets. What I mean is - your scene-drawing seems to be independent of any stuff you do with rendertargets. Because you render the scene just normally, and as far as I can see no rendertargets are involved there. So you have several textures which now contain stuff, but which seem to be never used.

Thought there is also lot's of outcommented code. Not sure what to make of this. If you ask for help please throw out everything which is not related to the problem. It's hard to read code from other people, every explanation helps. Every unnecessary line confuses. Such an example should be minimal - doing nothing but exactly showing the problem. And you have to add the corresponding media so people can reproduce the problem. And you have to describe exactly what you expect to happen.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Question about BlendOperation

Post by The_Glitch »

That example was edited has you see from the commented out code I'll clean it up more. Also you must be referring to rt2 rt3. I left them because the problem was

Code: Select all

quad->getMaterial(0).MaterialType = ((video::E_MATERIAL_TYPE)saturation_pass);
        quad->getMaterial(0).setTexture(0, rt);
        quad->render()
nothing ever changed before hand. In my original code the render targets were all used I'll clean it up and repost.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Question about BlendOperation

Post by The_Glitch »

My bad I should have cleaned it up but I promise those were not the problem Originally.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Question about BlendOperation

Post by The_Glitch »

http://www.datafilehost.com/d/c1d5e018


Alright here's the source cleaned up, the main cpp should only load native Irrlicht meshes like a cube I also packaged the hlsl shader and the screenquad header and cpp. I also removed unused things to make it a lot more readable and easier to debug.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Question about BlendOperation

Post by CuteAlien »

You still draw the scene normally. And then draw a quad later it seems from code. I didn't read through all it - this are still 800(!) lines! So no idea why you need all that to show some problem. Especially as some code doesn't seem to be used at all - like you create blur-shaders but never assign them to anything. So what is this about? As a rule of thumb - if your code to show a problem is longer than 50 lines there's a very high chance you haven't really reduced it yet to the real problem.

But anyway - the main thing confusing me is that you render your scene normally - it then results obviously in your scene rendered normally. If you you work with rendertarget effects you usually never do that. You only render scenes into rendertargets.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Question about BlendOperation

Post by The_Glitch »

Are you sure your looking at my most recent version I uploaded above?

I only have the blur_shader callback in it but that shouldn't affect anything as there was no reason to call or use it as the saturation shader never worked properly.

Code: Select all

 
 
while(device->run())
    if (device->isWindowActive())
    {
        driver->beginScene(true, true, video::SColor(255, 0, 0, 0));
 
 
        if (receiver.IsKeyDown(KEY_ESCAPE))
            exit(0);
 
        
 
            driver->setRenderTarget(rt, true, true, video::SColor(255,0,0,0));
 
            // draw whole scene into render buffer
            smgr->drawAll();
            
 
            // set back old render target
            // The buffer might have been distorted, so clear it
            driver->setRenderTarget(0, true, true, 0);
        
        //// draw scene normally
        smgr->drawAll();
        env->drawAll();
        
    
        
        quad->getMaterial(0).MaterialType = ((video::E_MATERIAL_TYPE)saturation_pass);
        quad->getMaterial(0).setTexture(0, rt);
        quad->render();
 
 
Doesn't the code above draw into a RTT then tell Irrlicht to render normally. I was under the Impression that's what your suppose to do.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Question about BlendOperation

Post by Nadro »

Code: Select all

smgr->drawAll(); // This call is unnecessary
env->drawAll(); // This call is unnecessary
 
quad->getMaterial(0).MaterialType = ((video::E_MATERIAL_TYPE)saturation_pass);
quad->getMaterial(0).setTexture(0, rt);
quad->render();
In your code quad will cover all screen, so 2 first lines from above code are unnecessary. If you want to mix results from 2 first lines and quad rendering you should set proper BlendOperation and BlendFactor for quad material.

You can use this tool for find a proper blend settings:
http://www.andersriggelsen.dk/glblendfunc.php
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Question about BlendOperation

Post by CuteAlien »

The_Glitch wrote:I only have the blur_shader callback in it but that shouldn't affect anything as there was no reason to call or use it as the saturation shader never worked properly.
*sigh* - you ask for our time here. It's hard to get motivated to spend the time reading and understanding your code if you can't even be bothered to spend the minimal time you would need yourself to kick out the stuff which has nothing to do with the problem. Instead you expect us to waste time reading through 800 lines and figuring out ourself which part of it belongs to the problem and which does actually nothing (except wasting our time). Sorry, but just no!!!

Just think about it a moment - all you have to do is go over each line (which you wrote!) and kick it out if it has nothing to do with the problem. What we have to do is go over each line figure out where it's used, why you put it in there, wondering why it's not used if it's not or if we miss something, etc... it takes us far more time. That is *not* the way to ask for help with programming problems.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Question about BlendOperation

Post by The_Glitch »

Okay Nadro I'll try what you suggested but to be honest I've done that in the past and I believe the results were the same outcome.
@ CuteAlien I'll remove the callback also.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Question about BlendOperation

Post by CuteAlien »

@The_Glitch ... why not remove *every* line not needed instead? You know this technique of removing everything not related to the problem will also help yourself when hunting bugs (some people call it divide and conquer - you will need to do that over and over when programming, so learn to do it right).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Question about BlendOperation

Post by The_Glitch »

@CuteAlien I've already done this with other projects when debugging. This is just a small sample program. I already knew the callbacks and things were fine before hand I'm just stripping everything in the cpp for you guys.

http://www.filedropper.com/main_3


^
Added Nadro's suggestion but nothing changed but I'll keep it in mind for the future. I stripped all callbacks that were not being used at this time, removed all shader links except to the offending shader.
So there should not be any non used items in this main.cpp.
Post Reply