Swapping a fragment shader

Basically a gaussian blur need to write one pixel black and all the other close to it a proportional decreasing gray, that’s the reason of those decreasing values.

Does this tell you more?

Thanks.

Alberto

No, I know the theory about a gaussian blur filter, this was just about your application.
There are no many ways to make a texture not displaying. Either, your don’t specify the texture correctly or your texture coordinates are false.
To check this, use texture coordinates that you are sure about. If nothing is displayed, your texture is not specified correctly, if something is displayed, your last texture coordinates were false.

Want to know the truth? I also think that the vertex shader is not needed for doing this.

I need only to:

  1. for each fragment
  2. take its color
  3. add a fraction of its color to neighborhood fragments

Do I need also a Vertex shader to do this?

Thanks.

Alberto

Komat,

All the ATI tools Shader Analizer, RenderMonkey don’t install on my Windows Vista machine.

Is it a known limitation?

Thanks.

Alberto

They should work on the Vista. I have the Shader Analyzer installed on the Vista and it works. What is failing in your case? The instalation itself or start of the program?

Installation ended prematurely because of an error…

What stupid error message :frowning:

Setups are fine because they work on XP machines.

Alberto

I looked at the Shader analyzer installation. The version I was using was 1.42. When I tried to install the latest one (1.44), I got the same error. It is possible that the installer configuration has something broken with the gui part of it on the Vista. You can work around that by using following command which will force reduced gui functionality during the installation:

msiexec /qr /i installfile.msi

Komat,

Wow, where did you learn these tricks.

In the meantime I downloaded the Nvidia FX Composer. What do you think of this tool?

I wanted to know your opinion also on the following matter:

I need a shader to blur an existing valid opengl texture: do I always need a vertex shader? As a newbie looks illogical to me?

If i setup correctly a fragment shader will it be used on the texture without drawing anything?

Thanks so much,

Alberto

It its some time since I last used it. If your engine uses the effect frameworks and shading languages it supports (no GLSL as far as I know), it can be imho very useful. In other cases it can be used for fast prototyping of some effect. I used it only for the prototyping because my shader generation pipeline is incompatible with it.

I need a shader to blur an existing valid opengl texture: do I always need a vertex shader?

You do not need the vertex shader. If you use the gl_TexCoord built-in varyings to pass any data you need to the fragment shader, it can work with the fixed function vertex pipeline. It can be also used with the fragments generated by the glDrawPixels or glBitmap functions (so no vertex processing at all). However in this case I would be worry about drivers implementing that incorrectly or using emulation.

If i setup correctly a fragment shader will it be used on the texture without drawing anything?

The shaders are applied during drawing operations (i.e. operations generating fragments) you can not apply them without drawing something.

Yes, look like FX COmposer has some problems with GLSL. Now I switch back to RenderMonkey to see if I can see my shader at work.

Following your reasoning, so I can define and link only a vertex shader and expect to find the right coordinates in the gl_TexCoord.xy, then to make something happen I will draw a white square on my texture just to put the shader in action: right?

Can all of this be simulated using the RenderMonkey?

Thanks so much again,

Alberto

I do not understand what do you exactly meant by that. If you meant that you wish to draw rectangle on the screen which contains blured content of the original texture, you need to do following:

  • [li]Create program object which will contain only a pixel shader. This pixel shader will take single coordinates from gl_TexCoord[ 0 ], and combines texture samples at various offsets from those coordinates.[]Bind the texture in question and the program object.[]Draw rectangle on desired part of the screen. Each vertex of the rectangle must have texture coordinates (for texture unit 0) which correspond to corresponding corner of the texture. The color of the rectangle is irrelevant unless the shader utilizes the gl_Color built-in varying.

if you wish to store the blured content back into the original texture, you would need to do the rendering into different texture or back buffer (if possible) and copy it back into the original texture (or switch the textures if you render into the different texture).

I assume that it is possible however I never used the RenderMonkey beyond looking at the examples it provides.

Where is the interest of not using a vertex shader…I mean it sounds for me, a source of many problems (driver support…). When you write both, vertex and fragment, you don’t have to think and you are sure that the vertex shader will do nothing more and nothing less than what you have told it to do.

Komat,

I forget to mention I am drawing on texture using a FBO and I’d like to see each triangle drawn blurred when the fragment shader is active.

Now I am concerned about mixing FBO and shaders: is it possible? Maybe I should use the standard gl funcs to alter the active texture?

Thanks so much again. I’ll hope soon to see this magic blur on my texture !!!

Alberto

You need to draw everything normaly into one texture. Then you need to render into different texture using the bluring shader and sampling from the texture containing the normal scene.

Now I am concerned about mixing FBO and shaders: is it possible?

It is possible.

Komat,

What do you mean exacly with “Then you need to render into different texture” ?

It is something we have never did before…

Thanks.

Alberto

Since what you are doing require multiple passes., you need to draw everything in a texture instead of the screen (or draw on the screen and copy in a texture but it is slower) with a fbo (framebuffer object). Then, you use the texture as a texture input for your shader and blur it.

More information about how to render to a texture here

dletozeun,

I have this already working, my shadow teture is working perfecty.

What I can’t understand is “Then, you use the texture as a texture input for your shader and blur it”. If I don’t draw anything the fragment shader won’t be applied. Right?

Thanks,

Alberto

Something like:


// Init textures
glGenTextures(1, &normal_image);
glGenTextures(1, &blured_image);
...

// Rendering of the normal scene.

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, some_fbo );
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, normal_image, 0);

render_the_scene_you_wish_to_blur() ;

// Generation of the blur into different texture.

glActiveTexture(GL_TEXTURE0) ;
glBindTexture(GL_TEXTURE2D, normal_image ) ;
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, blured_image, 0);

render_quad_using_the_bluring_shader_and_saming_from_texture_unit0()

glActiveTexture(GL_TEXTURE0,) ;
glBindTexture(GL_TEXTURE2D, 0 ) ;

// Do anything you wish with the blured_image texture


Komat,

Why should I render 1,000,000 quads twice? Isn’t enough to render it on the first texture than to draw one Quad with the same size of the texture to ‘activate’ the shader effect?

Thanks again,

Alberto