블로그 이미지
Every unexpected event is a path to learning for you. blueasa

카테고리

분류 전체보기 (2794)
Unity3D (852)
Programming (478)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (185)
협업 (11)
3DS Max (3)
Game (12)
Utility (68)
Etc (98)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (55)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday

LightMapSize 조절

Unity3D/LightMap / 2014. 3. 18. 09:44
using UnityEditor; 

public class LightMapSize_512 : EditorWindow 
{ 
    [MenuItem("LightMapSize/Size_512")] 
    static void Init() 
    { 
        LightmapEditorSettings.maxAtlasHeight = 512; 
        LightmapEditorSettings.maxAtlasWidth = 512; 
    } 
} 

public class LightMapSize_1024 : EditorWindow 
{ 
    [MenuItem("LightMapSize/Size_1024")] 
    static void Init() 
    { 
        LightmapEditorSettings.maxAtlasHeight = 1024; 
        LightmapEditorSettings.maxAtlasWidth = 1024; 
    } 
} 

public class LightMapSize_2048 : EditorWindow 
{ 
    [MenuItem("LightMapSize/Size_2048")] 
    static void Init() 
    { 
        LightmapEditorSettings.maxAtlasHeight = 2048; 
        LightmapEditorSettings.maxAtlasWidth = 2048; 
    } 
} 

public class LightMapSize_4096 : EditorWindow 
{ 
    [MenuItem("LightMapSize/Size_4096")] 
    static void Init() 
    { 
        LightmapEditorSettings.maxAtlasHeight = 4096; 
        LightmapEditorSettings.maxAtlasWidth = 4096; 
    } 
} 
출처 : http://devkorea.co.kr/bbs/board.php?bo_table=m03_qna&wr_id=43889&page=0&sca=&sfl=&stx=&spt=0&page=0&currentId=44#c_43910


반응형
Posted by blueasa
, |


Install "Lightmapping Extended":

Step 1 is to pick up "Lightmapping Extended" on the Unity Asset Store! and commit it into the project!https://www.assetstore.unity3d.com/#/content/6071

While most of the settings are a bit beyond pick up and play, the ability to save and load xml configurations is a life saver and if you are working with a team it can really speed up the workflow. There are great tool tips for the rest of the settings. Without a formal lighting background I make do with what I have and search for what I don't know.

Document Changes:

Despite knowing and saving your production settings with Lightmapping Extended, when dialing in a light setup I take screenshots of the editor and the light map settings panel. This lets me get good before and after images documented when I make subtle changes to the overall settings. It also lets me show others how the system works and how the scene has evolved.

UV scale / ratio fine tuning:

