Anyone mind posting there working gaussian blur shader?

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!
Post Reply
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Anyone mind posting there working gaussian blur shader?

Post by The_Glitch »

Before I get slammed I've scoured the Internet and have tried implementing the various shaders I've found some don't work at all and others strange results occur.

Some where straight out of render monkey with the weights provided in the shader and I could not get it to work properly, no shader compile errors either.

I fear it may be due to the screenquad node as I found a topic here about it.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Anyone mind posting there working gaussian blur shader?

Post by The_Glitch »

Let me state that I have some working blur shaders I'm just not so sure there Gaussian Blur shaders as when I use Gaussian filter in Photoshop as a test on an image it looks better.
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Re: Anyone mind posting there working gaussian blur shader?

Post by ent1ty »

irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Anyone mind posting there working gaussian blur shader?

Post by The_Glitch »

Thanks entity I have a gaussian blur shader similar to yours weights are provided in the shader but it never worked properly. I'll convert yours to hlsl.

Thanks Glitch.
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: Anyone mind posting there working gaussian blur shader?

Post by REDDemon »

hlsl have that weird 0.5 pixel offset thing..
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Anyone mind posting there working gaussian blur shader?

Post by The_Glitch »

@ REDDEMON

What do you mean?
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Anyone mind posting there working gaussian blur shader?

Post by Nadro »

@The_Glitch
You can find more info here:
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx

In D3D10+ you don't need any offsets, this "feature" is only related to D3D9.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Anyone mind posting there working gaussian blur shader?

Post by The_Glitch »

Yeah I think I read this in the past.

I thought the ScreenQuad Node handled this automatically. I could be wrong though.

In funtction below shiftx and shifty is this not what these lines are doing?

Code: Select all

 
 
CScreenQuadSceneNode::CScreenQuadSceneNode(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id) :ISceneNode(parent, mgr, id), hardwareBuffer(false)
{
    f32 shiftX, shiftY;
    core::dimension2d<u32> currentResolution;
 
    /** Here we initialize the vertices of the screen Aligned quad */
 
    currentResolution = mgr->getVideoDriver()->getScreenSize();
 
    aabb.reset(0, 0, 0);
 
    shiftX = 0.5f / currentResolution.Width;    //This small shift is necessary to compensate the texture sampling bias // This line Here
    shiftY = 0.5f / currentResolution.Height;   //It avoids that our effect becomes too blurry.   // This Line Here
 
    indexBuffer = new scene::CIndexBuffer(); // ";" is missing in my orig code.
    indexBuffer->addIndex(0); //0
    indexBuffer->addIndex(1);//1
    indexBuffer->addIndex(2);//2
    indexBuffer->addIndex(1);//1
    indexBuffer->addIndex(3);//3
    indexBuffer->addIndex(2);//2
 
    video::S3DVertex2TCoords vertices[4];
    
    vertices[0] = video::S3DVertex2TCoords(-1.0f, -1.0f, 0.0f, 0.0f, 0.0f, -1.0f, video::SColor(255, 255, 255, 255), shiftX, shiftY, shiftX, shiftY);
    vertices[1] = video::S3DVertex2TCoords(1.0f, -1.0, 0.0f, 0.0f, 0.0f, -1.0f, video::SColor(255, 255, 255, 255), 1.0f + shiftX, shiftY, 1.0f + shiftX, shiftY);
    vertices[2] = video::S3DVertex2TCoords(-1.0f, 1.0, 0.0f, 0.0f, 0.0f, -1.0f, video::SColor(255, 255, 255, 255), shiftX, 1.0f + shiftY, shiftX, 1.0f + shiftY);
    vertices[3] = video::S3DVertex2TCoords(1.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, video::SColor(255, 255, 255, 255), 1.0f + shiftX, 1.0f + shiftY, 1.0f + shiftX, 1.0f + shiftY);
 
    // vertex descriptor no. 1 is for S3DVertex2TCoords
    vertexBuffer = new scene::CVertexBuffer<video::S3DVertex2TCoords>(mgr->getVideoDriver()->getVertexDescriptor(1));
 
    vertexBuffer->addVertex(vertices[0]);
    vertexBuffer->addVertex(vertices[1]);
    vertexBuffer->addVertex(vertices[2]);
    vertexBuffer->addVertex(vertices[3]);
 
    /** Now we proceed to initialize the appropriate settings for the material we are going to use
    We can alter these later, but for the time being, initializing them here will do no harm */
 
    material.Lighting = false;                  //No need for lighting.
    material.BackfaceCulling = false;   //not needed, but simplifies things
    material.MaterialType = video::EMT_LIGHTMAP_ADD;
    setAutomaticCulling(scene::EAC_OFF);        //We don't need this scene node to be culled because we render it in screen space.
    material.ZBuffer = video::ECFN_ALWAYS;
    material.ZWriteEnable = false;
    
    
    for (u32 i = 0; i < _IRR_MATERIAL_MAX_TEXTURES_; ++i)
    {
        material.TextureLayer[i].TextureWrapU = irr::video::ETC_CLAMP;
        material.TextureLayer[i].TextureWrapV = irr::video::ETC_CLAMP;
    }
    
    
}
 
 
Post Reply