Jump to content
  • Advertisement
Sign in to follow this  
RPTD

OpenGL decals flickering with polygon offset

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

I'm trying to get some decals done. For this purpose I use the polygon offset with -4.0 offset to avoid flickering ( hence the decal is pushed back while rendering ). This works until you try go flat to the ground looking at the decal at a gazing angle. Then heavy flickering appears. I tried increasing up to -16.0 offset but it still happens. I can understand that the interpolation results in errors but if even 16 z-units offset can not correct the error, what can it be? Is there a catch with the OpenGL polygon offset call or does nVidia have a strange idea about how polygon offset actually work?

Share this post


Link to post
Share on other sites
Advertisement
Did you set both values corecly? Most time somthing like that should be fine:
glPolygonOffset(1.0, 2.0);
Another possibility is a buggy driver, for that case you should post your gfx card and driver version.

Share this post


Link to post
Share on other sites
Hm... I'm using
Quote:
OGL_CHECK( glEnable( GL_POLYGON_OFFSET_FILL ) );
OGL_CHECK( glPolygonOffset( 0.0f, -config->GetDecalOffset() ) );


I tried with 1.0f but this resulted in nothing rendered at all. Maybe I'm mistaken but after the specs the equation is
Quote:
factor * z + offset * units

and this is added to the z value... or is this the new z value?

Share this post


Link to post
Share on other sites
If one of that both values is 0.0 something is wrong. Unfortunately I can't find the right paper. Search for polygonoffset and shadowmapping. One of that both values is angle depent and zero if a polygon is parallel to the far/near plane, the other is a static offset that will be added to all z values. Try 1.0 for both values, and raise them if required...

Share this post


Link to post
Share on other sites
It's LEQUAL.

I played now around with a value of 1.0 for the scaling and various values for the offset. The decal is not drawn anymore. I really don't know what to try anymore.

One thing though jumps to my mind. I'm not sure but I think I read once something about locks that drivers put there... along the line of "you can only push 'back' but not 'forward'". If this is true you can not decrease depth values. Do drivers impose such a silly lock?

Share this post


Link to post
Share on other sites
I have success with negative values on both settings.
for a decal that's next to near clip I use around -7.0, -7.0 but it will always flicker when passing through the near clip plane.

normal usage I use -2.0, -2.0

When drawing shadow volumes, for example the top cap, I use +6.0, +6.0

These values are WIP but have so far been just fine (it's been a while since I wrote those sections of code).

jezham

Share this post


Link to post
Share on other sites
Got it working. -0.1 and -1.0 did the job. The next problem is now to get the decals to wrap around the geometry. Still found no way which works in all cases.

Share this post


Link to post
Share on other sites
My decals tend to be quite small but even with -0.1 and -1.0 they will flicker when passing through near clip. Luckily they never do as collision prevents the camera getting so close to a small object. I am wondering though, my project will contain skid marks etc. and these might cause a flicker, guess I'll cross that bridge when I get there, and keep the segment length not too long.

Hm wrapped decals, sounds just like skinning with your polygon_offset_fill settings.

I must go back to that soon, would be nice getting polygon_offset_line to work (for debugging).

Share this post


Link to post
Share on other sites
Nah, I mean having a quad you jolt down at the surface to get a decal from. Only works so far with specific geometry but not arbitrary geometry. More tricky than I thought in the first place :/

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!