• Advertisement
Sign in to follow this  

OpenGL Is Clustered Forward Shading worth implementing?

This topic is 1814 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

Advertisement

This has been a fascinating topic, and I commend everyone contributing too it! Warning, what follows is a somewhat off topic rant

 

Since it wasn't clear, I was arguing for deferred simply to handle most worst case scenarios in games today, not that it was the most efficient always, and yes forward/hybrid/etc. may always have scenarios where X is faster than Y. This generation, now closing, has seen an extreme need for optimization of resources for each game. Programmer time and talent has been, and will always be another consideration, but pushing good visuals versus limited resources has eaten up more and more consideration as time has gone on. So optimizing what you are doing for each game has been a priority, including refactoring something like lighting each time if need be.

 

This next generation however, I believe, will be different. Certainly more compute power will always be usable, pretty much into infinity. But the biggest constraint I can see is artist time. It's already been a constraint with modern games, and can only get worse now that a thousand materials can be supported on models a hundred thousand faces and more in count, not too mention all the advanced animation rigging for things like cloth physics, hair physics, skin and muscle simulation and etc. that can be done.

 

Which is simply why I foresee less time spent on refactoring rendering and more time making better tools for artists. Certainly, there are going to be cases still where forward/deferred/hybrid approaches are better; and as MJP pointed out you can have a more generalized pipeline far more easily now, which is great! But anything that makes the job easier and faster for artists, at least in my view, should be given priority. Which is a reason why I've viewed the use of multiple BRDFs with skepticism. The less the artist has to learn, and thus the more time spent actually making things, the better. And while certainly better can be done than Blinn-Phong, I'd simply rather not even give most artists the opportunity to sit there and switch between Beckmann to GGX to Cook-Torrance to etc. just to see what each did to "Get it right."

 

And I know there are ways to mitigate that. Suggestions I've seen range from pre-defined materials with correct values to not let artists screw things up to. etc. etc. All take time, and I'm mostly thinking way too hard about efficiency I suppose. So in short I'd rather hope for, in general, far less refactoring each game, as little complexity (and thus time and effort) added to the artists pipeline as possible, and more effort on all those very neat tools and research into such this go around. After all, I enjoy playing games as well, and would love to see them be as good as possible. And it makes more sense to me to take the Hollywood/offline VFX path of late, which is trying to make making things faster and cheaper, rather than trying harder to make things look better. So I'd rather have a deferred render capable of handling the worst case gameplay scenarios with a generalized BDRF that's good enough at doing multiple materials. But that's a far away thought I suppose.

Share this post


Link to post
Share on other sites

I.E. Here's what I'm talking about, even Hollywood and Disney have this problem and are trying to solve it: http://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_slides_v2.pdf

 

In fact, their BDRF sounds pretty good! "As few parameters as possible, 0-1 range, all combinations of parameters plausible" Mmmm yeah that's the stuff. One BDRF to rule them all, one BDRF to find them, one deferred renderer to bring them all, and in screenspace bind them! laugh.png

Edited by Frenetic Pony

Share this post


Link to post
Share on other sites
Which is a reason why I've viewed the use of multiple BRDFs with skepticism. The less the artist has to learn, and thus the more time spent actually making things, the better. And while certainly better can be done than Blinn-Phong, I'd simply rather not even give most artists the opportunity to sit there and switch between Beckmann to GGX to Cook-Torrance to etc. just to see what each did to "Get it right."

 

This isn't the problem you think it is; the BRDF/shaders are set up by tech artists (in association with rendering programmers) which are not the same guys doing the models/animation/rigging which take the time. Those guys are handed shaders and told 'use these' so they won't be swapping from one function to another to 'get it right'.

Share this post


Link to post
Share on other sites
Which is a reason why I've viewed the use of multiple BRDFs with skepticism. The less the artist has to learn, and thus the more time spent actually making things, the better. And while certainly better can be done than Blinn-Phong, I'd simply rather not even give most artists the opportunity to sit there and switch between Beckmann to GGX to Cook-Torrance to etc. just to see what each did to "Get it right."

 

