My question hasn't been solved yet
I have used this algorithm to apply the bloom effect to the scene( As suggested in the book "More OpenGL Game Programming" ):
1.Render the scene as usual
2.Render the same scene to the texture
3.blur the texture for N times
4.apply the texture to the scene using additive blending.

So, in the 2nd step, we need to render the same scene again. It's not good, since it decreases the FPS.

To render the scene to texture, I have used FBO with a GL_RGB texture attached to it.My friend was talking about the HDR effect and he said that I should use 64 bits floating point textures instead. Is he correct?
He also said that to apply the post process effects, I don't need to render the same scene again.Is he correct?

Alfonse Reinheart

01-08-2011, 10:14 PM

My friend was talking about the HDR effect and he said that I should use 64 bits floating point textures instead. Is he correct?

That depends. Do you want real bloom, or the silly fakey bloom you see horribly abused in far too many games these days?

Bloom should only occur when the light intensity from a particular location significantly exceeds maximum value at that wavelength (red, green, and/or blue). Furthermore, the quantity of bloom should be proportional to the quantity of light from that location.

Since colors clamped on the range (0, 1) can only test whether the light is at the maximum value or not, you don't have any way to control bloom except to say that anything above a certain value blooms. This looks horrible, because it basically means that anything semi-bright will bloom.

What HDR gives you is the ability to set the maximum light quantity independently of the actual light intensity. Thus, the resulting light reflected from a surface can be higher than this maximum. Since you can detect brighter-than-bright areas of light reflectance, you can now control bloom properly.

Personal note: game developers who misuse bloom should be flogged.

He also said that to apply the post process effects, I don't need to render the same scene again.Is he correct?

Think about it. Rendering the scene again will naturally produce the same results. Results that you already have since you rendered it once.

If you already have an answer, why bother computing it again?

Ehsan Kamrani

01-08-2011, 10:25 PM

Think about it. Rendering the scene again will naturally produce the same results. Results that you already have since you rendered it once.
If you already have an answer, why bother computing it again?
It's correct that I have rendered it once, but I have rendered it to the *default frame buffer*--not to the texture.
To render to texture, I have used FBO for offscreen rendering. This is my question: I render the scene as usual, but I can't use FBO, since nothing is rendered to the default frame buffer if I use FBO. Is there a way to render the scene to the default frame buffer and *also* render it to the texture simultaneously?

ugluk

01-08-2011, 11:22 PM

I ain't an expert in shaders and FBOs, but I think you can take your texture and render it in a quad, which goes into the framebuffer. But before that happens folks usually write several fragment shader stages doing bloom, anti-aliasing and other things.

Alfonse Reinheart

01-09-2011, 12:39 AM

Is there a way to render the scene to the default frame buffer and *also* render it to the texture simultaneously?

No, but why would you want to?

Just build up what you want to draw as a renderbuffer or texture, then draw it out to the screen. This is common practice, and essential if you want to use HDR.

Ehsan Kamrani

01-09-2011, 12:52 AM

If you see the algorithm , you understand what I'm talking about:
1.Render the scene as usual
2.Render the same scene to the texture
3.blur the texture for N times
4.apply the texture to the scene using additive blending.
(see stage 2).
This algorithm is from the book "More OpenGL Game Programming". So, is it an incorrect algorithm?

ZbuffeR

01-09-2011, 01:22 AM

Ehsan:
1.Render the scene to the texture
2.Use this unblurred texture to fill default frame buffer (render textured quad, use a blit, as your prefer)
3. (same as above)
4. (same as above)

You see, no need to render twice the scene.

Ehsan Kamrani

01-09-2011, 01:51 AM

Ehsan:
1.Render the scene to the texture
2.Use this unblurred texture to fill default frame buffer (render textured quad, use a blit, as your prefer)
3. (same as above)
4. (same as above)

You see, no need to render twice the scene.
Thanks ZBuffer. But What about the quality of the texture? I have currently used a 512 * 512 texture. Then it seems with your manner,I must render to a bigger texture? What about multisampling? Does FBO take the multisampling into account?

dehebo

01-09-2011, 04:03 AM

you can use more than one render target.
Full size for where you render your initial 'base' scene.
Then you can scale that down to another smaller render target for your blur passes etc.

Look around on the web there are many approaches for doing bloom; how devs handle the blurring, scaling(some upscale after blurs etc - think this is how handled in the latest halo games).

I dont have any links at hand at the moment but it is a very popular question on boards like these, also check out the gamedev.net forums - its a popular question there too.

ugluk

01-09-2011, 04:52 AM

Look at what this poster wrote to me and then removed himself from the topic:

Let's continue the discussion here then. Which part of my reply is wrong? I'm a noob, I freely admit it and I might learn something from a mistake.

admins: You can delete any of my posts, I've made, if you like. I am grateful for every reply I get, wrong or right.

Ehsan Kamrani

01-09-2011, 02:58 PM

