Jump to content
  • Advertisement
Sign in to follow this  
furrymaster

Deferred lighting and problem with resolution

This topic is 2855 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, i have some problem with resolution of G-Buffer, for example if i have viewport resolution: 800X600 i have ~80 FPS, if i have 4 times less i have 200FPS, if i have 1280X1024 i have only 30 FPS. Do u have any idea why i`ve got so less frame rate? If you need parts of my code to recognize problem just write, i`ll paste it.
Thanks for any advices

Share this post


Link to post
Share on other sites
Advertisement
The speed of writing to and reading from a texture is dependent on its size. This speed is called the fill rate, and the more pixels in the texture, the longer it takes to fill.

In your textures, there are:

200 x 150: 30000 pixels
800 x 600: 480000 pixels - 16x bigger than 200 x 150.
1280 x 1024: 1310720 pixels - 44x bigger than 200 x 150.

So you can see from this that the speed of operations will be much slower on the largest texture, because it has 44 times more pixels for the graphics card to fill.

If you don't need the precision, keep the buffer a smaller size than the viewport, maybe half the size in each dimension? Experiment with different values to find out what you need in your application.

You could also try simplifying your shader code so that it takes less time for each fragment. If you want some help doing this, post it up and I'll take a look. And you may have unnecessary steps in your rendering code, so post that up too :P

Sput

Share this post


Link to post
Share on other sites
First of all - i need good precision because if game is in 1280 X 1024 resolution - it should be at this resolution yes? So i cannot change viewport size to smaller(i think).

Here is shader:(on link because its much code)
http://www.speedyshare.com/files/23940842/deferredshaders.zip

"Defferred steps":
1. set Blending off, set depth test to LEQUAL
2. starting render to depth G-buffer:
[source=cpp]
GLenum bufs[] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT};
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, deferredShadingFBO);
glDrawBuffers( 3, bufs);
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


3.render objects(with shader which name in ZIP is "basic") with VBO/VAO
4.stop render into depth G-buffer
5.start render into G-buffer lightSpace:
[source=cpp]GLenum bufs[] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT};
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, lightAccumFBO);
glDrawBuffers( 1, bufs);
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);

glBlendFunc( GL_ONE, GL_ONE);
glEnable( GL_BLEND);

glEnable( GL_DEPTH_TEST);
glDepthMask( GL_FALSE);
/*here are FBO textures in which i render into*/
glActiveTexture( GL_TEXTURE0);
glBindTexture( GL_TEXTURE_2D, normal);
glActiveTexture( GL_TEXTURE1);
glBindTexture( GL_TEXTURE_2D, material);
glActiveTexture( GL_TEXTURE2);
glBindTexture( GL_TEXTURE_2D, pos);


6. render lights(dir light shader u got at ZIP file)- rendering here is maximum efficient(i`m sure)
7.stop render into g-buffer light space:
[source=cpp]glDepthMask( GL_TRUE);
glBindTexture( GL_TEXTURE_2D, 0);
glActiveTexture( GL_TEXTURE2);
glBindTexture( GL_TEXTURE_2D, 0);
glActiveTexture( GL_TEXTURE1);
glBindTexture( GL_TEXTURE_2D, 0);
glActiveTexture( GL_TEXTURE0);
glBindTexture( GL_TEXTURE_2D, 0);

glEnable( GL_DEPTH_TEST);
//here is place objects without lighting effect
glDisable( GL_BLEND);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);



8. draw fullscreen quad with shader-"display"(in ZIP file)

Share this post


Link to post
Share on other sites
Quote:

hi, i have some problem with resolution of G-Buffer, for example if i have viewport resolution: 800X600 i have ~80 FPS, if i have 4 times less i have 200FPS, if i have 1280X1024 i have only 30 FPS. Do u have any idea why i`ve got so less frame rate? If you need parts of my code to recognize problem just write, i`ll paste it.
Thanks for any advices

Deferred shaders are often pixel bound, meaning that when increasing the resolution it will get much slower.

To solve your problem you have to optimize your render pipeline. One option is to reduce the resolution of a framebuffer for "some" operations. You don't need the full resolution for blurring or ssao, still lighting should be done in full resolution.

The next option is to optimize the format of your framebuffers. Try to use half-float instead of float. Get rid of unused channels. Bundle channels in one framebuffer so that in your pipeline you don't need to use always all framebuffers as input. Pack normals into just two channels instead of three.

The next option is to optimize the shaders. Try to avoid many texture fetches. Instead of rendering a fullscreen quad for each light, try to calculate the lighting of X lights in a single pass. Try to avoid dynamic branching.


Share this post


Link to post
Share on other sites
Quote:
To solve your problem you have to optimize your render pipeline. One option is to reduce the resolution of a framebuffer for "some" operations. You don't need the full resolution for blurring or ssao, still lighting should be done in full resolution.

Em, i get this FPS without HDR/MSAA/SSAO


Quote:

The next option is to optimize the format of your framebuffers. Try to use half-float instead of float. Get rid of unused channels. Bundle channels in one framebuffer so that in your pipeline you don't need to use always all framebuffers as input. Pack normals into just two channels instead of three.

I ll try this but really i dont have any idea how to pack it.



I have heard thats its possible to do something with stencil test. Can someone tall me more about this?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!