This isn't the problem you think it is; the BRDF/shaders are set up by tech artists (in association with rendering programmers) which are not the same guys doing the models/animation/rigging which take the time. Those guys are handed shaders and told 'use these' so they won't be swapping from one function to another to 'get it right'.

Yes, and setting up a thousand BDRF shaders doesn't take up their time? Of course it does, otherwise Disney wouldn't have gone to all that trouble to reduce their rendering down to a single BDRF.

Share this post


Link to post
Share on other sites

ah yes, the old reductio ad absurdum argument....

 

A game is NOT going to have thousands of BDRF setup for it, a few will be selected from a small batch and those will be used (and result in many INSTANCES of the materials with different parameters) but the BDRFs themselves will be quite a low count. Over time more BDRF might get added but you aren't going to say "we are going to make a game, quick make ALL the BDRF shaders!" - that would be so many shades of dumb even thinking it is possible is.. well.. dumb.

Share this post


Link to post
Share on other sites
ah yes, the old reductio ad absurdum argument....

 

A game is NOT going to have thousands of BDRF setup for it, a few will be selected from a small batch and those will be used (and result in many INSTANCES of the materials with different parameters) but the BDRFs themselves will be quite a low count. Over time more BDRF might get added but you aren't going to say "we are going to make a game, quick make ALL the BDRF shaders!" - that would be so many shades of dumb even thinking it is possible is.. well.. dumb.

 

Tri-Ace was developing several already, for a game that was supposed to be this generation. Next gen there won't be nearly as much restriction, if Hollywood sees it as a problem to solve why would games, unburdened by much in the way of hardware constraints (as far as BDRF goes) be any different? Budgets can certainly be similar, and games often have far, far more assets.

 

With a single generalized BDRF, such as the one Disney has developed and I linked too, you would need a fat G-Buffer to store enough parameters sure. But you can go deferred and avoid dynamic branching, and you do save time. I'm not saying it's going to be as huge a benefit as a movie CG might get. Obviously artists wouldn't have time to sit there and fiddle with materials ad nauseum. But if it saves time it saves time. Point is I don't see much reason NOT to have a single, highly artists friendly BDRF as opposed to multiple kinds.

Share this post


Link to post
Share on other sites
Point is I don't see much reason NOT to have a single, highly artists friendly BDRF as opposed to multiple kinds.

In theory, it is a great idea... but, perhaps you're over-estimating next-gen power. Disney can spend an hour per frame, using 100 GPUs, we need 33ms per frame on 1 GPU.

 

For realtime, you're not going to want to compute sub-surface-scattering, or anisotropic reflections, for every surface if you can avoid it, etc, etc...

Edited by Hodgman

Share this post


Link to post
Share on other sites
For realtime, you're not going to want to compute sub-surface-scattering, or anisotropic reflections, for every surface if you can avoid it, etc, etc...

 

Awwee... But I want anistropic-specularity on my cream cheese, the bagels upon which 'tis spread, and my hot cup O' goodness!

 

There's an obvious engineering solution to this... isn't there? Ha... I'm sorry but I think it's just too simple to explicitly indicate. It's a very elementary premise of tool making... You don't need to internally implement such an "artist friendly BDRF" ... Too many hints ...

 

So yeah.

Share this post


Link to post
Share on other sites

Note that Forward+ (aka Clustered Forward, Light Indexed Deferred) is a very new topic and there's a lot of research coming up this year.

Now, just because I'd hate for this to turn into another deferred lighting / shading terminology kerfuffle:

 

Tiled Forward <=> Forward+, these use 2D tiling (same as Tiled Deferred), with a pre-z pass (optional) + separate geometry pass for shading.

Light Indexed Deferred, Builds the lists per pixel, which can be viewed as a 1x1 tile, and then it is really the same as Tiled Forward. The practical difference is pretty big, though...

Clustered Forward, performs tiling in 3D (or higher). othwewise as above.

Tiled/Clustered Deferred Shading, do tiling as their forward counterparts, but start with a G-Buffer pass and end with a deferred shading pass.

 

