0
votes

what is the difference between invariance and polygon offset in OpenGL. I am getting confused with both. Since both are related to low precession problems.

1
What do you mean by "invariance"? Invariance doesn't have anything to do with precision.Nicol Bolas
Thanks a lot for the replay @NicolBolas We do have a keyword invariant in opengl es 2.0. It is used to maintain then same precession of the output from vertex shaders(varying variable) over repeated call.Megharaj

1 Answers

2
votes

From the GLES 2.0 spec:

[...] variance refers to the possibility of getting different values from the same expression in different shaders. For example, say two vertex shaders each set gl_Position with the same expression in both shaders, and the input values into that expression are the same when both shaders run.

It is possible, due to independent compilation of the two shaders, that the values assigned to gl_Position are not exactly the same when the two shaders run. In this example, this can cause problems with alignment of geometry in a multi-pass algorithm. In general, such variance between shaders is allowed. To prevent variance, variables can be declared to be invariant, either individually or with a global setting.

In other words, invariant is a mechanism provided by gles for you (the programmer) to tell the implementation that when a certain shader code is compiled, the gpu code generated must be the same every time.

Polygon offset is, ummm, completely unrelated. I refer you to the official FAQ https://www.opengl.org/archives/resources/faq/technical/polygonoffset.htm