Пример #1
0
        /// <summary>
        /// Creates a new instance of <see cref="D3D10EffectImplementation"/>.
        /// </summary>
        /// <param name="renderer">The D3D10 renderer.</param>
        /// <param name="shaderByteCode">The compiled shader byte code.</param>
        /// <param name="profileName">Name of the shader profile.</param>
        /// <param name="sFlags">The shader flags.</param>
        /// <param name="eFlags">The effect flags.</param>
        internal D3D10EffectImplementation(D3D10Renderer renderer, byte[] shaderByteCode, String profileName, D3DC.ShaderFlags sFlags, D3DC.EffectFlags eFlags)
        {
            _cachedByteCode = shaderByteCode;
            _renderer       = renderer;
            _graphicsDevice = _renderer.GraphicsDevice;
            _profileName    = profileName;
            _sFlags         = sFlags;
            _eFlags         = eFlags;
            _effect         = D3D.Effect.FromMemory(_graphicsDevice, _cachedByteCode, _profileName, _sFlags, _eFlags, null, null, null);

            //Add to resource tracker
            _renderer.Resources.AddTrackedObject(_effect.ComPointer, this);

            int techCount = _effect.Description.TechniqueCount;
            D3D10EffectTechniqueCollection techniques = new D3D10EffectTechniqueCollection();
            D3D10EffectParameterCollection parameters = new D3D10EffectParameterCollection();

            base.SetTechniques(techniques);
            base.SetParameters(parameters);

            for (int i = 0; i < techCount; i++)
            {
                D3D10EffectTechnique tech = new D3D10EffectTechnique(this, _effect, _effect.GetTechniqueByIndex(i));
                ((D3D10EffectTechniqueCollection)techniques).Add(tech);
            }

            //Set the current technique, the first one by default
            _currentTechnique = (D3D10EffectTechnique)techniques[0];
        }
Пример #2
0
        static public void InitializeEffect()
        {
            effect = DX10.Effect.FromFile(device, "blinn.fx", "fx_4_0");
            Matrix V  = Camera.CameraView;
            Matrix VI = Matrix.Invert(V);

            effect.GetVariableByName("mWVP").AsMatrix().SetMatrix(V * Projection);
            effect.GetVariableByName("mVI").AsMatrix().SetMatrix(VI);
            effect.GetVariableByName("mW").AsMatrix().SetMatrix(Matrix.Identity);
            effect.GetVariableByName("mWIT").AsMatrix().SetMatrix(Matrix.Identity);
            effect.GetVariableByName("xDiffuseTexture").AsResource().SetResource(new ShaderResourceView(device, Diffuse));
            effect.GetVariableByName("xBumpTexture").AsResource().SetResource(new ShaderResourceView(device, BumpMap));
            effect.GetVariableByName("xReflectionTexture").AsResource().SetResource(new ShaderResourceView(device, Reflection));

            //zaczytanie ekstra tekstury i mapy wysokosci ; pobranie wymiarow
            effect.GetVariableByName("xTga").AsResource().SetResource(new ShaderResourceView(device, TgaTex));
            effect.GetVariableByName("xConcreteTexture").AsResource().SetResource(new ShaderResourceView(device, Concrete));
            effect.GetVariableByName("xHeightMap").AsResource().SetResource(new ShaderResourceView(device, HeightMap));
            effect.GetVariableByName("xDimension").AsVector().Set(HeightDimension);
            //dane do POM ; alfa - wspolczynnik wysokosci ; kamera
            alpha = 35.0f;
            effect.GetVariableByName("xAlpha").AsScalar().Set(alpha);
            CameraPos.X = Camera.Position.X;
            CameraPos.Y = Camera.Position.Y;
            CameraPos.Z = Camera.Position.Z;
            effect.GetVariableByName("xCameraPos").AsVector().Set(CameraPos);
            effect.GetVariableByName("xTexDimension").AsVector().Set(TexDimension);
            effect.GetVariableByName("xPomOn").AsScalar().Set(POMOn);
        }
        /// <summary>
        /// Clones the technique collection with the new effect instance
        /// and the new parent implementation.
        /// </summary>
        /// <param name="effect">The D3D10 effect.</param>
        /// <param name="parent">The D3D10 implementation.</param>
        /// <returns></returns>
        internal D3D10EffectTechniqueCollection Clone(D3D.Effect effect, D3D10EffectImplementation parent)
        {
            D3D10EffectTechniqueCollection clone = new D3D10EffectTechniqueCollection();

            for (int i = 0; i < Count; i++)
            {
                clone.Add(_techniques[i].Clone(effect.GetTechniqueByIndex(i), parent));
            }
            return(clone);
        }
