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


C# ShaderProgram.Use方法代码示例

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


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

示例1: loadContent

        void loadContent()
        {
            scenes = new List<Scene>();
            setProjectionMatrix();

            Dictionary<Enums.Textures, Texture> textures = new Dictionary<Enums.Textures, Texture>();
            Dictionary<Enums.MeshVBOs, MeshVBOs> meshVBOs = new Dictionary<Enums.MeshVBOs, MeshVBOs>();
            Dictionary<Enums.Shaders, ShaderProgram> shaders = new Dictionary<Enums.Shaders, ShaderProgram>();

            ShaderProgram defaultShader = new ShaderProgram(File.ReadAllText("content/shaders/defaultShader.vert"), File.ReadAllText("content/shaders/defaultShader.frag"), "defaultShader");
            //defaultShader.writeAllInfoLogs();
            Console.WriteLine(defaultShader.ProgramInfoLog);
            Console.WriteLine(defaultShader.ShaderInfoLog);
            defaultShader.Use();
            defaultShader.setUniform("lightPos", new Vector3(1,1,1));
            defaultShader.setUniform("ambientCoefficient", .1f);
            defaultShader.setUniform("lightIntensities", Vector3.One);

            ShaderProgram earthShader = new ShaderProgram(File.ReadAllText("content/shaders/earthShader.vert"), File.ReadAllText("content/shaders/earthShader.frag"), "earthShader");
            //earthShader.writeAllInfoLogs();
            Console.WriteLine(earthShader.ProgramInfoLog);
            earthShader.Use();
            earthShader.setUniform("lightPos", Vector3.Zero);
            earthShader.setUniform("lightIntensities", Vector3.One);

            ShaderProgram sunShader = new ShaderProgram(File.ReadAllText("content/shaders/defaultShader.vert"), File.ReadAllText("content/shaders/sunShader.frag"), "sunShader");
            Console.WriteLine(sunShader.ProgramInfoLog);
            //sunShader.writeAllInfoLogs();

            ShaderProgram lineShader = new ShaderProgram(File.ReadAllText("content/shaders/lineShader.vert"), File.ReadAllText("content/shaders/lineShader.frag"), "lineShader");
            Console.WriteLine(lineShader.ProgramInfoLog);
            //lineShader.writeAllInfoLogs();

            shaders.Add(Enums.Shaders.default_, defaultShader);
            shaders.Add(Enums.Shaders.earth, earthShader);
            shaders.Add(Enums.Shaders.sun, sunShader);
            shaders.Add(Enums.Shaders.line, lineShader);

            Console.Write("Loaded Shaders...");

            PlanetParameters planetParams = PlanetParameters.readFromFile("content/planetInfo.txt");
            ObjLoader loader = new ObjLoader();

            meshVBOs.Add(Enums.MeshVBOs.planet, loader.loadVBOS("content/models/sphere.obj"));
            meshVBOs.Add(Enums.MeshVBOs.saturnRings, loader.loadVBOS("content/models/saturnRings.obj"));
            meshVBOs.Add(Enums.MeshVBOs.uranusRings, loader.loadVBOS("content/models/uranusRings.obj"));

            Console.Write("Loading Textures...");

            textures.Add(Enums.Textures.starsT, new Texture("content/textures/stars.jpg"));
            textures.Add(Enums.Textures.sunT, new Texture("content/textures/sun4096g.jpg"));
            textures.Add(Enums.Textures.mercury, new Texture("content/textures/mercury4096.jpg"));
            textures.Add(Enums.Textures.venusT, new Texture("content/textures/venus4096.jpg"));
            textures.Add(Enums.Textures.earthT, new Texture("content/textures/earth4096.jpg"));
            textures.Add(Enums.Textures.earth_SpecT, new Texture("content/textures/earth_Spec4096.png"));
            textures.Add(Enums.Textures.earth_NightT, new Texture("content/textures/earth_Night4096.jpg"));
            textures.Add(Enums.Textures.earth_NormalT, new Texture("content/textures/earth_Normal4096.jpg"));
            textures.Add(Enums.Textures.earty_CloudsT, new Texture("content/textures/earth_Clouds4096.jpg"));
            textures.Add(Enums.Textures.moonT, new Texture("content/textures/moon4096.jpg"));
            textures.Add(Enums.Textures.marsT, new Texture("content/textures/mars4096.jpg"));
            textures.Add(Enums.Textures.jupiterT, new Texture("content/textures/jupiter4096.jpg"));
            textures.Add(Enums.Textures.saturnT, new Texture("content/textures/saturn2048.jpg"));
            textures.Add(Enums.Textures.uranusT, new Texture("content/textures/uranus2048.png"));
            textures.Add(Enums.Textures.neptuneT, new Texture("content/textures/neptune1024.png"));
            textures.Add(Enums.Textures.plutoT, new Texture("content/textures/pluto1024.jpg"));
            textures.Add(Enums.Textures.saturn_RingsT, new Texture("content/textures/saturnRings.png"));
            textures.Add(Enums.Textures.uranus_RingsT, new Texture("content/textures/uranusRings.png"));

            Console.Write(" done!\n");

            solarSystemScene = new SolarSystemScene(planetParams, meshVBOs, textures, shaders, hoursPerSecond, ZAxisLine, this.glPannel);
            scenes.Add(solarSystemScene);

            //planetSizeScene = new PlanetSizeScene(meshVBOs, textures, shaders);
            //scenes.Add(planetSizeScene);

            activeScene = scenes[0];

            Console.WriteLine("Created Scenes");
        }
开发者ID:Raptor2277,项目名称:Solar_System,代码行数:80,代码来源:Form1.cs

示例2: TextureInfo

            public TextureInfo( ShaderProgram shader, String identifier,
                TextureUnit textureUnit = TextureUnit.Texture0)
            {
                Shader = shader;
                Identifier = identifier;
                UniformLocation = GL.GetUniformLocation( Shader.Program, Identifier );
                TextureUnit = textureUnit;

                Shader.Use();

                int val = int.Parse( TextureUnit.ToString().Substring( "Texture".Length ) );

                GL.Uniform1( UniformLocation, val );

                CurrentTexture = null;
            }
开发者ID:vashage,项目名称:MarsMiner,代码行数:16,代码来源:ShaderProgram.cs

示例3: Draw

 public void Draw(ShaderProgram shaderProg)
 {
     shaderProg.Use (shader => {
         this.ViewportTarget.DrawRaw (shader, Matrix);
     });
 }
开发者ID:splitandthechro,项目名称:nginz,代码行数:6,代码来源:Viewport.cs


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