Ejemplo n.º 1
0
        public void Initialize(VolumetricLightBeam master, Shader shader)
        {
            HideFlags objectsHideFlags = Consts.ProceduralObjectsHideFlags;

            this.m_Master = master;
            ((Component)this).get_transform().SetParent(((Component)master).get_transform(), false);
            this.material = new Material(shader);
            ((Object)this.material).set_hideFlags(objectsHideFlags);
            this.meshRenderer = ((Component)this).get_gameObject().GetOrAddComponent <MeshRenderer>();
            ((Object)this.meshRenderer).set_hideFlags(objectsHideFlags);
            ((Renderer)this.meshRenderer).set_material(this.material);
            ((Renderer)this.meshRenderer).set_shadowCastingMode((ShadowCastingMode)0);
            ((Renderer)this.meshRenderer).set_receiveShadows(false);
            ((Renderer)this.meshRenderer).set_lightProbeUsage((LightProbeUsage)0);
            if (SortingLayer.IsValid(this.m_Master.sortingLayerID))
            {
                this.sortingLayerID = this.m_Master.sortingLayerID;
            }
            else
            {
                Debug.LogError((object)string.Format("Beam '{0}' has an invalid sortingLayerID ({1}). Please fix it by setting a valid layer.", (object)Utils.GetPath(((Component)this.m_Master).get_transform()), (object)this.m_Master.sortingLayerID));
            }
            this.sortingOrder = this.m_Master.sortingOrder;
            this.meshFilter   = ((Component)this).get_gameObject().GetOrAddComponent <MeshFilter>();
            ((Object)this.meshFilter).set_hideFlags(objectsHideFlags);
            ((Object)((Component)this).get_gameObject()).set_hideFlags(objectsHideFlags);
        }
Ejemplo n.º 2
0
    public void IntensityChangeCheck()
    {
        lightIntensityInput.text         = lightIntensity.value.ToString();
        lightFixture.spotlight.intensity = Globals.AdjustLight(lightIntensity.value);

        colorPreview.color           = new Color(lightColorR.value / 255.0f, lightColorG.value / 255.0f, lightColorB.value / 255.0f);
        lightFixture.spotlight.color = colorPreview.color;
        lightFixture.SetEmissionColor(lightFixture.spotlight.intensity, colorPreview.color);
        lightFixture.GetComponentInChildren <VLB.BeamGeometry>().gameObject.GetComponent <Renderer>().material.SetColor("_Color", colorPreview.color);

        foreach (int id in gameManager.captureImport.channels[lightFixture.captureData.channel].lightIds)
        {
            LightFixture channelFixture = gameManager.lightManager.lightIds[id].GetComponent <LightFixture>();
            channelFixture.spotlight.intensity = Globals.AdjustLight(lightIntensity.value);
            channelFixture.SetEmissionColor(Globals.AdjustLight(lightIntensity.value), gameManager.lightManager.lightIds[id].GetComponent <LightFixture>().spotlight.color);
            if (lightFixture.spotlight.intensity > 0.05f)
            {
                if (Globals.ShowingHaze)
                {
                    VLB.VolumetricLightBeam beamComponent = gameManager.lightManager.lightIds[id].GetComponentInChildren <VLB.VolumetricLightBeam>();
                    beamComponent.enabled = true;
                    Material beamRenderer = channelFixture.GetComponentInChildren <VLB.BeamGeometry>().gameObject.GetComponent <Renderer>().material;
                    beamRenderer.SetFloat("_AlphaInside", Globals.AdjustBeamValue(Globals.LightBeamInside, lightIntensity.value));
                    beamRenderer.SetFloat("_AlphaOutside", Globals.AdjustBeamValue(Globals.LightBeamOutside, lightIntensity.value));
                }
            }
            else
            {
                gameManager.lightManager.lightIds[id].GetComponentInChildren <VLB.VolumetricLightBeam>().enabled = false;
            }
        }
    }
        protected virtual void Awake()
        {
            m_Master = GetComponent <VolumetricLightBeam>();
            Debug.Assert(m_Master);

            m_Master._INTERNAL_DynamicOcclusionMode = GetDynamicOcclusionMode();
        }
