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


C# UnityEngine.Cubemap类代码示例

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


Cubemap类属于UnityEngine命名空间,在下文中一共展示了Cubemap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: capture

 public void capture(ref Cubemap targetCube, Transform at, bool HDR)
 {
     if( targetCube == null ) return;
     GameObject go = new GameObject("_temp_probe");
     go.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideAndDontSave;
     go.SetActive(true);
     Camera cam = go.AddComponent<Camera>();
     if( at != null ) {
         go.transform.position = at.position;
     }
     if(HDR) {
         Shader.EnableKeyword("MARMO_RGBM");
         Shader.DisableKeyword("MARMO_RGBA");
         Shader.SetGlobalFloat("_GlowStrength", 0f);
         Shader.SetGlobalFloat("_EmissionLM", 0f);
         cam.SetReplacementShader(Shader.Find("Hidden/Marmoset/RGBM Replacement"),"RenderType");
     }
     cam.RenderToCubemap(targetCube);
     targetCube.Apply(false);
     if(HDR) {
         cam.ResetReplacementShader();
         Shader.DisableKeyword("MARMO_RGBM");
         Shader.EnableKeyword("MARMO_RGBA");
     }
     GameObject.DestroyImmediate(go);
 }
开发者ID:randydijkstra,项目名称:Oculus-Reality,代码行数:26,代码来源:SkyProbe.cs

示例2: DirectionalCubemap

    public static void DirectionalCubemap()
    {
        int faceSize = 8;
        Cubemap cube = new Cubemap(faceSize, TextureFormat.RGB24, false);

        // For each side
        foreach (CubemapFace face in System.Enum.GetValues(typeof(CubemapFace))) {
            Color[] pixels = new Color[faceSize * faceSize];
            for (int x = 0; x < faceSize; ++x)
                for (int y = 0; y < faceSize; ++y) {

                    int index = x + y * faceSize;
                    Vector3 dir = Utils.Cubemap.CubemapDirection(face,
                                                                 (x+0.5f) / (float)faceSize - 0.5f,
                                                                 (y+0.5f) / (float)faceSize - 0.5f);

                    pixels[index] = new Color(dir.x, dir.y, dir.z);
                }

            cube.SetPixels(pixels, face);
            cube.Apply();
        }

        AssetDatabase.CreateAsset(cube, "Assets/BiasedPhysics/DirectionalCubemap.cubemap");
        Debug.Log("Generated /BiasedPhysics/DirectionalCubemap.cubemap");
    }
开发者ID:shadercoder,项目名称:Unity3D-experiments,代码行数:26,代码来源:TextureConverter.cs

示例3: CreateSubMips

		public static void CreateSubMips(Cubemap cube) {
			AssetDatabase.StartAssetEditing();
			int faceSize = cube.width;
			string cubePath = AssetDatabase.GetAssetPath(cube);

			//load all sub-assets
			UnityEngine.Object[] mips = AssetDatabase.LoadAllAssetRepresentationsAtPath(cubePath);
			if(mips != null) {
				for(int i=0; i<mips.Length; ++i) {
					if( mips[i] != null && AssetDatabase.IsSubAsset(mips[i]) ) UnityEngine.Object.DestroyImmediate(mips[i], true);
				}
			}
			AssetDatabase.Refresh();

			// skip mip level 0, its in the cubemap itself
			faceSize = faceSize >> 1;
			for( int mip = 1; faceSize > 0; ++mip ) {
				// extract mipmap faces from a cubemap and add them as textures in the sub image
				Texture2D tex = new Texture2D(faceSize, faceSize*6,TextureFormat.ARGB32,false);
				tex.name = "mip"+mip;
				for( int face = 0; face<6; ++face ) {
					tex.SetPixels(0, face*faceSize, faceSize, faceSize, cube.GetPixels((CubemapFace)face,mip));
				}
				tex.Apply();
				AssetDatabase.AddObjectToAsset(tex, cubePath);
				AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(tex));
				faceSize = faceSize >> 1;
			}
			AssetDatabase.StopAssetEditing();
			AssetDatabase.Refresh();
		}
