Пример #1
0
        private void pass_pLight(Light l, Texture shadowDepthTexture)
        {
            _fGBuffer.bindAttachements(new DrawBuffersEnum[] {
                DrawBuffersEnum.ColorAttachment6,
                DrawBuffersEnum.ColorAttachment7
            });
            GL.StencilFunc(StencilFunction.Notequal, 0, 0xFF);

            GL.Disable(EnableCap.DepthTest);
            GL.Enable(EnableCap.CullFace);
            GL.CullFace(CullFaceMode.Front);

            _pLighting_POINT.bind();

            // Bind gBuffer Textures
            _tNormal_Depth.bind(_pLighting_POINT.getSamplerUniform(0), 0);
            _tSpecular.bind(_pLighting_POINT.getSamplerUniform(1), 1);
            shadowDepthTexture.bind(_pLighting_POINT.getSamplerUniform(2), 2);

            // Load light uniforms
            GL.Uniform3(_pLighting_POINT.getUniform(RenderHelper.uLightPosition), l.spatial.position);
            GL.Uniform3(_pLighting_POINT.getUniform(RenderHelper.uLightColor), l.color);
            GL.Uniform1(_pLighting_POINT.getUniform(RenderHelper.uLightIntensity), l.intensity);
            GL.Uniform1(_pLighting_POINT.getUniform(RenderHelper.uLightFalloff), l.falloff);

            GL.Uniform1(_pLighting_POINT.getUniform("shadow_id"), l.sid);

            WorldDrawer.drawLightBounds(l, _pLighting_POINT);
        }
Пример #2
0
        //------------------------------------------------------
        // Lighting
        //------------------------------------------------------

        private void pass_Stencil(Light l)
        {
            _fGBuffer.bindAttachements(DrawBuffersEnum.None);

            GL.DepthMask(false);
            GL.Enable(EnableCap.DepthTest);
            GL.Disable(EnableCap.CullFace);

            GL.Clear(ClearBufferMask.StencilBufferBit);

            GL.StencilFunc(StencilFunction.Always, 0, 0);
            GL.StencilOpSeparate(StencilFace.Back, StencilOp.Keep, StencilOp.IncrWrap, StencilOp.Keep);
            GL.StencilOpSeparate(StencilFace.Front, StencilOp.Keep, StencilOp.DecrWrap, StencilOp.Keep);

            _pStencil.bind();
            WorldDrawer.drawLightBounds(l, _pStencil);
        }