Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by EmilyJrCH · Jul 19, 2021 at 10:40 AM · synchronizationflickering

SRP based Clustered Shading, weird flickering (maybe due to computebuffers out of sync i guess)

This might takes time to read;

I'm working on a tiny project, which is Building a Clustered Shading RP with SRP, I managed to complete the pre-computations of cluster filling and light assigning with Compute Shaders, and after that are two context.DrawRenders() calls to do Light Assignment Debug and Opaque. Here is a glimpse of my coding of this part:

 // Above is Cluster Filling and Light Assignment
 
 // 5. Debug Light Assignment
         mainCmdBuffer.SetGlobalBuffer(IdManager.ClusterFlagsId, computeBuffers.clusterFlagsBuffer);
         mainCmdBuffer.SetGlobalBuffer(IdManager.pointLightGridId, computeBuffers.pointLightGridBuffer);
         mainCmdBuffer.SetGlobalBuffer(IdManager.spotLightGridId, computeBuffers.spotLightGridBuffer);
         ExecuteBuffer();
         var debugDrawingSettings = new DrawingSettings(debugLightAssignShaderTagId, sortingSettings){
             enableDynamicBatching = useDynamicBatching,
             enableInstancing = useGPUInstancing
         };
         context.DrawRenderers(cullingResults, ref debugDrawingSettings, ref filteringSettings);
 
         // 6. Opaque Pass
         mainCmdBuffer.SetGlobalBuffer(IdManager.pointLightsId, computeBuffers.pointLightsBuffer);
         mainCmdBuffer.SetGlobalBuffer(IdManager.pointLightGridId, computeBuffers.pointLightGridBuffer);
         mainCmdBuffer.SetGlobalBuffer(IdManager.pointLightIndexListId, computeBuffers.pointLightIndexListBuffer);
         mainCmdBuffer.SetGlobalBuffer(IdManager.spotLightsId, computeBuffers.spotLightsBuffer);
         mainCmdBuffer.SetGlobalBuffer(IdManager.spotLightGridId, computeBuffers.spotLightGridBuffer);
         mainCmdBuffer.SetGlobalBuffer(IdManager.spotLightIndexListId, computeBuffers.spotLightIndexListBuffer);
         ExecuteBuffer();
         sortingSettings = new SortingSettings(camera) { criteria = SortingCriteria.CommonOpaque }; // -- pass camera to determine orthographic / distance-based sorting                                                                             // -- CommonOpaque: front-to-back
         // sortingSettings.criteria = SortingCriteria.OptimizeStateChanges;
         drawingSettings = new DrawingSettings(litShaderTagId, sortingSettings){
             enableDynamicBatching = useDynamicBatching,
             enableInstancing = useGPUInstancing
         };
         filteringSettings = new FilteringSettings(RenderQueueRange.opaque); // -- draw transparent objects later
         context.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings);

I built a simple scene to test, and Light Assign Debug seem to work fine, but weird flickering appeared in Opauqe Pass:

Videos: Light Assign Debug: https://drive.google.com/file/d/1yBVq38UZbG2md7I1rxSdT4Q0NyKVet18/view?usp=sharing Opaque Pass: https://drive.google.com/file/d/1NODAEZ04QdXd6zpD7KCDoZxJihmG4kP_/view?usp=sharing

You can see that Opaque Lighting worked well at the start, but flickering appeared 2-3 seconds later, the picture flickered and most lights disappeared and cluster screen tile appeared, What gave me a hint is that at around 6-7 seconds of this video, I clicked 'Capture in RenderDoc' and it turned correct magically. Since 'Capture in RenderDoc' would (nearly) pause a frame, so I guess the problem is that LightIndexList and LightGrid these two Compute Buffers I pass as the global buffer, somehow didn't acquired the correct value, out of sync maybe, and the pause of 'Capture in RenderDoc' somehow made them synchronized again.

Anybody knows what is really going wrong with my code, and how to fix it ?

Thanks for your reading, if you have similar problems, maybe we can discuss in comments.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

120 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Photon Network syncing the transform of a moving platform 0 Answers

How do I create an intermediate loading room in Photon? 0 Answers

Kindle Fire - Flickering UI on 2nd camera 1 Answer

How would i eliminate flickering caused by shader? 0 Answers

Text flickering through mask 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges