protected override void OnUpdate()
        {
            var ambientProbe = RenderSettings.ambientProbe;
            var updateAll    = ambientProbe != m_LastAmbientProbe;

            if (updateAll)
            {
                m_Query.ResetFilter();
            }

            m_LastAmbientProbe = ambientProbe;

            var job = new UpdateSHValuesJob
            {
                Properties = new SHProperties(ambientProbe),
                SHArType   = GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHAr>(),
                SHAgType   = GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHAg>(),
                SHAbType   = GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHAb>(),
                SHBrType   = GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHBr>(),
                SHBgType   = GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHBg>(),
                SHBbType   = GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHBb>(),
                SHCType    = GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHC>(),
            };

            Dependency = job.ScheduleParallel(m_Query, Dependency);

            if (updateAll)
            {
                m_Query.SetChangedVersionFilter(ComponentType.ReadWrite <AmbientProbeTag>());
            }
        }
예제 #2
0
        protected override void OnUpdate()
        {
            CleanUpCompletedJobs();

            var lightProbesQuery = new LightProbesQuery(Allocator.Persistent);

            if (m_UpdateAll)
            {
                m_Query.ResetFilter();
            }

            var job = new UpdateSHValuesJob
            {
                lightProbesQuery = lightProbesQuery,
                SHArType         = GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHAr>(),
                SHAgType         = GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHAg>(),
                SHAbType         = GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHAb>(),
                SHBrType         = GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHBr>(),
                SHBgType         = GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHBg>(),
                SHBbType         = GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHBb>(),
                SHCType          = GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHC>(),
                LocalToWorldType = GetComponentTypeHandle <LocalToWorld>(),
            };

            Dependency = job.ScheduleParallel(m_Query, Dependency);
            m_ScheduledJobs.Add(Dependency, lightProbesQuery);

            if (m_UpdateAll)
            {
                m_Query.SetChangedVersionFilter(ComponentType.ReadOnly <LocalToWorld>());
                m_UpdateAll = false;
            }
        }
        private static void UpdateEntitiesFromAmbientProbe(
            LightProbeUpdateSystem system,
            EntityQuery query,
            ComponentType[] queryFilter,
            SphericalHarmonicsL2 ambientProbe,
            SphericalHarmonicsL2 lastProbe)
        {
            Profiler.BeginSample("UpdateEntitiesFromAmbientProbe");
            var updateAll = ambientProbe != lastProbe;

            if (updateAll)
            {
                query.ResetFilter();
            }

            var job = new UpdateSHValuesJob
            {
                Properties = new SHProperties(ambientProbe),
                SHArType   = system.GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHAr>(),
                SHAgType   = system.GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHAg>(),
                SHAbType   = system.GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHAb>(),
                SHBrType   = system.GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHBr>(),
                SHBgType   = system.GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHBg>(),
                SHBbType   = system.GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHBb>(),
                SHCType    = system.GetComponentTypeHandle <BuiltinMaterialPropertyUnity_SHC>(),
            };

            system.Dependency = job.ScheduleParallel(query, system.Dependency);

            if (updateAll)
            {
                query.SetChangedVersionFilter(queryFilter);
            }
            Profiler.EndSample();
        }