0
\$\begingroup\$

I'm using Tile-Based Deferred rendering and I have run into an issue with my lights flickering.

For a long time now I would just add all my lights at once and let the renderer do its thing eg. build a big light list while generating my world data and just upload the light list to the GPU and leave it there.

This wasn't an issue because I can render 1000's of lights and the render would just take it but because I'm not uploading them every frame the lights are static and that works well for world lights but now I want my projectiles\other things to have dynamic lights so I now upload the light list every frame after culling it with my octree\frustum of course and it works well apart from flickering as I pan the camera\frustum moves.

I update my mesh data the same way and meshes don't flicker so I'm kinda stumped, I have tried offsetting the frustum I use for culling so that my camera is about 25% inside the frustum rather than have the frustum start at the camera position and also widening the FOV.

If there is any code you need to see let me know.

Edits:

It happens to all the lights but I notice it much more as the light moves from in front of me to the sides of the screen, it seem like it would be the lights flickering off for a frame, I have been trying to debug it with the VS GFX tools but I only happens when the camera moves, as soon as I stop moving the lights are fine, I'm trying to cap a frame that shows the lights in the midst of a flicker so I can check for NAN's or Inf. I had a read of another answer for the same type of thing but his fix didn't do anything.

Last night I also tried changing the way I do my containment\intersection tests and still no change.

My directional light is fine no flickering there its just point lights\spot lights that flicker.

While writing this I had a brain storm, another thing I did over the weekend was offset my camera to a 3rd person view so maybe I'm passing my player object position to the renderer and not the actual offset camera position.

\$\endgroup\$
  • \$\begingroup\$ Can you help us identify what kind of flicker you're seeing? I can think of a few cases that would cause a flicker effect if they happened for a brief frame: 1) no lights render 2) some lights fail to render but not others 3) (some) lights render with last frame's transform data, so their position or direction jumps or vibrates. If you can identify which of these cases (or other sources) is behind the flickering, it may help narrow down the root cause. \$\endgroup\$ – DMGregory Feb 5 '17 at 15:39
  • \$\begingroup\$ @DMGregory Your comment helped me think over every thing and I found the issue, I had offset my camera to be 3rd person and was sending its original position to the render when I should be sending the offset position. Lights don't flicker now. Should I make an answer? \$\endgroup\$ – Justin William Stanley Bryant Feb 6 '17 at 3:23
  • \$\begingroup\$ I'm glad that helped! It would be a good idea to write up the details of the solution you found as an answer, in case it helps future users who encounter similar issues. \$\endgroup\$ – DMGregory Feb 6 '17 at 3:25
0
\$\begingroup\$

The root of the problem was that I had offset my camera to be 3rd person and in doing so I didn't update my camera bounds(bounding sphere) to match the new offset so the renderer was using the wrong positon value and that's why the lights were flickering more as I moved past them.

It was a simple change of just updating the camera bounds center vector to match the new offset camera position I use to build my view matrix.

Dim BasePos As Vector3 = _position
camera.CameraTarget = BasePos + CType(Vector3.Transform(New Vector3(0, 25, 1000), Matrix.RotationX(MathHelper.ToRadians(camera.Pitch)) * Matrix.RotationY(MathHelper.ToRadians(camera.Yaw))), Vector3) // offsetting the camera
camera.CameraBounds.Center = BasePos //this right here is the problem

camera.CameraBounds.Center = camera.CameraTarget //this is the fix, very simple
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.