Hope this clears up, and/or prevents, some confusion.

Share this post


Link to post
Share on other sites

Haha, whoops. I don't know why I wrote BDRF. Here's a reminder (saw this on Twitter smile.png):

 

7zZgSIk.png

BeaRDed F!

Share this post


Link to post
Share on other sites

There is a thing I don't understand.
It appears there's this thing still going on which plain forward can only do 8-10 lights per pass. How? In the past I've had quite some success encoding light data in textures and looping them on entry-level SM3 hardware. Perhaps I'm not seeing the whole picture but in SM4 with the much higher resource limits and the unlimited dynamic instruction count... shouldn't we go easily in the thousand range? Of course we'll neeed a z-only pass first.
So I guess there are additional practical reasons to stay in the 8-10 range.

 

At the top of page 2, I read about extra pressure and lower execution efficiency. I understand.

But, as much as I love lighting modularity coming from deferred, as a DDR3 card owner I still don't understand how the improved processing makes up for the bandwidth increase required. The trend on bandwidth is set. It looks to me we want to trash compute in the future.

Share this post


Link to post
Share on other sites

Hi Krohm,

 

In shader model 4.0 you can have up to 4096 entries in a constant buffer (which would limit lights to ~256 if they have position, direction diffuse, specular). Or you can use texture buffers and have near limitless lights.

Let's say you use the latter, so no worries about the light count. And today with SM 5.0 we really don't need to worry about loop count limits either. So we're good on that front

 

Indeed you can loop through a 1000 lights in SM4+ hardware. But let's say I'm running at 1920x1080 resolution and the whole screen is covered.

1920x1080 x 1000 lights = 2.073.600.000 light evaluations per frame.

Not to mention some BRDFs are expensive (i.e. Cook Torrance). Framerate would be sloooooooooow. So slow in fact, that it could trigger the Windows watchdog for believing the GPU is stalled and restart the driver.

 

The secret behind Deferred shaders (or Forward+) is that even though there are thousands of lights, they're not covering the whole screen at the same time.

In other words: many small lights = few big lights.

It's typical that a single region of the screen isn't lit by more than 4-20 lights, may be 5 on average. Let's be pessimistic and say 10.

1920x1080 x 10 lights = 20.736.000 light evaluations per frame

That's a lot more reasonable for a GPU to perform in real time. In such scenario every region of pixels (called tiles) would only have to loop through 10 lights (on average), not a 1000 and waste gpu time on 990 lights that aren't needed.

Share this post


Link to post
Share on other sites
But what if you would test whether a light actually should be covering the individual pixels inside this loop and skip all the lights, that shouldn't? The only difference to a tile-based deferred renderer would be, that the light culling is performed per pixel instead of per tile. But you wouldn't have all the BRDF, transparency, bandwidth and Anti-Aliasing issues. It would basically be a worse version of a light indexed deferred renderer, because the list of lights is not precomputed. Edited by CryZe

Share this post


Link to post
Share on other sites

Also with more traditional forward rendering you would typically have stage (performed either offline or online) where you determine which lights will affect a given mesh, so that you only apply those lights when rendering it. Once again the only major difference is your granularity, and when/where you cull your lights at your given level of granularity. Doing everything on the GPU lets you achieve very fine granularity (per-tile or per-pixel) with relatively simple code, which is the primary draw of deferred techniques.

Share this post


Link to post
Share on other sites

But what if you would test whether a light actually should be covering the individual pixels inside this loop and skip all the lights, that shouldn't? The only difference to a tile-based deferred renderer would be, that the light culling is performed per pixel instead of per tile. But you wouldn't have all the BRDF, transparency, bandwidth and Anti-Aliasing issues. It would basically be a worse version of a light indexed deferred renderer, because the list of lights is not precomputed.

You could do that, but GPUs suck at branch-heavy applications, specially if there's not good branch coherency within the tile block (pixel shaders are run in blocks)

 

And even if it did, a tile-based deferred renderer is MUCH more efficient in performing this culling.

