コード例 #1
0
		public RenderTargetSetup(RenderBuffer color, RenderBuffer depth, int mipLevel, CubemapFace face)
		{
			this = new RenderTargetSetup(new RenderBuffer[]
			{
				color
			}, depth, mipLevel, face);
		}
コード例 #2
0
 public RenderTargetSetup(RenderBuffer[] color, RenderBuffer depth, int mip, CubemapFace face, RenderBufferLoadAction[] colorLoad, RenderBufferStoreAction[] colorStore, RenderBufferLoadAction depthLoad, RenderBufferStoreAction depthStore)
 {
   this.color = color;
   this.depth = depth;
   this.mipLevel = mip;
   this.cubemapFace = face;
   this.colorLoad = colorLoad;
   this.colorStore = colorStore;
   this.depthLoad = depthLoad;
   this.depthStore = depthStore;
 }
コード例 #3
0
ファイル: CtBeholder.cs プロジェクト: Zulkir/Beholder
 public static int ArrayIndex(CubemapFace cubemapFace)
 {
     switch (cubemapFace)
     {
         case CubemapFace.PositiveX: return 0;
         case CubemapFace.NegativeX: return 1;
         case CubemapFace.PositiveY: return 2;
         case CubemapFace.NegativeY: return 3;
         case CubemapFace.PositiveZ: return 4;
         case CubemapFace.NegativeZ: return 5;
         default: throw new ArgumentOutOfRangeException("cubemapFace");
     }
 }
コード例 #4
0
ファイル: CubeMapper.cs プロジェクト: imclab/CubeMapRenderer
    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();
    }
コード例 #5
0
ファイル: CubeMapper.cs プロジェクト: imclab/CubeMapRenderer
    void BeginCubeFaceRender(Cubemap target, CubemapFace f, int mipLevel, Camera cam)
    {
        // create temp texture, assign it to camera
        // figure out the size
        int size = target.width >> mipLevel;
        cam.targetTexture = RenderTexture.GetTemporary(size,size,16);

        // configure fov
        //cam.fieldOfView = 90;
        float edgeScale = 0.5f; // adjust this for your GPU
        cam.fieldOfView = 90+90f / (float)size*edgeScale;

        // point camera in right direction
        Matrix4x4 viewMat = SetOrthoNormalBasicInverse(kCubemapOrthoBases[(int)f*3+0], kCubemapOrthoBases[(int)f*3+1],kCubemapOrthoBases[(int)f*3+2]);
        Matrix4x4 translateMat = Matrix4x4.TRS (-cam.transform.position, Quaternion.identity, Vector3.one);
        cam.worldToCameraMatrix = viewMat*translateMat;
    }
コード例 #6
0
 public static Color FaceToColor(CubemapFace face)
 {
     switch (face) {
     case CubemapFace.PositiveX:
         return new Color(1,0,0);
     case CubemapFace.NegativeX:
         return new Color(0,1,1);
     case CubemapFace.PositiveY:
         return new Color(0,1,0);
     case CubemapFace.NegativeY:
         return new Color(1,0,1);
     case CubemapFace.PositiveZ:
         return new Color(0,0,1);
     case CubemapFace.NegativeZ:
         return new Color(1,1,0);
     }
     return new Color(0,0,0); // Shaddap compiler
 }
