Exemplo n.º 1
0
        /// <summary>
        /// Lazily recomputes the world inverse transpose matrix and
        /// eye position based on the current effect parameter settings.
        /// </summary>
        internal static EffectDirtyFlags SetLightingMatrices(EffectDirtyFlags dirtyFlags, ref Matrix world, ref Matrix view,
                                                             EffectParameter worldParam, EffectParameter worldInverseTransposeParam, EffectParameter eyePositionParam)
        {
            // Set the world and world inverse transpose matrices.
            if ((dirtyFlags & EffectDirtyFlags.World) != 0)
            {
                Matrix worldTranspose;
                Matrix worldInverseTranspose;

                Matrix.Invert(ref world, out worldTranspose);
                Matrix.Transpose(ref worldTranspose, out worldInverseTranspose);

                worldParam.SetValue(world);
                worldInverseTransposeParam.SetValue(worldInverseTranspose);

                dirtyFlags &= ~EffectDirtyFlags.World;
            }

            // Set the eye position.
            if ((dirtyFlags & EffectDirtyFlags.EyePosition) != 0)
            {
                Matrix viewInverse;

                Matrix.Invert(ref view, out viewInverse);

                eyePositionParam.SetValue(viewInverse.Translation);

                dirtyFlags &= ~EffectDirtyFlags.EyePosition;
            }

            return dirtyFlags;
        }