Пример #4
0
        /// <summary>
        /// Clones the collection using the new effect instance, used
        /// for when the implementation clones itself.
        /// </summary>
        /// <param name="effect">The D3D10 effect</param>
        /// <returns>Cloned collection</returns>
        internal D3D10EffectParameterCollection Clone(D3D.Effect effect)
        {
            D3D10EffectParameterCollection clone = new D3D10EffectParameterCollection();

            for (int i = 0; i < Count; i++)
            {
                D3D10EffectParameter paramToClone = _params[i];
                D3D.EffectVariable   eVar         = effect.GetVariableByName(paramToClone.Name);
                clone.Add(paramToClone.Clone(eVar));
            }
            return(clone);
        }
Пример #5
0
        /// <summary>
        /// Creates a new instance of <see cref="D3D10EffectPass"/>.
        /// </summary>
        /// <param name="parent">The implementation parent.</param>
        /// <param name="effect">The D3D10 effect so we can query for variables.</param>
        /// <param name="pass">The D3D10 pass.</param>
        internal D3D10EffectPass(D3D10EffectImplementation parent, D3D.Effect effect, D3D.EffectPass pass)
        {
            _pass     = pass;
            _renderer = parent.Renderer;

            D3D.EffectPassDescription desc = pass.Description;
            _name      = desc.Name;
            _layoutMap = new InputLayoutMap(_renderer, desc.Signature);

            //Fetch annotations
            int annoCount = desc.AnnotationCount;

            _annotations = new D3D10EffectAnnotationCollection();
            for (int i = 0; i < annoCount; i++)
            {
                D3D.EffectVariable            anno     = _pass.GetAnnotationByIndex(i);
                D3D.EffectVariableDescription annoDesc = anno.Description;
                D3D.EffectVariable            annoVar  = anno.AsString();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Object, EffectParameterType.String));
                    continue;
                }
                annoVar = anno.AsScalar();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Scalar, EffectParameterType.Unknown));
                    continue;
                }
                annoVar = anno.AsMatrix();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Matrix, EffectParameterType.Unknown));
                    continue;
                }
                annoVar = anno.AsVector();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Vector, EffectParameterType.Unknown));
                }
            }

            //Now to reflect the parameters and start adding them to the shader
            D3D.EffectPassShaderDescription vertexShaderDesc = pass.VertexShaderDescription;
            D3D.EffectShaderVariable        vertexShaderVar  = vertexShaderDesc.Variable;
            ParseShader(parent, effect, vertexShaderVar);
            ParseShader(parent, effect, pass.PixelShaderDescription.Variable);

            //And the standard input layout
            CreateInputLayout(vertexShaderVar, vertexShaderDesc.Index);
        }
Пример #6
0
 /// <summary>
 /// Releases unmanaged and - optionally - managed resources
 /// </summary>
 /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
 protected override void Dispose(bool disposing)
 {
     if (!IsDisposed)
     {
         if (_effect != null)
         {
             if (_renderer != null)
             {
                 _renderer.Resources.RemoveTrackedObject(_effect.ComPointer);
             }
             _effect.Dispose();
             _effect = null;
         }
         base.Dispose(disposing);
     }
 }
