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


C# ShaderProgram.setUniform方法代码示例

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


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

示例1: Sun

        public Sun(string dataBaseName, PlanetParameters param, Planet parent, MeshVBOs vbos, Texture t, ShaderProgram shader, ShaderProgram lineShader)
            : base(dataBaseName, param, parent, vbos, t, shader, lineShader)
        {
            bufferVerts = new VBO<float>(new float[] { -1, 1, 0, 1, 1, 0, 1, -1, 0, -1, -1, 0 }, BufferTarget.ArrayBuffer, VBO<float>.PointerType.vertex);
            bufferElems = new VBO<ushort>(new ushort[] { 0, 1, 2, 3 }, BufferTarget.ElementArrayBuffer, VBO<ushort>.PointerType.element);

            squareUvs = new VBO<float>(new float[] { 0, 1, 1, 1, 1, 0, 0, 0 }, BufferTarget.ArrayBuffer, VBO<float>.PointerType.texCoord);
            squareVerts = new VBO<float>(new float[] { -2, 2, 0, 2f, 2f, 0, 2f, -2f, 0, -2f, -2f, 0 }, BufferTarget.ArrayBuffer, VBO<float>.PointerType.vertex);
            squareElems = new VBO<ushort>(new ushort[] { 0, 1, 2, 3 }, BufferTarget.ElementArrayBuffer, VBO<ushort>.PointerType.element);

            this.coronaShader = new ShaderProgram(File.ReadAllText("content/shaders/coronaShader.vert"), File.ReadAllText("content/shaders/coronaShader.frag"), "coronaShader");
            Console.WriteLine(coronaShader.ProgramInfoLog);
            coronaShader.setUniform("proj", Form1.projectionMatrix);
            coronaShader.setUniform("model", Matrix4.Identity);

            this.billboardShader = new ShaderProgram(File.ReadAllText("content/shaders/billboardShader.vert"), File.ReadAllText("content/shaders/billboardShader.frag"), "billboardShader");
            Console.WriteLine(billboardShader.ProgramInfoLog);
            billboardShader.setUniform("proj", Form1.projectionMatrix);
            billboardShader.setUniform("model", Matrix4.Identity);

            frameBufferTime = 0;
            bufferResolution = new Vector2(1024, 1024);

            bufferTexture = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, bufferTexture);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)bufferResolution.X, (int)bufferResolution.Y, 0, PixelFormat.Rgba, PixelType.UnsignedByte, IntPtr.Zero);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);

            frameBuffer = GL.GenFramebuffer();
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, frameBuffer);
            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, bufferTexture, 0);
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); // make sure to set the framebuffer back to the default, or else bugs,
            //bugs that take two hours to debug
        }
开发者ID:Raptor2277,项目名称:Solar_System,代码行数:35,代码来源:Sun.cs

示例2: draw

        public void draw(Matrix4 cam, ShaderProgram shader)
        {
            GL.BindTexture(TextureTarget.Texture2D, this.texture.TextureID);

            shader.setUniform("model", parent.Transform);
            shader.setUniform("lighting", false);
            shader.bindBufferToShaderAttrib<float>(vbos.Verts, "vertIn");
            shader.bindBufferToShaderAttrib<float>(vbos.Uvs, "uvIn", 2);
            shader.bindBufferToShaderAttrib<float>(vbos.Normals, "normalIn");

            vbos.Elements.bind();

            GL.DrawElements(BeginMode.Quads, vbos.ElementsSize, DrawElementsType.UnsignedShort, 0);
        }
开发者ID:Raptor2277,项目名称:Solar_System,代码行数:14,代码来源:PlanetRing.cs

示例3: Earth

        public Earth(string dataBaseName, PlanetParameters param, Planet parent, MeshVBOs vbos, Texture diffuse, Texture specular, Texture night, Texture normal, Texture clouds, ShaderProgram earthShader, ShaderProgram lineShader)
            : base(dataBaseName, param, parent, vbos, diffuse, earthShader, lineShader)
        {
            this.specularT = specular;
            this.nightT = night;
            this.normalT = normal;
            this.cloudsT = clouds;
            this.cloudsSphereScale = Matrix4.CreateScale(1.005f);

            cloudShader = new ShaderProgram(File.ReadAllText("content/shaders/defaultShader.vert"), File.ReadAllText("content/shaders/cloudShader.frag"), "cloudShader");
            Console.WriteLine(cloudShader.ProgramInfoLog);
            cloudShader.setUniform("proj", Form1.projectionMatrix);
        }
开发者ID:Raptor2277,项目名称:Solar_System,代码行数:13,代码来源:Earth.cs

示例4: 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


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