Exemplo n.º 2
0
 internal static EffectDirtyFlags SetWorldViewProjAndFog(EffectDirtyFlags dirtyFlags, ref Matrix world, ref Matrix view, ref Matrix projection, ref Matrix worldView, bool fogEnabled, float fogStart, float fogEnd, EffectParameter worldViewProjParam, EffectParameter fogVectorParam)
 {
     if ((dirtyFlags & EffectDirtyFlags.WorldViewProj) != ~EffectDirtyFlags.All)
     {
         Matrix.Multiply(ref world, ref view, out worldView);
         Matrix result;
         Matrix.Multiply(ref worldView, ref projection, out result);
         worldViewProjParam.SetValue(result);
         dirtyFlags &= ~EffectDirtyFlags.WorldViewProj;
     }
     if (fogEnabled)
     {
         if ((dirtyFlags & (EffectDirtyFlags.Fog | EffectDirtyFlags.FogEnable)) != ~EffectDirtyFlags.All)
         {
             EffectHelpers.SetFogVector(ref worldView, fogStart, fogEnd, fogVectorParam);
             dirtyFlags &= ~(EffectDirtyFlags.Fog | EffectDirtyFlags.FogEnable);
         }
     }
     else if ((dirtyFlags & EffectDirtyFlags.FogEnable) != ~EffectDirtyFlags.All)
     {
         fogVectorParam.SetValue(Vector4.Zero);
         dirtyFlags &= ~EffectDirtyFlags.FogEnable;
     }
     return(dirtyFlags);
 }
        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        protected internal override void OnApply()
        {
            // Recompute the world+view+projection matrix or fog vector?
            dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam);

            // Recompute the diffuse/alpha material color parameter?
            if ((dirtyFlags & EffectDirtyFlags.MaterialColor) != 0)
            {
                diffuseColorParam.SetValue(new Vector4(diffuseColor * alpha, alpha));

                dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
            }

            // Recompute the shader index?
            if ((dirtyFlags & EffectDirtyFlags.ShaderIndex) != 0)
            {
                int shaderIndex = 0;

                if (!fogEnabled)
                {
                    shaderIndex += 1;
                }

                if (vertexColorEnabled)
                {
                    shaderIndex += 2;
                }

                dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;

                CurrentTechnique = Techniques[shaderIndex];
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Lazily recomputes the world inverse transpose matrix and
        /// eye position based on the current effect parameter settings.
        /// </summary>
        internal static EffectDirtyFlags SetLightingMatrices(EffectDirtyFlags dirtyFlags, ref Matrix world, ref Matrix view,
                                                             EffectParameter worldParam, EffectParameter worldInverseTransposeParam, EffectParameter eyePositionParam)
        {
            // Set the world and world inverse transpose matrices.
            if ((dirtyFlags & EffectDirtyFlags.World) != 0)
            {
                Matrix worldTranspose;
                Matrix worldInverseTranspose;

                Matrix.Invert(ref world, out worldTranspose);
                Matrix.Transpose(ref worldTranspose, out worldInverseTranspose);

                worldParam.SetValue(world);
                worldInverseTransposeParam.SetValue(worldInverseTranspose);

                dirtyFlags &= ~EffectDirtyFlags.World;
            }

            // Set the eye position.
            if ((dirtyFlags & EffectDirtyFlags.EyePosition) != 0)
            {
                Matrix viewInverse;

                Matrix.Invert(ref view, out viewInverse);

                eyePositionParam.SetValue(viewInverse.Translation);

                dirtyFlags &= ~EffectDirtyFlags.EyePosition;
            }

            return(dirtyFlags);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        protected internal override EffectPass OnApply(EffectPass pass)
        {
            // Recompute the world+view+projection matrix or fog vector?
            dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam);

            // Recompute the world inverse transpose and eye position?
            dirtyFlags = EffectHelpers.SetLightingMatrices(dirtyFlags, ref world, ref view, worldParam, worldInverseTransposeParam, eyePositionParam);

            // Recompute the diffuse/emissive/alpha material color parameters?
            if ((dirtyFlags & EffectDirtyFlags.MaterialColor) != 0)
            {
                EffectHelpers.SetMaterialColor(true, alpha, ref diffuseColor, ref emissiveColor, ref ambientLightColor, diffuseColorParam, emissiveColorParam);

                dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
            }

            // Check if we can use the only-bother-with-the-first-light shader optimization.
            bool newOneLight = !light1.Enabled && !light2.Enabled;

            if (oneLight != newOneLight)
            {
                oneLight    = newOneLight;
                dirtyFlags |= EffectDirtyFlags.ShaderIndex;
            }

            // Recompute the shader index?
            if ((dirtyFlags & EffectDirtyFlags.ShaderIndex) != 0)
            {
                int shaderIndex = 0;

                if (!fogEnabled)
                {
                    shaderIndex += 1;
                }

                if (weightsPerVertex == 2)
                {
                    shaderIndex += 2;
                }
                else if (weightsPerVertex == 4)
                {
                    shaderIndex += 4;
                }

                if (preferPerPixelLighting)
                {
                    shaderIndex += 12;
                }
                else if (oneLight)
                {
                    shaderIndex += 6;
                }

                shaderPass = pass.SubPasses[shaderIndex];

                dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;
            }

            return(base.OnApply(shaderPass));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create a new <see cref="VolumeRaycastingEffect"/> instance.
        /// </summary>
        /// <param name="graphicsDevice">The <see cref="GraphicsDevice"/> instance to render this effect.</param>
        internal VolumeRaycastingEffect(GraphicsDevice graphicsDevice) : base(graphicsDevice, typeof(VolumeRaycastingEffect))
        {
            this.dirtyFlags |= EffectDirtyFlags.WorldViewProjectionMatrix;
            this.mode        = EffectMode.ColorFromScreenSpacePosition;

            this.InitializeFullScreenQuad();
        }
Exemplo n.º 7
0
 internal static EffectDirtyFlags SetWorldViewProjAndFog(EffectDirtyFlags dirtyFlags, ref Matrix world, ref Matrix view, ref Matrix projection, ref Matrix worldView, bool fogEnabled, float fogStart, float fogEnd, EffectParameter worldViewProjParam, EffectParameter fogVectorParam)
 {
   if ((dirtyFlags & EffectDirtyFlags.WorldViewProj) != ~EffectDirtyFlags.All)
   {
     Matrix.Multiply(ref world, ref view, out worldView);
     Matrix result;
     Matrix.Multiply(ref worldView, ref projection, out result);
     worldViewProjParam.SetValue(result);
     dirtyFlags &= ~EffectDirtyFlags.WorldViewProj;
   }
   if (fogEnabled)
   {
     if ((dirtyFlags & (EffectDirtyFlags.Fog | EffectDirtyFlags.FogEnable)) != ~EffectDirtyFlags.All)
     {
       EffectHelpers.SetFogVector(ref worldView, fogStart, fogEnd, fogVectorParam);
       dirtyFlags &= ~(EffectDirtyFlags.Fog | EffectDirtyFlags.FogEnable);
     }
   }
   else if ((dirtyFlags & EffectDirtyFlags.FogEnable) != ~EffectDirtyFlags.All)
   {
     fogVectorParam.SetValue(Vector4.Zero);
     dirtyFlags &= ~EffectDirtyFlags.FogEnable;
   }
   return dirtyFlags;
 }
Exemplo n.º 8
0
        protected override void OnApply()
        {
            _pRange.SetValue(_range);
            _pIntensity.SetValue(_intensity);
            _pPosition.SetValue(_position);
            _pDepth.SetValue(_depth);
            _pLightDir.SetValue(_lightDir);
            _pInner.SetValue(_inner);
            _pOuter.SetValue(_outer);


            if ((dirtyFlags & EffectDirtyFlags.ShaderIndex) != 0)
            {
                int shaderIndex = 0;

                if (_shadowEnabled)
                {
                    shaderIndex += 1;
                }

                if (_normalmapEnabled)
                {
                    shaderIndex += 2;
                }

                if (_useSpotLight)
                {
                    shaderIndex += 4;
                }

                dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;

                CurrentTechnique = Techniques[shaderIndex];
            }
        }
Exemplo n.º 9
0
 protected internal override bool OnApply()
 {
     this.dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(this.dirtyFlags, ref this.world, ref this.view, ref this.projection, ref this.worldView, this.fogEnabled, this.fogStart, this.fogEnd, this.worldViewProjParam, this.fogVectorParam);
     if ((this.dirtyFlags & EffectDirtyFlags.MaterialColor) != ~EffectDirtyFlags.All)
     {
         this.diffuseColorParam.SetValue(new Vector4(this.diffuseColor * this.alpha, this.alpha));
         this.dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
     }
     if ((this.dirtyFlags & EffectDirtyFlags.ShaderIndex) != ~EffectDirtyFlags.All)
     {
         int num = 0;
         if (!this.fogEnabled)
         {
             ++num;
         }
         if (this.vertexColorEnabled)
         {
             num += 2;
         }
         this.dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;
         if (this._shaderIndex != num)
         {
             this._shaderIndex     = num;
             this.CurrentTechnique = this.Techniques[this._shaderIndex];
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        protected override void OnApply()
        {
            // Recompute the world+view+projection matrix or fog vector?
            dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam);

            // Recompute the world inverse transpose and eye position?
            dirtyFlags = EffectHelpers.SetLightingMatrices(dirtyFlags, ref world, ref view, worldParam, worldInverseTransposeParam, eyePositionParam);
        }
Exemplo n.º 11
0
        public void Begin(CommandEncoder commandEncoder)
        {
            commandEncoder.SetPipelineLayout(_pipelineLayout);

            _dirtyFlags |= EffectDirtyFlags.PipelineState;

            OnBegin();
        }
Exemplo n.º 12
0
 protected internal override bool OnApply()
 {
     this.dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(this.dirtyFlags, ref this.world, ref this.view, ref this.projection, ref this.worldView, this.fogEnabled, this.fogStart, this.fogEnd, this.worldViewProjParam, this.fogVectorParam);
     if ((this.dirtyFlags & EffectDirtyFlags.MaterialColor) != ~EffectDirtyFlags.All)
     {
         EffectHelpers.SetMaterialColor(this.lightingEnabled, this.alpha, ref this.diffuseColor, ref this.emissiveColor, ref this.ambientLightColor, this.diffuseColorParam, this.emissiveColorParam);
         this.dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
     }
     if (this.lightingEnabled)
     {
         this.dirtyFlags = EffectHelpers.SetLightingMatrices(this.dirtyFlags, ref this.world, ref this.view, this.worldParam, this.worldInverseTransposeParam, this.eyePositionParam);
         bool flag = !this.light1.Enabled && !this.light2.Enabled;
         if (this.oneLight != flag)
         {
             this.oneLight    = flag;
             this.dirtyFlags |= EffectDirtyFlags.ShaderIndex;
         }
     }
     if ((this.dirtyFlags & EffectDirtyFlags.ShaderIndex) != ~EffectDirtyFlags.All)
     {
         int num = 0;
         if (!this.fogEnabled)
         {
             ++num;
         }
         if (this.vertexColorEnabled)
         {
             num += 2;
         }
         if (this.textureEnabled)
         {
             num += 4;
         }
         if (this.lightingEnabled)
         {
             if (this.preferPerPixelLighting)
             {
                 num += 24;
             }
             else if (this.oneLight)
             {
                 num += 16;
             }
             else
             {
                 num += 8;
             }
         }
         this.dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;
         if (this._shaderIndex != num)
         {
             this._shaderIndex     = num;
             this.CurrentTechnique = this.Techniques[this._shaderIndex];
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 13
0
        public void ApplyPipelineState(CommandList commandEncoder)
        {
            if (_dirtyFlags.HasFlag(EffectDirtyFlags.PipelineState))
            {
                commandEncoder.SetPipeline(_pipelineState);

                _dirtyFlags &= ~EffectDirtyFlags.PipelineState;
            }
        }
Exemplo n.º 14
0
        public void Begin(CommandList commandEncoder)
        {
            _dirtyFlags |= EffectDirtyFlags.PipelineState;

            foreach (var parameter in _parameters.Values)
            {
                parameter.SetDirty();
            }
        }
Exemplo n.º 15
0
        protected internal override void OnApply()
        {
            dirtyFlags = EffectHelpers.SetWorldViewProj(dirtyFlags, ref world, ref view, ref projection, ref worldView, worldViewProjParam);

            if ((dirtyFlags & EffectDirtyFlags.MaterialColor) != 0)
            {
                EffectHelpers.SetMaterialColor(false, alpha, ref diffuseColor, ref emissiveColor, ref ambientLightColor, diffuseColorParam, null);
                dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        protected internal override void OnApply()
        {
            // Recompute the world+view+projection matrix or fog vector?
            dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam);

            // Recompute the world inverse transpose and eye position?
            dirtyFlags = EffectHelpers.SetLightingMatrices(dirtyFlags, ref world, ref view, worldParam, worldInverseTransposeParam, eyePositionParam);

            // Recompute the diffuse/emissive/alpha material color parameters?
            if ((dirtyFlags & EffectDirtyFlags.MaterialColor) != 0)
            {
                EffectHelpers.SetMaterialColor(true, alpha, ref diffuseColor, ref emissiveColor, ref ambientLightColor, diffuseColorParam, emissiveColorParam);

                dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
            }

            // Check if we can use the only-bother-with-the-first-light shader optimization.
            bool newOneLight = !light1.Enabled && !light2.Enabled;

            if (oneLight != newOneLight)
            {
                oneLight    = newOneLight;
                dirtyFlags |= EffectDirtyFlags.ShaderIndex;
            }

            // Recompute the shader index?
            if ((dirtyFlags & EffectDirtyFlags.ShaderIndex) != 0)
            {
                int shaderIndex = 0;

                if (!fogEnabled)
                {
                    shaderIndex += 1;
                }

                if (fresnelEnabled)
                {
                    shaderIndex += 2;
                }

                if (specularEnabled)
                {
                    shaderIndex += 4;
                }

                if (oneLight)
                {
                    shaderIndex += 8;
                }

                dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;

                CurrentTechnique = Techniques[shaderIndex];
            }
        }
Exemplo n.º 17
0
        public void SetPipelineState(EffectPipelineStateHandle pipelineStateHandle)
        {
            if (_pipelineStateHandle == pipelineStateHandle)
            {
                return;
            }

            _pipelineStateHandle = pipelineStateHandle;
            _pipelineState       = GetPipelineState(pipelineStateHandle);
            _dirtyFlags         |= EffectDirtyFlags.PipelineState;
        }
Exemplo n.º 18
0
        /// <summary>
        /// Checks to see whether the shader index for the specified effect has possibly changed.
        /// </summary>
        public static Boolean CheckForShaderIndexChanges <TEffect>(TEffect effect, EffectDirtyFlags dirtyFlags, ref Boolean oneLight)
            where TEffect : IEffectLights
        {
            var oneLightNew = !effect.DirectionalLight1.Enabled && !effect.DirectionalLight2.Enabled;

            if (oneLightNew != oneLight)
            {
                oneLight = oneLightNew;
                return(true);
            }
            return((dirtyFlags & EffectDirtyFlags.ShaderIndex) == EffectDirtyFlags.ShaderIndex);
        }
Exemplo n.º 19
0
        public void Apply(CommandEncoder commandEncoder)
        {
            if (_dirtyFlags.HasFlag(EffectDirtyFlags.PipelineState))
            {
                commandEncoder.SetPipelineState(_pipelineState);

                _dirtyFlags &= ~EffectDirtyFlags.PipelineState;
            }

            foreach (var parameter in _parameters.Values)
            {
                parameter.ApplyChanges(commandEncoder);
            }
        }
Exemplo n.º 20
0
 internal static EffectDirtyFlags SetWorldViewProjAndFog(
     EffectDirtyFlags dirtyFlags,
     ref Matrix world,
     ref Matrix view,
     ref Matrix projection,
     ref Matrix worldView,
     bool fogEnabled,
     float fogStart,
     float fogEnd,
     EffectParameter worldParam,
     EffectParameter viewParam,
     EffectParameter projectionParam,
     EffectParameter fogStartParam,
     EffectParameter fogEndParam,
     EffectParameter fogEnabledParam,
     EffectParameter fogColorParam,
     Vector3 fogColor)
 {
     if ((dirtyFlags & EffectDirtyFlags.WorldViewProj) != ~EffectDirtyFlags.All)
     {
         //   Matrix.Multiply(ref world, ref view, out worldView);
         //    Matrix result;
         //   Matrix.Multiply(ref worldView, ref projection, out result);
         // worldViewProjParam.SetValue(result);
         worldParam.SetValue(world);
         viewParam.SetValue(view);
         projectionParam.SetValue(projection);
         dirtyFlags &= ~EffectDirtyFlags.WorldViewProj;
     }
     if (fogEnabled)
     {
         if ((dirtyFlags & (EffectDirtyFlags.Fog | EffectDirtyFlags.FogEnable)) != ~EffectDirtyFlags.All)
         {
             // SetFogVector(ref worldView, fogStart, fogEnd, fogVectorParam);
             fogStartParam.SetValue(fogStart);
             fogEndParam.SetValue(fogEnd);
             fogEnabledParam.SetValue(1f);
             fogColorParam.SetValue(fogColor);
             dirtyFlags &= ~(EffectDirtyFlags.Fog | EffectDirtyFlags.FogEnable);
         }
     }
     else if ((dirtyFlags & EffectDirtyFlags.FogEnable) != ~EffectDirtyFlags.All)
     {
         fogEnabledParam.SetValue(0f);
         //fogVectorParam.SetValue(Vector4.Zero);
         dirtyFlags &= ~EffectDirtyFlags.FogEnable;
     }
     return(dirtyFlags);
 }
Exemplo n.º 21
0
        /// <summary>
        /// Updates the basic effect parameters for the specified effect.
        /// </summary>
        public static void UpdateEffectParameters <TEffect>(TEffect effect, EffectDirtyFlags dirtyFlags, OpenGLBasicEffectParameterBlock parameters, ref Matrix worldView)
            where TEffect : IEffectMatrices, IEffectFog, IEffectLights, IEffectTexture, IEffectMaterialColor
        {
            if ((dirtyFlags & EffectDirtyFlags.SrgbColor) == EffectDirtyFlags.SrgbColor)
            {
                if (parameters.SrgbColor != null)
                {
                    parameters.SrgbColor.SetValue(effect.SrgbColor);
                }
            }

            if ((dirtyFlags & EffectDirtyFlags.MaterialColor) == EffectDirtyFlags.MaterialColor)
            {
                UpdateEffectMaterialColor(effect, parameters);
            }

            if ((dirtyFlags & EffectDirtyFlags.MaterialTexture) == EffectDirtyFlags.MaterialTexture)
            {
                if (parameters.Texture != null)
                {
                    parameters.Texture.SetValue(effect.Texture);
                }
            }

            if ((dirtyFlags & EffectDirtyFlags.World) == EffectDirtyFlags.World)
            {
                UpdateEffectWorld(effect, parameters);
            }

            if ((dirtyFlags & EffectDirtyFlags.WorldViewProjection) == EffectDirtyFlags.WorldViewProjection)
            {
                UpdateEffectWorldViewProj(effect, parameters, ref worldView);
            }

            if ((dirtyFlags & EffectDirtyFlags.EyePosition) == EffectDirtyFlags.EyePosition)
            {
                UpdateEffectEyePosition(effect, parameters);
            }

            if ((dirtyFlags & EffectDirtyFlags.Fog) == EffectDirtyFlags.Fog || (dirtyFlags & EffectDirtyFlags.FogEnabled) == EffectDirtyFlags.FogEnabled)
            {
                UpdateEffectFog(effect, parameters, ref worldView);
            }

            effect.DirectionalLight0.Apply();
            effect.DirectionalLight1.Apply();
            effect.DirectionalLight2.Apply();
        }
Exemplo n.º 22
0
        /// <summary>
        /// Lazily recomputes the world+view+projection matrix and
        /// fog vector based on the current effect parameter settings.
        /// </summary>
        internal static EffectDirtyFlags SetWorldViewProjAndFog(EffectDirtyFlags dirtyFlags,
                                                                ref Matrix world, ref Matrix view, ref Matrix projection, ref Matrix worldView,
                                                                ref Matrix worldViewProj)
        {
            // Recompute the world+view+projection matrix?
            if ((dirtyFlags & EffectDirtyFlags.WorldViewProj) != 0)
            {
                Matrix.Multiply(ref world, ref view, out worldView);
                Matrix.Multiply(ref worldView, ref projection, out worldViewProj);

                //worldViewProjParam.SetValue(worldViewProj);

                dirtyFlags &= ~EffectDirtyFlags.WorldViewProj;
            }

            return(dirtyFlags);
        }
Exemplo n.º 23
0
        internal static EffectDirtyFlags SetWorldViewProj(EffectDirtyFlags dirtyFlags, ref Matrix world,
                                                          ref Matrix view, ref Matrix projection, ref Matrix worldView, EffectParameter worldViewProjParam)
        {
            if ((dirtyFlags & EffectDirtyFlags.WorldViewProj) != 0)
            {
                Matrix worldViewProj;

                Matrix.Multiply(ref world, ref view, out worldView);

                Matrix.Multiply(ref worldView, ref projection, out worldViewProj);

                worldViewProjParam.SetValue(worldViewProj);
                dirtyFlags &= ~EffectDirtyFlags.WorldViewProj;
            }

            return(dirtyFlags);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Lazily recomputes the world+view+projection matrix and
        /// fog vector based on the current effect parameter settings.
        /// </summary>
        internal static EffectDirtyFlags SetWorldViewProjAndFog(EffectDirtyFlags dirtyFlags,
                                                                ref Matrix world, ref Matrix view, ref Matrix projection, ref Matrix worldView,
                                                                bool fogEnabled, float fogStart, float fogEnd,
                                                                EffectParameter worldViewProjParam, EffectParameter fogVectorParam)
        {
            // Recompute the world+view+projection matrix?
            if ((dirtyFlags & EffectDirtyFlags.WorldViewProj) != 0)
            {
                Matrix worldViewProj;

                Matrix.Multiply(ref world, ref view, out worldView);
                Matrix.Multiply(ref worldView, ref projection, out worldViewProj);
                
                //worldViewProjParam.SetValue(worldViewProj);
				worldViewProjParam.SetValue(worldViewProj);

                //System.Console.WriteLine("Helper");
                dirtyFlags &= ~EffectDirtyFlags.WorldViewProj;
            }

            if (fogEnabled)
            {
                // Recompute the fog vector?
                if ((dirtyFlags & (EffectDirtyFlags.Fog | EffectDirtyFlags.FogEnable)) != 0)
                {
                    SetFogVector(ref worldView, fogStart, fogEnd, fogVectorParam);

                    dirtyFlags &= ~(EffectDirtyFlags.Fog | EffectDirtyFlags.FogEnable);
                }
            }
            else
            {
                // When fog is disabled, make sure the fog vector is reset to zero.
                if ((dirtyFlags & EffectDirtyFlags.FogEnable) != 0)
                {
                    fogVectorParam.SetValue(Vector4.Zero);

                    dirtyFlags &= ~EffectDirtyFlags.FogEnable;
                }
            }

            return dirtyFlags;
        }
Exemplo n.º 25
0
        /// <summary>
        /// Lazily recomputes the world+view+projection matrix and
        /// fog vector based on the current effect parameter settings.
        /// </summary>
        internal static EffectDirtyFlags SetWorldViewProjAndFog(EffectDirtyFlags dirtyFlags,
                                                                ref Matrix world, ref Matrix view, ref Matrix projection, ref Matrix worldView,
                                                                bool fogEnabled, float fogStart, float fogEnd,
                                                                EffectParameter worldViewProjParam, EffectParameter fogVectorParam)
        {
            // Recompute the world+view+projection matrix?
            if ((dirtyFlags & EffectDirtyFlags.WorldViewProj) != 0)
            {
                Matrix worldViewProj;

                Matrix.Multiply(ref world, ref view, out worldView);
                Matrix.Multiply(ref worldView, ref projection, out worldViewProj);

                //worldViewProjParam.SetValue(worldViewProj);
                worldViewProjParam.SetValue(worldViewProj);

                //System.Console.WriteLine("Helper");
                dirtyFlags &= ~EffectDirtyFlags.WorldViewProj;
            }

            if (fogEnabled)
            {
                // Recompute the fog vector?
                if ((dirtyFlags & (EffectDirtyFlags.Fog | EffectDirtyFlags.FogEnable)) != 0)
                {
                    SetFogVector(ref worldView, fogStart, fogEnd, fogVectorParam);

                    dirtyFlags &= ~(EffectDirtyFlags.Fog | EffectDirtyFlags.FogEnable);
                }
            }
            else
            {
                // When fog is disabled, make sure the fog vector is reset to zero.
                if ((dirtyFlags & EffectDirtyFlags.FogEnable) != 0)
                {
                    fogVectorParam.SetValue(Vector4.Zero);

                    dirtyFlags &= ~EffectDirtyFlags.FogEnable;
                }
            }

            return(dirtyFlags);
        }
Exemplo n.º 26
0
        internal static EffectDirtyFlags SetWorldViewProjAndFog(
            EffectDirtyFlags dirtyFlags,
            ref Matrix world,
            ref Matrix view,
            ref Matrix projection,
            ref Matrix worldView,
            EffectParameter worldParam,
            EffectParameter viewParam,
            EffectParameter projectionParam)
        {
            if ((dirtyFlags & EffectDirtyFlags.WorldViewProj) != ~EffectDirtyFlags.All)
            {
                worldParam.SetValue(world);
                viewParam.SetValue(view);
                projectionParam.SetValue(projection);
                dirtyFlags &= ~EffectDirtyFlags.WorldViewProj;
            }

            return(dirtyFlags);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        internal override bool OnApply()
        {
            // Recompute the world+view+projection matrix or fog vector?
            dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, ref worldViewProj);

            if (texture != null)
            {
                device.Textures[0] = texture;
            }

            if (dirtyFlags != 0)
            {
                XnaToUnity.Matrix(worldViewProj, out worldViewProj_Property.Value);
                worldViewProj_Property.Value.m23 = 0;

                worldViewProj_Property.ApplyToMaterial(material);
            }

            return(false);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Lazily recomputes the world+view+projection matrix and
        /// fog vector based on the current effect parameter settings.
        /// </summary>
        internal static EffectDirtyFlags SetWorldViewProjAndFog(EffectDirtyFlags dirtyFlags,
                                                                ref Matrix4x4 world, ref Matrix4x4 view, ref Matrix4x4 projection, ref Matrix4x4 worldView,
                                                                bool fogEnabled, float fogStart, float fogEnd,
                                                                EffectParameter worldViewProjParam, EffectParameter fogVectorParam)
        {
            // Recompute the world+view+projection matrix?
            if ((dirtyFlags & EffectDirtyFlags.WorldViewProj) != 0)
            {
                Matrix4x4 worldViewProj;

                worldView     = world * view;
                worldViewProj = worldView * projection;

                worldViewProjParam.SetValue(worldViewProj);

                dirtyFlags &= ~EffectDirtyFlags.WorldViewProj;
            }

            if (fogEnabled)
            {
                // Recompute the fog vector?
                if ((dirtyFlags & (EffectDirtyFlags.Fog | EffectDirtyFlags.FogEnable)) != 0)
                {
                    SetFogVector(ref worldView, fogStart, fogEnd, fogVectorParam);

                    dirtyFlags &= ~(EffectDirtyFlags.Fog | EffectDirtyFlags.FogEnable);
                }
            }
            else
            {
                // When fog is disabled, make sure the fog vector is reset to zero.
                if ((dirtyFlags & EffectDirtyFlags.FogEnable) != 0)
                {
                    fogVectorParam.SetValue(Vector4.Zero);

                    dirtyFlags &= ~EffectDirtyFlags.FogEnable;
                }
            }

            return(dirtyFlags);
        }
Exemplo n.º 29
0
 internal static EffectDirtyFlags SetLightingMatrices(EffectDirtyFlags dirtyFlags, ref Matrix world, ref Matrix view, EffectParameter worldParam, EffectParameter worldInverseTransposeParam, EffectParameter eyePositionParam)
 {
     if ((dirtyFlags & EffectDirtyFlags.World) != ~EffectDirtyFlags.All)
     {
         Matrix result1;
         Matrix.Invert(ref world, out result1);
         Matrix result2;
         Matrix.Transpose(ref result1, out result2);
         worldParam.SetValue(world);
         worldInverseTransposeParam.SetValue(result2);
         dirtyFlags &= ~EffectDirtyFlags.World;
     }
     if ((dirtyFlags & EffectDirtyFlags.EyePosition) != ~EffectDirtyFlags.All)
     {
         Matrix result;
         Matrix.Invert(ref view, out result);
         eyePositionParam.SetValue(result.Translation);
         dirtyFlags &= ~EffectDirtyFlags.EyePosition;
     }
     return(dirtyFlags);
 }
Exemplo n.º 30
0
 internal static EffectDirtyFlags SetLightingMatrices(EffectDirtyFlags dirtyFlags, ref Matrix world, ref Matrix view, EffectParameter worldParam, EffectParameter worldInverseTransposeParam, EffectParameter eyePositionParam)
 {
   if ((dirtyFlags & EffectDirtyFlags.World) != ~EffectDirtyFlags.All)
   {
     Matrix result1;
     Matrix.Invert(ref world, out result1);
     Matrix result2;
     Matrix.Transpose(ref result1, out result2);
     worldParam.SetValue(world);
     worldInverseTransposeParam.SetValue(result2);
     dirtyFlags &= ~EffectDirtyFlags.World;
   }
   if ((dirtyFlags & EffectDirtyFlags.EyePosition) != ~EffectDirtyFlags.All)
   {
     Matrix result;
     Matrix.Invert(ref view, out result);
     eyePositionParam.SetValue(result.Translation);
     dirtyFlags &= ~EffectDirtyFlags.EyePosition;
   }
   return dirtyFlags;
 }
Exemplo n.º 31
0
        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        protected override void OnApply()
        {
            // Recompute the world+view+projection matrix or fog vector?
            dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam);

            // Recompute the world inverse transpose and eye position?
            dirtyFlags = EffectHelpers.SetLightingMatrices(dirtyFlags, ref world, ref view, worldParam, worldInverseTransposeParam, eyePositionParam);
            
            // Recompute the diffuse/emissive/alpha material color parameters?
            if ((dirtyFlags & EffectDirtyFlags.MaterialColor) != 0)
            {
                EffectHelpers.SetMaterialColor(true, alpha, ref diffuseColor, ref emissiveColor, ref ambientLightColor, diffuseColorParam, emissiveColorParam);

                dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
            }

            // Check if we can use the only-bother-with-the-first-light shader optimization.
            bool newOneLight = !light1.Enabled && !light2.Enabled;
            
            if (oneLight != newOneLight)
            {
                oneLight = newOneLight;
                dirtyFlags |= EffectDirtyFlags.ShaderIndex;
            }

            // Recompute the shader index?
            if ((dirtyFlags & EffectDirtyFlags.ShaderIndex) != 0)
            {
                int shaderIndex = 0;
                
                if (!fogEnabled)
                    shaderIndex += 1;
                
                if (weightsPerVertex == 2)
                    shaderIndex += 2;
                else if (weightsPerVertex == 4)
                    shaderIndex += 4;
                
                if (preferPerPixelLighting)
                    shaderIndex += 12;
                else if (oneLight)
                    shaderIndex += 6;

                shaderIndexParam.SetValue(shaderIndex);

                dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;
            }
        }
Exemplo n.º 32
0
 public void SetPipelineState(EffectPipelineStateHandle pipelineStateHandle)
 {
     _pipelineState = GetPipelineState(pipelineStateHandle);
     _dirtyFlags   |= EffectDirtyFlags.PipelineState;
 }
Exemplo n.º 33
0
        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        protected internal override EffectPass OnApply(EffectPass pass)
        {
            // Make sure that domain, hull and geometry shaders are disable.
            GraphicsDevice.DomainShaderStage.Set(null);
            GraphicsDevice.HullShaderStage.Set(null);
            GraphicsDevice.GeometryShaderStage.Set(null);

            // Recompute the world+view+projection matrix or fog vector?
            dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam);

            // Recompute the diffuse/emissive/alpha material color parameters?
            if ((dirtyFlags & EffectDirtyFlags.MaterialColor) != 0)
            {
                EffectHelpers.SetMaterialColor(lightingEnabled, alpha, ref diffuseColor, ref emissiveColor, ref ambientLightColor, diffuseColorParam, emissiveColorParam);

                dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
            }

            if (lightingEnabled)
            {
                // Recompute the world inverse transpose and eye position?
                dirtyFlags = EffectHelpers.SetLightingMatrices(dirtyFlags, ref world, ref view, worldParam, worldInverseTransposeParam, eyePositionParam);

                // Check if we can use the only-bother-with-the-first-light shader optimization.
                bool newOneLight = !light1.Enabled && !light2.Enabled;

                if (oneLight != newOneLight)
                {
                    oneLight    = newOneLight;
                    dirtyFlags |= EffectDirtyFlags.ShaderIndex;
                }
            }

            // Recompute the shader index?
            if ((dirtyFlags & EffectDirtyFlags.ShaderIndex) != 0)
            {
                int shaderIndex = 0;

                if (!fogEnabled)
                {
                    shaderIndex += 1;
                }

                if (vertexColorEnabled)
                {
                    shaderIndex += 2;
                }

                if (textureEnabled)
                {
                    shaderIndex += 4;
                }

                if (lightingEnabled)
                {
                    if (preferPerPixelLighting)
                    {
                        shaderIndex += 24;
                    }
                    else if (oneLight)
                    {
                        shaderIndex += 16;
                    }
                    else
                    {
                        shaderIndex += 8;
                    }
                }

                shaderPass = pass.SubPasses[shaderIndex];

                dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;
            }

            // Call the base class to process callbacks
            pass = base.OnApply(shaderPass);

            return(pass);
        }
Exemplo n.º 34
0
        ///// <summary>
        ///// Creates a new AlphaTestEffect by cloning parameter settings from an existing instance.
        ///// </summary>
        //protected AlphaTestEffect(AlphaTestEffect cloneSource)
        //    : base(cloneSource)
        //{
        //    fogEnabled = cloneSource.fogEnabled;
        //    vertexColorEnabled = cloneSource.vertexColorEnabled;

        //    world = cloneSource.world;
        //    view = cloneSource.view;
        //    projection = cloneSource.projection;

        //    diffuseColor = cloneSource.diffuseColor;

        //    alpha = cloneSource.alpha;

        //    fogStart = cloneSource.fogStart;
        //    fogEnd = cloneSource.fogEnd;
            
        //    alphaFunction = cloneSource.alphaFunction;
        //    referenceAlpha = cloneSource.referenceAlpha;
        //}


        ///// <summary>
        ///// Creates a clone of the current AlphaTestEffect instance.
        ///// </summary>
        //public override Effect Clone()
        //{
        //    return new AlphaTestEffect(this);
        //}

        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        protected internal override EffectPass OnApply(EffectPass pass)
        {
            // Recompute the world+view+projection matrix or fog vector?
            dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam);

            // Recompute the diffuse/alpha material color parameter?
            if ((dirtyFlags & EffectDirtyFlags.MaterialColor) != 0)
            {
                diffuseColorParam.SetValue(new Vector4(diffuseColor * alpha, alpha));

                dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
            }

            // Recompute the alpha test settings?
            if ((dirtyFlags & EffectDirtyFlags.AlphaTest) != 0)
            {
                var alphaTest = new Vector4();
                bool eqNe = false;
                
                // Convert reference alpha from 8 bit integer to 0-1 float format.
                float reference = (float)referenceAlpha / 255f;
                
                // Comparison tolerance of half the 8 bit integer precision.
                const float threshold = 0.5f / 255f;
                
                switch (alphaFunction)
                {
                    case Direct3D11.Comparison.Less:
                        // Shader will evaluate: clip((a < x) ? z : w)
                        alphaTest.X = reference - threshold;
                        alphaTest.Z = 1;
                        alphaTest.W = -1;
                        break;

                    case Direct3D11.Comparison.LessEqual:
                        // Shader will evaluate: clip((a < x) ? z : w)
                        alphaTest.X = reference + threshold;
                        alphaTest.Z = 1;
                        alphaTest.W = -1;
                        break;

                    case Direct3D11.Comparison.GreaterEqual:
                        // Shader will evaluate: clip((a < x) ? z : w)
                        alphaTest.X = reference - threshold;
                        alphaTest.Z = -1;
                        alphaTest.W = 1;
                        break;

                    case Direct3D11.Comparison.Greater:
                        // Shader will evaluate: clip((a < x) ? z : w)
                        alphaTest.X = reference + threshold;
                        alphaTest.Z = -1;
                        alphaTest.W = 1;
                        break;

                    case Direct3D11.Comparison.Equal:
                        // Shader will evaluate: clip((abs(a - x) < Y) ? z : w)
                        alphaTest.X = reference;
                        alphaTest.Y = threshold;
                        alphaTest.Z = 1;
                        alphaTest.W = -1;
                        eqNe = true;
                        break;

                    case Direct3D11.Comparison.NotEqual:
                        // Shader will evaluate: clip((abs(a - x) < Y) ? z : w)
                        alphaTest.X = reference;
                        alphaTest.Y = threshold;
                        alphaTest.Z = -1;
                        alphaTest.W = 1;
                        eqNe = true;
                        break;

                    case Direct3D11.Comparison.Never:
                        // Shader will evaluate: clip((a < x) ? z : w)
                        alphaTest.Z = -1;
                        alphaTest.W = -1;
                        break;

                    case Direct3D11.Comparison.Always:
                    default:
                        // Shader will evaluate: clip((a < x) ? z : w)
                        alphaTest.Z = 1;
                        alphaTest.W = 1;
                        break;
                }
                
                alphaTestParam.SetValue(alphaTest);

                dirtyFlags &= ~EffectDirtyFlags.AlphaTest;
                
                // If we changed between less/greater vs. equal/notequal
                // compare modes, we must also update the shader index.
                if (isEqNe != eqNe)
                {
                    isEqNe = eqNe;
                    dirtyFlags |= EffectDirtyFlags.ShaderIndex;
                }
            }

            // Recompute the shader index?
            if ((dirtyFlags & EffectDirtyFlags.ShaderIndex) != 0)
            {
                int shaderIndex = 0;
                
                if (!fogEnabled)
                    shaderIndex += 1;
                
                if (vertexColorEnabled)
                    shaderIndex += 2;
                
                if (isEqNe)
                    shaderIndex += 4;

                shaderPass = pass.SubPasses[shaderIndex];

                dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;
            }

            return base.OnApply(shaderPass);
        }
Exemplo n.º 35
0
        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        protected override void OnApply()
        {
            if (!CastingShadow)
            {
                // Recompute the world+view+projection matrix or fog vector?
                dirtyFlags = SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref lightView, ref animateLightView, ref projection, ref lightProjection, ref animateLightProjection, ref worldView, ref lightWorldView, ref animateLightWorldView, fogEnabled, fogStart, fogEnd, ViewProjParam, lightWorldViewProjParam, animateLightWorldViewProjParam, fogVectorParam);

                // Recompute the world inverse transpose and eye position?
                dirtyFlags = SetLightingMatrices(dirtyFlags, ref world, ref view, worldParam, worldInverseTransposeParam, eyePositionParam);

                // Recompute the diffuse/emissive/alpha material color parameters?
                if ((dirtyFlags & EffectDirtyFlags.MaterialColor) != 0)
                {
                    SetMaterialColor(true, alpha, ref diffuseColor, ref emissiveColor, ref ambientLightColor, diffuseColorParam, emissiveColorParam);

                    dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
                }

                // Check if we can use the only-bother-with-the-first-light shader optimization.
                bool newOneLight = !light1.Enabled && !light2.Enabled;

                if (oneLight != newOneLight)
                {
                    oneLight = newOneLight;
                }
            }
        }
Exemplo n.º 36
0
        ///<summary> /// Lazily recomputes the world+view+projection matrix and
        /// fog vector based on the current effect parameter settings.
        /// </summary>
        public virtual EffectDirtyFlags SetWorldViewProjAndFog(EffectDirtyFlags dirtyFlags,
                                                                ref Matrix world, ref Matrix view, ref Matrix lightView, ref Matrix animateLightView, ref Matrix projection, ref Matrix lightProjection, ref Matrix animateLightProjection,
                                                                ref Matrix worldView, ref Matrix lightWorldView, ref Matrix animateLightWorldView, bool fogEnabled, float fogStart, float fogEnd,
                                                                EffectParameter ViewProjParam, EffectParameter lightWorldViewProjParam, EffectParameter animateLightWorldViewProjParam, EffectParameter fogVectorParam)
        {
            // Recompute the world+view+projection matrix?
            if ((dirtyFlags & (EffectDirtyFlags.ViewProj | EffectDirtyFlags.LightWorldViewProj)) != 0)
            {
                Matrix ViewProj;

                Matrix.Multiply(ref view, ref projection, out ViewProj);

                ViewProjParam.SetValue(ViewProj);

                dirtyFlags &= ~EffectDirtyFlags.ViewProj;

                Matrix lightWorldViewProj;

                Matrix.Multiply(ref world, ref lightView, out lightWorldView);
                Matrix.Multiply(ref lightWorldView, ref lightProjection, out lightWorldViewProj);

                lightWorldViewProjParam.SetValue(lightWorldViewProj);

                dirtyFlags &= ~EffectDirtyFlags.LightWorldViewProj;

                Matrix animateLightWorldViewProj;

                Matrix.Multiply(ref world, ref animateLightView, out animateLightWorldView);
                Matrix.Multiply(ref animateLightWorldView, ref animateLightProjection, out animateLightWorldViewProj);

                animateLightWorldViewProjParam.SetValue(animateLightWorldViewProj);

                dirtyFlags &= ~EffectDirtyFlags.AnimateLightWorldViewProj;
            }

            if (fogEnabled)
            {
                // Recompute the fog vector?
                if ((dirtyFlags & (EffectDirtyFlags.Fog | EffectDirtyFlags.FogEnable)) != 0)
                {
                    SetFogVector(ref worldView, fogStart, fogEnd, fogVectorParam);

                    dirtyFlags &= ~(EffectDirtyFlags.Fog | EffectDirtyFlags.FogEnable);
                }
            }
            else
            {
                // When fog is disabled, make sure the fog vector is reset to zero.
                if ((dirtyFlags & EffectDirtyFlags.FogEnable) != 0)
                {
                    fogVectorParam.SetValue(Vector4.Zero);

                    dirtyFlags &= ~EffectDirtyFlags.FogEnable;
                }
            }

            return dirtyFlags;
        }
Exemplo n.º 37
0
        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        protected override void OnApply()
        {
            // Recompute the world+view+projection matrix or fog vector?
            dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam);

            // Recompute the diffuse/emissive/alpha material color parameters?
            if ((dirtyFlags & EffectDirtyFlags.MaterialColor) != 0)
            {
                EffectHelpers.SetMaterialColor(lightingEnabled, alpha, ref diffuseColor, ref emissiveColor, ref ambientLightColor, diffuseColorParam, emissiveColorParam);

                dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
            }

            if (lightingEnabled)
            {
                // Recompute the world inverse transpose and eye position?
                dirtyFlags = EffectHelpers.SetLightingMatrices(dirtyFlags, ref world, ref view, worldParam, worldInverseTransposeParam, eyePositionParam);

                // Check if we can use the only-bother-with-the-first-light shader optimization.
                bool newOneLight = !light1.Enabled && !light2.Enabled;

                if (oneLight != newOneLight)
                {
                    oneLight    = newOneLight;
                    dirtyFlags |= EffectDirtyFlags.ShaderIndex;
                }
            }

            // Recompute the shader index?
            if ((dirtyFlags & EffectDirtyFlags.ShaderIndex) != 0)
            {
                int shaderIndex = 0;

                if (!fogEnabled)
                {
                    shaderIndex += 1;
                }

                if (vertexColorEnabled)
                {
                    shaderIndex += 2;
                }

                if (textureEnabled)
                {
                    shaderIndex += 4;
                }

                if (lightingEnabled)
                {
                    if (preferPerPixelLighting)
                    {
                        shaderIndex += 24;
                    }
                    else if (oneLight)
                    {
                        shaderIndex += 16;
                    }
                    else
                    {
                        shaderIndex += 8;
                    }
                }

                shaderIndexParam.SetValue(shaderIndex);

                dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;
            }
        }
Exemplo n.º 38
0
 protected internal override bool OnApply()
 {
   this.dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(this.dirtyFlags, ref this.world, ref this.view, ref this.projection, ref this.worldView, this.fogEnabled, this.fogStart, this.fogEnd, this.worldViewProjParam, this.fogVectorParam);
   if ((this.dirtyFlags & EffectDirtyFlags.MaterialColor) != ~EffectDirtyFlags.All)
   {
     EffectHelpers.SetMaterialColor(this.lightingEnabled, this.alpha, ref this.diffuseColor, ref this.emissiveColor, ref this.ambientLightColor, this.diffuseColorParam, this.emissiveColorParam);
     this.dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
   }
   if (this.lightingEnabled)
   {
     this.dirtyFlags = EffectHelpers.SetLightingMatrices(this.dirtyFlags, ref this.world, ref this.view, this.worldParam, this.worldInverseTransposeParam, this.eyePositionParam);
     bool flag = !this.light1.Enabled && !this.light2.Enabled;
     if (this.oneLight != flag)
     {
       this.oneLight = flag;
       this.dirtyFlags |= EffectDirtyFlags.ShaderIndex;
     }
   }
   if ((this.dirtyFlags & EffectDirtyFlags.ShaderIndex) != ~EffectDirtyFlags.All)
   {
     int num = 0;
     if (!this.fogEnabled)
       ++num;
     if (this.vertexColorEnabled)
       num += 2;
     if (this.textureEnabled)
       num += 4;
     if (this.lightingEnabled)
     {
       if (this.preferPerPixelLighting)
         num += 24;
       else if (this.oneLight)
         num += 16;
       else
         num += 8;
     }
     this.dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;
     if (this._shaderIndex != num)
     {
       this._shaderIndex = num;
       this.CurrentTechnique = this.Techniques[this._shaderIndex];
       return true;
     }
   }
   return false;
 }
Exemplo n.º 39
0
        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        protected internal override EffectPass OnApply(EffectPass pass)
        {
            // Recompute the world+view+projection matrix or fog vector?
            dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam);

            // Recompute the diffuse/alpha material color parameter?
            if ((dirtyFlags & EffectDirtyFlags.MaterialColor) != 0)
            {
                diffuseColorParam.SetValue(new Vector4(diffuseColor * alpha, alpha));

                dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
            }

            // Recompute the shader index?
            if ((dirtyFlags & EffectDirtyFlags.ShaderIndex) != 0)
            {
                int shaderIndex = 0;
                
                if (!fogEnabled)
                    shaderIndex += 1;
                
                if (vertexColorEnabled)
                    shaderIndex += 2;

                shaderPass = pass.SubPasses[shaderIndex];

                dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;
            }

            return base.OnApply(shaderPass);
        }
Exemplo n.º 40
0
        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        protected internal override bool OnApply()
        {
            // Recompute the world+view+projection matrix or fog vector?
            dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam);

            // Recompute the world inverse transpose and eye position?
            dirtyFlags = EffectHelpers.SetLightingMatrices(dirtyFlags, ref world, ref view, worldParam, worldInverseTransposeParam, eyePositionParam);
            
            // Recompute the diffuse/emissive/alpha material color parameters?
            if ((dirtyFlags & EffectDirtyFlags.MaterialColor) != 0)
            {
                EffectHelpers.SetMaterialColor(true, alpha, ref diffuseColor, ref emissiveColor, ref ambientLightColor, diffuseColorParam, emissiveColorParam);

                dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
            }

            // Check if we can use the only-bother-with-the-first-light shader optimization.
            bool newOneLight = !light1.Enabled && !light2.Enabled;
            
            if (oneLight != newOneLight)
            {
                oneLight = newOneLight;
                dirtyFlags |= EffectDirtyFlags.ShaderIndex;
            }

            // Recompute the shader index?
            if ((dirtyFlags & EffectDirtyFlags.ShaderIndex) != 0)
            {
                int shaderIndex = 0;
                
                if (!fogEnabled)
                    shaderIndex += 1;
                
                if (fresnelEnabled)
                    shaderIndex += 2;
                
                if (specularEnabled)
                    shaderIndex += 4;

                if (oneLight)
                    shaderIndex += 8;

                dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;

                if (_shaderIndex != shaderIndex)
                {
                    _shaderIndex = shaderIndex;
                    CurrentTechnique = Techniques[_shaderIndex];
                    return true;
                }
            }

            return false;
        }
Exemplo n.º 41
0
 protected internal override bool OnApply()
 {
   this.dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(this.dirtyFlags, ref this.world, ref this.view, ref this.projection, ref this.worldView, this.fogEnabled, this.fogStart, this.fogEnd, this.worldViewProjParam, this.fogVectorParam);
   if ((this.dirtyFlags & EffectDirtyFlags.MaterialColor) != ~EffectDirtyFlags.All)
   {
     this.diffuseColorParam.SetValue(new Vector4(this.diffuseColor * this.alpha, this.alpha));
     this.dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
   }
   if ((this.dirtyFlags & EffectDirtyFlags.AlphaTest) != ~EffectDirtyFlags.All)
   {
     Vector4 vector4 = new Vector4();
     bool flag = false;
     float num = (float) this.referenceAlpha / (float) byte.MaxValue;
     switch (this.alphaFunction)
     {
       case CompareFunction.Never:
         vector4.Z = -1f;
         vector4.W = -1f;
         break;
       case CompareFunction.Less:
         vector4.X = num - 0.001960784f;
         vector4.Z = 1f;
         vector4.W = -1f;
         break;
       case CompareFunction.LessEqual:
         vector4.X = num + 0.001960784f;
         vector4.Z = 1f;
         vector4.W = -1f;
         break;
       case CompareFunction.Equal:
         vector4.X = num;
         vector4.Y = 0.001960784f;
         vector4.Z = 1f;
         vector4.W = -1f;
         flag = true;
         break;
       case CompareFunction.GreaterEqual:
         vector4.X = num - 0.001960784f;
         vector4.Z = -1f;
         vector4.W = 1f;
         break;
       case CompareFunction.Greater:
         vector4.X = num + 0.001960784f;
         vector4.Z = -1f;
         vector4.W = 1f;
         break;
       case CompareFunction.NotEqual:
         vector4.X = num;
         vector4.Y = 0.001960784f;
         vector4.Z = -1f;
         vector4.W = 1f;
         flag = true;
         break;
       default:
         vector4.Z = 1f;
         vector4.W = 1f;
         break;
     }
     this.alphaTestParam.SetValue(vector4);
     this.dirtyFlags &= ~EffectDirtyFlags.AlphaTest;
     if (this.isEqNe != flag)
     {
       this.isEqNe = flag;
       this.dirtyFlags |= EffectDirtyFlags.ShaderIndex;
     }
   }
   if ((this.dirtyFlags & EffectDirtyFlags.ShaderIndex) != ~EffectDirtyFlags.All)
   {
     int num = 0;
     if (!this.fogEnabled)
       ++num;
     if (this.vertexColorEnabled)
       num += 2;
     if (this.isEqNe)
       num += 4;
     this.dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;
     if (this._shaderIndex != num)
     {
       this._shaderIndex = num;
       this.CurrentTechnique = this.Techniques[this._shaderIndex];
       return true;
     }
   }
   return false;
 }
Exemplo n.º 42
0

        
Exemplo n.º 43
0
        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        protected internal override bool OnApply()
        {
            // Recompute the world+view+projection matrix or fog vector?
            dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam);
            
            // Recompute the diffuse/emissive/alpha material color parameters?
            if ((dirtyFlags & EffectDirtyFlags.MaterialColor) != 0)
            {
                EffectHelpers.SetMaterialColor(lightingEnabled, alpha, ref diffuseColor, ref emissiveColor, ref ambientLightColor, diffuseColorParam, emissiveColorParam);

                dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
            }

            if (lightingEnabled)
            {
                // Recompute the world inverse transpose and eye position?
                dirtyFlags = EffectHelpers.SetLightingMatrices(dirtyFlags, ref world, ref view, worldParam, worldInverseTransposeParam, eyePositionParam);

                
                // Check if we can use the only-bother-with-the-first-light shader optimization.
                bool newOneLight = !light1.Enabled && !light2.Enabled;
                
                if (oneLight != newOneLight)
                {
                    oneLight = newOneLight;
                    dirtyFlags |= EffectDirtyFlags.ShaderIndex;
                }
            }

            // Recompute the shader index?
            if ((dirtyFlags & EffectDirtyFlags.ShaderIndex) != 0)
            {
                int shaderIndex = 0;
                
                if (!fogEnabled)
                    shaderIndex += 1;
                
                if (vertexColorEnabled)
                    shaderIndex += 2;
                
                if (textureEnabled)
                    shaderIndex += 4;

                if (lightingEnabled)
                {
                    if (preferPerPixelLighting)
                        shaderIndex += 24;
                    else if (oneLight)
                        shaderIndex += 16;
                    else
                        shaderIndex += 8;
                }

                dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;
#if PSM
#warning Major hack as PSM Shaders don't support multiple Techinques (yet)
                shaderIndex = 0;
#endif

                if (_shaderIndex != shaderIndex)
                {
                    _shaderIndex = shaderIndex;
                    CurrentTechnique = Techniques[_shaderIndex];
                    return true;
                }
            }

            return false;
        }
Exemplo n.º 44
0
 protected internal override bool OnApply()
 {
   this.dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(this.dirtyFlags, ref this.world, ref this.view, ref this.projection, ref this.worldView, this.fogEnabled, this.fogStart, this.fogEnd, this.worldViewProjParam, this.fogVectorParam);
   if ((this.dirtyFlags & EffectDirtyFlags.MaterialColor) != ~EffectDirtyFlags.All)
   {
     this.diffuseColorParam.SetValue(new Vector4(this.diffuseColor * this.alpha, this.alpha));
     this.dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
   }
   if ((this.dirtyFlags & EffectDirtyFlags.ShaderIndex) != ~EffectDirtyFlags.All)
   {
     int num = 0;
     if (!this.fogEnabled)
       ++num;
     if (this.vertexColorEnabled)
       num += 2;
     this.dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;
     if (this._shaderIndex != num)
     {
       this._shaderIndex = num;
       this.CurrentTechnique = this.Techniques[this._shaderIndex];
       return true;
     }
   }
   return false;
 }
Exemplo n.º 45
0
        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        protected internal override EffectPass OnApply(EffectPass pass)
        {
            // Make sure that domain, hull and geometry shaders are disable.
            GraphicsDevice.DomainShaderStage.Set(null);
            GraphicsDevice.HullShaderStage.Set(null);
            GraphicsDevice.GeometryShaderStage.Set(null);

            // Recompute the world+view+projection matrix or fog vector?
            dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam);
            
            // Recompute the diffuse/emissive/alpha material color parameters?
            if ((dirtyFlags & EffectDirtyFlags.MaterialColor) != 0)
            {
                EffectHelpers.SetMaterialColor(lightingEnabled, alpha, ref diffuseColor, ref emissiveColor, ref ambientLightColor, diffuseColorParam, emissiveColorParam);

                dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
            }

            if (lightingEnabled)
            {
                // Recompute the world inverse transpose and eye position?
                dirtyFlags = EffectHelpers.SetLightingMatrices(dirtyFlags, ref world, ref view, worldParam, worldInverseTransposeParam, eyePositionParam);
                
                // Check if we can use the only-bother-with-the-first-light shader optimization.
                bool newOneLight = !light1.Enabled && !light2.Enabled;
                
                if (oneLight != newOneLight)
                {
                    oneLight = newOneLight;
                    dirtyFlags |= EffectDirtyFlags.ShaderIndex;
                }
            }

            // Recompute the shader index?
            if ((dirtyFlags & EffectDirtyFlags.ShaderIndex) != 0)
            {
                int shaderIndex = 0;
                
                if (!fogEnabled)
                    shaderIndex += 1;
                
                if (vertexColorEnabled)
                    shaderIndex += 2;
                
                if (textureEnabled)
                    shaderIndex += 4;

                if (lightingEnabled)
                {
                    if (preferPerPixelLighting)
                        shaderIndex += 24;
                    else if (oneLight)
                        shaderIndex += 16;
                    else
                        shaderIndex += 8;
                }

                shaderPass = pass.SubPasses[shaderIndex];

                dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;
            }

            // Call the base class to process callbacks
            pass = base.OnApply(shaderPass);

            return pass;
        }
Exemplo n.º 46
0
        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        protected override void OnApply()
        {
            // Recompute the world+view+projection matrix or fog vector?
            dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam);

            // Recompute the world inverse transpose and eye position?
            dirtyFlags = EffectHelpers.SetLightingMatrices(dirtyFlags, ref world, ref view, worldParam, worldInverseTransposeParam, eyePositionParam);
        }