Пример #7
0
        private static void ParseShaderParameters(D3D10EffectImplementation parent, D3D.Effect effect, D3DC.ShaderReflection reflect)
        {
            D3DC.ShaderDescription desc = reflect.Description;
            int constantBuffers         = desc.ConstantBuffers;
            int boundResources          = desc.BoundResources;

            //Grab parameters
            for (int i = 0; i < constantBuffers; i++)
            {
                D3DC.ConstantBuffer cb = reflect.GetConstantBuffer(i);
                for (int j = 0; j < cb.Description.Variables; j++)
                {
                    D3DC.ShaderReflectionVariable cbVar = cb.GetVariable(j);
                    String name = cbVar.Description.Name;
                    if (parent.Parameters[name] == null)
                    {
                        D3D.EffectVariable         param     = effect.GetVariableByName(name);
                        D3DC.ShaderReflectionType  paramType = cbVar.GetVariableType();
                        D3DC.ShaderTypeDescription typeDesc  = paramType.Description;
                        if (Want(typeDesc.Class, typeDesc.Type))
                        {
                            ((D3D10EffectParameterCollection)parent.Parameters).Add(new D3D10EffectParameter(param, paramType));
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            //Grab resources
            for (int i = 0; i < boundResources; i++)
            {
                D3DC.InputBindingDescription inputBinding = reflect.GetResourceBindingDescription(i);
                String name = inputBinding.Name;
                if (parent.Parameters[name] == null)
                {
                    D3D.EffectVariable param = effect.GetVariableByName(name);
                    if (Want(inputBinding.Type, inputBinding.Dimension))
                    {
                        ((D3D10EffectParameterCollection)parent.Parameters).Add(new D3D10EffectParameter(param, inputBinding));
                    }
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Creates a new instance of <see cref="D3D10EffectImplementation"/>. Used for cloning.
        /// </summary>
        /// <param name="cloneSource">The implementation source to clone from</param>
        /// <param name="profileName">Name of the shader profile.</param>
        /// <param name="sFlags">The shader flags.</param>
        /// <param name="eFlags">The effect flags.</param>
        internal D3D10EffectImplementation(D3D10EffectImplementation cloneSource, String profileName, D3DC.ShaderFlags sFlags, D3DC.EffectFlags eFlags)
        {
            _cachedByteCode = cloneSource._cachedByteCode;
            _renderer       = cloneSource._renderer;
            _graphicsDevice = cloneSource._graphicsDevice;
            _profileName    = profileName;
            _sFlags         = sFlags;
            _eFlags         = eFlags;
            _effect         = D3D.Effect.FromMemory(_graphicsDevice, _cachedByteCode, _profileName, _sFlags, _eFlags, null, null, null);

            //Add to resource tracker
            _renderer.Resources.AddTrackedObject(_effect.ComPointer, this);

            //Clone techniques and parameters
            D3D10EffectTechniqueCollection techniques = cloneSource.Techniques as D3D10EffectTechniqueCollection;
            D3D10EffectParameterCollection parameters = cloneSource.Parameters as D3D10EffectParameterCollection;

            base.SetTechniques(techniques.Clone(_effect, this));
            base.SetParameters(parameters.Clone(_effect));
            _currentTechnique = (D3D10EffectTechnique)base.Techniques[0];
        }
Пример #9
0
        /// <summary>
        /// Creates a new instance of <see cref="D3D10EffectTechnique"/>.
        /// </summary>
        /// <param name="parent">The implementation parent.</param>
        /// <param name="effect">The D3D10 effect.</param>
        /// <param name="tech">The D3D10 technique.</param>
        internal D3D10EffectTechnique(D3D10EffectImplementation parent, D3D.Effect effect, D3D.EffectTechnique tech)
        {
            _tech   = tech;
            _parent = parent;

            D3D.EffectTechniqueDescription desc = _tech.Description;
            _name = desc.Name;

            //Fetch annotations
            int annoCount = desc.AnnotationCount;

            _annotations = new D3D10EffectAnnotationCollection();
            for (int i = 0; i < annoCount; i++)
            {
                D3D.EffectVariable            anno     = _tech.GetAnnotationByIndex(i);
                D3D.EffectVariableDescription annoDesc = anno.Description;
                D3D.EffectVariable            annoVar  = anno.AsString();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Object, EffectParameterType.String));
                }
                annoVar = anno.AsScalar();
                if (annoVar != null)
                {
                    //Need to find a way to get the param type...
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Scalar, EffectParameterType.Unknown));
                }
                annoVar = anno.AsMatrix();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Matrix, EffectParameterType.Single));
                }
            }

            _passes = new D3D10EffectPassCollection();
            for (int i = 0; i < desc.PassCount; i++)
            {
                _passes.Add(new D3D10EffectPass(parent, effect, tech.GetPassByIndex(i)));
            }
        }