Ejemplo n.º 4
0
        public void Reset()
        {
            geometryOverrideLayer = Consts.ConfigGeometryOverrideLayerDefault;
            geometryLayerID       = Consts.ConfigGeometryLayerIDDefault;
            geometryTag           = Consts.ConfigGeometryTagDefault;
            geometryRenderQueue   = (int)Consts.ConfigGeometryRenderQueueDefault;

            beamShader1Pass = Shader.Find("Hidden/VolumetricLightBeam1Pass");
            beamShader2Pass = Shader.Find("Hidden/VolumetricLightBeam2Pass");

            sharedMeshSides    = Consts.ConfigSharedMeshSides;
            sharedMeshSegments = Consts.ConfigSharedMeshSegments;

            globalNoiseScale    = Consts.NoiseScaleDefault;
            globalNoiseVelocity = Consts.NoiseVelocityDefault;

            noise3DData = Resources.Load("Noise3D_64x64x64") as TextAsset;
            noise3DSize = Consts.ConfigNoise3DSizeDefault;

            dustParticlesPrefab = Resources.Load("DustParticles", typeof(ParticleSystem)) as ParticleSystem;

            renderPipeline = Consts.ConfigGeometryRenderPipelineDefault;
            renderingMode  = Consts.ConfigGeometryRenderingModeDefault;

#if UNITY_EDITOR
            GlobalMesh.Destroy();
            VolumetricLightBeam._EditorSetAllMeshesDirty();
            OnRenderPipelineChanged(renderPipeline);
#endif
        }
Ejemplo n.º 5
0
        void OnEnable()
        {
            m_Beam = GetComponent <VolumetricLightBeam>();
            Debug.Assert(m_Beam != null);

            m_DynamicOcclusionRaycasting = GetComponent <DynamicOcclusionRaycasting>();

            switch (updateRate)
            {
            case TriggerZoneUpdateRate.OnEnable:
            {
                ComputeZone();
                enabled = false;
                break;
            }

            case TriggerZoneUpdateRate.OnOcclusionChange:
            {
                if (m_DynamicOcclusionRaycasting)
                {
                    m_DynamicOcclusionRaycasting.onOcclusionProcessed += OnOcclusionProcessed;
                }
                break;
            }
            }
        }
Ejemplo n.º 6
0
        public void Reset()
        {
            geometryOverrideLayer = Consts.ConfigGeometryOverrideLayerDefault;
            geometryLayerID       = Consts.ConfigGeometryLayerIDDefault;
            geometryTag           = Consts.ConfigGeometryTagDefault;
            geometryRenderQueue   = (int)Consts.ConfigGeometryRenderQueueDefault;

            sharedMeshSides    = Consts.ConfigSharedMeshSides;
            sharedMeshSegments = Consts.ConfigSharedMeshSegments;

            globalNoiseScale    = Consts.NoiseScaleDefault;
            globalNoiseVelocity = Consts.NoiseVelocityDefault;

            renderPipeline  = Consts.ConfigGeometryRenderPipelineDefault;
            renderingMode   = Consts.ConfigGeometryRenderingModeDefault;
            ditheringFactor = Consts.ConfigDitheringFactor;

            fadeOutCameraTag = Consts.ConfigFadeOutCameraTagDefault;

            featureEnabledColorGradient      = Consts.ConfigFeatureEnabledColorGradientDefault;
            featureEnabledDepthBlend         = Consts.ConfigFeatureEnabledDefault;
            featureEnabledNoise3D            = Consts.ConfigFeatureEnabledDefault;
            featureEnabledDynamicOcclusion   = Consts.ConfigFeatureEnabledDefault;
            featureEnabledMeshSkewing        = Consts.ConfigFeatureEnabledDefault;
            featureEnabledShaderAccuracyHigh = Consts.ConfigFeatureEnabledDefault;

            ResetInternalData();

#if UNITY_EDITOR
            GlobalMesh.Destroy();
            VolumetricLightBeam._EditorSetAllMeshesDirty();
#endif
        }
