示例#1
0
        public void Apply(CloudsMaterial material, float radius, Transform parent)
        {
            Remove();
            particleMaterial.MaxScale   = size.y;
            particleMaterial.MaxTrans   = maxTranslation;
            particleMaterial.NoiseScale = new Vector3(noiseScale.x, noiseScale.y, noiseScale.z / radius);
            ParticleMaterial            = new Material(ParticleCloudShader);
            particleMaterial.ApplyMaterialProperties(ParticleMaterial);
            material.ApplyMaterialProperties(ParticleMaterial);
            ParticleMaterial.EnableKeyword("SOFT_DEPTH_ON");

            volumeHolder = new GameObject();
            //Add the renderer here so othe rentities (shadows)
            //can easily access it.
            Renderer r = volumeHolder.AddComponent <MeshRenderer>();

            r.material = ParticleMaterial;
            ParticleMaterial.SetMatrix(ShaderProperties._ShadowBodies_PROPERTY, Matrix4x4.zero);
            ParticleMaterial.renderQueue = (int)Tools.Queue.Transparent + 2;

            r.enabled = false;
            volumeHolder.transform.parent        = parent;
            volumeHolder.transform.localPosition = Vector3.zero;
            volumeHolder.transform.localScale    = Vector3.one;
            volumeHolder.transform.localRotation = Quaternion.identity;
            volumeHolder.layer = (int)Tools.Layer.Local;
            volumeManager      = new VolumeManager(radius, size, ParticleMaterial, volumeHolder.transform, area.x, (int)area.y);
        }
示例#2
0
 public void Remove()
 {
     if (volumeHolder != null)
     {
         volumeHolder.transform.parent = null;
         volumeManager.Destroy();
         volumeManager = null;
         GameObject.Destroy(volumeHolder);
         volumeHolder = null;
     }
 }
        public void Apply(CloudsMaterial material, float radius, Transform parent)
        {
            Remove();
            particleMaterial.MaxScale = size.y;
            particleMaterial.MaxTrans = maxTranslation;
            particleMaterial.NoiseScale =  new Vector3(noiseScale.x, noiseScale.y, noiseScale.z / radius);
            ParticleMaterial = new Material(ParticleCloudShader);
            particleMaterial.ApplyMaterialProperties(ParticleMaterial);
            material.ApplyMaterialProperties(ParticleMaterial);
            ParticleMaterial.EnableKeyword("SOFT_DEPTH_ON");

            volumeHolder = new GameObject();
            //Add the renderer here so othe rentities (shadows)
            //can easily access it.
            Renderer r = volumeHolder.AddComponent<MeshRenderer>();
            r.material = ParticleMaterial;
            ParticleMaterial.SetMatrix(ShaderProperties._ShadowBodies_PROPERTY, Matrix4x4.zero);
            ParticleMaterial.renderQueue = (int)Tools.Queue.Transparent + 2;

            r.enabled = false;
            volumeHolder.transform.parent = parent;
            volumeHolder.transform.localPosition = Vector3.zero;
            volumeHolder.transform.localScale = Vector3.one;
            volumeHolder.transform.localRotation = Quaternion.identity;
            volumeHolder.layer = (int)Tools.Layer.Local;
            volumeManager = new VolumeManager(radius, size, ParticleMaterial, volumeHolder.transform, area.x, (int)area.y);
            
        }
 public void Remove()
 {
     if (volumeHolder != null)
     {
         volumeHolder.transform.parent = null;
         volumeManager.Destroy();
         volumeManager = null;
         GameObject.Destroy(volumeHolder);
         volumeHolder = null;
     }
 }