当前位置: 首页>>代码示例>>C#>>正文


C# Effect.GetTechnique方法代码示例

本文整理汇总了C#中Effect.GetTechnique方法的典型用法代码示例。如果您正苦于以下问题:C# Effect.GetTechnique方法的具体用法?C# Effect.GetTechnique怎么用?C# Effect.GetTechnique使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Effect的用法示例。


在下文中一共展示了Effect.GetTechnique方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadResources

        public override void LoadResources()
        {
            string base_path = (string)settings["Base.Path"];
            // load effect
            string errors;
            effect = Effect.FromFile(device, base_path + "Media/Effects/Bloom-new.fx", null, null,
                                      ShaderFlags.None, null, out errors);

            if (errors.Length > 0)
                throw new Exception("HLSL compile error");

            brightPass = effect.GetTechnique("std_BloomBrightPass");
            blurPass = effect.GetTechnique("std_BlurPass");
            finalPass = effect.GetTechnique("std_FinalPass");

            bpQuad = new CustomVertex.TransformedTextured[4];
            bpQuad[0].Tu = 0;
            bpQuad[0].Tv = 0;
            bpQuad[1].Tu = 1;
            bpQuad[1].Tv = 0;
            bpQuad[2].Tu = 0;
            bpQuad[2].Tv = 1;
            bpQuad[3].Tu = 1;
            bpQuad[3].Tv = 1;

            //testTexture = TextureLoader.FromFile(device, "c:/blurTest.bmp", 256, 128, 0, Usage.None, Format.X8R8G8B8, Pool.Managed, Filter.None, Filter.None, 0);
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:27,代码来源:BloomEffect.cs

示例2: CieloStellato

 public CieloStellato()
 {
     model = new Model("MEDIA//satellite.x", 0);
     EffectPool pool = new EffectPool();
     effect = Effect.FromFile(LogiX_Engine.Device, "MEDIA//NightSky.fx", null, ShaderFlags.None, pool);
     effectHandles = new EffectHandle[6];
     effectHandles[0] = effect.GetTechnique("t0");
     effectHandles[1] = effect.GetParameter(null, "matViewProjection");
     effectHandles[2] = effect.GetParameter(null, "Time");
     effectHandles[3] = effect.GetParameter(null, "BaseTexture");
     effectHandles[4] = effect.GetParameter(null, "NoiseTexture");
     effectHandles[5] = effect.GetParameter(null, "TexDimension");
     baseTexture = new BaseTexture[2];
     baseTexture[0] = TextureLoader.FromFile(LogiX_Engine.Device, "MEDIA//StarMap1.jpg");
     baseTexture[1] = TextureLoader.FromFile(LogiX_Engine.Device, "MEDIA//Noise.jpg");
 }
开发者ID:Chosko,项目名称:high-school-thesis,代码行数:16,代码来源:Planetarium.cs

示例3: Load

        /// <summary>
        /// Load the effect file & initialise everything
        /// </summary>
        public static void Load(Device device, ShaderFlags shaderFlags)
        {
            string err = "";										// shader compiler errors
            // Find and load the file
            try
            {
                string path = Utility.FindMediaFile("Simbiosis.fx");
                effect = ResourceCache.GetGlobalInstance().CreateEffectFromFile(device,
                                                                                path, null, null, shaderFlags, null, out err);
                if (effect == null) throw new Exception("effect = null");
            }
            catch (Exception e)
            {
                Debug.WriteLine("=========================================================================================");
                Debug.WriteLine("Unable to compile Effect file." + e.ToString());
                Debug.WriteLine(err);
                Debug.WriteLine("=========================================================================================");
                throw e;
            }

            // Set up handles for the globals
            matDiffuse = effect.GetParameter(null, "matDiffuse");
            matSpecular = effect.GetParameter(null, "matSpecular");
            matEmissive = effect.GetParameter(null, "matEmissive");
            matAmbient = effect.GetParameter(null, "matAmbient");
            baseTexture = effect.GetParameter(null, "baseTexture");
            bumpTexture = effect.GetParameter(null, "bumpTexture");
            world = effect.GetParameter(null, "world");
            worldViewProjection = effect.GetParameter(null, "worldViewProjection");
            eyePosition = effect.GetParameter(null, "eyePosition");
            isTextured = effect.GetParameter(null, "isTextured");
            isBump = effect.GetParameter(null, "isBump");
            isShadowed = effect.GetParameter(null, "isShadowed");
            isSpotlit = effect.GetParameter(null, "isSpotlit");
            spotVP = effect.GetParameter(null, "spotVP");
            spotTexture = effect.GetParameter(null, "spotTexture");
            spotPosition = effect.GetParameter(null, "spotPosition");
            causticTexture = effect.GetParameter(null, "causticTexture");
            envTexture = effect.GetParameter(null, "envTexture");
            shadowTexture = effect.GetParameter(null, "shadowTexture");
            shadowMatrix = effect.GetParameter(null, "shadowMatrix");

            // and the techniques
            mainTechnique = effect.GetTechnique("Main");
            sceneryTechnique = effect.GetTechnique("Scenery");
            waterTechnique = effect.GetTechnique("Water");
            skyboxTechnique = effect.GetTechnique("Skybox");
            shadowTechnique = effect.GetTechnique("Shadow");
            markerTechnique = effect.GetTechnique("Marker");

            // Set once-only shader constants
            effect.SetValue("sunPosition",new Vector4(512,1000,512,0));				// sun's position (.W is ignored - float3 in shader)
            effect.SetValue("ambient", new ColorValue(255, 255, 255));					// amount/colour of ambient skylight
            effect.SetValue("sunlight", new ColorValue(255, 255, 255));				// colour/brightness of sunlight

            // Set up the projection matrix for shadows, based on sun position
            sunProj = Matrix.OrthoLH(100, 100, 0, 1000);							// adjust width, height if necc
            effect.SetValue("sunProj", sunProj);
            SetCameraData();														// also set up the (variable) view matrix

            // Set up the projection matrix for caustics
            Matrix caustic =
                Matrix.Invert(														// "view" matrix
                Matrix.Translation(new Vector3(0, Water.WATERLEVEL, 0))				// caustics start at water level
                * Matrix.RotationYawPitchRoll(0, (float)Math.PI/2, 0)				// looking down
                )																	// Proj matrix (orthogonal)
                * Matrix.OrthoLH(80, 80, 0, 1000);									// adjust width, height
            effect.SetValue("causticMatrix", caustic);
        }
开发者ID:JamesTryand,项目名称:simergy,代码行数:72,代码来源:Fx.cs

示例4: LoadResources

        public override void LoadResources()
        {
            string base_path = (string)settings["Base.Path"];

            string errors;
            pEffect = Effect.FromFile(device, base_path + "Media/Effects/Blobs.fx", null, null, ShaderFlags.NotCloneable, null, out errors);

            if (errors.Length > 0)
                throw new Exception("HLSL compile error");

            // Initialize the technique for blending
            if (nPasses == 1)
            {
                // Multiple RT available
                hBlendTech = pEffect.GetTechnique("BlobBlend");
            }
            else
            {
                // Single RT. Multiple passes.
                hBlendTech = pEffect.GetTechnique("BlobBlendTwoPasses");
            }

            // Create the environment map
            pEnvMap = TextureLoader.FromCubeFile(device, base_path + "Media/Effects/LobbyCube.dds");
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:25,代码来源:MetaBlobsEffect.cs

示例5: Allocate

    public bool Allocate()
    {
      string[] files = _effectName.Split(';');
      if (files.Length == 0) 
        return false;

      StringBuilder effectShader = new StringBuilder(8196);
      Version vertexShaderVersion = GraphicsDevice.Device.Capabilities.VertexShaderVersion;
      Version pixelShaderVersion = GraphicsDevice.Device.Capabilities.PixelShaderVersion;
      for (int i = files.Length-1; i >= 0; --i)
      {
        string effectFilePath = SkinContext.SkinResources.GetResourceFilePath(string.Format(@"{0}\{1}.fx", SkinResources.SHADERS_DIRECTORY, files[i]));
        if (effectFilePath == null || !File.Exists(effectFilePath))
        {
          if (!_fileMissing)
            ServiceRegistration.Get<ILogger>().Error("Effect file {0} does not exist", effectFilePath);
          _fileMissing = true;
          return false;
        }
        _fileMissing = false;

        using (StreamReader reader = new StreamReader(effectFilePath))
          effectShader.Append(reader.ReadToEnd());

        // Concatenate
        effectShader.Append(Environment.NewLine);
      }

      effectShader.Replace("vs_2_0", String.Format("vs_{0}_{1}", vertexShaderVersion.Major, vertexShaderVersion.Minor));
      effectShader.Replace("ps_2_0", String.Format("ps_{0}_{1}", pixelShaderVersion.Major, pixelShaderVersion.Minor));

      // We place the lock here to comply to the MP2 multithreading guideline - we are not allowed to request the
      // effect resources when holding our lock
      lock (_syncObj)
      {
        if (_effect != null)
          return true;

        string errors = string.Empty;
        try
        {
          const ShaderFlags shaderFlags = ShaderFlags.OptimizationLevel3 | ShaderFlags.EnableBackwardsCompatibility; //| ShaderFlags.NoPreshader;
          _effect = Effect.FromString(GraphicsDevice.Device, effectShader.ToString(), null, null, null, shaderFlags, null, out errors);
          _handleWorldProjection = _effect.GetParameter(null, PARAM_WORLDVIEWPROJ);
          _handleTexture = _effect.GetParameter(null, PARAM_TEXTURE);
          _handleTechnique = _effect.GetTechnique(0);
          return true;
        }
        catch
        {
          ServiceRegistration.Get<ILogger>().Error("EffectAsset: Unable to load '{0}'", _effectName);
          ServiceRegistration.Get<ILogger>().Error("EffectAsset: Errors: {0}", errors);
          return false;
        }
      }
    }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:56,代码来源:EffectAssetCore.cs

示例6: Sole

 public Sole()
 {
     model = new Model("MEDIA//Sfera5.x", 0);
     EffectPool pool = new EffectPool();
     effect = Effect.FromFile(LogiX_Engine.Device, "MEDIA//Sun.fx", null, ShaderFlags.None, pool);
     effectHandles = new EffectHandle[5];
     effectHandles[0] = effect.GetTechnique("t0");
     effectHandles[1] = effect.GetParameter(null, "matViewProjection");
     effectHandles[2] = effect.GetParameter(null, "Time");
     effectHandles[3] = effect.GetParameter(null, "Texture");
     effectHandles[4] = effect.GetParameter(null, "TexDimension");
     baseTexture = TextureLoader.FromFile(LogiX_Engine.Device, "MEDIA//N030.jpg");
     Alone = new XMaterial(Color.White, Color.White, Color.Black, 1);
     light = new DirectionalLight(VertexData.Empty, Color.FromArgb(60, 10, 0), Color.FromArgb(255, 170, 100), Color.FromArgb(250, 250, 250));
 }
开发者ID:Chosko,项目名称:high-school-thesis,代码行数:15,代码来源:Planetarium.cs

示例7: CreaAnelli

 public void CreaAnelli(XTexture TextureBase, XTexture TexturePattern)
 {
     anelli = new Model("MEDIA\\ring.x", 0);
     textureAnelli = TextureBase;
     textureAnelliPattern = TexturePattern;
     EffectPool pool = new EffectPool();
     effect = Effect.FromFile(LogiX_Engine.Device, "MEDIA\\anelli.fx", null, ShaderFlags.None, pool);
     effectHandles = new EffectHandle[5];
     effectHandles[0] = effect.GetTechnique("t0");
     effectHandles[1] = effect.GetParameter(null, "matViewProjection");
     effectHandles[2] = effect.GetParameter(null, "matWorld");
     effectHandles[3] = effect.GetParameter(null, "colorTex");
     effectHandles[4] = effect.GetParameter(null, "alphaTex");
 }
开发者ID:Chosko,项目名称:high-school-thesis,代码行数:14,代码来源:Planetarium.cs

示例8: setupShaders

        private void setupShaders()
        {
            logMessageToFile("Setup shaders");
            // Load and initialize shader effect
            if (d3dDevice == null) return;

            try
            {
                string error = "";
                if (shaderMode == 0)
                {
                    shader = Effect.FromFile(d3dDevice, Path.Combine(Application.StartupPath, "BodyShader.fx"), null, ShaderFlags.None, null, out error);
                }
                if (shaderMode == 1)
                {
                    shader = Effect.FromFile(d3dDevice, Path.Combine(Application.StartupPath, "FaceShader.fx"), null, ShaderFlags.None, null, out error);
                }
                if (shaderMode == 2)
                {
                    shader = Effect.FromFile(d3dDevice, Path.Combine(Application.StartupPath, "HairShader.fx"), null, ShaderFlags.None, null, out error);
                }

                if (shader == null)
                {
                    if (!String.IsNullOrEmpty(error)) MessageBox.Show(error);
                }
                else
                {
                    shader.SetValue(EffectHandle.FromString("gSkinTexture"), skinTexture);
                    shader.SetValue(EffectHandle.FromString("gSkinSpecular"), skinSpecular);
                    if (models[0].textures.baseTexture != null) shader.SetValue(EffectHandle.FromString("gMultiplyTexture"), models[0].textures.baseTexture);
                    shader.SetValue(EffectHandle.FromString("gStencilTexture"), models[0].textures.curStencil);
                    if (models[0].textures.curStencil != null) shader.SetValue(EffectHandle.FromString("gUseStencil"), true);
                    shader.SetValue(EffectHandle.FromString("gSpecularTexture"), models[0].textures.specularTexture);
                    if (shaderMode == 0)
                    {
                        //currently only the bodyshader supports bumpmaps
                        shader.SetValue(EffectHandle.FromString("gReliefTexture"), normalMapTexture);
                        if (normalMapTexture != null) shader.SetValue(EffectHandle.FromString("gUseBumpMap"), true);

                        shader.SetValue(EffectHandle.FromString("gHideSkin"), hideSkin );
                    }
                    shader.SetValue(EffectHandle.FromString("gTileCount"), 1.0f);
                    shader.SetValue(EffectHandle.FromString("gAmbiColor"), new ColorValue(0.6f, 0.6f, 0.6f));
                    shader.SetValue(EffectHandle.FromString("gLamp0Pos"), new Vector4(-10f, 10f, -10f, 1.0f));
                    shader.SetValue(EffectHandle.FromString("gPhongExp"), 10.0f);
                    shader.SetValue(EffectHandle.FromString("gPhongExp"), 10.0f);
                    shader.SetValue(EffectHandle.FromString("gSpecColor"), new ColorValue(0.2f, 0.2f, 0.2f));
                    shader.SetValue(EffectHandle.FromString("gSurfaceColor"), new ColorValue(0.5f, 0.5f, 0.5f));
                    shader.Technique = shader.GetTechnique("normal_mapping");
                }
                wireframe = Effect.FromFile(d3dDevice, Path.Combine(Application.StartupPath, "Wireframe.fx"), null, ShaderFlags.None, null, out error);
                wireframe.SetValue(EffectHandle.FromString("gColor"), new ColorValue((int)wireframeColour.R, (int)wireframeColour.G, (int)wireframeColour.B));
                wireframe.Technique = wireframe.GetTechnique("wireframe");
            }
            catch (Exception ex)
            {
                logMessageToFile(ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }
开发者ID:ellacharmed,项目名称:madscientistproductions,代码行数:60,代码来源:RenderWindow.cs


注:本文中的Effect.GetTechnique方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。