Ejemplo n.º 7
0
        public void Initialize(VolumetricLightBeam master)
        {
            var hideFlags = Consts.ProceduralObjectsHideFlags;

            m_Master = master;
            this.Lod = m_Master.lod;
            bool noise = (m_Master.noiseEnabled && m_Master.noiseIntensity > 0f && Noise3D.isSupported);
            bool depth = (m_Master.depthBlendDistance > 0f);

            transform.SetParent(master.transform, false);
            meshRenderer = gameObject.GetOrAddComponent <MeshRenderer>();

            ChangeMat(noise, depth, false);
            meshRenderer.hideFlags         = hideFlags;
            meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
            meshRenderer.receiveShadows    = false;
            meshRenderer.lightProbeUsage   = UnityEngine.Rendering.LightProbeUsage.Off;
            meshFilter            = gameObject.GetOrAddComponent <MeshFilter>();
            meshRenderer.material = material;

            material.hideFlags = hideFlags;

            gameObject.hideFlags = hideFlags;

            gameObject.layer = Config.Instance.geometryLayerID;

            coneMesh        = MeshGenerator.GetSharedConeZ_Mesh(m_Master.geomSides);
            meshFilter.mesh = coneMesh;
            UpdateMaterialAndBounds();
        }
Ejemplo n.º 8
0
        public void Initialize(VolumetricLightBeam master, Shader shader)
        {
            HideFlags proceduralObjectsHideFlags = Consts.ProceduralObjectsHideFlags;

            this.m_Master = master;
            base.transform.SetParent(master.transform, false);
            this.material = new Material(shader)
            {
                hideFlags = proceduralObjectsHideFlags
            };
            this.meshRenderer                   = base.gameObject.GetOrAddComponent <MeshRenderer>();
            this.meshRenderer.hideFlags         = proceduralObjectsHideFlags;
            this.meshRenderer.material          = this.material;
            this.meshRenderer.shadowCastingMode = ShadowCastingMode.Off;
            this.meshRenderer.receiveShadows    = false;
            this.meshRenderer.lightProbeUsage   = LightProbeUsage.Off;
            if (!SortingLayer.IsValid(this.m_Master.sortingLayerID))
            {
                Debug.LogError(string.Format("Beam '{0}' has an invalid sortingLayerID ({1}). Please fix it by setting a valid layer.", Utils.GetPath(this.m_Master.transform), this.m_Master.sortingLayerID));
            }
            else
            {
                this.sortingLayerID = this.m_Master.sortingLayerID;
            }
            this.sortingOrder         = this.m_Master.sortingOrder;
            this.meshFilter           = base.gameObject.GetOrAddComponent <MeshFilter>();
            this.meshFilter.hideFlags = proceduralObjectsHideFlags;
            base.gameObject.hideFlags = proceduralObjectsHideFlags;
        }
Ejemplo n.º 9
0
 void SetDirty(DirtyFlags flags)
 {
     if (m_IsUsedInstance)
     {
         if (flags.HasFlag(DirtyFlags.Target))
         {
             EditorUtility.SetDirty(target);
         }
         if (flags.HasFlag(DirtyFlags.Shader))
         {
             m_NeedToRefreshShader = true;
         }
         if (flags.HasFlag(DirtyFlags.Noise))
         {
             m_NeedToReloadNoise = true;
         }
         if (flags.HasFlag(DirtyFlags.GlobalMesh))
         {
             GlobalMesh.Destroy();
         }
         if (flags.HasFlag(DirtyFlags.AllBeamGeom))
         {
             VolumetricLightBeam._EditorSetAllBeamGeomDirty();
         }
         if (flags.HasFlag(DirtyFlags.AllMeshes))
         {
             VolumetricLightBeam._EditorSetAllMeshesDirty();
         }
     }
 }