开发者ID:keyward,项目名称:EnemyOfMyEnemy,代码行数:31,代码来源:CubeMipProcessor.cs

示例4: UpdateCubemap

    public void UpdateCubemap(int faceMask = 63)
    {
        //if (!camera)
        //{
        //    //var go = new GameObject("CubemapCamera", typeof(Camera));
        //    //go.hideFlags = HideFlags.HideAndDontSave;
        //    //go.transform.position = transform.position;
        //    //go.transform.rotation = Quaternion.identity;
        //    //camera = go.camera;
        //    //cam.cullingMask = 1 << Layer.level;
        //    //cam.farClipPlane = 1000; // don't render very far into cubemap
        //    camera.enabled = false;
        //}

        if (!cubemap)
        {
            
            cubemap = new Cubemap(512, TextureFormat.RGB24, false);
#if UNITY_EDITOR
            UnityEditor.AssetDatabase.CreateAsset(cubemap, "Assets/cubemap.cubemap");
#endif
            //rtex.isCubemap = true;
            //rtex.hideFlags = HideFlags.HideAndDontSave;
            //renderer.sharedMaterial.SetTexture("_Cube", rtex);
        }

        //cam.transform.position = transform.position+Vector3.up*40;//Camera.main.transform.position;
        camera.RenderToCubemap(cubemap);
    }
开发者ID:friuns,项目名称:New-Unity-Project-tm2---Copy,代码行数:29,代码来源:CreateCubemap.cs

