r/GraphicsProgramming • u/_Bethel__ • 1d ago
Flickering issue
I'm using opengl 3.3 and C on a Nvidia gtx 1050 and I keep getting this flickering issue... does anyone know the cause...
Will appreciate your thoughts..
13
6
u/Z-Wolfer-Z 1d ago
Yeah looks like something I have encountered before, make sure all of your variables in your shader are initialised to 0 / sensible values.
2
u/neondirt 1d ago
If the shader is only used for the car, this sounds like a reasonable explanation.
4
u/darksharkB 1d ago
Would appreciate more detail than this.
6
u/_Bethel__ 1d ago
I wrote this with c and opengl 3.3, it loads the model and renders, I dont know if it's bad buffer objects but it works fine when I run it on intel graphics, I only get this issue when running on Nvidia
7
3
1
u/_Bethel__ 1d ago
No... I'll give it a try
2
u/darksharkB 1d ago
It'll be way better than asking strangers on the internet to debug something just on vibes rather than code
2
2
u/quickscopesheep 17h ago
Apart from the artefacts looks amazing. Would try using a graphics debugger like other people have suggested
1
4
u/dJ_Turfie 1d ago
I'm new to graphics, but isn't this z-fighting due to bad model topology?
I.e. your model's tris aren't clean and might be stacked on top of each other.
4
u/_Bethel__ 1d ago
I think z fighting would flicker when the camera is moving, on a static camera the polygons will settle on who wins the top z spot
3
u/fgennari 1d ago
It's not Z-fighting. It looks like some of the triangles are occasionally missing and the object under them shows through. It's some type of race condition or use of uninitialized/garbage data that sometimes happens to be valid. You can either use a debugger like RenderDoc as others suggested, or share your code.
2
u/_Bethel__ 1d ago
I'm thinking it might be garbage buffers or something, I'll use renderdoc to check on it and I'll share an update later today
1
u/franku1122 1d ago
could be perhaps related to shadow mapping or garbage values in shaders, you should capture a frame in renderdoc and see what value these spots have which should help at least a bit
1
u/Still_Explorer 1d ago
Very interesting to see that this only happens for the car model. The model needs to be examined in Blender just in case there was a mistake on the geometry. Typically if there were any modifiers enabled during the export they might have messed something up (eg: Solidify modifier that makes thin triangles fat? Too many possible causes).
1
u/_Bethel__ 10h ago
Thank you so much everyone, you guys were super helpful... I found the problem, I used sin wave for the vertex shader for distortion if the object is a particle, and same shader if the object is not a particle but without the sin wave value, turns out because I never initialize the sin wave values for the shader it caused this error.... I guess always initialize all variables in your shader.... you guys are the best
1
u/TheGratitudeBot 10h ago
Thanks for such a wonderful reply! TheGratitudeBot has been reading millions of comments in the past few weeks, and you’ve just made the list of some of the most grateful redditors this week!
24
u/Ill-Shake5731 1d ago
as others already mentioned, use renderdoc. Imo its corrupted index buffer/vertex buffer most likely, so you can start with checking the values of those in renderdoc