Ejemplo n.º 10
0
        public void Initialize(VolumetricLightBeam master, Shader shader)
        {
            var hideFlags = Consts.ProceduralObjectsHideFlags;

            m_Master = master;

            transform.SetParent(master.transform, false);
            material           = new Material(shader);
            material.hideFlags = hideFlags;

            meshRenderer                   = gameObject.GetOrAddComponent <MeshRenderer>();
            meshRenderer.hideFlags         = hideFlags;
            meshRenderer.material          = material;
            meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
            meshRenderer.receiveShadows    = false;
#if UNITY_5_4_OR_NEWER
            meshRenderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off;
#else
            meshRenderer.useLightProbes = false;
#endif
            sortingLayerID = m_Master.sortingLayerID;
            sortingOrder   = m_Master.sortingOrder;

            meshFilter           = gameObject.GetOrAddComponent <MeshFilter>();
            meshFilter.hideFlags = hideFlags;

            gameObject.hideFlags = hideFlags;
        }
 void Start()
 {
     isCulled = false;
     m_Master = GetComponent<VolumetricLightBeam>();
     Debug.Assert(m_Master);
     InstantiateParticleSystem();
     SetActiveAndPlay();
 }
Ejemplo n.º 12
0
 private void Start()
 {
     this.isCulled = false;
     this.m_Master = (VolumetricLightBeam)((Component)this).GetComponent <VolumetricLightBeam>();
     Debug.Assert(Object.op_Implicit((Object)this.m_Master));
     this.InstantiateParticleSystem();
     this.SetActiveAndPlay();
 }
 private void Start()
 {
     this.isCulled = false;
     this.m_Master = base.GetComponent <VolumetricLightBeam>();
     Debug.Assert(this.m_Master);
     this.InstantiateParticleSystem();
     this.SetActiveAndPlay();
 }
Ejemplo n.º 14
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            EditorGUILayout.LabelField(string.Format("Current Plugin Version: {0}", Version.Current), EditorStyles.miniBoldLabel);

            Header("Beam Geometry");
            EditorGUI.BeginChangeCheck();
            geometryLayerID.intValue = EditorGUILayout.LayerField(new GUIContent("Layer", "The layer the GameObjects holding the procedural cone meshes are created on"), geometryLayerID.intValue);
            geometryTag.stringValue  = EditorGUILayout.TagField(new GUIContent("Tag", "The tag applied on the procedural geometry GameObjects"), geometryTag.stringValue);
            if (EditorGUI.EndChangeCheck())
            {
                VolumetricLightBeam._EditorSetAllMeshesDirty();
            }
            EditorGUILayout.PropertyField(beamShader, new GUIContent("Shader", "Main shader applied to the cone beam geometry"));

            Header("Global 3D Noise");
            EditorGUILayout.PropertyField(globalNoiseScale, new GUIContent("Scale", "Global 3D Noise texture scaling: higher scale make the noise more visible, but potentially less realistic"));
            EditorGUILayout.PropertyField(globalNoiseVelocity, new GUIContent("Velocity", "Global World Space direction and speed of the noise scrolling, simulating the fog/smoke movement"));

            Header("3D Noise Texture Data");
            bool reloadNoise = false;

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(noise3DData, new GUIContent("Binary file", "Binary file holding the 3D Noise texture data (a 3D array). Must be exactly Size * Size * Size bytes long."));
            int newSizeValue = EditorGUILayout.IntField(new GUIContent("Data dimension", "Size (of one dimension) of the 3D Noise data. Must be power of 2. So if the binary file holds a 32x32x32 texture, this value must be 32.")
                                                        , noise3DSize.intValue);

            noise3DSize.intValue = Mathf.Max(2, Mathf.NextPowerOfTwo(newSizeValue));
            if (EditorGUI.EndChangeCheck())
            {
                reloadNoise = true;
            }

            if (Noise3D.isSupported && !Noise3D.isProperlyLoaded)
            {
                EditorGUILayout.HelpBox("Fail to load 3D noise texture", MessageType.Error);
            }

            Header("Volumetric Dust Particles");
            EditorGUILayout.PropertyField(dustParticlesPrefab, new GUIContent("Prefab", "ParticleSystem prefab instantiated for the Volumetric Dust Particles feature (Unity 5.5 or above)"));

            EditorGUILayout.Space();
            if (GUILayout.Button(new GUIContent("Default values", "Reset properties to their default values."), EditorStyles.miniButton))
            {
                UnityEditor.Undo.RecordObject(target, "Reset Config Properties");
                (target as Config).Reset();
            }

            serializedObject.ApplyModifiedProperties();

            if (reloadNoise)
            {
                Noise3D._EditorForceReloadData(); // Should be called AFTER ApplyModifiedProperties so the Config instance has the proper values when reloading data
            }
        }