Пример #10
0
        private static void ParseShader(D3D10EffectImplementation parent, D3D.Effect effect, D3D.EffectShaderVariable shaderVar)
        {
            D3D.EffectVariable testElem = shaderVar.GetElement(0);

            if (testElem == null)
            {
                if (shaderVar.IsValid)
                {
                    D3D.ShaderDescription shDesc;
                    shaderVar.GetShaderDescription(0, out shDesc);
                    D3DC.ShaderReflection reflect = new D3DC.ShaderReflection(shDesc.Bytecode);
                    ParseShaderParameters(parent, effect, reflect);

                    //Dispose of the reflection variable *and* the bytecode/signature of the shader desc...bytecode will reported as a leaked in ObjectTable
                    reflect.Dispose();
                    shDesc.Signature.Dispose();
                    shDesc.Bytecode.Dispose();
                }
            }
            else
            {
                int k = 1;
                while ((testElem = shaderVar.GetElement(k)) != null)
                {
                    if (testElem.IsValid)
                    {
                        D3D.ShaderDescription shDesc;
                        testElem.AsShader().GetShaderDescription(0, out shDesc);
                        D3DC.ShaderReflection reflect = new D3DC.ShaderReflection(shDesc.Bytecode);
                        ParseShaderParameters(parent, effect, reflect);

                        //Dispose of the reflection variable *and* the bytecode/signature of the shader desc...bytecode will reported as a leaked in ObjectTable
                        reflect.Dispose();
                        shDesc.Signature.Dispose();
                        shDesc.Bytecode.Dispose();
                    }
                    k++;
                }
            }
        }
