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

카테고리

분류 전체보기 (2809)
Unity3D (865)
Programming (479)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (234)
협업 (61)
3DS Max (3)
Game (12)
Utility (140)
Etc (98)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (55)
Android (16)
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

[링크1] https://www.sysnet.pe.kr/2/0/1264

[링크2] https://111110.tistory.com/entry/WELL-512-%EB%9E%9C%EB%8D%A4%EC%83%81%EC%88%98-%EC%83%9D%EC%84%B1-%EC%95%8C%EA%B3%A0%EB%A6%AC%EC%A6%98

[링크3] https://github.com/Mokbii/CSharpSyncRandom/tree/master/SyncRandomTest

 

반응형
Posted by blueasa
, |

꿈의집(HomeScapes)에서 위에 빨간 테두리로 보이는 것처럼 Soft Clip을 만들려고 이런저런 시도를 해보고

약간의 Trick을 포함해서 적용한 걸 간단하게 방법을 적어 놓음.

 

※ 우선은 블록들은 Sprite고, 밑에 Map이 Mesh를 사용하기 때문에 두가지 모두 Clipping 해야된다.

 

1. Unity 자체 Sprite Mask 추가(Menu-2D Object-Sprite Mask)

  [참조] https://docs.unity3d.com/kr/2020.3/Manual/class-SpriteMask.html

 

2. Sprite의 Mask Interaction을 Visible Inside Mask로 변경

3. Mesh Renderer도 Sprite Mask에 영향받도록 Shader에 아래처럼 Stencil 추가

Stencil {
		Ref 1
		Comp LEqual
    }

[참조1] https://devdata.tistory.com/166

[참조2] https://rainyrizzle.github.io/kr/AdvancedManual/AD_SpriteMask.html

------------------------------------------------------------------------------------------------

※ 여기까지 하면 Cutoff 된 상태로 Sprite, Mesh 둘 다 마스킹이 잘 된다.

   아래부터는 Soft Clip을 위해 구매한 에셋으로 시도한 Trick을 간단히 정리했다.

------------------------------------------------------------------------------------------------

4. Soft Clip을 위해 Sprite Alpha Mask 에셋 사용
   (제가 사용하기 위해 구매한 에셋이니 참조만 하시고 어떤 에셋을 사용하는지는 본인의 판단입니다.)

   [참조] https://assetstore.unity.com/packages/tools/particles-effects/sprite-alpha-mask-112704

 

5. Trick을 위해 맵의 배경 Sprite를 하나 복제해서 렌더링 순서를 아래와 같이 한다.

    (아래와 같이 배치하면 Foreground가 Map을 가려서 배경만 보이는 상태로 보인다.)

    [뒤] Background (Sprite)

    [중간] Map(Slot/Block 등) (Sprite+Mesh)

    [앞] Foreground (Sprite)

    

6. Foreground에 4.에서 산 에셋으로 Sprite Alpha Mask를 적용한다.

   (Masking 이미지는 아래 이미지를 사용하고, 9-Patch 한 후에 Sliced로 사용함)

Sprite Alpha Mask-Masking용 이미지

 

7. 6.의 Mask 크기는 1.의 Sprite Mask와 동일하게 맞춘다.

   (요약 : 앞에 배경을 하나 더 깔고 앞의 배경에 Alpha가 먹힌 구멍을 뚫어서 맵만 보이게 하려는 게 목적이다.)

 

8. 7.까지 하고나면 아래 이미지처럼 Sprite Mask의 Cutoff 영역 안쪽으로 Soft Clip처럼 보이게 된다.

   (빨간 테두리가 Sprite Mask 영역이고, 아래쪽 Sprite Mask 영역 안쪽으로 Soft Clip 처럼 적용된게 보인다)

Soft Clip Trick

 

 

 

반응형
Posted by blueasa
, |

'샘플 광고 단위 ID'를 사용해서 테스트 광고 테스트를 했었는데,

오늘 보니 테스트광고가 안나온다.

 