Ejemplo n.º 15
0
        void OnEnable()
        {
            m_Master = GetComponent <VolumetricLightBeam>();
            Debug.Assert(m_Master);
#if UNITY_EDITOR
            EditorLoadPrefs();
            editorDebugData.currentOccluder = null;
            editorDebugData.lastFrameUpdate = 0;
#endif
        }
        private IEnumerator CoPlaytimeUpdate()
        {
            VolumetricLightBeam volumetricLightBeam = this;

            while (volumetricLightBeam.trackChangesDuringPlaytime && ((Behaviour)volumetricLightBeam).get_enabled())
            {
                volumetricLightBeam.UpdateAfterManualPropertyChange();
                yield return((object)null);
            }
            volumetricLightBeam.m_CoPlaytimeUpdate = (Coroutine)null;
        }
        private IEnumerator CoPlaytimeUpdate()
        {
            VolumetricLightBeam volumetricLightBeam = null;

            while (volumetricLightBeam.trackChangesDuringPlaytime && volumetricLightBeam.enabled)
            {
                volumetricLightBeam.UpdateAfterManualPropertyChange();
                yield return(null);
            }
            volumetricLightBeam.m_CoPlaytimeUpdate = null;
        }
Ejemplo n.º 18
0
    // handle zoom logic
    private void updateZoom(float zoomAngle)
    {
        // set color of the material to a gradient between the colors as listed above
        Light[] lights = GetComponentsInChildren <Light>();

        foreach (var light in lights)
        {
            VLB.VolumetricLightBeam beam = light.GetComponentInChildren <VLB.VolumetricLightBeam>();
            light.spotAngle = zoomAngle;
            beam.UpdateAfterManualPropertyChange();
        }
    }
Ejemplo n.º 19
0
        void Start()
        {
            isCulled = false;

            m_Master = GetComponent <VolumetricLightBeam>();
            Debug.Assert(m_Master);
            HandleBackwardCompatibility(m_Master._INTERNAL_pluginVersion, Version.Current);

            InstantiateParticleSystem();

            SetActiveAndPlay();
        }
Ejemplo n.º 20
0
        public void Reset()
        {
            geometryLayerID     = 1;
            beamShader          = Shader.Find("VolumetricLightBeam/Beam");
            globalNoiseScale    = Consts.NoiseScaleDefault;
            globalNoiseVelocity = Consts.NoiseVelocityDefault;
            noise3DData         = Resources.Load("Noise3D_64x64x64") as TextAsset;
            noise3DSize         = 64;
            dustParticlesPrefab = Resources.Load("DustParticles", typeof(ParticleSystem)) as ParticleSystem;
#if UNITY_EDITOR
            VolumetricLightBeam._EditorSetAllMeshesDirty();
#endif
        }
