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


C# Cubemap.Apply方法代码示例

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


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

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

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

示例3: createPlaceHolderCube

 void createPlaceHolderCube()
 {
     if( PlaceHolderCube == null ) {
         PlaceHolderCube = new Cubemap(16,TextureFormat.ARGB32,true);
         for(int face = 0; face < 6; face++) {
             for(int x = 0; x < 16; x++) {
                 for(int y = 0; y < 16; y++) {
                     PlaceHolderCube.SetPixel((CubemapFace)face, x, y, Color.black);
                 }
             }
         }
         PlaceHolderCube.Apply(true);
     }
 }
开发者ID:KieranChandler,项目名称:BritishPoliceSimulator,代码行数:14,代码来源:SetupLux.cs

示例4: capture

        public void capture(ref Cubemap targetCube, Transform at)
        {
            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;
            }

            cam.RenderToCubemap(targetCube);
            targetCube.Apply(false);

            GameObject.DestroyImmediate(go);
        }
开发者ID:damard,项目名称:Unity,代码行数:16,代码来源:SkyProbe.cs

示例5: Create

        void Create()
        {
            try {
            string planetFolder = Application.dataPath + "/Worlds/Planets/" + worldName;
            System.IO.Directory.CreateDirectory(planetFolder);

            NoiseVector[] noiseVectors = CreateNoiseVectors(noiseLayers);

            Cubemap clouds = new Cubemap(detail, TextureFormat.RGBA32, false); // false for now as unity doesn't have seamless cubemaps $)%ˆ#)!_#

            foreach (CubemapFace face in System.Enum.GetValues(typeof(CubemapFace))) {
                EditorUtility.DisplayProgressBar("Latlong to cubemap", "Processing " + face, (float) face / 6.0f);
                Color[] pixels = new Color[detail * detail];
                for (int x = 0; x < detail; ++x)
                    for (int y = 0; y < detail; ++y) {
                        Vector3 dir = Utils.Cubemap.CubemapDirection(face,
                                                                     (x+0.5f) / (float)detail - 0.5f,
                                                                     (y+0.5f) / (float)detail - 0.5f);

                        float intensity = 0.0f;
                        foreach (NoiseVector vec in noiseVectors) {
                            float distance = (dir - vec.Normal).magnitude;
                            float v = Mathf.Max(0.0f, 1.0f - distance / vec.Radius);
                            intensity += v * vec.Amplitude;
                        }

                        int index = x + y * detail;
                        pixels[index] = new Color(intensity, intensity, intensity, intensity);
                    }

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

            clouds.SmoothEdges(); // Because unity doesn't support seamless filtering, but is it enough?

            string saveFolder = "Assets/Worlds/Planets/" + worldName + "/";
            string savePath = saveFolder + "clouds.cubemap";
            AssetDatabase.CreateAsset(clouds, savePath);

            } catch (System.Exception e) {
            Debug.LogError("Creation of clouds failed:\n" + e);
            }

            EditorUtility.ClearProgressBar();
        }
开发者ID:shadercoder,项目名称:Unity3D-experiments,代码行数:46,代码来源:CloudCreator.cs

示例6: Awake

        void Awake()
        {
            fogEffect = FindObjectOfType<FogEffect>();
            renderProperties = FindObjectOfType<RenderProperties>();

            var tmp = new Texture2D(4096, 4096);
            tmp.LoadImage(File.ReadAllBytes("C:\\Users\\nlight\\Desktop\\sky.png"));
            var pixels = tmp.GetPixels();

            cubemap = new Cubemap(4096, TextureFormat.RGBA32, false);
            cubemap.SetPixels(pixels, CubemapFace.NegativeX);
            cubemap.SetPixels(pixels, CubemapFace.NegativeY);
            cubemap.SetPixels(pixels, CubemapFace.NegativeZ);
            cubemap.SetPixels(pixels, CubemapFace.PositiveX);
            cubemap.SetPixels(pixels, CubemapFace.PositiveY);
            cubemap.SetPixels(pixels, CubemapFace.PositiveZ);
            cubemap.Apply();
        }
开发者ID:abdulrahmanwaly,项目名称:Skylines-Daybreak,代码行数:18,代码来源:SkyboxManager.cs

示例7: ConvertLatLongToCubemap

    public static void ConvertLatLongToCubemap()
    {
        foreach(Object o in Selection.GetFiltered(typeof(Texture2D),
                                                  SelectionMode.Assets)) {
            try {
                Texture2D latLong = o as Texture2D;

                int faceSize = Mathf.ClosestPowerOfTwo(latLong.width / 4);
                Cubemap cube = new Cubemap(faceSize, latLong.format, latLong.mipmapCount > 0);

                // For each side
                foreach (CubemapFace face in System.Enum.GetValues(typeof(CubemapFace))) {
                    EditorUtility.DisplayProgressBar("Latlong to cubemap", "Processing " + latLong.name + " " + face, (float) face / 6.0f);
                    Color[] pixels = new Color[faceSize * faceSize];
                    for (int x = 0; x < faceSize; ++x)
                        for (int y = 0; y < faceSize; ++y) {

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

                            Vector2 uv = Utils.Cubemap.DirectionToSphericalUV(dir);

                            int index = x + y * faceSize;
                            pixels[index] = latLong.GetPixelBilinear(uv.x, uv.y);
                        }

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

                string sourcePath = AssetDatabase.GetAssetPath(latLong);
                string saveFolder = System.IO.Path.GetDirectoryName(sourcePath);
                string destPath = saveFolder +"/" + latLong.name + ".cubemap";
                AssetDatabase.CreateAsset(cube, destPath);
                Debug.Log("Converted " + sourcePath + " to cubemap");
            } catch (System.Exception e) {
                Debug.LogError("Convertion from lat long to cubemap failed:\n" + e);
            }
        }
        EditorUtility.ClearProgressBar();
    }
开发者ID:shadercoder,项目名称:Unity3D-experiments,代码行数:42,代码来源:TextureConverter.cs

示例8: ConvolveIrradianceEnvironmentMap


//.........这里部分代码省略.........
		    //var m_NormCubeMap_pixels  = new Color[m_NormCubeMap.width*m_NormCubeMap.height];
		    //m_NormCubeMap_pixels = m_NormCubeMap.GetPixels((CubemapFace)iFaceIdx);

		    // Pointer to the start of the given face in m_NormCubeMapArray 
		    startFacePtr = a_Size*a_Size*iFaceIdx;

		    // read all pixels of irrCubeMap
            var cubeMap_pixels = new Color[irrCubeMap.width * irrCubeMap.height];
		    cubeMap_pixels = irrCubeMap.GetPixels((CubemapFace)iFaceIdx);


			    for (int y = 0; y < a_Size; y++) {
				    for (int x = 0; x < a_Size; x++) {

					    // read normalCube single pixel
					    Vector4 m_NormCubeMap_pixel = m_NormCubeMapArray[startFacePtr + y*a_Size + x];

					    // read originalCube single pixel
					    Color cubeMap_pixel = cubeMap_pixels[y*a_Size + x];

					    // solid angle stored in 4th channel of normalizer/solid angle cube map
					    weight = m_NormCubeMap_pixel[3];
					    //weight = TexelCoordSolidAngle(iFaceIdx, (float)x, (float)y, a_Size);

					    // pointer to direction and solid angle in cube map associated with texel
					    Vector3 texelVect;
					    texelVect.x = m_NormCubeMap_pixel[0];
					    texelVect.y = m_NormCubeMap_pixel[1];
					    texelVect.z = m_NormCubeMap_pixel[2];
					    //texelVect = TexelToVect(iFaceIdx, (float)x, (float)y, a_Size);
	
					    EvalSHBasis(texelVect, ref SHdir);

					    // read original colors and convert to float64
					    double R = cubeMap_pixel[0];
					    double G = cubeMap_pixel[1];
					    double B = cubeMap_pixel[2];

					    for (int i = 0; i < 25; i++)
					    {
						    SHr[i] += R * SHdir[i] * weight;
						    SHg[i] += G * SHdir[i] * weight;
						    SHb[i] += B * SHdir[i] * weight;
					    }
					    weightAccum += weight;
			    }
		    }
	    }
	    // Normalization - The sum of solid angle should be equal to the solid angle of the sphere (4 PI), so
	    // Normalize in order our weightAccum exactly match 4 PI.
	    for (int i = 0; i < 25; ++i)
	    {
		    SHr[i] *= 4.0 * CP_PI / weightAccum;
		    SHg[i] *= 4.0 * CP_PI / weightAccum;
		    SHb[i] *= 4.0 * CP_PI / weightAccum;
	    }

	    // Second step - Generate cubemap from SH coefficient

	    // Normalized vectors per cubeface and per-texel solid angle
	    // Why do we do it a 2nd time????
	    BuildNormalizerSolidAngleArray(a_Size, ref m_NormCubeMapArray);

	    for (int iFaceIdx = 0; iFaceIdx < 6; iFaceIdx++) {

		    // Pointer to the start of the given face in m_NormCubeMapArray 
		    startFacePtr = a_Size*a_Size*iFaceIdx;

		    for (int y = 0; y < a_Size; y++) {
			    for (int x = 0; x < a_Size; x++) {
				    // read normalCube pixel
				    Vector4 m_NormCubeMap_pixel = m_NormCubeMapArray[startFacePtr + y*a_Size + x];

				    // read normalvector and pass it to EvalSHBasis to get SHdir
				    Vector3 texelVect;
				    texelVect.x = m_NormCubeMap_pixel[0];
				    texelVect.y = m_NormCubeMap_pixel[1];
				    texelVect.z = m_NormCubeMap_pixel[2];
				    //texelVect = TexelToVect(iFaceIdx, (float)x, (float)y, a_Size);

				    EvalSHBasis( texelVect, ref SHdir);

				    // set color values
				    double R = 0.0;
				    double G = 0.0;
				    double B = 0.0;
				
				    for (int i = 0; i < 25; ++i)
				    {
					    R += (SHr[i] * SHdir[i] * SHBandFactor[i]);
					    G += (SHg[i] * SHdir[i] * SHBandFactor[i]);
					    B += (SHb[i] * SHdir[i] * SHBandFactor[i]);
				    }
				    // Lux needs alpha!
				    irrCubeMap.SetPixel((CubemapFace)iFaceIdx, x, y, new Color((float)R,(float)G,(float)B, 1.0f ));
			    }
		    }
	    }
	    irrCubeMap.Apply();
    }
