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

카테고리

분류 전체보기 (2324)N
Unity3D (568)
Programming (472)
Unreal (4)
Gamebryo (56)
Tip & Tech (185)N
협업 (34)
3DS Max (3)
Game (12)
Utility (116)
Etc (92)
Link (31)
Portfolio (19)
Subject (90)
iOS,OSX (38)
Android (13)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (1)
Memories (19)
Interest (37)
Thinking (36)
한글 (26)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (19)
Exercise (3)
나만의 맛집 (2)
냥이 (9)
육아 (9)
Total1,344,606
Today31
Yesterday150
Statistics Graph

달력

« » 2019.12
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

공지사항

태그목록

'UnityDiffuseLightmap'에 해당되는 글 1건

  1. 2014.06.23 UnityDiffuseLightmap.shader by jimfleming

Link : https://gist.github.com/jimfleming/5937437#file-unitydiffuselightmap-shader



Shader "Diffuse Lightmap" {
 
Properties {
_MainTex ("Texture 1", 2D) = "white" {}
}
 
SubShader {
Tags { "RenderType" = "Opaque" }
 
Pass {
// Disable lighting, we're only using the lightmap
Lighting Off
 
CGPROGRAM
// Must be a vert/frag shader, not a surface shader: the necessary variables
// won't be defined yet for surface shaders.
#pragma vertex vert
#pragma fragment frag
 
#include "UnityCG.cginc"
 
struct v2f {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
};
 
struct appdata_lightmap {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
 
// These are prepopulated by Unity
sampler2D unity_Lightmap;
float4 unity_LightmapST;
 
sampler2D _MainTex;
float4 _MainTex_ST; // Define this since its expected by TRANSFORM_TEX; it is also pre-populated by Unity.
 
v2f vert(appdata_lightmap i) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, i.vertex);
 
// UnityCG.cginc - Transforms 2D UV by scale/bias property
// #define TRANSFORM_TEX(tex,name) (tex.xy * name##_ST.xy + name##_ST.zw)
o.uv0 = TRANSFORM_TEX(i.texcoord, _MainTex);
 
// Use `unity_LightmapST` NOT `unity_Lightmap_ST`
o.uv1 = i.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
return o;
}
 
half4 frag(v2f i) : COLOR {
half4 main_color = tex2D(_MainTex, i.uv0);
 
// Decodes lightmaps:
// - doubleLDR encoded on GLES
// - RGBM encoded with range [0;8] on other platforms using surface shaders
// inline fixed3 DecodeLightmap(fixed4 color) {
// #if defined(SHADER_API_GLES) && defined(SHADER_API_MOBILE)
// return 2.0 * color.rgb;
// #else
// return (8.0 * color.a) * color.rgb;
// #endif
// }
 
main_color.rgb *= DecodeLightmap(tex2D(unity_Lightmap, i.uv1));
return main_color;
}
ENDCG
}
}
}



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

Unity Shader Reference  (0) 2014.06.24
Rendering Order - Queue tag  (0) 2014.06.24
UnityDiffuseLightmap.shader by jimfleming  (0) 2014.06.23
쉐이더 자료 많은 사이트..  (0) 2014.04.03
Toon/Tf2Shader  (0) 2013.07.19
Toon/Basic with Alpha  (0) 2013.07.19
Posted by blueasa

댓글을 달아 주세요