コード例 #7
0
	public void SaveRenderTexture( RenderTexture texture, Cubemap cube, CubemapFace face, bool flipX = false, bool flipY = true ) {
		RenderTexture.active = texture;
		// read render target
		Texture2D texture_ = new Texture2D(m_TextureSize, m_TextureSize, TextureFormat.ARGB32, false);
		texture_.ReadPixels( new Rect(0, 0, m_TextureSize, m_TextureSize), 0, 0);
		texture_.Apply ();
		// flip
		if (flipY) {
			for (int x = 0; x < m_TextureSize; x++) {
				for (int y1 = 0, y2 = m_TextureSize-1; y1 < y2; y1++, y2--) {
					Color t1 = texture_.GetPixel (x, y1);
					texture_.SetPixel (x, y1, texture_.GetPixel (x, y2));
					texture_.SetPixel (x, y2, t1);
				}
			}
		}
		texture_.Apply ();
		if (flipX) {
			for (int x1 = 0, x2 = m_TextureSize-1; x1 < x2; x1++, x2--) {
				for (int y = 0; y < m_TextureSize; y++) {
					Color t1 = texture_.GetPixel (x1, y);
					texture_.SetPixel (x1, y, texture_.GetPixel (x2, y));
					texture_.SetPixel (x2, y, t1);
				}
			}
		}
		texture_.Apply ();
		if (m_saveImage) {
			byte[] bytes = texture_.EncodeToPNG();
			string[] path_ = EditorApplication.currentScene.Split(char.Parse("/"));
			path_[path_.Length -1] = filename+"_"+face.ToString()+".png";
			System.IO.File.WriteAllBytes(string.Join("/", path_), bytes);
		}
		// save to cubemap
		cube.SetPixels (texture_.GetPixels (), face);
		cube.Apply ();
		DestroyImmediate(texture_);
		
		RenderTexture.active = null;
	}
コード例 #8
0
    private static Color[] GetPixels(Cubemap c, CubemapFace f)
    {
        var pixels = c.GetPixels(f);
        var halfH  = c.height / 2;

        for (var y = 0; y < halfH; y++)
        {
            var o = c.width * y;
            var n = c.width * (c.height - y - 1);

            for (var x = 0; x < c.width; x++)
            {
                var a = pixels[o + x];
                var b = pixels[n + x];

                pixels[o + x] = b;
                pixels[n + x] = a;
            }
        }

        return pixels;
    }
コード例 #9
0
 public void SetPixel(CubemapFace face, int x, int y, Color color)
 {
     INTERNAL_CALL_SetPixel(this, face, x, y, ref color);
 }
コード例 #10
0
	IEnumerator Capture(Cubemap cubemap,CubemapFace face,Camera cam)
	{
		var width = Screen.width;
		var height = Screen.height;

		Texture2D tex = new Texture2D(height, height, TextureFormat.ARGB32, false);
		int cubeSize = cubemap.height;
		
		cam.transform.localRotation = Rotation(face);
		
		yield return new WaitForEndOfFrame();

		tex.ReadPixels(new Rect((width-height)/2, 0, height, height), 0, 0);
		tex.Apply();
		tex = Resize(tex, cubeSize,cubeSize,false);

		Color cubeCol;
		for (int y = 0; y < cubeSize; y++)
		{
			for (int x = 0; x < cubeSize; x++)
			{

				cubeCol = tex.GetPixel(cubeSize + x, (cubeSize - 1) - y);

				cubemap.SetPixel(face, x, y, cubeCol);

			}
		}

		cubemap.Apply();

		DestroyImmediate(tex);
	}
コード例 #11
0
 private static extern void INTERNAL_CALL_SetPixel(Cubemap self, CubemapFace face, int x, int y, ref Color color);
コード例 #12
0
ファイル: Cubemap.cs プロジェクト: randomize/VimConfig
 public void SetPixels(Color[] colors, CubemapFace face)
 {
     int miplevel = 0;
     this.SetPixels(colors, face, miplevel);
 }
コード例 #13
0
 internal static void SetRenderTargetImpl(RenderTexture rt, int mipLevel, CubemapFace face)
 {
   if ((bool) ((Object) rt))
     Graphics.SetRenderTargetImpl(rt.colorBuffer, rt.depthBuffer, mipLevel, face);
   else
     Graphics.Internal_SetNullRT();
 }
コード例 #14
0
ファイル: HDUtils.cs プロジェクト: pball1000/FPS-Template
 public static void SetRenderTarget(CommandBuffer cmd, HDCamera camera, RTHandleSystem.RTHandle buffer, ClearFlag clearFlag = ClearFlag.None, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown, int depthSlice = 0)
 {
     SetRenderTarget(cmd, camera, buffer, clearFlag, CoreUtils.clearColorAllBlack, miplevel, cubemapFace, depthSlice);
 }
コード例 #15
0
ファイル: Cubemap.cs プロジェクト: randomize/VimConfig
 public Color[] GetPixels(CubemapFace face)
 {
     int miplevel = 0;
     return this.GetPixels(face, miplevel);
 }