开发者ID:Backman,项目名称:Hellbound,代码行数:101,代码来源:LuxCubeProcessor.cs

示例9: ConvolveRadianceEnvironmentMap

    //[MenuItem ("Lux Cubemapper/Cubemapper")]
    //static void CreateWizard () {
    //    ScriptableWizard.DisplayWizard<LuxCubeMapper>("Convolve cubemap", "Go");
    //}

    //void OnWizardCreate () {
    //    if (TakeNewProbe) RenderToCubeMap(cubeMap,probe);


    //    //	diffuse	
    //    if (ConvolutionMode == ConvoModes.Diffuse) {
    //        ConvolveIrradianceEnvironmentMap (cubeMap);
    //        if (PullHDR) FakeHDR(cubeMap, false);
    //    }

    //    if (ConvolutionMode == ConvoModes.Specular) {
    //        ConvolveRadianceEnvironmentMap (cubeMap);
    //        FixupCubeEdges(cubeMap);
    //        if (PullHDR) FakeHDR(cubeMap, true);
    //        cubeMap.filterMode = FilterMode.Trilinear;
    //        cubeMap.mipMapBias = 0.5f;
    //    }
    //}  


    //void OnWizardUpdate () {
    //}   

    //void RenderToCubeMap(Cubemap dest, GameObject probe) {
    //    var cubeCamera = new GameObject( "CubemapCamera", typeof(Camera) ) as GameObject;
    ////	cubeCamera.hideFlags = HideFlags.HideInHierarchy;
    //    var cubeCam = cubeCamera.GetComponent("Camera") as Camera;
    //    cubeCam.nearClipPlane = 0.001f;
    //    cubeCam.farClipPlane = 1000.0f;
    //    cubeCam.aspect = 1.0f;
    ////	cubeCam.hdr = true;
    //    cubeCam.cullingMask = 1 << 0;		
    //    cubeCamera.transform.position = probe.transform.position;
    //    cubeCam.RenderToCubemap(dest);
    //    GameObject.DestroyImmediate(cubeCamera);
    //}



