Example #1
0
        public MainVisual(IRenderState renderState, IContentLoader contentLoader)
        {
            this.renderState  = renderState;
            shaderProgram     = contentLoader.Load <IShaderProgram>("lambert.*");
            shaderPostProcess = contentLoader.LoadPixelShader("ChromaticAberration");
            shaderPostProcess = contentLoader.LoadPixelShader("swirl");
            shaderPostProcess = contentLoader.LoadPixelShader("sepia");
            shaderPostProcess = contentLoader.LoadPixelShader("vignet");
            shaderPostProcess = contentLoader.LoadPixelShader("Ripple");

            var mesh = Meshes.CreateCornellBox();             //TODO: ATI seams to do VAO vertex attribute ordering different for each shader would need to create own VAO

            geometry = VAOLoader.FromMesh(mesh, shaderProgram);
        }
Example #2
0
        public MainVisual(IRenderContext context, IContentLoader contentLoader)
        {
            this.context            = context;
            frameBuffer             = context.GetFrameBuffer();
            surfaceGeometry         = context.CreateRenderSurface(1024, 1024, true);
            suzanne.BackfaceCulling = true;
            suzanne.SetInputTexture("chalet", contentLoader.Load <ITexture2D>("chalet.jpg"));
            //model from https://sketchfab.com/models/e925320e1d5744d9ae661aeff61e7aef
            var mesh = contentLoader.Load <DefaultMesh>("chalet.obj").Transform(Transformation.Rotation(-90f, Axis.X));

            suzanne.UpdateMeshShader(mesh, contentLoader.Load <IShaderProgram>("shader.*"));
            suzanne.ZBufferTest = true;

            copyQuad.BackfaceCulling = false;
            copyQuad.SetInputTexture("tex", surfaceGeometry);
            copyQuad.UpdateMeshShader(null, contentLoader.LoadPixelShader("copy.frag"));
            copyQuad.ZBufferTest = false;

            var delta      = 2f;
            var extend     = 1f * delta;
            var translates = new List <Vector3>();

            for (float x = -extend; x <= extend; x += delta)
            {
                for (float z = -extend; z <= extend; z += delta)
                {
                    translates.Add(new Vector3(x, 0, z));
                }
            }
            suzanne.UpdateInstanceAttribute("translate", translates.ToArray());
            suzanne.InstanceCount = translates.Count;
        }
Example #3
0
        public DeferredRenderer(IContentLoader contentLoader, IRenderState renderState)
        {
            renderState.Set <DepthTest>(new DepthTest(true));
            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.Blend);
            GL.CullFace(CullFaceMode.Back);


            this.renderState   = renderState;
            this.contentLoader = contentLoader;

            deferredParticleShader        = contentLoader.Load <IShaderProgram>("deferred_particle.*");
            shadowMapShaderParticle       = contentLoader.Load <IShaderProgram>("shadowMapParticle.*");
            shadowLightViewShaderParticle = contentLoader.Load <IShaderProgram>("shadowLightViewParticle.*");

            deferredGeometryShader = contentLoader.Load <IShaderProgram>("deferred_geometry.*");

            deferredPost          = contentLoader.LoadPixelShader("deferred_post");
            pointLightShader      = contentLoader.Load <IShaderProgram>("def_pointLight.*");
            shadowMapShader       = contentLoader.Load <IShaderProgram>("shadowMap.*");
            shadowLightViewShader = contentLoader.Load <IShaderProgram>("shadowLightView.*");
            var lmesh = Meshes.CreateSphere(1, 2);

            pointLightSphere = VAOLoader.FromMesh(lmesh, pointLightShader);
        }
Example #4
0
        public SATGpuFilter(IContentLoader contentLoader, IRenderState renderState, int amountBlocksX, int amountBlocksY, int resX, int resY, int kernelSizeY, int kernelSizeX)
        {
            this.contentLoader  = contentLoader;
            this.renderState    = renderState;
            shaderSumHorizontal = contentLoader.LoadPixelShader("SATSumHorizontal");
            shaderSumVertical   = contentLoader.LoadPixelShader("SATSumVertical");

            shaderAssemblyVertical   = contentLoader.LoadPixelShader("SATAssemblyPassVertical");
            shaderAssemblyHorizontal = contentLoader.LoadPixelShader("SATAssemblyPassHorizontal");

            shaderSATFilter  = contentLoader.LoadPixelShader("SATFiltering");
            fullScreenQuad   = contentLoader.Load <IShaderProgram>("FullQuad.*");
            testTexture      = contentLoader.Load <ITexture2D>("testTexture.*");
            this.kernelSizeX = kernelSizeX;
            this.kernelSizeY = kernelSizeY;
            SetUpBlocksAndTextures(amountBlocksX, amountBlocksY, testTexture.Width, testTexture.Height);
        }