Share this post


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

  • Advertisement
  • Advertisement
  • Popular Now

  • Advertisement
  • Similar Content

    • By khawk
      We've just released all of the source code for the NeHe OpenGL lessons on our Github page at https://github.com/gamedev-net/nehe-opengl. code - 43 total platforms, configurations, and languages are included.
      Now operated by GameDev.net, NeHe is located at http://nehe.gamedev.net where it has been a valuable resource for developers wanting to learn OpenGL and graphics programming.

      View full story
    • By TheChubu
      The Khronos™ Group, an open consortium of leading hardware and software companies, announces from the SIGGRAPH 2017 Conference the immediate public availability of the OpenGL® 4.6 specification. OpenGL 4.6 integrates the functionality of numerous ARB and EXT extensions created by Khronos members AMD, Intel, and NVIDIA into core, including the capability to ingest SPIR-V™ shaders.
      SPIR-V is a Khronos-defined standard intermediate language for parallel compute and graphics, which enables content creators to simplify their shader authoring and management pipelines while providing significant source shading language flexibility. OpenGL 4.6 adds support for ingesting SPIR-V shaders to the core specification, guaranteeing that SPIR-V shaders will be widely supported by OpenGL implementations.
      OpenGL 4.6 adds the functionality of these ARB extensions to OpenGL’s core specification:
      GL_ARB_gl_spirv and GL_ARB_spirv_extensions to standardize SPIR-V support for OpenGL GL_ARB_indirect_parameters and GL_ARB_shader_draw_parameters for reducing the CPU overhead associated with rendering batches of geometry GL_ARB_pipeline_statistics_query and GL_ARB_transform_feedback_overflow_querystandardize OpenGL support for features available in Direct3D GL_ARB_texture_filter_anisotropic (based on GL_EXT_texture_filter_anisotropic) brings previously IP encumbered functionality into OpenGL to improve the visual quality of textured scenes GL_ARB_polygon_offset_clamp (based on GL_EXT_polygon_offset_clamp) suppresses a common visual artifact known as a “light leak” associated with rendering shadows GL_ARB_shader_atomic_counter_ops and GL_ARB_shader_group_vote add shader intrinsics supported by all desktop vendors to improve functionality and performance GL_KHR_no_error reduces driver overhead by allowing the application to indicate that it expects error-free operation so errors need not be generated In addition to the above features being added to OpenGL 4.6, the following are being released as extensions:
      GL_KHR_parallel_shader_compile allows applications to launch multiple shader compile threads to improve shader compile throughput WGL_ARB_create_context_no_error and GXL_ARB_create_context_no_error allow no error contexts to be created with WGL or GLX that support the GL_KHR_no_error extension “I’m proud to announce OpenGL 4.6 as the most feature-rich version of OpenGL yet. We've brought together the most popular, widely-supported extensions into a new core specification to give OpenGL developers and end users an improved baseline feature set. This includes resolving previous intellectual property roadblocks to bringing anisotropic texture filtering and polygon offset clamping into the core specification to enable widespread implementation and usage,” said Piers Daniell, chair of the OpenGL Working Group at Khronos. “The OpenGL working group will continue to respond to market needs and work with GPU vendors to ensure OpenGL remains a viable and evolving graphics API for all its customers and users across many vital industries.“
      The OpenGL 4.6 specification can be found at https://khronos.org/registry/OpenGL/index_gl.php. The GLSL to SPIR-V compiler glslang has been updated with GLSL 4.60 support, and can be found at https://github.com/KhronosGroup/glslang.
      Sophisticated graphics applications will also benefit from a set of newly released extensions for both OpenGL and OpenGL ES to enable interoperability with Vulkan and Direct3D. These extensions are named:
      GL_EXT_memory_object GL_EXT_memory_object_fd GL_EXT_memory_object_win32 GL_EXT_semaphore GL_EXT_semaphore_fd GL_EXT_semaphore_win32 GL_EXT_win32_keyed_mutex They can be found at: https://khronos.org/registry/OpenGL/index_gl.php
      Industry Support for OpenGL 4.6
      “With OpenGL 4.6 our customers have an improved set of core features available on our full range of OpenGL 4.x capable GPUs. These features provide improved rendering quality, performance and functionality. As the graphics industry’s most popular API, we fully support OpenGL and will continue to work closely with the Khronos Group on the development of new OpenGL specifications and extensions for our customers. NVIDIA has released beta OpenGL 4.6 drivers today at https://developer.nvidia.com/opengl-driver so developers can use these new features right away,” said Bob Pette, vice president, Professional Graphics at NVIDIA.
      "OpenGL 4.6 will be the first OpenGL release where conformant open source implementations based on the Mesa project will be deliverable in a reasonable timeframe after release. The open sourcing of the OpenGL conformance test suite and ongoing work between Khronos and X.org will also allow for non-vendor led open source implementations to achieve conformance in the near future," said David Airlie, senior principal engineer at Red Hat, and developer on Mesa/X.org projects.

      View full story
    • By _OskaR
      Hi,
      I have an OpenGL application but without possibility to wite own shaders.
      I need to perform small VS modification - is possible to do it in an alternative way? Do we have apps or driver modifictions which will catch the shader sent to GPU and override it?
    • By xhcao
      Does sync be needed to read texture content after access texture image in compute shader?
      My simple code is as below,
      glUseProgram(program.get());
      glBindImageTexture(0, texture[0], 0, GL_FALSE, 3, GL_READ_ONLY, GL_R32UI);
      glBindImageTexture(1, texture[1], 0, GL_FALSE, 4, GL_WRITE_ONLY, GL_R32UI);
      glDispatchCompute(1, 1, 1);
      // Does sync be needed here?
      glUseProgram(0);
      glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
      glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
                                     GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, texture[1], 0);
      glReadPixels(0, 0, kWidth, kHeight, GL_RED_INTEGER, GL_UNSIGNED_INT, outputValues);
       
      Compute shader is very simple, imageLoad content from texture[0], and imageStore content to texture[1]. Does need to sync after dispatchCompute?
    • By Jonathan2006
      My question: is it possible to transform multiple angular velocities so that they can be reinserted as one? My research is below:
      // This works quat quaternion1 = GEQuaternionFromAngleRadians(angleRadiansVector1); quat quaternion2 = GEMultiplyQuaternions(quaternion1, GEQuaternionFromAngleRadians(angleRadiansVector2)); quat quaternion3 = GEMultiplyQuaternions(quaternion2, GEQuaternionFromAngleRadians(angleRadiansVector3)); glMultMatrixf(GEMat4FromQuaternion(quaternion3).array); // The first two work fine but not the third. Why? quat quaternion1 = GEQuaternionFromAngleRadians(angleRadiansVector1); vec3 vector1 = GETransformQuaternionAndVector(quaternion1, angularVelocity1); quat quaternion2 = GEQuaternionFromAngleRadians(angleRadiansVector2); vec3 vector2 = GETransformQuaternionAndVector(quaternion2, angularVelocity2); // This doesn't work //quat quaternion3 = GEQuaternionFromAngleRadians(angleRadiansVector3); //vec3 vector3 = GETransformQuaternionAndVector(quaternion3, angularVelocity3); vec3 angleVelocity = GEAddVectors(vector1, vector2); // Does not work: vec3 angleVelocity = GEAddVectors(vector1, GEAddVectors(vector2, vector3)); static vec3 angleRadiansVector; vec3 angularAcceleration = GESetVector(0.0, 0.0, 0.0); // Sending it through one angular velocity later in my motion engine angleVelocity = GEAddVectors(angleVelocity, GEMultiplyVectorAndScalar(angularAcceleration, timeStep)); angleRadiansVector = GEAddVectors(angleRadiansVector, GEMultiplyVectorAndScalar(angleVelocity, timeStep)); glMultMatrixf(GEMat4FromEulerAngle(angleRadiansVector).array); Also how do I combine multiple angularAcceleration variables? Is there an easier way to transform the angular values?
  • Advertisement