当前位置: 首页>>代码示例>>C#>>正文


C# Camera.RenderToCubemap方法代码示例

本文整理汇总了C#中UnityEngine.Camera.RenderToCubemap方法的典型用法代码示例。如果您正苦于以下问题:C# Camera.RenderToCubemap方法的具体用法?C# Camera.RenderToCubemap怎么用?C# Camera.RenderToCubemap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Camera的用法示例。


在下文中一共展示了Camera.RenderToCubemap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

 // 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);
 }
开发者ID:OSW-team,项目名称:Project-4,代码行数:10,代码来源:RenderToCubeMap.cs

示例2: Make

        public static Cubemap Make(Camera camera)
        {
            Cubemap cmap = new Cubemap(4096, TextureFormat.ARGB32, false);

            if (camera.RenderToCubemap(cmap))
            {

                return cmap;
            }

            return null;
        }
开发者ID:massdriver,项目名称:FreeUniverse,代码行数:12,代码来源:CubemapGenerator.cs

示例3: copy_internal

        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;
        }
开发者ID:elephantatwork,项目名称:Secret-Game,代码行数:32,代码来源:SkyProbe.cs

示例4: convolve_internal

        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;
        }
开发者ID:elephantatwork,项目名称:Secret-Game,代码行数:61,代码来源:SkyProbe.cs


注:本文中的UnityEngine.Camera.RenderToCubemap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。