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

카테고리

분류 전체보기 (2738)
Unity3D (817)
Programming (475)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
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
05-05 21:38

Toon/Basic with Alpha

Unity3D/Shader / 2013. 7. 19. 22:27

출처에 있는 SubShader의 해당 부분만 교체..(실행 확인)



Toony-BasicWithAlpha.shader




1 Shader "Toon/Basic with Alpha" { 2 Properties { 3 _Color ("Main Color", Color) = (.5,.5,.5,1) 4 _MainTex ("Base (RGB)", 2D) = "white" {} 5 _ToonShade ("ToonShader Cubemap(RGB)", CUBE) = "" { Texgen CubeNormal } 6 } 7 8 9 SubShader { 10 Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 11 Pass { 12 Name "BASE" 13 Cull Back 14 Blend SrcAlpha OneMinusSrcAlpha 15 16 CGPROGRAM 17 #pragma vertex vert 18 #pragma fragment frag 19 #pragma fragmentoption ARB_precision_hint_fastest 20 21 #include "UnityCG.cginc" 22 23 sampler2D _MainTex; 24 samplerCUBE _ToonShade; 25 float4 _MainTex_ST; 26 float4 _Color; 27 28 struct appdata { 29 float4 vertex : POSITION; 30 float2 texcoord : TEXCOORD0; 31 float3 normal : NORMAL; 32 }; 33 34 struct v2f { 35 float4 pos : POSITION; 36 float2 texcoord : TEXCOORD0; 37 float3 cubenormal : TEXCOORD1; 38 }; 39 40 v2f vert (appdata v) 41 { 42 v2f o; 43 o.pos = mul (UNITY_MATRIX_MVP, v.vertex); 44 o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); 45 o.cubenormal = mul (UNITY_MATRIX_MV, float4(v.normal,0)); 46 return o; 47 } 48 49 float4 frag (v2f i) : COLOR 50 { 51 float4 col = _Color * tex2D(_MainTex, i.texcoord); 52 float4 cube = texCUBE(_ToonShade, i.cubenormal); 53 return float4(2.0f * cube.rgb * col.rgb, col.a); 54 } 55 ENDCG 56 } 57 } 58 59 SubShader { 60 Tags { "RenderType"="Opaque" } 61 Pass { 62 Name "BASE" 63 Cull Back 64 SetTexture [_MainTex] { 65 constantColor [_Color] 66 Combine texture * constant 67 } 68 SetTexture [_ToonShade] { 69 combine texture * previous DOUBLE, previous 70 } 71 } 72 } 73 74 Fallback "VertexLit" 75 } 76



출처 : http://forum.unity3d.com/threads/103030-Toon-shader-with-Transparency

반응형

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

쉐이더 자료 많은 사이트..  (0) 2014.04.03
Toon/Tf2Shader  (0) 2013.07.19
Toon/Lighted with Alpha  (0) 2013.07.19
toon-water shader  (0) 2012.11.07
스크립트로 Shader 변경  (0) 2012.11.06
Posted by blueasa
, |



Toony-LightedWithAlpha.shader




Shader "Toon/Lighted with Alpha" { 

Properties { 

_Color ("Main Color", Color) = (0.5,0.5,0.5,1)

_MainTex ("Base (RGB)", 2D) = "white" {} 

_Ramp ("Toon Ramp (RGB)", 2D) = "gray" {} 

}


    SubShader {

       Tags {"Queue"="Transparent" "RenderType"="Transparent"}

       Blend SrcAlpha OneMinusSrcAlpha

       LOD 200

 

CGPROGRAM

#pragma surface surf ToonRamp

 

sampler2D _Ramp;

 

// custom lighting function that uses a texture ramp based

// on angle between light direction and normal

#pragma lighting ToonRamp exclude_path:prepass

inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)

{

    #ifndef USING_DIRECTIONAL_LIGHT

    lightDir = normalize(lightDir);

    #endif

 

    half d = dot (s.Normal, lightDir)*0.5 + 0.5;

    half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;

 

    half4 c;

    c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);

    c.a = s.Alpha;

    return c;

}

 

 

sampler2D _MainTex;

float4 _Color;

 

struct Input {

    float2 uv_MainTex : TEXCOORD0;

};

 

void surf (Input IN, inout SurfaceOutput o) {

    half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;

    o.Albedo = c.rgb;

    o.Alpha = c.a;

}

ENDCG

 

    } 

 

    Fallback "Diffuse"

}


링크 : http://answers.unity3d.com/questions/180977/toon-lighted-alpha.html


참조 :http://stackoverflow.com/questions/13417458/unity-diffuse-shader-with-global-alpha

반응형

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

Toon/Tf2Shader  (0) 2013.07.19
Toon/Basic with Alpha  (0) 2013.07.19
toon-water shader  (0) 2012.11.07
스크립트로 Shader 변경  (0) 2012.11.06
AlphaVertexColor  (0) 2012.11.04
Posted by blueasa
, |

작업을 하다가 필요에 의해서 문득 든 궁금증..


컴포넌트로 추가 된 스크립트는 명시적인 자신의 이름으로만 찾아(GetComponent)지는가?


그래서 간단히 테스트 해봤다.


1) 클래스 2개 만들고,

