示例#1
0
        private void CombineSecond()
        {
            CombinerSecondShader.Use();
            HelperFramebuffer.Use();

            VXGIFramebuffer.UseTexture(9);
            CombinerFramebuffer.UseTexture(4);

            DrawPPMesh();
            Game.CheckErrors("Combine2 pass");
        }
示例#2
0
        public Renderer(int initialWidth, int initialHeight, int samples)
        {
            GlareTexture = new Texture(Media.Get("glaretex.png"));

            Voxelizer = new Voxel3dTextureWriter(256, 256, 256, new Vector3(22, 22, 22), new Vector3(0, 8, 0));

            CubeMapSphere = new Object3dInfo(Object3dManager.LoadFromObjSingle(Media.Get("cubemapsphere.obj")).Vertices);

            var cubeMapTexDefault = new CubeMapTexture(Media.Get("posx.jpg"), Media.Get("posy.jpg"), Media.Get("posz.jpg"),
                                                       Media.Get("negx.jpg"), Media.Get("negy.jpg"), Media.Get("negz.jpg"));

            CubeMaps.Add(new CubeMapInfo()
            {
                Texture      = cubeMapTexDefault,
                FalloffScale = 99999999.0f,
                Position     = Vector3.Zero
            });

            Width  = initialWidth;
            Height = initialHeight;


            Samples = samples;

            CreateBuffers();

            HDRShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "HDR.fragment.glsl");
            HDRShader.SetGlobal("MSAA_SAMPLES", samples.ToString());
            if (samples > 1)
            {
                HDRShader.SetGlobal("USE_MSAA", "");
            }

            VXGIShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "VXGI.fragment.glsl");
            VXGIShader.SetGlobal("MSAA_SAMPLES", samples.ToString());
            if (samples > 1)
            {
                VXGIShader.SetGlobal("USE_MSAA", "");
            }

            AmbientOcclusionShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "AmbientOcclusion.fragment.glsl");
            AmbientOcclusionShader.SetGlobal("MSAA_SAMPLES", samples.ToString());
            if (samples > 1)
            {
                AmbientOcclusionShader.SetGlobal("USE_MSAA", "");
            }

            FogShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "Fog.fragment.glsl");
            FogShader.SetGlobal("MSAA_SAMPLES", samples.ToString());
            if (samples > 1)
            {
                FogShader.SetGlobal("USE_MSAA", "");
            }

            DeferredShader = ShaderProgram.Compile("PostProcessPerspective.vertex.glsl", "Deferred.fragment.glsl");
            DeferredShader.SetGlobal("MSAA_SAMPLES", samples.ToString());
            if (samples > 1)
            {
                DeferredShader.SetGlobal("USE_MSAA", "");
            }

            EnvLightShader = ShaderProgram.Compile("PostProcessPerspective.vertex.glsl", "EnvironmentLight.fragment.glsl");
            EnvLightShader.SetGlobal("MSAA_SAMPLES", samples.ToString());
            if (samples > 1)
            {
                EnvLightShader.SetGlobal("USE_MSAA", "");
            }

            CombinerShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "Combiner.fragment.glsl");
            CombinerShader.SetGlobal("MSAA_SAMPLES", samples.ToString());
            if (samples > 1)
            {
                CombinerShader.SetGlobal("USE_MSAA", "");
            }

            CombinerSecondShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "CombinerSecond.fragment.glsl");
            CombinerSecondShader.SetGlobal("MSAA_SAMPLES", samples.ToString());
            if (samples > 1)
            {
                CombinerSecondShader.SetGlobal("USE_MSAA", "");
            }

            MotionBlurShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "MotionBlur.fragment.glsl");
            MotionBlurShader.SetGlobal("MSAA_SAMPLES", samples.ToString());
            if (samples > 1)
            {
                MotionBlurShader.SetGlobal("USE_MSAA", "");
            }

            BloomShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "Bloom.fragment.glsl");

            PostProcessingMesh          = new Object3dInfo(VertexInfo.FromFloatArray(postProcessingPlaneVertices));
            PostProcessingMesh.DrawMode = PrimitiveType.TriangleStrip;
        }