Exemplo n.º 1
0
        internal void SetupDrawCall(Camera cam)
        {
            if (UseFrustumCulling)
            {
                GeomUtil.CalculateFrustumPlanes(s_planes, Camera.current.projectionMatrix * Camera.current.worldToCameraMatrix);
                isVisible |= GeometryUtility.TestPlanesAABB(s_planes, Bounds);
            }

            if (!SystemComp.enabled || SystemComp.ParticleCount == 0)
            {
                return;
            }


            //Setup proper size mult depending on camera ortho size
            if (isPixelSize)
            {
                var pixelMult = Mathf.Max(1.0f / Screen.width, 1.0f / Screen.height);
                if (cam.orthographic)
                {
                    pixelMult *= cam.orthographicSize * 2.0f;
                }
                m_cacheMaterial.SetVector(SID._PixelMult, new Vector4(pixelMult, cam.orthographic ? 0.0f : 1.0f));
            }
            else
            {
                m_cacheMaterial.SetVector(SID._PixelMult, new Vector4(1.0f, 0.0f));
            }

            //Setup DrawM
            Bounds bounds = UseFrustumCulling ? _bounds : new Bounds(Vector3.zero, Vector3.one * 10000);
            var    layer  = SystemComp.gameObject.layer;

            Graphics.DrawMeshInstancedIndirect(m_particleMesh, 0, m_cacheMaterial, bounds, m_argsBuffer, 0, null, CastShadows, ReceiveShadows, layer, cam);
        }