[링크] https://developers.google.com/admob/android/test-ads

 

테스트 광고 사용 설정  |  Android  |  Google Developers

테스트 광고 사용 설정 이 가이드에는 광고 통합에서 테스트 광고를 사용하는 방법이 나와 있습니다. 개발 중에는 테스트 광고를 사용하여 광고를 클릭해도 Google 광고주에게 비용이 청구되지

developers.google.com

 

이래저래 찾아보다 보니 위 링크에 아래와 같은 주의사항이 적혀 있다.

------------------------------------------------------------------------------------

주의: 앱에 app-ads.txt 파일을 설정한 경우 데모 광고 단위를 사용하여 광고를 로드하려면 다음 행을 app-ads.txt 파일에 포함해야 합니다.

google.com, pub-3940256099942544, DIRECT, f08c47fec0942fa0

또는 테스트 기기를 사용 설정하고 자체 광고 단위 ID를 대신 사용할 수 있습니다.

------------------------------------------------------------------------------------

이전에는 '샘플 광고 단위 ID'를 쓰면 그냥 나왔는데 이젠 app-ads.txt로 인증 받던지, '테스트 기기를 등록'해서 사용하라는 것 같다.

 

나는 테스트 기기 등록은 귀찮으니 app-ads.txt 파일에 추가하는걸로..

 

[추가]

app-ads.txt 파일에 추가하고 하루 뒤 테스트 광고가 정상적으로 나오는 것을 확인했다.

(참고로 app-ads.txt 파일 크롤링이 최대 24시간 걸린다고 하기 때문에,

운좋으면 몇십분만에 바로 될수도 있지만 안된다면 만24시간이 지난후에 다시 확인해보자)

반응형
Posted by blueasa
, |

[문제]

Unity 2020.3에서 'UnityEngine.AI.NavMeshAgent'를 사용하는 소스가 있는 에셋을 추가하니 아래와 같은 에러메시지가 뜸.

 

[에러메시지] CS1069: The type name 'NavMeshAgent' could not be found in the namespace 'UnityEngine.AI'.

 

[해결방법] Package Manager-Built-in-AI Enable

[참조] You have to enable the built in package 'AI' in the Package Manager window to fix this error.

 

 

[출처] https://forum.unity.com/threads/cant-find-navmeshagent-data-type.449932/

 

Can't find NavMeshAgent data type

I will make an AI but I can't find the data type. I don't understand what's going on. if you know, how can i fix this? [IMG] As you see, the data...

forum.unity.com

 

반응형
Posted by blueasa
, |

[ErrorMessage] Unexpected character encountered while parsing value: . Path '', line 0, position 0.

 

[Solved] In my case, the file containing JSON string had BOM. Once I removed BOM the problem was solved.

 

[추가] 로드 할 파일 인코딩 타입을 확인해보자.

 

[출처] https://stackoverflow.com/questions/23259173/unexpected-character-encountered-while-parsing-value

 

Unexpected character encountered while parsing value

Currently, I have some issues. I'm using C# with Json.NET. The issue is that I always get: {"Unexpected character encountered while parsing value: e. Path '', line 0, position 0."} So t...

stackoverflow.com

 

반응형
Posted by blueasa
, |

출처 : https://qiita.com/kuuki_yomenaio/items/00d74762e930d037ad27

Spine 오브젝트는?

Spine 개체는 Unity에서 말하는 MeshRenderer로 렌더링되고 있습니다. 
(spine-unity의 SkeletonRenderer.cs가 해당 소스입니다) 
즉, MeshRenderer의 Mask 처리를 만들 수 있다면, Mask를 사용할 수 있게 됩니다. 


(왜 이런 엄한 부분을 가지고 예제를 만든 걸까...)

Mask 처리에 대해

요는 Renderer를 Mask하면 되는 것이지만, 
SpriteRenderer 자체를 Mask하는 처리는 Unity에는 없는 것 같습니다. 
그래서, 간단히 자작하기로 했습니다.

Shader로 실제 제작