示例5: CopyTextureCube

        private void CopyTextureCube(string texturePath, Cubemap cubemap, BabylonTexture babylonTexture)
        {
            if (!babylonScene.AddTextureCube(texturePath))
            {
                return;
            }

            try
            {
                foreach (CubemapFace face in Enum.GetValues(typeof(CubemapFace)))
                {
                    var faceTexturePath = Path.Combine(babylonScene.OutputPath, Path.GetFileNameWithoutExtension(texturePath));

                    switch (face)
                    {
                        case CubemapFace.PositiveX:
                            faceTexturePath += "_px.jpg";
                            break;
                        case CubemapFace.NegativeX:
                            faceTexturePath += "_nx.jpg";
                            break;
                        case CubemapFace.PositiveY:
                            faceTexturePath += "_py.jpg";
                            break;
                        case CubemapFace.NegativeY:
                            faceTexturePath += "_ny.jpg";
                            break;
                        case CubemapFace.PositiveZ:
                            faceTexturePath += "_pz.jpg";
                            break;
                        case CubemapFace.NegativeZ:
                            faceTexturePath += "_nz.jpg";
                            break;
                        default:
                            continue;
                    }

                    var tempTexture = new Texture2D(cubemap.width, cubemap.height, TextureFormat.RGB24, false);

                    tempTexture.SetPixels(cubemap.GetPixels(face));
                    tempTexture.Apply();

                    // Flip faces in cube texture.
                    tempTexture = FlipTexture(tempTexture);

                    File.WriteAllBytes(faceTexturePath, tempTexture.EncodeToJPG());
                }

            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            var textureName = Path.GetFileNameWithoutExtension(texturePath);
            babylonTexture.name = textureName;
            babylonTexture.isCube = true;
            babylonTexture.level = exportationOptions.ReflectionDefaultLevel;
            babylonTexture.coordinatesMode = 3;
        }
开发者ID:CreateAppAdmin,项目名称:Babylon.js,代码行数:60,代码来源:SceneBuilder.Materials.cs

示例6: Initialize

        public void Initialize(float landMinHeight, float landMaxHeight, float oceanHeight, Cubemap landHeightmap)
        {
            Material mat = renderer.sharedMaterial;
            mat.SetVector("_MinMaxHeight_OceanHeight", new Vector4(landMinHeight, landMaxHeight, oceanHeight, 0.0f));

            //mat.SetTexture("_LandCube", planet.renderer.sharedMaterial.GetTexture("_LandCube"));
            mat.SetTexture("_LandCube", landHeightmap);
        }
开发者ID:shadercoder,项目名称:Unity3D-experiments,代码行数:8,代码来源:Ocean.cs

示例7: Awake

	void Awake () 
	{
		material = GetComponent<Renderer>().material;
		cubemap = (Cubemap)material.GetTexture("_Cube");
		rendererArray = GetComponentsInChildren<Renderer>();
		rotation = material.GetFloat("_Rotation");
		bookArray = GetComponentsInChildren<Book>();
	}
开发者ID:leon196,项目名称:MystJamGame,代码行数:8,代码来源:World.cs

示例8: ExtractSkybox

    public static void ExtractSkybox()
    {
        RenderSettings.skybox = null;

        // get the camera reference.
        Camera cameraObj = GameObject.Find ("AGF_CameraManager").GetComponent<AGF_CameraManager>().GetMainCamera();
        AGF_AtmosphereManager atmosphereManager = GameObject.Find ("AGF_AtmosphereManager").GetComponent<AGF_AtmosphereManager>();

        if(cameraObj.GetComponent<Skybox>().material.GetTexture("_Tex") == null)
            return;

        // step 1: create the target directory, if necessary.
        string targetDirectory = Main.TrimEndFromString( Application.dataPath, "Assets" ) + sourceFolder + "/" + sceneFolder + "/Skyboxes";
        if ( Directory.Exists( targetDirectory ) == false ){
            Directory.CreateDirectory( targetDirectory );
        }

        // step 2: clear the old files, if they exist.
        if ( File.Exists( targetDirectory + "/skyboxCubemap.cubemap" ) ){
            AssetDatabase.DeleteAsset( sourceFolder + "/skyboxCubemap.cubemap" );
        }
        if ( File.Exists( targetDirectory + "/skyboxMaterial.mat" ) ){
            AssetDatabase.DeleteAsset( sourceFolder + "/skyboxMaterial.mat" );
        }

        // step 3: copy over the cubemap from the camera.
        Cubemap cubemapReference = (Cubemap)cameraObj.GetComponent<Skybox>().material.GetTexture("_Tex");
        Cubemap skyboxCubemap = new Cubemap(cubemapReference.width, TextureFormat.RGB24, false);

        EditorUtility.CopySerialized( cubemapReference, skyboxCubemap );

        // step 4: create the cubemap asset.
        AssetDatabase.CreateAsset( skyboxCubemap, sourceFolder + "/" + sceneFolder + "/Skyboxes/skyboxCubemap.cubemap" );
        //		AssetDatabase.ImportAsset( sourceFolder + "/" + sceneFolder + "/Skyboxes/skyboxCubemap.cubemap" );

        // step 5: Create a temporary material, and link it up to the cubemap.
        Material skyboxMaterial = new Material( cameraObj.GetComponent<Skybox>().material );
        skyboxMaterial.SetTexture( "_Tex", (Cubemap)AssetDatabase.LoadAssetAtPath(sourceFolder + "/" + sceneFolder + "/Skyboxes/skyboxCubemap.cubemap", typeof(Cubemap) ) );

        // step 6: create the material asset.
        AssetDatabase.CreateAsset( skyboxMaterial, sourceFolder + "/" + sceneFolder + "/Skyboxes/skyboxMaterial.mat" );
        //		AssetDatabase.ImportAsset( sourceFolder + "/" + sceneFolder + "/Skyboxes/skyboxMaterial.mat" );

        // Now that both the cubemap and material have been created, assign the material into the camera.
        cameraObj.GetComponent<Skybox>().material = (Material)AssetDatabase.LoadAssetAtPath( sourceFolder + "/" + sceneFolder + "/Skyboxes/skyboxMaterial.mat", typeof(Material) );

        // In addition, we need to add another camera script to control the skybox rotation, etc.
        if ( cameraObj.GetComponent<AGF_SkyboxRotator>() == null ){
            cameraObj.gameObject.AddComponent<AGF_SkyboxRotator>();
        }
        cameraObj.gameObject.GetComponent<AGF_SkyboxRotator>().autoRotate = atmosphereManager.GetCurrentSkybox().autoRotate;
        cameraObj.gameObject.GetComponent<AGF_SkyboxRotator>().autoRotationSpeed = atmosphereManager.GetCurrentSkybox().autoRotationSpeed;
        cameraObj.gameObject.GetComponent<AGF_SkyboxRotator>().rotation = atmosphereManager.GetCurrentSkybox().rotation;
        cameraObj.gameObject.GetComponent<AGF_SkyboxRotator>().tint = atmosphereManager.GetCurrentSkybox().tint;

        EditorUtility.SetDirty( cameraObj.gameObject );
    }
开发者ID:NikMifsud,项目名称:GreatSiege,代码行数:57,代码来源:AGF_AssetBundleResourceExtractor.cs

示例9: InitializeMaterial

        public void InitializeMaterial(int size, float minHeight, float maxHeight, float sandPercentage)
        {
            Material mat = renderer.sharedMaterial;

            Heightmap = mat.GetTexture("_LandCube") as Cubemap;

            mat.SetFloat("_InvLandDetail", 1.0f / size);
            mat.SetVector("_MinMaxHeight_SandPercentage", new Vector4(minHeight, maxHeight, sandPercentage, 0.0f));
        }
开发者ID:shadercoder,项目名称:Unity3D-experiments,代码行数:9,代码来源:Land.cs

示例10: Update

 void Update() 
 {
     m_CurrMaterial = renderer.sharedMaterial;
     if (m_CurrMaterial) 
     {
         m_MapCurr = CheckDistance();
         m_CurrMaterial.SetTexture("_Cubemap", m_MapCurr);
     }
 }
开发者ID:Shahdee,项目名称:shaders,代码行数:9,代码来源:FresnelSystem.cs

示例11: BuildSurfaceMesh

        public static void BuildSurfaceMesh(ref MeshPlane mesh, ref Random rand)
        {
            var brush = Resources.Load("PlanetBuilding/SurfaceBrush");

            if (brush == null)
            {
                Debug.LogError("Unable to load basic brush prefab");
                return;
            }

            var rampTex = Resources.Load("Textures/PlanetRamp") as Texture;

            if (rampTex == null)
            {
                Debug.LogError("Unable to load planet colour ramp");
                return;
            }

            // Apply brush texture somehow
            // * 0.1f
            float brushBaseSize = 1.0f;
            float brushSizeLarge = brushBaseSize * 0.2f;
            float brushSizeSmall = brushBaseSize * 0.02f;

            for (int i = 0; i < rand.Next(25, 75); ++i)
            {
                var go = (GameObject.Instantiate(brush) as GameObject);

                var ch = go.transform.GetChild(0);
                var brushScale = (float)(brushSizeSmall + (rand.NextDouble() * brushSizeLarge));
                ch.localScale = new Vector3(brushScale, brushScale, brushScale);

                go.transform.SetParent(mesh.transform);
                go.transform.Rotate(
                    (float)rand.NextDouble() * 360.0f,
                    (float)rand.NextDouble() * 360.0f,
                    (float)rand.NextDouble() * 360.0f
                    );
            }

            var localCam = mesh.gameObject.AddComponent<Camera>();
            localCam.cullingMask = PlanetBrushLayer;
            localCam.fieldOfView = 90;
            localCam.backgroundColor = Color.black;

            Cubemap c = new Cubemap(2048, TextureFormat.ARGB32, false);
            localCam.RenderToCubemap(c);

            mesh.GetComponent<Renderer>().material.SetTexture("_Tex", c);
            mesh.GetComponent<Renderer>().material.SetTexture("_PlanetRamp", rampTex);

            Component.Destroy(localCam);
             			foreach ( Transform ch in mesh.transform ){
             				GameObject.Destroy(ch.gameObject);
             			}
        }
开发者ID:finlaybob,项目名称:odyssey2,代码行数:56,代码来源:PlanetFactory.cs

示例12: CancelSelection

 public void CancelSelection()
 {
     this.m_SelectedCubemap = null;
     this.m_SelectedCubemapInfo = null;
     this.m_SelectedShadowCubemapOwnerInfo = null;
     this.m_SelectedLightIconIndex = -1;
     this.m_SelectedShadowInfo = null;
     this.m_HoveringCubeMapIndex = -1;
     this.m_DragBeingPerformed = false;
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:10,代码来源:LookDevEnvironmentWindow.cs

示例13: 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

示例14: Initialize

 public static void Initialize()
 {
     m_ZeroAmbientProbe.Clear();
     if (m_SkyboxMaterial == null)
     {
         m_SkyboxMaterial = new Material(Shader.Find("Skybox/Cubemap"));
     }
     if (m_ScreenQuadMesh == null)
     {
         m_ScreenQuadMesh = new Mesh();
         m_ScreenQuadMesh.vertices = new Vector3[] { new Vector3(-1f, -1f, 0f), new Vector3(1f, 1f, 0f), new Vector3(1f, -1f, 0f), new Vector3(-1f, 1f, 0f) };
         m_ScreenQuadMesh.triangles = new int[] { 0, 1, 2, 1, 0, 3 };
     }
     if (m_GBufferPatchMaterial == null)
     {
         m_GBufferPatchMaterial = new Material(EditorGUIUtility.LoadRequired("LookDevView/GBufferWhitePatch.shader") as Shader);
         m_DrawBallsMaterial = new Material(EditorGUIUtility.LoadRequired("LookDevView/GBufferBalls.shader") as Shader);
     }
     if (m_LookDevCompositing == null)
     {
         m_LookDevCompositing = new Material(EditorGUIUtility.LoadRequired("LookDevView/LookDevCompositing.shader") as Shader);
     }
     if (m_DeferredOverlayMaterial == null)
     {
         m_DeferredOverlayMaterial = EditorGUIUtility.LoadRequired("SceneView/SceneViewDeferredMaterial.mat") as Material;
     }
     if (m_DefaultHDRI == null)
     {
         m_DefaultHDRI = EditorGUIUtility.Load("LookDevView/DefaultHDRI.exr") as Cubemap;
         if (m_DefaultHDRI == null)
         {
             m_DefaultHDRI = EditorGUIUtility.Load("LookDevView/DefaultHDRI.asset") as Cubemap;
         }
     }
     if (m_LookDevCubeToLatlong == null)
     {
         m_LookDevCubeToLatlong = new Material(EditorGUIUtility.LoadRequired("LookDevView/LookDevCubeToLatlong.shader") as Shader);
     }
     if (m_SelectionTexture == null)
     {
         m_SelectionTexture = new RenderTexture(250, 0x7d, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
     }
     if (m_BrightestPointRT == null)
     {
         m_BrightestPointRT = new RenderTexture(250, 0x7d, 0, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Default);
     }
     if (m_BrightestPointTexture == null)
     {
         m_BrightestPointTexture = new Texture2D(250, 0x7d, TextureFormat.RGBAHalf, false);
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:51,代码来源:LookDevResources.cs

示例15: Draw

        public override void Draw()
        {
            GUILayout.BeginVertical();
            GUILayout.Label( "Default:" );
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            _defaultTexture = (DefaultTextureType)EditorGUILayout.EnumPopup( _defaultTexture );
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            previewTexture = (Cubemap)EditorGUILayout.ObjectField( previewTexture, typeof(Cubemap), new[] { GUILayout.Width (60), GUILayout.Height (60) });
            GUILayout.EndVertical();
        }
开发者ID:Sacristan,项目名称:shaderschool,代码行数:14,代码来源:TextureCubeProperty.cs


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