RenderToCubemap() private méthode

private RenderToCubemap ( Cubemap cubemap ) : bool
cubemap Cubemap
Résultat bool
 // Use this for initialization
 void Start()
 {
     cam = GetComponent<Camera>();
     var rtex = new RenderTexture(cubemapSize, cubemapSize, 16);
     rtex.isCubemap = true;
     rtex.hideFlags = HideFlags.HideAndDontSave;
     mat.SetTexture("_Cube", rtex);
     cam.RenderToCubemap(rtex, 0);
 }
 static public int RenderToCubemap(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 2, typeof(UnityEngine.RenderTexture)))
         {
             UnityEngine.Camera        self = (UnityEngine.Camera)checkSelf(l);
             UnityEngine.RenderTexture a1;
             checkType(l, 2, out a1);
             var ret = self.RenderToCubemap(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (matchType(l, argc, 2, typeof(UnityEngine.Cubemap)))
         {
             UnityEngine.Camera  self = (UnityEngine.Camera)checkSelf(l);
             UnityEngine.Cubemap a1;
             checkType(l, 2, out a1);
             var ret = self.RenderToCubemap(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (matchType(l, argc, 2, typeof(UnityEngine.RenderTexture), typeof(int)))
         {
             UnityEngine.Camera        self = (UnityEngine.Camera)checkSelf(l);
             UnityEngine.RenderTexture a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             var ret = self.RenderToCubemap(a1, a2);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (matchType(l, argc, 2, typeof(UnityEngine.Cubemap), typeof(int)))
         {
             UnityEngine.Camera  self = (UnityEngine.Camera)checkSelf(l);
             UnityEngine.Cubemap a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             var ret = self.RenderToCubemap(a1, a2);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #3
0
        private UnityEngine.Cubemap renderSky()
        {
            UnityEngine.Cubemap cubemap = new UnityEngine.Cubemap(1024, TextureFormat.ARGB32, false);
            cubemap.name = "Sky";
            GameObject go = new GameObject("CubemapCamera");

            UnityEngine.Camera camera = go.AddComponent <UnityEngine.Camera>();
            camera.cullingMask = 0;
            camera.RenderToCubemap(cubemap);
            GameObject.DestroyImmediate(go);
            return(cubemap);
        }
        public static Cubemap Make(Camera camera)
        {
            Cubemap cmap = new Cubemap(4096, TextureFormat.ARGB32, false);

            if (camera.RenderToCubemap(cmap))
            {

                return cmap;
            }

            return null;
        }
 static public int RenderToCubemap(IntPtr l)
 {
     try{
         if (matchType(l, 2, typeof(UnityEngine.Cubemap)))
         {
             UnityEngine.Camera  self = (UnityEngine.Camera)checkSelf(l);
             UnityEngine.Cubemap a1;
             checkType(l, 2, out a1);
             System.Boolean ret = self.RenderToCubemap(a1);
             pushValue(l, ret);
             return(1);
         }
         else if (matchType(l, 2, typeof(UnityEngine.Cubemap), typeof(System.Int32)))
         {
             UnityEngine.Camera  self = (UnityEngine.Camera)checkSelf(l);
             UnityEngine.Cubemap a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             System.Boolean ret = self.RenderToCubemap(a1, a2);
             pushValue(l, ret);
             return(1);
         }
         else if (matchType(l, 2, typeof(UnityEngine.RenderTexture)))
         {
             UnityEngine.Camera        self = (UnityEngine.Camera)checkSelf(l);
             UnityEngine.RenderTexture a1;
             checkType(l, 2, out a1);
             System.Boolean ret = self.RenderToCubemap(a1);
             pushValue(l, ret);
             return(1);
         }
         else if (matchType(l, 2, typeof(UnityEngine.RenderTexture), typeof(System.Int32)))
         {
             UnityEngine.Camera        self = (UnityEngine.Camera)checkSelf(l);
             UnityEngine.RenderTexture a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             System.Boolean ret = self.RenderToCubemap(a1, a2);
             pushValue(l, ret);
             return(1);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
        private void copy_internal(Texture dstCube, Texture srcCube, bool dstRGBM, bool srcRGBM, bool linear, Camera cam, Material skyMat, Matrix4x4 matrix)
        {
            bool prevHDR = cam.hdr;
            CameraClearFlags prevFlags = cam.clearFlags;
            int prevMask = cam.cullingMask;
            cam.clearFlags = CameraClearFlags.Skybox;
            cam.cullingMask = 0;
            cam.hdr = !dstRGBM; // might need HDR camera buffer when we're not rendering to RGBM encoded pixels

            skyMat.name = "Internal HDR to RGBM Skybox";
            skyMat.shader = Shader.Find("Hidden/Marmoset/RGBM Cube");

            //toggleKeywordPair("MARMO_LINEAR", "MARMO_GAMMA", linear);
            toggleKeywordPair("MARMO_RGBM_INPUT_ON", "MARMO_RGBM_INPUT_OFF", srcRGBM);
            toggleKeywordPair("MARMO_RGBM_OUTPUT_ON", "MARMO_RGBM_OUTPUT_OFF", dstRGBM);

            skyMat.SetMatrix("_SkyMatrix", matrix);
            skyMat.SetTexture("_CubeHDR", srcCube);

            Material prevSkyMat = UnityEngine.RenderSettings.skybox;
            UnityEngine.RenderSettings.skybox = skyMat;

            RenderTexture RT = dstCube as RenderTexture;
            Cubemap cube = dstCube as Cubemap;
            if(RT)  		cam.RenderToCubemap(RT);
            else if(cube)	cam.RenderToCubemap(cube);

            cam.hdr = prevHDR;
            cam.clearFlags = prevFlags;
            cam.cullingMask = prevMask;
            UnityEngine.RenderSettings.skybox = prevSkyMat;
        }
        private void convolve_internal(Texture dstTex, Texture srcCube, bool dstRGBM, bool srcRGBM, bool linear, Camera cam, Material skyMat, Matrix4x4 matrix)
        {
            bool prevHDR = cam.hdr;
            CameraClearFlags prevFlags = cam.clearFlags;
            int prevMask = cam.cullingMask;
            cam.clearFlags = CameraClearFlags.Skybox;
            cam.cullingMask = 0;
            cam.hdr = !dstRGBM; // might need HDR camera buffer when we're not rendering to RGBM encoded pixels

            skyMat.name = "Internal Convolve Skybox";
            skyMat.shader = Shader.Find("Hidden/Marmoset/RGBM Convolve");

            //toggleKeywordPair("MARMO_LINEAR", "MARMO_GAMMA", linear);
            toggleKeywordPair("MARMO_RGBM_INPUT_ON", "MARMO_RGBM_INPUT_OFF", srcRGBM);
            toggleKeywordPair("MARMO_RGBM_OUTPUT_ON", "MARMO_RGBM_OUTPUT_OFF", dstRGBM);

            skyMat.SetMatrix("_SkyMatrix", matrix);
            skyMat.SetTexture("_CubeHDR", srcCube);
            bindRandomValueTable(skyMat,"_PhongRands", srcCube.width);

            Material prevSkyMat = UnityEngine.RenderSettings.skybox;
            UnityEngine.RenderSettings.skybox = skyMat;

            Cubemap dstCube = dstTex as Cubemap;
            RenderTexture dstRT = dstTex as RenderTexture;

            if( dstCube ) {
                if( generateMipChain ) {
                    int mipCount = mset.QPow.Log2i(dstCube.width) - 1;
                    int mip = highestMipIsMirror ? 1 : 0;
                    for( ; mip<mipCount; ++mip ) {
                        int mipSize = 1 << (mipCount-mip);
                        float mipExp = mset.QPow.clampedDownShift(this.maxExponent, highestMipIsMirror ? (mip-1) : mip, 1);
                        skyMat.SetFloat("_SpecularExp", mipExp);
                        skyMat.SetFloat ("_SpecularScale", this.convolutionScale);
                        Cubemap mipCube = new Cubemap(mipSize, dstCube.format, false);
                        cam.RenderToCubemap(mipCube);

                        for(int f=0; f<6; ++f) {
                            CubemapFace face = (CubemapFace)f;
                            dstCube.SetPixels(mipCube.GetPixels(face), face, mip);
                        }
                        Cubemap.DestroyImmediate(mipCube);
                    }
                    dstCube.Apply(false);
                } else {
                    skyMat.SetFloat("_SpecularExp", this.maxExponent);
                    skyMat.SetFloat ("_SpecularScale", this.convolutionScale);
                    cam.RenderToCubemap(dstCube);
                }
            } else if(dstRT) {
                skyMat.SetFloat("_SpecularExp", this.maxExponent);
                skyMat.SetFloat ("_SpecularScale", this.convolutionScale);
                cam.RenderToCubemap(dstRT);
            }

            cam.clearFlags = prevFlags;
            cam.cullingMask = prevMask;
            cam.hdr = prevHDR;
            UnityEngine.RenderSettings.skybox = prevSkyMat;
        }