Exemplo n.º 47
0
        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        protected internal override bool OnApply()
        {
            // Recompute the world+view+projection matrix or fog vector?
            dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam);

            // Recompute the diffuse/alpha material color parameter?
            if ((dirtyFlags & EffectDirtyFlags.MaterialColor) != 0)
            {
                diffuseColorParam.SetValue(new Vector4(diffuseColor * alpha, alpha));

                dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
            }

            // Recompute the shader index?
            if ((dirtyFlags & EffectDirtyFlags.ShaderIndex) != 0)
            {
                int shaderIndex = 0;
                
                if (!fogEnabled)
                    shaderIndex += 1;
                
                if (vertexColorEnabled)
                    shaderIndex += 2;
                
                dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;

                if (_shaderIndex != shaderIndex)
                {
                    _shaderIndex = shaderIndex;
                    CurrentTechnique = Techniques[_shaderIndex];
                    return true;
                }
            }

            return false;
        }
Exemplo n.º 48
0
        /// <summary>
        /// Lazily computes derived parameter values immediately before applying the effect.
        /// </summary>
        protected internal override void OnApply()
        {
            // Recompute the world+view+projection matrix or fog vector?
            dirtyFlags = EffectHelpers.SetWorldViewProjAndFog(dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam);

            // Recompute the diffuse/alpha material color parameter?
            if ((dirtyFlags & EffectDirtyFlags.MaterialColor) != 0)
            {
                diffuseColorParam.SetValue(new Vector4(diffuseColor * alpha, alpha));

                dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
            }

            // Recompute the alpha test settings?
            if ((dirtyFlags & EffectDirtyFlags.AlphaTest) != 0)
            {
                Vector4 alphaTest = new Vector4();
                bool    eqNe      = false;

                // Convert reference alpha from 8 bit integer to 0-1 float format.
                float reference = (float)referenceAlpha / 255f;

                // Comparison tolerance of half the 8 bit integer precision.
                const float threshold = 0.5f / 255f;

                switch (alphaFunction)
                {
                case CompareFunction.Less:
                    // Shader will evaluate: clip((a < x) ? z : w)
                    alphaTest.X = reference - threshold;
                    alphaTest.Z = 1;
                    alphaTest.W = -1;
                    break;

                case CompareFunction.LessEqual:
                    // Shader will evaluate: clip((a < x) ? z : w)
                    alphaTest.X = reference + threshold;
                    alphaTest.Z = 1;
                    alphaTest.W = -1;
                    break;

                case CompareFunction.GreaterEqual:
                    // Shader will evaluate: clip((a < x) ? z : w)
                    alphaTest.X = reference - threshold;
                    alphaTest.Z = -1;
                    alphaTest.W = 1;
                    break;

                case CompareFunction.Greater:
                    // Shader will evaluate: clip((a < x) ? z : w)
                    alphaTest.X = reference + threshold;
                    alphaTest.Z = -1;
                    alphaTest.W = 1;
                    break;

                case CompareFunction.Equal:
                    // Shader will evaluate: clip((abs(a - x) < Y) ? z : w)
                    alphaTest.X = reference;
                    alphaTest.Y = threshold;
                    alphaTest.Z = 1;
                    alphaTest.W = -1;
                    eqNe        = true;
                    break;

                case CompareFunction.NotEqual:
                    // Shader will evaluate: clip((abs(a - x) < Y) ? z : w)
                    alphaTest.X = reference;
                    alphaTest.Y = threshold;
                    alphaTest.Z = -1;
                    alphaTest.W = 1;
                    eqNe        = true;
                    break;

                case CompareFunction.Never:
                    // Shader will evaluate: clip((a < x) ? z : w)
                    alphaTest.Z = -1;
                    alphaTest.W = -1;
                    break;

                case CompareFunction.Always:
                default:
                    // Shader will evaluate: clip((a < x) ? z : w)
                    alphaTest.Z = 1;
                    alphaTest.W = 1;
                    break;
                }

                alphaTestParam.SetValue(alphaTest);

                dirtyFlags &= ~EffectDirtyFlags.AlphaTest;

                // If we changed between less/greater vs. equal/notequal
                // compare modes, we must also update the shader index.
                if (isEqNe != eqNe)
                {
                    isEqNe      = eqNe;
                    dirtyFlags |= EffectDirtyFlags.ShaderIndex;
                }
            }

            // Recompute the shader index?
            if ((dirtyFlags & EffectDirtyFlags.ShaderIndex) != 0)
            {
                int shaderIndex = 0;

                if (!fogEnabled)
                {
                    shaderIndex += 1;
                }

                if (vertexColorEnabled)
                {
                    shaderIndex += 2;
                }

                if (isEqNe)
                {
                    shaderIndex += 4;
                }

                shaderIndexParam.SetValue(shaderIndex);

                dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;
            }
        }