Ejemplo n.º 21
0
        public static bool CanBeBatched(VolumetricLightBeam beamA, VolumetricLightBeam beamB, ref string reasons)
        {
            bool ret = true;

            if (!CanBeBatched(beamA, ref reasons))
            {
                ret = false;
            }

            if (!CanBeBatched(beamB, ref reasons))
            {
                ret = false;
            }

            if ((beamA.GetComponent <DynamicOcclusionAbstractBase>() == null) != (beamB.GetComponent <DynamicOcclusionAbstractBase>() == null))
            {
                AppendErrorMessage(ref reasons, string.Format("{0}/{1}: dynamically occluded and non occluded beams cannot be batched together", beamA.name, beamB.name));
                ret = false;
            }

            if (beamA.colorMode != beamB.colorMode)
            {
                AppendErrorMessage(ref reasons, "Color Mode mismatch");
                ret = false;
            }

            if (beamA.blendingMode != beamB.blendingMode)
            {
                AppendErrorMessage(ref reasons, "Blending Mode mismatch");
                ret = false;
            }

            if (beamA.isNoiseEnabled != beamB.isNoiseEnabled)
            {
                AppendErrorMessage(ref reasons, "3D Noise enabled mismatch");
                ret = false;
            }

            if (!forceEnableDepthBlend)
            {
#pragma warning disable 0162
                if ((beamA.depthBlendDistance > 0) != (beamB.depthBlendDistance > 0))
                {
                    AppendErrorMessage(ref reasons, "Opaque Geometry Blending mismatch");
                    ret = false;
                }
#pragma warning restore 0162
            }

            return(ret);
        }
Ejemplo n.º 22
0
        public void Initialize(VolumetricLightBeam master)
        {
            Debug.Assert(master != null);

            var customHideFlags = Consts.ProceduralObjectsHideFlags;

            m_Master = master;

            transform.SetParent(master.transform, false);

            meshRenderer                      = gameObject.GetOrAddComponent <MeshRenderer>();
            meshRenderer.hideFlags            = customHideFlags;
            meshRenderer.shadowCastingMode    = UnityEngine.Rendering.ShadowCastingMode.Off;
            meshRenderer.receiveShadows       = false;
            meshRenderer.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off; // different reflection probes could break batching with GPU Instancing
#if UNITY_5_4_OR_NEWER
            meshRenderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off;
#else
            meshRenderer.useLightProbes = false;
#endif

            if (!shouldUseGPUInstancedMaterial)
            {
                m_CustomMaterial = MaterialManager.NewMaterial(gpuInstanced: false);
                ApplyMaterial();
            }

            if (SortingLayer.IsValid(m_Master.sortingLayerID))
            {
                sortingLayerID = m_Master.sortingLayerID;
            }
            else
            {
                Debug.LogError(string.Format("Beam '{0}' has an invalid sortingLayerID ({1}). Please fix it by setting a valid layer.", Utils.GetPath(m_Master.transform), m_Master.sortingLayerID));
            }

            sortingOrder = m_Master.sortingOrder;

            meshFilter           = gameObject.GetOrAddComponent <MeshFilter>();
            meshFilter.hideFlags = customHideFlags;

            gameObject.hideFlags = customHideFlags;

#if UNITY_EDITOR
            UnityEditor.GameObjectUtility.SetStaticEditorFlags(gameObject, master.GetStaticEditorFlagsForSubObjects());
            gameObject.SetSameSceneVisibilityStatesThan(master.gameObject);
#endif

            RestartFadeOutCoroutine();
        }