コード例 #16
0
 bool IsCubemapFaceEnabled(CubemapFace face)
 {
     return((cubemapFaceMask & (1 << (int)face)) != 0);
 }
コード例 #17
0
ファイル: HDUtils.cs プロジェクト: pball1000/FPS-Template
 // This set of RenderTarget management methods is supposed to be used when rendering into a camera dependent render texture.
 // This will automatically set the viewport based on the camera size and the RTHandle scaling info.
 public static void SetRenderTarget(CommandBuffer cmd, HDCamera camera, RTHandleSystem.RTHandle buffer, ClearFlag clearFlag, Color clearColor, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown, int depthSlice = 0)
 {
     cmd.SetRenderTarget(buffer, miplevel, cubemapFace, depthSlice);
     SetViewportAndClear(cmd, camera, buffer, clearFlag, clearColor);
 }
コード例 #18
0
        public Color32[] GetPixels32(CubemapFace face, int arrayElement)
        {
            int miplevel = 0;

            return(GetPixels32(face, arrayElement, miplevel));
        }
コード例 #19
0
 extern public Color32[] GetPixels32(CubemapFace face, int arrayElement, [uei.DefaultValue("0")]  int miplevel);
コード例 #20
0
        public void SetPixels32(Color32[] colors, CubemapFace face, int arrayElement)
        {
            int miplevel = 0;

            SetPixels32(colors, face, arrayElement, miplevel);
        }
