Ejemplo n.º 1
0
 protected override void DoInitialize()
 {
     base.DoInitialize();
     {
         var           shader  = new ComputeShader(computeCode);
         var           array   = new ShaderArray(shader);
         ShaderProgram program = array.GetShaderProgram();
         this.computeProgram = program;
     }
     {
         VertexBuffer buffer  = this.RenderUnit.Model.GetVertexAttribute(ParticlesModel.strPosition).First();
         Texture      texture = buffer.DumpBufferTexture(GL.GL_RGBA32F, false);
         this.texPosition = texture;
     }
     {
         VertexBuffer buffer  = this.RenderUnit.Model.GetVertexAttribute(ParticlesModel.strVelocity).First();
         Texture      texture = buffer.DumpBufferTexture(GL.GL_RGBA32F, false);
         this.texVelocity = texture;
     }
     {
         var random = new Random();
         for (int i = 0; i < attractorCount; i++)
         {
             this.attractors[i] = new vec4((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble());
         }
     }
 }
Ejemplo n.º 2
0
        public PeelingNode(vec3 size, params SceneNodeBase[] children)
        {
            this.ModelSize = size;

            this.query = new Query();
            this.Children.AddRange(children);
            {
                var cs       = new CSharpGL.ComputeShader(Shaders.engraveXComp);
                var provider = new ShaderArray(cs);
                this.engraveXComp = provider.GetShaderProgram();
            }
            {
                var cs       = new CSharpGL.ComputeShader(Shaders.engraveYComp);
                var provider = new ShaderArray(cs);
                this.engraveYComp = provider.GetShaderProgram();
            }
            {
                var cs       = new CSharpGL.ComputeShader(Shaders.engraveZComp);
                var provider = new ShaderArray(cs);
                this.engraveZComp = provider.GetShaderProgram();
            }
            {
                var data = new uint[Width * Height * Depth];
                this.outBuffer = data.GenVertexBuffer(VBOConfig.UInt, BufferUsage.DynamicCopy);
            }
            {
                this.InitializePeelingResource(vWidth, vHeight);
            }
        }
Ejemplo n.º 3
0
        //public static PBRNode Create()
        //{
        //    var model = new SphereModel();
        //    RenderMethodBuilder background, pbr, irradiance, equiRectangular2Cubemap, brdf, prefliter, debug;
        //    {
        //        var vs = new VertexShader(backgroundVertexCode);
        //        var fs = new FragmentShader(backgroundFragmentCode);
        //        var map = new AttributeMap();
        //        map.Add("vPosition", SphereModel.strPosition);
        //        background = new RenderMethodBuilder(new ShaderArray(vs, fs), map);
        //    }
        //    {
        //        var vs = new VertexShader(PBRVertexCode);
        //        var fs = new FragmentShader(PBRFragmentCode);
        //        var map = new AttributeMap();
        //        map.Add("vPosition", SphereModel.strPosition);
        //        map.Add("vTexCoords", SphereModel.strTexCoord);
        //        map.Add("vNormal", SphereModel.strNormal);
        //        pbr = new RenderMethodBuilder(new ShaderArray(vs, fs), map);
        //    }
        //    {
        //        var vs = new VertexShader(irradianceVertexCode);
        //        var fs = new FragmentShader(irradianceFragmentCode);
        //        var map = new AttributeMap();
        //        map.Add("vPosition", SphereModel.strPosition);
        //        irradiance = new RenderMethodBuilder(new ShaderArray(vs, fs), map);
        //    }
        //    {
        //        var vs = new VertexShader(equiRectangularVertexCode);
        //        var fs = new FragmentShader(equiRectangularFragmentCode);
        //        var map = new AttributeMap();
        //        map.Add("vPosition", SphereModel.strPosition);
        //        equiRectangular2Cubemap = new RenderMethodBuilder(new ShaderArray(vs, fs), map);
        //    }
        //    {
        //        var vs = new VertexShader(BRDFVertexCode);
        //        var fs = new FragmentShader(BRDFFragmentCode);
        //        var map = new AttributeMap();
        //        map.Add("vPosition", SphereModel.strPosition);
        //        map.Add("vTexCoords", SphereModel.strTexCoord);
        //        brdf = new RenderMethodBuilder(new ShaderArray(vs, fs), map);
        //    }
        //    {
        //        var vs = new VertexShader(prefliterVertexCode);
        //        var fs = new FragmentShader(prefliterFragmentCode);
        //        var map = new AttributeMap();
        //        map.Add("vPosition", SphereModel.strPosition);
        //        prefliter = new RenderMethodBuilder(new ShaderArray(vs, fs), map);
        //    }
        //    {
        //        var vs = new VertexShader(debugWindowVertexCode);
        //        var fs = new FragmentShader(debugWindowFragmentCode);
        //        var map = new AttributeMap();
        //        map.Add("vPosition", SphereModel.strPosition);
        //        map.Add("vTexcoord", SphereModel.strTexCoord);
        //        debug = new RenderMethodBuilder(new ShaderArray(vs, fs), map);
        //    }

        //    var node = new PBRNode(model, background, pbr, irradiance, equiRectangular2Cubemap, brdf, prefliter, debug);

        //    node.Initialize();

        //    return node;
        //}

        public PBRNode()
        {
            {
                var vs    = new VertexShader(backgroundVertexCode);
                var fs    = new FragmentShader(backgroundFragmentCode);
                var array = new ShaderArray(vs, fs);
                this.backgroundProgram = array.GetShaderProgram();
            }
            {
                var vs    = new VertexShader(PBRVertexCode);
                var fs    = new FragmentShader(PBRFragmentCode);
                var array = new ShaderArray(vs, fs);
                this.pbrProgram = array.GetShaderProgram();
            }
            {
                var vs    = new VertexShader(irradianceVertexCode);
                var fs    = new FragmentShader(irradianceFragmentCode);
                var array = new ShaderArray(vs, fs);
                this.irradianceProgram = array.GetShaderProgram();
            }
            {
                var vs    = new VertexShader(equiRectangularVertexCode);
                var fs    = new FragmentShader(equiRectangularFragmentCode);
                var array = new ShaderArray(vs, fs);
                this.equiRectangular2CubemapProgram = array.GetShaderProgram();
            }
            {
                var vs    = new VertexShader(BRDFVertexCode);
                var fs    = new FragmentShader(BRDFFragmentCode);
                var array = new ShaderArray(vs, fs);
                this.brdfProgram = array.GetShaderProgram();
            }
            {
                var vs    = new VertexShader(prefliterVertexCode);
                var fs    = new FragmentShader(prefliterFragmentCode);
                var array = new ShaderArray(vs, fs);
                this.prefliterProgram = array.GetShaderProgram();
            }
            {
                var vs    = new VertexShader(debugWindowVertexCode);
                var fs    = new FragmentShader(debugWindowFragmentCode);
                var array = new ShaderArray(vs, fs);
                this.debugProgram = array.GetShaderProgram();
            }

            this.Initialize();
        }