간단한 것은 역시 스텐실 테스트를 사용하는 것이군요. 
아주 간단하게 설명하면, 스텐실이란 모양을 도려낸다는 의미로 
픽셀 렌더링을 할 때 이 점을 찍는가 찍지 않는다인지를 판정하는 테스트입니다. 
이것을 이용합니다.

Spine 쪽에 적용하는 shader

SpineShader.shader
Shader "Custom/SpineShader"{
Properties
{
        _MainTex ("Base (RGB)", 2D) = "white" {}
}

SubShader
{
        Tags {"Queue"="Transparent+2" "IgnoreProjector"="True" "RenderType"="Transparent"}
        ZWrite Off
        Blend SrcAlpha OneMinusSrcAlpha

        Stencil {
                                Ref 1
                                Comp Equal
        }

        Pass
        {
                CGPROGRAM
                        #pragma vertex vert
                        #pragma fragment frag

                        #include "UnityCG.cginc"

                        struct appdata_t
                        {
                                float4 vertex : POSITION;
                                float2 texcoord : TEXCOORD0;
                        };

                        struct v2f
                        {
                                float4 vertex : SV_POSITION;
                                half2 texcoord : TEXCOORD0;
                        };

                        sampler2D _MainTex;
                        float4 _MainTex_ST;

                        v2f vert (appdata_t v)
                        {
                                v2f o;
                                o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                                o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
                                return o;
                        }

                        fixed4 frag (v2f i) : COLOR
                        {
                                fixed4 col = tex2D(_MainTex, i.texcoord);
                                return col;
                        }
                ENDCG
        }
}

}

Mask할 Sprite에 설정하는 Shader

SpineSoriteMask.shader
Shader "Custom/SpineSpriteMask"{
Properties
{
        _MainTex ("Base (RGB)", 2D) = "white" {}
}

SubShader
{
        Tags {"Queue"="Transparent+1" "IgnoreProjector"="True"}
        ZWrite Off
        AlphaTest Greater 0.5
        ColorMask 0
        ZTest Always


        Stencil {
                                Ref 1
                                Comp always
                                Pass replace
                        }


        Pass
        {
                CGPROGRAM
                        #pragma vertex vert
                        #pragma fragment frag

                        #include "UnityCG.cginc"

                        struct appdata_t
                        {
                                float4 vertex : POSITION;
                                float2 texcoord : TEXCOORD0;
                        };

                        struct v2f
                        {
                                float4 vertex : SV_POSITION;
                                half2 texcoord : TEXCOORD0;
                        };

                        sampler2D _MainTex;
                        float4 _MainTex_ST;

                        v2f vert (appdata_t v)
                        {
                                v2f o;
                                o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                                o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
                                return o;
                        }

                        fixed4 frag (v2f i) : COLOR
                        {
                                fixed4 col = tex2D(_MainTex, i.texcoord);
                                if(col.a<0.1)discard;
                                return col;
                        }
                ENDCG
        }
}

}

해설

SpineShader.shader
   Stencil {
             Ref 1
             Comp Equal
   }
SpineSoriteMask.shader
   ColorMask 0
   Stencil {
             Ref 1
             Comp always
             Pass replace
   }

Stencil

해설에 대해서는 
edo_m18 씨의 [Unity] Unity의 Shader 스텐실 버퍼를 시도
를 참고하십시오.

먼저, SpineSpriteMask 입니다만, 
"참조 값 1의 것과 비교하고, 모두 OK로 해서,
참조 값을 버퍼에 기록하고, ColorMask 0 으로 묘화는 하지 않음" 
이 됩니다.

그리고 SpineShader. 
"참조 값은 1, 값의 일치를 체크" 
가 됩니다.

이 설정을 함으로써 
SpineShader 측의 묘화는  StencilTest 를 받게 되고, 
SpineSpriteMask 측에서 설정한 모양대로 도려내지도록 그려집니다.

Unity에서 사용할 때에는 Material화 시킬 필요가 있습니다만, 
그에 대해서는
github
여기를 참고하십시오.

