Unity Shader Offset Factor, units detailed

Source: Internet
Author: User

A long time ago to find the various information about the offset, today there are some people asked, I simply sent up, and then someone asked me to address directly! Explanation on the Unity document: https://docs.unity3d.com/Manual/SL-CullAndDepth.html Offset Factor, Units
Allows specify a depth offset with the parameters. factor and units. factor scales the Maximum Z slope, with respect to X or Y of the polygon, and units scale the minimum resolvable depth buffer valu E. This allows-polygon to is drawn on top of another although they is actually in the same position. For Example offset 0,–1 pulls The polygon closer to the camera ignoring the polygon ' s slope, WHEREAS OFFSE T–1,–1 will pull the polygon even closer when looking at a grazing angle. Basically equals no explanation. Explanation on the Unity forum:https://forum.unity3d.com/threads/offset-parameters.23281/    has: Polygon offset allows the Application to specify a depth offset with the parameters, factor and units. Factor scales the maximum Z slope, with respect to X or Y of the polygon, and units scales the minimum resolvable depth bu Ffer value. The results is summed to produce the depth offset. This offset is applied on screen space, typically with positive Z pointing into the screen. The factor parameter is required to ensure correct results in filled primitives that's nearly edge-on to the viewer. The difference between Z values for the same pixel generated by both coplanar primitives can be as great as T He maximum Z slope in X or Y. This Z slope is large for nearly edge-on primitives, and almost non-existent for face-on primitives. The factor parameter lets you add this type of variable difference into the resulting depth offset. A Typical use might is to set factor and units to 1.0 to offset primitives into positive Z (into the screen) and enable PO Lygon offset for fill mode. The passes is then made, once with the model's solid geometry and once again with the line geometry. Nearly edge-on filled polygons is pushed substantially away from the eyepoint, to minimize interference with the line Geo Metry, while nearly planar polygons is drawn at least one depth buffer unit behind the line geometry. From HTTPS://WWW.Opengl.org/archives/resources/faq/technical/polygonoffset.htm  from OpenGL's explanation: Https://www.khronos.org/registry /opengl-refpages/gl4/html/glpolygonoffset.xhtml or https://msdn.microsoft.com/en-us/library/windows/desktop/ dd373973 (v=vs.85). aspx mentions:

When GL_POLYGON_OFFSET_FILL , GL_POLYGON_OFFSET_LINE or was GL_POLYGON_OFFSET_POINT enabled, each fragment ' s depth value would be offset after it's interpolated from The depth values of the appropriate vertices. The value of the offset is factorxdz+rxunitsfactorxdz+rxunits, where Dzdz are a measurement of the change in depth relative To the screen area of the polygon, and RR is the smallest value, which is guaranteed to produce a resolvable offset for a G Iven implementation. The offset is added before the depth test was performed and before the value is written into the depth buffer.

glPolygonOffsetis useful for rendering hidden-line images, for applying decals to surfaces, and for rendering solids with highlighted EDG Es. There is a blog about this explanation: http://www.voidcn.com/blog/cubesky/article/p-6092419.htmlhttp://kovax.blog18.fc2.com/blog-entry-50.html

The depth value of each fragment increases the offset shown below:

offset = (M * factor) + (R * units)

M is the maximum value in the slope of the depth of the polygon (calculated during the rasterization phase). This sentence is difficult to understand, you just need to know that the more a polygon is parallel to the near clipping surface (close to clipping plan), the closer the M is to 0.

R is the smallest value that can produce a distinguished difference in the depth value of a window's coordinate system, and r is a constant specified by the platform that specifically implements OpenGL.

An offset greater than 0 pushes the model farther away from you (the camera), and correspondingly, an offset less than 0 will pull the model closer. Http://miffysora.wikidot.com/glpolygonoffset Finally, here's a little bit about how m is calculated. But it seems a little wrong.

Then find: Http://www.glprogramming.com/red/chapter06.html#name4 and continue to check: https://www.inf.ufes.br/~thomas/graphics/ Opengl/docs/glspec1.1/node58.html

Unity Shader Offset Factor, units detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.