Beispiel #1
0
 public static void ResetStaticState()
 {
     _initialized = false;
     _dpiScale    = 1f;
     _feather     = 0.7f;
     DashAtlas.ResetStaticState();
 }
Beispiel #2
0
        /*
         * public static double getPixelSize() {
         *  return 1.0 / Camera.main.nonJitteredProjectionMatrix.GetColumn(0).magnitude / (double)Camera.main.pixelWidth * 2.0;
         * }
         */

        public void UpdateDirty()
        {
            var pixel = getPixelSize();

            // These seem unnecesary. Dir is not used in shader
            // Right is used but in a special case, not sure how necessary.
            // Vector4 dir = Camera.transform.forward.normalized;
            // Vector4 right = Camera.transform.right.normalized;
            foreach (var l in lines)
            {
                var style = l.Key;
                if (l.Value.dirty)
                {
                    FillMesh(l.Value);
                    l.Value.dirty = false;
                }

                foreach (var m in l.Value.objects)
                {
                    var material = m.GetComponent <MeshRenderer>().sharedMaterial;
                    material.SetFloat("_Pixel", (float)1.0);
                    //material.SetVector("_CamDir", dir);
                    //material.SetVector("_CamRight", right);
                    material.SetFloat("_Width", (float)(style.width * style.scale(pixel)));
                    material.SetFloat("_StippleWidth", (float)(style.dashesScale(pixel)));
                    material.SetFloat("_PatternLength", style.GetPatternLength());
                    material.SetColor("_Color", style.color);

                    if (UseSilhouetteNormals)
                    {
                        material.EnableKeyword("USE_SILHOUETTE_NORMALS");
                    }
                    else
                    {
                        material.DisableKeyword("USE_SILHOUETTE_NORMALS");
                    }

                    material.SetFloat(
                        "_ZTest",
                        (float)(style.depthTest ?
                                UnityEngine.Rendering.CompareFunction.LessEqual :
                                UnityEngine.Rendering.CompareFunction.Always)
                        );

                    material.SetTexture("_MainTex", DashAtlas.GetAtlas(style.dashes));
                    material.renderQueue = style.queue;
                }
            }
        }