After I get my main light sources in and where I want them I run a high quality bake so I can see where major shadows fall. Armed with this I can manually select all prefabs that are 100% within shadow and set their "Scale in Lightmap" setting down to .1 - .05. Once you have done this to all relevant objects you can do the reverse for 'hero' objects. Unfortunately you often want to increase the light map resolution on large objects such as the ground, and depending on how the geometry is split up the UV block might be too big and bulky to do too much with. (Currently Unity 4.1 does a terrible job auto laying out UV's - according to this thread that should be resolved in 4.2)

Maximize your resolution within your output targets:

Once I have all the manual light map scaling in place I then nuke my settings back down to a 10-20 second render time and start inching the resolution up or down to get everything at my desired output target. We often want to get everything onto 1 1024 map (which we can still cut down later). I want the scene to look as good as it can be - even if it means spending an hour bumping up the resolution by .01!

Editing the light map .exr file:

While my options are limited I from time to time do bring in the final .exr image into Photoshop for some slight level adjustments Note that doing this will probably hose you if you need to do dual light map realtime lighting. Photoshop is pretty limited in what you can do to a 32 channel image however I do have a work around for solidifying unity's output if I feel the image will benefit form it. since you can't use the magic wand with a tolerance of 1 to select out and delete the black I save off a version with 16 channels, save a selection of what I want to delete and load it back into the 32 bit file, delete out the black and run Solidify A on it to blend in the image. I am 100% sure there is an easier way to do this - I just have no experience editing HDR files, let alone 16bit in photoshop.

Wishes:

I would LOVE to be able to set what I want my output to be and have Unity fill in the rest. I usually have to spend an hour or two over the course of a scene setup fine tuning the atlas resolution trying to get it all onto 1 1024 map for instance. This changes and needs to be re-optimized every time you manually set a scale override on something in your scene (which I have the tendency to do quite often!)

Additionally I would LOVE to have some sort of automated workflow occur where I could set up a stationary camera that takes the same screenshot after every bake and splices in the settings data as well!

That's all for now, hope this saves somebody some time!




출처 http://mkingery.com/blog/unity-lightmapping-tips-tricks-and-thoughts

반응형

'Unity3D > LightMap' 카테고리의 다른 글

[펌] Unity 5 lightmapped scene assetbundle problem  (0) 2017.04.19
유니티5 라이트 맵 팁  (0) 2015.06.19
LightMapSize 조절  (0) 2014.03.18
Posted by blueasa
, |

파일을 열 때 에러가 났다는 것인데 파일이 존재함에도 불구하고 에러가 난 것입니다.  

이런 경우는 해당 파일이 다른 프로세스에서 사용중이기 때문에 나옵니다.  

그래서 원본 파일을 템프 파일에 복사한 후 원본이 아닌 복사본을 열어버리고.. 나중에 다시 템프 파일을 삭제해 버리는 것이죠. 

 

                        string fileTemp = fileFullNm + "_tmp";
                        File.Copy(fileFullNm, fileTemp, true);

                        //다른프로세서가 사용중인것을 방지
                        FileStream fs = new FileStream(fileTemp, FileMode.Open);

 

                        ~~~~

                        File.Delete(fileTemp);

 

 

 

[출처] C# 다른 프로세스가 사용중이라면서 에러가 나는경우에 이렇게|작성자 doghole

 

C# 다른 프로세스가 사용중이라면서 에러가 나는경우에 이렇게

파일을 열 때 에러가 났다는 것인데 파일이 존재함에도 불구하고 에러가 난 것입니다. 이런 경우는...

blog.naver.com

 

반응형

'Programming > C#' 카테고리의 다른 글

C# Excel Tutorial  (0) 2014.03.26
C# 에서 Excel 로 데이터 기록 및 읽기 [OleDB]  (46) 2014.03.25
제네릭(Generic)과 제약조건  (0) 2014.03.13
Reading Excel Files in C#  (0) 2014.03.12
C# 의 Shift 비트 연산 정리  (0) 2013.12.18
Posted by blueasa
, |


링크 : http://smilejsu.tistory.com/576

반응형
Posted by blueasa
, |


링크 : http://istudy.tistory.com/75

반응형
Posted by blueasa
, |



링크 : http://warmz.tistory.com/365

반응형
Posted by blueasa
, |


Link : http://forum.codecall.net/topic/71788-reading-excel-files-in-c/

반응형

'Programming > C#' 카테고리의 다른 글

[펌] 다른 프로세스가 사용중이라면서 에러가 나는경우에 이렇게  (4) 2014.03.17
제네릭(Generic)과 제약조건  (0) 2014.03.13
C# 의 Shift 비트 연산 정리  (0) 2013.12.18
Copy List to List  (0) 2013.10.10
Sorting  (0) 2013.10.02
Posted by blueasa
, |

Platform Dependent Compilation

Unity includes a feature named "Platform Dependent Compilation". This consists of some preprocessor directives that let you partition your scripts to compile and execute a section of code exclusively for one of the supported platforms.

Furthermore, you can run this code within the Editor, so you can compile the code specifically for your mobile/console and test it in the Editor!

Platform Defines

The platform defines that Unity supports for your scripts are:

UNITY_EDITORDefine for calling Unity Editor scripts from your game code.
UNITY_STANDALONE_OSXPlatform define for compiling/executing code specifically for Mac OS (This includes Universal, PPC and Intel architectures).
UNITY_DASHBOARD_WIDGETPlatform define when creating code for Mac OS dashboard widgets.
UNITY_STANDALONE_WINUse this when you want to compile/execute code for Windows stand alone applications.
UNITY_STANDALONE_LINUXUse this when you want to compile/execute code for Linux stand alone applications.
UNITY_STANDALONEUse this to compile/execute code for any standalone platform (Mac, Windows or Linux).
UNITY_WEBPLAYERPlatform define for web player content (this includes Windows and Mac Web player executables).
UNITY_WIIPlatform define for compiling/executing code for the Wii console.
UNITY_IPHONEPlatform define for compiling/executing code for the iPhone platform.
UNITY_ANDROIDPlatform define for the Android platform.
UNITY_PS3Platform define for running PlayStation 3 code.
UNITY_XBOX360Platform define for executing Xbox 360 code.
UNITY_NACLPlatform define when compiling code for Google native client (this will be set additionally to UNITY_WEBPLAYER).
UNITY_FLASHPlatform define when compiling code for Adobe Flash.
UNITY_BLACKBERRYPlatform define for a Blackberry10 device.
UNITY_WP8Platform define for Windows Phone 8.
UNITY_METROPlatform define for Windows Store Apps (additionally NETFX_CORE is defined when compiling C# files against .NET Core).
UNITY_WINRTEquivalent to UNITY_WP8 | UNITY_METRO

Also you can compile code selectively depending on the version of the engine you are working on. Currently the supported ones are:

UNITY_2_6Platform define for the major version of Unity 2.6.
UNITY_2_6_1Platform define for specific version 1 from the major release 2.6.
UNITY_3_0Platform define for the major version of Unity 3.0.
UNITY_3_0_0Platform define for the specific version 0 of Unity 3.0.
UNITY_3_1Platform define for major version of Unity 3.1.
UNITY_3_2Platform define for major version of Unity 3.2.
UNITY_3_3Platform define for major version of Unity 3.3.
UNITY_3_4Platform define for major version of Unity 3.4.
UNITY_3_5Platform define for major version of Unity 3.5.
UNITY_4_0Platform define for major version of Unity 4.0.
UNITY_4_0_1Platform define for major version of Unity 4.0.1.
UNITY_4_1Platform define for major version of Unity 4.1.
UNITY_4_2Platform define for major version of Unity 4.2.

Note: For versions before 2.6.0 there are no platform defines as this feature was first introduced in that version.

Testing precompiled code.

We are going to show a small example of how to use the precompiled code. This will simply print a message that depends on the platform you have selected to build your target.

First of all, select the platform you want to test your code against by clicking on File -> Build Settings. This will bring the build settings window to select your target platform.


Build Settings window with the WebPlayer Selected as Target platform.

Select the platform you want to test your precompiled code against and press the Switch Editor button to tell Unity which platform you are targeting.

Create a script and copy/paste this code:-

// JS
function Awake() {
  #if UNITY_EDITOR
    Debug.Log("Unity Editor");
  #endif

  #if UNITY_IPHONE
    Debug.Log("Iphone");
  #endif

  #if UNITY_STANDALONE_OSX
    Debug.Log("Stand Alone OSX");
  #endif

  #if UNITY_STANDALONE_WIN
    Debug.Log("Stand Alone Windows");
  #endif	
}


// C#
using UnityEngine;
using System.Collections;

public class PlatformDefines : MonoBehaviour {
  void Start () {

    #if UNITY_EDITOR
      Debug.Log("Unity Editor");
    #endif

    #if UNITY_IPHONE
      Debug.Log("Iphone");
    #endif

    #if UNITY_STANDALONE_OSX
	Debug.Log("Stand Alone OSX");
    #endif

    #if UNITY_STANDALONE_WIN
      Debug.Log("Stand Alone Windows");
    #endif

  }			   
}


// Boo
import UnityEngine

class PlatformDefines (MonoBehaviour): 

	def Start ():
		ifdef UNITY_EDITOR:
			Debug.Log("Unity Editor")

		ifdef UNITY_IPHONE:
			Debug.Log("IPhone")

		ifdef UNITY_STANDALONE_OSX:
			Debug.Log("Stand Alone OSX")

		ifdef not UNITY_IPHONE:
			Debug.Log("not an iPhone")

Then, depending on which platform you selected, one of the messages will get printed on the Unity console when you press play.

Note that in c# you can use a CONDITIONAL attribute which is a more clean, less error-prone way of stripping out functions, see http://msdn.microsoft.com/en-us/library/4xssyw96.aspx.

In addition to the basic #if compiler directive, you can also use a multiway test in C# and JavaScript:-

#if UNITY_EDITOR
    Debug.Log("Unity Editor");
#elif UNITY_IPHONE
    Debug.Log("Unity iPhone");
#else
    Debug.Log("Any other platform");
#endif

However, Boo currently supports only the ifdef directive.

Platform Custom Defines

It is also possible to add to the built-in selection of defines by supplying your own. In the Other Settings panel of the Player Settings, you will see the Scripting Define Symbols textbox.

Here, you can enter the names of the symbols you want to define for that particular platform, separated by semicolons. These symbols can then be used as the conditions for #if directives just like the built-in ones.

Global Custom Defines

You can define your own preprocessor directives to control which code gets included when compiling. To do this you must add a text file with the extra directives to the "Assets/" folder. The name of the file depends on the language you are using, and the extension is .rsp:

C#<Project Path>/Assets/smcs.rsp
C# - Editor Scripts<Project Path>/Assets/gmcs.rsp
UnityScript<Project Path>/Assets/us.rsp
Boo<Project Path>/Assets/boo.rsp

As an example, if you include the single line "-define:UNITY_DEBUG" in your smcs.rsp file the define UNITY_DEBUG will exist as a global define for C# scripts, except for Editor scripts.

Every time you make changes to .rsp files you will need to recompile for them to be effective. You can do this by updating or reimporting a single script (.js, .cs or .boo) file.

If you want to modify only global defines, you should use Scripting Define Symbols in Player Settings, because this will cover all the compilers. If you choose the .rsp files instead, you'll have to provide one file for every compiler Unity uses, and you won't know when one or another compiler is used.

The use of the .rsp files is described in the help section of the smcs application which is included in the Editor installation folder. You can get more information by running "smcs -help". Also, bear in mind the .rsp file needs to match the compiler being invoked. For example, when targeting the web player, smcs is used with smcs.rsp; when targeting standalone players, gmcs is used with gmcs.rsp; when targeting MS compiler, csc is used with csc.rsp; and so on.


출처 : https://docs.unity3d.com/Documentation/Manual/PlatformDependentCompilation.html

반응형

'Unity3D > Script' 카테고리의 다른 글

어플을 내렸을때, 어플을 종료할때의 처리  (3) 2014.04.04
Unity Singleton  (0) 2014.03.24
Generic Based Singleton for MonoBehaviours完全版(?)  (0) 2014.03.05
Singleton  (0) 2014.03.05
Serializable, NonSerialized  (0) 2013.07.30
Posted by blueasa
, |

Unity AssetBundle Dependencies

In the last few weeks I’ve spent quite a lot of time with Unity’s Asset Bundle system. Understanding how dependencies were tracked. What determines GC cleanup of assets and understanding why the editor profiler produces particular results has been a bit of a struggle. I’m lucky enough to work for a group that allows me to have access to the Unity source code however so this has probably been slightly less painful than it has been for others going down this same path.

First, I’d like to acknowledge what appears to be the most useful piece of Unity Answers information that I’ve come across, located here. This seems to explain the general mechanics of how to include dependencies using the push and then pop method in an editor script.

For my purposes, I created a test project that contained several prefabs all containing simple GUI elements. These elements all used the same fonts and referenced the same textures. This was to verify that, in the editor profiler and in instruments, assets were in fact being shared.

I’ve included my example editor script below to demonstrate some of the methods I used for packing the bundles. In my case, I am traversing all assets in my prefab folder and treating elements with the word “Global” in their name as shared. If I were to have many dependency bundles instead of the one that I have in this example I would have to sort the order in which I am packing these bundles.

using UnityEngine;
using UnityEditor;

using System.IO;
using System.Collections.Generic;

public class AssetBundleBuild : MonoBehaviour
{
    [MenuItem("AssetBundle/Build Bundles")]
    private static void BuildBundles()
    {
        DirectoryInfo directory = new DirectoryInfo(Application.dataPath + "/Prefabs");
        FileInfo[] files = directory.GetFiles("*.prefab", SearchOption.AllDirectories);

        bool shouldPush;

        BuildPipeline.PushAssetDependencies();
        foreach (FileInfo f in files)
        {
            shouldPush = !f.Name.Contains("Global");
            if (shouldPush)
            {
                BuildPipeline.PushAssetDependencies();
            }

            // Get each asset path
            string path = Application.dataPath + "/Bundles/" + f.Name.Substring(0, f.Name.LastIndexOf(".")) + ".bundle";
            string assetPath = f.FullName.Substring(f.FullName.IndexOf("Assets", f.FullName.Length - f.FullName.IndexOf("Assets")));

            Object asset = AssetDatabase.LoadMainAssetAtPath(assetPath);
            //Debug.Log("Asset to pack " + asset + " , " + asset.name);

            BuildAssetBundleOptions options = 
                BuildAssetBundleOptions.DisableWriteTypeTree | 
                BuildAssetBundleOptions.CollectDependencies | 
                BuildAssetBundleOptions.CompleteAssets | 
                BuildAssetBundleOptions.DeterministicAssetBundle;

            if (!shouldPush)
            {
                Object[] d = EditorUtility.CollectDependencies(new Object[] { asset });

                List<Object> dSource = new List<Object>();
                List<string> dNames = new List<string>();

                // In this case I'm attempting to manually collect dependencies for tracking purposes
                // however this does not always seem to be necessary unless you have complex prefab heirarchies
                foreach (Object o in d)
                {
                    if (o != null && !dSource.Contains(o))
                    {
                        Debug.Log(" -- d " + o + " , " + o.name + " , " + o.GetType());

                        dSource.Add(o);
                        dNames.Add(o.name);
                    }
                }

                Debug.Log("::BUILDING DEPENDENCY BUNDLE:: " + asset.name + " , " + dSource.Count);
                BuildPipeline.BuildAssetBundleExplicitAssetNames(
                    dSource.ToArray(), 
                    dNames.ToArray(), 
                    path, 
                    options, 
                    EditorUserBuildSettings.activeBuildTarget);
            }
            else
            {
                Debug.Log("::NON DEPENDENCY:: " + asset.name);
                BuildPipeline.BuildAssetBundleExplicitAssetNames(
                    new Object[] { asset }, 
                    new string[] { asset.name }, 
                    path, 
                    options, 
                    EditorUserBuildSettings.activeBuildTarget);

                if (shouldPush)
                {
                    BuildPipeline.PopAssetDependencies();
                }
            }
        }

        BuildPipeline.PopAssetDependencies();

        Debug.Log("[AssetBundleBuild] Complete.");
    }
}

Now, from the standpoint of packing shared dependencies, this seemed to work with most asset types such as textures or prefabs but when I included fonts, while they wouldn’t be duplicated across multiple bundles, I would always see two copies of my fonts. One set would be flagged as being ‘used by scripts and native code’ and the other would only be flagged as ‘used by native code’. After performing numerous tests, I discovered that upon opening the dependency bundle containing the font I was interested in, if there was a copy of the font in the project directory as well, both versions would be loaded into Resources. I haven’t been able to verify whether this happens on device as well but my inclination is that it only occurs in the editor.

The Problem of the Decompression Buffer

Another problem that became visible when working with large quantities of bundles that (based off of conversations with Unity technical representatives and the 4.2.0b3 beta client) may have changed in such a way as to render the problem less dire is that Unity, as of 4.1.5, allocates an 8mb decompression buffer per each asset bundle being opened. If there is an attempt to parallelize these requests, each request will allocate it’s own decompression buffer. This can be rather disconcerting as one can see how the allocation amount (especially on restricted memory devices) can really get a guy down.

Although 4.2.0b3 seems to be reducing the decompression buffer size down to 0.5mb per bundle the problem of parallelization still persists. The only immediate solution for individuals loading any quantity of bundles seems to be amortizing the requests in such a way as to prevent too much overlap. If someone out there has a suggestion to mitigate this problem otherwise please drop me a line mcelroy.jon[at]gmail.com


출처 : http://blog.jonmcelroy.com/post/55526714506/unity-assetbundle-dependencies

반응형
Posted by blueasa
, |

KGC AssetBundle

2013.09.26
10:30 ~ 11:30


Asset: 유니티에서 게임을 만들떄 필요한 모든 컨텐츠 
AssetBundle? Asset들을 하나로 묶는 기능 
압축 파일 포멧 

LZMA Algorithm 사용 

어셋번들의 중요성 
빌드 사이즈를 줄일수 있다.
게임 패치 (CDN과 같은 서버에 올려놓고 다운받는 형식)
더 낳은 퍼포먼스 (캐시 기능)


Caching이란?
CDN -> Local Disk <-> Unity

캐싱폴더 위치는?

모바일 / PC / 콘솔 : 4기가 캐싱사용가능
웹 : 50MB (캐싱 라이센스) 

캐싱폴더가 다 찬다면?
어셋번들이 사용된 시간을 기준으로 가장 최근에 사용되지 않은 어셋번들 부터 삭제 (Least Rencently Used algorithm )

만약 하드디스크가 꽉 차거나 모든 캐쉬가 사용중이라면?
어셋번들을 캐싱하지 않고 메모리에 올림 (like new WWW())

유니티 버전 호환성과 사이즈 DisableWriteTypeTree

ASsetBundle메모리 

Distory -> UnloadUnuseAssets사용 (런타임시 반복호출시 힉헙 상태 발생 가능성 있음)

프로파일러 사용 권장 


어셋번들의 암호화 
  • Open SSL을 이용해서 어셋번들을 암호화 
  • 암호화된 어셋번들을 텍스트로 변환
  • 전달 방법을 선택 
    • Application포함 
    • 서버에서 다운로드
  • 암호화된 어셋번들을 메모리에서 복호화 (with System.Security.Encrypt)

>>>> Binary 파일 변환과정을 거쳐 암호화를 시킬수 있다.

PC/웹 : 하위 호환성 유지 

안드로이드 / iOS : 호환 할수 있도록 계획 중
Q. 어셋번들과 유니티 버전에서 문제점 (새로 만들어야 한다. 소수점 2째자리 업데이트는 호환 가능 )


어셋사이즈와 해싱된 사이즈가 다른 이유?
어셋번들이 캐싱폴더에 저장될때는 Uncompressed상태에서 자장 ( 압축 풀린 상태 ) -> 보다 빠른 로딩이 가능 


캐싱 용량을 줄이고 싶을때 
Caching.maximumAvailableDiskSpace 사용 

캐싱을 삭제 하고 싶을때(캐싱폴더 전체가 삭제 됨) / 특정 번들을 삭제 하는 방법은 없다. (내년에 추가될 예정)
Caching.CleanCache


"어셋번들을 쪼갤수록 좋다"


Q. CRC알고리즘 ?
Q. 스크립트 포함되어 있는 오브젝트를 어셋번들 공유시 스크립트 동기화 문제



반응형
Posted by blueasa
, |