Пример #11
0
        public Sky(Vector3 lightDir, StreamReader file)
        {
            ///
               // outerRadius = innerRadius * 1.0157313f;
               // atmScale = 1f / (outerRadius - innerRadius);

            dome.CreateDome((int)size.X, (int)size.Y);
               // waveLength4 = new Vector3((float)Math.Pow(waveLength.X, 4), (float)Math.Pow(waveLength.Y, 4), (float)Math.Pow(waveLength.Z, 4));
               // double pow = -0.84;
               // waveLength084 = new Vector3((float)Math.Pow(waveLength.X, pow), (float)Math.Pow(waveLength.Y, pow), (float)Math.Pow(waveLength.Z, pow));

            effect = ResourceManager.mainManager.LoadEffect("Resources\\Effects\\Sky.fx", ResourceManager.mainManager.GetDefaultEffectPool());
            pass = effect.GetTechniqueByName("Render").GetPassByIndex(0);
            updatePass = effect.GetTechniqueByName("Update").GetPassByIndex(0);
            D3D10.InputElement[] elements = new SlimDX.Direct3D10.InputElement[2];
                elements[0] = new SlimDX.Direct3D10.InputElement("POSITION", 0, SlimDX.DXGI.Format.R32G32B32_Float, 0, 0);
                elements[1] = new D3D10.InputElement("TEXCOORD", 0, SlimDX.DXGI.Format.R32G32_Float, 12, 0);
                layout = new SlimDX.Direct3D10.InputLayout(Game.gameClass.GetDevice(), elements, pass.Description.Signature);
                layoutUpdate = Quad.GetLayout(updatePass);
            translation = effect.GetVariableByName("translation").AsVector();
            sunPosition = effect.GetVariableByName("sunPos").AsVector();
               // Vector4 mieTemps = new Vector4((3 * (1 - g * g)) / (2 * (2 + g * g)), 1 + g * g, g, 1);
            mieTemps = effect.GetVariableByName("mieTemps").AsVector();
            K = effect.GetVariableByName("K").AsVector();
            waveLengthRay = effect.GetVariableByName("waveLengthRay").AsVector();
            waveLengthMie = effect.GetVariableByName("waveLengthMie").AsVector();
            scaleDepth = effect.GetVariableByName("scaleDepth").AsVector();
            sunIntensity = effect.GetVariableByName("sunIntensity").AsScalar();
            //textures
            D3D10.Texture2DDescription desc = new SlimDX.Direct3D10.Texture2DDescription();
            desc.ArraySize = 1;
            desc.BindFlags = D3D10.BindFlags.ShaderResource | SlimDX.Direct3D10.BindFlags.RenderTarget;
            desc.CpuAccessFlags = D3D10.CpuAccessFlags.None;
            desc.Format = SlimDX.DXGI.Format.R16G16B16A16_Float;
            desc.Height = (int)size.Y;
            desc.MipLevels = 1;
            desc.OptionFlags = D3D10.ResourceOptionFlags.None;
            desc.Usage = D3D10.ResourceUsage.Default;
            desc.Width = (int)size.X;

            SlimDX.DXGI.SampleDescription sampleDescription = new SlimDX.DXGI.SampleDescription();
            sampleDescription.Count = 1;
            sampleDescription.Quality = 0;
            desc.SampleDescription = sampleDescription;

            rayLookupTexture = new D3D10.Texture2D(Game.gameClass.GetDevice(), desc);
            mieLookupTexture = new D3D10.Texture2D(Game.gameClass.GetDevice(), desc);

               /* desc.BindFlags = D3D10.BindFlags.None;
            desc.CpuAccessFlags = D3D10.CpuAccessFlags.Write;
            desc.Usage = D3D10.ResourceUsage.Staging;

            mieUpdateTexture = new D3D10.Texture2D(Game.gameClass.GetDevice(), desc);
            rayUpdateTexture = new D3D10.Texture2D(Game.gameClass.GetDevice(), desc);

            mieUpdateTextureMap = mieUpdateTexture.Map(0, D3D10.MapMode.Write, D3D10.MapFlags.DoNotWait);
            mieUpdateTexture.Unmap(0);

            rayUpdateTextureMap = rayUpdateTexture.Map(0, D3D10.MapMode.Write, D3D10.MapFlags.DoNotWait);
            rayUpdateTexture.Unmap(0);*/
            using (D3D10.ShaderResourceView view = new SlimDX.Direct3D10.ShaderResourceView(Game.gameClass.GetDevice(), rayLookupTexture))
                effect.GetVariableByName("rayLookupTex").AsResource().SetResource(view);
             using (D3D10.ShaderResourceView view = new SlimDX.Direct3D10.ShaderResourceView(Game.gameClass.GetDevice(), mieLookupTexture))
                effect.GetVariableByName("mieLookupTex").AsResource().SetResource(view);

             viewPort = new Viewport();
             viewPort.Height = (int)size.Y;
             viewPort.Width = (int)size.X;
             viewPort.MaxZ = 1.0f;
             viewPort.MinZ = 0.0f;
             viewPort.X = 0;
             viewPort.Y = 0;

             renderTargets[0] = new SlimDX.Direct3D10.RenderTargetView(Game.gameClass.GetDevice(), rayLookupTexture);
             renderTargets[1] = new SlimDX.Direct3D10.RenderTargetView(Game.gameClass.GetDevice(), mieLookupTexture);

             Load(file);

             CalculateLookupOnGPU(-lightDir);
        }
Пример #12
0
        public virtual void Init(D3DDevice device)
        {
            SlimDX.D3DCompiler.ShaderFlags shaderflags = SlimDX.D3DCompiler.ShaderFlags.EnableStrictness;
            SlimDX.D3DCompiler.EffectFlags effectFlags = SlimDX.D3DCompiler.EffectFlags.None;
            effect = D3D.Effect.FromFile(device.Device, ShaderFilename, "fx_4_0", shaderflags, effectFlags, null, null, null);

            passes = new List<D3D.EffectPass>();
            for (int i = 0; i < MaxTechniques; i++)
            {
                D3D.EffectTechnique technique = effect.GetTechniqueByIndex(i);
                if (technique == null || !technique.IsValid) break;
                for (int p = 0; p < MaxPasses; p++)
                {
                    D3D.EffectPass pass = technique.GetPassByIndex(p);
                    if (pass == null || !pass.IsValid) break;
                    passes.Add(pass);
                }
            }

            World = effect.GetVariableByName("World").AsMatrix();
            View = effect.GetVariableByName("View").AsMatrix();
            Proj = effect.GetVariableByName("Proj").AsMatrix();
            InvProj = effect.GetVariableByName("InvProj").AsMatrix();
            CameraPos = effect.GetVariableByName("CameraPos").AsVector();
        }
