• Advertisement
Sign in to follow this  

Deactivating vertex colours (MDX):

This topic is 3735 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to use the effect files referenced in my mesh file as defaults and then overwrite one or two properties during runtime. It's probably not a good idea to do that, but I don't think it's the cause of the problem I'm having. I want to treat vertex colours as a type of light, so that when I switch off the both the lights and the textures, the mesh will appear as plain white. As far as I know, setting the ColorVertex property as false should prevent the vertex colours from being used. However when I switch off the lights and texture the vertex colours are still displayed. I found a way around it using the TextureFactor, but I'd prefere to use the ColorVertex property as I don't like the idea of changing the render states in the middle of an effext pass.
            m_xDevice.Transform.World =
                Matrix.Translation(Position - Centre) *
                Matrix.Scaling(Scale, Scale, Scale) *

            StateBackup xStateBackup = new StateBackup(ref m_xDevice);

                #region Render with effects

                for (int i = 0; i < m_axEffects.Length; i++)
                    int iPasses = m_axEffects[i].Begin(FX.None);

                    for (int p = 0; p < iPasses; p++)

                        if (xStateBackup.m_eColorOperation == TextureOperation.SelectArg1 ||
                            xStateBackup.m_eColorOperation == TextureOperation.SelectArg2)
                            m_xDevice.TextureState[0].ColorOperation = xStateBackup.m_eColorOperation;
                        else if (xStateBackup.m_eColorOperation == TextureOperation.Disable)
                            m_xDevice.RenderState.ColorVertex = false;
                            m_xDevice.RenderState.TextureFactor = unchecked((int)0xFFFFFFFF);
                            m_xDevice.TextureState[0].ColorOperation = TextureOperation.SelectArg2;
                            m_xDevice.TextureState[0].ColorArgument2 = TextureArgument.TFactor;

                        m_xDevice.RenderState.Lighting &= xStateBackup.m_bLighting;

                        m_xDevice.SamplerState[0].MagFilter = xStateBackup.m_eMagFilter;
                        m_xDevice.SamplerState[0].MinFilter = xStateBackup.m_eMinFilter;

                        m_xDevice.Material = m_axMaterials[i];
                        m_xDevice.SetTexture(0, m_axTextures[i]);




BTW, when I start an effect or a pass do all the original render states and texture states get backed up or just the ones that got changed for that pass?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement