Пример #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
    // lets make the bounds of the cloud -1M to +1M in x and y
    // Start is called before the first frame update
    void Start()
    {
        drawer = GetComponent <WorldDrawer>();
        Vector2Int[] cloud = new Vector2Int[cloudSize];
        for (int i = 0; i < cloudSize; i++)
        {
            cloud[i] = new Vector2Int(UnityEngine.Random.Range(-cloudScale, cloudScale), UnityEngine.Random.Range(-cloudScale, cloudScale));
        }

        Array.Sort(cloud, Vector2IntComparer); //ascending or descending?
        List <Vector2Int> hull = ComputeHull(cloud);

        Vector2[] floatCloud = new Vector2[cloudSize];
        //foreach(Vector2Int p in cloud)
        //  drawer.DrawPoint( (float)p.x/cloudScale,(float)p.y/cloudScale,Color.blue);
        for (int i = 0; i < cloudSize; i++)
        {
            floatCloud[i] = (Vector2)(cloud[i]);
        }
        drawer.DrawPoints(floatCloud, Color.blue);
        foreach (Vector2Int v in hull)
        {
            drawer.ColorPoint((float)(v.x) / cloudScale, (float)(v.y) / cloudScale, Color.red);
        }
    }
Пример #3
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);
        }
Пример #4
0
 public void renderLightObjects(BeginMode begin_mode, Program program)
 {
     WorldDrawer.drawLights(begin_mode, lights, program, Matrix4.Identity, _current_animation_time, false);
 }
Пример #5
0
 public void renderMeshes_Basic(BeginMode begin_mode, Program program)
 {
     WorldDrawer.drawMeshes(begin_mode, _meshes, program, Matrix4.Identity, _current_animation_time, 0);
 }