Ejemplo n.º 1
0
        public void Render(AntiAliasingQuality quality, RenderTarget input, RenderTarget output)
        {
            if (EdgeParams[0] == null)
            {
                for (var i = 0; i < 4; i++)
                {
                    EdgeParams[i] = new EdgeShaderParams();
                    BlendParams[i] = new BlendShaderParams();
                    NeighborhoodParams[i] = new NeighborhoodShaderParams();

                    EdgeShader[i].GetUniformLocations(EdgeParams[i]);
                    BlendShader[i].GetUniformLocations(BlendParams[i]);
                    NeighborhoodShader[i].GetUniformLocations(NeighborhoodParams[i]);
                }
            }

            var index = (int)quality;

            // Edge
            Backend.BeginPass(EdgeRenderTarget, new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
            Backend.BeginInstance(EdgeShader[index].Handle, new int[] { input.Textures[0].Handle },
                samplers: new int[] { LinearClampSampler });
            Backend.BindShaderVariable(EdgeParams[index].SamplerScene, 0);

            Backend.DrawMesh(QuadMesh.MeshHandle);
            Backend.EndPass();

            // Blend
            Backend.BeginPass(BlendRenderTarget, new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
            Backend.BeginInstance(BlendShader[index].Handle, new int[] { EdgeRenderTarget.Textures[0].Handle, AreaTexture.Handle, SearchTexture.Handle },
                samplers: new int[] { LinearClampSampler, LinearClampSampler, NearClampSampler });
            Backend.BindShaderVariable(BlendParams[index].SamplerEdge, 0);
            Backend.BindShaderVariable(BlendParams[index].SamplerArea, 1);
            Backend.BindShaderVariable(BlendParams[index].SamplerSearch, 2);

            Backend.DrawMesh(QuadMesh.MeshHandle);
            Backend.EndPass();

            // Neighborhood
            Backend.BeginPass(output, new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
            Backend.BeginInstance(NeighborhoodShader[index].Handle, new int[] { input.Textures[0].Handle, BlendRenderTarget.Textures[0].Handle },
                samplers: new int[] { LinearClampSampler, LinearClampSampler });
            Backend.BindShaderVariable(NeighborhoodParams[index].SamplerScene, 0);
            Backend.BindShaderVariable(NeighborhoodParams[index].SamplerBlend, 1);

            Backend.DrawMesh(QuadMesh.MeshHandle);
            Backend.EndPass();
        }
Ejemplo n.º 2
0
    private SMAA.QualityPreset GetMsaaPreset(AntiAliasingQuality quality)
    {
        switch (quality)
        {
        case AntiAliasingQuality.Low:
            return(SMAA.QualityPreset.Low);

        case AntiAliasingQuality.Medium:
            return(SMAA.QualityPreset.Medium);

        case AntiAliasingQuality.High:
            return(SMAA.QualityPreset.High);

        case AntiAliasingQuality.Ultra:
            return(SMAA.QualityPreset.Ultra);

        default:
            throw new ArgumentOutOfRangeException("quality", quality, null);
        }
    }
Ejemplo n.º 3
0
    private FXAA.Preset GetFxaaPreset(AntiAliasingQuality quality)
    {
        switch (quality)
        {
        case AntiAliasingQuality.Low:
            return(FXAA.Preset.performancePreset);

        case AntiAliasingQuality.Medium:
            return(FXAA.Preset.defaultPreset);

        case AntiAliasingQuality.High:
            return(FXAA.Preset.qualityPreset);

        case AntiAliasingQuality.Ultra:
            return(FXAA.Preset.extremeQualityPreset);

        default:
            throw new ArgumentOutOfRangeException("quality", quality, null);
        }
    }