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


C# Cubemap.SetPixels方法代码示例

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


在下文中一共展示了Cubemap.SetPixels方法的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: EndCubeFaceRender

    void EndCubeFaceRender(Cubemap target, CubemapFace f, int mipLevel, Camera cam, bool aa)
    {
        // read pixels into destination
        int size = target.width >> mipLevel;
        Texture2D tempTex = new Texture2D (size, size);
        tempTex.ReadPixels(new Rect(0,0,size,size), 0,0, false);
        //Debug.Log (mipLevel);
        target.SetPixels(tempTex.GetPixels(), f, mipLevel);
        Object.DestroyImmediate(tempTex);

        // cleanup camera
        RenderTexture.ReleaseTemporary(cam.targetTexture);
        cam.targetTexture = null;
        cam.ResetWorldToCameraMatrix();
    }
开发者ID:imclab,项目名称:CubeMapRenderer,代码行数:15,代码来源:CubeMapper.cs

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

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

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

示例6: FixupCubeEdges

    //--------------------------------------------------------------------------------------
    // Fixup cube edges

    void FixupCubeEdges (Cubemap CubeMap)
    {
	    int maxMipLevels = (int)(Mathf.Log((float)CubeMap.width, 2.0f)) + 1;
	    int base_Size = CubeMap.width;
	
	    // Do not perform any edge fixed for mip level 0
	    for (int mipLevel = 1; mipLevel < maxMipLevels; mipLevel++)
	    {
		    // declare jagged array for all faces and init its child arrays
		    Color[][] PixelsOfAllFaces = new Color[6][];
		    PixelsOfAllFaces[0] = CubeMap.GetPixels(CubemapFace.PositiveX, mipLevel);
		    PixelsOfAllFaces[1] = CubeMap.GetPixels(CubemapFace.NegativeX, mipLevel);
		    PixelsOfAllFaces[2] = CubeMap.GetPixels(CubemapFace.PositiveY, mipLevel);
		    PixelsOfAllFaces[3] = CubeMap.GetPixels(CubemapFace.NegativeY, mipLevel);
		    PixelsOfAllFaces[4] = CubeMap.GetPixels(CubemapFace.PositiveZ, mipLevel);
		    PixelsOfAllFaces[5] = CubeMap.GetPixels(CubemapFace.NegativeZ, 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;


		    int a_FixupWidth = 3;
		    int fixupDist = (int)Mathf.Min( a_FixupWidth, a_Size / 2);

		    AverageCorner(a_Size, PixelsOfAllFaces[sg_CubeCornerList[0,0]], PixelsOfAllFaces[sg_CubeCornerList[0,1]], PixelsOfAllFaces[sg_CubeCornerList[0,2]], 0, 0, a_Size, a_Size, a_Size, 0);
		    AverageCorner(a_Size, PixelsOfAllFaces[sg_CubeCornerList[1,0]], PixelsOfAllFaces[sg_CubeCornerList[1,1]], PixelsOfAllFaces[sg_CubeCornerList[1,2]], a_Size, 0, a_Size, 0, 0, 0);
		    AverageCorner(a_Size, PixelsOfAllFaces[sg_CubeCornerList[2,0]], PixelsOfAllFaces[sg_CubeCornerList[2,1]], PixelsOfAllFaces[sg_CubeCornerList[2,2]], 0, a_Size, a_Size, 0, a_Size, a_Size);
		    AverageCorner(a_Size, PixelsOfAllFaces[sg_CubeCornerList[3,0]], PixelsOfAllFaces[sg_CubeCornerList[3,1]], PixelsOfAllFaces[sg_CubeCornerList[3,2]], a_Size, a_Size, a_Size, a_Size, 0, a_Size);
		    AverageCorner(a_Size, PixelsOfAllFaces[sg_CubeCornerList[4,0]], PixelsOfAllFaces[sg_CubeCornerList[4,1]], PixelsOfAllFaces[sg_CubeCornerList[4,2]], a_Size, 0, 0, a_Size, 0, 0);
		    AverageCorner(a_Size, PixelsOfAllFaces[sg_CubeCornerList[5,0]], PixelsOfAllFaces[sg_CubeCornerList[5,1]], PixelsOfAllFaces[sg_CubeCornerList[5,2]], 0, 0, 0, 0, a_Size, 0);
		    AverageCorner(a_Size, PixelsOfAllFaces[sg_CubeCornerList[6,0]], PixelsOfAllFaces[sg_CubeCornerList[6,1]], PixelsOfAllFaces[sg_CubeCornerList[6,2]], a_Size, a_Size, 0, 0, 0, a_Size);
		    AverageCorner(a_Size, PixelsOfAllFaces[sg_CubeCornerList[7,0]], PixelsOfAllFaces[sg_CubeCornerList[7,1]], PixelsOfAllFaces[sg_CubeCornerList[7,2]], 0, a_Size, 0, a_Size, a_Size, a_Size);

		    // Perform 2nd iteration in reverse order

		    AverageCorner(a_Size, PixelsOfAllFaces[sg_CubeCornerList[7,0]], PixelsOfAllFaces[sg_CubeCornerList[7,1]], PixelsOfAllFaces[sg_CubeCornerList[7,2]], 0, a_Size, 0, a_Size, a_Size, a_Size);
		    AverageCorner(a_Size, PixelsOfAllFaces[sg_CubeCornerList[6,0]], PixelsOfAllFaces[sg_CubeCornerList[6,1]], PixelsOfAllFaces[sg_CubeCornerList[6,2]], a_Size, a_Size, 0, 0, 0, a_Size);
		    AverageCorner(a_Size, PixelsOfAllFaces[sg_CubeCornerList[5,0]], PixelsOfAllFaces[sg_CubeCornerList[5,1]], PixelsOfAllFaces[sg_CubeCornerList[5,2]], 0, 0, 0, 0, a_Size, 0);
		    AverageCorner(a_Size, PixelsOfAllFaces[sg_CubeCornerList[4,0]], PixelsOfAllFaces[sg_CubeCornerList[4,1]], PixelsOfAllFaces[sg_CubeCornerList[4,2]], a_Size, 0, 0, a_Size, 0, 0);
		    AverageCorner(a_Size, PixelsOfAllFaces[sg_CubeCornerList[3,0]], PixelsOfAllFaces[sg_CubeCornerList[3,1]], PixelsOfAllFaces[sg_CubeCornerList[3,2]], a_Size, a_Size, a_Size, a_Size, 0, a_Size);
		    AverageCorner(a_Size, PixelsOfAllFaces[sg_CubeCornerList[2,0]], PixelsOfAllFaces[sg_CubeCornerList[2,1]], PixelsOfAllFaces[sg_CubeCornerList[2,2]], 0, a_Size, a_Size, 0, a_Size, a_Size);
		    AverageCorner(a_Size, PixelsOfAllFaces[sg_CubeCornerList[1,0]], PixelsOfAllFaces[sg_CubeCornerList[1,1]], PixelsOfAllFaces[sg_CubeCornerList[1,2]], a_Size, 0, a_Size, 0, 0, 0);
		    AverageCorner(a_Size, PixelsOfAllFaces[sg_CubeCornerList[0,0]], PixelsOfAllFaces[sg_CubeCornerList[0,1]], PixelsOfAllFaces[sg_CubeCornerList[0,2]], 0, 0, a_Size, a_Size, a_Size, 0);

	

		    // Average Edges
		    // Note that this loop does not process the corner texels, since they have already been averaged
		    for (int i = 1; i < (a_Size - 1); i++)
		    {
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[0,0]], PixelsOfAllFaces[sg_CubeEdgeList[0,1]], i, 0, a_Size, a_Size - i, fixupDist, new Vector4(0, 1, -1, 0) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[1,0]], PixelsOfAllFaces[sg_CubeEdgeList[1,1]], i, a_Size, a_Size, i, fixupDist, new Vector4(0, -1, -1, 0) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[2,0]], PixelsOfAllFaces[sg_CubeEdgeList[2,1]], 0, i, a_Size, i, fixupDist, new Vector4(1, 0, -1, 0) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[3,0]], PixelsOfAllFaces[sg_CubeEdgeList[3,1]], a_Size, i, 0, i, fixupDist, new Vector4(-1, 0, 1, 0) );
			
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[4,0]], PixelsOfAllFaces[sg_CubeEdgeList[4,1]], i, 0, 0, i, fixupDist, new Vector4(0, 1, 1, 0) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[5,0]], PixelsOfAllFaces[sg_CubeEdgeList[5,1]], i, a_Size, 0, a_Size - i, fixupDist, new Vector4(0, -1, 1, 0) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[6,0]], PixelsOfAllFaces[sg_CubeEdgeList[6,1]], a_Size, i, 0, i, fixupDist, new Vector4(-1, 0, 1, 0) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[7,0]], PixelsOfAllFaces[sg_CubeEdgeList[7,1]], 0, i, a_Size, i, fixupDist, new Vector4(1, 0, -1, 0) );
			
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[8,0]], PixelsOfAllFaces[sg_CubeEdgeList[8,1]], i, a_Size, i, 0, fixupDist, new Vector4(0, -1, 0, 1) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[9,0]], PixelsOfAllFaces[sg_CubeEdgeList[9,1]], i, 0, a_Size - i, 0, fixupDist, new Vector4(0, 1, 0, 1) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[10,0]], PixelsOfAllFaces[sg_CubeEdgeList[10,1]], i, 0, i, a_Size, fixupDist, new Vector4(0, 1, 0, -1) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[11,0]], PixelsOfAllFaces[sg_CubeEdgeList[11,1]], i, a_Size, a_Size - i, a_Size, fixupDist, new Vector4(0, -1, 0, -1) );
		
		    }
		    // Perform 2nd iteration in reverse order
	    /*	for (int i = 0; i < (a_Size); i++)
		    {
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[11,0]], PixelsOfAllFaces[sg_CubeEdgeList[11,1]], i, a_Size, a_Size - i, a_Size, fixupDist, new Vector4(0, -1, 0, -1) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[10,0]], PixelsOfAllFaces[sg_CubeEdgeList[10,1]], i, 0, i, a_Size, fixupDist, new Vector4(0, 1, 0, -1) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[9,0]], PixelsOfAllFaces[sg_CubeEdgeList[9,1]], i, 0, a_Size - i, 0, fixupDist, new Vector4(0, 1, 0, 1) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[8,0]], PixelsOfAllFaces[sg_CubeEdgeList[8,1]], i, a_Size, i, 0, fixupDist, new Vector4(0, -1, 0, 1) );
			
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[7,0]], PixelsOfAllFaces[sg_CubeEdgeList[7,1]], 0, i, a_Size, i, fixupDist, new Vector4(1, 0, -1, 0) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[6,0]], PixelsOfAllFaces[sg_CubeEdgeList[6,1]], a_Size, i, 0, i, fixupDist, new Vector4(-1, 0, 1, 0) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[5,0]], PixelsOfAllFaces[sg_CubeEdgeList[5,1]], i, a_Size, 0, a_Size - i, fixupDist, new Vector4(0, -1, 1, 0) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[4,0]], PixelsOfAllFaces[sg_CubeEdgeList[4,1]], i, 0, 0, i, fixupDist, new Vector4(0, 1, 1, 0) );	
			
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[3,0]], PixelsOfAllFaces[sg_CubeEdgeList[3,1]], a_Size, i, 0, i, fixupDist, new Vector4(-1, 0, 1, 0) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[2,0]], PixelsOfAllFaces[sg_CubeEdgeList[2,1]], 0, i, a_Size, i, fixupDist, new Vector4(1, 0, -1, 0) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[1,0]], PixelsOfAllFaces[sg_CubeEdgeList[1,1]], i, a_Size, a_Size, i, fixupDist, new Vector4(0, -1, -1, 0) );
			    AverageEdge(a_Size, PixelsOfAllFaces[sg_CubeEdgeList[0,0]], PixelsOfAllFaces[sg_CubeEdgeList[0,1]], i, 0, a_Size, a_Size - i, fixupDist, new Vector4(0, 1, -1, 0) );
		    } */

		

		    // Write Pixel from the jagged array back to the cubemap faces
		    for (int writeFace = 0; writeFace < 6; writeFace++ ) {
			    Color[] tempColors = PixelsOfAllFaces[writeFace];
			    CubeMap.SetPixels(tempColors, (CubemapFace)writeFace, mipLevel);
		    }
	    }
	    CubeMap.Apply(false); 
    }