コード例 #21
0
    private Patch GeneratePatch(Patch parent, CubemapFace face, int level, int quadrant, Vector2 cornerLocal, Vector3 corner, Vector3 axis1, Vector3 axis2)
    {
        var patchResolution2 = patchResolution + 1;
        var positions        = new Vector3[patchResolution2 * patchResolution2];
        var uv0s             = new Vector2[patchResolution2 * patchResolution2];
        var uv1s             = new Vector2[patchResolution2 * patchResolution2];
        var normals          = new Vector3[patchResolution2 * patchResolution2];
        var tangents         = new Vector4[patchResolution2 * patchResolution2];

        var axis1Step = axis1 / patchResolution;
        var axis2Step = axis2 / patchResolution;
        var uvSCorner = (cornerLocal * 0.5f + new Vector2(0.5f, 0.5f));
        var uv1Corner = uvSCorner;
        var uvSStep   = ((levelSize[level] * 0.5f) / patchResolution);
        var uv1Step   = uvSStep;

        for (var z = 0; z < patchResolution2; z++)
        {
            for (var x = 0; x < patchResolution2; x++)
            {
                var vertexIndex = z * patchResolution2 + x;

                // Calculate stuff
                var position0 = (corner + axis1Step *  x      + axis2Step *  z     ).normalized;
                var position1 = (corner + axis1Step * (x + 1) + axis2Step *  z     ).normalized;
                var position2 = (corner + axis1Step *  x      + axis2Step * (z + 1)).normalized;
                var position  = position0;

                var displacement0   = 0.0f;
                var displacement1   = 0.0f;
                var displacement2   = 0.0f;
                var displacementUV0 = Vector2.zero;

                switch (DisplacementConfiguration)
                {
                    case SGT_SurfaceConfiguration.Sphere:
                    {
                        var texture = displacementTexture.GetTexture2D(0);

                        displacementUV0 = SGT_Helper.CartesianToPolarUV(position0);

                        if (texture != null)
                        {
                            var pixelUV         = SGT_Helper.PixelUV(texture);
                            var displacementUV1 = SGT_Helper.CartesianToPolarUV(position1);
                            var displacementUV2 = SGT_Helper.CartesianToPolarUV(position2);

                            displacementUV0.y = SGT_Helper.ClampUV(displacementUV0.y, pixelUV.y);
                            displacementUV1.y = SGT_Helper.ClampUV(displacementUV1.y, pixelUV.y);
                            displacementUV2.y = SGT_Helper.ClampUV(displacementUV2.y, pixelUV.y);

                            displacement0 = texture.GetPixelBilinear(displacementUV0.x, displacementUV0.y).r;
                            displacement1 = texture.GetPixelBilinear(displacementUV1.x, displacementUV1.y).r;
                            displacement2 = texture.GetPixelBilinear(displacementUV2.x, displacementUV2.y).r;
                        }
                    }
                    break;
                    case SGT_SurfaceConfiguration.Cube:
                    {
                        var face0    = SGT_Helper.CubeFace(position0);
                        var face1    = SGT_Helper.CubeFace(position1);
                        var face2    = SGT_Helper.CubeFace(position2);
                        var texture0 = displacementTexture.GetTexture2D(face0);
                        var texture1 = displacementTexture.GetTexture2D(face1);
                        var texture2 = displacementTexture.GetTexture2D(face2);

                        displacementUV0 = SGT_Helper.CubeUV(face0, position0, true);

                        if (texture0 != null)
                        {
                            displacement0 = texture0.GetPixelBilinear(displacementUV0.x, displacementUV0.y).r;
                        }

                        if (texture1 != null)
                        {
                            var displacementUV1 = SGT_Helper.CubeUV(face1, position1, true);

                            displacement1 = texture1.GetPixelBilinear(displacementUV1.x, displacementUV1.y).r;
                        }

                        if (texture2 != null)
                        {
                            var displacementUV2 = SGT_Helper.CubeUV(face2, position2, true);

                            displacement2 = texture2.GetPixelBilinear(displacementUV2.x, displacementUV2.y).r;
                        }
                    }
                    break;
                }

                position0 *= Mathf.Lerp(scaleMin, scaleMax, displacement0);
                position1 *= Mathf.Lerp(scaleMin, scaleMax, displacement1);
                position2 *= Mathf.Lerp(scaleMin, scaleMax, displacement2);

                var vec1 = (position1 - position0).normalized;
                var vec2 = (position2 - position0).normalized;

                // Write vertex data
                positions[vertexIndex] = position0;
                normals[vertexIndex]   = Vector3.Cross(vec2, vec1);
                tangents[vertexIndex]  = SGT_Helper.NewVector4(-vec2, 1.0f);

                if (DisplacementConfiguration == surfaceConfiguration)
                {
                    switch (surfaceConfiguration)
                    {
                        case SGT_SurfaceConfiguration.Sphere: uv0s[vertexIndex] = displacementUV0;                         break;
                        case SGT_SurfaceConfiguration.Cube:   uv0s[vertexIndex] = SGT_Helper.CubeUV(face, position, true); break;
                    }
                }
                else
                {
                    switch (surfaceConfiguration)
                    {
                        case SGT_SurfaceConfiguration.Sphere: uv0s[vertexIndex] = SGT_Helper.CartesianToPolarUV(position0); break;
                        case SGT_SurfaceConfiguration.Cube:   uv0s[vertexIndex] = SGT_Helper.CubeUV(face, position0, true); break;
                    }
                }

                uv1s[vertexIndex] = uv1Corner + new Vector2(uv1Step * x, uv1Step * z);
            }
        }

        // Remove wrapping seam
        if (surfaceConfiguration == SGT_SurfaceConfiguration.Sphere)
        {
            var indices = patchIndices[0];

            for (var i = 0; i < indices.Length; i += 3)
            {
                var index1 = indices[i + 0];
                var index2 = indices[i + 1];
                var index3 = indices[i + 2];
                var mid    = (positions[index1] + positions[index2] + positions[index3]) / 3.0f;

                if (mid.x < 0.0f && mid.z < 0.0f)
                {
                    for (var j = 0; j < 3; j++)
                    {
                        var index = indices[i + j];
                        var pos   = positions[index];

                        if (pos.z < 0.0f && Mathf.Approximately(pos.x, 0.0f) == true)
                        {
                            uv0s[index].x = 1.0f;
                        }
                    }
                }
            }
        }

        var bounds = new Bounds(positions[0], Vector3.zero);

        for (var i = 1; i < patchResolution2 * patchResolution2; i++)
        {
            bounds.Encapsulate(positions[i]);
        }

        var patch = new Patch();

        patch.parent      = parent;
        patch.face        = face;
        patch.level       = level;
        patch.quadrant    = quadrant;
        patch.cornerLocal = cornerLocal;
        patch.corner      = corner;
        patch.axis1       = axis1;
        patch.axis2       = axis2;
        patch.positions   = positions;
        patch.uv0s        = uv0s;
        patch.uv1s        = uv1s;
        patch.normals     = normals;
        patch.tangents    = tangents;
        patch.bounds      = bounds;

        return patch;
    }
