Logo by simon.snake - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Did you know ? you can use LaTex inside Postings on fractalforums.com!
 
*
Welcome, Guest. Please login or register. October 24, 2020, 11:55:41 AM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Best way to split GLSL into tiles?  (Read 1316 times)
0 Members and 1 Guest are viewing this topic.
Softology
Conqueror
*******
Posts: 120


« on: November 21, 2012, 01:11:59 AM »

I had a peek at the Fragmentarium source code, but couldn't find the relevant part.

What is the best way to render a shader as multiple smaller sub-tiles (to avoid the default 2 second video driver timeouts)?

At the moment I am using loops and glviewport, like...

Code:
          for yloop:=0 to ytiles-1 do
          begin
               for xloop:=0 to xtiles-1 do
               begin
                    glviewport(xloop*xtilesize,yloop*ytilesize,xloop*xtilesize+xtilesize,yloop*ytilesize+ytilesize);
                    glBegin(GL_QUADS);
                    glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1, -1);
                    glTexCoord2f( 1.0, 0.0 ); glVertex2f(  1, -1);
                    glTexCoord2f( 1.0, 1.0 ); glVertex2f(  1,  1);
                    glTexCoord2f( 0.0, 1.0 ); glVertex2f( -1,  1);
                    glEnd;
                    glfinish;
                    application.processmessages;
               end;
          end;

Which does work, but seems to really slow down the rendering.  I think this is due to the glfinish having to wait for the GPU to finish all its work before continuing with the next tile, but if I don't include that then the video card will timeout.

Any ideas for improving the above method without the slowdown?  How does Fragmentarium handle the issue?

Thanks,
Jason.
Logged
eiffie
Guest
« Reply #1 on: November 21, 2012, 06:07:01 PM »

Are you sure it is not something you do in processMessages like a screen refresh? That would slow things down.
Logged
Softology
Conqueror
*******
Posts: 120


« Reply #2 on: November 22, 2012, 04:15:10 AM »

Commenting processmessages didn't make a difference.  I only include it so the app doesn't get the dreaded Windows "not responding" title bar during intensive shaders.

Finding that I was using way more tiles than necessary (as in each subtile was around 10x10 pixels in size) helped get the speed back up.

The above method/code still leads to a slight delay compared to a single full screen qaud.  As an example if a single quad gives 1 fps then splitting the screen into 9 sub quads gives 0.5 fps.

It isn't a huge deal.  As long as I can avoid the GPU timeouts it is acceptible for the time being.  But if there is a smarter way to divide the screen up I am ready to be educated.

Thanks,
Jason.
« Last Edit: November 22, 2012, 04:19:22 AM by Softology » Logged
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #3 on: November 22, 2012, 07:12:59 AM »

I don't use tile rendering to prevent time-outs - tile rendering is only used to create high-resolution images, and I always render whole fullscreen quads.

I think the best way to split up the rendering is to use progressive/accumulated rendering. Simple render to a offscreen buffer (a Frame Buffer Object), and when writing to the buffer, add the previous result. Then, when drawing the buffer to the screen, divide by the number of samples (this must be done in a custom shader). This way you can do progressive anti-aliasing or Monto-carlo raytracing (soft shadows, DOF, ...). Fragmentarium use a slightly more complex buffer setup, with two offscreen buffers, flipped at each frame, so that you can sample from neighbor points (this makes reaction-diffusion and game-of-life systems possible). I also use float buffers (32-bit for each channel), to avoid quantization errors, and allow for HDR rendering.

In Fragmentarium I use the alpha-channel to keep track of how many samples have been used - this also allows me to do weighted sampling, since I can use the alpha-channel for the sum of the weights.
Logged
Softology
Conqueror
*******
Posts: 120


« Reply #4 on: November 28, 2012, 05:28:22 AM »

Thanks Mikael.

I only started down the tile based approach after I was using older GPUs for testing that kept timing out with more complex shaders.

Your other tips will come in handy when I eventually get the hang of shaders and GLSL to a more competant level.

Jason.
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Tiles format Mandelbulber BattleMetalChris 2 1169 Last post July 22, 2012, 01:45:25 AM
by BattleMetalChris
Fractal bathroom tiles Other Artforms Mrz00m 0 747 Last post June 21, 2015, 12:40:10 AM
by Mrz00m
Rendering: tiles visible in final render Fragmentarium « 1 2 3 » Sabine 31 2008 Last post September 08, 2016, 01:45:59 PM
by Sabine
Inconsistent coloring of Big Render tiles bug reporting JohnQForumPoster 1 424 Last post September 09, 2016, 09:43:44 PM
by JohnQForumPoster

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.165 seconds with 28 queries. (Pretty URLs adds 0.011s, 2q)