GetPixel() private méthode

private GetPixel ( CubemapFace face, int x, int y ) : Color
face CubemapFace
x int
y int
Résultat Color
 static public int GetPixel(IntPtr l)
 {
     try {
         UnityEngine.Cubemap     self = (UnityEngine.Cubemap)checkSelf(l);
         UnityEngine.CubemapFace a1;
         checkEnum(l, 2, out a1);
         System.Int32 a2;
         checkType(l, 3, out a2);
         System.Int32 a3;
         checkType(l, 4, out a3);
         var ret = self.GetPixel(a1, a2, a3);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int GetPixel(IntPtr l)
 {
     try{
         UnityEngine.Cubemap     self = (UnityEngine.Cubemap)checkSelf(l);
         UnityEngine.CubemapFace a1;
         checkEnum(l, 2, out a1);
         System.Int32 a2;
         checkType(l, 3, out a2);
         System.Int32 a3;
         checkType(l, 4, out a3);
         UnityEngine.Color ret = self.GetPixel(a1, a2, a3);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemple #3
0
 static public int GetPixel(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.Cubemap     self = (UnityEngine.Cubemap)checkSelf(l);
         UnityEngine.CubemapFace a1;
         a1 = (UnityEngine.CubemapFace)LuaDLL.luaL_checkinteger(l, 2);
         System.Int32 a2;
         checkType(l, 3, out a2);
         System.Int32 a3;
         checkType(l, 4, out a3);
         var ret = self.GetPixel(a1, a2, a3);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
	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);
	}
	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);
	}
Exemple #6
0
	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);
			}
	}