Exemplo n.º 49
0
		/// <summary>
		/// Lazily computes derived parameter values immediately before applying the effect.
		/// </summary>
		protected internal override void OnApply ()
		{


			// Recompute the shader index?
//			if ((dirtyFlags & EffectDirtyFlags.ShaderIndex) != 0) {
				int shaderIndex = 0;

				if (!fogEnabled)
					shaderIndex += 1;

				if (vertexColorEnabled)
					shaderIndex += 2;

				if (textureEnabled)
					shaderIndex += 4;

				if (lightingEnabled) {
					if (preferPerPixelLighting)
						shaderIndex += 24;
					else if (oneLight)
						shaderIndex += 16;
					else
						shaderIndex += 8;
				}
//
//				//shaderIndexParam.SetValue (shaderIndex);
//
//				dirtyFlags &= ~EffectDirtyFlags.ShaderIndex;
				if (oldIndex != shaderIndex) {
					int vertexShader = VSArray[VSIndices[shaderIndex]];
					int fragmentShader = PSArray[PSIndices[shaderIndex]];
					UpdateTechnique("BasicEffect", "", vertexShader, fragmentShader);
					oldIndex = shaderIndex;
					// Update here
				}
//			}


			// These are the states that work
			GLStateManager.Projection(Projection);
			GLStateManager.WorldView(world, view);

			// Override this for now for testing purposes
			dirtyFlags |= EffectDirtyFlags.World | EffectDirtyFlags.WorldViewProj;
			dirtyFlags |= EffectDirtyFlags.WorldViewProj | EffectDirtyFlags.EyePosition;
			dirtyFlags &= ~EffectDirtyFlags.FogEnable; // turn off fog for now
			dirtyFlags |= EffectDirtyFlags.MaterialColor;

			GLStateManager.Textures2D(TextureEnabled);
			GLStateManager.ColorArray(VertexColorEnabled);

			// Recompute the world+view+projection matrix or fog vector?
			dirtyFlags = EffectHelpers.SetWorldViewProjAndFog (dirtyFlags, ref world, ref view, ref projection, ref worldView, fogEnabled, fogStart, fogEnd, worldViewProjParam, fogVectorParam);

			// Recompute the diffuse/emissive/alpha material color parameters?
			if ((dirtyFlags & EffectDirtyFlags.MaterialColor) != 0) {
				EffectHelpers.SetMaterialColor (lightingEnabled, alpha, ref diffuseColor, ref emissiveColor, ref ambientLightColor, diffuseColorParam, emissiveColorParam);

				dirtyFlags &= ~EffectDirtyFlags.MaterialColor;
			}

			if (TextureEnabled) {
				_texture.Apply();
				textureParam.SetValue(_texture);
				//System.Console.WriteLine("Texture set");
			}
//
//			if (lightingEnabled) {
//				// Recompute the world inverse transpose and eye position?
//				dirtyFlags = EffectHelpers.SetLightingMatrices (dirtyFlags, ref world, ref view, worldParam, worldInverseTransposeParam, eyePositionParam);
//                
//				// Check if we can use the only-bother-with-the-first-light shader optimization.
//				bool newOneLight = !light1.Enabled && !light2.Enabled;
//                
//				if (oneLight != newOneLight) {
//					oneLight = newOneLight;
//					dirtyFlags |= EffectDirtyFlags.ShaderIndex;
//				}
//			}




		}