Ejemplo n.º 23
0
        public void Initialize(VolumetricLightBeam master)
        {
            var hideFlags = Consts.ProceduralObjectsHideFlags;

            m_Master = master;

            transform.SetParent(master.transform, false);

            meshRenderer                   = gameObject.GetOrAddComponent <MeshRenderer>();
            meshRenderer.hideFlags         = hideFlags;
            meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
            meshRenderer.receiveShadows    = false;
#if UNITY_5_4_OR_NEWER
            meshRenderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off;
#else
            meshRenderer.useLightProbes = false;
#endif

            if (Config.Instance.actualRenderingMode != RenderingMode.GPUInstancing)
            {
                m_CustomMaterial = MaterialManager.NewMaterial(gpuInstanced: false);
                ApplyMaterial();
            }

            if (SortingLayer.IsValid(m_Master.sortingLayerID))
            {
                sortingLayerID = m_Master.sortingLayerID;
            }
            else
            {
                Debug.LogError(string.Format("Beam '{0}' has an invalid sortingLayerID ({1}). Please fix it by setting a valid layer.", Utils.GetPath(m_Master.transform), m_Master.sortingLayerID));
            }

            sortingOrder = m_Master.sortingOrder;

            meshFilter           = gameObject.GetOrAddComponent <MeshFilter>();
            meshFilter.hideFlags = hideFlags;

            gameObject.hideFlags = hideFlags;

#if UNITY_EDITOR
            // Apply the same static flags to the BeamGeometry than the VLB GAO
            var flags = UnityEditor.GameObjectUtility.GetStaticEditorFlags(master.gameObject);
            flags &= ~(UnityEditor.StaticEditorFlags.ContributeGI); // remove the Lightmap static flag since it will generate error messages when selecting the BeamGeometry GAO in the editor
            UnityEditor.GameObjectUtility.SetStaticEditorFlags(gameObject, flags);
#endif

            RestartFadeOutCoroutine();
        }
Ejemplo n.º 24
0
        public static void AddComponentFromEditor <TComp>(VolumetricLightBeam self) where TComp : Component
        {
            if (self)
            {
                if (self.GetComponent <TComp>() == null)
                {
                    var comp = Undo.AddComponent <TComp>(self.gameObject);

                    if (comp is DynamicOcclusionRaycasting)
                    {
                        (comp as DynamicOcclusionRaycasting).dimensions = self.dimensions;
                    }
                }
            }
        }
Ejemplo n.º 25
0
    // handle color changes
    // @REACH: true color wheel implementation
    private void UpdateColor(int c)
    {
        // set color of the material to a gradient between the colors as listed above
        Light[] lights = GetComponentsInChildren <Light>();

        foreach (var light in lights)
        {
            VLB.VolumetricLightBeam beam = light.GetComponentInChildren <VLB.VolumetricLightBeam>();

            // single color
            if (c < 128)
            {
                // set the color of the beam
                Color set = sharpyColor[c];
                light.color = new Color(set.r, set.g, set.b, lightAlpha);
                beam.UpdateAfterManualPropertyChange();

                // COMMENTED OUT: code for blending, but that's not what we really want
                //int colorIndex = c / 9; // which color a we're mixing;
                //int step = c % 9; // step between color a and b
                //float mix = step / 9f; // the mix between color a and b

                //// get the colors
                //Color a = sharpyColor[colorIndex];
                //Color b;

                //// wrap around for color b
                //if (colorIndex < 14)
                //    b = sharpyColor[colorIndex + 1];
                //else
                //    b = sharpyColor[0];

                //// set the material's color
                //Color mixed = Color.Lerp(a, b, mix);
                //rend.material.color = new Color (mixed.r, mixed.g, mixed.b, 0.5f);

                //// may use this mixing instead if not satisfied with Lerp color mixing above
                //// Color mixed = LerpHSV(a, b, mix);
                //// rend.material.color = new Color (mixed.r, mixed.g, mixed.b, 0.5f);
            }
            // rotating color wheel
            else
            {
                // rotate colors
            }
        }
    }
Ejemplo n.º 26
0
        public static bool CanBeBatched(VolumetricLightBeam beam, ref string reasons)
        {
            bool ret = true;

            if (beam.geomMeshType != MeshType.Shared)
            {
                AppendErrorMessage(ref reasons, string.Format("{0} is not using shared mesh", beam.name));
                ret = false;
            }

            if (beam.GetComponent <DynamicOcclusionDepthBuffer>())
            {
                AppendErrorMessage(ref reasons, string.Format("{0} is using the DynamicOcclusion DepthBuffer feature", beam.name));
                ret = false;
            }
            return(ret);
        }