コード例 #22
0
ファイル: HDUtils.cs プロジェクト: pball1000/FPS-Template
        public static void SetRenderTarget(CommandBuffer cmd, HDCamera camera, RTHandleSystem.RTHandle colorBuffer, RTHandleSystem.RTHandle depthBuffer, ClearFlag clearFlag, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown, int depthSlice = 0)
        {
            int cw = colorBuffer.rt.width;
            int ch = colorBuffer.rt.height;
            int dw = depthBuffer.rt.width;
            int dh = depthBuffer.rt.height;

            Debug.Assert(cw == dw && ch == dh);

            SetRenderTarget(cmd, camera, colorBuffer, depthBuffer, clearFlag, CoreUtils.clearColorAllBlack, miplevel, cubemapFace, depthSlice);
        }
コード例 #23
0
 private static extern void INTERNAL_CALL_GetPixel(Cubemap self, CubemapFace face, int x, int y, out Color value);
コード例 #24
0
 public static void SetRenderTarget(CommandBuffer cmd, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthBuffer, ClearFlag clearFlag, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown)
 {
     SetRenderTarget(cmd, colorBuffer, depthBuffer, clearFlag, clearColorAllBlack, miplevel, cubemapFace);
 }
コード例 #25
0
ファイル: Cubemap.cs プロジェクト: randomize/VimConfig
 private static extern void INTERNAL_CALL_SetPixel(Cubemap self, CubemapFace face, int x, int y, ref Color color);
コード例 #26
0
        public static void SetRenderTarget(CommandBuffer cmd, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthBuffer, ClearFlag clearFlag, Color clearColor, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown)
        {
            cmd.SetRenderTarget(colorBuffer, depthBuffer, miplevel, cubemapFace);

            if (clearFlag != ClearFlag.None)
            {
                cmd.ClearRenderTarget((clearFlag & ClearFlag.Depth) != 0, (clearFlag & ClearFlag.Color) != 0, clearColor);
            }
        }
コード例 #27
0
 private static extern void Internal_SetMRTFullSetup(RenderBuffer[] colorSA, out RenderBuffer depth, int mip, CubemapFace face, RenderBufferLoadAction[] colorLoadSA, RenderBufferStoreAction[] colorStoreSA, RenderBufferLoadAction depthLoad, RenderBufferStoreAction depthStore);
コード例 #28
0
 public static void SetRenderTarget(CommandBuffer cmd, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthBuffer, ClearFlag clearFlag, Color clearColor, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown, int depthSlice = 0)
 {
     cmd.SetRenderTarget(colorBuffer, depthBuffer, miplevel, cubemapFace, depthSlice);
     ClearRenderTarget(cmd, clearFlag, clearColor);
 }
コード例 #29
0
 /// <summary>
 ///   <para>Sets current render target.</para>
 /// </summary>
 /// <param name="setup"></param>
 /// <param name="rt"></param>
 /// <param name="mipLevel"></param>
 /// <param name="face"></param>
 /// <param name="colorBuffer"></param>
 /// <param name="depthBuffer"></param>
 /// <param name="colorBuffers"></param>
 public static void SetRenderTarget(RenderTexture rt, int mipLevel, CubemapFace face)
 {
   Graphics.SetRenderTargetImpl(rt, mipLevel, face);
 }
コード例 #30
0
 // This set of RenderTarget management methods is supposed to be used when rendering into a camera dependent render texture.
 // This will automatically set the viewport based on the camera size and the RTHandle scaling info.
 public static void SetRenderTarget(CommandBuffer cmd, RTHandle buffer, ClearFlag clearFlag, Color clearColor, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown, int depthSlice = -1)
 {
     // We use -1 as a default value because when doing SPI for XR, it will bind the full texture array by default (and has no effect on 2D textures)
     // Unfortunately, for cubemaps, passing -1 does not work for faces other than the first one, so we fall back to 0 in this case.
     if (depthSlice == -1 && buffer.rt.dimension == TextureDimension.Cube)
     {
         depthSlice = 0;
     }
     cmd.SetRenderTarget(buffer, miplevel, cubemapFace, depthSlice);
     SetViewportAndClear(cmd, buffer, clearFlag, clearColor);
 }