//--------------------------------------------------------------------------------------
// ConvolveRadianceEnvironmentMap

    void ConvolveRadianceEnvironmentMap (Cubemap RadianceCube) {
	    int a_Size = RadianceCube.width;
	    int n_Size = a_Size;
	    int startMipLevel = 0;
	    float specularPower;
	    float[] specPowr = new float [] {
		    SpecularPower, SpecularPower/2.0f, SpecularPower/4.0f, SpecularPower/8.0f, SpecularPower/16.0f, SpecularPower/32.0f, SpecularPower/64.0f, SpecularPower/128.0f, SpecularPower/256.0f, SpecularPower/512.0f
	    };

	    // Calculate maxmiplevels
	    int maxMipLevels = (int)Mathf.Log(a_Size, 2) + 1;
    //
        float mytime = Time.realtimeSinceStartup;
	
	    // if HighestMipIsReflection == true then skip processing of the highest mip level
	    if (HighestMipIsReflection) {
		    startMipLevel = 1;
		    n_Size = n_Size >> 1;		
	    } 

	    for (int mipLevel = startMipLevel; mipLevel < maxMipLevels; mipLevel++)
	    {
		    Vector4[] m_NormCubeMapArray = new Vector4[n_Size*n_Size*6];
		    BuildNormalizerSolidAngleArray(n_Size, ref m_NormCubeMapArray);

		    specularPower = specPowr[mipLevel];
		    float Angle;
		    // If we use SpecularPower, automatically calculate the a_BaseFilterAngle required, this will speed the process
		    Angle = GetBaseFilterAngle(specularPower);
		    // Go for it:
		    FilterCubefaces(RadianceCube, m_NormCubeMapArray, mipLevel, Angle, specularPower);
    //		FilterCubefacesBF(RadianceCube, mipLevel, Angle, specularPower);
		    n_Size = n_Size >> 1;
	    }
    //
        Debug.Log(Time.realtimeSinceStartup - mytime);

	    RadianceCube.Apply(false);
	
    }
