Forum

Polygon Offset Sucks

Discuss programming topics that involve the OpenGL API.

Moderator: InsideQC Admins

Polygon Offset Sucks

Postby mh » Sat Oct 23, 2010 5:49 pm

Another thing to not do:
  • The spec allows it to be implementation-dependent (clicky) so the same values may give different results on different hardware.
  • You may encounter floating point precision problems when moving between 16-bit and 24-bit depth buffers.
  • The depth buffer is non-linear so the same values will give different results at different depths.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby Sajt » Sat Oct 23, 2010 7:19 pm

I know, right. #3 ruined it for me.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby Spike » Sat Oct 23, 2010 8:14 pm

hence why its not supported in the minimal gl3 spec.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby andrewj » Sun Oct 24, 2010 2:36 am

How do you do decals or multi-pass rendering on older cards without polygon offset?

It may be a crappy tool, but the alternatives (glDepthRange or adjusting the coordinates of polygons directly) seem a lot worse.
andrewj
 
Posts: 133
Joined: Mon Aug 30, 2010 3:29 pm
Location: Australia

Postby leileilol » Sun Oct 24, 2010 4:05 am

you don't. you don't wanna make this guy angry
Image

look at those eyes don't piss him off






or you can use stainmaps for decals which really suck for bullets and really obstruct appearances of floors. i'm glad that was only a short time novelty but it doesn't need polygon offset as it just touches the lightmap


also - could decals be rendered in a separate pass from the world which is calculated by z after the render to peel away from the obstructed decals but the rendering of the decals themselves don't use an offset but a depth check after they're made while calculating an offset?!! i don't know what the hell i'm saying
i should not be here
leileilol
 
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Postby r00k » Sun Oct 24, 2010 5:29 am

His face is red because the card runs HOT without a cooling fan ;)
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Postby revelator » Sun Oct 24, 2010 5:46 am

got an ol vectra with twice the angry :D sli even.
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Postby leileilol » Sun Oct 24, 2010 6:00 am

see? when you spend over $600 on the real deal, the slug RIVAl and pathATIc hardware are just small time. The ultra performance blazing at 1024x768 HIGH RESOLUTION with T-buffer and more game companies adopting Glide as the new industry standard... is why you should invest in TDFX today
i should not be here
leileilol
 
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Postby mh » Sun Oct 24, 2010 11:55 am

Multipass is easy, GLQuake, Quake II and Q3A already do it without needing to use polygon offset and without any trouble (look at R_BlendLightmaps for example). Invariance guarantees that this will work just fine. The only trouble happens when you have co-planar polygons that don't use the same vertexes.

For decals you can just tweak the projection matrix to get the desired result. Even Microsoft's software implementation will allow that. A quick search on Google for "polygon offset alternatives" throws up quite a few interesting candidates too.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby Spike » Sun Oct 24, 2010 1:27 pm

Q3's clipped decals use polygon offset. Its a shader attribute to say 'push this nearer'.

But yeah, two polys drawn with the same vertex coords will have the exact same depth coords (different glsl/fixed-function might not!), which is how q3 gets away with the bulk of its multipass rendering.

Thus one way to do clipped decals is to use texture clamping and draw the decal the full size of each surface its superimposed upon (minecraft seems to do its blob shadows like this, for example).
Note that you do have to take care with your matricies. glLoadMatrix is more robust than recalculating the different matricies each time, I find...
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby mh » Sun Oct 24, 2010 3:25 pm

ftransform guarantees invariance, but then again ftransform is also deprecated. :lol: (It might also be slower as it sends the vertex through the same calculations as fixed, which presumably has a lot of extra generic baggage attached.) Still handy though if you're happy to aim at a lower version of the spec.

If you're using GLSL at all I guess you really should be using it for everything.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby Spike » Sun Oct 24, 2010 9:23 pm

anything that 'supports' a deprecated ftransform doesn't have a fixed-function pipeline any more, so it'll match if your maths matches anyway, at least that's the theory. So long as you're using the same matricies.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby Sajt » Mon Oct 25, 2010 6:44 am

Yeah ftransform and fixed-function pipeline are deprecated together.

Spike wrote:Thus one way to do clipped decals is to use texture clamping and draw the decal the full size of each surface its superimposed upon


OK I will do this from now on. Duhh.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby andrewj » Mon Oct 25, 2010 9:53 am

Sajt wrote:OK I will do this from now on. Duhh.

My reaction too -- so obvious now :)
andrewj
 
Posts: 133
Joined: Mon Aug 30, 2010 3:29 pm
Location: Australia


Return to OpenGL Programming

Who is online

Users browsing this forum: No registered users and 1 guest