コード例 #31
0
	Quaternion Rotation(CubemapFace face)
	{
		Quaternion result;
		switch(face)
		{
		case CubemapFace.PositiveX:
			result = Quaternion.Euler(0, 90, 0);
			break;
		case CubemapFace.NegativeX:
			result = Quaternion.Euler(0, -90, 0);
			break;
		case CubemapFace.PositiveY:
			result = Quaternion.Euler(-90, 0, 0);
			break;
		case CubemapFace.NegativeY:
			result = Quaternion.Euler(90, 0, 0);
			break;
		case CubemapFace.NegativeZ:
			result = Quaternion.Euler(0, 180, 0);
			break;
		default:
			result = Quaternion.Euler(0, 0, 0);
			break;
		}
		return result;
	}
コード例 #32
0
 public static void SetRenderTarget(CommandBuffer cmd, RTHandle buffer, ClearFlag clearFlag = ClearFlag.None, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown, int depthSlice = -1)
 => SetRenderTarget(cmd, buffer, clearFlag, Color.clear, miplevel, cubemapFace, depthSlice);
コード例 #33
0
 extern public void SetPixels(Color[] colors, CubemapFace face, int arrayElement, [uei.DefaultValue("0")]  int miplevel);
コード例 #34
0
        public static void SetRenderTarget(CommandBuffer cmd, RTHandle colorBuffer, RTHandle depthBuffer, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown, int depthSlice = -1)
        {
            int cw = colorBuffer.rt.width;
            int ch = colorBuffer.rt.height;
            int dw = depthBuffer.rt.width;
            int dh = depthBuffer.rt.height;

            Debug.Assert(cw == dw && ch == dh);

            SetRenderTarget(cmd, colorBuffer, depthBuffer, ClearFlag.None, Color.clear, miplevel, cubemapFace, depthSlice);
        }
コード例 #35
0
		public void SetPixels(Color[] colors, CubemapFace face){}
コード例 #36
0
        public static void SetRenderTarget(CommandBuffer cmd, RTHandle colorBuffer, RTHandle depthBuffer, ClearFlag clearFlag, Color clearColor, int miplevel = 0, CubemapFace cubemapFace = CubemapFace.Unknown, int depthSlice = -1)
        {
            int cw = colorBuffer.rt.width;
            int ch = colorBuffer.rt.height;
            int dw = depthBuffer.rt.width;
            int dh = depthBuffer.rt.height;

            Debug.Assert(cw == dw && ch == dh);

            CoreUtils.SetRenderTarget(cmd, colorBuffer.rt, depthBuffer.rt, miplevel, cubemapFace, depthSlice);
            SetViewportAndClear(cmd, colorBuffer, clearFlag, clearColor);
        }
コード例 #37
0
    private static void SaveCubemapFace(Cubemap c, CubemapFace f, string path)
    {
        var pixels  = GetPixels(c, f);
        var texture = new Texture2D(c.width, c.height);
        var fPath   = path + "_" + f + ".png";//AssetDatabase.GenerateUniqueAssetPath(path + "_" + f + ".png");

        texture.SetPixels(pixels);
        texture.Apply();

        SaveTexture(texture, fPath);

        SgtHelper.Destroy(texture);

        Debug.Log("Saved cubemap face to: " + fPath);
    }
コード例 #38
0
 extern private static void Internal_SetRTSimple(RenderBuffer color, RenderBuffer depth, int mip, CubemapFace face, int depthSlice);
コード例 #39
0
 /// <summary>
 ///   <para>Returns pixel color at coordinates (face, x, y).</para>
 /// </summary>
 /// <param name="face"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 public Color GetPixel(CubemapFace face, int x, int y)
 {
   Color color;
   Cubemap.INTERNAL_CALL_GetPixel(this, face, x, y, out color);
   return color;
 }
コード例 #40
0
 extern private static void Internal_SetMRTSimple([NotNull] RenderBuffer[] color, RenderBuffer depth, int mip, CubemapFace face, int depthSlice);
