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

카테고리

분류 전체보기 (2737)
Unity3D (817)
Programming (474)
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
04-25 00:00

[요약]

1) Tags { "Queue"="Transparent" "RenderType" = "Opaque" }

2) #pragma surface surf Lambert alpha

 

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

Three steps:

Add objects rendered with this shader to the Transparent queue by adding “Queue”=“Transparent” to the subshader’s Tags list.
Add “alpha” to the surface function declaration, after the lighting function declaration, so the line becomes “#pragma surface surf Lambert alpha”
Actually set the alpha to something in the surface function, i.e. set o.Alpha = whatever you want.
I have done these modifications and used the _ColorTint’s alpha channel in the example. Then the shader becomes this:

 

Shader "-smn-/GlowingBorder" {
    Properties {
       _ColorTint("ColorTint", Color) = (1,1,1,1)
       _MainTex("Main Texture", 2D) = "white" {}
       _BumpMap("Normal Map", 2D) = "bump" {}
       _RimColorOuter("Rim Color Outer", Color) = (1,1,1,1)
       _RimColorInner("Rim Color Inner", Color) = (1,1,1,1)
       _RimPowerOuter("Rim Power Outer", Range(0.0, 7.0)) = 3.0
       _RimPowerInner("Rim Power Inner", Range(0.0, 20.0)) = 3.0
    }
    SubShader {
       Tags { "Queue"="Transparent" "RenderType" = "Opaque" }
 
 
       CGPROGRAM
       #pragma surface surf Lambert alpha
 
       struct Input {
         float4 color : COLOR;
         float2 uv_MainTex;
         float2 uv_BumpMap;
         float3 viewDir;
       };
 
       float4 _ColorTint;
       sampler2D _MainTex;
       sampler2D _BumpMap;
       float4 _RimColorOuter;
       float4 _RimColorInner;
       float _RimPowerOuter;
       float _RimPowerInner;
 
       void surf (Input IN, inout SurfaceOutput o) {
         IN.color = _ColorTint;
         o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb * IN.color;
         o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
 		 o.Alpha = _ColorTint.a; // For example. Could also be the alpha channel on the interpolated vertex color (IN.color.a), or the one from the texture.
		
         half rimOuter = 1.0 -saturate(dot(normalize(IN.viewDir), o.Normal));
         half rimInner = saturate(dot(normalize(IN.viewDir), o.Normal));
         o.Emission = (_RimColorOuter.rgb * pow(rimOuter, _RimPowerOuter)) + (_RimColorInner.rgb * pow(rimInner, _RimPowerInner)) ;
       }
       ENDCG
    } 
    FallBack "Diffuse"
}

 

 

[출처] https://discussions.unity.com/t/how-can-i-add-alpha-channel-to-this-shader/100942

 

How can I add alpha-channel to this shader?

Hello, I have this shader that does not support alpha map. How can I modify it so I can adjust the alpha channel so as to be transparent? Thanks! Shader "-smn-/GlowingBorder" { Properties { _ColorTint("ColorTint", Color) = (1,1,1,1) _MainTex("Main Texture"

discussions.unity.com

 

 

반응형
Posted by blueasa
, |

 

Alpha 적용 (전)

 

김프의 Color to Alpha 도구는 사용 방법을 알고 있으면 매우 편리하며이 작업은 특히 적합합니다.

  1. 김프에서 이미지를 열고 필요한 경우 RGB 색상 모드로 변경하십시오.
  2. 레이어 → 투명도 → 색상을 알파로 ...를 선택합니다 .
  3. #000000투명하게하려면 색상으로 검은 색 ( )을 선택하십시오 .
  4. "확인"을 클릭하십시오.
  5. 결과 이미지를 PNG 형식으로 저장하십시오.
    Alpha 적용 (후)

 

[출처] qastack.kr/graphicdesign/6449/add-transparency-to-an-existing-png

 

기존 PNG에 투명도 추가

 

qastack.kr

 

[GIMP 다운로드] www.gimp.org/downloads

 

GIMP - Downloads

The official download page for all things GIMP! Please only use the official binaries provided here unless you really, really know what you’re doing (it’s the only way to be safe). We try to provide binaries in-time with regular releases, but may occa

www.gimp.org

 

반응형
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
, |