void init(float nearPlane, float farPlane)
        {
            init_renderpass();

            descLayoutMain = new DescriptorSetLayout(dev,
                                                     new VkDescriptorSetLayoutBinding(0, VkShaderStageFlags.Vertex | VkShaderStageFlags.Fragment, VkDescriptorType.UniformBuffer),//matrices and params
                                                     new VkDescriptorSetLayoutBinding(1, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler),
                                                     new VkDescriptorSetLayoutBinding(2, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler),
                                                     new VkDescriptorSetLayoutBinding(3, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler),
                                                     new VkDescriptorSetLayoutBinding(4, VkShaderStageFlags.Fragment, VkDescriptorType.UniformBuffer),  //lights
                                                     new VkDescriptorSetLayoutBinding(5, VkShaderStageFlags.Fragment, VkDescriptorType.UniformBuffer)); //materials
#if WITH_SHADOWS
            descLayoutMain.Bindings.Add(new VkDescriptorSetLayoutBinding(6, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler));
#endif

            if (TEXTURE_ARRAY)
            {
                descLayoutMain.Bindings.Add(new VkDescriptorSetLayoutBinding(7, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler));                  //texture array
                //descLayoutMain.Bindings.Add (new VkDescriptorSetLayoutBinding (8, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler));//down sampled hdr
            }
            else
            {
                descLayoutTextures = new DescriptorSetLayout(dev,
                                                             new VkDescriptorSetLayoutBinding(0, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler),
                                                             new VkDescriptorSetLayoutBinding(1, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler),
                                                             new VkDescriptorSetLayoutBinding(2, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler),
                                                             new VkDescriptorSetLayoutBinding(3, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler),
                                                             new VkDescriptorSetLayoutBinding(4, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler)
                                                             );
            }

            descLayoutGBuff = new DescriptorSetLayout(dev,
                                                      new VkDescriptorSetLayoutBinding(0, VkShaderStageFlags.Fragment, VkDescriptorType.InputAttachment),  //color + roughness
                                                      new VkDescriptorSetLayoutBinding(1, VkShaderStageFlags.Fragment, VkDescriptorType.InputAttachment),  //emit + metal
                                                      new VkDescriptorSetLayoutBinding(2, VkShaderStageFlags.Fragment, VkDescriptorType.InputAttachment),  //normals + AO
                                                      new VkDescriptorSetLayoutBinding(3, VkShaderStageFlags.Fragment, VkDescriptorType.InputAttachment)); //Pos + depth



            GraphicPipelineConfig cfg = GraphicPipelineConfig.CreateDefault(VkPrimitiveTopology.TriangleList, NUM_SAMPLES);
            cfg.rasterizationState.cullMode = VkCullModeFlags.Back;
            if (NUM_SAMPLES != VkSampleCountFlags.SampleCount1)
            {
                cfg.multisampleState.sampleShadingEnable = true;
                cfg.multisampleState.minSampleShading    = 0.5f;
            }
            cfg.Cache = pipelineCache;
            if (TEXTURE_ARRAY)
            {
                cfg.Layout = new PipelineLayout(dev, descLayoutMain, descLayoutGBuff);
            }
            else
            {
                cfg.Layout = new PipelineLayout(dev, descLayoutMain, descLayoutGBuff, descLayoutTextures);
            }

            cfg.Layout.AddPushConstants(
                new VkPushConstantRange(VkShaderStageFlags.Vertex, (uint)Marshal.SizeOf <Matrix4x4> ()),
                new VkPushConstantRange(VkShaderStageFlags.Fragment, sizeof(int), 64)
                );
            cfg.RenderPass   = renderPass;
            cfg.SubpassIndex = SP_MODELS;
            cfg.blendAttachments.Add(new VkPipelineColorBlendAttachmentState(false));
            cfg.blendAttachments.Add(new VkPipelineColorBlendAttachmentState(false));
            cfg.blendAttachments.Add(new VkPipelineColorBlendAttachmentState(false));
            //cfg.blendAttachments.Add (new VkPipelineColorBlendAttachmentState (false));

            cfg.AddVertex <PbrModelTexArray.Vertex> ();

            using (SpecializationInfo constants = new SpecializationInfo(
                       new SpecializationConstant <float> (0, nearPlane),
                       new SpecializationConstant <float> (1, farPlane),
                       new SpecializationConstant <float> (2, MAX_MATERIAL_COUNT))) {
                cfg.AddShaders(new ShaderInfo(dev, VkShaderStageFlags.Vertex, "#shaders.GBuffPbr.vert.spv"));
                if (TEXTURE_ARRAY)
                {
                    cfg.AddShaders(new ShaderInfo(dev, VkShaderStageFlags.Fragment, "#shaders.GBuffPbrTexArray.frag.spv", constants));
                }
                else
                {
                    cfg.AddShaders(new ShaderInfo(dev, VkShaderStageFlags.Fragment, "#shaders.GBuffPbr.frag.spv", constants));
                }

                gBuffPipeline = new GraphicPipeline(cfg);
            }
            cfg.rasterizationState.cullMode = VkCullModeFlags.Front;
            //COMPOSE PIPELINE
            cfg.blendAttachments.Clear();
            cfg.blendAttachments.Add(new VkPipelineColorBlendAttachmentState(false));
            cfg.ResetShadersAndVerticesInfos();
            cfg.SubpassIndex = SP_COMPOSE;
            cfg.Layout       = gBuffPipeline.Layout;
            cfg.depthStencilState.depthTestEnable  = false;
            cfg.depthStencilState.depthWriteEnable = false;
            using (SpecializationInfo constants = new SpecializationInfo(
                       new SpecializationConstant <uint> (0, (uint)lights.Length))) {
                cfg.AddShaders(new ShaderInfo(dev, VkShaderStageFlags.Vertex, "#vke.FullScreenQuad.vert.spv"));
#if WITH_SHADOWS
                cfg.AddShaders(new ShaderInfo(dev, VkShaderStageFlags.Fragment, "#shaders.compose_with_shadows.frag.spv", constants));
#else
                cfg.AddShader(VkShaderStageFlags.Fragment, "#shaders.compose.frag.spv", constants);
#endif
                composePipeline = new GraphicPipeline(cfg);
            }
            cfg.Shaders[1].Dispose();
            //DEBUG DRAW use subpass of compose
            cfg.Shaders[1]   = new ShaderInfo(dev, VkShaderStageFlags.Fragment, "#shaders.show_gbuff.frag.spv");
            cfg.SubpassIndex = SP_COMPOSE;
            debugPipeline    = new GraphicPipeline(cfg);
            cfg.DisposeShaders();
            ////TONE MAPPING
            //cfg.shaders[1] = new ShaderInfo (VkShaderStageFlags.Fragment, "#shaders.tone_mapping.frag.spv");
            //cfg.SubpassIndex = SP_TONE_MAPPING;
            //toneMappingPipeline = new GraphicPipeline (cfg);

            dsMain  = descriptorPool.Allocate(descLayoutMain);
            dsGBuff = descriptorPool.Allocate(descLayoutGBuff);

            envCube = new EnvironmentCube(cubemapPath, gBuffPipeline.Layout, gQueue, renderPass);

            matrices.prefilteredCubeMipLevels = envCube.prefilterCube.CreateInfo.mipLevels;

            DescriptorSetWrites dsMainWrite = new DescriptorSetWrites(dsMain, descLayoutMain.Bindings.GetRange(0, 5).ToArray());
            dsMainWrite.Write(dev,
                              uboMatrices.Descriptor,
                              envCube.irradianceCube.Descriptor,
                              envCube.prefilterCube.Descriptor,
                              envCube.lutBrdf.Descriptor,
                              uboLights.Descriptor);

#if WITH_SHADOWS
            dsMainWrite = new DescriptorSetWrites(dsMain, descLayoutMain.Bindings[6]);
            dsMainWrite.Write(dev, shadowMapRenderer.shadowMap.Descriptor);
#endif
        }