---

* 스파인측 설정

 

* 마스크이미지측 설정

* 매터리얼 설정은 이렇게(특별히 이미지는 지정하지 않고 쉐이더만 넣음)



출처: https://devdata.tistory.com/166 [CH:Windship DevDATA Center]

 

[Unity] Spine 오브젝트를 Mask하기

출처 : https://qiita.com/kuuki_yomenaio/items/00d74762e930d037ad27 Spine 오브젝트는? Spine 개체는 Unity에서 말하는 MeshRenderer로 렌더링되고 있습니다. (spine-unity의 SkeletonRenderer.cs가 해당 소스..

devdata.tistory.com

[참조] https://rainyrizzle.github.io/kr/AdvancedManual/AD_SpriteMask.html

 

Sprite Mask 적용하기

유니티의 "스프라이트 마스크(Sprite Mask)"를 이용하면 다른 Sprite Renderer의 일부를 숨기면서 렌더링을 할 수 있습니다. - 스프라이트 마스크 (유니티 공식 메뉴얼) AnyPortrait에서 제작된 캐릭터들은 S

rainyrizzle.github.io

 

반응형

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

[링크] Unity Toon Shader(with Outline)  (0) 2023.02.22
[링크] Unity-Chan Toon Shader 2.0 (UTS2)  (0) 2021.11.30
[펌] Celery - Toon/Cel shader  (0) 2021.03.30
[펌] Toon Shader  (0) 2021.03.30
[링크] Unity Cel Shading - 카툰렌더링  (0) 2021.03.30
Posted by blueasa
, |

[NGUI 2020.2.2 사용 중..]

 

NGUI에서 UI가 가릴 때 Game 내 일반 오브젝트에 영향을 안주게 막기 위해서

예전에는 UICamea.hoveredObject를 사용했는데, 이번에 사용해보니 값이 이상하다.

그래서 좀 찾아보니 UICamea.IsOverUI가 있다.

참조 링크의 내용에는 문제가 있는 것처럼 말하긴 하는데 빌드해서 봐도 별다른 문제점은 없어보여서 일단 쓰기로 함.

 

[참조] http://www.tasharen.com/forum/index.php?topic=13282.0

 

UICamea.hoveredObject, UICamera.fallThrough, IsOver UI Problem.

When 3D Object and NGUI Object located same position on viewPort, "if(UICamera.hoveredObject != null)" code only touched NGUI Object. This code is no problem NGUI 3.0.2 version, Editor and Mobile too. But, latest version "UICamera.hoveredObject" is pointed

www.tasharen.com

[다른방식] https://blueasa.tistory.com/2549

 

[펌] NGUI와 일반 오브젝트 구분 피킹법

