Esempio n. 1
0
    private bool CullPoint(Vector2 point)
    {
        _Area0 = APIMath.Cross(point - _Position0, _Position1 - _Position0) / _AreaFull;
        _Area1 = APIMath.Cross(point - _Position1, _Position2 - _Position1) / _AreaFull;
        _Area2 = APIMath.Cross(point - _Position2, _Position0 - _Position2) / _AreaFull;

        return(_Area0 >= 0 && _Area1 >= 0 && _Area2 >= 0);
    }
Esempio n. 2
0
    private bool CullBackface()
    {
        Vector2 edge1 = _Position1 - _Position0;
        Vector2 edge2 = _Position2 - _Position1;

        _AreaFull = APIMath.Cross(edge2, edge1);

        return(_AreaFull > 0);
    }
Esempio n. 3
0
    private void CalculateBounds()
    {
        APIMath.MaxMinFast(_Position0.x, _Position1.x, _Position2.x, ref _XMAXF, ref _XMINF);
        APIMath.MaxMinFast(_Position0.y, _Position1.y, _Position2.y, ref _YMAXF, ref _YMINF);

        _XMAX = (int)(APIContext.viewport.widht * _XMAXF);
        _YMAX = (int)(APIContext.viewport.height * _YMAXF);
        _XMIN = (int)(APIContext.viewport.widht * _XMINF);
        _YMIN = (int)(APIContext.viewport.height * _YMINF);
    }
Esempio n. 4
0
    private bool DepthTest(Vector3 point, int x, int y)
    {
        if (!APIContext.states.depthTest)
        {
            return(true);
        }

        APITextureBuffer depthBuffer = APIContext.frameBufferManager.frameBufferTarget.depthBuffer;
        float            depth       = point.z;

        if (APIMath.Tex2D(depthBuffer, point).r <= depth)
        {
            depthBuffer.SetPixel(x, y, Color.red * depth);

            return(true);
        }

        return(false);
    }
Esempio n. 5
0
    private bool CalculateMipmap()
    {
        if (!Mathf.IsPowerOfTwo(_Width) || !Mathf.IsPowerOfTwo(_Height))
        {
            return(false);
        }

        int dimension = Mathf.Min(_Width, _Height);
        int size      = APIMath.Log2(dimension);

        _Mipmaps[0] = this;
        _Dimension  = dimension;

        for (int i = 1; i < size; i++)
        {
            dimension >>= 1;
            _Mipmaps[i] = new APITextureBuffer(_Mipmaps[i - 1], dimension, dimension);
        }

        return(true);
    }
    public override Color Fragment(VertData i)
    {
        float att = Vector3.Dot(i.normal, new Vector3(0, -1f, 0));

        return(att * APIMath.Tex2D(mainTexture, i.uv));
    }