Beispiel #1
0
        /// <summary>
        /// 球面調和関数を用いて圧縮する(RGBのみ)
        /// </summary>
        /// <param name="coef_list"></param>
        /// <param name="pCube"></param>
        public Vector3[] CompressRGB(SHCalcData pCube)
        {
            //	SH計算
            ComputeSHTable();
            //	立体角計算
            ComputeDeltaFormFactor();

            //	イメージデータを圧縮
            Vector3[] coefList = new Vector3[s_SHCoefNum[m_shBandNum]];
            for (int l = 0; l < s_SHCoefNum[m_shBandNum]; ++l)
            {
                double r = 0.0;
                double g = 0.0;
                double b = 0.0;

                for (uint f = 0; f < (int)CubeMapFace.Max; ++f)
                {
                    Color3[] face_color = pCube.GetCubeColorData(f);
                    for (uint p = 0; p < m_cubeMapSize * m_cubeMapSize; ++p)
                    {
                        double value = ((double)m_pDeltaFormFactorTable[f, p] * (double)m_pCubeSHTable[f, p, l]);
                        r += (double)(face_color[p].Red * value);
                        g += (double)(face_color[p].Green * value);
                        b += (double)(face_color[p].Blue * value);
                    }
                }

                coefList[l].X = (float)(r);
                coefList[l].Y = (float)(g);
                coefList[l].Z = (float)(b);
            }
            return(coefList);
        }
Beispiel #2
0
        /// <summary>
        /// キューブマップからSH係数を取得
        /// </summary>
        static public Vector4[] GetSphericalHarmonics(Texture cubemap, uint band)
        {
            SHCalcData shData   = new SHCalcData(cubemap);
            SHHelper   shHelper = new SHHelper(band, shData.MapSize);

            Vector3[] shCoef  = shHelper.CompressRGB(shData);
            int       coefNum = s_SHCoefNum[band];

            Vector4[] shScalingCoef = new Vector4[coefNum];
            for (uint i = 0; i < coefNum; i++)
            {
                SHHelper.GetSphericalHarmonics(out shScalingCoef[i], ref shCoef[i], i);
            }
            return(shScalingCoef);
        }
Beispiel #3
0
        /// <summary>
        /// 球面調和関数を用いて圧縮する(Rのみ)
        /// </summary>
        /// <param name="coef_list"></param>
        /// <param name="pCube"></param>
        public void CompressR(float[] coef_list, SHCalcData pCube)
        {
            //	SH計算
            ComputeSHTable();
            //	立体角計算
            ComputeDeltaFormFactor();

            //	イメージデータを圧縮
            for (int l = 0; l < s_SHCoefNum[m_shBandNum]; ++l)
            {
                double r = 0.0;
                for (uint f = 0; f < (int)CubeMapFace.Max; ++f)
                {
                    Color3[] face_color = pCube.GetCubeColorData(f);
                    for (uint p = 0; p < m_cubeMapSize * m_cubeMapSize; ++p)
                    {
                        double value = ((double)m_pDeltaFormFactorTable[f, p] * (double)m_pCubeSHTable[f, p, l]);
                        r += ((double)face_color[p].Red * value);
                    }
                }

                coef_list[l] = (float)(r);
            }
        }