예제 #1
0
        public static void UpdateFlare(LightId id, ref MyFlareDesc glare)
        {
            var oldFlareId = m_lights.Data[id.Index].FlareId;

            m_lights.Data[id.Index].FlareId = MyFlareRenderer.Set(m_lights.Data[id.Index].FlareId, glare);
            if (m_lights.Data[id.Index].FlareId != FlareId.NULL && !m_spotlights[id.Index].Enabled && !m_pointlights[id.Index].Enabled)
            {
                DistantFlaresWithoutLight.Add(id);
            }
            else if (oldFlareId != FlareId.NULL)
            {
                DistantFlaresWithoutLight.Remove(id);
            }
        }
예제 #2
0
        public void UpdateLight()
        {
            UpdateSpotParams();

            if (m_propertiesDirty || m_positionDirty)
            {
                ProfilerShort.Begin("UpdateRenderLight");

                m_propertiesDirty = m_positionDirty = false;

                MyLightLayout pointLight = new MyLightLayout()
                {
                    Range         = Range,
                    Color         = Color,
                    Falloff       = Falloff,
                    GlossFactor   = GlossFactor,
                    DiffuseFactor = DiffuseFactor,
                };

                MySpotLightLayout spotLight = new MySpotLightLayout()
                {
                    Light = new MyLightLayout()
                    {
                        Range         = ReflectorRange,
                        Color         = ReflectorColor,
                        Falloff       = ReflectorFalloff,
                        GlossFactor   = ReflectorGlossFactor,
                        DiffuseFactor = ReflectorDiffuseFactor,
                    },
                    Up        = ReflectorUp,
                    Direction = ReflectorDirection,
                };

                MyFlareDesc glare = new MyFlareDesc()
                {
                    Enabled        = GlareOn,
                    Direction      = ReflectorDirection,
                    Range          = Range,
                    Color          = Color,
                    Type           = GlareType,
                    Size           = GlareSize,
                    QuerySize      = GlareQuerySize,
                    QueryFreqMinMs = GlareQueryFreqMinMs,
                    QueryFreqRndMs = GlareQueryFreqRndMs,
                    Intensity      = GlareIntensity,
                    Material       = MyStringId.GetOrCompute(GlareMaterial),
                    MaxDistance    = GlareMaxDistance,
                    ParentGID      = ParentID,
                };

                UpdateRenderLightData renderLightData = new UpdateRenderLightData()
                {
                    ID                       = RenderObjectID,
                    Position                 = Position,
                    Type                     = (VRageRender.LightTypeEnum)(int) LightType,
                    ParentID                 = ParentID,
                    PointPositionOffset      = PointLightOffset,
                    SpecularColor            = SpecularColor,
                    UseInForwardRender       = UseInForwardRender,
                    ReflectorConeMaxAngleCos = ReflectorConeMaxAngleCos,
                    ShadowDistance           = ShadowDistance,
                    CastShadows              = CastShadows,
                    PointLightOn             = LightOn,
                    PointLightIntensity      = Intensity,
                    PointLight               = pointLight,
                    SpotLightOn              = ReflectorOn,
                    SpotLightIntensity       = ReflectorIntensity,
                    SpotLight                = spotLight,
                    ReflectorTexture         = ReflectorTexture,
                    Glare                    = glare,
                };

                MyRenderProxy.UpdateRenderLight(ref renderLightData);

                ProfilerShort.End();
            }
        }