ZBuffer,
It seems that the texture dimensions are really important. If I use a 1024 * 1024 texture, I don't get good results--The texture quality isn't good enough in my 22" monitor with 1680 * 1050 resolution. However if I use a 2048 * 2048 texture, I get good results( but the frame rate decreases to 30 fps ). So it seems that the quality of texture is depend on the resolution of the monitor?Also, it seems that rendering to a bigger texture really affects the FPS?

ugluk,
I sent you a "private message", but you published it here! This forum is for one purpose.peoples are gathered here to talk about their programming skills and programming troubles. so if u are not an expert please act like one. it's OpenGL board not a kindergarten.

ugluk

01-09-2011, 03:37 PM

Ehsan, you enlighten us all with your utterances and exhortations.

Alfonse Reinheart

01-09-2011, 03:42 PM

It seems that the texture dimensions are really important. If I use a 1024 * 1024 texture, I don't get good results--The texture quality isn't good enough in my 22" monitor with 1680 * 1050 resolution.

If you know your screen is 1680x1050, is there some reason you can't just create a 1680x1050 texture?

Non-power-of-two textures have been around in one form or another for the better part of a decade.

This forum is for one purpose.peoples are gathered here to talk about their programming skills and programming troubles. so if u are not an expert please act like one. it's OpenGL board not a kindergarten.

Well, let's see. He answered your question. His answer was correct: you should be rendering to a texture (or other intermediate form), then using that to do your bloom. And his response was reasonably well-stated.

So I'm afraid I don't see your problem with it. And I certainly don't see the need for your vitrol nor your asking him to remove his post.

Ehsan Kamrani

01-09-2011, 03:43 PM

Ehsan, you enlighten us all with your utterances and exhortations.
Thanks buddy

Ehsan Kamrani

01-09-2011, 03:52 PM

If you know your screen is 1680x1050, is there some reason you can't just create a 1680x1050 texture?

Non-power-of-two textures have been around in one form or another for the better part of a decade.

OK, Thanks.But what about decreasing the FPS while rendering to the bigger textures? Does FBO support multisampling while rendering the scene to texture?

Well, let's see. He answered your question. His answer was correct: you should be rendering to a texture (or other intermediate form), then using that to do your bloom. And his response was reasonably well-stated.

So I'm afraid I don't see your problem with it. And I certainly don't see the need for your vitrol nor your asking him to remove his post.
I asked him with a "personal message" and I "removed it". Then he has published every happening here--My personal message and removing the post.He could send a personal message to me. why he published it in the forum?

Alfonse Reinheart

01-09-2011, 04:42 PM

But what about decreasing the FPS while rendering to the bigger textures?

What about it? Bloom isn't free; it's going to cost you framerate. Just like any effect.

Considering that your alternative was to render the scene twice, I think this is probably better.

Does FBO support multisampling while rendering the scene to texture?

If your hardware is good enough (OpenGL 3.3 or better), there are multisample textures. Otherwise no.

Then again, using the method you stated at the beginning wouldn't get you multisample either. Not for the actual bloom texture.

ZbuffeR

01-09-2011, 04:49 PM

Does FBO support multisampling while rendering the scene to texture?
If your hardware is good enough (OpenGL 3.3 or better), there are multisample textures. Otherwise no.
For older hardware, and especially if your work in full screen or avoid other windows going over your rendering, you can render to main framebuffer with any classic multisampling, then glTexCopySubImage2D the result to create the texture to be blurred by a shader on a FBO (if you need to keep first render pass intact).

Ehsan Kamrani

01-09-2011, 05:09 PM

Then again, using the method you stated at the beginning wouldn't get you multisample either. Not for the actual bloom texture.
But I have requested a window with multisampling--I have requested 8 samples per pixel.
with that method, I don't need to have a texture with multisampling, since I blur the texture for N times and blend it with the contents of the frame buffer.
Here are 2 screen shots of the scene:
Bloom1 (http://gwproject.zehnezibaco.com/dhhn_zyba_wblag/Beach_Village_Gallery_files/Media/bloom5/bloom5.jpg?disposition=download)
Bloom2 (http://gwproject.zehnezibaco.com/dhhn_zyba_wblag/Beach_Village_Gallery_files/Media/bloom6/bloom6.jpg?disposition=download)
(BTW, I know that I need to add auto exposure to my engine. As you see, the first scene is so bright ).
_________________________________________________
Regarding this post (http://www.gamedev.net/topic/480332-fbo-and-multisampling/) , I can use glRenderbufferStorageMultisampleEXT instead of glRenderbufferStorageEXT, So I can use FBO + multisampling. However, the replies of the aforementioned link suggest that glRenderbufferStorageMultisampleEXT function is not supported in ATI hardware.But what about todays hardwares? Can I use from glRenderbufferStorageMultisampleEXT function on both NVidia and ATI GPUs?

ugluk

01-09-2011, 06:02 PM

I already wrote about why I posed your message. To discuss your comments further. Apparently you have difficulty memorizing and following what other people write.

For example, I'm interested in what ZBuffer had in mind when he wrote about blitting the rendered-to texture. Maybe the extension that allows you to draw a texture as a sprite (I don't recall the name)?