Ejemplo n.º 1
0
        ////////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////////
        public virtual void Begin(BlendingMode mode)
        {
            bmode = mode;
            if (mode != BlendingMode.None)
            {
                BlendState state = states.BlendState;
                if (mode == BlendingMode.Additive)
                {
                    state = BlendState.Additive;
                }

                if (this.customMatrix.HasValue)
                {
                    sb.Begin(SpriteSortMode.Immediate, state, states.SamplerState, states.DepthStencilState, states.RasterizerState, null, this.customMatrix.Value);
                }
                else
                {
                    sb.Begin(SpriteSortMode.Immediate, state, states.SamplerState, states.DepthStencilState, states.RasterizerState);
                }
            }
            else
            {
                if (this.customMatrix.HasValue)
                {
                    sb.Begin(SpriteSortMode.Immediate, BlendState.Opaque, states.SamplerState, states.DepthStencilState, states.RasterizerState, null, this.customMatrix.Value);
                }
                else
                {
                    sb.Begin(SpriteSortMode.Immediate, BlendState.Opaque, states.SamplerState, states.DepthStencilState, states.RasterizerState);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AdaptiveBinarizeForm"/> class.
        /// </summary>
        /// <param name="viewer">The image viewer for image preview.</param>
        /// <param name="rect">Selection rectangle.</param>
        /// <param name="blendColor">Blend color.</param>
        /// <param name="blendMode">Blending mode.</param>
        public ColorBlendForm(ImageViewer viewer, Rectangle rect, Color blendColor, BlendingMode blendMode)
        {
            InitializeComponent();

            _imageProcessingPreviewInViewer = new ImageProcessingPreviewManager(viewer);
            _imageProcessingPreviewInViewer.UseCurrentViewerZoomWhenPreviewProcessing = true;

            _blendMode = blendMode;

            // set available blending modes
            Array values = Enum.GetValues(typeof(BlendingMode));

            object[] vals = new object[values.Length];
            values.CopyTo(vals, 0);
            blendModeComboBox.Items.AddRange(vals);
            blendModeComboBox.SelectedItem = blendMode;

            // set blend color
            channelAlphaTrackBar.Value = blendColor.A;
            channelRedTrackBar.Value   = blendColor.R;
            channelGreenTrackBar.Value = blendColor.G;
            channelBlueTrackBar.Value  = blendColor.B;

            _disableBlending = false;
            SetColor();
        }
Ejemplo n.º 3
0
 // Constructor
 public PresentLayer(RendererLayer layer, BlendingMode blending)
 {
     this.layer        = layer;
     this.blending     = blending;
     this.alpha        = 1f;
     this.antialiasing = false;
 }
Ejemplo n.º 4
0
 // Constructor
 public PresentLayer(RendererLayer layer)
 {
     this.layer        = layer;
     this.blending     = BlendingMode.None;
     this.alpha        = 1f;
     this.antialiasing = false;
 }
Ejemplo n.º 5
0
        public static int BlendingOperation(int pixel, int blend, BlendingMode mode)
        {
            double p = (double)pixel / 255;
            double b = (double)blend / 255;

            double result = -1;

            if (mode == BlendingMode.Multiply)
            {
                result = p * b;
            }
            else if (mode == BlendingMode.Overlay)
            {
                result = (p > 0.5 ? 1 : 0) * (1 - (1 - 2 * (p - 0.5)) * (1 - b)) + (p <= 0.5 ? 1 : 0) * ((2 * p) * b);
            }
            else if (mode == BlendingMode.Screen)
            {
                result = 1 - (1 - p) * (1 - b);
            }
            else if (mode == BlendingMode.LinearDodge)
            {
                result = p + b;
            }

            return((int)(result * 255));
        }
Ejemplo n.º 6
0
 // Constructor
 public PresentLayer(RendererLayer layer, BlendingMode blending, float alpha, bool antialiasing)
 {
     this.layer        = layer;
     this.blending     = blending;
     this.alpha        = alpha;
     this.antialiasing = antialiasing;
 }
Ejemplo n.º 7
0
        public void Reset()
        {
            colorMode      = Consts.ColorModeDefault;
            color          = Consts.FlatColor;
            colorFromLight = true;

            intensityFromLight    = true;
            intensityModeAdvanced = false;
            intensityInside       = Consts.IntensityDefault;
            intensityOutside      = Consts.IntensityDefault;

            blendingMode   = Consts.BlendingModeDefault;
            shaderAccuracy = Consts.ShaderAccuracyDefault;

            spotAngleFromLight = true;
            spotAngle          = Consts.SpotAngleDefault;

            coneRadiusStart    = Consts.ConeRadiusStart;
            geomMeshType       = Consts.GeomMeshType;
            geomCustomSides    = Consts.GeomSidesDefault;
            geomCustomSegments = Consts.GeomSegmentsDefault;
            geomCap            = Consts.GeomCap;

            attenuationEquation       = Consts.AttenuationEquationDefault;
            attenuationCustomBlending = Consts.AttenuationCustomBlending;

            fallOffEndFromLight = true;
            fallOffStart        = Consts.FallOffStart;
            fallOffEnd          = Consts.FallOffEnd;

            depthBlendDistance     = Consts.DepthBlendDistance;
            cameraClippingDistance = Consts.CameraClippingDistance;

            glareFrontal = Consts.GlareFrontal;
            glareBehind  = Consts.GlareBehind;

            fresnelPow = Consts.FresnelPow;

            noiseMode              = Consts.NoiseModeDefault;
            noiseIntensity         = Consts.NoiseIntensityDefault;
            noiseScaleUseGlobal    = true;
            noiseScaleLocal        = Consts.NoiseScaleDefault;
            noiseVelocityUseGlobal = true;
            noiseVelocityLocal     = Consts.NoiseVelocityDefault;

            sortingLayerID = 0;
            sortingOrder   = 0;

            fadeOutBegin = Consts.FadeOutBeginDefault;
            fadeOutEnd   = Consts.FadeOutEndDefault;

            dimensions = Consts.DimensionsDefault;
            tiltFactor = Consts.TiltDefault;
            skewingLocalForwardDirection = Consts.SkewingLocalForwardDirectionDefault;
            clippingPlaneTransform       = Consts.ClippingPlaneTransformDefault;

            trackChangesDuringPlaytime = false;

            m_EditorDirtyFlags = EditorDirtyFlags.Everything;
        }
Ejemplo n.º 8
0
        public ModelMaterial(byte[] inData)
        {
            using (MemoryStream ms = new MemoryStream(inData))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    this.Flags     = (MaterialFlags)br.ReadUInt32();
                    this.Shader    = (WMOFragmentShaderType)br.ReadUInt32();
                    this.BlendMode = (BlendingMode)br.ReadUInt32();

                    this.FirstTextureOffset = br.ReadUInt32();
                    this.FirstColour        = br.ReadRGBA();
                    this.FirstFlags         = (MaterialFlags)br.ReadUInt32();

                    this.SecondTextureOffset = br.ReadUInt32();
                    this.SecondColour        = br.ReadRGBA();

                    this.GroundType         = new ForeignKey <uint>(DatabaseName.TerrainType, nameof(DBCRecord.ID), br.ReadUInt32());            // TODO: Implement TerrainTypeRecord
                    this.ThirdTextureOffset = br.ReadUInt32();
                    this.BaseDiffuseColour  = br.ReadRGBA();
                    this.ThirdFlags         = (MaterialFlags)br.ReadUInt32();

                    this.RuntimeData1 = br.ReadUInt32();
                    this.RuntimeData2 = br.ReadUInt32();
                    this.RuntimeData3 = br.ReadUInt32();
                    this.RuntimeData4 = br.ReadUInt32();
                }
            }
        }
Ejemplo n.º 9
0
        public ModelMaterial(byte[] inData)
        {
            using (MemoryStream ms = new MemoryStream(inData))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    this.Flags     = (MaterialFlags)br.ReadUInt32();
                    this.Shader    = (ShaderTypes)br.ReadUInt32();
                    this.BlendMode = (BlendingMode)br.ReadUInt32();

                    this.FirstTextureOffset = br.ReadUInt32();
                    this.FirstColour        = br.ReadRGBA();
                    this.FirstFlags         = (MaterialFlags)br.ReadUInt32();

                    this.SecondTextureOffset = br.ReadUInt32();
                    this.SecondColour        = br.ReadRGBA();

                    this.GroundType         = new UInt32ForeignKey("TerrainType", "ID", br.ReadUInt32());
                    this.ThirdTextureOffset = br.ReadUInt32();
                    this.BaseDiffuseColour  = br.ReadRGBA();
                    this.ThirdFlags         = (MaterialFlags)br.ReadUInt32();

                    this.RuntimeData1 = br.ReadUInt32();
                    this.RuntimeData2 = br.ReadUInt32();
                    this.RuntimeData3 = br.ReadUInt32();
                    this.RuntimeData4 = br.ReadUInt32();
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Function to initialize the sprite object.
        /// </summary>
        private void InitSprite()
        {
            // Convert the anchor to integer values and store separately.
            // We turn off anchoring for our display sprite so that we can edit the anchor
            // without doing all kinds of weird stuff to display the sprite correctly.
            _spriteAnchor = (Point)Sprite.Anchor;
            _blendMode    = Sprite.BlendingMode;

            // Disable the sprite anchor.
            Sprite.Anchor   = Vector2.Zero;
            Sprite.Scale    = new Vector2(1);
            Sprite.Position = Vector2.Zero;

            TextureSprite = Renderer.Renderables.CreateSprite("TextureSprite", new Vector2(1), GorgonColor.Transparent);
            TextureSprite.TextureRegion = new RectangleF(0, 0, 1, 1);

            if (Sprite.Texture != null)
            {
                TextureSprite.Texture = Sprite.Texture;
                TextureSprite.Size    = Sprite.Texture.Settings.Size;
                TextureSprite.Color   = new GorgonColor(1, 1, 1, 0.35f);
            }

            _textureRect = Rectangle.Truncate(Sprite.Texture != null ? Sprite.Texture.ToPixel(Sprite.TextureRegion) : Sprite.TextureRegion);

            Vertices = new SpriteVertices(this);

            ValidateSpriteProperties();
        }
Ejemplo n.º 11
0
        static string InjectFragmentInstructions(string shader, BlendingMode blendingMode, string function)
        {
            var maskedComponent = blendingMode == BlendingMode.Classic ? ".a" : "";

            return(ModifyFunctionReturn(shader, @"fixed4", function, (varName, inputName) =>
                                        varName + maskedComponent + " *= SOFTMASK_GET_MASK(" + inputName + ");"
                                        ));
        }
Ejemplo n.º 12
0
 public void BlendUsing(BlendingMode blendingMode)
 {
     RenderStates = new RenderStates(
         blendingMode.ToSfmlBlendMode(),
         RenderStates.Transform,
         RenderStates.Texture,
         RenderStates.Shader
         );
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Handles the SelectedIndexChanged event of BlendingModeComboBox object.
 /// </summary>
 private void blendingModeComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (_isFormInitializing)
     {
         return;
     }
     _blendingMode = (BlendingMode)blendingModeComboBox.SelectedItem;
     ExecuteProcessing();
 }
Ejemplo n.º 14
0
 internal static BlendMode ToSfmlBlendMode(this BlendingMode blendingMode)
 {
     return(blendingMode switch
     {
         BlendingMode.None => BlendMode.None,
         BlendingMode.Add => BlendMode.Add,
         BlendingMode.Alpha => BlendMode.Alpha,
         BlendingMode.Multiply => BlendMode.Multiply,
         _ => RenderStates.Default.BlendMode
     });
Ejemplo n.º 15
0
 internal SpriteBase(BinaryReaderEx br, DRBVersion version) : base(br, version)
 {
     TexLeftEdge   = br.ReadInt16();
     TexTopEdge    = br.ReadInt16();
     TexRightEdge  = br.ReadInt16();
     TexBottomEdge = br.ReadInt16();
     TextureIndex  = br.ReadInt16();
     Orientation   = (SpriteOrientation)br.ReadByte();
     BlendMode     = br.ReadEnum8 <BlendingMode>();
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Creates a simple <see cref="BlendState"/> with additive blending equation parameters.
 /// </summary>
 /// <param name="isOpaque">Whether this <see cref="BlendState"/> is opaque.</param>
 public BlendState(bool isOpaque)
 {
     IsOpaque          = isOpaque;
     EquationModeRGB   = BlendingMode.FuncAdd;
     EquationModeAlpha = BlendingMode.FuncAdd;
     SourceFactorRGB   = BlendingFactor.One;
     SourceFactorAlpha = BlendingFactor.One;
     DestFactorRGB     = BlendingFactor.One;
     DestFactorAlpha   = BlendingFactor.One;
 }
Ejemplo n.º 17
0
        ////////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////////
        public virtual void Begin(BlendingMode mode)
        {
            if (mode != BlendingMode.None)
            {
                sb.Begin(SpriteSortMode.Immediate, states.BlendState, states.SamplerState, states.DepthStencilState, states.RasterizerState);
            }
            else
            {
                sb.Begin(SpriteSortMode.Immediate, BlendState.Opaque, states.SamplerState, states.DepthStencilState, states.RasterizerState);
            }
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MDXMaterial"/> class.
 /// </summary>
 /// <param name="br">The reader to read the instance from.</param>
 /// <param name="version">The version to read the instance in the context of.</param>
 public MDXMaterial(BinaryReader br, WarcraftVersion version)
 {
     Flags = (MDXRenderFlag)br.ReadUInt16();
     if (version >= WarcraftVersion.Cataclysm)
     {
         BlendMode = (BlendingMode)br.ReadUInt16();
     }
     else
     {
         BlendMode = RemapBlendingMode(br.ReadUInt16());
     }
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Creates a <see cref="BlendState"/> with a simple color-blending equation.
 /// </summary>
 /// <param name="isOpaque">Whether this <see cref="BlendState"/> is opaque.</param>
 /// <param name="equationModeRgba">The equation mode to use for the RGBA values.</param>
 /// <param name="sourceFactorRgba">The source factor to use for the RGBA values.</param>
 /// <param name="destFactorRgba">The destination factor to use for the RGBA values.</param>
 /// <param name="blendColor">The equation-constant blending color.</param>
 public BlendState(bool isOpaque, BlendingMode equationModeRgba, BlendingFactor sourceFactorRgba,
                   BlendingFactor destFactorRgba, Vector4 blendColor = default)
 {
     IsOpaque          = isOpaque;
     EquationModeRGB   = equationModeRgba;
     EquationModeAlpha = equationModeRgba;
     SourceFactorRGB   = sourceFactorRgba;
     SourceFactorAlpha = sourceFactorRgba;
     DestFactorRGB     = destFactorRgba;
     DestFactorAlpha   = destFactorRgba;
     BlendColor        = blendColor;
 }
Ejemplo n.º 20
0
// currentMonster.Name, Color.Red.ToHex(true));
// string.Format("You attempt to hit the [color:#FFFF0000]{0}[/color] but [color:{1}]MISS[/color]!",
// example:

        /// BlendingMode.Default will begin drawing using the default blend state settings.
        /// </param>
        /// <param name="mode">
        /// Specify BlendingMode.None will begin drawing in overwrite mode.
        /// <summary>
        /// Begins drawing batched objects.
        /// </summary>
        public virtual void Begin(BlendingMode mode)
        {
            bmode = mode;
            if (mode != BlendingMode.None)
            {
                sb.Begin(SpriteSortMode.Immediate, states.BlendState, states.SamplerState, states.DepthStencilState,
                         states.RasterizerState);
            }
// Grab the text color of the Enabled state.
            else
            {
                sb.Begin(SpriteSortMode.Immediate, BlendState.Opaque, states.SamplerState, states.DepthStencilState,
                         states.RasterizerState);
            }
        }
Ejemplo n.º 21
0
        public void Reset()
        {
            colorMode      = Consts.ColorModeDefault;
            color          = Consts.FlatColor;
            colorFromLight = true;

            alphaInside  = Consts.Alpha;
            alphaOutside = Consts.Alpha;
            blendingMode = Consts.BlendingModeDefault;

            spotAngleFromLight = true;
            spotAngle          = Consts.SpotAngleDefault;

            coneRadiusStart    = Consts.ConeRadiusStart;
            geomMeshType       = Consts.GeomMeshType;
            geomCustomSides    = Consts.GeomSidesDefault;
            geomCustomSegments = Consts.GeomSegmentsDefault;
            geomCap            = Consts.GeomCap;

            attenuationEquation       = Consts.AttenuationEquationDefault;
            attenuationCustomBlending = Consts.AttenuationCustomBlending;

            fadeEndFromLight = true;
            fadeStart        = Consts.FadeStart;
            fadeEnd          = Consts.FadeEnd;

            depthBlendDistance     = Consts.DepthBlendDistance;
            cameraClippingDistance = Consts.CameraClippingDistance;

            glareFrontal = Consts.GlareFrontal;
            glareBehind  = Consts.GlareBehind;

            fresnelPow = Consts.FresnelPow;

            noiseEnabled           = false;
            noiseIntensity         = Consts.NoiseIntensityDefault;
            noiseScaleUseGlobal    = true;
            noiseScaleLocal        = Consts.NoiseScaleDefault;
            noiseVelocityUseGlobal = true;
            noiseVelocityLocal     = Consts.NoiseVelocityDefault;

            sortingLayerID = 0;
            sortingOrder   = 0;

            trackChangesDuringPlaytime = false;

            m_EditorDirtyFlags = EditorDirtyFlags.Everything;
        }
Ejemplo n.º 22
0
        public static BlendMode toBlendMode(this BlendingMode B)
        {
            switch (B)
            {
            case BlendingMode.None:
                return(BlendMode.None);

            case BlendingMode.Alpha:
                return(BlendMode.Alpha);

            case BlendingMode.Add:
                return(BlendMode.Add);

            case BlendingMode.Multiply:
                return(BlendMode.Multiply);
            }
            return(BlendMode.None);
        }
Ejemplo n.º 23
0
    public static Color GetBlendingFactor( BlendingMode blend, Color s, Color d)
    {
        Color factor = new Color(1,1,1,1);

        switch (blend) {
        case BlendingMode.Color:
            factor = Color.white;
            break;
        case BlendingMode.Mask:
            factor = factor - new Color( s.a, s.a, s.a, s.a);
            break;
        case BlendingMode.Alpha:
            factor = new Color( s.a, s.a, s.a, s.a);
            break;
        }

        return factor;
    }
Ejemplo n.º 24
0
        public BlendingFactorState(BlendingMode mode)
        {
            switch (mode)
            {
            case BlendingMode.Off:
                enabled = false;
                break;

            case BlendingMode.Alphablend:
                src  = alphaSrc = BlendingFactorSrc.SrcAlpha;
                dest = alphaDest = BlendingFactorDest.OneMinusSrcAlpha;
                break;

            case BlendingMode.Color:
                src       = BlendingFactorSrc.SrcAlpha;
                dest      = BlendingFactorDest.OneMinusSrcAlpha;
                alphaSrc  = BlendingFactorSrc.Zero;
                alphaDest = BlendingFactorDest.One;
                break;

            case BlendingMode.Additive:
                src  = alphaSrc = BlendingFactorSrc.SrcAlpha;
                dest = alphaDest = BlendingFactorDest.One;
                break;

            case BlendingMode.Premultiply:
                src       = BlendingFactorSrc.SrcAlpha;
                dest      = BlendingFactorDest.OneMinusSrcAlpha;
                alphaSrc  = BlendingFactorSrc.One;
                alphaDest = BlendingFactorDest.OneMinusSrcAlpha;
                break;

            case BlendingMode.Premultiplied:
                src  = alphaSrc = BlendingFactorSrc.One;
                dest = alphaDest = BlendingFactorDest.OneMinusSrcAlpha;
                break;
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Executes the ColorBlendCommand command.
        /// </summary>
        public void ExecuteColorBlendCommand()
        {
            ColorBlendForm dlg;

            try
            {
                dlg = new ColorBlendForm(_viewer, ViewerSelectionRectangle, _blendColor, _blendMode);
            }
            catch (ImageProcessingException ex)
            {
                MessageBox.Show(ex.Message, "Image processing exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (dlg.ShowProcessingDialog())
            {
                _blendMode  = dlg.BlendMode;
                _blendColor = dlg.BlendColor;
                ColorBlendCommand command = ImageProcessingCommandFactory.CreateColorBlendCommand(_viewer.Image);
                command.BlendingMode = _blendMode;
                command.BlendColor   = _blendColor;
                ExecuteProcessingCommand(command);
            }
        }
Ejemplo n.º 26
0
 static extern void EntityParameters_SetBlendingMode(IntPtr pointer, BlendingMode value);
Ejemplo n.º 27
0
        public void RenderBSPBackToFront(BlendingMode currentTransparency, BSPNode root,
            UnlitTintedShaderDescription shader)
        {
            var d = root.Plane.Distance(EngineCamera.Position);

            if (d >= 0)
            {
                if (root.Back != null)
                {
                    RenderBSPBackToFront(currentTransparency, root.Back, shader);
                }

                foreach (var p in root.PolygonsBack)
                {
                    RenderPolygonTransparency(currentTransparency, p, shader);
                }
                foreach (var p in root.PolygonsFront)
                {
                    RenderPolygonTransparency(currentTransparency, p, shader);
                }

                if (root.Front != null)
                {
                    RenderBSPBackToFront(currentTransparency, root.Front, shader);
                }
            }
            else
            {
                if (root.Front != null)
                {
                    RenderBSPBackToFront(currentTransparency, root.Front, shader);
                }

                foreach (var p in root.PolygonsFront)
                {
                    RenderPolygonTransparency(currentTransparency, p, shader);
                }
                foreach (var p in root.PolygonsBack)
                {
                    RenderPolygonTransparency(currentTransparency, p, shader);
                }

                if (root.Back != null)
                {
                    RenderBSPBackToFront(currentTransparency, root.Back, shader);
                }
            }
        }
Ejemplo n.º 28
0
        public void RenderPolygonTransparency(BlendingMode currentTransparency, BSPFaceRef bspRef,
            UnlitTintedShaderDescription shader)
        {
            // Blending mode switcher.
            // Note that modes above 2 aren't explicitly used in TR textures, only for
            // internal particle processing. Theoretically it's still possible to use
            // them if you will force type via TRTextur utility.
            var refe = bspRef.Polygon;
            var p = refe.Polygon;
            if(currentTransparency != p.BlendMode)
            {
                currentTransparency = p.BlendMode;
                switch (p.BlendMode)
                {
                    case BlendingMode.Multiply: // Classic PC alpha
                        GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.One);
                        break;

                    case BlendingMode.InvertSrc: // Inversion by src (PS darkness) - SAME AS IN TR3-TR5
                        GL.BlendFunc(BlendingFactorSrc.Zero, BlendingFactorDest.OneMinusSrcAlpha);
                        break;

                    case BlendingMode.InvertDst: // Inversion by dest
                        GL.BlendFunc(BlendingFactorSrc.OneMinusSrcColor, BlendingFactorDest.OneMinusSrcAlpha);
                        break;

                    case BlendingMode.Screen: // Screen (smoke, etc.)
                        GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha);
                        break;

                    case BlendingMode.AnimatedTexture:
                        GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.Zero);
                        break;
                }
            }

            var mvp = Camera.GLViewProjMat.MultiplyByTransform(bspRef.Transform);

            GL.UniformMatrix4(shader.ModelViewProjection, false, ref mvp);

            refe.UsedVertexArray.Bind();
            GL.BindTexture(TextureTarget.Texture2D, World.Textures[p.TexIndex]);

            GL.DrawElements(PrimitiveType.Triangles, (int)refe.Count, DrawElementsType.UnsignedInt, (int)(sizeof(uint) * refe.FirstIndex));
        }
Ejemplo n.º 29
0
 public static void SetBlendingMode(this GraphicsDevice _, BlendingMode blendingMode)
 {
   GraphicsDeviceExtensions.blendCombiner.BlendingMode = blendingMode;
 }
Ejemplo n.º 30
0
        ////////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////////
        public virtual void Begin(BlendingMode mode)
        {
            if (mode != BlendingMode.None)
            {
                sb.Begin(SpriteSortMode.Immediate, states.BlendState, states.SamplerState, states.DepthStencilState, states.RasterizerState);
            }
            else
            {
                sb.Begin(SpriteSortMode.Immediate, BlendState.Opaque, states.SamplerState, states.DepthStencilState, states.RasterizerState);
            }
        }
Ejemplo n.º 31
0
 public void BlendFunc(BlendingMode sfactor, BlendingMode dfactor) => this.CallMethod <object>(BLEND_FUNC, sfactor, dfactor);
Ejemplo n.º 32
0
 public void BlendFuncSeparate(BlendingMode srcRGB, BlendingMode dstRGB, BlendingMode srcAlpha, BlendingMode dstAlpha) => this.CallMethod <object>(BLEND_FUNC_SEPARATE, srcRGB, dstRGB, srcAlpha, dstAlpha);
Ejemplo n.º 33
0
        public ModelMaterial(byte[] inData)
        {
            using (MemoryStream ms = new MemoryStream(inData))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    this.Flags = (MaterialFlags) br.ReadUInt32();
                    this.Shader = (ShaderTypes) br.ReadUInt32();
                    this.BlendMode = (BlendingMode) br.ReadUInt32();

                    this.FirstTextureOffset = br.ReadUInt32();
                    this.FirstColour = br.ReadRGBA();
                    this.FirstFlags  = (MaterialFlags)br.ReadUInt32();

                    this.SecondTextureOffset = br.ReadUInt32();
                    this.SecondColour = br.ReadRGBA();

                    this.GroundType = new UInt32ForeignKey("TerrainType", "ID", br.ReadUInt32());
                    this.ThirdTextureOffset = br.ReadUInt32();
                    this.BaseDiffuseColour = br.ReadRGBA();
                    this.ThirdFlags = (MaterialFlags)br.ReadUInt32();

                    this.RuntimeData1 = br.ReadUInt32();
                    this.RuntimeData2 = br.ReadUInt32();
                    this.RuntimeData3 = br.ReadUInt32();
                    this.RuntimeData4 = br.ReadUInt32();
                }
            }
        }
Ejemplo n.º 34
0
        //property.Expanded =  EditorGUILayout.Foldout( property.Expanded, property.GetPropertyType().PropertyTypeString() );
        public void Draw()
        {
            var shaderNameContent = new GUIContent(
                    "Shader Name",
                    "Name for shader. Includes the hierarchy listing, that is, MyShaders/Shader will be in a folder called \"MyShaders\" in the shader selection dropdown. Also used when referring to fallback shaders.");

            var oldColor = GUI.color;
            if( string.IsNullOrEmpty(_shaderName ) )
            {
                GUI.color = Color.red;
            }
            _shaderName.Value = EditorGUILayout.TextField(shaderNameContent, _shaderName.Value);
            GUI.color = oldColor;

            var shaderFallbackContent = new GUIContent(
                    "Shader Fallback",
                    "Fallback shader to use in case this shader can not be used.");

            _shaderFallback.Value = EditorGUILayout.TextField( shaderFallbackContent, _shaderFallback.Value );

            var targetContent = new GUIContent("Shader Model","Requires more recent hardware to use the shader, but allows for more instructions, texture reads, and more input information.");
            _shaderTarget = (ShaderTarget)EditorGUILayout.EnumPopup( targetContent, _shaderTarget );

            var excludePathContent = new GUIContent("Exclude Path","Exclude a renderpath from shader generation");
            _excludePath = (ExcludePath)EditorGUILayout.EnumPopup( excludePathContent, _excludePath );

            GUILayout.Space(8);
            _showQueueSettings = EditorGUILayout.Foldout( _showQueueSettings, "Queue Settings" );
            if( _showQueueSettings )
            {
                var renderTypeContent = new GUIContent("Render Type","This is the rendertype tag inserted into the shader. Can be used for shader replace");
                _renderType = (RenderType)EditorGUILayout.EnumPopup( renderTypeContent, _renderType );

                if ( _renderType == RenderType.Custom )
                    _renderTypeCustom.Value = EditorGUILayout.TextField( "Custom Type" ,_renderTypeCustom.Value );

                var queueContent = new GUIContent("Render Queue","The render queue that this material will be put in");
                _queue = (Queue)EditorGUILayout.EnumPopup( queueContent, _queue );

                var offContent = new GUIContent(
                    "Queue Offset",
                    "Offset for drawing. Used to ensure some things draw before or after others, it specifically is an offset from the given queue- That is to say, you won't have a transparent object draw before an opaque object (or similar) due to this offset.");
                _queueAdjust = EditorGUILayout.IntSlider(offContent, _queueAdjust.Value, -100, 100);
            }

            GUILayout.Space( 8 );
            _showCullingAndDepthSettings = EditorGUILayout.Foldout( _showCullingAndDepthSettings, "Culling and Depth Settings" );
            if( _showCullingAndDepthSettings )
            {
                var zWriteContent = new GUIContent("Write Depth","Depth is considered when testing other objects. Disable for certain effects, like letting other things draw over yourself, or for speed on most overlays.");
                _zWrite = (ZWrite)EditorGUILayout.EnumPopup( zWriteContent, _zWrite );

                var cullModeContent = new GUIContent("CullMode","Select back / forward to clip backwards facing polygons");
                _cullMode = (CullMode)EditorGUILayout.EnumPopup( cullModeContent, _cullMode );

                var zTestContent = new GUIContent("ZTest","Select Z-Test Value");
                _zTest = (ZTest)EditorGUILayout.EnumPopup( zTestContent, _zTest );

                var enableLODContent = new GUIContent("Enable LOD","Enable Shader LOD scaling");
                _enableLOD = EditorGUILayout.BeginToggleGroup( enableLODContent, _enableLOD );
                _lod = EditorGUILayout.IntSlider( "LOD", _lod, 0, 1000 );
                EditorGUILayout.EndToggleGroup();
            }

            GUILayout.Space( 8 );
            _showBlending = EditorGUILayout.Foldout( _showBlending, "Blending Settings" );
            if( _showBlending )
            {
                var blendingTypeContent = new GUIContent("Blend Type","Use a build in blend mode or a custom blend mode");
                _blending = (BlendingType)EditorGUILayout.EnumPopup( blendingTypeContent, _blending );

                if( CustomBlendingEnabled() )
                {
                    var srcBlendContent = new GUIContent("Src Blend Mode","How the source channel of blending is used");
                    _srcBlend = (BlendingMode)EditorGUILayout.EnumPopup( srcBlendContent, _srcBlend );

                    var dstBlendContent = new GUIContent("Dst Blend Mode","How the destination channel of blending is used");
                    _dstBlend = (BlendingMode)EditorGUILayout.EnumPopup( dstBlendContent, _dstBlend );
                }
            }

            GUILayout.Space( 8 );
            _showColorAndLighting = EditorGUILayout.Foldout( _showColorAndLighting, "Color And Lighting Settings" );
            if( _showColorAndLighting )
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label( "Color Mask:", GUILayout.ExpandWidth(false) );
                _colorMaskR.Value = EditorExtensions.ToggleButton( _colorMaskR.Value, "R","Mask R Channel");
                _colorMaskG.Value = EditorExtensions.ToggleButton( _colorMaskG.Value, "G","Mask G Channel");
                _colorMaskB.Value = EditorExtensions.ToggleButton( _colorMaskB.Value, "B","Mask B Channel");
                _colorMaskA.Value = EditorExtensions.ToggleButton( _colorMaskA.Value, "A","Mask A Channel");
                GUILayout.EndHorizontal();

                _dualForward = GUILayout.Toggle( _dualForward, new GUIContent( "Forward Dual Lightmaps","Use dual lightmaps in the forward rendering path" ));
                _fullForwardShadows = GUILayout.Toggle( _fullForwardShadows, new GUIContent( "Forward Full Shadows", "Support all shadow types in Forward rendering path." ));
                _softVegetation = GUILayout.Toggle( _softVegetation, new GUIContent( "Soft Vegetation", "Makes the surface shader only be rendered when Soft Vegetation is on." ));
                _noAmbient = GUILayout.Toggle( _noAmbient, new GUIContent( "No Ambient", "Do not apply any ambient lighting or spherical harmonics lights."));
                _noLightmap = GUILayout.Toggle( _noLightmap, new GUIContent( "No Lightmaps", "Disables lightmap support in this shader (makes a shader smaller)." ));
                _addShadow = GUILayout.Toggle( _addShadow, new GUIContent( "Advanced Shadow Pass", "Performs vertex transformations and clipping for the shadow pass, you need to use this if shadows do not display properly." ));

                _ignoreProjectors = GUILayout.Toggle( _ignoreProjectors, new GUIContent( "Ignore Projectors", "Ignores projector components, should be used if your doing custom vertex transformations or most transparency" ));
                _approxview = GUILayout.Toggle( _approxview, new GUIContent( "Approximate View", "Computes normalized view direction per-vertex instead of per-pixel, for shaders that need it. This is faster, but view direction is not entirely correct when camera gets close to surface." ));
                _halfasview = GUILayout.Toggle( _halfasview, new GUIContent( "Half As View", "Pass half-direction vector into the lighting function instead of view-direction. Half-direction will be computed and normalized per vertex. This is faster, but not entirely correct." ));
                _noForwardAdd = GUILayout.Toggle( _noForwardAdd, new GUIContent( "Disable Forward Add", "Disables Forward rendering additive pass. This makes the shader support one full directional light, with all other lights computed per-vertex/SH. Makes shaders smaller as well." ));
            }

            GUILayout.Space( 8 );
            _showFogSettings = EditorGUILayout.Foldout( _showFogSettings, "Fog Settings" );
            if( _showFogSettings )
            {
                _fogModeOverride = EditorGUILayout.BeginToggleGroup( "Fog Mode Override", _fogModeOverride );
                var fogModeContent = new GUIContent("Fog Mode","The type of fog to use");
                _fogMode = (FogMode)EditorGUILayout.EnumPopup( fogModeContent, _fogMode );

                if( _fogMode == FogMode.Linear )
                {
                    _fogNearLinear.Value = EditorGUILayout.FloatField( "Near Linear Range:", _fogNearLinear );
                    _fogFarLinear.Value = EditorGUILayout.FloatField( "Far Linear Range:", _fogFarLinear );
                }
                EditorGUILayout.EndToggleGroup();

                _fogColorOverride = EditorGUILayout.BeginToggleGroup( "Fog Color Override", _fogColorOverride );
                _fogColor.Value = EditorGUILayout.ColorField("Fog Color:", _fogColor );
                EditorGUILayout.EndToggleGroup();

                _fogDensityOverride = EditorGUILayout.BeginToggleGroup( "Fog Density Override", _fogDensityOverride );
                _fogDensity.Value = EditorGUILayout.FloatField( "Fog Density:", _fogDensity );
                EditorGUILayout.EndToggleGroup();
            }
        }
Ejemplo n.º 35
0
 public void SetBlendingMode(BlendingMode mode = BlendingMode.Opaque)
 {
     blendingMode = mode;
 }
Ejemplo n.º 36
0
 public static void SetBlendingMode(this GraphicsDevice _, BlendingMode blendingMode)
 {
     GraphicsDeviceExtensions.blendCombiner.BlendingMode = blendingMode;
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Adjusts <see cref="Drawable.Blending"/> after a delay.
 /// </summary>
 /// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
 public static TransformSequence <T> TransformBlendingMode <T>(this T drawable, BlendingMode newValue, double delay = 0)
     where T : Drawable
 => drawable.TransformTo(drawable.PopulateTransform(new TransformBlendingMode(), newValue, delay));
Ejemplo n.º 38
0
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////
        public virtual void Begin(BlendingMode mode)
        {
            bmode = mode;
            if (mode != BlendingMode.None)
            {
                BlendState state = states.BlendState;
                if (mode == BlendingMode.Additive)
                {
                    state = BlendState.Additive;
                }

                if (this.customMatrix.HasValue)
                {
                    sb.Begin(SpriteSortMode.Immediate, state, states.SamplerState, states.DepthStencilState, states.RasterizerState, null, this.customMatrix.Value);
                }
                else
                {
                    sb.Begin(SpriteSortMode.Immediate, state, states.SamplerState, states.DepthStencilState, states.RasterizerState);
                }
            }
            else
            {
                if (this.customMatrix.HasValue)
                {
                    sb.Begin(SpriteSortMode.Immediate, BlendState.Opaque, states.SamplerState, states.DepthStencilState, states.RasterizerState, null, this.customMatrix.Value);
                }
                else
                {
                    sb.Begin(SpriteSortMode.Immediate, BlendState.Opaque, states.SamplerState, states.DepthStencilState, states.RasterizerState);
                }
            }
        }
Ejemplo n.º 39
0
        public void CreateWMOObject()
        {
            if (terrainHandler.working)
            {
                WMO.WMOStruct data        = WMO.AllWMOData.Dequeue();
                GameObject    WMOinstance = new GameObject();

                terrainHandler.LoadedWMOIds[data.fileDataId] = WMOinstance;

                int nGroups = data.Info.nGroups;
                for (int g = 0; g < nGroups; g++)
                {
                    // group object //
                    GameObject GroupInstance = new GameObject();
                    GroupInstance.isStatic = true;
                    GroupInstance.transform.SetParent(terrainHandler.LoadedWMOIds[data.fileDataId].transform);
                    GroupInstance.name = data.groupsData[g].groupName;

                    LODGroup   Lodgroup  = GroupInstance.AddComponent <LODGroup>();
                    LOD[]      lods      = new LOD[1];
                    Renderer[] renderers = new Renderer[data.groupsData[g].nBatches];

                    // Batches //
                    for (int bn = 0; bn < data.groupsData[g].nBatches; bn++)
                    {
                        ////////////////////////////////
                        #region object

                        GameObject BatchInstance = new GameObject();
                        BatchInstance.isStatic = true;
                        BatchInstance.transform.SetParent(GroupInstance.transform);
                        BatchInstance.name = bn.ToString();
                        BatchInstance.transform.transform.eulerAngles = new Vector3(BatchInstance.transform.transform.eulerAngles.x, BatchInstance.transform.transform.eulerAngles.y - 180, GroupInstance.transform.transform.eulerAngles.z);

                        #endregion
                        ////////////////////////////////

                        ////////////////////////////////
                        #region mesh

                        BatchInstance.AddComponent <MeshRenderer>();
                        BatchInstance.GetComponent <MeshRenderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.TwoSided;
                        renderers[bn] = BatchInstance.GetComponent <MeshRenderer>();
                        BatchInstance.AddComponent <MeshFilter>();
                        Mesh bmesh = new Mesh();

                        uint batchVertSize = data.groupsData[g].batch_MaxIndex[bn] - data.groupsData[g].batch_MinIndex[bn] + 1;

                        Vector3[]  batchVertices      = new Vector3[batchVertSize];
                        Vector2[]  batchUVs           = new Vector2[batchVertSize];
                        Vector3[]  batchNormals       = new Vector3[batchVertSize];
                        Color32[]  batchVertexColors  = new Color32[batchVertSize];
                        List <int> batchTrianglesList = new List <int>();
                        int[]      batchTriangles;

                        int  arrayPosition     = 0;
                        uint batch_startVertex = data.groupsData[g].batch_MinIndex[bn];
                        uint batch_endVertex   = data.groupsData[g].batch_MaxIndex[bn];
                        for (uint v = batch_startVertex; v <= batch_endVertex; v++)
                        {
                            batchVertices[arrayPosition] = data.groupsData[g].vertices[v];
                            batchUVs[arrayPosition]      = data.groupsData[g].UVs[v];
                            batchNormals[arrayPosition]  = data.groupsData[g].normals[v];
                            if (!data.groupsData[g].flags.Hasvertexolors)
                            {
                                batchVertexColors[arrayPosition] = new Color32(127, 127, 127, 127);
                            }
                            else
                            {
                                batchVertexColors[arrayPosition] = data.groupsData[g].vertexColors[(int)v];
                            }
                            arrayPosition++;
                        }

                        uint batch_startIndex = data.groupsData[g].batch_StartIndex[bn];
                        uint batch_nIndices   = data.groupsData[g].batch_Count[bn];
                        for (uint idx = batch_startIndex; idx <= batch_startIndex + batch_nIndices - 2; idx = idx + 3)
                        {
                            uint in1 = data.groupsData[g].triangles[idx + 0];
                            uint in2 = data.groupsData[g].triangles[idx + 1];
                            uint in3 = data.groupsData[g].triangles[idx + 2];
                            int  a   = (int)(in1 - batch_startVertex);
                            int  b   = (int)(in2 - batch_startVertex);
                            int  c   = (int)(in3 - batch_startVertex);

                            batchTrianglesList.Add(a);
                            batchTrianglesList.Add(b);
                            batchTrianglesList.Add(c);
                        }
                        batchTrianglesList.Reverse();
                        batchTriangles = batchTrianglesList.ToArray();

                        bmesh.vertices  = batchVertices;
                        bmesh.uv        = batchUVs;
                        bmesh.normals   = batchNormals;
                        bmesh.triangles = batchTriangles;
                        bmesh.colors32  = batchVertexColors;
                        BatchInstance.GetComponent <MeshFilter>().mesh             = bmesh;
                        BatchInstance.GetComponent <MeshRenderer>().sharedMaterial = missingMaterial;

                        #endregion
                        ////////////////////////////////

                        ////////////////////////////////
                        #region material

                        uint TextureFileDataId = data.texturePaths[data.materials[data.groupsData[g].batchMaterialIDs[bn]].TextureId1];
                        BatchInstance.GetComponent <Renderer>().material = WMOmaterials[(int)data.materials[data.groupsData[g].batchMaterialIDs[bn]].ShaderType];

                        ////////////////////////////////
                        #region Set Fragment Shader

                        WMOFragmentShader shader = data.materials[data.groupsData[g].batchMaterialIDs[bn]].ShaderType;
                        switch (shader)
                        {
                        case WMOFragmentShader.Diffuse:
                        {
                            BatchInstance.GetComponent <Renderer>().material.SetFloat("_ShaderDiffuse", 1.0f);
                            break;
                        }

                        case WMOFragmentShader.Specular:
                        {
                            BatchInstance.GetComponent <Renderer>().material.SetFloat("_ShaderSpecular", 1.0f);
                            break;
                        }

                        case WMOFragmentShader.Metal:
                        {
                            BatchInstance.GetComponent <Renderer>().material.SetFloat("_ShaderMetal", 1.0f);
                            break;
                        }

                        case WMOFragmentShader.Env:
                        {
                            BatchInstance.GetComponent <Renderer>().material.SetFloat("_ShaderEnv", 1.0f);
                            break;
                        }

                        case WMOFragmentShader.Opaque:
                        {
                            BatchInstance.GetComponent <Renderer>().material.SetFloat("_ShaderOpaque", 1.0f);
                            BatchInstance.GetComponent <Renderer>().material.SetFloat("_AlphaToMask", 1.0f);
                            break;
                        }

                        default:
                        {
                            BatchInstance.GetComponent <Renderer>().material.SetFloat("_ShaderDiffuse", 1.0f);
                            break;
                        }
                        }


                        #endregion
                        ////////////////////////////////

                        ////////////////////////////////
                        #region Set Material Flags

                        // F_UNCULLED //
                        int Culling = 2; // on (only front)
                        if (data.materials[data.groupsData[g].batchMaterialIDs[bn]].flags.F_UNCULLED)
                        {
                            Culling = 0; // off (both sides_
                        }
                        BatchInstance.GetComponent <Renderer>().material.SetFloat("F_UNCULLED", Culling);
                        // F_UNLIT //
                        if (data.materials[data.groupsData[g].batchMaterialIDs[bn]].flags.F_UNLIT)
                        {
                            BatchInstance.GetComponent <Renderer>().material.EnableKeyword("F_UNLIT");
                        }
                        //BatchInstance.GetComponent<Renderer>().material.SetFloat("_F_UNLIT", data.materials[data.groupsData[g].batchMaterialIDs[bn]].flags.F_UNLIT ? 1 : 0);
                        // F_UNFOGGED //
                        BatchInstance.GetComponent <Renderer>().material.SetFloat("_F_UNFOGGED", data.materials[data.groupsData[g].batchMaterialIDs[bn]].flags.F_UNFOGGED ? 1 : 0);

                        #endregion
                        ////////////////////////////////

                        ////////////////////////////////
                        #region Set Blending Mode

                        // set default blend: One Zero, basicly off
                        UnityEngine.Rendering.BlendMode source      = UnityEngine.Rendering.BlendMode.One;
                        UnityEngine.Rendering.BlendMode destination = UnityEngine.Rendering.BlendMode.Zero;

                        BlendingMode blending = data.materials[data.groupsData[g].batchMaterialIDs[bn]].BlendMode;

                        switch (blending)
                        {
                        case BlendingMode.Opaque:
                        {
                            source      = UnityEngine.Rendering.BlendMode.One;
                            destination = UnityEngine.Rendering.BlendMode.Zero;
                            break;
                        }

                        case BlendingMode.AlphaKey:
                        {
                            source      = UnityEngine.Rendering.BlendMode.One;
                            destination = UnityEngine.Rendering.BlendMode.Zero;
                            break;
                        }

                        case BlendingMode.Alpha:
                        {
                            source      = UnityEngine.Rendering.BlendMode.SrcAlpha;
                            destination = UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha;
                            break;
                        }

                        case BlendingMode.Additive:
                        {
                            source      = UnityEngine.Rendering.BlendMode.One;
                            destination = UnityEngine.Rendering.BlendMode.One;
                            break;
                        }

                        case BlendingMode.Modulate:
                        {
                            source      = UnityEngine.Rendering.BlendMode.DstColor;
                            destination = UnityEngine.Rendering.BlendMode.Zero;
                            break;
                        }

                        case BlendingMode.Modulate2x:
                        {
                            source      = UnityEngine.Rendering.BlendMode.DstColor;
                            destination = UnityEngine.Rendering.BlendMode.SrcColor;
                            break;
                        }

                        case BlendingMode.ModulateAdditive:
                        {
                            source      = UnityEngine.Rendering.BlendMode.DstColor;
                            destination = UnityEngine.Rendering.BlendMode.One;
                            break;
                        }

                        default:
                        {
                            Debug.Log("BlendMode To Add: " + blending.ToString() + " Texture Used: " + TextureFileDataId);
                            source      = UnityEngine.Rendering.BlendMode.One;
                            destination = UnityEngine.Rendering.BlendMode.Zero;
                            break;
                        }
                        }
                        BatchInstance.GetComponent <Renderer>().material.SetInt("MySrcMode", (int)source);
                        BatchInstance.GetComponent <Renderer>().material.SetInt("MyDstMode", (int)destination);

                        #endregion
                        ////////////////////////////////

                        ////////////////////////////////
                        #region Assign Textures

                        if (LoadedWMOTextures.ContainsKey(TextureFileDataId))
                        {
                            BatchInstance.GetComponent <Renderer>().material.SetTexture("_MainTex", LoadedWMOTextures[TextureFileDataId]);
                        }
                        else
                        {
                            try
                            {
                                Texture2Ddata tdata = data.textureData[TextureFileDataId];
                                Texture2D     tex   = new Texture2D(tdata.width, tdata.height, tdata.textureFormat, tdata.hasMipmaps);
                                tex.LoadRawTextureData(tdata.TextureData);
                                tex.Apply();
                                LoadedWMOTextures[TextureFileDataId] = tex;
                                BatchInstance.GetComponent <Renderer>().material.SetTexture("_MainTex", tex);
                            }
                            catch (Exception ex)
                            {
                                Debug.Log("Error: Loading RawTextureData @ WMOhandler");
                                Debug.LogException(ex);
                            }
                        }
                        #endregion
                        ////////////////////////////////

                        #endregion
                        ////////////////////////////////
                    }

                    lods[0] = new LOD(.1f, renderers);
                    Lodgroup.SetLODs(lods);
                    Lodgroup.animateCrossFading = true;
                    Lodgroup.fadeMode           = LODFadeMode.SpeedTree;
                    Lodgroup.RecalculateBounds();
                }

                terrainHandler.LoadedWMOIds[data.fileDataId].transform.position   = data.position;
                terrainHandler.LoadedWMOIds[data.fileDataId].transform.rotation   = data.rotation;
                terrainHandler.LoadedWMOIds[data.fileDataId].transform.localScale = data.scale;
                if (data.uniqueID != -1)
                {
                    if (terrainHandler.ADTBlockWMOParents[data.uniqueID] != null)
                    {
                        terrainHandler.LoadedWMOIds[data.fileDataId].transform.SetParent(terrainHandler.ADTBlockWMOParents[data.uniqueID].transform);
                    }
                    else
                    {
                        Destroy(terrainHandler.LoadedWMOIds[data.fileDataId]);
                    }
                }
                terrainHandler.LoadedWMOIds[data.fileDataId].name = data.Info.wmoID.ToString();

                terrainHandler.frameBusy = false;
            }
        }