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


C# Cubemap.GetPixel方法代码示例

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


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

示例1: setFaceAverage

	private void setFaceAverage(ref Cubemap filteredCubeMap, 
	                            int a, int b, int c, int d, int e, int f)
	{
		Color average = 
			(filteredCubeMap.GetPixel((CubemapFace)a, b, c) 
			 + filteredCubeMap.GetPixel((CubemapFace)d, e, f)) / 2.0f;
		filteredCubeMap.SetPixel((CubemapFace)a, b, c, average);
		filteredCubeMap.SetPixel((CubemapFace)d, e, f, average);
	}
开发者ID:sasuke010101,项目名称:UnityShader,代码行数:9,代码来源:ComputeDiffuseEnvironmentMap.cs

示例2: setCornerAverage

	private void setCornerAverage(ref Cubemap filteredCubeMap, 
	                              int a, int b, int c, int d, int e, int f, int g, int h, int i)
	{
		Color average = 
			(filteredCubeMap.GetPixel((CubemapFace)a, b, c) 
			 + filteredCubeMap.GetPixel((CubemapFace)d, e, f) 
			 + filteredCubeMap.GetPixel((CubemapFace)g, h, i)) / 3.0f;
		filteredCubeMap.SetPixel((CubemapFace)a, b, c, average);
		filteredCubeMap.SetPixel((CubemapFace)d, e, f, average);
		filteredCubeMap.SetPixel((CubemapFace)g, h, i, average);
	}
开发者ID:sasuke010101,项目名称:UnityShader,代码行数:11,代码来源:ComputeDiffuseEnvironmentMap.cs

示例3: CalcAmbientLight

	void CalcAmbientLight(Cubemap TempCube){
			//AMBIENT LIGHT CALCULATION
			string path = AssetDatabase.GetAssetPath(TempCube);
			TextureImporter ti =  TextureImporter.GetAtPath(path) as TextureImporter;
			bool OldIsReadable = false;
			int OldMaxSize = 1;
			if (ti!=null){
					OldIsReadable = ti.isReadable;
					ti.isReadable = true;
					OldMaxSize = ti.maxTextureSize;
					ti.maxTextureSize = 32;
					AssetDatabase.ImportAsset(path);
			}
			//CubeResize = new Texture2D(70,70,TextureFormat.ARGB32,false);
			//Color[] colors = new Color[(int)(CubeResize.width*CubeResize.height)];
			Cubemap UseCube = TempCube;
			int MipmapLevel = 0;
			try {
				TempCube.GetPixel(CubemapFace.PositiveX,0,0);
			}
			catch {
				UseCube = defaultBackCube;
			}
			int i = 1;
			if (UseCube.height>4){
				for (i=1;i<9;i++){
					bool Continue = false;
					try {
						Continue = false;
						Color[] colors2 = UseCube.GetPixels(CubemapFace.PositiveX,i);
						if (colors2!=null&&colors2.Length>1)
						Continue = true;
					}
					catch{
						Continue = false;
					}
	//				Debug.Log(Continue);
					if (!Continue)
					break;
				}
			}
			MipmapLevel = i-1;
//			Debug.Log(MipmapLevel);
			
			
			Color PosXo = UseCube.GetPixel(CubemapFace.PositiveX,0,0);
			Color NegXo = UseCube.GetPixel(CubemapFace.NegativeX,0,0);
			Color PosYo = UseCube.GetPixel(CubemapFace.PositiveY,0,0);
			Color NegYo = UseCube.GetPixel(CubemapFace.NegativeY,0,0);
			Color PosZo = UseCube.GetPixel(CubemapFace.PositiveZ,0,0);
			Color NegZo = UseCube.GetPixel(CubemapFace.NegativeZ,0,0);
			
			if (MipmapLevel!=0){
				PosXo = UseCube.GetPixels(CubemapFace.PositiveX,MipmapLevel)[0];
				NegXo = UseCube.GetPixels(CubemapFace.NegativeX,MipmapLevel)[0];
				PosYo = UseCube.GetPixels(CubemapFace.PositiveY,MipmapLevel)[0];
				NegYo = UseCube.GetPixels(CubemapFace.NegativeY,MipmapLevel)[0];
				PosZo = UseCube.GetPixels(CubemapFace.PositiveZ,MipmapLevel)[0];
				NegZo = UseCube.GetPixels(CubemapFace.NegativeZ,MipmapLevel)[0];
			}
			
			Color PosX = Color.Lerp(PosXo,NegYo,0.5f);
			Color NegX = Color.Lerp(NegXo,NegYo,0.5f);
			Color PosY = Color.Lerp(PosYo,PosXo,0.2f);
			Color NegY = Color.Lerp(NegYo,NegXo,0.2f);
			Color PosZ = Color.Lerp(PosZo,NegYo,0.5f);
			Color NegZ = Color.Lerp(NegZo,NegYo,0.5f);
			
			#if UNITY_5
			SphericalHarmonicsL2 L = new SphericalHarmonicsL2();
			L.AddDirectionalLight(new Vector3(1,0,0),PosX,ToGreyscale(PosX));
			L.AddDirectionalLight(new Vector3(0,1,0),PosY,ToGreyscale(PosY));
			L.AddDirectionalLight(new Vector3(0,0,1),PosZ,ToGreyscale(PosZ));
			
			L.AddDirectionalLight(new Vector3(-1,0,0),NegX,ToGreyscale(NegX));
			L.AddDirectionalLight(new Vector3(0,-1,0),NegY,ToGreyscale(NegY));
			L.AddDirectionalLight(new Vector3(0,0,-1),NegZ,ToGreyscale(NegZ));
			

			(previewCam.GetComponent("PreviewCameraSet") as PreviewCameraSet).NewAmbient = L;
			#endif
			Color C = (PosX/6f)+(NegX/6f)+(PosY/6f)+(NegY/6f)+(PosZ/6f)+(NegZ/6f);
			//Debug.Log(C);
			(previewCam.GetComponent("PreviewCameraSet") as PreviewCameraSet).NewAmbientColor = C;
			//L.AddDirectionalLight(new Vector3(0,0,1),new Color(0.5f,0,0),1f);
			//Debug.Log(ToGreyscale(new Color(0.5f,0,0)));
			//CubeResize.SetPixels(colors);
			//CubeResize.Apply(false,false);
			if (ti!=null){
				ti.isReadable = OldIsReadable;
				ti.maxTextureSize = OldMaxSize;
				AssetDatabase.ImportAsset(path);
			}
	}
开发者ID:Thaon,项目名称:IRNBRU,代码行数:94,代码来源:ShaderPreview.cs


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