Class for handling cube maps, Use this to create or modify existing.

Inheritance: Texture
Exemplo n.º 1
0
 static public int GetPixels(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             UnityEngine.Cubemap     self = (UnityEngine.Cubemap)checkSelf(l);
             UnityEngine.CubemapFace a1;
             checkEnum(l, 2, out a1);
             var ret = self.GetPixels(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 3)
         {
             UnityEngine.Cubemap     self = (UnityEngine.Cubemap)checkSelf(l);
             UnityEngine.CubemapFace a1;
             checkEnum(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             var ret = self.GetPixels(a1, a2);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
// fields

// properties
    static void Cubemap_mipmapCount(JSVCall vc)
    {
        UnityEngine.Cubemap _this = (UnityEngine.Cubemap)vc.csObj;
        var result = _this.mipmapCount;

        JSApi.setInt32((int)JSApi.SetType.Rval, (System.Int32)(result));
    }
Exemplo n.º 3
0
// fields

// properties
    static void Cubemap_format(JSVCall vc)
    {
        UnityEngine.Cubemap _this = (UnityEngine.Cubemap)vc.csObj;
        var result = _this.format;

        JSApi.setEnum((int)JSApi.SetType.Rval, (int)result);
    }
    public void OnGUI()
    {
        if ( m_Manager == null )
        {
            GUIHelpers.InfosArea( "There is no Nuaj' Manager to generate the cube map from !", GUIHelpers.INFOS_AREA_TYPE.ERROR );
            return;
        }

        // Ask for camera
        GUIHelpers.BeginHorizontal();
        GUIHelpers.EnableHorizontalGroups = false;
        m_Camera = GUIHelpers.SelectObject<GameObject>( new GUIContent( "Camera Object", "The object used to render the cube map from" ), m_Camera, null );
        if ( GUIHelpers.Button( new GUIContent( "Reset", "Resets the camera to the Nuaj' camera" ) ) )
            m_Camera = m_ManagerCamera;
        GUIHelpers.EnableHorizontalGroups = true;
        GUIHelpers.EndHorizontal();

        // Ask for scene filtering
        m_bRenderScene = GUIHelpers.CheckBox( new GUIContent( "Render Scene", "Shows or hides the scene in the cube map" ), m_bRenderScene, null );
        GUIHelpers.Separate();

        // Ask for target cube map
        m_CubeMap = GUIHelpers.SelectCubeMap( new GUIContent( "Target Cube Map", "Selects the target cube map to render to" ), m_CubeMap, null );

        GUIHelpers.Separate( 20 );

        using ( GUIHelpers.GUIEnabler( m_Camera != null && m_Camera.camera != null && m_CubeMap != null ) )
        {
            if ( GUIHelpers.Button( new GUIContent( "Render CubeMap" ) ) )
                Render();
        }
    }
Exemplo n.º 5
0
 static public int Apply(IntPtr l)
 {
     try{
         if (matchType(l, 2, typeof(bool), typeof(bool)))
         {
             UnityEngine.Cubemap self = (UnityEngine.Cubemap)checkSelf(l);
             System.Boolean      a1;
             checkType(l, 2, out a1);
             System.Boolean a2;
             checkType(l, 3, out a2);
             self.Apply(a1, a2);
             return(0);
         }
         else if (matchType(l, 2, typeof(bool)))
         {
             UnityEngine.Cubemap self = (UnityEngine.Cubemap)checkSelf(l);
             System.Boolean      a1;
             checkType(l, 2, out a1);
             self.Apply(a1);
             return(0);
         }
         else if (matchType(l, 2))
         {
             UnityEngine.Cubemap self = (UnityEngine.Cubemap)checkSelf(l);
             self.Apply();
             return(0);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
    public void UpdateCubemap(int faceMask = 63)
    {
        //if (!camera)
        //{
        //    //var go = new GameObject("CubemapCamera", typeof(Camera));
        //    //go.hideFlags = HideFlags.HideAndDontSave;
        //    //go.transform.position = transform.position;
        //    //go.transform.rotation = Quaternion.identity;
        //    //camera = go.camera;
        //    //cam.cullingMask = 1 << Layer.level;
        //    //cam.farClipPlane = 1000; // don't render very far into cubemap
        //    camera.enabled = false;
        //}

        if (!cubemap)
        {
            
            cubemap = new Cubemap(512, TextureFormat.RGB24, false);
#if UNITY_EDITOR
            UnityEditor.AssetDatabase.CreateAsset(cubemap, "Assets/cubemap.cubemap");
#endif
            //rtex.isCubemap = true;
            //rtex.hideFlags = HideFlags.HideAndDontSave;
            //renderer.sharedMaterial.SetTexture("_Cube", rtex);
        }

        //cam.transform.position = transform.position+Vector3.up*40;//Camera.main.transform.position;
        camera.RenderToCubemap(cubemap);
    }
Exemplo n.º 7
0
 public void capture(ref Cubemap targetCube, Transform at, bool HDR)
 {
     if( targetCube == null ) return;
     GameObject go = new GameObject("_temp_probe");
     go.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideAndDontSave;
     go.SetActive(true);
     Camera cam = go.AddComponent<Camera>();
     if( at != null ) {
         go.transform.position = at.position;
     }
     if(HDR) {
         Shader.EnableKeyword("MARMO_RGBM");
         Shader.DisableKeyword("MARMO_RGBA");
         Shader.SetGlobalFloat("_GlowStrength", 0f);
         Shader.SetGlobalFloat("_EmissionLM", 0f);
         cam.SetReplacementShader(Shader.Find("Hidden/Marmoset/RGBM Replacement"),"RenderType");
     }
     cam.RenderToCubemap(targetCube);
     targetCube.Apply(false);
     if(HDR) {
         cam.ResetReplacementShader();
         Shader.DisableKeyword("MARMO_RGBM");
         Shader.EnableKeyword("MARMO_RGBA");
     }
     GameObject.DestroyImmediate(go);
 }
Exemplo n.º 8
0
 static public int SetPixels(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 3)
         {
             UnityEngine.Cubemap self = (UnityEngine.Cubemap)checkSelf(l);
             UnityEngine.Color[] a1;
             checkType(l, 2, out a1);
             UnityEngine.CubemapFace a2;
             checkEnum(l, 3, out a2);
             self.SetPixels(a1, a2);
             return(0);
         }
         else if (argc == 4)
         {
             UnityEngine.Cubemap self = (UnityEngine.Cubemap)checkSelf(l);
             UnityEngine.Color[] a1;
             checkType(l, 2, out a1);
             UnityEngine.CubemapFace a2;
             checkEnum(l, 3, out a2);
             System.Int32 a3;
             checkType(l, 4, out a3);
             self.SetPixels(a1, a2, a3);
             return(0);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
    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");
    }
Exemplo n.º 10
0
 static public int GetPixels(IntPtr l)
 {
     try{
         if (matchType(l, 2, typeof(UnityEngine.CubemapFace), typeof(int)))
         {
             UnityEngine.Cubemap     self = (UnityEngine.Cubemap)checkSelf(l);
             UnityEngine.CubemapFace a1;
             checkEnum(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             UnityEngine.Color[] ret = self.GetPixels(a1, a2);
             pushValue(l, ret);
             return(1);
         }
         else if (matchType(l, 2, typeof(UnityEngine.CubemapFace)))
         {
             UnityEngine.Cubemap     self = (UnityEngine.Cubemap)checkSelf(l);
             UnityEngine.CubemapFace a1;
             checkEnum(l, 2, out a1);
             UnityEngine.Color[] ret = self.GetPixels(a1);
             pushValue(l, ret);
             return(1);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemplo n.º 11
0
 static public int SmoothEdges(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 1)
         {
             UnityEngine.Cubemap self = (UnityEngine.Cubemap)checkSelf(l);
             self.SmoothEdges();
             pushValue(l, true);
             return(1);
         }
         else if (argc == 2)
         {
             UnityEngine.Cubemap self = (UnityEngine.Cubemap)checkSelf(l);
             System.Int32        a1;
             checkType(l, 2, out a1);
             self.SmoothEdges(a1);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 12
0
    void Reset()
    {
        lastResetTime = System.DateTime.Now.ToString ();

        ambientEquatorColor = RenderSettings.ambientEquatorColor;
        ambientGroundColor = RenderSettings.ambientGroundColor;
        ambientIntensity = RenderSettings.ambientIntensity;
        ambientLight = RenderSettings.ambientLight;
        ambientMode = RenderSettings.ambientMode;
        ambientProbe = RenderSettings.ambientProbe;
        ambientSkyColor = RenderSettings.ambientSkyColor;
        customReflection = RenderSettings.customReflection;
        defaultReflectionMode = RenderSettings.defaultReflectionMode;
        defaultReflectionResolution = RenderSettings.defaultReflectionResolution;
        flareFadeSpeed = RenderSettings.flareFadeSpeed;
        flareStrength = RenderSettings.flareStrength;
        fog = RenderSettings.fog;
        fogColor = RenderSettings.fogColor;
        fogDensity = RenderSettings.fogDensity;
        fogEndDistance = RenderSettings.fogEndDistance;
        fogMode = RenderSettings.fogMode;
        fogStartDistance = RenderSettings.fogStartDistance;
        haloStrength = RenderSettings.haloStrength;
        reflectionBounces = RenderSettings.reflectionBounces;
        reflectionIntensity = RenderSettings.reflectionIntensity;
        skybox = RenderSettings.skybox;
    }
Exemplo n.º 13
0
 static public int SmoothEdges(IntPtr l)
 {
     try{
         if (matchType(l, 2, typeof(int)))
         {
             UnityEngine.Cubemap self = (UnityEngine.Cubemap)checkSelf(l);
             System.Int32        a1;
             checkType(l, 2, out a1);
             self.SmoothEdges(a1);
             return(0);
         }
         else if (matchType(l, 2))
         {
             UnityEngine.Cubemap self = (UnityEngine.Cubemap)checkSelf(l);
             self.SmoothEdges();
             return(0);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
        private void CopyTextureCube(string texturePath, Cubemap cubemap, BabylonTexture babylonTexture)
        {
            if (!babylonScene.AddTextureCube(texturePath))
            {
                return;
            }

            try
            {
                foreach (CubemapFace face in Enum.GetValues(typeof(CubemapFace)))
                {
                    var faceTexturePath = Path.Combine(babylonScene.OutputPath, Path.GetFileNameWithoutExtension(texturePath));

                    switch (face)
                    {
                        case CubemapFace.PositiveX:
                            faceTexturePath += "_px.jpg";
                            break;
                        case CubemapFace.NegativeX:
                            faceTexturePath += "_nx.jpg";
                            break;
                        case CubemapFace.PositiveY:
                            faceTexturePath += "_py.jpg";
                            break;
                        case CubemapFace.NegativeY:
                            faceTexturePath += "_ny.jpg";
                            break;
                        case CubemapFace.PositiveZ:
                            faceTexturePath += "_pz.jpg";
                            break;
                        case CubemapFace.NegativeZ:
                            faceTexturePath += "_nz.jpg";
                            break;
                        default:
                            continue;
                    }

                    var tempTexture = new Texture2D(cubemap.width, cubemap.height, TextureFormat.RGB24, false);

                    tempTexture.SetPixels(cubemap.GetPixels(face));
                    tempTexture.Apply();

                    // Flip faces in cube texture.
                    tempTexture = FlipTexture(tempTexture);

                    File.WriteAllBytes(faceTexturePath, tempTexture.EncodeToJPG());
                }

            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            var textureName = Path.GetFileNameWithoutExtension(texturePath);
            babylonTexture.name = textureName;
            babylonTexture.isCube = true;
            babylonTexture.level = exportationOptions.ReflectionDefaultLevel;
            babylonTexture.coordinatesMode = 3;
        }
Exemplo n.º 15
0
		public static void CreateSubMips(Cubemap cube) {
			AssetDatabase.StartAssetEditing();
			int faceSize = cube.width;
			string cubePath = AssetDatabase.GetAssetPath(cube);

			//load all sub-assets
			UnityEngine.Object[] mips = AssetDatabase.LoadAllAssetRepresentationsAtPath(cubePath);
			if(mips != null) {
				for(int i=0; i<mips.Length; ++i) {
					if( mips[i] != null && AssetDatabase.IsSubAsset(mips[i]) ) UnityEngine.Object.DestroyImmediate(mips[i], true);
				}
			}
			AssetDatabase.Refresh();

			// skip mip level 0, its in the cubemap itself
			faceSize = faceSize >> 1;
			for( int mip = 1; faceSize > 0; ++mip ) {
				// extract mipmap faces from a cubemap and add them as textures in the sub image
				Texture2D tex = new Texture2D(faceSize, faceSize*6,TextureFormat.ARGB32,false);
				tex.name = "mip"+mip;
				for( int face = 0; face<6; ++face ) {
					tex.SetPixels(0, face*faceSize, faceSize, faceSize, cube.GetPixels((CubemapFace)face,mip));
				}
				tex.Apply();
				AssetDatabase.AddObjectToAsset(tex, cubePath);
				AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(tex));
				faceSize = faceSize >> 1;
			}
			AssetDatabase.StopAssetEditing();
			AssetDatabase.Refresh();
		}
Exemplo n.º 16
0
        public void Initialize(float landMinHeight, float landMaxHeight, float oceanHeight, Cubemap landHeightmap)
        {
            Material mat = renderer.sharedMaterial;
            mat.SetVector("_MinMaxHeight_OceanHeight", new Vector4(landMinHeight, landMaxHeight, oceanHeight, 0.0f));

            //mat.SetTexture("_LandCube", planet.renderer.sharedMaterial.GetTexture("_LandCube"));
            mat.SetTexture("_LandCube", landHeightmap);
        }
Exemplo n.º 17
0
	void Awake () 
	{
		material = GetComponent<Renderer>().material;
		cubemap = (Cubemap)material.GetTexture("_Cube");
		rendererArray = GetComponentsInChildren<Renderer>();
		rotation = material.GetFloat("_Rotation");
		bookArray = GetComponentsInChildren<Book>();
	}
Exemplo n.º 18
0
        public void InitializeMaterial(int size, float minHeight, float maxHeight, float sandPercentage)
        {
            Material mat = renderer.sharedMaterial;

            Heightmap = mat.GetTexture("_LandCube") as Cubemap;

            mat.SetFloat("_InvLandDetail", 1.0f / size);
            mat.SetVector("_MinMaxHeight_SandPercentage", new Vector4(minHeight, maxHeight, sandPercentage, 0.0f));
        }
Exemplo n.º 19
0
 void Update() 
 {
     m_CurrMaterial = renderer.sharedMaterial;
     if (m_CurrMaterial) 
     {
         m_MapCurr = CheckDistance();
         m_CurrMaterial.SetTexture("_Cubemap", m_MapCurr);
     }
 }
    public static void ExtractSkybox()
    {
        RenderSettings.skybox = null;

        // get the camera reference.
        Camera cameraObj = GameObject.Find ("AGF_CameraManager").GetComponent<AGF_CameraManager>().GetMainCamera();
        AGF_AtmosphereManager atmosphereManager = GameObject.Find ("AGF_AtmosphereManager").GetComponent<AGF_AtmosphereManager>();

        if(cameraObj.GetComponent<Skybox>().material.GetTexture("_Tex") == null)
            return;

        // step 1: create the target directory, if necessary.
        string targetDirectory = Main.TrimEndFromString( Application.dataPath, "Assets" ) + sourceFolder + "/" + sceneFolder + "/Skyboxes";
        if ( Directory.Exists( targetDirectory ) == false ){
            Directory.CreateDirectory( targetDirectory );
        }

        // step 2: clear the old files, if they exist.
        if ( File.Exists( targetDirectory + "/skyboxCubemap.cubemap" ) ){
            AssetDatabase.DeleteAsset( sourceFolder + "/skyboxCubemap.cubemap" );
        }
        if ( File.Exists( targetDirectory + "/skyboxMaterial.mat" ) ){
            AssetDatabase.DeleteAsset( sourceFolder + "/skyboxMaterial.mat" );
        }

        // step 3: copy over the cubemap from the camera.
        Cubemap cubemapReference = (Cubemap)cameraObj.GetComponent<Skybox>().material.GetTexture("_Tex");
        Cubemap skyboxCubemap = new Cubemap(cubemapReference.width, TextureFormat.RGB24, false);

        EditorUtility.CopySerialized( cubemapReference, skyboxCubemap );

        // step 4: create the cubemap asset.
        AssetDatabase.CreateAsset( skyboxCubemap, sourceFolder + "/" + sceneFolder + "/Skyboxes/skyboxCubemap.cubemap" );
        //		AssetDatabase.ImportAsset( sourceFolder + "/" + sceneFolder + "/Skyboxes/skyboxCubemap.cubemap" );

        // step 5: Create a temporary material, and link it up to the cubemap.
        Material skyboxMaterial = new Material( cameraObj.GetComponent<Skybox>().material );
        skyboxMaterial.SetTexture( "_Tex", (Cubemap)AssetDatabase.LoadAssetAtPath(sourceFolder + "/" + sceneFolder + "/Skyboxes/skyboxCubemap.cubemap", typeof(Cubemap) ) );

        // step 6: create the material asset.
        AssetDatabase.CreateAsset( skyboxMaterial, sourceFolder + "/" + sceneFolder + "/Skyboxes/skyboxMaterial.mat" );
        //		AssetDatabase.ImportAsset( sourceFolder + "/" + sceneFolder + "/Skyboxes/skyboxMaterial.mat" );

        // Now that both the cubemap and material have been created, assign the material into the camera.
        cameraObj.GetComponent<Skybox>().material = (Material)AssetDatabase.LoadAssetAtPath( sourceFolder + "/" + sceneFolder + "/Skyboxes/skyboxMaterial.mat", typeof(Material) );

        // In addition, we need to add another camera script to control the skybox rotation, etc.
        if ( cameraObj.GetComponent<AGF_SkyboxRotator>() == null ){
            cameraObj.gameObject.AddComponent<AGF_SkyboxRotator>();
        }
        cameraObj.gameObject.GetComponent<AGF_SkyboxRotator>().autoRotate = atmosphereManager.GetCurrentSkybox().autoRotate;
        cameraObj.gameObject.GetComponent<AGF_SkyboxRotator>().autoRotationSpeed = atmosphereManager.GetCurrentSkybox().autoRotationSpeed;
        cameraObj.gameObject.GetComponent<AGF_SkyboxRotator>().rotation = atmosphereManager.GetCurrentSkybox().rotation;
        cameraObj.gameObject.GetComponent<AGF_SkyboxRotator>().tint = atmosphereManager.GetCurrentSkybox().tint;

        EditorUtility.SetDirty( cameraObj.gameObject );
    }
Exemplo n.º 21
0
        public static void BuildSurfaceMesh(ref MeshPlane mesh, ref Random rand)
        {
            var brush = Resources.Load("PlanetBuilding/SurfaceBrush");

            if (brush == null)
            {
                Debug.LogError("Unable to load basic brush prefab");
                return;
            }

            var rampTex = Resources.Load("Textures/PlanetRamp") as Texture;

            if (rampTex == null)
            {
                Debug.LogError("Unable to load planet colour ramp");
                return;
            }

            // Apply brush texture somehow
            // * 0.1f
            float brushBaseSize = 1.0f;
            float brushSizeLarge = brushBaseSize * 0.2f;
            float brushSizeSmall = brushBaseSize * 0.02f;

            for (int i = 0; i < rand.Next(25, 75); ++i)
            {
                var go = (GameObject.Instantiate(brush) as GameObject);

                var ch = go.transform.GetChild(0);
                var brushScale = (float)(brushSizeSmall + (rand.NextDouble() * brushSizeLarge));
                ch.localScale = new Vector3(brushScale, brushScale, brushScale);

                go.transform.SetParent(mesh.transform);
                go.transform.Rotate(
                    (float)rand.NextDouble() * 360.0f,
                    (float)rand.NextDouble() * 360.0f,
                    (float)rand.NextDouble() * 360.0f
                    );
            }

            var localCam = mesh.gameObject.AddComponent<Camera>();
            localCam.cullingMask = PlanetBrushLayer;
            localCam.fieldOfView = 90;
            localCam.backgroundColor = Color.black;

            Cubemap c = new Cubemap(2048, TextureFormat.ARGB32, false);
            localCam.RenderToCubemap(c);

            mesh.GetComponent<Renderer>().material.SetTexture("_Tex", c);
            mesh.GetComponent<Renderer>().material.SetTexture("_PlanetRamp", rampTex);

            Component.Destroy(localCam);
             			foreach ( Transform ch in mesh.transform ){
             				GameObject.Destroy(ch.gameObject);
             			}
        }
 public void CancelSelection()
 {
     this.m_SelectedCubemap = null;
     this.m_SelectedCubemapInfo = null;
     this.m_SelectedShadowCubemapOwnerInfo = null;
     this.m_SelectedLightIconIndex = -1;
     this.m_SelectedShadowInfo = null;
     this.m_HoveringCubeMapIndex = -1;
     this.m_DragBeingPerformed = false;
 }
Exemplo n.º 23
0
	void Update(){
		if (ShaderSandwich.Instance==null)
		Close();

		#if UNITY_5
		defaultBackCube = ShaderSandwich.DayCube;
		#else
		defaultBackCube = ShaderSandwich.KitchenCube;
		#endif
	}
Exemplo n.º 24
0
        public static Cubemap Make(Camera camera)
        {
            Cubemap cmap = new Cubemap(4096, TextureFormat.ARGB32, false);

            if (camera.RenderToCubemap(cmap))
            {

                return cmap;
            }

            return null;
        }
Exemplo n.º 25
0
 static public int get_format(IntPtr l)
 {
     try {
         UnityEngine.Cubemap self = (UnityEngine.Cubemap)checkSelf(l);
         pushValue(l, true);
         pushEnum(l, (int)self.format);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 26
0
 static public int get_mipmapCount(IntPtr l)
 {
     try {
         UnityEngine.Cubemap self = (UnityEngine.Cubemap)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.mipmapCount);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 27
0
    static bool Camera_RenderToCubemap__Cubemap(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 1)
        {
            UnityEngine.Cubemap arg0 = (UnityEngine.Cubemap)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(((UnityEngine.Camera)vc.csObj).RenderToCubemap(arg0)));
        }

        return(true);
    }
Exemplo n.º 28
0
        private UnityEngine.Cubemap renderSky()
        {
            UnityEngine.Cubemap cubemap = new UnityEngine.Cubemap(1024, TextureFormat.ARGB32, false);
            cubemap.name = "Sky";
            GameObject go = new GameObject("CubemapCamera");

            UnityEngine.Camera camera = go.AddComponent <UnityEngine.Camera>();
            camera.cullingMask = 0;
            camera.RenderToCubemap(cubemap);
            GameObject.DestroyImmediate(go);
            return(cubemap);
        }
Exemplo n.º 29
0
 static public int get_format(IntPtr l)
 {
     try {
         UnityEngine.Cubemap self = (UnityEngine.Cubemap)checkSelf(l);
         pushEnum(l, (int)self.format);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemplo n.º 30
0
 static public int constructor(IntPtr l)
 {
     UnityEngine.Cubemap o;
     System.Int32        a1;
     checkType(l, 2, out a1);
     UnityEngine.TextureFormat a2;
     checkEnum(l, 3, out a2);
     System.Boolean a3;
     checkType(l, 4, out a3);
     o = new UnityEngine.Cubemap(a1, a2, a3);
     pushObject(l, o);
     return(1);
 }
 static void RenderSettings_customReflection(JSVCall vc)
 {
     if (vc.bGet)
     {
         var result = UnityEngine.RenderSettings.customReflection;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.Cubemap arg0 = (UnityEngine.Cubemap)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.RenderSettings.customReflection = arg0;
     }
 }
Exemplo n.º 32
0
 public static void Initialize()
 {
     m_ZeroAmbientProbe.Clear();
     if (m_SkyboxMaterial == null)
     {
         m_SkyboxMaterial = new Material(Shader.Find("Skybox/Cubemap"));
     }
     if (m_ScreenQuadMesh == null)
     {
         m_ScreenQuadMesh = new Mesh();
         m_ScreenQuadMesh.vertices = new Vector3[] { new Vector3(-1f, -1f, 0f), new Vector3(1f, 1f, 0f), new Vector3(1f, -1f, 0f), new Vector3(-1f, 1f, 0f) };
         m_ScreenQuadMesh.triangles = new int[] { 0, 1, 2, 1, 0, 3 };
     }
     if (m_GBufferPatchMaterial == null)
     {
         m_GBufferPatchMaterial = new Material(EditorGUIUtility.LoadRequired("LookDevView/GBufferWhitePatch.shader") as Shader);
         m_DrawBallsMaterial = new Material(EditorGUIUtility.LoadRequired("LookDevView/GBufferBalls.shader") as Shader);
     }
     if (m_LookDevCompositing == null)
     {
         m_LookDevCompositing = new Material(EditorGUIUtility.LoadRequired("LookDevView/LookDevCompositing.shader") as Shader);
     }
     if (m_DeferredOverlayMaterial == null)
     {
         m_DeferredOverlayMaterial = EditorGUIUtility.LoadRequired("SceneView/SceneViewDeferredMaterial.mat") as Material;
     }
     if (m_DefaultHDRI == null)
     {
         m_DefaultHDRI = EditorGUIUtility.Load("LookDevView/DefaultHDRI.exr") as Cubemap;
         if (m_DefaultHDRI == null)
         {
             m_DefaultHDRI = EditorGUIUtility.Load("LookDevView/DefaultHDRI.asset") as Cubemap;
         }
     }
     if (m_LookDevCubeToLatlong == null)
     {
         m_LookDevCubeToLatlong = new Material(EditorGUIUtility.LoadRequired("LookDevView/LookDevCubeToLatlong.shader") as Shader);
     }
     if (m_SelectionTexture == null)
     {
         m_SelectionTexture = new RenderTexture(250, 0x7d, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
     }
     if (m_BrightestPointRT == null)
     {
         m_BrightestPointRT = new RenderTexture(250, 0x7d, 0, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Default);
     }
     if (m_BrightestPointTexture == null)
     {
         m_BrightestPointTexture = new Texture2D(250, 0x7d, TextureFormat.RGBAHalf, false);
     }
 }
 void createPlaceHolderCube()
 {
     if( PlaceHolderCube == null ) {
         PlaceHolderCube = new Cubemap(16,TextureFormat.ARGB32,true);
         for(int face = 0; face < 6; face++) {
             for(int x = 0; x < 16; x++) {
                 for(int y = 0; y < 16; y++) {
                     PlaceHolderCube.SetPixel((CubemapFace)face, x, y, Color.black);
                 }
             }
         }
         PlaceHolderCube.Apply(true);
     }
 }
Exemplo n.º 34
0
        public override void Draw()
        {
            GUILayout.BeginVertical();
            GUILayout.Label( "Default:" );
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            _defaultTexture = (DefaultTextureType)EditorGUILayout.EnumPopup( _defaultTexture );
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            previewTexture = (Cubemap)EditorGUILayout.ObjectField( previewTexture, typeof(Cubemap), new[] { GUILayout.Width (60), GUILayout.Height (60) });
            GUILayout.EndVertical();
        }
Exemplo n.º 35
0
    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();
    }
Exemplo n.º 36
0
        public void capture(ref Cubemap targetCube, Transform at)
        {
            if( targetCube == null ) return;
            GameObject go = new GameObject("_temp_probe");
            go.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideAndDontSave;
            go.SetActive(true);
            Camera cam = go.AddComponent<Camera>();
            if( at != null ) {
                go.transform.position = at.position;
            }

            cam.RenderToCubemap(targetCube);
            targetCube.Apply(false);

            GameObject.DestroyImmediate(go);
        }
Exemplo n.º 37
0
        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();
        }
Exemplo n.º 38
0
    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;
    }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.Cubemap o;
			System.Int32 a1;
			checkType(l,2,out a1);
			UnityEngine.TextureFormat a2;
			checkEnum(l,3,out a2);
			System.Boolean a3;
			checkType(l,4,out a3);
			o=new UnityEngine.Cubemap(a1,a2,a3);
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
        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();
        }
Exemplo n.º 41
0
    public static void AttachSkyboxCubemapRecursively( Transform t, Cubemap cubemap )
    {
        foreach ( Transform child in t ){
            if ( child == t.transform ){
                continue;
            }

            AttachSkyboxCubemapRecursively( child, cubemap );
        }

        if ( t.GetComponent<Renderer>() ){
            for (int i = 0; i < t.GetComponent<Renderer>().sharedMaterials.Length; i++){
                if ( t.GetComponent<Renderer>().sharedMaterials[i].HasProperty("_Cube") ){
                    t.GetComponent<Renderer>().sharedMaterials[i].SetTexture("_Cube", cubemap);
                }
            }
        }
    }
    void Update()
    {
        if (Environment != boundEnvironment) {
            Shader.SetGlobalTexture("_GlobalEnvironment", Environment);
            boundEnvironment = Environment;
        }

        if (ConvolutedEnvironment != boundConvolutedEnvironment) {
            if (ConvolutedEnvironment) {
                Shader.SetGlobalTexture("_GlobalConvolutedEnvironment", ConvolutedEnvironment);
                Shader.SetGlobalFloat("_GlobalConvolutedEnvironmentMipmapCount", (float)(ConvolutedEnvironment.mipmapCount - 2));
            } else {
                Shader.SetGlobalTexture("_GlobalConvolutedEnvironment", null);
                Shader.SetGlobalFloat("_GlobalConvolutedEnvironmentMipmapCount", 0.0f);
            }
            boundEnvironment = Environment;
        }
    }
Exemplo n.º 43
0
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.Cubemap o;
         System.Int32 a1;
         checkType(l,2,out a1);
         UnityEngine.TextureFormat a2;
         checkEnum(l,3,out a2);
         System.Boolean a3;
         checkType(l,4,out a3);
         o=new UnityEngine.Cubemap(a1,a2,a3);
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
Exemplo n.º 44
0
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.Cubemap o;
     if (matchType(l, 1, typeof(int), typeof(UnityEngine.TextureFormat), typeof(bool)))
     {
         System.Int32 a1;
         checkType(l, 1, out a1);
         UnityEngine.TextureFormat a2;
         checkEnum(l, 2, out a2);
         System.Boolean a3;
         checkType(l, 3, out a3);
         o = new UnityEngine.Cubemap(a1, a2, a3);
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
Exemplo n.º 45
0
 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);
     }
 }
Exemplo n.º 46
0
 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));
     }
 }
Exemplo n.º 47
0
 public void OnGUI()
 {
     GUILayout.Label("Choose the Cubemap you want to split into 6 images", EditorStyles.boldLabel);
     EditorGUILayout.Space();
     splitCube = EditorGUILayout.ObjectField("Cubemap:", splitCube, typeof(Cubemap), false) as Cubemap;
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     if (GUILayout.Button("Split Cubemap"))
     {
         if (splitCube)
         {
             Split();
         }
         if (!splitCube)
         {
             ExporterWindow.ShowMessage("You must select a cubemap");
         }
     }
 }
Exemplo n.º 48
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.Cubemap o;
         System.Int32        a1;
         checkType(l, 2, out a1);
         UnityEngine.TextureFormat a2;
         checkEnum(l, 3, out a2);
         System.Boolean a3;
         checkType(l, 4, out a3);
         o = new UnityEngine.Cubemap(a1, a2, a3);
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    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();
    }
Exemplo n.º 50
0
 static public int SetPixels(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 5)
         {
             UnityEngine.Cubemap self = (UnityEngine.Cubemap)checkSelf(l);
             UnityEngine.Color[] a1;
             checkArray(l, 3, out a1);
             UnityEngine.CubemapFace a2;
             checkEnum(l, 4, out a2);
             System.Int32 a3;
             checkType(l, 5, out a3);
             self.SetPixels(a1, a2, a3);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 4)
         {
             UnityEngine.Cubemap self = (UnityEngine.Cubemap)checkSelf(l);
             UnityEngine.Color[] a1;
             checkArray(l, 3, out a1);
             UnityEngine.CubemapFace a2;
             checkEnum(l, 4, out a2);
             self.SetPixels(a1, a2);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 51
0
 public bool RenderToCubemap(Cubemap cubemap, [UnityEngine.Internal.DefaultValue("63")] int faceMask)
 {
     return(this.Internal_RenderToCubemapTexture(cubemap, faceMask));
 }
Exemplo n.º 52
0
 public bool RenderToCubemap(Cubemap cubemap, [DefaultValue("63")] int faceMask)
 {
     return(Internal_RenderToCubemapTexture(cubemap, faceMask));
 }
Exemplo n.º 53
0
 private bool Internal_RenderToCubemapTexture(Cubemap cubemap, int faceMask)
 {
     throw new NotImplementedException("なにこれ");
 }
Exemplo n.º 54
0
        public bool RenderToCubemap(Cubemap cubemap)
        {
            int faceMask = 63;

            return(this.RenderToCubemap(cubemap, faceMask));
        }
Exemplo n.º 55
0
 extern private static bool Internal_CreateImpl([Writable] Cubemap mono, int ext, int mipCount, GraphicsFormat format, TextureCreationFlags flags, IntPtr nativeTex);
Exemplo n.º 56
0
 private static extern void Internal_Create([Writable] Cubemap mono, int size, TextureFormat format, bool mipmap);
Exemplo n.º 57
0
 private static extern void INTERNAL_CALL_SetPixel(Cubemap self, CubemapFace face, int x, int y, ref Color color);
Exemplo n.º 58
0
 public bool RenderToCubemap(Cubemap cubemap)
 {
     return(RenderToCubemapImpl(cubemap, 63));
 }
Exemplo n.º 59
0
 public bool RenderToCubemap(Cubemap cubemap, int faceMask)
 {
     return(RenderToCubemapImpl(cubemap, faceMask));
 }
Exemplo n.º 60
0
 private extern bool Internal_RenderToCubemapTexture(Cubemap cubemap, int faceMask);