public class Test : MonoBehaviour

{

    public int m_iCount = 0;   // 접근 테스트용

    ....

}


public class Test2 : Test

{

    ....

}


2) Test2를 Component로 추가

3) 이 상태에서 Test 클래스로 GetComponent를 해봤다.

Test scTest = gameObject.GetComponent<Test>();

if (scTest)

{

    Debug.Log(scTest.m_iCount);

}



[결론]

잘된다. 쓰자~

반응형
Posted by blueasa
, |

Photon Cloud 강좌

Unity3D/Photon / 2013. 7. 16. 00:49

Photon Cloud 강좌 1


Photon Cloud 강좌 2


Photon Cloud 강좌 3


Photon Cloud 강좌 4



출처 : http://www.wolfpack.pe.kr

반응형

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

포튼서버 예제 관련 사이트 입니다.  (0) 2013.09.14
Posted by blueasa
, |


링크 : http://mingu.kr/80

반응형
Posted by blueasa
, |


링크 : http://www.unitystudy.net/bbs/board.php?bo_table=writings&wr_id=43

반응형
Posted by blueasa
, |
  1. using System.IO;
  2. DirectoryInfo dir = new DirectoryInfo(myPath);
  3. FileInfo[] info = dir.GetFiles("*.*");
  4. foreach (FileInfo f in info) 
  5. { ... }



참조 : http://msdn.microsoft.com/en-us/library/system.io.directoryinfo.aspx


출처 : http://answers.unity3d.com/questions/16433/get-list-of-all-files-in-a-directory.html

반응형
Posted by blueasa
, |

링크 : http://u3d.as/content/unity-technologies/mecanim-example-scenes/3Bs

반응형

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

메카님 강좌(by 도플광어)  (0) 2013.07.05
Posted by blueasa
, |


유니티 메카님(mecanim) 강좌 - 1 : http://cafe.naver.com/jcga/3037


유니티 메카님(mecanim) 강좌 - 2 : http://cafe.naver.com/jcga/3038

반응형

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

Mecanim Example Scenes  (0) 2013.07.05
Posted by blueasa
, |

Texture Sizes

Ideally texture sizes should be powers of two on the sides. These sizes are as follows: 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 etc. pixels. The textures do not have to be square, i.e. width can be different from height. Note that each platform may impose maximum texture sizes.


Android

Unless you're targeting a specific hardware, like Tegra, we'd recommend using ETC1 compression. If needed you could store an external alpha channel and still benefit from lower texture footprint. If you absolutely want to store an alpha channel in a texture, RGBA16 bit is the compression supported by all hardware vendors.


Textures can be imported from DDS files but only DXT or uncompressed pixel formats are currently supported.

 

If your app utilizes an unsupported texture compression, the textures will be uncompressed to RGBA 32 and stored in memory along with the compressed ones.So in this case you lose time decompressing textures and lose memory storing them twice. It may also have a very negative impact on rendering performance.

 

중요한부분에 빨간마커!

 

요약 : 

 

플랫폼별 텍스쳐사이즈 리미트를 확인

암축설정은 ETC1 할것이유인 즉슨 ETC1 모든 기기에서 지원하는데만약 지원하지않는 압축형식을 사용할경우 텍스쳐는 32bit형식으로 압축이 풀리면서 메모리가 졎대는 현상이 발생함

 

추가 :

2^x*2^x정방형태의 텍스쳐를 사용할것



[출처] Unity3d Texture 레퍼런스정리|작성자 송주씨


반응형
Posted by blueasa
, |