开发者ID:Backman,项目名称:Hellbound,代码行数:99,代码来源:LuxCubeProcessor.cs

示例7: FilterCubefacesBF


//.........这里部分代码省略.........
	    //angle about center tap to define filter cone
	    float filterAngle;
	    //min angle a src texel can cover (in degrees)
	    srcTexelAngle = (180.0f / CP_PI) * Mathf.Atan2(1.0f, (float)a_Size);  
	    //filter angle is 1/2 the cone angle
        filterAngle = a_FilterConeAngle / 2.0f;
        //ensure filter angle is larger than a texel
        if(filterAngle < srcTexelAngle)
        {
            filterAngle = srcTexelAngle;    
        }
        //ensure filter cone is always smaller than the hemisphere
        if(filterAngle > 90.0f)
        {
            filterAngle = 90.0f;
        }

	    // The maximum number of texels in 1D the filter cone angle will cover
	    // Used to determine bounding box size for filter extents
	    filterSize = (int)Mathf.Ceil(filterAngle / srcTexelAngle);
	    // Ensure conservative region always covers at least one texel
        if(filterSize < 1)
        {
            filterSize = 1;
        }

	    // dotProdThresh threshold based on cone angle to determine whether or not taps 
	    // Reside within the cone angle
	    dotProdThresh = Mathf.Cos( (CP_PI / 180.0f) * filterAngle );

	    // Process required faces
	    for (int a_FaceIdx = 0; a_FaceIdx < 6; a_FaceIdx++)
	    {
		    // 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++)
			    {
				    Vector4 Sample = new Vector4();
				    Color tempCol = new Color();
				
				    // get center tap direction
				    Vector3 centerTapDir = TexelToVect(a_FaceIdx, (float)a_U, (float)a_V, a_Size);

				    //--------------------------------------------------------------------------------------
				    //	ProcessFilterExtents 

				    float weightAccum = 0.0f;

				    // Iterate over cubefaces
				    for(int iFaceIdx = 0; iFaceIdx < 6; iFaceIdx++ )
				    {
					    for(int v = 0; v < a_Size; v++)
					    {
						    for(int u = 0; u < a_Size; u++)
						    {
							    // CP_FILTER_TYPE_COSINE_POWER
							    // Pointer to direction in cube map associated with texel
							    Vector3 texelVect = TexelToVect(iFaceIdx, (float)u, (float)v, a_Size);
							    // Check dot product to see if texel is within cone
							    float tapDotProd = Vector3.Dot(texelVect, centerTapDir);


							    float weight = 0.0f;
							    if( tapDotProd >= dotProdThresh && tapDotProd > 0.0f )
							    {
								
								    // Weight should be proportional to the solid angle of the tap
                 				    weight = TexelCoordSolidAngle(iFaceIdx, (float)u, (float)v, a_Size);
								    // Here we decide if we use a Phong/Blinn or a Phong/Blinn BRDF.
								    // Phong/Blinn BRDF is just the Phong/Blinn model multiply by the cosine of the lambert law
								    // so just adding one to specularpower do the trick.					   
								    // weight *= pow(tapDotProd, (a_SpecularPower + (float32)IsPhongBRDF));
							    // CP_FILTER_TYPE_COSINE_POWER
								    weight *= Mathf.Pow(tapDotProd, a_SpecularPower);
							    // CP_FILTER_TYPE_COSINE
								    //weight *= tapDotProd;
							    }
							    // Accumulate weight
							    weightAccum += weight;

							    // Get pixel from the input cubeMap array
							    tempCol = PixelsOfAllFaces[a_Size*a_Size*iFaceIdx + a_Size*v + u];
							    Sample += new Vector4(tempCol.r * weight, tempCol.g * weight, tempCol.b * weight, 1.0f);
						    }
					    }
				    }
				    // one pixel processed
				    // Lux needs alpha!
				    OutputCubeFacePixels[a_FaceIdx][a_V*a_Size + a_U] = new Color(Sample.x/ weightAccum, Sample.y/ weightAccum, Sample.z/ weightAccum, 1.0f);
			    // end inner loops
			    }
		    }
	    }
	    // Write Pixel from the jagged array back to the cubemap faces
	    for (int writeFace = 0; writeFace < 6; writeFace++ ) {
		    Color[] tempColors = OutputCubeFacePixels[writeFace];
		    RadianceCubeMap.SetPixels(tempColors, (CubemapFace)writeFace, mipLevel);
	    }
    }
