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


C# IRenderer.UseShader方法代码示例

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


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

示例1: Render

    public void Render(IRenderer renderer)
    {
      renderer.UseShader(_shaderName);
      foreach (var textureParameter in _textureParameters)
      {
        renderer.UseTexture(textureParameter.Value.Name, _shaderName, textureParameter.Key);
      }
      if (_isDirty)
      {
        foreach (var numericParameter in _numericParameters)
        {
          renderer.SetNumericParameter(numericParameter.Key, numericParameter.Value, _shaderName);
        }
        foreach (var vectorParameter in _vectorParameters)
        {
          renderer.SetVectorParameter(vectorParameter.Key, vectorParameter.Value, _shaderName);
        }
        _isDirty = false;
      }

    }
开发者ID:dgopena,项目名称:Starter3D.Base,代码行数:21,代码来源:Shader.cs

示例2: Draw

        public void Draw(IRenderer r, Node n)
        {
            if (Age > LifeTime)
                return;

            r.SetMode(RenderMode.Draw3D);
            r.SetMaterial(Mat);
            r.BindTexture(Mat.diffusemap.Id);
            r.UseShader(Shader);
            r.SetUniform(Shader.GetUniformLocation("Alpha"), new float[] { CurrentAlpha });

            float s = CurrentSize / 2;
            Matrix4 m = BaseMatrix * Matrix4Extensions.FromScale(s, s, s);
            r.PushMatrix();
            r.MultMatrix(m);
            r.Draw(Vertices, PrimitiveType.QUADS, 0, 4, null);
            r.PopMatrix();
        }
开发者ID:cody82,项目名称:spacewar-arena,代码行数:18,代码来源:effects.cs

示例3: Draw

        public void Draw(IRenderer r, Node n)
        {
            //r.SetMode(RenderMode.Draw3D);
            //r.SetMode(RenderMode.Draw3DPointSprite);
            r.UseShader(Root.Instance.ResourceManager.LoadShader("terrain.shader"));
            Material.NoLighting = false;
            r.SetMaterial(Material);
            Material.Apply(Root.Instance.ResourceManager.LoadShader("terrain.shader"), r);
            //r.BindTexture(Color,0);
            //r.BindTexture(Detail,1);

            if (scamap != null)
            {
                Shader s = Root.Instance.ResourceManager.LoadShader("terrain.supcom.shader");
                r.UseShader(s);

                r.SetUniform(s.GetUniformLocation("LowerAlbedo"), new int[] { 0 });
                r.BindTexture(Root.Instance.ResourceManager.LoadTexture(scamap.Layers[0].PathTexture).Id, 0);

                r.SetUniform(s.GetUniformLocation("Albedo0"), new int[] { 1 });
                r.BindTexture(Root.Instance.ResourceManager.LoadTexture(scamap.Layers[1].PathTexture).Id, 1);

                r.SetUniform(s.GetUniformLocation("Albedo1"), new int[] { 2 });
                r.BindTexture(Root.Instance.ResourceManager.LoadTexture(scamap.Layers[2].PathTexture).Id, 2);

                r.SetUniform(s.GetUniformLocation("Albedo2"), new int[] { 3 });
                r.BindTexture(Root.Instance.ResourceManager.LoadTexture(scamap.Layers[3].PathTexture).Id, 3);

                r.SetUniform(s.GetUniformLocation("Albedo3"), new int[] { 4 });
                r.BindTexture(Root.Instance.ResourceManager.LoadTexture(scamap.Layers[4].PathTexture).Id, 4);

                r.SetUniform(s.GetUniformLocation("UpperAlbedo"), new int[] { 5 });
                r.BindTexture(Root.Instance.ResourceManager.LoadTexture(scamap.Layers[5].PathTexture).Id, 5);

                r.SetUniform(s.GetUniformLocation("Mask"), new int[] { 6 });
                r.BindTexture(Material.diffusemap.Id, 6);
                r.SetUniform(s.GetUniformLocation("NormalMap"), new int[] { 7 });
                r.BindTexture(Material.DetailMap.Id, 7);

                r.SetUniform(s.GetUniformLocation("TerrainScale"), new float[] { 10.0f});
                r.SetUniform(s.GetUniformLocation("LowerAlbedoTile"), new float[] { scamap.Layers[0].ScaleTexture });
                r.SetUniform(s.GetUniformLocation("Albedo0Tile"), new float[] { scamap.Layers[1].ScaleTexture });
                r.SetUniform(s.GetUniformLocation("Albedo1Tile"), new float[] { scamap.Layers[2].ScaleTexture });
                r.SetUniform(s.GetUniformLocation("Albedo2Tile"), new float[] { scamap.Layers[3].ScaleTexture });
                r.SetUniform(s.GetUniformLocation("Albedo3Tile"), new float[] { scamap.Layers[4].ScaleTexture });
                r.SetUniform(s.GetUniformLocation("UpperAlbedoTile"), new float[] { scamap.Layers[5].ScaleTexture });
            }
            else
            {
                r.UseShader(Root.Instance.ResourceManager.LoadShader("terrain.shader"));
                r.SetMaterial(Material);
                Material.Apply(Root.Instance.ResourceManager.LoadShader("terrain.shader"), r);
            }
            /*for(int x=0;x<PatchCount;++x)
            {
                for(int y=0;y<PatchCount;++y)
                {
                    Patches[y][x].Visible=false;
                }
            }*/

            ArrayList list=new ArrayList();
            Tree.GetVisibleLeafs(Root.Instance.Scene.camera,list);
            int frame=Root.Instance.frame;
            foreach(QuadTree q in list)
            {
                Patches[q.Position.Y][q.Position.X].VisibleFrame=frame;
            }
            int x,y;
            //for(int x=0;x<PatchCount;++x)
            {
                //for(int y=0;y<PatchCount;++y)
                foreach(QuadTree q in list)
                {
                    x=q.Position.X;
                    y=q.Position.Y;
                    //if(Patches[y][x].Visible)
                        Patches[y][x].Level=CalcLevel(x,y,Root.Instance.Scene.camera);
                }
            }
            //for(int x=0;x<PatchCount;++x)
            {
                //for(int y=0;y<PatchCount;++y)
                {
                    //if(Patches[y][x].Visible)
                    foreach(QuadTree q in list)
                    {
                        x=q.Position.X;
                        y=q.Position.Y;
                        Patches[y][x].FixCracks();
                        Patches[y][x].Draw(r,n);
                    }
                }
            }
            /*for(int x=0;x<PatchCount;++x)
            {
                for(int y=0;y<PatchCount;++y)
                {
                    if(Patches[y][x].Visible)
                }
//.........这里部分代码省略.........
开发者ID:cody82,项目名称:spacewar-arena,代码行数:101,代码来源:Terrain.cs

示例4: DrawInternal

        public override void DrawInternal(IRenderer r, RectangleF rect)
        {
            base.DrawInternal(r, rect);

            r.SetMode(RenderMode.Draw3DPointSprite);
            r.UseShader(Shader);
            r.Draw(PointBuffer, PrimitiveType.POINTS, 0, Count, null);
            r.SetMode(RenderMode.Draw2D);
        }
开发者ID:cody82,项目名称:spacewar-arena,代码行数:9,代码来源:windows.cs


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