Ejemplo n.º 27
0
        public static bool CanBeBatched(VolumetricLightBeam beam, ref string reason)
        {
            bool ret = true;

            if (beam.geomMeshType != MeshType.Shared)
            {
                AppendErrorMessage(ref reason, string.Format("{0} is not using shared mesh", beam.name));
                ret = false;
            }

            if (beam.GetComponent <DynamicOcclusion>())
            {
                AppendErrorMessage(ref reason, string.Format("{0}: dynamically occluded and non occluded beams cannot be batched together", beam.name));
                ret = false;
            }
            return(ret);
        }
Ejemplo n.º 28
0
        public static bool CanBeBatched(VolumetricLightBeam beamA, VolumetricLightBeam beamB, ref string reasons)
        {
            bool ret = true;

            if (!CanBeBatched(beamA, ref reasons))
            {
                ret = false;
            }

            if (!CanBeBatched(beamB, ref reasons))
            {
                ret = false;
            }

            if (beamA.colorMode != beamB.colorMode)
            {
                AppendErrorMessage(ref reasons, "Color Mode mismatch");
                ret = false;
            }

            if (beamA.blendingMode != beamB.blendingMode)
            {
                AppendErrorMessage(ref reasons, "Blending Mode mismatch");
                ret = false;
            }

            if (beamA.noiseEnabled != beamB.noiseEnabled)
            {
                AppendErrorMessage(ref reasons, "3D Noise enabled mismatch");
                ret = false;
            }

            if (!forceEnableDepthBlend)
            {
#pragma warning disable 0162
                if ((beamA.depthBlendDistance > 0) != (beamB.depthBlendDistance > 0))
                {
                    AppendErrorMessage(ref reasons, "Opaque Geometry Blending mismatch");
                    ret = false;
                }
#pragma warning restore 0162
            }

            return(ret);
        }
Ejemplo n.º 29
0
        public void Initialize(VolumetricLightBeam master)
        {
            var hideFlags = Consts.ProceduralObjectsHideFlags;

            m_Master = master;

            transform.SetParent(master.transform, false);

            meshRenderer                   = gameObject.GetOrAddComponent <MeshRenderer>();
            meshRenderer.hideFlags         = hideFlags;
            meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
            meshRenderer.receiveShadows    = false;
#if UNITY_5_4_OR_NEWER
            meshRenderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off;
#else
            meshRenderer.useLightProbes = false;
#endif

            if (Config.Instance.actualRenderingMode != RenderingMode.GPUInstancing)
            {
                m_CustomMaterial = MaterialManager.NewMaterial(gpuInstanced: false);
                ApplyMaterial();
            }

            if (SortingLayer.IsValid(m_Master.sortingLayerID))
            {
                sortingLayerID = m_Master.sortingLayerID;
            }
            else
            {
                Debug.LogError(string.Format("Beam '{0}' has an invalid sortingLayerID ({1}). Please fix it by setting a valid layer.", Utils.GetPath(m_Master.transform), m_Master.sortingLayerID));
            }

            sortingOrder = m_Master.sortingOrder;

            meshFilter           = gameObject.GetOrAddComponent <MeshFilter>();
            meshFilter.hideFlags = hideFlags;

            gameObject.hideFlags = hideFlags;

            RestartFadeOutCoroutine();
        }
Ejemplo n.º 30
0
        public static bool CanBeBatched(VolumetricLightBeam beam, ref string reasons)
        {
            bool ret = true;

            if (Config.Instance.actualRenderingMode == RenderingMode.GPUInstancing)
            {
                if (beam.geomMeshType != MeshType.Shared)
                {
                    AppendErrorMessage(ref reasons, string.Format("{0} is not using shared mesh", beam.name));
                    ret = false;
                }
            }

            if (Config.Instance.featureEnabledDynamicOcclusion && beam.GetComponent <DynamicOcclusionDepthBuffer>() != null)
            {
                AppendErrorMessage(ref reasons, string.Format("{0} is using the DynamicOcclusion DepthBuffer feature", beam.name));
                ret = false;
            }
            return(ret);
        }