Пример #1
0
            private static void DrawMesh(Pass pass)
            {
                int colliderCount = pass.layerMaskList.Count;

                if (colliderCount < 1)
                {
                    return;
                }

                for (int id = 0; id < colliderCount; id++)
                {
                    LightCollider2D collider = pass.layerMaskList[id];

                    switch (collider.mainShape.maskType)
                    {
                    case LightCollider2D.MaskType.MeshRenderer:
                        Mesh.Mask(pass.light, collider, pass.materialWhite, pass.layer);
                        break;

                    case LightCollider2D.MaskType.BumpedMeshRenderer:
                        Material material = collider.bumpMapMode.SelectMaterial(pass.materialNormalMap_PixelToLight, pass.materialNormalMap_ObjectToLight);
                        Mesh.MaskNormalMap(pass.light, collider, material, pass.layer);
                        break;

                    case LightCollider2D.MaskType.SkinnedMeshRenderer:
                        SkinnedMesh.Mask(pass.light, collider, pass.materialWhite, pass.layer);
                        break;
                    }
                }
            }
Пример #2
0
        private static void DrawCollider(Pass pass)
        {
            LightCollider2D collider = (LightCollider2D)pass.sortPass.sortObject.lightObject;

            if (collider.shadowLayer == pass.layerID && pass.drawShadows)
            {
                if (collider.ShadowDisabled() == false)
                {
                    ShadowEngine.GetMaterial().SetPass(0);

                    GL.Begin(GL.TRIANGLES);

                    Shadow.Shape.Draw(pass.light, collider);

                    GL.End();
                }
            }

            // Masking
            if (collider.maskLayer == pass.layerID && pass.drawMask)
            {
                pass.materialWhite.color = Color.white;

                switch (collider.mainShape.maskType)
                {
                case LightCollider2D.MaskType.SpritePhysicsShape:
                case LightCollider2D.MaskType.Collider2D:
                case LightCollider2D.MaskType.Collider3D:
                case LightCollider2D.MaskType.CompositeCollider2D:

                    pass.materialWhite.SetPass(0);
                    GL.Begin(GL.TRIANGLES);
                    Shape.Mask(pass.light, collider, pass.layer);
                    GL.End();

                    break;

                case LightCollider2D.MaskType.Sprite:

                    SpriteRenderer2D.Mask(pass.light, collider, pass.materialWhite, pass.layer);

                    break;

                case LightCollider2D.MaskType.BumpedSprite:

                    Material material = collider.bumpMapMode.SelectMaterial(pass.materialNormalMap_PixelToLight, pass.materialNormalMap_ObjectToLight);
                    SpriteRenderer2D.MaskNormalMap(pass.light, collider, material, pass.layer);

                    break;

                case LightCollider2D.MaskType.MeshRenderer:

                    pass.materialWhite.SetPass(0);
                    GL.Begin(GL.TRIANGLES);
                    Mesh.Mask(pass.light, collider, pass.materialWhite, pass.layer);
                    GL.End();

                    break;

                case LightCollider2D.MaskType.BumpedMeshRenderer:

                    Material material2 = collider.bumpMapMode.SelectMaterial(pass.materialNormalMap_PixelToLight, pass.materialNormalMap_ObjectToLight);
                    material2.SetPass(0);
                    GL.Begin(GL.TRIANGLES);
                    Mesh.MaskNormalMap(pass.light, collider, material2, pass.layer);
                    GL.End();

                    break;

                case LightCollider2D.MaskType.SkinnedMeshRenderer:

                    pass.materialWhite.SetPass(0);
                    GL.Begin(GL.TRIANGLES);
                    SkinnedMesh.Mask(pass.light, collider, pass.materialWhite, pass.layer);
                    GL.End();

                    break;
                }
            }
        }