Beispiel #1
0
    void updateColor(KVertex vertex, List <Vector3> coefficients)
    {
        var   vertexSH = vertex.getSH();
        float a0       = 3.141593f;
        float a1       = 2.094395f;
        float a2       = 0.785398f;

        Vector3 color =
            a0 * vertexSH[0] * coefficients[0] +
            a1 * vertexSH[1] * coefficients[1] +
            a1 * vertexSH[2] * coefficients[2] +
            a1 * vertexSH[3] * coefficients[3] +
            a2 * vertexSH[4] * coefficients[4] +
            a2 * vertexSH[5] * coefficients[5] +
            a2 * vertexSH[6] * coefficients[6] +
            a2 * vertexSH[7] * coefficients[7] +
            a2 * vertexSH[8] * coefficients[8];

        vertex.setColor(new Color(color.x, color.y, color.z));
    }
Beispiel #2
0
    void updateColor1(KVertex vertex, List <Vector3> coefficients)
    {
        var   vertexSH = vertex.getSH();
        float a0       = 1; //athf.PI;// 1;//3.141593f;
        float a1       = 1; //athf.PI*(2.0f/3); ;//2.094395f;
        float a2       = 1; //Mathf.PI * (1.0f / 4);// 0.785398f;

        Vector3 color =
            a0 * vertexSH[0] * coefficients[0] +
            a1 * vertexSH[1] * coefficients[1] +
            a1 * vertexSH[2] * coefficients[2] +
            a1 * vertexSH[3] * coefficients[3] +
            a2 * vertexSH[4] * coefficients[4] +
            a2 * vertexSH[5] * coefficients[5] +
            a2 * vertexSH[6] * coefficients[6] +
            a2 * vertexSH[7] * coefficients[7] +
            a2 * vertexSH[8] * coefficients[8];

        //color *= 0.5f;
        vertex.setColor(new Color(color.x, color.y, color.z));
    }
Beispiel #3
0
    void updateColor2(KVertex vertex, List <Vector3> coef)
    {
        /*
         *
         * var vertexSH = vertex.getSH();
         * float a0 = 3.141593f;
         * float a1 = 2.094395f;
         * float a2 = 0.785398f;
         *
         * Vector3 color =
         *  a0 * vertexSH[0] * coefficients[0] +
         *  a1 * vertexSH[1] * coefficients[1] +
         *  a1 * vertexSH[2] * coefficients[2] +
         *  a1 * vertexSH[3] * coefficients[3] +
         *  a2 * vertexSH[4] * coefficients[4] +
         *  a2 * vertexSH[5] * coefficients[5] +
         *  a2 * vertexSH[6] * coefficients[6] +
         *  a2 * vertexSH[7] * coefficients[7] +
         *  a2 * vertexSH[8] * coefficients[8];
         * vertex.setColor(new Color(color.x, color.y, color.z));
         * */
        var   vertexSH = vertex.getSH();
        var   N        = vertex.Normal;
        float C1       = 0.429043f;
        float C2       = 0.511665f;
        float C3       = 0.743125f;
        float C4       = 0.886227f;
        float C5       = 0.247708f;

        var L00  = coef[0];
        var L1_1 = coef[1];
        var L10  = coef[2];
        var L11  = coef[3];
        var L2_2 = coef[4];
        var L2_1 = coef[5];
        var L20  = coef[6];
        var L21  = coef[7];
        var L22  = coef[8];

        // constant term, lowest frequency //////
        Vector3 color = C4 * coef[0] +

                        // axis aligned terms ///////////////////
                        2.0f * C2 * coef[1] * N.y +
                        2.0f * C2 * coef[2] * N.z +
                        2.0f * C2 * coef[3] * N.x +

                        // band 2 terms /////////////////////////
                        2.0f * C1 * coef[4] * N.x * N.y +
                        2.0f * C1 * coef[5] * N.y * N.z +
                        C3 * coef[6] * N.z * N.z - C5 * coef[6] +
                        2.0f * C1 * coef[7] * N.x * N.z +
                        C1 * coef[8] * (N.x * N.x - N.y * N.y);

        /*
         * Vector3 irradianceColor =
         *  c1 * L22 * (N.x * N.x - N.y * N.y) +
         *  c3 * L20 * (N.z * N.z) +
         *  c4 * L00 -
         *  c5 * L20 +
         *  2 * c1 * (L2_2 * N.x * N.y + L21 * N.x * N.z + L2_1 * N.y * N.z) +
         *  2 * c2 * (L11 * N.x + L1_1 * N.y + L10 * N.z);
         *
         * */
        vertex.setColor(new Color(color.x, color.y, color.z));
    }