开发者ID:Backman,项目名称:Hellbound,代码行数:87,代码来源:LuxCubeProcessor.cs

示例10: RenderCubeFaces

    IEnumerator RenderCubeFaces(Cubemap cube, bool irradiance)
    {
        if (irradiance)
        {
            size = (int)DiffSize;
            mipmap = false;
        }
        else
        {
            size = (int)SpecSize;
            mipmap = true;
        }

        cube = new Cubemap((int)size, texFor, mipmap);
        yield return StartCoroutine(Capture(cube, CubemapFace.PositiveZ, CubeCamera));
        yield return StartCoroutine(Capture(cube, CubemapFace.PositiveX, CubeCamera));
        yield return StartCoroutine(Capture(cube, CubemapFace.NegativeX, CubeCamera));
        yield return StartCoroutine(Capture(cube, CubemapFace.NegativeZ, CubeCamera));
        yield return StartCoroutine(Capture(cube, CubemapFace.PositiveY, CubeCamera));
        yield return StartCoroutine(Capture(cube, CubemapFace.NegativeY, CubeCamera));
        cube.Apply(mipmap);
        if (irradiance)
        {
            Cubemap diffCube = cube;
            diffCube.name = cubeName;
            if (SmoothEdges)
            {
                diffCube.SmoothEdges(SmoothEdgePixel);
            }

            diffCube.wrapMode = TextureWrapMode.Clamp;
            string finalDiffPath = diffCube.name + "DIFF.cubemap";

            AssetDatabase.CreateAsset(diffCube, finalDiffPath);
            SerializedObject serializedCubemap = new SerializedObject(diffCube);
            SetLinearSpace(ref serializedCubemap, true);
            DIFFCube = diffCube;
        }
        else
        {
            Cubemap specCube = cube;
            specCube.name = cubeName;
            if (SmoothEdges)
            {
                specCube.SmoothEdges(SmoothEdgePixel);
            }

            specCube.wrapMode = TextureWrapMode.Clamp;
            string finalSpecPath = specCube.name + "SPEC.cubemap";

            AssetDatabase.CreateAsset(specCube, finalSpecPath);

            SerializedObject serializedCubemap = new SerializedObject(specCube);
            SetLinearSpace(ref serializedCubemap, true);
            SPECCube = specCube;
        }
        yield return StartCoroutine(Finished());
    }
