本文整理汇总了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);
}
示例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);
}
示例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);
}
}