Exemplo n.º 1
0
        internal void drawShadowBuffers(Framebuffer shadowFb)
        {
            shadowFb.enable(false);

            for (int i = 0; i < spotlights.Count; i++)
            {
                spotlights[i].lightId = i;

                bool needsUpdate = spotlights[i].viewInfo.checkForUpdates(drawables);
                currentLight = i;

                if (needsUpdate)
                {
                    Console.WriteLine(i + " -> updating Shadowbuffer");

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

                    GL.DepthFunc(DepthFunction.Always);
                    mFilter2d.draw(ShaderTypes.wipingShader, new int[] { spotlights[i].ProjectionTexture }, Shader.Uniform.in_vector, new Vector2(i, lightCount));
                    GL.DepthFunc(DepthFunction.Less);

                    GL.ColorMask(false, false, false, true);
                    drawSceene(Pass.shadow, spotlights[i].viewInfo);
                    GL.ColorMask(true, true, true, true);
                }
            }

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

            //"disable" writing to certain uv space
            int tmpLightCount = lightCount;
            lightCount = 1;
            currentLight = 0;

            if (sunLight.viewInfo.wasUpdated)
            {
                //generating wide range sun shadows
                sunFrameBuffer.enable(true);

                GL.ColorMask(false, false, false, false);
                drawSceene(Pass.shadow, sunLight.viewInfo);
                GL.ColorMask(true, true, true, true);
            }

            //generating short range sun shadows
            sunInnerFrameBuffer.enable(true);

            GL.ColorMask(false, false, false, false);
            drawSceene(Pass.shadow, sunLight.innerViewInfo);
            GL.ColorMask(true, true, true, true);

            //clean up
            lightCount = tmpLightCount;
        }
Exemplo n.º 2
0
        internal void drawShadowBuffers(Framebuffer shadowFb)
        {
            shadowFb.enable(false);

            for (int i = 0; i < spotlights.Count; i++)
            {
                spotlights[i].lightId = i;

                bool needsUpdate = spotlights[i].viewInfo.checkForUpdates(drawables);
                currentLight = i;

                if (needsUpdate)
                {
                    Console.WriteLine(i + " -> updating Shadowbuffer");

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

                    GL.DepthFunc(DepthFunction.Always);
                    mFilter2d.draw(ShaderTypes.wipingShader, new int[] { spotlights[i].ProjectionTexture }, Shader.Uniform.in_vector, new Vector2(i, lightCount));
                    GL.DepthFunc(DepthFunction.Less);

                    GL.ColorMask(false, false, false, true);
                    drawSceene(Pass.shadow, spotlights[i].viewInfo);
                    GL.ColorMask(true, true, true, true);
                }
            }

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

            //"disable" writing to certain uv space
            int tmpLightCount = lightCount;

            lightCount   = 1;
            currentLight = 0;

            if (sunLight.viewInfo.wasUpdated)
            {
                //generating wide range sun shadows
                sunFrameBuffer.enable(true);

                GL.ColorMask(false, false, false, false);
                drawSceene(Pass.shadow, sunLight.viewInfo);
                GL.ColorMask(true, true, true, true);
            }


            //generating short range sun shadows
            sunInnerFrameBuffer.enable(true);

            GL.ColorMask(false, false, false, false);
            drawSceene(Pass.shadow, sunLight.innerViewInfo);
            GL.ColorMask(true, true, true, true);


            //clean up
            lightCount = tmpLightCount;
        }