Пример #13
0
        //creation functions
        public Terrain(int q, StreamReader file)
        {
            quadSize = q;
            //loading effect
            effect = ResourceManager.mainManager.LoadEffect("Resources\\Effects\\Terrain.fx", ResourceManager.mainManager.GetDefaultEffectPool());
            technique = effect.GetTechniqueByName("Render");
            pass = technique.GetPassByIndex(0);
            //creating layout
            D3D10.InputElement[] elements = new SlimDX.Direct3D10.InputElement[1];
            elements[0] = new SlimDX.Direct3D10.InputElement("TEXCOORD", 0, SlimDX.DXGI.Format.R32G32_Float, 0, 0, D3D10.InputClassification.PerVertexData, 0);
            layout = new SlimDX.Direct3D10.InputLayout(Game.gameClass.GetDevice(), elements, pass.Description.Signature);

            //loading texture
            D3D10.ImageLoadInformation load = new SlimDX.Direct3D10.ImageLoadInformation();
            load.BindFlags = D3D10.BindFlags.ShaderResource;
            load.CpuAccessFlags = D3D10.CpuAccessFlags.None;
            load.MipLevels = 1;
            load.Usage=D3D10.ResourceUsage.Default;
            load.OptionFlags = D3D10.ResourceOptionFlags.None;
            load.FilterFlags = D3D10.FilterFlags.Point;
            load.Format = SlimDX.DXGI.Format.R8G8B8A8_UNorm;
            normalTexture = D3D10.Texture2D.FromFile(Game.gameClass.GetDevice(), Path.GetDirectoryName(Game.gameClass.GetLvLFilePath()) + "\\normals.png", load);
            Globals.mapSize = normalTexture.Description.Width;

            if (Game.gameClass.GetEngineState() != EngineState.play)
            {
                D3D10.Texture2DDescription desc = new SlimDX.Direct3D10.Texture2DDescription();
                desc.ArraySize = 1;
                desc.BindFlags = D3D10.BindFlags.None;
                desc.CpuAccessFlags = D3D10.CpuAccessFlags.Write;
                desc.Format = SlimDX.DXGI.Format.R8G8B8A8_UNorm;
                desc.Height = Globals.mapSize;
                desc.Width = Globals.mapSize;
                desc.Usage = D3D10.ResourceUsage.Staging;
                desc.MipLevels = 1;
                SlimDX.DXGI.SampleDescription sampleDescription = new SlimDX.DXGI.SampleDescription();
                sampleDescription.Count = 1;
                sampleDescription.Quality = 0;
                desc.SampleDescription = sampleDescription;
                normalTexUpdater = new SlimDX.Direct3D10.Texture2D(Game.gameClass.GetDevice(), desc);
                normalData = normalTexUpdater.Map(0, D3D10.MapMode.Write, D3D10.MapFlags.DoNotWait);
                normalTexUpdater.Unmap(0);
            }

               // LoadTextureArray(file);
            //setting up vertices and creating vertex buffer
            LoadVertexInfo();
            CreateVertexBuffer();

            //constant buffer variables
            effect.GetVariableByName("mapSize").AsScalar().Set(Globals.mapSize);
            using(D3D10.ShaderResourceView normalView=new D3D10.ShaderResourceView(Game.gameClass.GetDevice(),normalTexture))
                effect.GetVariableByName("normalMap").AsResource().SetResource(normalView);
              //  using (D3D10.ShaderResourceView texturesView = new D3D10.ShaderResourceView(Game.gameClass.GetDevice(), textures))
            //    effect.GetVariableByName("textures").AsResource().SetResource(texturesView);

            orientations=effect.GetVariableByName("orientations").AsVector();
               // effect.GetVariableByName("texCoordMul").AsScalar().Set(TextureInfo.texCoordMul);
            heightMul = effect.GetVariableByName("heightMul").AsScalar();
            heightMul.Set(Globals.heightMultiplier);

            //handles edit mode
            if (Game.gameClass.GetEngineState() != EngineState.play)
            {
                techniqueEdit = effect.GetTechniqueByName("Edit");
                passEdit = techniqueEdit.GetPassByIndex(0);
                mousePick = effect.GetVariableByName("mousePick").AsVector();
                pickOptions = effect.GetVariableByName("pickOpt").AsVector();
            }
            Globals.SetMap(map);
        }