NGUI 를 사용하면서 GUI에 가린 오브젝트들이 GUI와 같이 클릭되는 현상을 게임 제작하면 많이들 보게됩니다. 그럴때는 아래 소스에서 작동하는 녀석으로 쓰면됩니다. if (UICamera.Raycast (Input.mousePosit

blueasa.tistory.com

 

반응형
Posted by blueasa
, |

NGUI 를 사용하면서 GUI에 가린 오브젝트들이 GUI와 같이 클릭되는 현상을 게임 제작하면 많이들 보게됩니다. 그럴때는 아래 소스에서 작동하는 녀석으로 쓰면됩니다.

 

if (UICamera.Raycast (Input.mousePosition) == true) 
{

        // NGUI 오브젝트가 선택되었음
} else

{

       // 해당 일반 오브젝트 선택되었음

}

 

or

 

if(null == UICamera.hoveredObject)

{

    // 게임쪽 클릭 처리

}

 

본인은 2번째 소스로 쓰다가 최근에 들어서 모바일에서 작동이 잘 안하는 관계로 1번을 사용하고 있습니다.



출처: https://sjcy.tistory.com/entry/NGUI와-일반-오브젝트-구분-피킹법 [Charlotte's web]

 

NGUI와 일반 오브젝트 구분 피킹법

NGUI 를 사용하면서 GUI에 가린 오브젝트들이 GUI와 같이 클릭되는 현상을 게임 제작하면 많이들 보게됩니다. 그럴때는 아래 소스에서 작동하는 녀석으로 쓰면됩니다. if (UICamera.Raycast (Input.mousePosit

sjcy.tistory.com

 

반응형
Posted by blueasa
, |

짓궃다vs 짖궃다

작성자 서주혜 등록일 2016. 11. 23. 조회수 11,119

짓궃다와 짖궃다중 어느 표현이 맞는 표현 입니까?

비밀번호  삭제

[답변]'짓궂다'

답변자 온라인 가나다 답변일 2016. 11. 25.

안녕하십니까?

 

'장난스럽게 남을 괴롭고 귀찮게 하여 달갑지 아니하다'를 의미하는 말은 '짓궂다'로 표기하는 것이 올바릅니다. '짓궃다/짖궃다'는 모두 틀린 표기입니다.

----
<참고>
짓-궂다 [짇ː꾿따]
「형용사」
 장난스럽게 남을 괴롭고 귀찮게 하여 달갑지 아니하다.
¶ 짓궂은 웃음/짓궂은 장난/짓궂은 질문/짓궂은 아이/짓궂게 놀리다/왕은 짓궂게 빙글빙글 웃으며 젊은 왕비를 놀려 본다.≪박종화, 다정불심≫

 

 

[출처] https://www.korean.go.kr/front/onlineQna/onlineQnaView.do?mn_id=216&qna_seq=108834

 

국립국어원

축소 확대 온라인가나다 상세보기 짓궃다vs 짖궃다 작성자 서주혜 등록일 2016. 11. 23. 조회수 11,120 짓궃다와 짖궃다중 어느 표현이 맞는 표현 입니까? [답변]'짓궂다' 답변자 온라인 가나다 답변일

www.korean.go.kr

 

반응형
Posted by blueasa
, |

Here are two small tricks that can help if you’re making an isometric 2D game in Unity. Ok, so not actually isometric, but that’s the term we’re used to in videogames, so we’ll go with it. These are quite basic and if you’re working on such a game you’ve probably already tackled them your own way. This is our take on it, hopefully it’s useful to someone.

Sprite Ordering

Normally in a 2D game there is no concept of depth, so if you simply place the sprites in the world, you’ll most likely have objects appearing in the wrong order than what you’d expect in an isometric game.

 

Thankfully Unity exposes Sorting Layer and Order In Layer properties for Renderers.
A quick fix is to set the value of Order in Layer to depend on the Y position of the object.

 

[ExecuteInEditMode]
[RequireComponent(typeof(Renderer))]
public class DepthSortByY : MonoBehaviour
{

    private const int IsometricRangePerYUnit = 100;

    void Update()
    {
        Renderer renderer = GetComponent();
        renderer.sortingOrder = -(int)(transform.position.y * IsometricRangePerYUnit);
    }
}

This solves the problem for the simplest case, when we assume all objects rest on the ground.

 

Let’s assume we want to have an object that is above the ground in the world, like placing a bird house on that tree. Just trying to place it in the world will treat the pivot of the object as being at ground level, with no way to both place it at a proper height and sort it correctly.

 

There are several options for this. Just to get it out of the system, the first option is to add empty space to the texture below the bird house to make sure the pivot is at ground level (in Unity, the pivot can’t be outside of the sprite). This is baaaad! This is wasting texture space, and all instances of that object will need to be at the same height in the game. There are other, less insane, options.

One is having a height property in the DepthSortByY behavior and subtract it from transform.position.y when computing the sorting order.
Another solution (which we went with) is allowing the DepthSortByY behavior to make the depth computation based on another object’s transform. This way, the objects will be considered to be at the same point in space as their target and they’ll have the same depth order, even if they’re at different Y positions in the scene. In the bird house example, the bird house uses the tree’s world position for its depth computations.
This solution works better for our game, because it allows artists to move the item freely while staying at the depth (and not have to deal with editing the “height” parameter). And mainly because all the gameplay takes place in the ground’s 2D plane anyway so all objects are guaranteed to have a root object that has the ground position. In your own game, it might be easier to just use the first option.

[ExecuteInEditMode]
[RequireComponent(typeof(Renderer))]
public class IsometricObject : MonoBehaviour
{
   private const int IsometricRangePerYUnit = 100;
   
   [Tooltip("Will use this object to compute z-order")]
    public Transform Target;
    
    [Tooltip("Use this to offset the object slightly in front or behind the Target object")]
    public int TargetOffset = 0;
    
    void Update()
    {
        if (Target == null)
            Target = transform;
        Renderer renderer = GetComponent();
        renderer.sortingOrder = -(int)(Target.position.y * IsometricRangePerYUnit) + TargetOffset;
    }
}

This is how this example is set up in Unity:

The birdhouse references the tree for its depth.

 

And this is how it behaves in practice:

 

Ground Projection

For certain visual elements and effect, we wanted them to look properly projected on the ground, but also not spend too much time on making art for them. The ‘isometric’ view of the game means that anything that is horizontally on the ground should look squashed vertically.
For simple sprites, this is quite easy. Just draw them directly with the correct perspective and place them in the game.

Things get more complicated when you need something that should be able to rotate in any direction. Like something to show the direction the character is moving in, or some visual effect sweeping the ground towards your attacking direction. Especially if these are things that are animated, drawing them manually for all possible orientations is out of the question (or so the artists claim).

Our solution is: the artists draw and animate these effects as if viewed top-down, and the programmers take care of transforming them at runtime to look as if they were projected on the ground. Without any transformation, just taken from the artists and placed in the game rotating them to match the player’s direction they look like below.

 

We need to squash them vertically. For a sprite that doesn’t rotate, just scaling on the Y dimension does the job. But for a rotating sprite this doesn’t work, and it’s even worse for animations. The first thing we tried was a custom shader that transformed the vertices in the local space to squash them vertically (naturally, we went with the most complex solution first), but this needed to break batching to work properly with all sprites and animations. Or I was just bad at writing that shader, maybe…

The final solution is absurdly simple. Just rotate the object around the X axis, and it works!
However, we also wanted to:

  • apply the rotation automatically and consistently, and not have to remember or care about setting the X component of the rotation ourselves
  • be able to set the Z component of the rotation (to make the effect rotate towards any game world direction)
  • not have to visit all ‘ground projected’ effects when changing the amount of squashing

Basically, the game should not have to know that a rotation on X axis is happening. If an object has the ProjectOnGround behavior attached, it should just draw properly without additional effort. So we do the math just before rendering, and restore the rotation to its normal value right after. This hides the rotation around the X axis from the rest of the code.

[ExecuteInEditMode]
    public class ProjectOnGround : MonoBehaviour
    {
        private Quaternion savedRotation;

        // called before rendering the object        
        void OnWillRenderObject()
        {
            savedRotation = transform.rotation;
            var eulers = transform.rotation.eulerAngles;
            transform.rotation = Quaternion.Euler(Constants.Isometric.PerspectiveAngle, eulers.y, eulers.z);
        }

        //called right after rendering the object
        void OnRenderObject()
        {
            transform.rotation = savedRotation;
        }
    }

Simple and easy. Too bad I wasted time trying to write a shader for this. The result looks good and we can simple ‘project’ any object by just adding this behavior to it.

 

 

 

[출처] https://breadcrumbsinteractive.com/two-unity-tricks-isometric-games/

 

Two Unity tricks for isometric games - Breadcrumbs

Here are two small tricks that can help if you’re making an isometric 2D game in Unity. Ok, so not actually isometric, but that’s the term we’re used to in videogames, so we’ll go with it. These are quite basic and if you’re working on such a gam

breadcrumbsinteractive.com

 

반응형
Posted by blueasa
, |