开发者ID:Backman,项目名称:Hellbound,代码行数:101,代码来源:LuxCubeProcessor.cs

示例8: RenderCube

    public IEnumerator RenderCube(GameObject lightShapeObjTemp, GameObject lightShapeObjTempAlt, GameObject groundShapeObjTemp, Material gMat, Material lsMat, Material alsMat)
    {
        yield return new WaitForEndOfFrame();
        var cubeCamera = new GameObject( "CubemapCamera", typeof(Camera) ) as GameObject;
        cubeCamera.hideFlags = HideFlags.HideInHierarchy;
        var cubeCam = cubeCamera.GetComponent("Camera") as Camera;
        var tempFull = new Cubemap (LightShapeProbe.LightShapeManager.CubeMapSize, TextureFormat.RGB24, LightShapeProbe.LightShapeManager.hasMips) as Cubemap;
        yield return new WaitForEndOfFrame();
        cubeCam.nearClipPlane = 0.001f;
        cubeCam.aspect = 1.0f;

        if(LightShapeProbe.LightShapeManager.worldCamera)
        {
            if(!RenderSettings.skybox)
            {
                if(!LightShapeProbe.overrideCameraColor)
                {
                    cubeCam.backgroundColor = LightShapeProbe.LightShapeManager.worldCamera.backgroundColor;
                }

                if(LightShapeProbe.overrideCameraColor)
                {
                    cubeCam.backgroundColor = LightShapeProbe.BGColor;
                }
            }

                if(RenderSettings.skybox)
                {
                    if(!LightShapeProbe.overrideCameraColor)
                    {
                        cubeCam.clearFlags = CameraClearFlags.Skybox;
                    }
                    if(LightShapeProbe.overrideCameraColor)
                    {
                        cubeCam.clearFlags = CameraClearFlags.SolidColor;
                        cubeCam.backgroundColor = LightShapeProbe.BGColor;
                    }
                }
        }

        cubeCam.fov = 90;
        cubeCam.cullingMask = 1 << 0;
        cubeCamera.transform.position = transform.position;

        cubeCamera.transform.eulerAngles = new Vector3(0, 90, 0);
        Texture2D tex = new Texture2D (LightShapeProbe.LightShapeManager.CubeMapSize, LightShapeProbe.LightShapeManager.CubeMapSize, TextureFormat.RGB24, false);

        yield return new WaitForEndOfFrame();
        tex.ReadPixels (new Rect(1, 1, LightShapeProbe.LightShapeManager.CubeMapSize, LightShapeProbe.LightShapeManager.CubeMapSize), 0, 0);
        yield return new WaitForEndOfFrame();
        tex.Apply ();
        CubeMapColors = tex.GetPixels();

        Color [,] bigPicture = new Color[LightShapeProbe.LightShapeManager.CubeMapSize, LightShapeProbe.LightShapeManager.CubeMapSize];

        row = -1;

        for( int i = 0; i < LightShapeProbe.LightShapeManager.CubeMapSize * LightShapeProbe.LightShapeManager.CubeMapSize; ++i )
        {
           		  if ( i % LightShapeProbe.LightShapeManager.CubeMapSize == 0 ) ++row;
          		  bigPicture[row, i % LightShapeProbe.LightShapeManager.CubeMapSize] = CubeMapColors[i];
        }

        Color [,] flippedX = new Color[LightShapeProbe.LightShapeManager.CubeMapSize, LightShapeProbe.LightShapeManager.CubeMapSize];

        for( int i = 0; i < LightShapeProbe.LightShapeManager.CubeMapSize; ++i )
        {
            for( int j = 0; j < LightShapeProbe.LightShapeManager.CubeMapSize; ++j)
            {
                flippedX[LightShapeProbe.LightShapeManager.CubeMapSize - 1 - i, j] = bigPicture[i, j];
           		}
        }

        row = -1;

        for( int i = 0; i < LightShapeProbe.LightShapeManager.CubeMapSize * LightShapeProbe.LightShapeManager.CubeMapSize; ++i )
        {
            if ( i % LightShapeProbe.LightShapeManager.CubeMapSize == 0 ) ++row;
                CubeMapColors[i] = flippedX[row, i % LightShapeProbe.LightShapeManager.CubeMapSize];
        }

        tempFull.SetPixels(CubeMapColors, CubemapFace.PositiveX);
        tempFull.Apply();

        cubeCamera.transform.eulerAngles = new Vector3(0, 270, 0);
        yield return new WaitForEndOfFrame();
        tex.ReadPixels (new Rect(1, 1, LightShapeProbe.LightShapeManager.CubeMapSize, LightShapeProbe.LightShapeManager.CubeMapSize), 0, 0);
        yield return new WaitForEndOfFrame();
        tex.Apply ();
        CubeMapColors = tex.GetPixels();

        bigPicture = new Color[LightShapeProbe.LightShapeManager.CubeMapSize, LightShapeProbe.LightShapeManager.CubeMapSize];

        row = -1;

        for( int i = 0; i < LightShapeProbe.LightShapeManager.CubeMapSize * LightShapeProbe.LightShapeManager.CubeMapSize; ++i )
        {
           		  if ( i % LightShapeProbe.LightShapeManager.CubeMapSize == 0 ) ++row;
          		  bigPicture[row, i % LightShapeProbe.LightShapeManager.CubeMapSize] = CubeMapColors[i];
        }
//.........这里部分代码省略.........
开发者ID:ifty420,项目名称:Traffic-Racer-2-3d,代码行数:101,代码来源:AltMethod.cs

示例9: UseColor

    void UseColor()
    {
        var othersCube = new Cubemap (LightShapeProbe.LightShapeManager.CubeMapSize, TextureFormat.RGB24, false) as Cubemap;

        CubeMapColorsR = othersCube.GetPixels(CubemapFace.PositiveX);

        for(var rXp = 0; rXp < CubeMapColorsR.Length; rXp++)
        {
            CubeMapColorsR[rXp] = LightShapeProbe.reflectedColor;
        }

        othersCube.SetPixels(CubeMapColorsR, CubemapFace.PositiveX);
        othersCube.Apply();

        CubeMapColorsR = othersCube.GetPixels(CubemapFace.NegativeX);
        for(var rXn = 0; rXn < CubeMapColorsR.Length; rXn++)
        {
            CubeMapColorsR[rXn] = LightShapeProbe.reflectedColor;
        }

        othersCube.SetPixels(CubeMapColorsR, CubemapFace.NegativeX);
        othersCube.Apply();

        CubeMapColorsR = othersCube.GetPixels(CubemapFace.PositiveY);
        for(var rYp = 0; rYp < CubeMapColorsR.Length; rYp++)
        {
            CubeMapColorsR[rYp] = LightShapeProbe.reflectedColor;
        }

        othersCube.SetPixels(CubeMapColorsR, CubemapFace.PositiveY);
        othersCube.Apply();

        CubeMapColorsR = othersCube.GetPixels(CubemapFace.NegativeY);
        for(var rYn = 0; rYn < CubeMapColorsR.Length; rYn++)
        {
            CubeMapColorsR[rYn] = LightShapeProbe.reflectedColor;
        }

        othersCube.SetPixels(CubeMapColorsR, CubemapFace.NegativeY);
        othersCube.Apply();

        CubeMapColorsR = othersCube.GetPixels(CubemapFace.PositiveZ);
        for(var rZp = 0; rZp < CubeMapColorsR.Length; rZp++)
        {
            CubeMapColorsR[rZp] = LightShapeProbe.reflectedColor;
        }

        othersCube.SetPixels(CubeMapColorsR, CubemapFace.PositiveZ);
        othersCube.Apply();

        CubeMapColorsR = othersCube.GetPixels(CubemapFace.NegativeZ);
        for(var rZn = 0; rZn < CubeMapColorsR.Length; rZn++)
        {
            CubeMapColorsR[rZn] = LightShapeProbe.reflectedColor;
        }

        othersCube.SetPixels(CubeMapColorsR, CubemapFace.NegativeZ);
        othersCube.Apply();

        GameObject[] wObjects = LightShapeProbe.LightShapeManager.cubeProbes;

        foreach(GameObject o in wObjects)
        {
            var oo = o.GetComponent("LightShapeProbe") as LightShapeProbe;

            foreach(GameObject ooo in oo.myObjects)
            {
                var tempMat = ooo.GetComponent<MeshRenderer>();

         				tempMat.sharedMaterial.SetTexture("_Cube", othersCube);
            }
        }
    }
开发者ID:ifty420,项目名称:Traffic-Racer-2-3d,代码行数:73,代码来源:AltMethod.cs

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

示例11: BuildCubeMap

		static public void BuildCubeMap (string name, int [][][] cube) {
			int size = cube.Length;

			Color[] upPixels = new Color [size * size];
			Color[] downPixels = new Color [size * size];
			Color[] rightPixels = new Color [size * size];
			Color[] leftPixels = new Color [size * size];
			Color[] forwardPixels = new Color [size * size];
			Color[] backPixels = new Color [size * size];

			float h = 0;

			for (int i = 0; i < size; i++) {
				for (int j = 0; j < size; j++) {
					h = cube [size - 1 - j][size - 1][size - 1 - i];
					upPixels [size * size - 1 - (j + i * size)] = new Color (h/255f, h/255f, h/255f, 1f);
					
					h = cube [size - 1 - j][0][i];
					downPixels [size * size - 1 - (j + i * size)] = new Color (h/255f, h/255f, h/255f, 1f);
					
					h = cube [size - 1][i][j];
					rightPixels [size * size - 1 - (j + i * size)] = new Color (h/255f, h/255f, h/255f, 1f);
					
					h = cube [0][i][size - 1 - j];
					leftPixels [size * size - 1 - (j + i * size)] = new Color (h/255f, h/255f, h/255f, 1f);
					
					h = cube [size - 1 - j][i][size - 1];
					forwardPixels [size * size - 1 - (j + i * size)] = new Color (h/255f, h/255f, h/255f, 1f);
					
					h = cube [j][i][0];
					backPixels [size * size - 1 - (j + i * size)] = new Color (h/255f, h/255f, h/255f, 1f);
				}
			}

			Cubemap cubeMap = new Cubemap (size, TextureFormat.RGBA32, false);
			cubeMap.SetPixels (upPixels, CubemapFace.PositiveY);
			cubeMap.SetPixels (downPixels, CubemapFace.NegativeY);
			cubeMap.SetPixels (rightPixels, CubemapFace.PositiveX);
			cubeMap.SetPixels (leftPixels, CubemapFace.NegativeX);
			cubeMap.SetPixels (forwardPixels, CubemapFace.PositiveZ);
			cubeMap.SetPixels (backPixels, CubemapFace.NegativeZ);

			AssetDatabase.CreateAsset (cubeMap, "Assets/PlanetBuilder/Resources/CubeMapGenerator/Cubemaps/" + name + ".asset");
		}
开发者ID:DigiM4x,项目名称:PlanetBuilder,代码行数:44,代码来源:CubeMapUtility.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: m_CreateCubemap

	/**
	 * キューブマップの作成.
	 */
	private void m_CreateCubemap() {
		if (m_srcTexture == null) {
			EditorUtility.DisplayDialog("Error", "Please set panorama image!", "OK");
			return;
		}

		// Textureを出力するディレクトリの作成.
		if (!Directory.Exists(PanoramaToCubemap.outputImageDirectory)) {
			Directory.CreateDirectory(PanoramaToCubemap.outputImageDirectory);
		}

		int texSize = m_GetCubemapTextureSize();
		m_Cubemap = new Cubemap(texSize, TextureFormat.RGB24, false);

		if (m_dstTextureFront != null) {
			m_EnableTextureGetPixel(m_dstTextureFront, true);

			Color [] dstCols = new Color[texSize * texSize];

			int iPos = 0;
			for (int y = 0; y < texSize; y++) {
				Color [] srcLines = m_dstTextureFront.GetPixels(0, texSize - y - 1, texSize, 1);
				for (int x = 0; x < texSize; x++) {
					dstCols[iPos + x] = srcLines[x];
				}
				iPos += texSize;
			}
			m_Cubemap.SetPixels(dstCols, CubemapFace.PositiveZ);

			m_EnableTextureGetPixel(m_dstTextureFront, false);
		}
		if (m_dstTextureBack != null) {
			m_EnableTextureGetPixel(m_dstTextureBack, true);

			Color [] dstCols = new Color[texSize * texSize];
			
			int iPos = 0;
			for (int y = 0; y < texSize; y++) {
				Color [] srcLines = m_dstTextureBack.GetPixels(0, texSize - y - 1, texSize, 1);
				for (int x = 0; x < texSize; x++) {
					dstCols[iPos + x] = srcLines[x];
				}
				iPos += texSize;
			}
			m_Cubemap.SetPixels(dstCols, CubemapFace.NegativeZ);

			m_EnableTextureGetPixel(m_dstTextureBack, false);
		}
		if (m_dstTextureLeft != null) {
			m_EnableTextureGetPixel(m_dstTextureLeft, true);

			Color [] dstCols = new Color[texSize * texSize];
			
			int iPos = 0;
			for (int y = 0; y < texSize; y++) {
				Color [] srcLines = m_dstTextureLeft.GetPixels(0, texSize - y - 1, texSize, 1);
				for (int x = 0; x < texSize; x++) {
					dstCols[iPos + x] = srcLines[x];
				}
				iPos += texSize;
			}
			m_Cubemap.SetPixels(dstCols, CubemapFace.PositiveX);

			m_EnableTextureGetPixel(m_dstTextureLeft, false);
		}
		if (m_dstTextureRight != null) {
			m_EnableTextureGetPixel(m_dstTextureRight, true);

			Color [] dstCols = new Color[texSize * texSize];
			
			int iPos = 0;
			for (int y = 0; y < texSize; y++) {
				Color [] srcLines = m_dstTextureRight.GetPixels(0, texSize - y - 1, texSize, 1);
				for (int x = 0; x < texSize; x++) {
					dstCols[iPos + x] = srcLines[x];
				}
				iPos += texSize;
			}
			m_Cubemap.SetPixels(dstCols, CubemapFace.NegativeX);

			m_EnableTextureGetPixel(m_dstTextureRight, false);
		}
		if (m_dstTextureUp != null) {
			m_EnableTextureGetPixel(m_dstTextureUp, true);

			Color [] dstCols = new Color[texSize * texSize];
			
			int iPos = 0;
			for (int y = 0; y < texSize; y++) {
				Color [] srcLines = m_dstTextureUp.GetPixels(0, texSize - y - 1, texSize, 1);
				for (int x = 0; x < texSize; x++) {
					dstCols[iPos + x] = srcLines[x];
				}
				iPos += texSize;
			}
			m_Cubemap.SetPixels(dstCols, CubemapFace.PositiveY);

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

示例14: blurCubeCallback

        private void blurCubeCallback(object data)
        {
            Cubemap tempCube = new Cubemap(this.cube.width, TextureFormat.ARGB32, false);
            for(int i=0; i<6; ++i) {
                CubemapFace face = (CubemapFace)i;
                tempCube.SetPixels(this.cube.GetPixels(face), face);
            }
            tempCube.Apply(false);
            mset.AssetUtil.setLinear(new SerializedObject(tempCube), false);

            mset.SkyProbe p = new mset.SkyProbe();
            p.maxExponent = (int)data;
            p.convolutionScale = 1f;
            p.highestMipIsMirror = false;
            p.generateMipChain = false;
            bool linear = UnityEditor.PlayerSettings.colorSpace == ColorSpace.Linear;

            Undo.RegisterCompleteObjectUndo(this.cube, "cubemap blur");
            p.blur(this.cube, tempCube, this.HDR, this.HDR, linear);
            queuedPath = fullPath;
        }
开发者ID:elephantatwork,项目名称:Secret-Game,代码行数:21,代码来源:CubemapGUI.cs

示例15: clearCheckerCube

 public static void clearCheckerCube( ref Cubemap cube )
 {
     Color gray0 = new Color(0.25f,0.25f,0.25f,0.25f);
     Color gray1 = new Color(0.50f,0.50f,0.50f,0.25f);
     Color[] c = cube.GetPixels(CubemapFace.NegativeX);
     int w = cube.width;
     int sqw = Mathf.Max(1,w/4);	//width of square
     for( int face=0; face<6; ++face ) {
         for(int x=0; x<w; ++x)
         for(int y=0; y<w; ++y) {
             if(((x/sqw)%2) == ((y/sqw)%2))	c[y*w + x] = gray0;
             else 							c[y*w + x] = gray1;
         }
         cube.SetPixels(c, (CubemapFace)face);
     }
     cube.Apply(true);
 }
开发者ID:randydijkstra,项目名称:Oculus-Reality,代码行数:17,代码来源:Util.cs


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