Example #5
0
        public DirectionalShadowMapping(IContentLoader contentLoader, Dictionary <Enums.EntityType, DefaultMesh> meshes)
        {
            _depthShader  = contentLoader.Load <IShaderProgram>("depth.*");
            _shadowShader = contentLoader.LoadPixelShader("shadow.glsl");

            foreach (var meshContainer in meshes)
            {
                _geometriesDepth.Add(meshContainer.Key, VAOLoader.FromMesh(meshContainer.Value, _depthShader));
            }
        }
        public DeferedVisual(IRenderState renderState, IContentLoader contentLoader)
        {
            this.renderState   = renderState;
            deferedDataProgram = contentLoader.Load <IShaderProgram>(new string[] { "lambert.vert", "deferedData.frag" });
            deferedProgram     = contentLoader.LoadPixelShader("defered.frag");
            //deferedProgram = contentLoader.Load<IShaderProgram>("lambert.*");

            var mesh = Meshes.CreateCornellBox(); //TODO: ATI seams to do VAO vertex attribute ordering different for each shader would need to create own VAO

            geometry = VAOLoader.FromMesh(mesh, deferedDataProgram);
        }
Example #7
0
        public Visual(IRenderState renderState, IContentLoader contentLoader)
        {
            fbo = new FBO(Texture2dGL.Create(70, 70));
            fbo.Texture.Filter = TextureFilterMode.Nearest;
            copyToFrameBuffer  = new PostProcessing(contentLoader.LoadPixelShader("copy.frag"));

            renderState.Set(BlendStates.AlphaBlend);
            renderState.Set(new LineSmoothing(true));
            renderState.Set(new LineWidth(5f));
            GL.Enable(EnableCap.PointSmooth);
        }
Example #8
0
        public MainVisual(IRenderContext renderContext, IContentLoader contentLoader)
        {
            frameBuffer             = renderContext.GetFrameBuffer();
            imageObstacles          = renderContext.CreateRenderSurface(512, 512, false, 2, true);
            imageObstaclesLastFrame = renderContext.CreateRenderSurface(512, 512, false, 2, true);

            paintObstacles.UpdateMeshShader(null, contentLoader.LoadPixelShader("paintObstacles"));

            drawParticles.ShaderPointSize = true;
            drawParticles.UpdateShaderBuffer("Particles", InitParticles());
            drawParticles.UpdateMeshShader(null, contentLoader.Load <IShaderProgram>("particles.*"));
            drawParticles.InstanceCount = particleCount;
        }
Example #9
0
        public Rasterizer(IContentLoader contentLoader, int resolutionX, int resolutionY, Action drawHandler)
        {
            if (drawHandler is null)
            {
                throw new ArgumentException("Draw handler must not equal null!");
            }

            this.drawHandler  = drawHandler;
            copyToFrameBuffer = new PostProcessing(contentLoader.LoadPixelShader("copy.frag"));
            var texRenderSurface = Texture2dGL.Create(resolutionX, resolutionY);

            texRenderSurface.Filter = TextureFilterMode.Nearest;
            fbo = new FBO(texRenderSurface);
        }
 public PostProcessingVisual(int width, int height, IContentLoader contentLoader)
 {
     renderToTexture = new FBO(Texture2dGL.Create(width, height));
     renderToTexture.Texture.WrapFunction = TextureWrapFunction.MirroredRepeat;
     try
     {
         shaderProgram = contentLoader.LoadPixelShader("Grayscale");
         shaderProgram = contentLoader.LoadPixelShader("Sepia");
         shaderProgram = contentLoader.LoadPixelShader("Vignetting");
         shaderProgram = contentLoader.LoadPixelShader("ChromaticAberration");
         shaderProgram = contentLoader.LoadPixelShader("convolution");
         shaderProgram = contentLoader.LoadPixelShader("EdgeDetect");
         shaderProgram = contentLoader.LoadPixelShader("Ripple");
         shaderProgram = contentLoader.LoadPixelShader("Swirl");
     }
     catch (ShaderException e)
     {
         Console.WriteLine(e.Message);
         Console.ReadLine();
     }
 }
Example #11
0
 public SSAOWithBlur(IContentLoader contentLoader, float blurKernelSize)
 {
     _ssao   = new OnePassPostProcessShader(contentLoader.LoadPixelShader("SSAO.glsl"));
     _blur   = new AvgBlur(contentLoader, blurKernelSize);
     _shader = contentLoader.LoadPixelShader("saturationMap.glsl");
 }
Example #12
0
 public Bloom(IContentLoader contentLoader)
 {
     _extract = new OnePassPostProcessShader(contentLoader.LoadPixelShader("Extract.glsl"));
     _blur    = new AvgBlur(contentLoader);
     _add     = new Addition(contentLoader);
 }
Example #13
0
 public Add(IContentLoader contentLoader, byte fboTexComponentCount = 4, bool fboTexFloat = false)
 {
     _addProgram           = contentLoader.LoadPixelShader("add.glsl");
     _fboTexComponentCount = fboTexComponentCount;
     _fboTexFloat          = fboTexFloat;
 }
 public AddWithDepthTest(IContentLoader contentLoader)
 {
     _addWithDepthTestProgram = contentLoader.LoadPixelShader("addWithDepthTest.glsl");
 }
Example #15
0
 public AvgBlur(IContentLoader contentLoader, float blurKernelSize = 20, byte fboTexComponentCount = 4, bool fboTexFloat = false)
     : base(contentLoader.LoadPixelShader("BlurAvgPass1.glsl"), contentLoader.LoadPixelShader("BlurAvgPass2.glsl"), fboTexComponentCount, fboTexFloat)
 {
     _blurKernelSize = blurKernelSize;
 }
Example #16
0
 public Lighting(IContentLoader contentLoader)
 {
     _shader = contentLoader.LoadPixelShader("lighting.glsl");
 }