コード例 #41
0
ファイル: Cubemap.cs プロジェクト: randomize/VimConfig
 public extern Color GetPixel(CubemapFace face, int x, int y);
コード例 #42
0
 extern private static void Internal_SetMRTFullSetup(
     [NotNull] RenderBuffer[] color, RenderBuffer depth, int mip, CubemapFace face, int depthSlice,
     [NotNull] RenderBufferLoadAction[] colorLA, [NotNull] RenderBufferStoreAction[] colorSA,
     RenderBufferLoadAction depthLA, RenderBufferStoreAction depthSA
     );
コード例 #43
0
ファイル: Cubemap.cs プロジェクト: randomize/VimConfig
 public extern Color[] GetPixels(CubemapFace face, [DefaultValue("0")] int miplevel);
コード例 #44
0
 public RenderTargetSetup(RenderBuffer[] color, RenderBuffer depth, int mip, CubemapFace face)
 {
     this = new RenderTargetSetup(color, depth, mip, face, RenderTargetSetup.LoadActions(color), RenderTargetSetup.StoreActions(color), depth.loadAction, depth.storeAction);
 }
コード例 #45
0
ファイル: Cubemap.cs プロジェクト: randomize/VimConfig
 public void SetPixel(CubemapFace face, int x, int y, Color color)
 {
     INTERNAL_CALL_SetPixel(this, face, x, y, ref color);
 }
コード例 #46
0
 public RenderTargetSetup(RenderBuffer color, RenderBuffer depth, int mipLevel, CubemapFace face)
 {
     this = new RenderTargetSetup(new RenderBuffer[]
     {
         color
     }, depth, mipLevel, face);
 }
コード例 #47
0
ファイル: Cubemap.cs プロジェクト: randomize/VimConfig
 public extern void SetPixels(Color[] colors, CubemapFace face, [DefaultValue("0")] int miplevel);
コード例 #48
0
ファイル: Graphics.cs プロジェクト: zhxhxlzt/UnityCsReference
 public RenderTargetSetup(RenderBuffer color, RenderBuffer depth, int mipLevel, CubemapFace face, int depthSlice)
     : this(new RenderBuffer[] { color }, depth, mipLevel, face)
 {
     this.depthSlice = depthSlice;
 }
コード例 #49
0
 private static extern void Internal_SetMRTSimple(RenderBuffer[] colorSA, out RenderBuffer depth, int mip, CubemapFace face);
コード例 #50
0
ファイル: Graphics.cs プロジェクト: zhxhxlzt/UnityCsReference
 public RenderTargetSetup(RenderBuffer[] color, RenderBuffer depth, int mip, CubemapFace face)
     : this(color, depth, mip, face, LoadActions(color), StoreActions(color), depth.loadAction, depth.storeAction)
 {
 }
コード例 #51
0
 internal static void SetRenderTargetImpl(RenderBuffer[] colorBuffers, RenderBuffer depthBuffer, int mipLevel, CubemapFace face)
 {
   RenderBuffer depth = depthBuffer;
   Graphics.Internal_SetMRTSimple(colorBuffers, out depth, mipLevel, face);
 }
コード例 #52
0
 public extern Color GetPixel(CubemapFace face, int x, int y);
コード例 #53
0
 /// <summary>
 ///   <para>Sets current render target.</para>
 /// </summary>
 /// <param name="setup"></param>
 /// <param name="rt"></param>
 /// <param name="mipLevel"></param>
 /// <param name="face"></param>
 /// <param name="colorBuffer"></param>
 /// <param name="depthBuffer"></param>
 /// <param name="colorBuffers"></param>
 public static void SetRenderTarget(RenderBuffer colorBuffer, RenderBuffer depthBuffer, int mipLevel, CubemapFace face)
 {
   Graphics.SetRenderTargetImpl(colorBuffer, depthBuffer, mipLevel, face);
 }
コード例 #54
0
        public Color[] GetPixels(CubemapFace face)
        {
            int miplevel = 0;

            return(GetPixels(face, miplevel));
        }
コード例 #55
0
	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);
	}
コード例 #56
0
 extern public Color[] GetPixels(CubemapFace face, [uei.DefaultValue("0")]  int miplevel);
