Пример #1
0
        static void RenderSpotLight(MyLightRenderElement lightElement, MyEffectPointLight effectPointLight)
        {
            MyLight light = lightElement.Light;

            Matrix lightViewProjectionShadow = Matrix.Identity;

            // Always cull clockwise (render inner parts of object), depth test is done in PS using light radius and cone angle
            RasterizerState.CullClockwise.Apply();
            DepthStencilState.None.Apply();

            //m_device.BlendState = BlendState.Additive;
            //Need to use max because of overshinning places where multiple lights shine
            MyStateObjects.Light_Combination_BlendState.Apply();

            if (lightElement.RenderShadows && lightElement.ShadowMap != null)
            {
                m_spotShadowRenderer.SetupSpotShadowBaseEffect(effectPointLight, lightElement.ShadowLightViewProjection, lightElement.ShadowMap);
            }
            effectPointLight.SetNearSlopeBiasDistance(4);

            effectPointLight.SetLightPosition(light.Position);
            effectPointLight.SetLightIntensity(light.Intensity);
            effectPointLight.SetSpecularLightColor(light.SpecularColor);
            effectPointLight.SetFalloff(light.Falloff);

            effectPointLight.SetLightViewProjection(lightElement.View * lightElement.Projection);
            effectPointLight.SetReflectorDirection(light.ReflectorDirection);
            effectPointLight.SetReflectorConeMaxAngleCos(1 - light.ReflectorConeMaxAngleCos);
            effectPointLight.SetReflectorColor(light.ReflectorColor);
            effectPointLight.SetReflectorRange(light.ReflectorRange);
            effectPointLight.SetReflectorIntensity(light.ReflectorIntensity);
            effectPointLight.SetReflectorTexture(light.ReflectorTexture);
            effectPointLight.SetReflectorFalloff(light.ReflectorFalloff);

            if (lightElement.RenderShadows)
                effectPointLight.SetTechnique(effectPointLight.DefaultSpotShadowTechnique);
            else
                effectPointLight.SetTechnique(effectPointLight.DefaultSpotTechnique);

            MySimpleObjectDraw.DrawConeForLight(effectPointLight, lightElement.World);
        }