(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

(Solved)Question about BlendOperation(SOLVED)

Post by The_Glitch »

I'm trying to perform a operation on an Image that was a rtt, and it's basically suppose to get the threshold area of a texture for bloom and non bloom with a float for increasing and decreasing. My question is do I have to use a certain blend type ex MIIN, or MIN_FACTOR. The reason I ask is that the pixel shader doesn't seem able to affect the rtt at all no changes. I've tested the pixel shader in RenderMonkey and it does work, I've also tested the Vertex Shader to verify and it does work also.
Last edited by The_Glitch on Mon Dec 01, 2014 9:07 am, edited 1 time in total.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Question about BlendOperation

Post by The_Glitch »

Image


I've gotten post processing going a lot better thanks to mongoose7. I was setting the switch to default frame buffer wrong. Also discovered that the pixel shader to extract bloom area's of a texture doesn't work in Irrlicht so I was wondering If I needed to set a special parameter like BlenOperation.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Question about BlendOperation

Post by The_Glitch »

Code: Select all

 
saturate((Color – Threshold) / (1 – Threshold));
 
Simple Pixel shader line of code

Irrlicht doesn't like this shader line in hlsl.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Question about BlendOperation

Post by CuteAlien »

Sorry, I really wish I could help. Only thing I can tell is that Irrlicht has nothing to do with the shaders themself (those are just passed on to the graphic card). So it's more likely about accessing the texture. So the problem is likely not in the shader but in the way you pass that texture to the shader.
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 »

It's okay atleast you said something. I'm not doing anything different then other shaders.

Code: Select all

sampler TextureSampler : register(s0); 

That's it only one texture for the shader. I'll even post the shader it's that simple of a shader.

Code: Select all

 
sampler TextureSampler : register(s0);
 
// Get the threshold of what brightness level we want to glow
 
float Threshold = 0.3;
 
     float4 PixelShader(float2 texCoord : TEXCOORD0) : COLOR0
 
{
      float4 Color = tex2D(TextureSampler, texCoord);
 
// Get the bright areas that is brighter than Threshold and return it.
 
    return saturate((Color – Threshold) / (1 – Threshold));
}
 
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Question about BlendOperation

Post by CuteAlien »

I think you are probably looking in the wrong place. It's likely not the shader, but the way the texture is passed. Which means c++ code, not shader code. Like for example you might try to pass the texture while you still render into it. Or you pass the wrong texture. Or the texture is still locked (not sure if that would really be a problem actually).
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 »

Code: Select all

 
                driver->setRenderTarget(rt4, true, true, video::SColor(255, 0, 0, 0));  // Render the quad with the orginal scene texture
 
        quad->getMaterial(0).MaterialType = ((video::E_MATERIAL_TYPE)saturation_pass); // Here we "try" to extract the bloom areas of the scene and render it into the above target rt4
        quad->getMaterial(0).setTexture(0, rt);
        quad->getMaterial(0).UseMipMaps = false;
        quad->render();
               driver->setRenderTarget(0, true, true, 0);
 
/*
Further rendering things are done here but the problem lies above^^
*/
 
This is what I'm doing.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Question about BlendOperation

Post by The_Glitch »

Image
Image
Image
Image


Just wanted to test my post processing further using fixed function pipeline only shader I used is a blur shader which works well. I then used a second screenquad the uses the

Code: Select all

BlendOperation EBO_MAX_FACTOR
and it's pretty close at getting bloom but a shader is still much better. So I've narrowed down nothing on the Irrlicht side to fix the problem as to why it hates the bloom extraction shader.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Question about BlendOperation

Post by CuteAlien »

I'm not very familiar with rendertargets. But I think you have to reset setRenderTarget always (like you do here for rt4). Maybe you forgot to do that for rt?
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 »

Code: Select all

 
                driver->beginScene(true, true, video::SColor(0, 0, 0, 0));
 
 
        driver->setRenderTarget(rt, true, true, video::SColor(255, 0, 0, 0));
 
        smgr->drawAll();
 
                driver->setRenderTarget(0, true, true, 0);
 
 

No this code above is before the code I posted earlier. I do appreciate the help though. I know it's not me setting up post processing as I tested it on the fixed function and it works just not very well though.
I'll probably just package up the small render to texture app and send to you since you suggest it's Irrlicht side of things.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Question about BlendOperation

Post by mongoose7 »

Probably too early to send test code to CuteAlien as the problem is more likely to be in your code. For example, you posted this:
The_Glitch wrote:

Code: Select all

 
                driver->setRenderTarget(rt4, true, true, video::SColor(255, 0, 0, 0));  // Render the quad with the orginal scene texture
 
        quad->getMaterial(0).MaterialType = ((video::E_MATERIAL_TYPE)saturation_pass); // Here we "try" to extract the bloom areas of the scene and render it into the above target rt4
        quad->getMaterial(0).setTexture(0, rt);
        quad->getMaterial(0).UseMipMaps = false;
        quad->render();
               driver->setRenderTarget(0, true, true, 0);
 
/*
Further rendering things are done here but the problem lies above^^
*/
 
This is what I'm doing.
This shows that you are drawing the screen quad into rt4. You are not drawing it to the screen, though. You should probably show CuteAlien how you get the contents of rt4 onto the screen.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Question about BlendOperation

Post by The_Glitch »

Code: Select all

                
                driver->setRenderTarget(rt4, true, true, video::SColor(255, 0, 0, 0));
        
                quad->getMaterial(0).MaterialType = ((video::E_MATERIAL_TYPE)saturation_pass);
        quad->getMaterial(0).setTexture(0, rt);
        quad->render();
        
 
        driver->setRenderTarget(0, true, false, 0);
 
                      ////// Normal Rendering is done here just to test If the above even made it this far.
                quad->getMaterial(0).MaterialType = ((video::EMT_LIGHTMAP_ADD));
        quad->getMaterial(0).setTexture(0, rt2);
        quad->getMaterial(0).setTexture(1, rt4);
        quad->render();
 
 
 
 
 


Well I've edited this code in my project a lot for debugging purpose's but this is basically what I'm doing.
I'm pretty sure it's me I know and hope it's not Irrlicht I'm just having a hard time finding it. When I use Irrlicht's built in materials It seems to work fine.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Question about BlendOperation

Post by mongoose7 »

I know nothing about EMT_LIGHTMAP_ADD; I think it is a Quake Map shader. But according to Example 22, it needs two sets of texture coordinates. Why not write your own shader to add the two textures, which is what I guess you are trying to do.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Question about BlendOperation

Post by The_Glitch »

Well I'm only use Irrlicht shaders to work out the problem why the bloom extraction shader doesn't work. The saturation_pass you see above applied to the screenquad.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Question about BlendOperation

Post by The_Glitch »

Just thought I'd be more clear

Code: Select all

EMT_LIGHTMAP_ADD 
is just to take my results and add them the screenquad already takes care of the texture coordinates. I'm just mainly trying to find why the shader I posted above the

Code: Select all

saturation_pass
has no effect on the Image that's passed to the screenquad.


Were's NADRO when u need him LOL
Post Reply