Glow OpenGL shader ... NOOB!
-
- Posts: 260
- Joined: Thu Apr 17, 2008 1:38 pm
- Location: Brasopolis - Brazil
Glow OpenGL shader ... NOOB!
Hello guys,
I'm trying to work with shaders and made some good progress, making glass and another tratments here. Fine!
Now, I want to give one more step, and working with glow or blur effects, within shaders.
Studying around, I think I understood the steps to make a glow shader. Correct me if I misunderstood:
1. Create a new framebuffer;
2. Render the glowing parts in this framebuffer;
3. Blur them (gaussian);
4. Proceed with the rendering normally;
5. SUM that "new" framebuffer to the current framebuffer;
6. Let's go to the screen.
So, first of all, I need to learn how to create a new FBO (Frame Buffer Object).
I saw that I have to use this void function:
glGenFramebuffersEXT(x,y);
But, seems that I cannot call this function inside the Irrlicht fragment shader.
How can I create a new framebuffer using shaders inside Irrlicht?
Thanks, and don't forget, I'm newbie
I'm trying to work with shaders and made some good progress, making glass and another tratments here. Fine!
Now, I want to give one more step, and working with glow or blur effects, within shaders.
Studying around, I think I understood the steps to make a glow shader. Correct me if I misunderstood:
1. Create a new framebuffer;
2. Render the glowing parts in this framebuffer;
3. Blur them (gaussian);
4. Proceed with the rendering normally;
5. SUM that "new" framebuffer to the current framebuffer;
6. Let's go to the screen.
So, first of all, I need to learn how to create a new FBO (Frame Buffer Object).
I saw that I have to use this void function:
glGenFramebuffersEXT(x,y);
But, seems that I cannot call this function inside the Irrlicht fragment shader.
How can I create a new framebuffer using shaders inside Irrlicht?
Thanks, and don't forget, I'm newbie
Professional Software Developer and Amateur Game Designer
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
Re: Glow OpenGL shader ... NOOB!
The method used with irrlicht is to create a render texture, render the glowing objects to that, then later pass that as a parameter to another shader to sum them.
-
- Posts: 260
- Joined: Thu Apr 17, 2008 1:38 pm
- Location: Brasopolis - Brazil
Re: Glow OpenGL shader ... NOOB!
Ah ... good, I made this with another shader, so is the correct manner.
But, now I have to proceed with the next step. How apply an image treatment.
Imagine that I have to make an Infra Red view. I think that changing the material of everything in the world isn't the best way.
So, how can I apply a shader in the final rendering result?
Thanks guys.
But, now I have to proceed with the next step. How apply an image treatment.
Imagine that I have to make an Infra Red view. I think that changing the material of everything in the world isn't the best way.
So, how can I apply a shader in the final rendering result?
Thanks guys.
Professional Software Developer and Amateur Game Designer
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
Re: Glow OpenGL shader ... NOOB!
There`re plenty of postprocess shader examples around, why don`t you simply take one and check the code?
Of course you`ll need to modify the shaders a bit, but the project on Irrlicht side will be ready for you.
Of course you`ll need to modify the shaders a bit, but the project on Irrlicht side will be ready for you.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
-
- Posts: 260
- Joined: Thu Apr 17, 2008 1:38 pm
- Location: Brasopolis - Brazil
Re: Glow OpenGL shader ... NOOB!
Hi Shadowslair,
So, this is called postprocess? I really found some nice postprocessing examples, but I was not pretty sure that is the thing. Now I have a path to go.
Thanks for the answer, let's work!
So, this is called postprocess? I really found some nice postprocessing examples, but I was not pretty sure that is the thing. Now I have a path to go.
Thanks for the answer, let's work!
Professional Software Developer and Amateur Game Designer
-
- Posts: 21
- Joined: Thu Feb 20, 2014 7:39 pm
Re: Glow OpenGL shader ... NOOB!
No you render your world as normal but to two different buffers at the same time. One will contain all "glow" materials. The other will contain all normal stuff. Then you render a single quad that covers the whole screen with a shader to which you pass the two framebuffers that you have created in the previous pass. It is this shader that samples both textures such that you get the blur, glow, night vision etc. effect.
Re: Glow OpenGL shader ... NOOB!
Support this,
Mind helping us as newbies by providing a beginning sample code of how to apply render to texture as multi shading?
Sorry, I tried searching over many posts but most of them are too old and the links are broken.
We only need really simple sample code, for the good of the rest like us as well.
Much appreciated.
Thanks =)
Mind helping us as newbies by providing a beginning sample code of how to apply render to texture as multi shading?
Sorry, I tried searching over many posts but most of them are too old and the links are broken.
We only need really simple sample code, for the good of the rest like us as well.
Much appreciated.
Thanks =)
Re: Glow OpenGL shader ... NOOB!
Some examples of postprocessing were posted here about two or three years ago. Try googling this site.
Re: Glow OpenGL shader ... NOOB!
I tried for weeks now TnT but the source files had been removed TnT
please provide us newbie a guide TnT
please provide us newbie a guide TnT
Re: Glow OpenGL shader ... NOOB!
It works like photoshop. You render to a render target texture. Then reset the render target to the framebuffer. The texture is now available to use as a texture, so use it to texture a quadrilateral with a shader. The shader can simply write the texture colour, or it can change it somehow. For example, by reading the texture values around the (u, v) point and averaging them, you can blur the scene. Above you have been told that glow needs two textures, but you can achieve a rudimentary glow by reading the texture and, if the colour is 'bright', increase it even more. Also, if the colour is not so bright, sample the texture around the point and if there are any bright points nearby, increase the intensity inversely proportional to the distance.
But you can do whatever photoshop filters do. For example, by also reading another texture, say a grid, you can multiply the two textures to have the grid appear over the scene.
But you can do whatever photoshop filters do. For example, by also reading another texture, say a grid, you can multiply the two textures to have the grid appear over the scene.
Re: Glow OpenGL shader ... NOOB!
thanks bro, I am well known to graphics theory, the only problem I had is that I wonder why my code isn't working, so would like to have a simple example of how to use it properly.
-
- Competition winner
- Posts: 523
- Joined: Tue Jan 15, 2013 6:36 pm
Re: Glow OpenGL shader ... NOOB!
You might should post your code as no one is most likely to post there's. I believe with Irrlicht it's actually easier to do a glow shader then most other engines. I remember seeing a example of one on the forums and the shader was about 12 lines mostly whitespaces. The hardest part is most likely just the rtt. Let me know if you would like to see it.
Re: Glow OpenGL shader ... NOOB!
This is where i setup 2 textures (2 shaders) :
This is where i started to integrate 2 shaders into 1 scene node, but failed.
Code: Select all
ITexture * rtt0 = videoDriver->addRenderTargetTexture(core::dimension2d<u32>(256,256), "RTT0");
body->getMaterial(0).setTexture(0, rtt0);
ITexture * rtt1 = videoDriver->addRenderTargetTexture(core::dimension2d<u32>(256,256), "RTT1");
body->getMaterial(0).setTexture(1, rtt1);
This is where i started to integrate 2 shaders into 1 scene node, but failed.
Code: Select all
// set render target texture
node->setVisible(false);
videoDriver->setRenderTarget(rtt0, true, true, video::SColor(0,0,0,0));
node->getMaterial(0).MaterialType = (E_MATERIAL_TYPE) gShaderA;
node->render();
videoDriver->setRenderTarget(rtt1, false, false, video::SColor(0,0,0,0));
node->getMaterial(0).MaterialType = (E_MATERIAL_TYPE) gShaderB;
node->render();
// draw whole scene into render buffer
sceneManager->drawAll();
// set back old render target
// The buffer might have been distorted, so clear it
videoDriver->setRenderTarget(0, true, true, video::SColor(0, 0, 0, 0));
node->setVisible(true);
sceneManager->drawAll();
-
- Competition winner
- Posts: 523
- Joined: Tue Jan 15, 2013 6:36 pm
Re: Glow OpenGL shader ... NOOB!
I can't say for sure but I did a quick glance and I know Irrlicht doesn't like a single node to have 2 shaders applied. Is your effect all in one shader or is it 2 separate shaders?