コード例 #57
0
    /// <summary>
    /// Save unity cubemap into NPOT 6x1 cubemap/texture atlas in the following format PX NX PY NY PZ NZ
    /// </summary>
    /// <description>
    /// Supported format: PNG/JPG
    /// Default file name: using current time OVR_hh_mm_ss.png 
    /// </description>
    public static bool SaveCubemapCapture(Cubemap cubemap, string pathName = null)
    {
        string fileName;
        string dirName;
        int width = cubemap.width;
        int height = cubemap.height;
        int x = 0;
        int y = 0;
        bool saveToPNG = true;

        if (string.IsNullOrEmpty(pathName))
        {
            dirName = Application.persistentDataPath + "/OVR_ScreenShot360/";
            fileName = null;
        }
        else
        {
            dirName = Path.GetDirectoryName(pathName);
            fileName = Path.GetFileName(pathName);

            if (dirName[dirName.Length - 1] != '/' || dirName[dirName.Length - 1] != '\\')
                dirName += "/";
        }

        if (string.IsNullOrEmpty(fileName))
            fileName = "OVR_" + System.DateTime.Now.ToString("hh_mm_ss") + ".png";

        string extName = Path.GetExtension(fileName);
        if (extName == ".png")
        {
            saveToPNG = true;
        }
        else if (extName == ".jpg")
        {
            saveToPNG = false;
        }
        else
        {
            Debug.LogError("Unsupported file format" + extName);
            return false;
        }

        // Validate path
        DirectoryInfo dirInfo;
        try
        {
            dirInfo = System.IO.Directory.CreateDirectory(dirName);
        }
        catch (System.Exception e)
        {
            Debug.LogError("Failed to create path " + dirName + " since " + e.ToString());
            return false;
        }

        // Create the new texture
        Texture2D tex = new Texture2D(width * 6, height, TextureFormat.RGB24, false);
        if (tex == null)
        {
            Debug.LogError("[OVRScreenshotWizard] Failed creating the texture!");
            return false;
        }

        // Merge all the cubemap faces into the texture
        // Reference cubemap format: http://docs.unity3d.com/Manual/class-Cubemap.html
        CubemapFace[] faces = new CubemapFace[] { CubemapFace.PositiveX, CubemapFace.NegativeX, CubemapFace.PositiveY, CubemapFace.NegativeY, CubemapFace.PositiveZ, CubemapFace.NegativeZ };
        for (int i = 0; i < faces.Length; i++)
        {
            // get the pixels from the cubemap
            Color[] srcPixels = null;
            Color[] pixels = cubemap.GetPixels(faces[i]);
            // if desired, flip them as they are ordered left to right, bottom to top
            srcPixels = new Color[pixels.Length];
            for (int y1 = 0; y1 < height; y1++)
            {
                for (int x1 = 0; x1 < width; x1++)
                {
                    srcPixels[y1 * width + x1] = pixels[((height - 1 - y1) * width) + x1];
                }
            }
            // Copy them to the dest texture
            tex.SetPixels(x, y, width, height, srcPixels);
            x += width;
        }

        try
        {
            // Encode the texture and save it to disk
            byte[] bytes = saveToPNG ? tex.EncodeToPNG() : tex.EncodeToJPG();

            System.IO.File.WriteAllBytes(dirName + fileName, bytes);
            Debug.Log("Cubemap file created " + dirName + fileName);
        }
        catch (System.Exception e)
        {
            Debug.LogError("Failed to save cubemap file since " + e.ToString());
            return false;
        }

        DestroyImmediate(tex);
        return true;
    }
コード例 #58
0
 public extern void SetPixels(Color[] colors, CubemapFace face, [DefaultValue("0")] int miplevel);
コード例 #59
0
ファイル: Graphics.cs プロジェクト: zhxhxlzt/UnityCsReference
 internal static void SetRenderTargetImpl(RenderBuffer colorBuffer, RenderBuffer depthBuffer, int mipLevel, CubemapFace face, int depthSlice)
 {
     Internal_SetRTSimple(colorBuffer, depthBuffer, mipLevel, face, depthSlice);
 }
コード例 #60
0
        public void SetPixels(Color[] colors, CubemapFace face)
        {
            int miplevel = 0;

            SetPixels(colors, face, miplevel);
        }