开发者ID:TravisDean,项目名称:MEZ,代码行数:58,代码来源:LuxEnvProbe.cs

示例11: ConvolveSpecularCubeMap

	IEnumerator ConvolveSpecularCubeMap()
	{
		int size = 0;
		int samples = 0;
		size = CubeSizeSetup(false);
		samples = qualitySetup(false);

		if(radianceModel == radianceEnum.BlinnPhong)
		{
			convolveSpecularSkybox = new Material(Shader.Find("Hidden/Antonov Suit/Radiance/Blinn"));
		}

		if(radianceModel == radianceEnum.GGX)
		{
			convolveSpecularSkybox = new Material(Shader.Find("Hidden/Antonov Suit/Radiance/GGX"));
		}

		convolveSpecularSkybox.SetInt("_specSamples",samples);
		convolveSpecularSkybox.SetInt("_specularSize", size);
		convolveSpecularSkybox.SetTexture("_SpecCubeIBL", specularCube);

		UnityEngine.RenderSettings.skybox = convolveSpecularSkybox;

		Cubemap tempCube = new Cubemap(size, TextureFormat.ARGB32, true);

		for(int mip = 0; (size >> mip) > 0; mip++)
		{

			// v0.035 better way to get exponent with different cubemap size
			float minExponent = 0.005f;

			float exponent = Mathf.Max( (float)specularExponent / (float)size * (float)mip, minExponent );

			/*
			float[] expVal = new float [] {
				0.01f,0.1f,0.2f,0.3f,0.4f,0.5f,0.6f,0.7f,0.8f,0.9f,1.0f
			};

			float exponent = expVal[mip];

			convolveSpecularSkybox.SetFloat("_Shininess", exponent );
			*/

			if( mip == 0 )
			{
				convolveSpecularSkybox.SetFloat("_Shininess", minExponent);
			}
			if( mip != 0 && radianceModel == radianceEnum.GGX)
			{
				convolveSpecularSkybox.SetFloat("_Shininess", exponent + 0.05f);
			}
			if( mip != 0 && radianceModel == radianceEnum.BlinnPhong)
			{
				convolveSpecularSkybox.SetFloat("_Shininess", exponent);
			}

			int cubeSize = Mathf.Max(1, tempCube.width >> mip );

			Cubemap mipCube = new Cubemap(cubeSize, TextureFormat.ARGB32, false);

			if( hasPro == true )
			{		
				cubeCamera.RenderToCubemap(mipCube);

				for(int f=0; f<6; ++f) 
				{
					CubemapFace face = (CubemapFace)f;
					tempCube.SetPixels(mipCube.GetPixels(face), face, mip);
				}

			}
			else
			{
				yield return StartCoroutine(CaptureImportanceSample(tempCube, CubemapFace.PositiveZ, cubeCamera,mip));
				yield return StartCoroutine(CaptureImportanceSample(tempCube, CubemapFace.PositiveX, cubeCamera,mip));
				yield return StartCoroutine(CaptureImportanceSample(tempCube, CubemapFace.NegativeX, cubeCamera,mip));
				yield return StartCoroutine(CaptureImportanceSample(tempCube, CubemapFace.NegativeZ, cubeCamera,mip));
				yield return StartCoroutine(CaptureImportanceSample(tempCube, CubemapFace.PositiveY, cubeCamera,mip));
				yield return StartCoroutine(CaptureImportanceSample(tempCube, CubemapFace.NegativeY, cubeCamera,mip));
			}
		}

		// v0.035 this fix the ugly mipmap transition
		tempCube.filterMode = FilterMode.Trilinear;
		tempCube.wrapMode = TextureWrapMode.Clamp;

		if (SystemInfo.graphicsShaderLevel != 50)
		{
			tempCube.SmoothEdges(smoothEdge);
		}

		tempCube.Apply(false);

		specularCube = tempCube;

		string convolvedSpecularPath = GetOutPutPath(specularCube,false);
	
		AssetDatabase.CreateAsset(specularCube, convolvedSpecularPath);
		SerializedObject serializedCubemap = new SerializedObject(specularCube);
		SetLinearSpace(ref serializedCubemap, false);
//.........这里部分代码省略.........
开发者ID:ArieLeo,项目名称:AntonovSuit,代码行数:101,代码来源:AntonovSuitProbe.cs

示例12: CaptureImportanceSample

	IEnumerator CaptureImportanceSample(Cubemap cubemap,CubemapFace face,Camera cam, int mip)
	{



		var width = Screen.width;
		var height = Screen.height;
		Texture2D tex = new Texture2D(height, height, TextureFormat.ARGB32, false);

		cam.transform.localRotation = Rotation(face);
		
		yield return new WaitForEndOfFrame();
		
		tex.ReadPixels(new Rect((width-height)/2, 0, height, height), 0, 0);
		tex.Apply();

		int cubeSize = Mathf.Max(1, cubemap.width >> mip );
	
		tex = Resize(tex, cubeSize,cubeSize,true);

		Color[] tempCol = tex.GetPixels();

		cubemap.SetPixels(tempCol,face,mip);

		cubemap.Apply(false);

		DestroyImmediate(tex);
	}
开发者ID:ArieLeo,项目名称:AntonovSuit,代码行数:28,代码来源:AntonovSuitProbe.cs

示例13: FakeHDR

    void FakeHDR (Cubemap CubeMap, bool hasmipLevels) {
	    int maxMipLevels = 1;
	    if (hasmipLevels) {
		    maxMipLevels = (int)(Mathf.Log((float)CubeMap.width, 2.0f)) + 1;
	    }
	    int base_Size = CubeMap.width;
	    Vector4 rgbmColor = new Vector4();

	    for (int mipLevel = 0; mipLevel < maxMipLevels; mipLevel++)
	    {
		    int a_Size = base_Size >> mipLevel;
		    // As we use a_Size as pointer in our arrays we have to lower it by 1
		    //a_Size -= 1;


		    for (int a_FaceIdx = 0; a_FaceIdx < 6; a_FaceIdx++)
		    {
			    // Get all pixels of the given face
			    Color[] FaceColors = CubeMap.GetPixels((CubemapFace)a_FaceIdx, mipLevel);
			    // Iterate over dst cube map face texel
			    for (int a_V  = 0; a_V < a_Size; a_V++)
			    {
				    for (int a_U = 0; a_U < a_Size; a_U++)
				    {
					    rgbmColor.x = FaceColors[a_V * a_Size + a_U].r;
					    rgbmColor.y = FaceColors[a_V * a_Size + a_U].g;
					    rgbmColor.z = FaceColors[a_V * a_Size + a_U].b;
					    rgbmColor *= 1.0f/6.0f;
					    rgbmColor.w = Mathf.Clamp01(Mathf.Max(Mathf.Max(rgbmColor.x, rgbmColor.y), rgbmColor.z));
					    rgbmColor.w = Mathf.Ceil(rgbmColor.w*255.0f) / 255.0f;
					    rgbmColor.x = rgbmColor.x / rgbmColor.w;
					    rgbmColor.y = rgbmColor.y / rgbmColor.w;
					    rgbmColor.z = rgbmColor.z / rgbmColor.w;
					    FaceColors[a_V * a_Size + a_U] = rgbmColor;
				    }
			    }
			    CubeMap.SetPixels(FaceColors,(CubemapFace)a_FaceIdx, mipLevel);
		    }
	    }
	    CubeMap.Apply(false);
    }
开发者ID:Backman,项目名称:Hellbound,代码行数:41,代码来源:LuxCubeProcessor.cs

示例14: CopyCubemapFace

    private void CopyCubemapFace(CubemapFace face, Cubemap source, ref Cubemap target)
    {
        //Create the blank texture container
        Texture2D snapshot = new Texture2D(source.width, source.height, source.format, m_useMipMaps, false);
        snapshot.wrapMode = TextureWrapMode.Clamp;

        // Read Face Pixels into the Texture
        snapshot.SetPixels(source.GetPixels(face), 0);

        // Resize to new size
        snapshot = Scale(snapshot, m_resolution, m_resolution);

        // Finally write the contents to the new Cubemap
        target.SetPixels(snapshot.GetPixels(), face, 0);
        target.Apply();
    }
开发者ID:fengqk,项目名称:Art,代码行数:16,代码来源:CubemapToolPropertyModifier.cs

示例15: OnGUI

	private void OnGUI()
	{		
		m_scrollPos = EditorGUILayout.BeginScrollView(m_scrollPos);

        EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(325));
            EditorGUILayout.HelpBox("This tool aims to help you when you want to change properties that are not covered by the standard Unity Inspector for Cubemaps, e.g. Mip Map Bias and Unity 4 Smooth Edges. This tool is experimental and should be used with care. I do not take responsibility if something goes wrong or produces undesirable results.", MessageType.Info);
        EditorGUILayout.EndHorizontal();

		GUILayout.Label("1. Define Cubemap", EditorStyles.boldLabel);			
		m_Cubemap = EditorGUILayout.ObjectField(m_Cubemap, typeof(Cubemap), false, GUILayout.Height(70), GUILayout.Width(70)) as Cubemap;	

		if(m_Cubemap != null)
        {
            // Serialization helps determine and set Linear and Mip Map values
            SerializedObject serializedCubemap = new SerializedObject(m_Cubemap);

            // Display Name of the current Cubemap
            GUILayout.Label(m_Cubemap.name);

            GUILayout.Space(15);

            GUILayout.Label("2. Modify Settings", EditorStyles.boldLabel);

            EditorGUIUtility.LookLikeControls(125f);

            // SETTINGS VERTICAL AREA
            EditorGUILayout.BeginVertical(GUILayout.MaxWidth(325));
            {
                EditorGUILayout.HelpBox("Some settings require the Cubemap to be rebuilt, which means you need to re-assign it to your objects.", MessageType.Warning);

                // SETTINGS START HERE
                EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(300));
                {
                    EditorGUILayout.BeginVertical(GUILayout.Width(250));
                    {
                        m_resolution = EditorGUILayout.IntPopup("New Resolution:", m_resolution, m_resolutions, m_resSizes);
                        EditorGUILayout.LabelField("Currently:", m_Cubemap.height.ToString() + "x" + m_Cubemap.width.ToString());
                    }
                    EditorGUILayout.EndVertical();
                    EditorGUILayout.BeginVertical(GUILayout.MaxWidth(50));
                    {
                        GUI.backgroundColor = CubemapHelpers.ColorGreen;
                        if (GUILayout.Button("Apply", GUILayout.Width(50), GUILayout.Height(20)))
                        {
                            RemakeCubemap(ref m_Cubemap);
                        }
                        GUI.backgroundColor = Color.white;
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();
                
                EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(300));
                {
                    EditorGUILayout.BeginVertical(GUILayout.Width(250));
                    {
                        m_useLinearSpace = EditorGUILayout.Toggle("Linear Space:", m_useLinearSpace);
                        EditorGUILayout.LabelField("Currently: " + (CubemapHelpers.isLinear(serializedCubemap) ? "Yes":"No"));
                    }
                    EditorGUILayout.EndVertical();
                    EditorGUILayout.BeginVertical(GUILayout.MaxWidth(50));
                    {
                        GUI.backgroundColor = CubemapHelpers.ColorGreen;
                        if (GUILayout.Button("Apply", GUILayout.Width(50), GUILayout.Height(20)))
                        {
                            CubemapHelpers.setLinear(ref serializedCubemap, m_useLinearSpace);
                        }
                        GUI.backgroundColor = Color.white;
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();

                EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(300));
                {
                    EditorGUILayout.BeginVertical(GUILayout.Width(250));
                    {
                        m_useMipMaps = EditorGUILayout.Toggle("Mip Maps:", m_useMipMaps);
                        EditorGUILayout.LabelField("Currently: " + (CubemapHelpers.usingMipMap(serializedCubemap) ? "Yes" : "No"));
                    }
                    EditorGUILayout.EndVertical();
                    EditorGUILayout.BeginVertical(GUILayout.MaxWidth(50));
                    {
                        GUI.backgroundColor = CubemapHelpers.ColorGreen;
                        if (GUILayout.Button("Apply", GUILayout.Width(50), GUILayout.Height(20)))
                        {
                            CubemapHelpers.setMipMap(ref serializedCubemap, m_useMipMaps);
                        }
                        GUI.backgroundColor = Color.white;
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();

//.........这里部分代码省略.........
开发者ID:fengqk,项目名称:Art,代码行数:101,代码来源:CubemapToolPropertyModifier.cs


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