Esempio n. 1
0
        public static void projectCubeBuffer(ref SHEncoding sh, CubeBuffer cube)
        {
            sh.clearToBlack();
            float totalarea = 0f;
            ulong faceSize = (ulong)cube.faceSize;
            float[] dc = new float[9];
            Vector3 u = Vector3.zero;

            for(ulong face=0; face<6; ++face)
            for(ulong y=0; y<faceSize; ++y)
            for(ulong x=0; x<faceSize; ++x) {
                //compute cube direction
                float areaweight = 1f;
                mset.Util.invCubeLookup(ref u, ref areaweight, face, x, y, faceSize);
                float shscale = 4f / 3f;
                ulong index = face*faceSize*faceSize + y*faceSize + x;
                Color rgba = cube.pixels[index];

                //project on basis functions, and accumulate
                dc[0] = project_l0_m0(u);

                dc[1] = project_l1_mneg1(u);
                dc[2] = project_l1_m0(u);
                dc[3] = project_l1_m1(u);

                dc[4] = project_l2_mneg2(u);
                dc[5] = project_l2_mneg1(u);
                dc[6] = project_l2_m0(u);
                dc[7] = project_l2_m1(u);
                dc[8] = project_l2_m2(u);
                for(int i=0; i<9; ++i ) {
                    sh.c[3*i + 0] += shscale * areaweight * rgba[0] * dc[i];
                    sh.c[3*i + 1] += shscale * areaweight * rgba[1] * dc[i];
                    sh.c[3*i + 2] += shscale * areaweight * rgba[2] * dc[i];
                }
                totalarea += areaweight;
            }

            //complete the integration by dividing by total area
            scale( ref sh, 16f / totalarea );
        }
Esempio n. 2
0
        public CubemapGUI(Type _type, bool _inspector)
        {
            type = _type;
            mipmapped = type == Type.SIM;
            inputPath = "";
            clear();
            inspector = _inspector;
            buffers = new CubeBuffer[4];
            for(int i=0; i<buffers.Length; ++i) {
                buffers[i] = new CubeBuffer();
            }

            if( lightGizmo==null ){
                lightGizmo = Resources.Load("light") as Texture2D;
            }
            if( pickerIcon==null ) {
                if( EditorGUIUtility.isProSkin ) {
                    pickerIcon = Resources.Load("white_picker") as Texture2D;
                } else {
                    pickerIcon = Resources.Load("picker") as Texture2D;
                }
            }
        }
Esempio n. 3
0
        public void OnEnable()
        {
            hideFlags |= HideFlags.HideAndDontSave;

            if (lightGizmo == null) {
                lightGizmo = Resources.Load("light") as Texture2D;
            }

            if (pickerIcon == null) {
                if (EditorGUIUtility.isProSkin) {
                    pickerIcon = Resources.Load("white_picker") as Texture2D;
                }
                else {
                    pickerIcon = Resources.Load("picker") as Texture2D;
                }
            }

            setType(type, inspector);

            if (buffers == null) {
                buffers = new CubeBuffer[4];
                for (int i = 0; i < buffers.Length; ++i) {
                    buffers[i] = new CubeBuffer();
                }
            }
        }
Esempio n. 4
0
 public void init()
 {
     CONVO = new CubeBuffer();
     IN = new CubeBuffer();
 }