Пример #1
0
        //------------------------------------------------------
        // Passes
        //------------------------------------------------------

        public void pass_DeferredShading(Scene scene, fx_Shadow fx_Shadow)
        {
            //------------------------------------------------------
            // Clear Lighting Buffer from last frame
            //------------------------------------------------------
            _fGBuffer.bind(new DrawBuffersEnum[] {
                DrawBuffersEnum.ColorAttachment6,
                DrawBuffersEnum.ColorAttachment7
            });
            GL.Clear(ClearBufferMask.ColorBufferBit);

            //------------------------------------------------------
            // Fill gBuffer with Scene
            //------------------------------------------------------
            pass_Geometry(scene);

            //------------------------------------------------------
            // Accumulate Lighting from Scene
            //------------------------------------------------------
            GL.Enable(EnableCap.StencilTest);
            GL.Enable(EnableCap.Blend);
            GL.BlendEquation(BlendEquationMode.FuncAdd);
            GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.One);
            foreach (Light l in scene.lights)
            {
                switch (l.type)
                {
                case Light.type_spot:
                    pass_Stencil(l);
                    pass_sLight(l, fx_Shadow.tSpot);
                    break;

                case Light.type_point:
                    pass_Stencil(l);
                    pass_pLight(l, fx_Shadow.tPoint);
                    break;
                }
            }


            GL.Disable(EnableCap.StencilTest);
            GL.Disable(EnableCap.Blend);
            GL.Enable(EnableCap.CullFace);
            GL.CullFace(CullFaceMode.Back);
            //GL.Disable(EnableCap.DepthTest);
        }
Пример #2
0
        public void lightInjection(Scene scene, fx_Shadow shadow, SpatialData camera_spatial)
        {
            if (!_enabled)
            {
                return;
            }


            int workgroup_size = 4;
            int texture_size   = (int)_vx_volume_dimensions * 8;

            _tTemp.clear();

            _pInjection.bind();


            GL.Uniform2(_pInjection.getUniform("texture_size"), shadow.tSpot.dimensions.Xy);

            GL.Uniform1(_pInjection.getUniform("vx_volume_dimensions"), _vx_volume_dimensions);
            GL.Uniform1(_pInjection.getUniform("vx_volume_scale"), _vx_volume_scale);
            GL.Uniform3(_pInjection.getUniform("vx_volume_position"), -voxelSnap(camera_spatial.position));

            _tVoxelVolume.bindImageUnit(_pInjection.getSamplerUniform(0), 0, TextureAccess.ReadWrite);
            _tVoxelVolume_Diffuse.bind(_pInjection.getSamplerUniform(1), 1);

            shadow.tSpot.bind(_pInjection.getSamplerUniform(2), 2);
            shadow.tPoint.bind(_pInjection.getSamplerUniform(3), 3);
            shadow.tDirectional.bind(_pInjection.getSamplerUniform(4), 4);

            _tTemp.bindImageUnit(_pInjection.getSamplerUniform(5), 5, TextureAccess.WriteOnly);


            GL.DispatchCompute(((int)shadow.tSpot.dimensions.X / workgroup_size), ((int)shadow.tSpot.dimensions.Y / workgroup_size), 1);

            GL.MemoryBarrier(MemoryBarrierFlags.TextureFetchBarrierBit | MemoryBarrierFlags.ShaderImageAccessBarrierBit);
        }