├── 3D数学基础 图形与游戏开发.pdf ├── 3D游戏引擎设计 实时计算机图形学的应用方法(第2版).txt ├── Cg教程_可编程实时图形权威指南.pdf ├── GPU编程与 CG语言 中文版.pdf ├── OpenGL ES 2.0编程指南中文版.pdf ├── OpenGL编程指南(原书第7版).pdf ├── Unity 着色器和屏幕特效开发秘笈.pdf ├── Unity3D内置Shader源码.rar ├── Unity3D内置Shader源码 └── buildInShader │ ├── DefaultResources │ ├── Alpha-BumpSpec.shader │ ├── Alpha-Bumped.shader │ ├── Alpha-Diffuse.shader │ ├── Alpha-Glossy.shader │ ├── Alpha-Parallax.shader │ ├── Alpha-ParallaxSpec.shader │ ├── Alpha-VertexLit.shader │ ├── AlphaTest-BumpSpec.shader │ ├── AlphaTest-Bumped.shader │ ├── AlphaTest-Diffuse.shader │ ├── AlphaTest-Glossy.shader │ ├── AlphaTest-SoftEdgeUnlit.shader │ ├── AlphaTest-VertexLit.shader │ ├── Camera-DepthNormalTexture.shader │ ├── Camera-DepthTexture.shader │ ├── Decal.shader │ ├── Flare.shader │ ├── Font.shader │ ├── Illumin-BumpSpec.shader │ ├── Illumin-Bumped.shader │ ├── Illumin-Diffuse.shader │ ├── Illumin-Glossy.shader │ ├── Illumin-Parallax.shader │ ├── Illumin-ParallaxSpec.shader │ ├── Illumin-VertexLit.shader │ ├── Internal-BlitCopy.shader │ ├── Internal-CombineDepthNormals.shader │ ├── Internal-Flare.shader │ ├── Internal-GUITexture.shader │ ├── Internal-GUITextureBlit.shader │ ├── Internal-GUITextureClip.shader │ ├── Internal-GUITextureClipText.shader │ ├── Internal-Halo.shader │ ├── Internal-PrePassCollectShadows.shader │ ├── Internal-PrePassLighting.shader │ ├── Normal-BumpSpec.shader │ ├── Normal-Bumped.shader │ ├── Normal-Diffuse.shader │ ├── Normal-DiffuseDetail.shader │ ├── Normal-DiffuseFast.shader │ ├── Normal-DiffuseFogOff.shader │ ├── Normal-Glossy.shader │ ├── Normal-Parallax.shader │ ├── Normal-ParallaxSpec.shader │ ├── Normal-VertexLit.shader │ ├── Particle Add.shader │ ├── Particle AddMultiply.shader │ ├── Particle AddSmooth.shader │ ├── Particle Alpha Blend.shader │ ├── Particle Blend.shader │ ├── Particle Multiply.shader │ ├── Particle MultiplyDouble.shader │ ├── Particle Premultiply Blend.shader │ ├── Particle VertexLit Blended.shader │ ├── Reflect-BumpNolight.shader │ ├── Reflect-BumpSpec.shader │ ├── Reflect-BumpVertexLit.shader │ ├── Reflect-Bumped.shader │ ├── Reflect-Diffuse.shader │ ├── Reflect-Glossy.shader │ ├── Reflect-Parallax.shader │ ├── Reflect-ParallaxSpec.shader │ ├── Reflect-VertexLit.shader │ ├── Shadow-ScreenBlur.shader │ ├── Shadow-ScreenBlurRotated.shader │ ├── Skybox.shader │ ├── TerrainShaders │ │ ├── Details │ │ │ ├── VertexLit.shader │ │ │ ├── WavingGrass.shader │ │ │ └── WavingGrassBillboard.shader │ │ ├── Splats │ │ │ ├── AddPass.shader │ │ │ └── FirstPass.shader │ │ └── Trees │ │ │ └── BillboardTree.shader │ └── skybox cubed.shader │ ├── DefaultResourcesExtra │ ├── Lightmap-BumpSpec.shader │ ├── Lightmap-Bumped.shader │ ├── Lightmap-Diffuse.shader │ ├── Lightmap-Glossy.shader │ ├── Lightmap-VertexLit.shader │ ├── Mobile │ │ ├── Mobile-BumpSpec-1DirectionalLight.shader │ │ ├── Mobile-BumpSpec.shader │ │ ├── Mobile-Bumped.shader │ │ ├── Mobile-Diffuse.shader │ │ ├── Mobile-Lightmap-Unlit.shader │ │ ├── Mobile-Particle-Add.shader │ │ ├── Mobile-Particle-Alpha-VertexLit.shader │ │ ├── Mobile-Particle-Alpha.shader │ │ ├── Mobile-Particle-Multiply.shader │ │ ├── Mobile-Skybox.shader │ │ ├── Mobile-VertexLit-OnlyDirectionalLights.shader │ │ └── Mobile-VertexLit.shader │ ├── Nature │ │ ├── SoftOcclusion │ │ │ ├── SH_Vertex.cginc │ │ │ ├── TreeSoftOcclusionBark.shader │ │ │ ├── TreeSoftOcclusionBarkRendertex.shader │ │ │ ├── TreeSoftOcclusionLeaves.shader │ │ │ └── TreeSoftOcclusionLeavesRendertex.shader │ │ └── TreeCreator │ │ │ ├── Tree.cginc │ │ │ ├── TreeCreatorBark.shader │ │ │ ├── TreeCreatorBarkOptimized.shader │ │ │ ├── TreeCreatorBarkRendertex.shader │ │ │ ├── TreeCreatorLeaves.shader │ │ │ ├── TreeCreatorLeavesFast.shader │ │ │ ├── TreeCreatorLeavesFastOptimized.shader │ │ │ ├── TreeCreatorLeavesOptimized.shader │ │ │ ├── TreeCreatorLeavesRendertex.shader │ │ │ └── TreeVertexLit.cginc │ └── Unlit │ │ ├── Unlit-Alpha.shader │ │ ├── Unlit-AlphaTest.shader │ │ └── Unlit-Normal.shader │ └── Particle Alpha Blend ZWrite Off.shader ├── Unity3D内部Shader详解.doc ├── Unity3D内部Shader详解.doc.f1471951feb1ea9e6e3f344c6ea4ef00bb89d573 ├── 实时计算机图形学第2版.pdf ├── 游戏引擎架.txt ├── 计算机图形学.chm └── 顶点动画.xlsx /3D数学基础 图形与游戏开发.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x522758754/Graphics-books/af4c41eec6b53dc367772e2e93af77df422fe7ad/3D数学基础 图形与游戏开发.pdf -------------------------------------------------------------------------------- /3D游戏引擎设计 实时计算机图形学的应用方法(第2版).txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x522758754/Graphics-books/af4c41eec6b53dc367772e2e93af77df422fe7ad/3D游戏引擎设计 实时计算机图形学的应用方法(第2版).txt -------------------------------------------------------------------------------- /Cg教程_可编程实时图形权威指南.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x522758754/Graphics-books/af4c41eec6b53dc367772e2e93af77df422fe7ad/Cg教程_可编程实时图形权威指南.pdf -------------------------------------------------------------------------------- /GPU编程与 CG语言 中文版.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x522758754/Graphics-books/af4c41eec6b53dc367772e2e93af77df422fe7ad/GPU编程与 CG语言 中文版.pdf -------------------------------------------------------------------------------- /OpenGL ES 2.0编程指南中文版.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x522758754/Graphics-books/af4c41eec6b53dc367772e2e93af77df422fe7ad/OpenGL ES 2.0编程指南中文版.pdf -------------------------------------------------------------------------------- /OpenGL编程指南(原书第7版).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x522758754/Graphics-books/af4c41eec6b53dc367772e2e93af77df422fe7ad/OpenGL编程指南(原书第7版).pdf -------------------------------------------------------------------------------- /Unity 着色器和屏幕特效开发秘笈.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x522758754/Graphics-books/af4c41eec6b53dc367772e2e93af77df422fe7ad/Unity 着色器和屏幕特效开发秘笈.pdf -------------------------------------------------------------------------------- /Unity3D内置Shader源码.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x522758754/Graphics-books/af4c41eec6b53dc367772e2e93af77df422fe7ad/Unity3D内置Shader源码.rar -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Alpha-BumpSpec.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Bumped Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) 5 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 6 | _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} 7 | _BumpMap ("Normalmap", 2D) = "bump" {} 8 | } 9 | 10 | SubShader { 11 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 12 | LOD 400 13 | 14 | CGPROGRAM 15 | #pragma surface surf BlinnPhong alpha 16 | 17 | sampler2D _MainTex; 18 | sampler2D _BumpMap; 19 | fixed4 _Color; 20 | half _Shininess; 21 | 22 | struct Input { 23 | float2 uv_MainTex; 24 | float2 uv_BumpMap; 25 | }; 26 | 27 | void surf (Input IN, inout SurfaceOutput o) { 28 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 29 | o.Albedo = tex.rgb * _Color.rgb; 30 | o.Gloss = tex.a; 31 | o.Alpha = tex.a * _Color.a; 32 | o.Specular = _Shininess; 33 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 34 | } 35 | ENDCG 36 | } 37 | 38 | FallBack "Transparent/VertexLit" 39 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Alpha-Bumped.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Bumped Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 5 | _BumpMap ("Normalmap", 2D) = "bump" {} 6 | } 7 | 8 | SubShader { 9 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 10 | LOD 300 11 | 12 | CGPROGRAM 13 | #pragma surface surf Lambert alpha 14 | 15 | sampler2D _MainTex; 16 | sampler2D _BumpMap; 17 | fixed4 _Color; 18 | 19 | struct Input { 20 | float2 uv_MainTex; 21 | float2 uv_BumpMap; 22 | }; 23 | 24 | void surf (Input IN, inout SurfaceOutput o) { 25 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 26 | o.Albedo = c.rgb; 27 | o.Alpha = c.a; 28 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 29 | } 30 | ENDCG 31 | } 32 | 33 | FallBack "Transparent/Diffuse" 34 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Alpha-Diffuse.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 5 | } 6 | 7 | SubShader { 8 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 9 | LOD 200 10 | 11 | CGPROGRAM 12 | #pragma surface surf Lambert alpha 13 | 14 | sampler2D _MainTex; 15 | fixed4 _Color; 16 | 17 | struct Input { 18 | float2 uv_MainTex; 19 | }; 20 | 21 | void surf (Input IN, inout SurfaceOutput o) { 22 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 23 | o.Albedo = c.rgb; 24 | o.Alpha = c.a; 25 | } 26 | ENDCG 27 | } 28 | 29 | Fallback "Transparent/VertexLit" 30 | } 31 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Alpha-Glossy.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) 5 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 6 | _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} 7 | } 8 | 9 | SubShader { 10 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 11 | LOD 300 12 | 13 | CGPROGRAM 14 | #pragma surface surf BlinnPhong alpha 15 | 16 | sampler2D _MainTex; 17 | fixed4 _Color; 18 | half _Shininess; 19 | 20 | struct Input { 21 | float2 uv_MainTex; 22 | }; 23 | 24 | void surf (Input IN, inout SurfaceOutput o) { 25 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 26 | o.Albedo = tex.rgb * _Color.rgb; 27 | o.Gloss = tex.a; 28 | o.Alpha = tex.a * _Color.a; 29 | o.Specular = _Shininess; 30 | } 31 | ENDCG 32 | } 33 | 34 | Fallback "Transparent/VertexLit" 35 | } 36 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Alpha-Parallax.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Parallax Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _Parallax ("Height", Range (0.005, 0.08)) = 0.02 5 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 6 | _BumpMap ("Normalmap", 2D) = "bump" {} 7 | _ParallaxMap ("Heightmap (A)", 2D) = "black" {} 8 | } 9 | 10 | SubShader { 11 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 12 | LOD 500 13 | 14 | CGPROGRAM 15 | #pragma surface surf Lambert alpha 16 | 17 | sampler2D _MainTex; 18 | sampler2D _BumpMap; 19 | sampler2D _ParallaxMap; 20 | fixed4 _Color; 21 | float _Parallax; 22 | 23 | struct Input { 24 | float2 uv_MainTex; 25 | float2 uv_BumpMap; 26 | float3 viewDir; 27 | }; 28 | 29 | void surf (Input IN, inout SurfaceOutput o) { 30 | half h = tex2D (_ParallaxMap, IN.uv_BumpMap).w; 31 | float2 offset = ParallaxOffset (h, _Parallax, IN.viewDir); 32 | IN.uv_MainTex += offset; 33 | IN.uv_BumpMap += offset; 34 | 35 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 36 | o.Albedo = c.rgb; 37 | o.Alpha = c.a; 38 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 39 | } 40 | ENDCG 41 | } 42 | 43 | FallBack "Transparent/Bumped Diffuse" 44 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Alpha-ParallaxSpec.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Parallax Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) 5 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 6 | _Parallax ("Height", Range (0.005, 0.08)) = 0.02 7 | _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} 8 | _BumpMap ("Normalmap", 2D) = "bump" {} 9 | _ParallaxMap ("Heightmap (A)", 2D) = "black" {} 10 | } 11 | 12 | SubShader { 13 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 14 | LOD 600 15 | 16 | CGPROGRAM 17 | #pragma surface surf BlinnPhong alpha 18 | #pragma exclude_renderers flash 19 | 20 | sampler2D _MainTex; 21 | sampler2D _BumpMap; 22 | sampler2D _ParallaxMap; 23 | fixed4 _Color; 24 | half _Shininess; 25 | float _Parallax; 26 | 27 | struct Input { 28 | float2 uv_MainTex; 29 | float2 uv_BumpMap; 30 | float3 viewDir; 31 | }; 32 | 33 | void surf (Input IN, inout SurfaceOutput o) { 34 | half h = tex2D (_ParallaxMap, IN.uv_BumpMap).w; 35 | float2 offset = ParallaxOffset (h, _Parallax, IN.viewDir); 36 | IN.uv_MainTex += offset; 37 | IN.uv_BumpMap += offset; 38 | 39 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 40 | o.Albedo = tex.rgb * _Color.rgb; 41 | o.Gloss = tex.a; 42 | o.Alpha = tex.a * _Color.a; 43 | o.Specular = _Shininess; 44 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 45 | } 46 | ENDCG 47 | } 48 | 49 | FallBack "Transparent/Bumped Specular" 50 | } 51 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Alpha-VertexLit.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/VertexLit" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Spec Color", Color) = (1,1,1,0) 5 | _Emission ("Emissive Color", Color) = (0,0,0,0) 6 | _Shininess ("Shininess", Range (0.1, 1)) = 0.7 7 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 8 | } 9 | 10 | // 2/3 texture stage GPUs 11 | SubShader { 12 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 13 | LOD 100 14 | 15 | Alphatest Greater 0 16 | ZWrite Off 17 | Blend SrcAlpha OneMinusSrcAlpha 18 | ColorMask RGB 19 | 20 | // Non-lightmapped 21 | Pass { 22 | Tags { "LightMode" = "Vertex" } 23 | Material { 24 | Diffuse [_Color] 25 | Ambient [_Color] 26 | Shininess [_Shininess] 27 | Specular [_SpecColor] 28 | Emission [_Emission] 29 | } 30 | Lighting On 31 | SeparateSpecular On 32 | SetTexture [_MainTex] { 33 | Combine texture * primary DOUBLE, texture * primary 34 | } 35 | } 36 | 37 | // Lightmapped, encoded as dLDR 38 | Pass { 39 | Tags { "LightMode" = "VertexLM" } 40 | 41 | BindChannels { 42 | Bind "Vertex", vertex 43 | Bind "normal", normal 44 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 45 | Bind "texcoord", texcoord1 // main uses 1st uv 46 | } 47 | SetTexture [unity_Lightmap] { 48 | matrix [unity_LightmapMatrix] 49 | constantColor [_Color] 50 | combine texture * constant 51 | } 52 | SetTexture [_MainTex] { 53 | combine texture * previous DOUBLE, texture * primary 54 | } 55 | } 56 | 57 | // Lightmapped, encoded as RGBM 58 | Pass { 59 | Tags { "LightMode" = "VertexLMRGBM" } 60 | 61 | BindChannels { 62 | Bind "Vertex", vertex 63 | Bind "normal", normal 64 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 65 | Bind "texcoord1", texcoord1 // unused 66 | Bind "texcoord", texcoord2 // main uses 1st uv 67 | } 68 | 69 | SetTexture [unity_Lightmap] { 70 | matrix [unity_LightmapMatrix] 71 | combine texture * texture alpha DOUBLE 72 | } 73 | SetTexture [unity_Lightmap] { 74 | constantColor [_Color] 75 | combine previous * constant 76 | } 77 | SetTexture [_MainTex] { 78 | combine texture * previous QUAD, texture * primary 79 | } 80 | } 81 | } 82 | 83 | // 1 texture stage GPUs 84 | SubShader { 85 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 86 | LOD 100 87 | 88 | Alphatest Greater 0 89 | ZWrite Off 90 | Blend SrcAlpha OneMinusSrcAlpha 91 | ColorMask RGB 92 | 93 | Pass { 94 | Tags { "LightMode" = "Always" } 95 | Material { 96 | Diffuse [_Color] 97 | Ambient [_Color] 98 | Shininess [_Shininess] 99 | Specular [_SpecColor] 100 | Emission [_Emission] 101 | } 102 | Lighting On 103 | SeparateSpecular On 104 | SetTexture [_MainTex] { 105 | Combine texture * primary DOUBLE, texture * primary 106 | } 107 | } 108 | } 109 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/AlphaTest-BumpSpec.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Cutout/Bumped Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) 5 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 6 | _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} 7 | _BumpMap ("Normalmap", 2D) = "bump" {} 8 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 9 | } 10 | 11 | SubShader { 12 | Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"} 13 | LOD 400 14 | 15 | CGPROGRAM 16 | #pragma surface surf BlinnPhong alphatest:_Cutoff 17 | #pragma exclude_renderers flash 18 | 19 | sampler2D _MainTex; 20 | sampler2D _BumpMap; 21 | fixed4 _Color; 22 | half _Shininess; 23 | 24 | struct Input { 25 | float2 uv_MainTex; 26 | float2 uv_BumpMap; 27 | }; 28 | 29 | void surf (Input IN, inout SurfaceOutput o) { 30 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 31 | o.Albedo = tex.rgb * _Color.rgb; 32 | o.Gloss = tex.a; 33 | o.Alpha = tex.a * _Color.a; 34 | o.Specular = _Shininess; 35 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 36 | } 37 | ENDCG 38 | } 39 | 40 | FallBack "Transparent/Cutout/VertexLit" 41 | } 42 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/AlphaTest-Bumped.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Cutout/Bumped Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 5 | _BumpMap ("Normalmap", 2D) = "bump" {} 6 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 7 | } 8 | 9 | SubShader { 10 | Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"} 11 | LOD 300 12 | 13 | CGPROGRAM 14 | #pragma surface surf Lambert alphatest:_Cutoff 15 | 16 | sampler2D _MainTex; 17 | sampler2D _BumpMap; 18 | fixed4 _Color; 19 | 20 | struct Input { 21 | float2 uv_MainTex; 22 | float2 uv_BumpMap; 23 | }; 24 | 25 | void surf (Input IN, inout SurfaceOutput o) { 26 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 27 | o.Albedo = c.rgb; 28 | o.Alpha = c.a; 29 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 30 | } 31 | ENDCG 32 | } 33 | 34 | FallBack "Transparent/Cutout/Diffuse" 35 | } 36 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/AlphaTest-Diffuse.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Cutout/Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 5 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 6 | } 7 | 8 | SubShader { 9 | Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"} 10 | LOD 200 11 | 12 | CGPROGRAM 13 | #pragma surface surf Lambert alphatest:_Cutoff 14 | 15 | sampler2D _MainTex; 16 | fixed4 _Color; 17 | 18 | struct Input { 19 | float2 uv_MainTex; 20 | }; 21 | 22 | void surf (Input IN, inout SurfaceOutput o) { 23 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 24 | o.Albedo = c.rgb; 25 | o.Alpha = c.a; 26 | } 27 | ENDCG 28 | } 29 | 30 | Fallback "Transparent/Cutout/VertexLit" 31 | } 32 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/AlphaTest-Glossy.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Cutout/Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) 5 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 6 | _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} 7 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 8 | } 9 | 10 | SubShader { 11 | Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"} 12 | LOD 300 13 | 14 | CGPROGRAM 15 | #pragma surface surf BlinnPhong alphatest:_Cutoff 16 | 17 | sampler2D _MainTex; 18 | fixed4 _Color; 19 | half _Shininess; 20 | 21 | struct Input { 22 | float2 uv_MainTex; 23 | }; 24 | 25 | void surf (Input IN, inout SurfaceOutput o) { 26 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 27 | o.Albedo = tex.rgb * _Color.rgb; 28 | o.Gloss = tex.a; 29 | o.Alpha = tex.a * _Color.a; 30 | o.Specular = _Shininess; 31 | } 32 | ENDCG 33 | } 34 | 35 | Fallback "Transparent/Cutout/VertexLit" 36 | } 37 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/AlphaTest-SoftEdgeUnlit.shader: -------------------------------------------------------------------------------- 1 | /* 2 | Renders doubled sides objects without lighting. Useful for 3 | grass, trees or foliage. 4 | 5 | This shader renders two passes for all geometry, one 6 | for opaque parts and one with semitransparent details. 7 | 8 | This makes it possible to render transparent objects 9 | like grass without them being sorted by depth. 10 | */ 11 | 12 | Shader "Transparent/Cutout/Soft Edge Unlit" { 13 | Properties { 14 | _Color ("Main Color", Color) = (1, 1, 1, 1) 15 | _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {} 16 | _Cutoff ("Base Alpha cutoff", Range (0,.9)) = .5 17 | } 18 | 19 | SubShader { 20 | Tags { "Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout" } 21 | Lighting off 22 | 23 | // Render both front and back facing polygons. 24 | Cull Off 25 | 26 | // first pass: 27 | // render any pixels that are more than [_Cutoff] opaque 28 | Pass { 29 | CGPROGRAM 30 | #pragma vertex vert 31 | #pragma fragment frag 32 | 33 | #include "UnityCG.cginc" 34 | 35 | struct appdata_t { 36 | float4 vertex : POSITION; 37 | float4 color : COLOR; 38 | float2 texcoord : TEXCOORD0; 39 | }; 40 | 41 | struct v2f { 42 | float4 vertex : POSITION; 43 | float4 color : COLOR; 44 | float2 texcoord : TEXCOORD0; 45 | }; 46 | 47 | sampler2D _MainTex; 48 | float4 _MainTex_ST; 49 | float _Cutoff; 50 | 51 | v2f vert (appdata_t v) 52 | { 53 | v2f o; 54 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 55 | o.color = v.color; 56 | o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); 57 | return o; 58 | } 59 | 60 | float4 _Color; 61 | half4 frag (v2f i) : COLOR 62 | { 63 | half4 col = _Color * tex2D(_MainTex, i.texcoord); 64 | clip(col.a - _Cutoff); 65 | return col; 66 | } 67 | ENDCG 68 | } 69 | 70 | // Second pass: 71 | // render the semitransparent details. 72 | Pass { 73 | Tags { "RequireOption" = "SoftVegetation" } 74 | 75 | // Dont write to the depth buffer 76 | ZWrite off 77 | 78 | // Set up alpha blending 79 | Blend SrcAlpha OneMinusSrcAlpha 80 | 81 | CGPROGRAM 82 | #pragma vertex vert 83 | #pragma fragment frag 84 | 85 | #include "UnityCG.cginc" 86 | 87 | struct appdata_t { 88 | float4 vertex : POSITION; 89 | float4 color : COLOR; 90 | float2 texcoord : TEXCOORD0; 91 | }; 92 | 93 | struct v2f { 94 | float4 vertex : POSITION; 95 | float4 color : COLOR; 96 | float2 texcoord : TEXCOORD0; 97 | }; 98 | 99 | sampler2D _MainTex; 100 | float4 _MainTex_ST; 101 | float _Cutoff; 102 | 103 | v2f vert (appdata_t v) 104 | { 105 | v2f o; 106 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 107 | o.color = v.color; 108 | o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); 109 | return o; 110 | } 111 | 112 | float4 _Color; 113 | half4 frag (v2f i) : COLOR 114 | { 115 | half4 col = _Color * tex2D(_MainTex, i.texcoord); 116 | clip(-(col.a - _Cutoff)); 117 | return col; 118 | } 119 | ENDCG 120 | } 121 | } 122 | 123 | SubShader { 124 | Tags { "IgnoreProjector"="True" "RenderType"="TransparentCutout" } 125 | Lighting off 126 | 127 | // Render both front and back facing polygons. 128 | Cull Off 129 | 130 | // first pass: 131 | // render any pixels that are more than [_Cutoff] opaque 132 | Pass { 133 | AlphaTest Greater [_Cutoff] 134 | SetTexture [_MainTex] { 135 | constantColor [_Color] 136 | combine texture * constant, texture * constant 137 | } 138 | } 139 | 140 | // Second pass: 141 | // render the semitransparent details. 142 | Pass { 143 | Tags { "RequireOption" = "SoftVegetation" } 144 | 145 | // Dont write to the depth buffer 146 | ZWrite off 147 | 148 | // Only render pixels less or equal to the value 149 | AlphaTest LEqual [_Cutoff] 150 | 151 | // Set up alpha blending 152 | Blend SrcAlpha OneMinusSrcAlpha 153 | 154 | SetTexture [_MainTex] { 155 | constantColor [_Color] 156 | Combine texture * constant, texture * constant 157 | } 158 | } 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/AlphaTest-VertexLit.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Cutout/VertexLit" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Spec Color", Color) = (1,1,1,0) 5 | _Emission ("Emissive Color", Color) = (0,0,0,0) 6 | _Shininess ("Shininess", Range (0.1, 1)) = 0.7 7 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 8 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 9 | } 10 | 11 | // 2/3 texture stage GPUs 12 | SubShader { 13 | Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"} 14 | LOD 100 15 | 16 | // Non-lightmapped 17 | Pass { 18 | Tags { "LightMode" = "Vertex" } 19 | Alphatest Greater [_Cutoff] 20 | AlphaToMask True 21 | ColorMask RGB 22 | Material { 23 | Diffuse [_Color] 24 | Ambient [_Color] 25 | Shininess [_Shininess] 26 | Specular [_SpecColor] 27 | Emission [_Emission] 28 | } 29 | Lighting On 30 | SeparateSpecular On 31 | SetTexture [_MainTex] { 32 | Combine texture * primary DOUBLE, texture * primary 33 | } 34 | } 35 | 36 | // Lightmapped, encoded as dLDR 37 | Pass { 38 | Tags { "LightMode" = "VertexLM" } 39 | Alphatest Greater [_Cutoff] 40 | AlphaToMask True 41 | ColorMask RGB 42 | 43 | BindChannels { 44 | Bind "Vertex", vertex 45 | Bind "normal", normal 46 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 47 | Bind "texcoord", texcoord1 // main uses 1st uv 48 | } 49 | SetTexture [unity_Lightmap] { 50 | matrix [unity_LightmapMatrix] 51 | constantColor [_Color] 52 | combine texture * constant 53 | } 54 | SetTexture [_MainTex] { 55 | combine texture * previous DOUBLE, texture * primary 56 | } 57 | } 58 | 59 | // Lightmapped, encoded as RGBM 60 | Pass { 61 | Tags { "LightMode" = "VertexLMRGBM" } 62 | Alphatest Greater [_Cutoff] 63 | AlphaToMask True 64 | ColorMask RGB 65 | 66 | BindChannels { 67 | Bind "Vertex", vertex 68 | Bind "normal", normal 69 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 70 | Bind "texcoord1", texcoord1 // unused 71 | Bind "texcoord", texcoord2 // main uses 1st uv 72 | } 73 | 74 | SetTexture [unity_Lightmap] { 75 | matrix [unity_LightmapMatrix] 76 | combine texture * texture alpha DOUBLE 77 | } 78 | SetTexture [unity_Lightmap] { 79 | constantColor [_Color] 80 | combine previous * constant 81 | } 82 | SetTexture [_MainTex] { 83 | combine texture * previous QUAD, texture * primary 84 | } 85 | } 86 | 87 | // Pass to render object as a shadow caster 88 | Pass { 89 | Name "Caster" 90 | Tags { "LightMode" = "ShadowCaster" } 91 | Offset 1, 1 92 | 93 | Fog {Mode Off} 94 | ZWrite On ZTest LEqual Cull Off 95 | 96 | CGPROGRAM 97 | #pragma vertex vert 98 | #pragma fragment frag 99 | #pragma multi_compile_shadowcaster 100 | #pragma fragmentoption ARB_precision_hint_fastest 101 | #include "UnityCG.cginc" 102 | 103 | struct v2f { 104 | V2F_SHADOW_CASTER; 105 | float2 uv : TEXCOORD1; 106 | }; 107 | 108 | uniform float4 _MainTex_ST; 109 | 110 | v2f vert( appdata_base v ) 111 | { 112 | v2f o; 113 | TRANSFER_SHADOW_CASTER(o) 114 | o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); 115 | return o; 116 | } 117 | 118 | uniform sampler2D _MainTex; 119 | uniform fixed _Cutoff; 120 | uniform fixed4 _Color; 121 | 122 | float4 frag( v2f i ) : COLOR 123 | { 124 | fixed4 texcol = tex2D( _MainTex, i.uv ); 125 | clip( texcol.a*_Color.a - _Cutoff ); 126 | 127 | SHADOW_CASTER_FRAGMENT(i) 128 | } 129 | ENDCG 130 | 131 | } 132 | 133 | // Pass to render object as a shadow collector 134 | Pass { 135 | Name "ShadowCollector" 136 | Tags { "LightMode" = "ShadowCollector" } 137 | 138 | Fog {Mode Off} 139 | ZWrite On ZTest LEqual 140 | 141 | CGPROGRAM 142 | #pragma vertex vert 143 | #pragma fragment frag 144 | #pragma fragmentoption ARB_precision_hint_fastest 145 | #pragma multi_compile_shadowcollector 146 | 147 | #define SHADOW_COLLECTOR_PASS 148 | #include "UnityCG.cginc" 149 | 150 | struct v2f { 151 | V2F_SHADOW_COLLECTOR; 152 | float2 uv : TEXCOORD5; 153 | }; 154 | 155 | uniform float4 _MainTex_ST; 156 | 157 | v2f vert (appdata_base v) 158 | { 159 | v2f o; 160 | TRANSFER_SHADOW_COLLECTOR(o) 161 | o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); 162 | return o; 163 | } 164 | 165 | uniform sampler2D _MainTex; 166 | uniform fixed _Cutoff; 167 | uniform fixed4 _Color; 168 | 169 | fixed4 frag (v2f i) : COLOR 170 | { 171 | fixed4 texcol = tex2D( _MainTex, i.uv ); 172 | clip( texcol.a*_Color.a - _Cutoff ); 173 | 174 | SHADOW_COLLECTOR_FRAGMENT(i) 175 | } 176 | ENDCG 177 | 178 | } 179 | } 180 | 181 | // 1 texture stage GPUs 182 | SubShader { 183 | Tags {"IgnoreProjector"="True" "RenderType"="TransparentCutout"} 184 | LOD 100 185 | 186 | Pass { 187 | Tags { "LightMode" = "Always" } 188 | Alphatest Greater [_Cutoff] 189 | AlphaToMask True 190 | ColorMask RGB 191 | Material { 192 | Diffuse [_Color] 193 | Ambient [_Color] 194 | Shininess [_Shininess] 195 | Specular [_SpecColor] 196 | Emission [_Emission] 197 | } 198 | Lighting On 199 | SeparateSpecular On 200 | SetTexture [_MainTex] { 201 | Combine texture * primary DOUBLE, texture * primary 202 | } 203 | } 204 | } 205 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Decal.shader: -------------------------------------------------------------------------------- 1 | Shader "Decal" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _MainTex ("Base (RGB)", 2D) = "white" {} 5 | _DecalTex ("Decal (RGBA)", 2D) = "black" {} 6 | } 7 | 8 | SubShader { 9 | Tags { "RenderType"="Opaque" } 10 | LOD 250 11 | 12 | CGPROGRAM 13 | #pragma surface surf Lambert 14 | 15 | sampler2D _MainTex; 16 | sampler2D _DecalTex; 17 | fixed4 _Color; 18 | 19 | struct Input { 20 | float2 uv_MainTex; 21 | float2 uv_DecalTex; 22 | }; 23 | 24 | void surf (Input IN, inout SurfaceOutput o) { 25 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex); 26 | half4 decal = tex2D(_DecalTex, IN.uv_DecalTex); 27 | c.rgb = lerp (c.rgb, decal.rgb, decal.a); 28 | c *= _Color; 29 | o.Albedo = c.rgb; 30 | o.Alpha = c.a; 31 | } 32 | ENDCG 33 | } 34 | 35 | Fallback "Diffuse" 36 | } 37 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Flare.shader: -------------------------------------------------------------------------------- 1 | Shader "FX/Flare" { 2 | Properties { 3 | _MainTex ("Particle Texture", 2D) = "black" {} 4 | } 5 | SubShader { 6 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 7 | Cull Off Lighting Off ZWrite Off Ztest Always Fog { Mode Off } 8 | Blend One One 9 | 10 | Pass { 11 | CGPROGRAM 12 | #pragma vertex vert 13 | #pragma fragment frag 14 | #pragma fragmentoption ARB_precision_hint_fastest 15 | 16 | #include "UnityCG.cginc" 17 | 18 | sampler2D _MainTex; 19 | fixed4 _TintColor; 20 | 21 | struct appdata_t { 22 | float4 vertex : POSITION; 23 | fixed4 color : COLOR; 24 | float2 texcoord : TEXCOORD0; 25 | }; 26 | 27 | struct v2f { 28 | float4 vertex : POSITION; 29 | fixed4 color : COLOR; 30 | float2 texcoord : TEXCOORD0; 31 | }; 32 | 33 | float4 _MainTex_ST; 34 | 35 | v2f vert (appdata_t v) 36 | { 37 | v2f o; 38 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 39 | o.color = v.color; 40 | o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); 41 | return o; 42 | } 43 | 44 | fixed4 frag (v2f i) : COLOR 45 | { 46 | fixed4 col; 47 | fixed4 tex = tex2D(_MainTex, i.texcoord); 48 | col.rgb = i.color.rgb * tex.rgb; 49 | col.a = tex.a; 50 | return col; 51 | } 52 | ENDCG 53 | } 54 | } 55 | 56 | SubShader { 57 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 58 | Cull Off Lighting Off ZWrite Off Ztest Always Fog { Mode Off } 59 | Blend One One 60 | Color (1,1,1,1) 61 | Pass { 62 | SetTexture [_MainTex] { combine texture * primary, texture } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Font.shader: -------------------------------------------------------------------------------- 1 | Shader "GUI/Text Shader" { 2 | Properties { 3 | _MainTex ("Font Texture", 2D) = "white" {} 4 | _Color ("Text Color", Color) = (1,1,1,1) 5 | } 6 | 7 | SubShader { 8 | 9 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 10 | Lighting Off Cull Off ZTest Always ZWrite Off Fog { Mode Off } 11 | Blend SrcAlpha OneMinusSrcAlpha 12 | 13 | Pass { 14 | CGPROGRAM 15 | #pragma vertex vert 16 | #pragma fragment frag 17 | #pragma fragmentoption ARB_precision_hint_fastest 18 | 19 | #include "UnityCG.cginc" 20 | 21 | struct appdata_t { 22 | float4 vertex : POSITION; 23 | float2 texcoord : TEXCOORD0; 24 | }; 25 | 26 | struct v2f { 27 | float4 vertex : POSITION; 28 | float2 texcoord : TEXCOORD0; 29 | }; 30 | 31 | sampler2D _MainTex; 32 | uniform float4 _MainTex_ST; 33 | uniform fixed4 _Color; 34 | 35 | v2f vert (appdata_t v) 36 | { 37 | v2f o; 38 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 39 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 40 | return o; 41 | } 42 | 43 | fixed4 frag (v2f i) : COLOR 44 | { 45 | fixed4 col = _Color; 46 | col.a *= tex2D(_MainTex, i.texcoord).a; 47 | return col; 48 | } 49 | ENDCG 50 | } 51 | } 52 | 53 | SubShader { 54 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 55 | Lighting Off Cull Off ZTest Always ZWrite Off Fog { Mode Off } 56 | Blend SrcAlpha OneMinusSrcAlpha 57 | Pass { 58 | Color [_Color] 59 | SetTexture [_MainTex] { 60 | combine primary, texture * primary 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Illumin-BumpSpec.shader: -------------------------------------------------------------------------------- 1 | Shader "Self-Illumin/Bumped Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) 5 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 6 | _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} 7 | _Illum ("Illumin (A)", 2D) = "white" {} 8 | _BumpMap ("Normalmap", 2D) = "bump" {} 9 | _EmissionLM ("Emission (Lightmapper)", Float) = 0 10 | } 11 | SubShader { 12 | Tags { "RenderType"="Opaque" } 13 | LOD 400 14 | CGPROGRAM 15 | #pragma surface surf BlinnPhong 16 | 17 | sampler2D _MainTex; 18 | sampler2D _BumpMap; 19 | sampler2D _Illum; 20 | fixed4 _Color; 21 | half _Shininess; 22 | 23 | struct Input { 24 | float2 uv_MainTex; 25 | float2 uv_Illum; 26 | float2 uv_BumpMap; 27 | }; 28 | 29 | void surf (Input IN, inout SurfaceOutput o) { 30 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 31 | fixed4 c = tex * _Color; 32 | o.Albedo = c.rgb; 33 | o.Emission = c.rgb * tex2D(_Illum, IN.uv_Illum).a; 34 | o.Gloss = tex.a; 35 | o.Alpha = c.a; 36 | o.Specular = _Shininess; 37 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 38 | } 39 | ENDCG 40 | } 41 | FallBack "Self-Illumin/Specular" 42 | } 43 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Illumin-Bumped.shader: -------------------------------------------------------------------------------- 1 | Shader "Self-Illumin/Bumped Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} 5 | _Illum ("Illumin (A)", 2D) = "white" {} 6 | _BumpMap ("Normalmap", 2D) = "bump" {} 7 | _EmissionLM ("Emission (Lightmapper)", Float) = 0 8 | } 9 | SubShader { 10 | Tags { "RenderType"="Opaque" } 11 | LOD 300 12 | 13 | CGPROGRAM 14 | #pragma surface surf Lambert 15 | 16 | sampler2D _MainTex; 17 | sampler2D _BumpMap; 18 | sampler2D _Illum; 19 | fixed4 _Color; 20 | 21 | struct Input { 22 | float2 uv_MainTex; 23 | float2 uv_Illum; 24 | float2 uv_BumpMap; 25 | }; 26 | 27 | void surf (Input IN, inout SurfaceOutput o) { 28 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 29 | fixed4 c = tex * _Color; 30 | o.Albedo = c.rgb; 31 | o.Emission = c.rgb * tex2D(_Illum, IN.uv_Illum).a; 32 | o.Alpha = c.a; 33 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 34 | } 35 | ENDCG 36 | } 37 | FallBack "Self-Illumin/Diffuse" 38 | } 39 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Illumin-Diffuse.shader: -------------------------------------------------------------------------------- 1 | Shader "Self-Illumin/Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} 5 | _Illum ("Illumin (A)", 2D) = "white" {} 6 | _EmissionLM ("Emission (Lightmapper)", Float) = 0 7 | } 8 | SubShader { 9 | Tags { "RenderType"="Opaque" } 10 | LOD 200 11 | 12 | CGPROGRAM 13 | #pragma surface surf Lambert 14 | 15 | sampler2D _MainTex; 16 | sampler2D _Illum; 17 | fixed4 _Color; 18 | 19 | struct Input { 20 | float2 uv_MainTex; 21 | float2 uv_Illum; 22 | }; 23 | 24 | void surf (Input IN, inout SurfaceOutput o) { 25 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 26 | fixed4 c = tex * _Color; 27 | o.Albedo = c.rgb; 28 | o.Emission = c.rgb * tex2D(_Illum, IN.uv_Illum).a; 29 | o.Alpha = c.a; 30 | } 31 | ENDCG 32 | } 33 | FallBack "Self-Illumin/VertexLit" 34 | } 35 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Illumin-Glossy.shader: -------------------------------------------------------------------------------- 1 | Shader "Self-Illumin/Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) 5 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 6 | _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} 7 | _Illum ("Illumin (A)", 2D) = "white" {} 8 | _EmissionLM ("Emission (Lightmapper)", Float) = 0 9 | } 10 | SubShader { 11 | Tags { "RenderType"="Opaque" } 12 | LOD 300 13 | 14 | CGPROGRAM 15 | #pragma surface surf BlinnPhong 16 | 17 | sampler2D _MainTex; 18 | sampler2D _Illum; 19 | fixed4 _Color; 20 | half _Shininess; 21 | 22 | struct Input { 23 | float2 uv_MainTex; 24 | float2 uv_Illum; 25 | }; 26 | 27 | void surf (Input IN, inout SurfaceOutput o) { 28 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 29 | fixed4 c = tex * _Color; 30 | o.Albedo = c.rgb; 31 | o.Emission = c.rgb * tex2D(_Illum, IN.uv_Illum).a; 32 | o.Gloss = tex.a; 33 | o.Alpha = c.a; 34 | o.Specular = _Shininess; 35 | } 36 | ENDCG 37 | } 38 | FallBack "Self-Illumin/Diffuse" 39 | } 40 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Illumin-Parallax.shader: -------------------------------------------------------------------------------- 1 | Shader "Self-Illumin/Parallax Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _Parallax ("Height", Range (0.005, 0.08)) = 0.02 5 | _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} 6 | _Illum ("Illumin (A)", 2D) = "white" {} 7 | _BumpMap ("Normalmap", 2D) = "bump" {} 8 | _ParallaxMap ("Heightmap (A)", 2D) = "black" {} 9 | _EmissionLM ("Emission (Lightmapper)", Float) = 0 10 | } 11 | SubShader { 12 | Tags { "RenderType"="Opaque" } 13 | LOD 500 14 | 15 | CGPROGRAM 16 | #pragma surface surf Lambert 17 | 18 | sampler2D _MainTex; 19 | sampler2D _BumpMap; 20 | sampler2D _ParallaxMap; 21 | sampler2D _Illum; 22 | fixed4 _Color; 23 | float _Parallax; 24 | 25 | struct Input { 26 | float2 uv_MainTex; 27 | float2 uv_BumpMap; 28 | float2 uv_Illum; 29 | float3 viewDir; 30 | }; 31 | 32 | void surf (Input IN, inout SurfaceOutput o) { 33 | half h = tex2D (_ParallaxMap, IN.uv_BumpMap).w; 34 | float2 offset = ParallaxOffset (h, _Parallax, IN.viewDir); 35 | IN.uv_MainTex += offset; 36 | IN.uv_BumpMap += offset; 37 | IN.uv_Illum += offset; 38 | 39 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 40 | o.Albedo = c.rgb; 41 | o.Emission = c.rgb * tex2D(_Illum, IN.uv_Illum).a; 42 | o.Alpha = c.a; 43 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 44 | } 45 | ENDCG 46 | } 47 | FallBack "Self-Illumin/Bumped Diffuse" 48 | } 49 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Illumin-ParallaxSpec.shader: -------------------------------------------------------------------------------- 1 | Shader "Self-Illumin/Parallax Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) 5 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 6 | _Parallax ("Height", Range (0.005, 0.08)) = 0.02 7 | _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} 8 | _Illum ("Illumin (A)", 2D) = "white" {} 9 | _BumpMap ("Normalmap", 2D) = "bump" {} 10 | _ParallaxMap ("Heightmap (A)", 2D) = "black" {} 11 | _EmissionLM ("Emission (Lightmapper)", Float) = 0 12 | } 13 | SubShader { 14 | Tags { "RenderType"="Opaque" } 15 | LOD 600 16 | 17 | CGPROGRAM 18 | #pragma surface surf BlinnPhong 19 | #pragma target 3.0 20 | 21 | sampler2D _MainTex; 22 | sampler2D _BumpMap; 23 | sampler2D _ParallaxMap; 24 | sampler2D _Illum; 25 | fixed4 _Color; 26 | float _Parallax; 27 | half _Shininess; 28 | 29 | struct Input { 30 | float2 uv_MainTex; 31 | float2 uv_BumpMap; 32 | float2 uv_Illum; 33 | float3 viewDir; 34 | }; 35 | 36 | void surf (Input IN, inout SurfaceOutput o) { 37 | half h = tex2D (_ParallaxMap, IN.uv_BumpMap).w; 38 | float2 offset = ParallaxOffset (h, _Parallax, IN.viewDir); 39 | IN.uv_MainTex += offset; 40 | IN.uv_BumpMap += offset; 41 | IN.uv_Illum += offset; 42 | 43 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 44 | fixed4 c = tex * _Color; 45 | o.Albedo = c.rgb; 46 | o.Gloss = tex.a; 47 | o.Emission = c.rgb * tex2D(_Illum, IN.uv_Illum).a; 48 | o.Specular = _Shininess; 49 | o.Alpha = c.a; 50 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 51 | } 52 | ENDCG 53 | } 54 | FallBack "Self-Illumin/Bumped Specular" 55 | } 56 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Illumin-VertexLit.shader: -------------------------------------------------------------------------------- 1 | Shader "Self-Illumin/VertexLit" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Spec Color", Color) = (1,1,1,1) 5 | _Shininess ("Shininess", Range (0.1, 1)) = 0.7 6 | _MainTex ("Base (RGB)", 2D) = "white" {} 7 | _Illum ("Illumin (A)", 2D) = "white" {} 8 | _EmissionLM ("Emission (Lightmapper)", Float) = 0 9 | } 10 | 11 | // ------------------------------------------------------------------ 12 | // Dual texture cards 13 | 14 | SubShader { 15 | LOD 100 16 | Tags { "RenderType"="Opaque" } 17 | 18 | Pass { 19 | Name "BASE" 20 | Tags {"LightMode" = "Vertex"} 21 | Material { 22 | Diffuse [_Color] 23 | Shininess [_Shininess] 24 | Specular [_SpecColor] 25 | } 26 | SeparateSpecular On 27 | Lighting On 28 | SetTexture [_Illum] { 29 | constantColor [_Color] 30 | combine constant lerp (texture) previous 31 | } 32 | SetTexture [_MainTex] { 33 | Combine texture * previous, texture*primary 34 | } 35 | } 36 | } 37 | 38 | Fallback "VertexLit" 39 | } 40 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Internal-BlitCopy.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/BlitCopy" { 2 | Properties { _MainTex ("", any) = "" {} } 3 | SubShader { 4 | Pass { 5 | ZTest Always Cull Off ZWrite Off Fog { Mode Off } 6 | 7 | CGPROGRAM 8 | #pragma vertex vert 9 | #pragma fragment frag 10 | #pragma fragmentoption ARB_precision_hint_fastest 11 | 12 | #include "UnityCG.cginc" 13 | 14 | sampler2D _MainTex; 15 | 16 | struct appdata_t { 17 | float4 vertex : POSITION; 18 | float2 texcoord : TEXCOORD0; 19 | }; 20 | 21 | struct v2f { 22 | float4 vertex : POSITION; 23 | float2 texcoord : TEXCOORD0; 24 | }; 25 | 26 | v2f vert (appdata_t v) 27 | { 28 | v2f o; 29 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 30 | o.texcoord = v.texcoord.xy; 31 | return o; 32 | } 33 | 34 | fixed4 frag (v2f i) : COLOR 35 | { 36 | return tex2D(_MainTex, i.texcoord); 37 | } 38 | ENDCG 39 | 40 | } 41 | } 42 | SubShader { 43 | Pass { 44 | ZTest Always Cull Off ZWrite Off Fog { Mode Off } 45 | SetTexture [_MainTex] { combine texture } 46 | } 47 | } 48 | Fallback Off 49 | } 50 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Internal-CombineDepthNormals.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Internal-CombineDepthNormals" { 2 | SubShader { 3 | 4 | Pass { 5 | ZWrite Off ZTest Always Cull Off Fog { Mode Off } 6 | CGPROGRAM 7 | #pragma vertex vert 8 | #pragma fragment frag 9 | #include "UnityCG.cginc" 10 | 11 | struct appdata { 12 | float4 vertex : POSITION; 13 | float2 texcoord : TEXCOORD0; 14 | }; 15 | 16 | struct v2f { 17 | float4 pos : SV_POSITION; 18 | float2 uv : TEXCOORD0; 19 | }; 20 | float4 _CameraNormalsTexture_ST; 21 | 22 | v2f vert (appdata v) 23 | { 24 | v2f o; 25 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 26 | o.uv = TRANSFORM_TEX(v.texcoord,_CameraNormalsTexture); 27 | return o; 28 | } 29 | sampler2D _CameraDepthTexture; 30 | sampler2D _CameraNormalsTexture; 31 | 32 | float4x4 _WorldToCamera; 33 | 34 | fixed4 frag (v2f i) : COLOR 35 | { 36 | float d = UNITY_SAMPLE_DEPTH(tex2D (_CameraDepthTexture, i.uv)); 37 | float3 n = tex2D (_CameraNormalsTexture, i.uv) * 2.0 - 1.0; 38 | d = Linear01Depth (d); 39 | n = mul ((float3x3)_WorldToCamera, n); 40 | n.z = -n.z; 41 | return (d < (1.0-1.0/65025.0)) ? EncodeDepthNormal (d, n.xyz) : float4(0.5,0.5,1.0,1.0); 42 | } 43 | ENDCG 44 | } 45 | 46 | } 47 | Fallback Off 48 | } 49 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Internal-Flare.shader: -------------------------------------------------------------------------------- 1 | 2 | Shader "Hidden/Internal-Flare" 3 | { 4 | SubShader { 5 | 6 | Tags {"RenderType"="Overlay"} 7 | ZWrite Off ZTest Always 8 | Fog {Mode Off} 9 | Cull Off 10 | Blend One One 11 | ColorMask RGB 12 | 13 | Pass { 14 | CGPROGRAM 15 | #pragma vertex vert 16 | #pragma fragment frag 17 | #pragma fragmentoption ARB_precision_hint_fastest 18 | 19 | #include "UnityCG.cginc" 20 | 21 | sampler2D _FlareTexture; 22 | 23 | struct appdata_t { 24 | float4 vertex : POSITION; 25 | fixed4 color : COLOR; 26 | float2 texcoord : TEXCOORD0; 27 | }; 28 | 29 | struct v2f { 30 | float4 vertex : POSITION; 31 | fixed4 color : COLOR; 32 | float2 texcoord : TEXCOORD0; 33 | }; 34 | 35 | float4 _FlareTexture_ST; 36 | 37 | v2f vert (appdata_t v) 38 | { 39 | v2f o; 40 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 41 | o.color = v.color; 42 | o.texcoord = TRANSFORM_TEX(v.texcoord, _FlareTexture); 43 | return o; 44 | } 45 | 46 | fixed4 frag (v2f i) : COLOR 47 | { 48 | return tex2D(_FlareTexture, i.texcoord) * i.color; 49 | } 50 | ENDCG 51 | } 52 | } 53 | 54 | SubShader { 55 | Tags {"RenderType"="Overlay"} 56 | ZWrite Off ZTest Always 57 | Fog {Mode Off} 58 | Cull Off 59 | Blend One One 60 | ColorMask RGB 61 | BindChannels { 62 | Bind "vertex", vertex Bind "color", color Bind "texcoord", texcoord0 63 | } 64 | Pass { 65 | SetTexture [_FlareTexture] { combine previous * texture } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Internal-GUITexture.shader: -------------------------------------------------------------------------------- 1 | 2 | Shader "Hidden/Internal-GUITexture" 3 | { 4 | Properties { _MainTex ("Texture", any) = "" {} } 5 | 6 | SubShader { 7 | 8 | Tags { "ForceSupported" = "True" "RenderType"="Overlay" } 9 | 10 | Lighting Off 11 | Blend SrcAlpha OneMinusSrcAlpha 12 | Cull Off 13 | ZWrite Off 14 | Fog { Mode Off } 15 | ZTest Always 16 | 17 | Pass { 18 | CGPROGRAM 19 | #pragma vertex vert 20 | #pragma fragment frag 21 | #pragma fragmentoption ARB_precision_hint_fastest 22 | 23 | #include "UnityCG.cginc" 24 | 25 | struct appdata_t { 26 | float4 vertex : POSITION; 27 | fixed4 color : COLOR; 28 | float2 texcoord : TEXCOORD0; 29 | }; 30 | 31 | struct v2f { 32 | float4 vertex : POSITION; 33 | fixed4 color : COLOR; 34 | float2 texcoord : TEXCOORD0; 35 | }; 36 | 37 | sampler2D _MainTex; 38 | 39 | uniform float4 _MainTex_ST; 40 | 41 | v2f vert (appdata_t v) 42 | { 43 | v2f o; 44 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 45 | o.color = v.color; 46 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 47 | return o; 48 | } 49 | 50 | fixed4 frag (v2f i) : COLOR 51 | { 52 | return 2.0f * tex2D(_MainTex, i.texcoord) * i.color; 53 | } 54 | ENDCG 55 | } 56 | } 57 | 58 | 59 | SubShader { 60 | 61 | Tags { "ForceSupported" = "True" "RenderType"="Overlay" } 62 | 63 | Lighting Off 64 | Blend SrcAlpha OneMinusSrcAlpha 65 | Cull Off 66 | ZWrite Off 67 | Fog { Mode Off } 68 | ZTest Always 69 | 70 | BindChannels { 71 | Bind "vertex", vertex 72 | Bind "color", color 73 | Bind "TexCoord", texcoord 74 | } 75 | 76 | Pass { 77 | SetTexture [_MainTex] { 78 | combine primary * texture DOUBLE, primary * texture DOUBLE 79 | } 80 | } 81 | } 82 | 83 | Fallback off 84 | } 85 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Internal-GUITextureBlit.shader: -------------------------------------------------------------------------------- 1 | 2 | Shader "Hidden/Internal-GUITextureBlit" 3 | { 4 | Properties { _MainTex ("Texture", Any) = "white" {} } 5 | 6 | SubShader { 7 | Tags { "ForceSupported" = "True" } 8 | 9 | Lighting Off 10 | Blend SrcAlpha OneMinusSrcAlpha 11 | Cull Off 12 | ZWrite Off 13 | Fog { Mode Off } 14 | ZTest Always 15 | 16 | Pass { 17 | CGPROGRAM 18 | #pragma vertex vert 19 | #pragma fragment frag 20 | #pragma fragmentoption ARB_precision_hint_fastest 21 | 22 | #include "UnityCG.cginc" 23 | 24 | struct appdata_t { 25 | float4 vertex : POSITION; 26 | fixed4 color : COLOR; 27 | float2 texcoord : TEXCOORD0; 28 | }; 29 | 30 | struct v2f { 31 | float4 vertex : POSITION; 32 | fixed4 color : COLOR; 33 | float2 texcoord : TEXCOORD0; 34 | float2 texgencoord : TEXCOORD1; 35 | }; 36 | 37 | uniform float4 _MainTex_ST; 38 | uniform fixed4 _Color; 39 | uniform float4x4 _GUIClipTextureMatrix; 40 | 41 | v2f vert (appdata_t v) 42 | { 43 | v2f o; 44 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 45 | float4 texgen = mul(UNITY_MATRIX_MV, v.vertex); 46 | o.texgencoord = mul(_GUIClipTextureMatrix, texgen); 47 | o.color = v.color; 48 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 49 | return o; 50 | } 51 | 52 | sampler2D _MainTex; 53 | sampler2D _GUIClipTexture; 54 | 55 | fixed4 frag (v2f i) : COLOR 56 | { 57 | fixed4 col; 58 | col.rgb = tex2D (_MainTex, i.texcoord).rgb * i.color.rgb; 59 | col.a = i.color.a * tex2D(_GUIClipTexture, i.texgencoord).a; 60 | return col; 61 | } 62 | ENDCG 63 | } 64 | } 65 | 66 | SubShader 67 | { 68 | Tags { "ForceSupported" = "True" } 69 | Lighting Off 70 | Cull Off 71 | ZWrite Off 72 | Fog { Mode Off } 73 | ZTest Always 74 | Blend SrcAlpha OneMinusSrcAlpha 75 | 76 | BindChannels { 77 | Bind "vertex", vertex 78 | Bind "color", color 79 | Bind "TexCoord", texcoord 80 | } 81 | Pass { 82 | SetTexture [_MainTex] { 83 | combine primary * texture, primary 84 | } 85 | SetTexture [_GUIClipTexture] { 86 | combine previous, previous * texture alpha 87 | } 88 | } 89 | } 90 | 91 | // Really ancient subshader for single-texture cards... 92 | SubShader { Lighting Off Cull Off ZWrite Off Fog { Mode Off } ZTest Always 93 | Tags { "ForceSupported" = "True" } 94 | BindChannels { Bind "vertex", vertex Bind "color", color Bind "TexCoord", texcoord } 95 | Pass { ColorMask A SetTexture [_GUIClipTexture] { combine texture, texture alpha } } // write clip alpha to A 96 | Pass { ColorMask RGB Blend DstAlpha OneMinusDstAlpha SetTexture [_MainTex] { combine primary * texture } } // Get in main texture 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Internal-GUITextureClip.shader: -------------------------------------------------------------------------------- 1 | 2 | Shader "Hidden/Internal-GUITextureClip" 3 | { 4 | Properties { _MainTex ("Texture", Any) = "white" {} } 5 | 6 | SubShader { 7 | 8 | Tags { "ForceSupported" = "True" } 9 | 10 | Lighting Off 11 | Blend SrcAlpha OneMinusSrcAlpha 12 | Cull Off 13 | ZWrite Off 14 | Fog { Mode Off } 15 | ZTest Always 16 | 17 | Pass { 18 | CGPROGRAM 19 | #pragma vertex vert 20 | #pragma fragment frag 21 | #pragma fragmentoption ARB_precision_hint_fastest 22 | 23 | #include "UnityCG.cginc" 24 | 25 | struct appdata_t { 26 | float4 vertex : POSITION; 27 | fixed4 color : COLOR; 28 | float2 texcoord : TEXCOORD0; 29 | }; 30 | 31 | struct v2f { 32 | float4 vertex : POSITION; 33 | fixed4 color : COLOR; 34 | float2 texcoord : TEXCOORD0; 35 | float2 texgencoord : TEXCOORD1; 36 | }; 37 | 38 | sampler2D _MainTex; 39 | sampler2D _GUIClipTexture; 40 | 41 | uniform float4 _MainTex_ST; 42 | uniform fixed4 _Color; 43 | uniform float4x4 _GUIClipTextureMatrix; 44 | 45 | v2f vert (appdata_t v) 46 | { 47 | v2f o; 48 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 49 | float4 texgen = mul(UNITY_MATRIX_MV, v.vertex); 50 | o.texgencoord = mul(_GUIClipTextureMatrix, texgen); 51 | o.color = v.color; 52 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 53 | return o; 54 | } 55 | 56 | fixed4 frag (v2f i) : COLOR 57 | { 58 | fixed4 col = tex2D(_MainTex, i.texcoord) * i.color; 59 | col.a *= tex2D(_GUIClipTexture, i.texgencoord).a; 60 | return col; 61 | } 62 | ENDCG 63 | } 64 | } 65 | 66 | 67 | SubShader { 68 | Tags { "ForceSupported" = "True" } 69 | 70 | Lighting Off 71 | Blend SrcAlpha OneMinusSrcAlpha 72 | Cull Off 73 | ZWrite Off 74 | Fog { Mode Off } 75 | ZTest Always 76 | 77 | BindChannels { 78 | Bind "vertex", vertex 79 | Bind "color", color 80 | Bind "TexCoord", texcoord 81 | } 82 | 83 | Pass { 84 | SetTexture [_MainTex] { 85 | combine primary * texture 86 | } 87 | SetTexture [_GUIClipTexture] { // Clipping texture - Gets bound to the clipping matrix from code. 88 | combine previous, previous * texture alpha 89 | } 90 | } 91 | } 92 | SubShader { 93 | Tags { "ForceSupported" = "True" } 94 | Lighting Off 95 | Cull Off 96 | ZWrite Off 97 | Fog { Mode Off } 98 | ZTest Always 99 | 100 | BindChannels { 101 | Bind "vertex", vertex 102 | Bind "color", color 103 | Bind "TexCoord", texcoord 104 | } 105 | Pass { // Get the base alpha in 106 | ColorMask A 107 | SetTexture [_MainTex] { 108 | combine primary * texture 109 | } 110 | } 111 | Pass { // Multiply in the clip alpha 112 | ColorMask A 113 | Blend DstAlpha Zero 114 | SetTexture [_GUIClipTexture] { 115 | combine texture, texture alpha 116 | } 117 | } 118 | Pass { // Multiply in the clip alpha 119 | ColorMask RGB 120 | Blend DstAlpha OneMinusDstAlpha 121 | SetTexture [_MainTex] { 122 | combine primary * texture 123 | } 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Internal-GUITextureClipText.shader: -------------------------------------------------------------------------------- 1 | 2 | Shader "Hidden/Internal-GUITextureClipText" 3 | { 4 | Properties { _MainTex ("Texture", 2D) = "white" {} } 5 | 6 | SubShader { 7 | Tags { "ForceSupported" = "True" } 8 | 9 | Lighting Off 10 | Blend SrcAlpha OneMinusSrcAlpha 11 | Cull Off 12 | ZWrite Off 13 | Fog { Mode Off } 14 | ZTest Always 15 | 16 | Pass { 17 | CGPROGRAM 18 | #pragma vertex vert 19 | #pragma fragment frag 20 | #pragma fragmentoption ARB_precision_hint_fastest 21 | 22 | #include "UnityCG.cginc" 23 | 24 | struct appdata_t { 25 | float4 vertex : POSITION; 26 | fixed4 color : COLOR; 27 | float2 texcoord : TEXCOORD0; 28 | }; 29 | 30 | struct v2f { 31 | float4 vertex : POSITION; 32 | fixed4 color : COLOR; 33 | float2 texcoord : TEXCOORD0; 34 | float2 texgencoord : TEXCOORD1; 35 | }; 36 | 37 | sampler2D _MainTex; 38 | sampler2D _GUIClipTexture; 39 | 40 | uniform float4 _MainTex_ST; 41 | uniform fixed4 _Color; 42 | uniform float4x4 _GUIClipTextureMatrix; 43 | 44 | v2f vert (appdata_t v) 45 | { 46 | v2f o; 47 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 48 | float4 texgen = mul(UNITY_MATRIX_MV, v.vertex); 49 | o.texgencoord = mul(_GUIClipTextureMatrix, texgen); 50 | o.color = v.color; 51 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 52 | return o; 53 | } 54 | 55 | fixed4 frag (v2f i) : COLOR 56 | { 57 | fixed4 col = _Color; 58 | col.a *= tex2D(_MainTex, i.texcoord).a * tex2D(_GUIClipTexture, i.texgencoord).a; 59 | return col; 60 | } 61 | ENDCG 62 | } 63 | } 64 | 65 | SubShader { 66 | Tags { "ForceSupported" = "True" } 67 | 68 | Lighting Off 69 | Blend SrcAlpha OneMinusSrcAlpha 70 | Cull Off 71 | ZWrite Off 72 | Fog { Mode Off } 73 | ZTest Always 74 | 75 | Pass { 76 | SetTexture [_MainTex] { 77 | ConstantColor [_Color] combine constant, constant * texture alpha 78 | } 79 | SetTexture [_GUIClipTexture] { // clipping texture - Gets bound to the clipping matrix from code 80 | combine previous, previous * texture alpha 81 | } 82 | } 83 | } 84 | 85 | // Really ancient sub shader for single-texture cards 86 | SubShader { 87 | Lighting Off 88 | Cull Off 89 | ZWrite Off 90 | Fog { Mode Off } 91 | ZTest Always 92 | Tags { "ForceSupported" = "True" } 93 | 94 | Pass { // Get the base alpha in 95 | ColorMask A 96 | SetTexture [_MainTex] { 97 | ConstantColor [_Color] combine constant * texture alpha, constant * texture alpha 98 | } 99 | } 100 | Pass { // Multiply in the clip alpha 101 | ColorMask A 102 | Blend DstAlpha Zero 103 | SetTexture [_GUIClipTexture] { 104 | combine previous, previous * texture alpha 105 | } 106 | } 107 | Pass { // Get color 108 | ColorMask RGB 109 | Blend DstAlpha OneMinusDstAlpha 110 | SetTexture [_MainTex] { 111 | ConstantColor [_Color] combine constant * texture alpha} 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Internal-Halo.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Internal-Halo" { 2 | SubShader { 3 | Tags {"RenderType"="Overlay"} 4 | ZWrite off Cull off // NOTE: 'Cull off' is important as the halo meshes flip handedness each time... BUG: #1220 5 | Fog { Color (0,0,0,0) } 6 | Blend OneMinusDstColor One 7 | AlphaTest Greater 0 8 | ColorMask RGB 9 | Pass { 10 | CGPROGRAM 11 | #pragma vertex vert 12 | #pragma fragment frag 13 | #include "UnityCG.cginc" 14 | sampler2D _HaloFalloff; 15 | struct appdata_t { 16 | float4 vertex : POSITION; 17 | fixed4 color : COLOR; 18 | float2 texcoord : TEXCOORD0; 19 | }; 20 | struct v2f { 21 | float4 vertex : POSITION; 22 | fixed4 color : COLOR; 23 | float2 texcoord : TEXCOORD0; 24 | }; 25 | float4 _HaloFalloff_ST; 26 | v2f vert (appdata_t v) 27 | { 28 | v2f o; 29 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 30 | o.color = v.color; 31 | o.texcoord = TRANSFORM_TEX(v.texcoord,_HaloFalloff); 32 | return o; 33 | } 34 | fixed4 frag (v2f i) : COLOR 35 | { 36 | half a = tex2D(_HaloFalloff, i.texcoord).a; 37 | return half4 (i.color.rgb * a, a); 38 | } 39 | ENDCG 40 | } 41 | } 42 | SubShader { 43 | Tags {"RenderType"="Overlay"} 44 | ZWrite off Cull off // NOTE: 'Cull off' is important as the halo meshes flip handedness each time... BUG: #1220 45 | Fog { Color (0,0,0,0) } 46 | Blend OneMinusDstColor One 47 | AlphaTest Greater 0 48 | ColorMask RGB 49 | Pass { 50 | BindChannels { 51 | Bind "Vertex", vertex 52 | Bind "Color", color 53 | // caveat: because _HaloFalloff is a global texture prop, 54 | // can't bind to texcoord; need explicit texcoord0 55 | Bind "TexCoord", texcoord0 56 | } 57 | SetTexture [_HaloFalloff] { combine primary * texture alpha, texture alpha } 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Internal-PrePassCollectShadows.shader: -------------------------------------------------------------------------------- 1 | // Collects cascaded shadows into screen space buffer ready for blurring 2 | Shader "Hidden/Internal-PrePassCollectShadows" { 3 | Properties { 4 | _ShadowMapTexture ("", any) = "" {} 5 | } 6 | SubShader { 7 | Pass { 8 | ZWrite Off ZTest Always Cull Off Fog { Mode Off } 9 | 10 | CGPROGRAM 11 | #pragma vertex vert 12 | #pragma fragment frag 13 | #pragma exclude_renderers noshadows flash 14 | #pragma glsl_no_auto_normalization 15 | #pragma multi_compile_shadowcollector 16 | 17 | #include "UnityCG.cginc" 18 | struct appdata { 19 | float4 vertex : POSITION; 20 | float2 texcoord : TEXCOORD0; 21 | float3 normal : NORMAL; 22 | }; 23 | 24 | struct v2f { 25 | float4 pos : SV_POSITION; 26 | float2 uv : TEXCOORD0; 27 | float3 ray : TEXCOORD1; 28 | }; 29 | 30 | v2f vert (appdata v) 31 | { 32 | v2f o; 33 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 34 | o.uv = v.texcoord; 35 | o.ray = v.normal; 36 | return o; 37 | } 38 | sampler2D _CameraDepthTexture; 39 | float4 unity_LightmapFade; 40 | 41 | float4x4 _CameraToWorld; 42 | float4x4 unity_World2Shadow[4]; 43 | float4 _LightSplitsNear; 44 | float4 _LightSplitsFar; 45 | float4 unity_ShadowSplitSpheres[4]; 46 | float4 unity_ShadowSplitSqRadii; 47 | float4 unity_ShadowFadeCenterAndType; 48 | 49 | float4 _LightShadowData; 50 | sampler2D _ShadowMapTexture; 51 | 52 | inline float SquareLength(float3 vec) 53 | { 54 | return dot(vec, vec); 55 | } 56 | 57 | inline half unitySampleShadow (float4 wpos, float z) 58 | { 59 | float3 sc0 = mul (unity_World2Shadow[0], wpos).xyz; 60 | float3 sc1 = mul (unity_World2Shadow[1], wpos).xyz; 61 | float3 sc2 = mul (unity_World2Shadow[2], wpos).xyz; 62 | float3 sc3 = mul (unity_World2Shadow[3], wpos).xyz; 63 | 64 | #if defined (SHADOWS_SPLIT_SPHERES) 65 | float3 fromCenter0 = wpos.xyz - unity_ShadowSplitSpheres[0].xyz; 66 | float3 fromCenter1 = wpos.xyz - unity_ShadowSplitSpheres[1].xyz; 67 | float3 fromCenter2 = wpos.xyz - unity_ShadowSplitSpheres[2].xyz; 68 | float3 fromCenter3 = wpos.xyz - unity_ShadowSplitSpheres[3].xyz; 69 | float4 distances2 = float4(dot(fromCenter0,fromCenter0), dot(fromCenter1,fromCenter1), dot(fromCenter2,fromCenter2), dot(fromCenter3,fromCenter3)); 70 | float4 weights = float4(distances2 < unity_ShadowSplitSqRadii); 71 | weights.yzw = saturate(weights.yzw - weights.xyz); 72 | #else 73 | float4 zNear = float4( z >= _LightSplitsNear ); 74 | float4 zFar = float4( z < _LightSplitsFar ); 75 | float4 weights = zNear * zFar; 76 | #endif 77 | 78 | float4 coord = float4(sc0 * weights[0] + sc1 * weights[1] + sc2 * weights[2] + sc3 * weights[3], 1); 79 | #if defined (SHADOWS_NATIVE) && !defined (SHADER_API_OPENGL) 80 | half shadow = tex2Dproj (_ShadowMapTexture, UNITY_PROJ_COORD(coord)).r; 81 | shadow = lerp(_LightShadowData.r, 1.0, shadow); 82 | #else 83 | half shadow = UNITY_SAMPLE_DEPTH(tex2D (_ShadowMapTexture, coord.xy)) < coord.z ? _LightShadowData.r : 1.0; 84 | #endif 85 | //shadow = dot(weights, float4(0,0.33,0.66,1)*0.33); 86 | return shadow; 87 | } 88 | 89 | fixed4 frag (v2f i) : COLOR 90 | { 91 | float depth = UNITY_SAMPLE_DEPTH(tex2D (_CameraDepthTexture, i.uv)); 92 | depth = Linear01Depth (depth); 93 | float4 vpos = float4(i.ray * depth,1); 94 | float4 wpos = mul (_CameraToWorld, vpos); 95 | half shadow = unitySampleShadow (wpos, vpos.z); 96 | float4 res; 97 | res.x = shadow; 98 | res.y = 1.0; 99 | res.zw = EncodeFloatRG (1 - depth); 100 | return res; 101 | } 102 | 103 | ENDCG 104 | } 105 | 106 | } 107 | Fallback Off 108 | } 109 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Normal-BumpSpec.shader: -------------------------------------------------------------------------------- 1 | Shader "Bumped Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) 5 | _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 6 | _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} 7 | _BumpMap ("Normalmap", 2D) = "bump" {} 8 | } 9 | SubShader { 10 | Tags { "RenderType"="Opaque" } 11 | LOD 400 12 | 13 | CGPROGRAM 14 | #pragma surface surf BlinnPhong 15 | 16 | 17 | sampler2D _MainTex; 18 | sampler2D _BumpMap; 19 | fixed4 _Color; 20 | half _Shininess; 21 | 22 | struct Input { 23 | float2 uv_MainTex; 24 | float2 uv_BumpMap; 25 | }; 26 | 27 | void surf (Input IN, inout SurfaceOutput o) { 28 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 29 | o.Albedo = tex.rgb * _Color.rgb; 30 | o.Gloss = tex.a; 31 | o.Alpha = tex.a * _Color.a; 32 | o.Specular = _Shininess; 33 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 34 | } 35 | ENDCG 36 | } 37 | 38 | FallBack "Specular" 39 | } 40 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Normal-Bumped.shader: -------------------------------------------------------------------------------- 1 | Shader "Bumped Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _MainTex ("Base (RGB)", 2D) = "white" {} 5 | _BumpMap ("Normalmap", 2D) = "bump" {} 6 | } 7 | 8 | SubShader { 9 | Tags { "RenderType"="Opaque" } 10 | LOD 300 11 | 12 | CGPROGRAM 13 | #pragma surface surf Lambert 14 | 15 | sampler2D _MainTex; 16 | sampler2D _BumpMap; 17 | fixed4 _Color; 18 | 19 | struct Input { 20 | float2 uv_MainTex; 21 | float2 uv_BumpMap; 22 | }; 23 | 24 | void surf (Input IN, inout SurfaceOutput o) { 25 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 26 | o.Albedo = c.rgb; 27 | o.Alpha = c.a; 28 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 29 | } 30 | ENDCG 31 | } 32 | 33 | FallBack "Diffuse" 34 | } 35 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Normal-Diffuse.shader: -------------------------------------------------------------------------------- 1 | Shader "Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _MainTex ("Base (RGB)", 2D) = "white" {} 5 | } 6 | SubShader { 7 | Tags { "RenderType"="Opaque" } 8 | LOD 200 9 | 10 | CGPROGRAM 11 | #pragma surface surf Lambert 12 | 13 | sampler2D _MainTex; 14 | fixed4 _Color; 15 | 16 | struct Input { 17 | float2 uv_MainTex; 18 | }; 19 | 20 | void surf (Input IN, inout SurfaceOutput o) { 21 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 22 | o.Albedo = c.rgb; 23 | o.Alpha = c.a; 24 | } 25 | ENDCG 26 | } 27 | 28 | Fallback "VertexLit" 29 | } 30 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Normal-DiffuseDetail.shader: -------------------------------------------------------------------------------- 1 | Shader "Diffuse Detail" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _MainTex ("Base (RGB)", 2D) = "white" {} 5 | _Detail ("Detail (RGB)", 2D) = "gray" {} 6 | } 7 | 8 | SubShader { 9 | Tags { "RenderType"="Opaque" } 10 | LOD 250 11 | 12 | CGPROGRAM 13 | #pragma surface surf Lambert 14 | 15 | sampler2D _MainTex; 16 | sampler2D _Detail; 17 | fixed4 _Color; 18 | 19 | struct Input { 20 | float2 uv_MainTex; 21 | float2 uv_Detail; 22 | }; 23 | 24 | void surf (Input IN, inout SurfaceOutput o) { 25 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 26 | c.rgb *= tex2D(_Detail,IN.uv_Detail).rgb*2; 27 | o.Albedo = c.rgb; 28 | o.Alpha = c.a; 29 | } 30 | ENDCG 31 | } 32 | 33 | Fallback "Diffuse" 34 | } 35 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Normal-DiffuseFast.shader: -------------------------------------------------------------------------------- 1 | // Does not do anything in 3.x 2 | Shader "Legacy Shaders/Diffuse Fast" { 3 | Properties { 4 | _Color ("Main Color", Color) = (1,1,1,1) 5 | _MainTex ("Base (RGB)", 2D) = "white" {} 6 | } 7 | Fallback "VertexLit" 8 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Normal-DiffuseFogOff.shader: -------------------------------------------------------------------------------- 1 | Shader "DiffuseFogOff" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _MainTex ("Base (RGB)", 2D) = "white" {} 5 | } 6 | SubShader { 7 | Tags { "RenderType"="Opaque" } 8 | LOD 200 9 | Fog Off 10 | 11 | CGPROGRAM 12 | #pragma surface surf Lambert 13 | 14 | sampler2D _MainTex; 15 | fixed4 _Color; 16 | 17 | struct Input { 18 | float2 uv_MainTex; 19 | }; 20 | 21 | void surf (Input IN, inout SurfaceOutput o) { 22 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 23 | o.Albedo = c.rgb; 24 | o.Alpha = c.a; 25 | } 26 | ENDCG 27 | } 28 | 29 | Fallback "VertexLit" 30 | } 31 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Normal-Glossy.shader: -------------------------------------------------------------------------------- 1 | Shader "Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) 5 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 6 | _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} 7 | } 8 | 9 | SubShader { 10 | Tags { "RenderType"="Opaque" } 11 | LOD 300 12 | 13 | CGPROGRAM 14 | #pragma surface surf BlinnPhong 15 | 16 | sampler2D _MainTex; 17 | fixed4 _Color; 18 | half _Shininess; 19 | 20 | struct Input { 21 | float2 uv_MainTex; 22 | }; 23 | 24 | void surf (Input IN, inout SurfaceOutput o) { 25 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 26 | o.Albedo = tex.rgb * _Color.rgb; 27 | o.Gloss = tex.a; 28 | o.Alpha = tex.a * _Color.a; 29 | o.Specular = _Shininess; 30 | } 31 | ENDCG 32 | } 33 | 34 | Fallback "VertexLit" 35 | } 36 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Normal-Parallax.shader: -------------------------------------------------------------------------------- 1 | Shader "Parallax Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _Parallax ("Height", Range (0.005, 0.08)) = 0.02 5 | _MainTex ("Base (RGB)", 2D) = "white" {} 6 | _BumpMap ("Normalmap", 2D) = "bump" {} 7 | _ParallaxMap ("Heightmap (A)", 2D) = "black" {} 8 | } 9 | 10 | SubShader { 11 | Tags { "RenderType"="Opaque" } 12 | LOD 500 13 | 14 | CGPROGRAM 15 | #pragma surface surf Lambert 16 | 17 | sampler2D _MainTex; 18 | sampler2D _BumpMap; 19 | sampler2D _ParallaxMap; 20 | fixed4 _Color; 21 | float _Parallax; 22 | 23 | struct Input { 24 | float2 uv_MainTex; 25 | float2 uv_BumpMap; 26 | float3 viewDir; 27 | }; 28 | 29 | void surf (Input IN, inout SurfaceOutput o) { 30 | half h = tex2D (_ParallaxMap, IN.uv_BumpMap).w; 31 | float2 offset = ParallaxOffset (h, _Parallax, IN.viewDir); 32 | IN.uv_MainTex += offset; 33 | IN.uv_BumpMap += offset; 34 | 35 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 36 | o.Albedo = c.rgb; 37 | o.Alpha = c.a; 38 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 39 | } 40 | ENDCG 41 | } 42 | 43 | FallBack "Bumped Diffuse" 44 | } 45 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Normal-ParallaxSpec.shader: -------------------------------------------------------------------------------- 1 | Shader "Parallax Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) 5 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 6 | _Parallax ("Height", Range (0.005, 0.08)) = 0.02 7 | _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} 8 | _BumpMap ("Normalmap", 2D) = "bump" {} 9 | _ParallaxMap ("Heightmap (A)", 2D) = "black" {} 10 | } 11 | SubShader { 12 | Tags { "RenderType"="Opaque" } 13 | LOD 600 14 | 15 | CGPROGRAM 16 | #pragma surface surf BlinnPhong 17 | #pragma target 3.0 18 | 19 | sampler2D _MainTex; 20 | sampler2D _BumpMap; 21 | sampler2D _ParallaxMap; 22 | fixed4 _Color; 23 | half _Shininess; 24 | float _Parallax; 25 | 26 | struct Input { 27 | float2 uv_MainTex; 28 | float2 uv_BumpMap; 29 | float3 viewDir; 30 | }; 31 | 32 | void surf (Input IN, inout SurfaceOutput o) { 33 | half h = tex2D (_ParallaxMap, IN.uv_BumpMap).w; 34 | float2 offset = ParallaxOffset (h, _Parallax, IN.viewDir); 35 | IN.uv_MainTex += offset; 36 | IN.uv_BumpMap += offset; 37 | 38 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 39 | o.Albedo = tex.rgb * _Color.rgb; 40 | o.Gloss = tex.a; 41 | o.Alpha = tex.a * _Color.a; 42 | o.Specular = _Shininess; 43 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 44 | } 45 | ENDCG 46 | } 47 | 48 | FallBack "Bumped Specular" 49 | } 50 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Normal-VertexLit.shader: -------------------------------------------------------------------------------- 1 | Shader "VertexLit" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Spec Color", Color) = (1,1,1,1) 5 | _Emission ("Emissive Color", Color) = (0,0,0,0) 6 | _Shininess ("Shininess", Range (0.01, 1)) = 0.7 7 | _MainTex ("Base (RGB)", 2D) = "white" {} 8 | } 9 | 10 | // 2/3 texture stage GPUs 11 | SubShader { 12 | Tags { "RenderType"="Opaque" } 13 | LOD 100 14 | 15 | // Non-lightmapped 16 | Pass { 17 | Tags { "LightMode" = "Vertex" } 18 | 19 | Material { 20 | Diffuse [_Color] 21 | Ambient [_Color] 22 | Shininess [_Shininess] 23 | Specular [_SpecColor] 24 | Emission [_Emission] 25 | } 26 | Lighting On 27 | SeparateSpecular On 28 | SetTexture [_MainTex] { 29 | Combine texture * primary DOUBLE, texture * primary 30 | } 31 | } 32 | 33 | // Lightmapped, encoded as dLDR 34 | Pass { 35 | Tags { "LightMode" = "VertexLM" } 36 | 37 | BindChannels { 38 | Bind "Vertex", vertex 39 | Bind "normal", normal 40 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 41 | Bind "texcoord", texcoord1 // main uses 1st uv 42 | } 43 | 44 | SetTexture [unity_Lightmap] { 45 | matrix [unity_LightmapMatrix] 46 | constantColor [_Color] 47 | combine texture * constant 48 | } 49 | SetTexture [_MainTex] { 50 | combine texture * previous DOUBLE, texture * primary 51 | } 52 | } 53 | 54 | // Lightmapped, encoded as RGBM 55 | Pass { 56 | Tags { "LightMode" = "VertexLMRGBM" } 57 | 58 | BindChannels { 59 | Bind "Vertex", vertex 60 | Bind "normal", normal 61 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 62 | Bind "texcoord1", texcoord1 // unused 63 | Bind "texcoord", texcoord2 // main uses 1st uv 64 | } 65 | 66 | SetTexture [unity_Lightmap] { 67 | matrix [unity_LightmapMatrix] 68 | combine texture * texture alpha DOUBLE 69 | } 70 | SetTexture [unity_Lightmap] { 71 | constantColor [_Color] 72 | combine previous * constant 73 | } 74 | SetTexture [_MainTex] { 75 | combine texture * previous QUAD, texture * primary 76 | } 77 | } 78 | 79 | // Pass to render object as a shadow caster 80 | Pass { 81 | Name "ShadowCaster" 82 | Tags { "LightMode" = "ShadowCaster" } 83 | 84 | Fog {Mode Off} 85 | ZWrite On ZTest LEqual Cull Off 86 | Offset 1, 1 87 | 88 | CGPROGRAM 89 | #pragma vertex vert 90 | #pragma fragment frag 91 | #pragma multi_compile_shadowcaster 92 | #pragma fragmentoption ARB_precision_hint_fastest 93 | #include "UnityCG.cginc" 94 | 95 | struct v2f { 96 | V2F_SHADOW_CASTER; 97 | }; 98 | 99 | v2f vert( appdata_base v ) 100 | { 101 | v2f o; 102 | TRANSFER_SHADOW_CASTER(o) 103 | return o; 104 | } 105 | 106 | float4 frag( v2f i ) : COLOR 107 | { 108 | SHADOW_CASTER_FRAGMENT(i) 109 | } 110 | ENDCG 111 | 112 | } 113 | 114 | // Pass to render object as a shadow collector 115 | Pass { 116 | Name "ShadowCollector" 117 | Tags { "LightMode" = "ShadowCollector" } 118 | 119 | Fog {Mode Off} 120 | ZWrite On ZTest LEqual 121 | 122 | CGPROGRAM 123 | #pragma vertex vert 124 | #pragma fragment frag 125 | #pragma fragmentoption ARB_precision_hint_fastest 126 | #pragma multi_compile_shadowcollector 127 | 128 | #define SHADOW_COLLECTOR_PASS 129 | #include "UnityCG.cginc" 130 | 131 | struct appdata { 132 | float4 vertex : POSITION; 133 | }; 134 | 135 | struct v2f { 136 | V2F_SHADOW_COLLECTOR; 137 | }; 138 | 139 | v2f vert (appdata v) 140 | { 141 | v2f o; 142 | TRANSFER_SHADOW_COLLECTOR(o) 143 | return o; 144 | } 145 | 146 | fixed4 frag (v2f i) : COLOR 147 | { 148 | SHADOW_COLLECTOR_FRAGMENT(i) 149 | } 150 | ENDCG 151 | 152 | } 153 | } 154 | 155 | // 1 texture stage GPUs 156 | SubShader { 157 | Tags { "RenderType"="Opaque" } 158 | LOD 100 159 | 160 | // Non-lightmapped 161 | Pass { 162 | Tags { "LightMode" = "Vertex" } 163 | 164 | Material { 165 | Diffuse [_Color] 166 | Ambient [_Color] 167 | Shininess [_Shininess] 168 | Specular [_SpecColor] 169 | Emission [_Emission] 170 | } 171 | Lighting On 172 | SeparateSpecular On 173 | SetTexture [_MainTex] { 174 | Combine texture * primary DOUBLE, texture * primary 175 | } 176 | } 177 | // Lightmapped, encoded as dLDR 178 | Pass { 179 | // 1st pass - sample Lightmap 180 | Tags { "LightMode" = "VertexLM" } 181 | 182 | BindChannels { 183 | Bind "Vertex", vertex 184 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 185 | } 186 | SetTexture [unity_Lightmap] { 187 | matrix [unity_LightmapMatrix] 188 | constantColor [_Color] 189 | combine texture * constant 190 | } 191 | } 192 | Pass { 193 | // 2nd pass - multiply with _MainTex 194 | Tags { "LightMode" = "VertexLM" } 195 | ZWrite Off 196 | Fog {Mode Off} 197 | Blend DstColor Zero 198 | SetTexture [_MainTex] { 199 | combine texture 200 | } 201 | } 202 | } 203 | } 204 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Particle Add.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/Additive" { 2 | Properties { 3 | _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5) 4 | _MainTex ("Particle Texture", 2D) = "white" {} 5 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 6 | } 7 | 8 | Category { 9 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 10 | Blend SrcAlpha One 11 | AlphaTest Greater .01 12 | ColorMask RGB 13 | Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) } 14 | BindChannels { 15 | Bind "Color", color 16 | Bind "Vertex", vertex 17 | Bind "TexCoord", texcoord 18 | } 19 | 20 | // ---- Fragment program cards 21 | SubShader { 22 | Pass { 23 | 24 | CGPROGRAM 25 | #pragma vertex vert 26 | #pragma fragment frag 27 | #pragma fragmentoption ARB_precision_hint_fastest 28 | #pragma multi_compile_particles 29 | 30 | #include "UnityCG.cginc" 31 | 32 | sampler2D _MainTex; 33 | fixed4 _TintColor; 34 | 35 | struct appdata_t { 36 | float4 vertex : POSITION; 37 | fixed4 color : COLOR; 38 | float2 texcoord : TEXCOORD0; 39 | }; 40 | 41 | struct v2f { 42 | float4 vertex : POSITION; 43 | fixed4 color : COLOR; 44 | float2 texcoord : TEXCOORD0; 45 | #ifdef SOFTPARTICLES_ON 46 | float4 projPos : TEXCOORD1; 47 | #endif 48 | }; 49 | 50 | float4 _MainTex_ST; 51 | 52 | v2f vert (appdata_t v) 53 | { 54 | v2f o; 55 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 56 | #ifdef SOFTPARTICLES_ON 57 | o.projPos = ComputeScreenPos (o.vertex); 58 | COMPUTE_EYEDEPTH(o.projPos.z); 59 | #endif 60 | o.color = v.color; 61 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 62 | return o; 63 | } 64 | 65 | sampler2D _CameraDepthTexture; 66 | float _InvFade; 67 | 68 | fixed4 frag (v2f i) : COLOR 69 | { 70 | #ifdef SOFTPARTICLES_ON 71 | float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))); 72 | float partZ = i.projPos.z; 73 | float fade = saturate (_InvFade * (sceneZ-partZ)); 74 | i.color.a *= fade; 75 | #endif 76 | 77 | return 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord); 78 | } 79 | ENDCG 80 | } 81 | } 82 | 83 | // ---- Dual texture cards 84 | SubShader { 85 | Pass { 86 | SetTexture [_MainTex] { 87 | constantColor [_TintColor] 88 | combine constant * primary 89 | } 90 | SetTexture [_MainTex] { 91 | combine texture * previous DOUBLE 92 | } 93 | } 94 | } 95 | 96 | // ---- Single texture cards (does not do color tint) 97 | SubShader { 98 | Pass { 99 | SetTexture [_MainTex] { 100 | combine texture * primary 101 | } 102 | } 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Particle AddMultiply.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/~Additive-Multiply" { 2 | Properties { 3 | _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5) 4 | _MainTex ("Particle Texture", 2D) = "white" {} 5 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 6 | } 7 | 8 | Category { 9 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 10 | Blend One OneMinusSrcAlpha 11 | ColorMask RGB 12 | Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,1) } 13 | BindChannels { 14 | Bind "Color", color 15 | Bind "Vertex", vertex 16 | Bind "TexCoord", texcoord 17 | } 18 | 19 | // ---- Fragment program cards 20 | SubShader { 21 | Pass { 22 | 23 | CGPROGRAM 24 | #pragma vertex vert 25 | #pragma fragment frag 26 | #pragma fragmentoption ARB_precision_hint_fastest 27 | #pragma multi_compile_particles 28 | 29 | #include "UnityCG.cginc" 30 | 31 | sampler2D _MainTex; 32 | fixed4 _TintColor; 33 | 34 | struct appdata_t { 35 | float4 vertex : POSITION; 36 | fixed4 color : COLOR; 37 | float2 texcoord : TEXCOORD0; 38 | }; 39 | 40 | struct v2f { 41 | float4 vertex : POSITION; 42 | fixed4 color : COLOR; 43 | float2 texcoord : TEXCOORD0; 44 | #ifdef SOFTPARTICLES_ON 45 | float4 projPos : TEXCOORD1; 46 | #endif 47 | }; 48 | 49 | float4 _MainTex_ST; 50 | 51 | v2f vert (appdata_t v) 52 | { 53 | v2f o; 54 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 55 | #ifdef SOFTPARTICLES_ON 56 | o.projPos = ComputeScreenPos (o.vertex); 57 | COMPUTE_EYEDEPTH(o.projPos.z); 58 | #endif 59 | o.color = v.color; 60 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 61 | return o; 62 | } 63 | 64 | sampler2D _CameraDepthTexture; 65 | float _InvFade; 66 | 67 | fixed4 frag (v2f i) : COLOR 68 | { 69 | #ifdef SOFTPARTICLES_ON 70 | float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))); 71 | float partZ = i.projPos.z; 72 | float fade = saturate (_InvFade * (sceneZ-partZ)); 73 | i.color *= fade; 74 | #endif 75 | 76 | fixed4 tex = tex2D(_MainTex, i.texcoord); 77 | fixed4 col; 78 | col.rgb = _TintColor.rgb * tex.rgb * i.color.rgb * 2.0f; 79 | col.a = (1 - tex.a) * (_TintColor.a * i.color.a * 2.0f); 80 | return col; 81 | } 82 | ENDCG 83 | } 84 | } 85 | 86 | // ---- Dual texture cards 87 | SubShader { 88 | Pass { 89 | SetTexture [_MainTex] { 90 | constantColor [_TintColor] 91 | combine constant * texture, constant * primary DOUBLE 92 | } 93 | SetTexture [_MainTex] { 94 | combine previous * primary DOUBLE, one - texture * previous 95 | } 96 | } 97 | } 98 | 99 | // ---- Single texture cards (does not do color tint) 100 | SubShader { 101 | Pass { 102 | SetTexture [_MainTex] { 103 | combine texture * primary DOUBLE, one - texture * primary 104 | } 105 | } 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Particle AddSmooth.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/Additive (Soft)" { 2 | Properties { 3 | _MainTex ("Particle Texture", 2D) = "white" {} 4 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 5 | } 6 | 7 | Category { 8 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 9 | Blend One OneMinusSrcColor 10 | ColorMask RGB 11 | Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) } 12 | BindChannels { 13 | Bind "Color", color 14 | Bind "Vertex", vertex 15 | Bind "TexCoord", texcoord 16 | } 17 | 18 | // ---- Fragment program cards 19 | SubShader { 20 | Pass { 21 | 22 | CGPROGRAM 23 | #pragma vertex vert 24 | #pragma fragment frag 25 | #pragma fragmentoption ARB_precision_hint_fastest 26 | #pragma multi_compile_particles 27 | 28 | #include "UnityCG.cginc" 29 | 30 | sampler2D _MainTex; 31 | fixed4 _TintColor; 32 | 33 | struct appdata_t { 34 | float4 vertex : POSITION; 35 | fixed4 color : COLOR; 36 | float2 texcoord : TEXCOORD0; 37 | }; 38 | 39 | struct v2f { 40 | float4 vertex : POSITION; 41 | fixed4 color : COLOR; 42 | float2 texcoord : TEXCOORD0; 43 | #ifdef SOFTPARTICLES_ON 44 | float4 projPos : TEXCOORD1; 45 | #endif 46 | }; 47 | 48 | float4 _MainTex_ST; 49 | 50 | v2f vert (appdata_t v) 51 | { 52 | v2f o; 53 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 54 | #ifdef SOFTPARTICLES_ON 55 | o.projPos = ComputeScreenPos (o.vertex); 56 | COMPUTE_EYEDEPTH(o.projPos.z); 57 | #endif 58 | o.color = v.color; 59 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 60 | return o; 61 | } 62 | 63 | sampler2D _CameraDepthTexture; 64 | float _InvFade; 65 | 66 | fixed4 frag (v2f i) : COLOR 67 | { 68 | #ifdef SOFTPARTICLES_ON 69 | float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))); 70 | float partZ = i.projPos.z; 71 | float fade = saturate (_InvFade * (sceneZ-partZ)); 72 | i.color.a *= fade; 73 | #endif 74 | 75 | half4 prev = i.color * tex2D(_MainTex, i.texcoord); 76 | prev.rgb *= prev.a; 77 | return prev; 78 | } 79 | ENDCG 80 | } 81 | } 82 | 83 | // ---- Dual texture cards 84 | SubShader { 85 | Pass { 86 | SetTexture [_MainTex] { 87 | combine texture * primary 88 | } 89 | SetTexture [_MainTex] { 90 | combine previous * previous alpha, previous 91 | } 92 | } 93 | } 94 | 95 | // ---- Single texture cards (does not do particle colors) 96 | SubShader { 97 | Pass { 98 | SetTexture [_MainTex] { 99 | combine texture * texture alpha, texture 100 | } 101 | } 102 | } 103 | } 104 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Particle Alpha Blend.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/Alpha Blended" { 2 | Properties { 3 | _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5) 4 | _MainTex ("Particle Texture", 2D) = "white" {} 5 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 6 | } 7 | 8 | Category { 9 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 10 | Blend SrcAlpha OneMinusSrcAlpha 11 | AlphaTest Greater .01 12 | ColorMask RGB 13 | Cull Off Lighting Off ZWrite Off 14 | BindChannels { 15 | Bind "Color", color 16 | Bind "Vertex", vertex 17 | Bind "TexCoord", texcoord 18 | } 19 | 20 | // ---- Fragment program cards 21 | SubShader { 22 | Pass { 23 | 24 | CGPROGRAM 25 | #pragma vertex vert 26 | #pragma fragment frag 27 | #pragma fragmentoption ARB_precision_hint_fastest 28 | #pragma multi_compile_particles 29 | 30 | #include "UnityCG.cginc" 31 | 32 | sampler2D _MainTex; 33 | fixed4 _TintColor; 34 | 35 | struct appdata_t { 36 | float4 vertex : POSITION; 37 | fixed4 color : COLOR; 38 | float2 texcoord : TEXCOORD0; 39 | }; 40 | 41 | struct v2f { 42 | float4 vertex : POSITION; 43 | fixed4 color : COLOR; 44 | float2 texcoord : TEXCOORD0; 45 | #ifdef SOFTPARTICLES_ON 46 | float4 projPos : TEXCOORD1; 47 | #endif 48 | }; 49 | 50 | float4 _MainTex_ST; 51 | 52 | v2f vert (appdata_t v) 53 | { 54 | v2f o; 55 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 56 | #ifdef SOFTPARTICLES_ON 57 | o.projPos = ComputeScreenPos (o.vertex); 58 | COMPUTE_EYEDEPTH(o.projPos.z); 59 | #endif 60 | o.color = v.color; 61 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 62 | return o; 63 | } 64 | 65 | sampler2D _CameraDepthTexture; 66 | float _InvFade; 67 | 68 | fixed4 frag (v2f i) : COLOR 69 | { 70 | #ifdef SOFTPARTICLES_ON 71 | float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))); 72 | float partZ = i.projPos.z; 73 | float fade = saturate (_InvFade * (sceneZ-partZ)); 74 | i.color.a *= fade; 75 | #endif 76 | 77 | return 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord); 78 | } 79 | ENDCG 80 | } 81 | } 82 | 83 | // ---- Dual texture cards 84 | SubShader { 85 | Pass { 86 | SetTexture [_MainTex] { 87 | constantColor [_TintColor] 88 | combine constant * primary 89 | } 90 | SetTexture [_MainTex] { 91 | combine texture * previous DOUBLE 92 | } 93 | } 94 | } 95 | 96 | // ---- Single texture cards (does not do color tint) 97 | SubShader { 98 | Pass { 99 | SetTexture [_MainTex] { 100 | combine texture * primary 101 | } 102 | } 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Particle Blend.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/Blend" { 2 | Properties { 3 | _MainTex ("Particle Texture", 2D) = "white" {} 4 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 5 | } 6 | 7 | Category { 8 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 9 | Blend DstColor One 10 | ColorMask RGB 11 | Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) } 12 | BindChannels { 13 | Bind "Color", color 14 | Bind "Vertex", vertex 15 | Bind "TexCoord", texcoord 16 | } 17 | 18 | SubShader { 19 | Pass { 20 | 21 | CGPROGRAM 22 | #pragma vertex vert 23 | #pragma fragment frag 24 | #pragma fragmentoption ARB_precision_hint_fastest 25 | #pragma multi_compile_particles 26 | 27 | #include "UnityCG.cginc" 28 | 29 | sampler2D _MainTex; 30 | fixed4 _TintColor; 31 | 32 | struct appdata_t { 33 | float4 vertex : POSITION; 34 | fixed4 color : COLOR; 35 | float2 texcoord : TEXCOORD0; 36 | }; 37 | 38 | struct v2f { 39 | float4 vertex : POSITION; 40 | fixed4 color : COLOR; 41 | float2 texcoord : TEXCOORD0; 42 | #ifdef SOFTPARTICLES_ON 43 | float4 projPos : TEXCOORD1; 44 | #endif 45 | }; 46 | 47 | float4 _MainTex_ST; 48 | 49 | v2f vert (appdata_t v) 50 | { 51 | v2f o; 52 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 53 | #ifdef SOFTPARTICLES_ON 54 | o.projPos = ComputeScreenPos (o.vertex); 55 | COMPUTE_EYEDEPTH(o.projPos.z); 56 | #endif 57 | o.color = v.color; 58 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 59 | return o; 60 | } 61 | 62 | sampler2D _CameraDepthTexture; 63 | float _InvFade; 64 | 65 | fixed4 frag (v2f i) : COLOR 66 | { 67 | #ifdef SOFTPARTICLES_ON 68 | float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))); 69 | float partZ = i.projPos.z; 70 | float fade = saturate (_InvFade * (sceneZ-partZ)); 71 | i.color *= fade; 72 | #endif 73 | 74 | return i.color * tex2D(_MainTex, i.texcoord); 75 | } 76 | ENDCG 77 | } 78 | } 79 | 80 | SubShader { 81 | Pass { 82 | SetTexture [_MainTex] { combine texture * primary } 83 | } 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Particle Multiply.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/Multiply" { 2 | Properties { 3 | _MainTex ("Particle Texture", 2D) = "white" {} 4 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 5 | } 6 | 7 | Category { 8 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 9 | Blend Zero SrcColor 10 | Cull Off Lighting Off ZWrite Off Fog { Color (1,1,1,1) } 11 | BindChannels { 12 | Bind "Color", color 13 | Bind "Vertex", vertex 14 | Bind "TexCoord", texcoord 15 | } 16 | 17 | // ---- Fragment program cards 18 | SubShader { 19 | Pass { 20 | 21 | CGPROGRAM 22 | #pragma vertex vert 23 | #pragma fragment frag 24 | #pragma fragmentoption ARB_precision_hint_fastest 25 | #pragma multi_compile_particles 26 | 27 | #include "UnityCG.cginc" 28 | 29 | sampler2D _MainTex; 30 | fixed4 _TintColor; 31 | 32 | struct appdata_t { 33 | float4 vertex : POSITION; 34 | fixed4 color : COLOR; 35 | float2 texcoord : TEXCOORD0; 36 | }; 37 | 38 | struct v2f { 39 | float4 vertex : POSITION; 40 | fixed4 color : COLOR; 41 | float2 texcoord : TEXCOORD0; 42 | #ifdef SOFTPARTICLES_ON 43 | float4 projPos : TEXCOORD1; 44 | #endif 45 | }; 46 | 47 | float4 _MainTex_ST; 48 | 49 | v2f vert (appdata_t v) 50 | { 51 | v2f o; 52 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 53 | #ifdef SOFTPARTICLES_ON 54 | o.projPos = ComputeScreenPos (o.vertex); 55 | COMPUTE_EYEDEPTH(o.projPos.z); 56 | #endif 57 | o.color = v.color; 58 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 59 | return o; 60 | } 61 | 62 | sampler2D _CameraDepthTexture; 63 | float _InvFade; 64 | 65 | fixed4 frag (v2f i) : COLOR 66 | { 67 | #ifdef SOFTPARTICLES_ON 68 | float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))); 69 | float partZ = i.projPos.z; 70 | float fade = saturate (_InvFade * (sceneZ-partZ)); 71 | i.color.a *= fade; 72 | #endif 73 | 74 | half4 prev = i.color * tex2D(_MainTex, i.texcoord); 75 | return lerp(half4(1,1,1,1), prev, prev.a); 76 | } 77 | ENDCG 78 | } 79 | } 80 | 81 | // ---- Dual texture cards 82 | SubShader { 83 | Pass { 84 | SetTexture [_MainTex] { 85 | combine texture * primary 86 | } 87 | SetTexture [_MainTex] { 88 | constantColor (1,1,1,1) 89 | combine previous lerp (previous) constant 90 | } 91 | } 92 | } 93 | 94 | // ---- Single texture cards (does not do particle colors) 95 | SubShader { 96 | Pass { 97 | SetTexture [_MainTex] { 98 | constantColor (1,1,1,1) 99 | combine texture lerp(texture) constant 100 | } 101 | } 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Particle MultiplyDouble.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/Multiply (Double)" { 2 | Properties { 3 | _MainTex ("Particle Texture", 2D) = "white" {} 4 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 5 | } 6 | 7 | Category { 8 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 9 | Blend DstColor SrcColor 10 | ColorMask RGB 11 | Cull Off Lighting Off ZWrite Off Fog { Color (0.5,0.5,0.5,0.5) } 12 | BindChannels { 13 | Bind "Color", color 14 | Bind "Vertex", vertex 15 | Bind "TexCoord", texcoord 16 | } 17 | 18 | // ---- Fragment program cards 19 | SubShader { 20 | Pass { 21 | 22 | CGPROGRAM 23 | #pragma vertex vert 24 | #pragma fragment frag 25 | #pragma fragmentoption ARB_precision_hint_fastest 26 | #pragma multi_compile_particles 27 | 28 | #include "UnityCG.cginc" 29 | 30 | sampler2D _MainTex; 31 | fixed4 _TintColor; 32 | 33 | struct appdata_t { 34 | float4 vertex : POSITION; 35 | fixed4 color : COLOR; 36 | float2 texcoord : TEXCOORD0; 37 | }; 38 | 39 | struct v2f { 40 | float4 vertex : POSITION; 41 | fixed4 color : COLOR; 42 | float2 texcoord : TEXCOORD0; 43 | #ifdef SOFTPARTICLES_ON 44 | float4 projPos : TEXCOORD1; 45 | #endif 46 | }; 47 | 48 | float4 _MainTex_ST; 49 | 50 | v2f vert (appdata_t v) 51 | { 52 | v2f o; 53 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 54 | #ifdef SOFTPARTICLES_ON 55 | o.projPos = ComputeScreenPos (o.vertex); 56 | COMPUTE_EYEDEPTH(o.projPos.z); 57 | #endif 58 | o.color = v.color; 59 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 60 | return o; 61 | } 62 | 63 | sampler2D _CameraDepthTexture; 64 | float _InvFade; 65 | 66 | fixed4 frag (v2f i) : COLOR 67 | { 68 | #ifdef SOFTPARTICLES_ON 69 | float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))); 70 | float partZ = i.projPos.z; 71 | float fade = saturate (_InvFade * (sceneZ-partZ)); 72 | i.color.a *= fade; 73 | #endif 74 | 75 | fixed4 col; 76 | fixed4 tex = tex2D(_MainTex, i.texcoord); 77 | col.rgb = tex.rgb * i.color.rgb * 2; 78 | col.a = i.color.a * tex.a; 79 | return lerp(fixed4(0.5f,0.5f,0.5f,0.5f), col, col.a); 80 | } 81 | ENDCG 82 | } 83 | } 84 | 85 | // ---- Dual texture cards 86 | SubShader { 87 | Pass { 88 | SetTexture [_MainTex] { 89 | combine texture * primary DOUBLE, primary * texture 90 | } 91 | SetTexture [_MainTex] { 92 | constantColor (.5,.5,.5,.5) 93 | combine previous lerp (previous) constant 94 | } 95 | } 96 | } 97 | 98 | // ---- Single texture cards (does not do particle colors) 99 | SubShader { 100 | Pass { 101 | SetTexture [_MainTex] { 102 | constantColor (.5,.5,.5,.5) 103 | combine texture lerp(texture) constant 104 | } 105 | } 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Particle Premultiply Blend.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/Alpha Blended Premultiply" { 2 | Properties { 3 | _MainTex ("Particle Texture", 2D) = "white" {} 4 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 5 | } 6 | 7 | Category { 8 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 9 | Blend One OneMinusSrcAlpha 10 | ColorMask RGB 11 | Cull Off Lighting Off ZWrite Off Fog { Mode Off } 12 | BindChannels { 13 | Bind "Color", color 14 | Bind "Vertex", vertex 15 | Bind "TexCoord", texcoord 16 | } 17 | 18 | // ---- Fragment program cards 19 | SubShader { 20 | Pass { 21 | 22 | CGPROGRAM 23 | #pragma vertex vert 24 | #pragma fragment frag 25 | #pragma fragmentoption ARB_precision_hint_fastest 26 | #pragma multi_compile_particles 27 | 28 | #include "UnityCG.cginc" 29 | 30 | sampler2D _MainTex; 31 | fixed4 _TintColor; 32 | 33 | struct appdata_t { 34 | float4 vertex : POSITION; 35 | fixed4 color : COLOR; 36 | float2 texcoord : TEXCOORD0; 37 | }; 38 | 39 | struct v2f { 40 | float4 vertex : POSITION; 41 | fixed4 color : COLOR; 42 | float2 texcoord : TEXCOORD0; 43 | #ifdef SOFTPARTICLES_ON 44 | float4 projPos : TEXCOORD1; 45 | #endif 46 | }; 47 | 48 | float4 _MainTex_ST; 49 | 50 | v2f vert (appdata_t v) 51 | { 52 | v2f o; 53 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 54 | #ifdef SOFTPARTICLES_ON 55 | o.projPos = ComputeScreenPos (o.vertex); 56 | COMPUTE_EYEDEPTH(o.projPos.z); 57 | #endif 58 | o.color = v.color; 59 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 60 | return o; 61 | } 62 | 63 | sampler2D _CameraDepthTexture; 64 | float _InvFade; 65 | 66 | fixed4 frag (v2f i) : COLOR 67 | { 68 | #ifdef SOFTPARTICLES_ON 69 | float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))); 70 | float partZ = i.projPos.z; 71 | float fade = saturate (_InvFade * (sceneZ-partZ)); 72 | i.color.a *= fade; 73 | #endif 74 | 75 | return i.color * tex2D(_MainTex, i.texcoord) * i.color.a; 76 | } 77 | ENDCG 78 | } 79 | } 80 | 81 | // ---- Dual texture cards 82 | SubShader { 83 | Pass { 84 | SetTexture [_MainTex] { 85 | combine primary * primary alpha 86 | } 87 | SetTexture [_MainTex] { 88 | combine previous * texture 89 | } 90 | } 91 | } 92 | 93 | // ---- Single texture cards (not entirely correct) 94 | SubShader { 95 | Pass { 96 | SetTexture [_MainTex] { 97 | combine texture * primary 98 | } 99 | } 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Particle VertexLit Blended.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/VertexLit Blended" { 2 | Properties { 3 | _EmisColor ("Emissive Color", Color) = (.2,.2,.2,0) 4 | _MainTex ("Particle Texture", 2D) = "white" {} 5 | } 6 | 7 | SubShader { 8 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 9 | Tags { "LightMode" = "Vertex" } 10 | Cull Off 11 | Lighting On 12 | Material { Emission [_EmisColor] } 13 | ColorMaterial AmbientAndDiffuse 14 | ZWrite Off 15 | ColorMask RGB 16 | Blend SrcAlpha OneMinusSrcAlpha 17 | AlphaTest Greater .001 18 | Pass { 19 | SetTexture [_MainTex] { combine primary * texture } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Reflect-BumpNolight.shader: -------------------------------------------------------------------------------- 1 | Shader "Reflective/Bumped Unlit" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5) 5 | _MainTex ("Base (RGB), RefStrength (A)", 2D) = "white" {} 6 | _Cube ("Reflection Cubemap", Cube) = "" { TexGen CubeReflect } 7 | _BumpMap ("Normalmap", 2D) = "bump" {} 8 | } 9 | 10 | Category { 11 | Tags { "RenderType"="Opaque" } 12 | LOD 250 13 | 14 | // ------------------------------------------------------------------ 15 | // Shaders 16 | 17 | SubShader { 18 | // Always drawn reflective pass 19 | Pass { 20 | Name "BASE" 21 | Tags {"LightMode" = "Always"} 22 | CGPROGRAM 23 | #pragma vertex vert 24 | #pragma fragment frag 25 | #pragma fragmentoption ARB_precision_hint_fastest 26 | 27 | #include "UnityCG.cginc" 28 | 29 | struct v2f { 30 | float4 pos : SV_POSITION; 31 | float2 uv : TEXCOORD0; 32 | float2 uv2 : TEXCOORD1; 33 | float3 I : TEXCOORD2; 34 | float3 TtoW0 : TEXCOORD3; 35 | float3 TtoW1 : TEXCOORD4; 36 | float3 TtoW2 : TEXCOORD5; 37 | }; 38 | 39 | uniform float4 _MainTex_ST, _BumpMap_ST; 40 | 41 | v2f vert(appdata_tan v) 42 | { 43 | v2f o; 44 | o.pos = mul (UNITY_MATRIX_MVP, v.vertex); 45 | o.uv = TRANSFORM_TEX(v.texcoord,_MainTex); 46 | o.uv2 = TRANSFORM_TEX(v.texcoord,_BumpMap); 47 | 48 | o.I = -WorldSpaceViewDir( v.vertex ); 49 | 50 | TANGENT_SPACE_ROTATION; 51 | o.TtoW0 = mul(rotation, _Object2World[0].xyz * unity_Scale.w); 52 | o.TtoW1 = mul(rotation, _Object2World[1].xyz * unity_Scale.w); 53 | o.TtoW2 = mul(rotation, _Object2World[2].xyz * unity_Scale.w); 54 | 55 | return o; 56 | } 57 | 58 | uniform sampler2D _BumpMap; 59 | uniform sampler2D _MainTex; 60 | uniform samplerCUBE _Cube; 61 | uniform fixed4 _ReflectColor; 62 | uniform fixed4 _Color; 63 | 64 | fixed4 frag (v2f i) : COLOR 65 | { 66 | // Sample and expand the normal map texture 67 | fixed3 normal = UnpackNormal(tex2D(_BumpMap, i.uv2)); 68 | 69 | fixed4 texcol = tex2D(_MainTex,i.uv); 70 | 71 | // transform normal to world space 72 | half3 wn; 73 | wn.x = dot(i.TtoW0, normal); 74 | wn.y = dot(i.TtoW1, normal); 75 | wn.z = dot(i.TtoW2, normal); 76 | 77 | // calculate reflection vector in world space 78 | half3 r = reflect(i.I, wn); 79 | 80 | fixed4 c = UNITY_LIGHTMODEL_AMBIENT * texcol; 81 | c.rgb *= 2; 82 | fixed4 reflcolor = texCUBE(_Cube, r) * _ReflectColor * texcol.a; 83 | return c + reflcolor; 84 | } 85 | ENDCG 86 | } 87 | } 88 | 89 | // ------------------------------------------------------------------ 90 | // No vertex or fragment programs 91 | 92 | SubShader { 93 | Pass { 94 | Tags {"LightMode" = "Always"} 95 | Name "BASE" 96 | BindChannels { 97 | Bind "Vertex", vertex 98 | Bind "Normal", normal 99 | } 100 | SetTexture [_Cube] { 101 | constantColor [_ReflectColor] 102 | combine texture * constant 103 | } 104 | } 105 | } 106 | } 107 | 108 | FallBack "VertexLit", 1 109 | 110 | } 111 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Reflect-BumpSpec.shader: -------------------------------------------------------------------------------- 1 | Shader "Reflective/Bumped Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Specular Color", Color) = (0.5,0.5,0.5,1) 5 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 6 | _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5) 7 | _MainTex ("Base (RGB) RefStrGloss (A)", 2D) = "white" {} 8 | _Cube ("Reflection Cubemap", Cube) = "" { TexGen CubeReflect } 9 | _BumpMap ("Normalmap", 2D) = "bump" {} 10 | } 11 | 12 | SubShader { 13 | Tags { "RenderType"="Opaque" } 14 | LOD 400 15 | CGPROGRAM 16 | #pragma surface surf BlinnPhong 17 | #pragma target 3.0 18 | 19 | sampler2D _MainTex; 20 | sampler2D _BumpMap; 21 | samplerCUBE _Cube; 22 | 23 | fixed4 _Color; 24 | fixed4 _ReflectColor; 25 | half _Shininess; 26 | 27 | struct Input { 28 | float2 uv_MainTex; 29 | float2 uv_BumpMap; 30 | float3 worldRefl; 31 | INTERNAL_DATA 32 | }; 33 | 34 | void surf (Input IN, inout SurfaceOutput o) { 35 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 36 | fixed4 c = tex * _Color; 37 | o.Albedo = c.rgb; 38 | 39 | o.Gloss = tex.a; 40 | o.Specular = _Shininess; 41 | 42 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 43 | 44 | float3 worldRefl = WorldReflectionVector (IN, o.Normal); 45 | fixed4 reflcol = texCUBE (_Cube, worldRefl); 46 | reflcol *= tex.a; 47 | o.Emission = reflcol.rgb * _ReflectColor.rgb; 48 | o.Alpha = reflcol.a * _ReflectColor.a; 49 | } 50 | ENDCG 51 | } 52 | 53 | FallBack "Reflective/Bumped Diffuse" 54 | } 55 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Reflect-BumpVertexLit.shader: -------------------------------------------------------------------------------- 1 | Shader "Reflective/Bumped VertexLit" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Spec Color", Color) = (1,1,1,1) 5 | _Shininess ("Shininess", Range (0.1, 1)) = 0.7 6 | _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5) 7 | _MainTex ("Base (RGB) RefStrength (A)", 2D) = "white" {} 8 | _Cube ("Reflection Cubemap", Cube) = "" { TexGen CubeReflect } 9 | _BumpMap ("Normalmap", 2D) = "bump" {} 10 | } 11 | 12 | Category { 13 | Tags { "RenderType"="Opaque" } 14 | LOD 250 15 | SubShader { 16 | UsePass "Reflective/Bumped Unlit/BASE" 17 | Pass { 18 | Tags { "LightMode" = "Vertex" } 19 | Blend One One ZWrite Off Fog { Color (0,0,0,0) } 20 | Material { 21 | Diffuse [_Color] 22 | Ambient [_Color] 23 | Shininess [_Shininess] 24 | Specular [_SpecColor] 25 | Emission [_Emission] 26 | } 27 | Lighting On 28 | SeparateSpecular On 29 | SetTexture [_MainTex] { 30 | constantColor [_Color] 31 | Combine texture * primary DOUBLE, texture * primary 32 | } 33 | } 34 | } 35 | } 36 | 37 | FallBack "Reflective/VertexLit" 38 | } 39 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Reflect-Bumped.shader: -------------------------------------------------------------------------------- 1 | Shader "Reflective/Bumped Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5) 5 | _MainTex ("Base (RGB) RefStrength (A)", 2D) = "white" {} 6 | _Cube ("Reflection Cubemap", Cube) = "_Skybox" { TexGen CubeReflect } 7 | _BumpMap ("Normalmap", 2D) = "bump" {} 8 | } 9 | 10 | SubShader { 11 | Tags { "RenderType"="Opaque" } 12 | LOD 300 13 | 14 | CGPROGRAM 15 | #pragma surface surf Lambert 16 | 17 | sampler2D _MainTex; 18 | sampler2D _BumpMap; 19 | samplerCUBE _Cube; 20 | 21 | fixed4 _Color; 22 | fixed4 _ReflectColor; 23 | 24 | struct Input { 25 | float2 uv_MainTex; 26 | float2 uv_BumpMap; 27 | float3 worldRefl; 28 | INTERNAL_DATA 29 | }; 30 | 31 | void surf (Input IN, inout SurfaceOutput o) { 32 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 33 | fixed4 c = tex * _Color; 34 | o.Albedo = c.rgb; 35 | 36 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 37 | 38 | float3 worldRefl = WorldReflectionVector (IN, o.Normal); 39 | fixed4 reflcol = texCUBE (_Cube, worldRefl); 40 | reflcol *= tex.a; 41 | o.Emission = reflcol.rgb * _ReflectColor.rgb; 42 | o.Alpha = reflcol.a * _ReflectColor.a; 43 | } 44 | ENDCG 45 | } 46 | 47 | FallBack "Reflective/VertexLit" 48 | } 49 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Reflect-Diffuse.shader: -------------------------------------------------------------------------------- 1 | Shader "Reflective/Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5) 5 | _MainTex ("Base (RGB) RefStrength (A)", 2D) = "white" {} 6 | _Cube ("Reflection Cubemap", Cube) = "_Skybox" { TexGen CubeReflect } 7 | } 8 | SubShader { 9 | LOD 200 10 | Tags { "RenderType"="Opaque" } 11 | 12 | CGPROGRAM 13 | #pragma surface surf Lambert 14 | 15 | sampler2D _MainTex; 16 | samplerCUBE _Cube; 17 | 18 | fixed4 _Color; 19 | fixed4 _ReflectColor; 20 | 21 | struct Input { 22 | float2 uv_MainTex; 23 | float3 worldRefl; 24 | }; 25 | 26 | void surf (Input IN, inout SurfaceOutput o) { 27 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 28 | fixed4 c = tex * _Color; 29 | o.Albedo = c.rgb; 30 | 31 | fixed4 reflcol = texCUBE (_Cube, IN.worldRefl); 32 | reflcol *= tex.a; 33 | o.Emission = reflcol.rgb * _ReflectColor.rgb; 34 | o.Alpha = reflcol.a * _ReflectColor.a; 35 | } 36 | ENDCG 37 | } 38 | 39 | FallBack "Reflective/VertexLit" 40 | } 41 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Reflect-Glossy.shader: -------------------------------------------------------------------------------- 1 | Shader "Reflective/Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) 5 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 6 | _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5) 7 | _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} 8 | _Cube ("Reflection Cubemap", Cube) = "_Skybox" { TexGen CubeReflect } 9 | } 10 | SubShader { 11 | LOD 300 12 | Tags { "RenderType"="Opaque" } 13 | 14 | CGPROGRAM 15 | #pragma surface surf BlinnPhong 16 | 17 | sampler2D _MainTex; 18 | samplerCUBE _Cube; 19 | 20 | fixed4 _Color; 21 | fixed4 _ReflectColor; 22 | half _Shininess; 23 | 24 | struct Input { 25 | float2 uv_MainTex; 26 | float3 worldRefl; 27 | }; 28 | 29 | void surf (Input IN, inout SurfaceOutput o) { 30 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 31 | fixed4 c = tex * _Color; 32 | o.Albedo = c.rgb; 33 | o.Gloss = tex.a; 34 | o.Specular = _Shininess; 35 | 36 | fixed4 reflcol = texCUBE (_Cube, IN.worldRefl); 37 | reflcol *= tex.a; 38 | o.Emission = reflcol.rgb * _ReflectColor.rgb; 39 | o.Alpha = reflcol.a * _ReflectColor.a; 40 | } 41 | ENDCG 42 | } 43 | 44 | FallBack "Reflective/VertexLit" 45 | } 46 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Reflect-Parallax.shader: -------------------------------------------------------------------------------- 1 | Shader "Reflective/Parallax Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5) 5 | _Parallax ("Height", Range (0.005, 0.08)) = 0.02 6 | _MainTex ("Base (RGB) RefStrength (A)", 2D) = "white" {} 7 | _Cube ("Reflection Cubemap", Cube) = "_Skybox" { TexGen CubeReflect } 8 | _BumpMap ("Normalmap", 2D) = "bump" {} 9 | _ParallaxMap ("Heightmap (A)", 2D) = "black" {} 10 | } 11 | SubShader { 12 | Tags { "RenderType"="Opaque" } 13 | LOD 500 14 | 15 | CGPROGRAM 16 | #pragma surface surf Lambert 17 | #pragma target 3.0 18 | 19 | sampler2D _MainTex; 20 | sampler2D _BumpMap; 21 | samplerCUBE _Cube; 22 | sampler2D _ParallaxMap; 23 | 24 | fixed4 _Color; 25 | fixed4 _ReflectColor; 26 | float _Parallax; 27 | 28 | struct Input { 29 | float2 uv_MainTex; 30 | float2 uv_BumpMap; 31 | float3 worldRefl; 32 | float3 viewDir; 33 | INTERNAL_DATA 34 | }; 35 | 36 | void surf (Input IN, inout SurfaceOutput o) { 37 | half h = tex2D (_ParallaxMap, IN.uv_BumpMap).w; 38 | float2 offset = ParallaxOffset (h, _Parallax, IN.viewDir); 39 | IN.uv_MainTex += offset; 40 | IN.uv_BumpMap += offset; 41 | 42 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 43 | fixed4 c = tex * _Color; 44 | o.Albedo = c.rgb; 45 | 46 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 47 | 48 | float3 worldRefl = WorldReflectionVector (IN, o.Normal); 49 | fixed4 reflcol = texCUBE (_Cube, worldRefl); 50 | reflcol *= tex.a; 51 | o.Emission = reflcol.rgb * _ReflectColor.rgb; 52 | o.Alpha = reflcol.a * _ReflectColor.a; 53 | } 54 | ENDCG 55 | } 56 | 57 | FallBack "Reflective/Bumped Diffuse" 58 | } 59 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Reflect-ParallaxSpec.shader: -------------------------------------------------------------------------------- 1 | Shader "Reflective/Parallax Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Specular Color", Color) = (0.5,0.5,0.5,1) 5 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 6 | _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5) 7 | _Parallax ("Height", Range (0.005, 0.08)) = 0.02 8 | _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" { } 9 | _Cube ("Reflection Cubemap", Cube) = "_Skybox" { TexGen CubeReflect } 10 | _BumpMap ("Normalmap", 2D) = "bump" { } 11 | _ParallaxMap ("Heightmap (A)", 2D) = "black" {} 12 | } 13 | SubShader { 14 | Tags { "RenderType"="Opaque" } 15 | LOD 600 16 | 17 | CGPROGRAM 18 | #pragma surface surf BlinnPhong 19 | #pragma target 3.0 20 | 21 | sampler2D _MainTex; 22 | sampler2D _BumpMap; 23 | samplerCUBE _Cube; 24 | sampler2D _ParallaxMap; 25 | 26 | fixed4 _Color; 27 | fixed4 _ReflectColor; 28 | half _Shininess; 29 | float _Parallax; 30 | 31 | struct Input { 32 | float2 uv_MainTex; 33 | float2 uv_BumpMap; 34 | float3 worldRefl; 35 | float3 viewDir; 36 | INTERNAL_DATA 37 | }; 38 | 39 | void surf (Input IN, inout SurfaceOutput o) { 40 | half h = tex2D (_ParallaxMap, IN.uv_BumpMap).w; 41 | float2 offset = ParallaxOffset (h, _Parallax, IN.viewDir); 42 | IN.uv_MainTex += offset; 43 | IN.uv_BumpMap += offset; 44 | 45 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 46 | o.Albedo = tex.rgb * _Color.rgb; 47 | o.Gloss = tex.a; 48 | o.Specular = _Shininess; 49 | 50 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 51 | 52 | float3 worldRefl = WorldReflectionVector (IN, o.Normal); 53 | fixed4 reflcol = texCUBE (_Cube, worldRefl); 54 | reflcol *= tex.a; 55 | o.Emission = reflcol.rgb * _ReflectColor.rgb; 56 | o.Alpha = reflcol.a * _ReflectColor.a; 57 | } 58 | ENDCG 59 | } 60 | 61 | FallBack "Reflective/Bumped Specular" 62 | } 63 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Reflect-VertexLit.shader: -------------------------------------------------------------------------------- 1 | Shader "Reflective/VertexLit" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Spec Color", Color) = (1,1,1,1) 5 | _Shininess ("Shininess", Range (0.03, 1)) = 0.7 6 | _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5) 7 | _MainTex ("Base (RGB) RefStrength (A)", 2D) = "white" {} 8 | _Cube ("Reflection Cubemap", Cube) = "_Skybox" { TexGen CubeReflect } 9 | } 10 | 11 | Category { 12 | Tags { "RenderType"="Opaque" } 13 | LOD 150 14 | 15 | // ------------------------------------------------------------------ 16 | // Pixel shader cards 17 | 18 | SubShader { 19 | 20 | // First pass does reflection cubemap 21 | Pass { 22 | Name "BASE" 23 | Tags {"LightMode" = "Always"} 24 | CGPROGRAM 25 | #pragma exclude_renderers gles xbox360 ps3 26 | #pragma vertex vert 27 | #pragma fragment frag 28 | #pragma fragmentoption ARB_precision_hint_fastest 29 | #include "UnityCG.cginc" 30 | 31 | struct v2f { 32 | float4 pos : SV_POSITION; 33 | float2 uv : TEXCOORD0; 34 | float3 I : TEXCOORD1; 35 | }; 36 | 37 | uniform float4 _MainTex_ST; 38 | 39 | v2f vert(appdata_tan v) 40 | { 41 | v2f o; 42 | o.pos = mul (UNITY_MATRIX_MVP, v.vertex); 43 | o.uv = TRANSFORM_TEX(v.texcoord,_MainTex); 44 | 45 | // calculate world space reflection vector 46 | float3 viewDir = WorldSpaceViewDir( v.vertex ); 47 | float3 worldN = mul((float3x3)_Object2World, v.normal * unity_Scale.w); 48 | o.I = reflect( -viewDir, worldN ); 49 | 50 | return o; 51 | } 52 | 53 | uniform sampler2D _MainTex; 54 | uniform samplerCUBE _Cube; 55 | uniform fixed4 _ReflectColor; 56 | 57 | fixed4 frag (v2f i) : COLOR 58 | { 59 | fixed4 texcol = tex2D (_MainTex, i.uv); 60 | fixed4 reflcol = texCUBE( _Cube, i.I ); 61 | reflcol *= texcol.a; 62 | return reflcol * _ReflectColor; 63 | } 64 | ENDCG 65 | } 66 | 67 | // Vertex Lit 68 | Pass { 69 | Tags { "LightMode" = "Vertex" } 70 | Blend One One ZWrite Off Fog { Color (0,0,0,0) } 71 | Lighting On 72 | Material { 73 | Diffuse [_Color] 74 | Emission [_PPLAmbient] 75 | Specular [_SpecColor] 76 | Shininess [_Shininess] 77 | } 78 | SeparateSpecular On 79 | CGPROGRAM 80 | #pragma exclude_renderers shaderonly 81 | #pragma fragment frag 82 | #pragma fragmentoption ARB_precision_hint_fastest 83 | 84 | #include "UnityCG.cginc" 85 | 86 | struct v2f { 87 | float2 uv : TEXCOORD0; 88 | fixed4 diff : COLOR0; 89 | fixed4 spec : COLOR1; 90 | }; 91 | 92 | uniform sampler2D _MainTex : register(s0); 93 | uniform fixed4 _ReflectColor; 94 | uniform fixed4 _SpecColor; 95 | 96 | fixed4 frag (v2f i) : COLOR 97 | { 98 | fixed4 temp = tex2D (_MainTex, i.uv); 99 | fixed4 c; 100 | c.xyz = (temp.xyz * i.diff.xyz + temp.w * i.spec.xyz ) * 2; 101 | c.w = temp.w * (i.diff.w + Luminance(i.spec.xyz) * _SpecColor.a); 102 | return c; 103 | } 104 | ENDCG 105 | SetTexture[_MainTex] {} 106 | } 107 | 108 | // Lightmapped 109 | Pass { 110 | Tags { "LightMode" = "VertexLM" } 111 | Blend One One ZWrite Off Fog { Color (0,0,0,0) } 112 | ColorMask RGB 113 | 114 | BindChannels { 115 | Bind "Vertex", vertex 116 | Bind "normal", normal 117 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 118 | Bind "texcoord", texcoord1 // main uses 1st uv 119 | } 120 | 121 | SetTexture [unity_Lightmap] { 122 | matrix [unity_LightmapMatrix] 123 | constantColor [_Color] 124 | combine texture * constant 125 | } 126 | SetTexture [_MainTex] { 127 | combine texture * previous DOUBLE, texture * primary 128 | } 129 | } 130 | 131 | // Lightmapped, encoded as RGBM 132 | Pass { 133 | Tags { "LightMode" = "VertexLMRGBM" } 134 | Blend One One ZWrite Off Fog { Color (0,0,0,0) } 135 | ColorMask RGB 136 | 137 | BindChannels { 138 | Bind "Vertex", vertex 139 | Bind "normal", normal 140 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 141 | Bind "texcoord1", texcoord1 // unused 142 | Bind "texcoord", texcoord2 // main uses 1st uv 143 | } 144 | 145 | SetTexture [unity_Lightmap] { 146 | matrix [unity_LightmapMatrix] 147 | combine texture * texture alpha DOUBLE 148 | } 149 | SetTexture [unity_Lightmap] { 150 | constantColor [_Color] 151 | combine previous * constant 152 | } 153 | SetTexture [_MainTex] { 154 | combine texture * previous QUAD, texture * primary 155 | } 156 | } 157 | } 158 | 159 | // ------------------------------------------------------------------ 160 | // Old cards 161 | 162 | SubShader { 163 | Pass { 164 | Name "BASE" 165 | Tags { "LightMode" = "Vertex" } 166 | Material { 167 | Diffuse [_Color] 168 | Ambient (1,1,1,1) 169 | Shininess [_Shininess] 170 | Specular [_SpecColor] 171 | } 172 | Lighting On 173 | SeparateSpecular on 174 | SetTexture [_MainTex] { 175 | combine texture * primary DOUBLE, texture * primary 176 | } 177 | SetTexture [_Cube] { 178 | combine texture * previous alpha + previous, previous 179 | } 180 | } 181 | } 182 | } 183 | 184 | // Fallback for cards that don't do cubemapping 185 | FallBack "VertexLit" 186 | } 187 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Shadow-ScreenBlur.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Shadow-ScreenBlur" { 2 | Properties { 3 | _MainTex ("Base", 2D) = "white" {} 4 | } 5 | SubShader { 6 | Pass { 7 | ZTest Always Cull Off ZWrite Off 8 | Fog { Mode off } 9 | 10 | CGPROGRAM 11 | #pragma vertex vert 12 | #pragma fragment frag 13 | #pragma exclude_renderers noshadows 14 | #pragma fragmentoption ARB_precision_hint_fastest 15 | #include "UnityCG.cginc" 16 | 17 | v2f_img vert (appdata_img v) 18 | { 19 | v2f_img o; 20 | o.pos = mul (UNITY_MATRIX_MVP, v.vertex); 21 | o.uv = v.texcoord.xy; 22 | #if SHADER_API_FLASH 23 | o.uv.xy *= unity_NPOTScale.xy; 24 | #endif 25 | return o; 26 | } 27 | 28 | 29 | uniform sampler2D _MainTex; 30 | 31 | // x,y of each - sample offset for blur 32 | uniform float4 _BlurOffsets0; 33 | uniform float4 _BlurOffsets1; 34 | uniform float4 _BlurOffsets2; 35 | uniform float4 _BlurOffsets3; 36 | uniform float4 _BlurOffsets4; 37 | uniform float4 _BlurOffsets5; 38 | uniform float4 _BlurOffsets6; 39 | uniform float4 _BlurOffsets7; 40 | 41 | float4 unity_ShadowBlurParams; 42 | 43 | 44 | 45 | #define LOOP_ITERATION(i) { \ 46 | float4 sample = tex2D( _MainTex, (coord + radius * _BlurOffsets##i).xy ); \ 47 | float sampleDist = sample.b + sample.a / 255.0; \ 48 | float diff = dist - sampleDist; \ 49 | diff = saturate( diffTolerance - abs(diff) ); \ 50 | mask.xy += diff * sample.xy; } 51 | 52 | fixed4 frag (v2f_img i) : COLOR 53 | { 54 | float4 coord = float4(i.uv,0,0); 55 | float4 mask = tex2D( _MainTex, coord.xy ); 56 | float dist = mask.b + mask.a / 255.0; 57 | float radius = saturate(unity_ShadowBlurParams.y / (1.0-dist)); 58 | 59 | float diffTolerance = unity_ShadowBlurParams.x; 60 | 61 | mask.xy *= diffTolerance; 62 | 63 | // Would this code look better in a loop? You bet. 64 | // But, that requires using a uniform array in GLSL, 65 | // which means that shaderlab would need support for array parameters. 66 | // So, until we have that, this needs to be unrolled to work in GLSL, 67 | // then we can revert to the looped version. 68 | 69 | LOOP_ITERATION (0); 70 | LOOP_ITERATION (1); 71 | LOOP_ITERATION (2); 72 | LOOP_ITERATION (3); 73 | 74 | // In Flash, due to very limited register count we can't do more samples :( 75 | #ifndef SHADER_API_FLASH 76 | LOOP_ITERATION (4); 77 | LOOP_ITERATION (5); 78 | LOOP_ITERATION (6); 79 | LOOP_ITERATION (7); 80 | #endif 81 | 82 | float shadow = mask.x / mask.y; 83 | return shadow; 84 | } 85 | ENDCG 86 | } 87 | } 88 | 89 | Fallback Off 90 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Shadow-ScreenBlurRotated.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Shadow-ScreenBlurRotated" { 2 | Properties { 3 | _MainTex ("Base", 2D) = "white" {} 4 | } 5 | SubShader { 6 | Pass { 7 | ZTest Always Cull Off ZWrite Off 8 | Fog { Mode off } 9 | 10 | CGPROGRAM 11 | #pragma vertex vert_img 12 | #pragma fragment frag 13 | #pragma exclude_renderers noshadows 14 | #pragma fragmentoption ARB_precision_hint_fastest 15 | #pragma target 3.0 16 | #include "UnityCG.cginc" 17 | 18 | 19 | #if SHADER_API_PS3 20 | # define shadowPrecission float 21 | # define shadowPrecission4 float4 22 | #else 23 | # define shadowPrecission half 24 | # define shadowPrecission4 half4 25 | #endif 26 | 27 | 28 | uniform sampler2D _MainTex; 29 | uniform sampler2D unity_RandomRotation16; 30 | 31 | // x,y of each - sample offset for blur 32 | uniform float4 _BlurOffsets0; 33 | uniform float4 _BlurOffsets1; 34 | uniform float4 _BlurOffsets2; 35 | uniform float4 _BlurOffsets3; 36 | uniform float4 _BlurOffsets4; 37 | uniform float4 _BlurOffsets5; 38 | uniform float4 _BlurOffsets6; 39 | uniform float4 _BlurOffsets7; 40 | 41 | // @TODO: Should be possible to calc offset and scale in the dot products here. Should be faster on platforms with free swizzles (like.. not PS3) 42 | inline float2 GetRotatedTexCoord(float2 offsets, float4 rotation) 43 | { 44 | float2 offset; 45 | offset.x = dot( offsets.xy, rotation.rg ); 46 | offset.y = dot( offsets.xy, rotation.ba ); 47 | return offset; 48 | } 49 | 50 | float4 unity_ShadowBlurParams; 51 | #define LOOP_ITERATION(i) { \ 52 | shadowPrecission4 sample = tex2D( _MainTex, coord + radius * GetRotatedTexCoord(_BlurOffsets##i.xy, rotation) ); \ 53 | shadowPrecission sampleDist = sample.b + sample.a / 255.0; \ 54 | shadowPrecission diff = dist - sampleDist; \ 55 | diff = saturate( diffTolerance - abs(diff) ); \ 56 | mask.xy += diff * sample.xy; } 57 | 58 | fixed4 frag (v2f_img i) : COLOR 59 | { 60 | float4 coord = float4(i.uv,0,0); 61 | const float randomRotationTextureSize = 16.0f; 62 | 63 | shadowPrecission4 rotation = 2.0 * tex2D( unity_RandomRotation16, (coord.xy * _ScreenParams.xy) / randomRotationTextureSize ) - 1.0; 64 | shadowPrecission4 mask = tex2D( _MainTex, coord.xy ); 65 | shadowPrecission dist = mask.b + mask.a / 255.0; 66 | shadowPrecission radius = saturate(unity_ShadowBlurParams.y / (1.0-dist)); 67 | 68 | shadowPrecission diffTolerance = unity_ShadowBlurParams.x; 69 | 70 | mask.xy *= diffTolerance; 71 | 72 | // Would this code look better in a loop? You bet. 73 | // But, that requires using a uniform array in GLSL, 74 | // which means that shaderlab would need support for array parameters. 75 | // So, until we have that, this needs to be unrolled to work in GLSL, 76 | // then we can revert to the looped version. 77 | 78 | LOOP_ITERATION (0); 79 | LOOP_ITERATION (1); 80 | LOOP_ITERATION (2); 81 | LOOP_ITERATION (3); 82 | LOOP_ITERATION (4); 83 | LOOP_ITERATION (5); 84 | LOOP_ITERATION (6); 85 | LOOP_ITERATION (7); 86 | 87 | shadowPrecission shadow = mask.x / mask.y; 88 | return shadow; 89 | } 90 | ENDCG 91 | } 92 | } 93 | 94 | Fallback Off 95 | } 96 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/Skybox.shader: -------------------------------------------------------------------------------- 1 | Shader "RenderFX/Skybox" { 2 | Properties { 3 | _Tint ("Tint Color", Color) = (.5, .5, .5, .5) 4 | _FrontTex ("Front (+Z)", 2D) = "white" {} 5 | _BackTex ("Back (-Z)", 2D) = "white" {} 6 | _LeftTex ("Left (+X)", 2D) = "white" {} 7 | _RightTex ("Right (-X)", 2D) = "white" {} 8 | _UpTex ("Up (+Y)", 2D) = "white" {} 9 | _DownTex ("down (-Y)", 2D) = "white" {} 10 | } 11 | 12 | SubShader { 13 | Tags { "Queue"="Background" "RenderType"="Background" } 14 | Cull Off ZWrite Off Fog { Mode Off } 15 | 16 | CGINCLUDE 17 | #include "UnityCG.cginc" 18 | 19 | fixed4 _Tint; 20 | 21 | struct appdata_t { 22 | float4 vertex : POSITION; 23 | float2 texcoord : TEXCOORD0; 24 | }; 25 | struct v2f { 26 | float4 vertex : POSITION; 27 | float2 texcoord : TEXCOORD0; 28 | }; 29 | v2f vert (appdata_t v) 30 | { 31 | v2f o; 32 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 33 | o.texcoord = v.texcoord; 34 | return o; 35 | } 36 | fixed4 skybox_frag (v2f i, sampler2D smp) 37 | { 38 | fixed4 tex = tex2D (smp, i.texcoord); 39 | fixed4 col; 40 | col.rgb = tex.rgb + _Tint.rgb - unity_ColorSpaceGrey; 41 | col.a = tex.a * _Tint.a; 42 | return col; 43 | } 44 | ENDCG 45 | 46 | Pass { 47 | CGPROGRAM 48 | #pragma vertex vert 49 | #pragma fragment frag 50 | #pragma fragmentoption ARB_precision_hint_fastest 51 | sampler2D _FrontTex; 52 | fixed4 frag (v2f i) : COLOR { return skybox_frag(i,_FrontTex); } 53 | ENDCG 54 | } 55 | Pass{ 56 | CGPROGRAM 57 | #pragma vertex vert 58 | #pragma fragment frag 59 | #pragma fragmentoption ARB_precision_hint_fastest 60 | sampler2D _BackTex; 61 | fixed4 frag (v2f i) : COLOR { return skybox_frag(i,_BackTex); } 62 | ENDCG 63 | } 64 | Pass{ 65 | CGPROGRAM 66 | #pragma vertex vert 67 | #pragma fragment frag 68 | #pragma fragmentoption ARB_precision_hint_fastest 69 | sampler2D _LeftTex; 70 | fixed4 frag (v2f i) : COLOR { return skybox_frag(i,_LeftTex); } 71 | ENDCG 72 | } 73 | Pass{ 74 | CGPROGRAM 75 | #pragma vertex vert 76 | #pragma fragment frag 77 | #pragma fragmentoption ARB_precision_hint_fastest 78 | sampler2D _RightTex; 79 | fixed4 frag (v2f i) : COLOR { return skybox_frag(i,_RightTex); } 80 | ENDCG 81 | } 82 | Pass{ 83 | CGPROGRAM 84 | #pragma vertex vert 85 | #pragma fragment frag 86 | #pragma fragmentoption ARB_precision_hint_fastest 87 | sampler2D _UpTex; 88 | fixed4 frag (v2f i) : COLOR { return skybox_frag(i,_UpTex); } 89 | ENDCG 90 | } 91 | Pass{ 92 | CGPROGRAM 93 | #pragma vertex vert 94 | #pragma fragment frag 95 | #pragma fragmentoption ARB_precision_hint_fastest 96 | sampler2D _DownTex; 97 | fixed4 frag (v2f i) : COLOR { return skybox_frag(i,_DownTex); } 98 | ENDCG 99 | } 100 | } 101 | 102 | SubShader { 103 | Tags { "Queue"="Background" "RenderType"="Background" } 104 | Cull Off ZWrite Off Fog { Mode Off } 105 | Color [_Tint] 106 | Pass { 107 | SetTexture [_FrontTex] { combine texture +- primary, texture * primary } 108 | } 109 | Pass { 110 | SetTexture [_BackTex] { combine texture +- primary, texture * primary } 111 | } 112 | Pass { 113 | SetTexture [_LeftTex] { combine texture +- primary, texture * primary } 114 | } 115 | Pass { 116 | SetTexture [_RightTex] { combine texture +- primary, texture * primary } 117 | } 118 | Pass { 119 | SetTexture [_UpTex] { combine texture +- primary, texture * primary } 120 | } 121 | Pass { 122 | SetTexture [_DownTex] { combine texture +- primary, texture * primary } 123 | } 124 | } 125 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/TerrainShaders/Details/VertexLit.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/TerrainEngine/Details/Vertexlit" { 2 | Properties { 3 | _MainTex ("Main Texture", 2D) = "white" { } 4 | } 5 | SubShader { 6 | Tags { "RenderType"="Opaque" } 7 | LOD 200 8 | 9 | CGPROGRAM 10 | #pragma surface surf Lambert 11 | 12 | sampler2D _MainTex; 13 | 14 | struct Input { 15 | float2 uv_MainTex; 16 | fixed4 color : COLOR; 17 | }; 18 | 19 | void surf (Input IN, inout SurfaceOutput o) { 20 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * IN.color; 21 | o.Albedo = c.rgb; 22 | o.Alpha = c.a; 23 | } 24 | 25 | ENDCG 26 | } 27 | SubShader { 28 | Tags { "RenderType"="Opaque" } 29 | Pass { 30 | Tags { "LightMode" = "Vertex" } 31 | ColorMaterial AmbientAndDiffuse 32 | Lighting On 33 | SetTexture [_MainTex] { 34 | combine texture * primary DOUBLE, texture * primary 35 | } 36 | } 37 | Pass { 38 | Tags { "LightMode" = "VertexLMRGBM" } 39 | ColorMaterial AmbientAndDiffuse 40 | BindChannels { 41 | Bind "Vertex", vertex 42 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 43 | Bind "texcoord", texcoord1 // main uses 1st uv 44 | } 45 | SetTexture [unity_Lightmap] { 46 | matrix [unity_LightmapMatrix] 47 | combine texture * texture alpha DOUBLE 48 | } 49 | SetTexture [_MainTex] { combine texture * previous QUAD, texture } 50 | } 51 | } 52 | 53 | Fallback "VertexLit" 54 | } 55 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/TerrainShaders/Details/WavingGrass.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/TerrainEngine/Details/WavingDoublePass" { 2 | Properties { 3 | _WavingTint ("Fade Color", Color) = (.7,.6,.5, 0) 4 | _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {} 5 | _WaveAndDistance ("Wave and distance", Vector) = (12, 3.6, 1, 1) 6 | _Cutoff ("Cutoff", float) = 0.5 7 | } 8 | 9 | SubShader { 10 | Tags { 11 | "Queue" = "Geometry+200" 12 | "IgnoreProjector"="True" 13 | "RenderType"="Grass" 14 | } 15 | Cull Off 16 | LOD 200 17 | ColorMask RGB 18 | 19 | CGPROGRAM 20 | #pragma surface surf Lambert vertex:WavingGrassVert addshadow 21 | #pragma exclude_renderers flash 22 | #include "TerrainEngine.cginc" 23 | 24 | sampler2D _MainTex; 25 | fixed _Cutoff; 26 | 27 | struct Input { 28 | float2 uv_MainTex; 29 | fixed4 color : COLOR; 30 | }; 31 | 32 | void surf (Input IN, inout SurfaceOutput o) { 33 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * IN.color; 34 | o.Albedo = c.rgb; 35 | o.Alpha = c.a; 36 | clip (o.Alpha - _Cutoff); 37 | o.Alpha *= IN.color.a; 38 | } 39 | ENDCG 40 | } 41 | 42 | SubShader { 43 | Tags { 44 | "Queue" = "Geometry+200" 45 | "IgnoreProjector"="True" 46 | "RenderType"="Grass" 47 | } 48 | Cull Off 49 | LOD 200 50 | ColorMask RGB 51 | 52 | Pass { 53 | Tags { "LightMode" = "Vertex" } 54 | Material { 55 | Diffuse (1,1,1,1) 56 | Ambient (1,1,1,1) 57 | } 58 | Lighting On 59 | ColorMaterial AmbientAndDiffuse 60 | AlphaTest Greater [_Cutoff] 61 | SetTexture [_MainTex] { combine texture * primary DOUBLE, texture } 62 | } 63 | Pass { 64 | Tags { "LightMode" = "VertexLMRGBM" } 65 | AlphaTest Greater [_Cutoff] 66 | BindChannels { 67 | Bind "Vertex", vertex 68 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 69 | Bind "texcoord", texcoord1 // main uses 1st uv 70 | } 71 | SetTexture [unity_Lightmap] { 72 | matrix [unity_LightmapMatrix] 73 | combine texture * texture alpha DOUBLE 74 | } 75 | SetTexture [_MainTex] { combine texture * previous QUAD, texture } 76 | } 77 | } 78 | 79 | Fallback Off 80 | } 81 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/TerrainShaders/Details/WavingGrassBillboard.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/TerrainEngine/Details/BillboardWavingDoublePass" { 2 | Properties { 3 | _WavingTint ("Fade Color", Color) = (.7,.6,.5, 0) 4 | _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {} 5 | _WaveAndDistance ("Wave and distance", Vector) = (12, 3.6, 1, 1) 6 | _Cutoff ("Cutoff", float) = 0.5 7 | } 8 | 9 | CGINCLUDE 10 | #include "UnityCG.cginc" 11 | #include "TerrainEngine.cginc" 12 | #pragma glsl_no_auto_normalization 13 | 14 | struct v2f { 15 | float4 pos : POSITION; 16 | fixed4 color : COLOR; 17 | float4 uv : TEXCOORD0; 18 | }; 19 | v2f BillboardVert (appdata_full v) { 20 | v2f o; 21 | WavingGrassBillboardVert (v); 22 | o.color = v.color; 23 | 24 | o.color.rgb *= ShadeVertexLights (v.vertex, v.normal); 25 | 26 | o.pos = mul (UNITY_MATRIX_MVP, v.vertex); 27 | o.uv = v.texcoord; 28 | return o; 29 | } 30 | ENDCG 31 | 32 | SubShader { 33 | Tags { 34 | "Queue" = "Geometry+200" 35 | "IgnoreProjector"="True" 36 | "RenderType"="GrassBillboard" 37 | } 38 | Cull Off 39 | LOD 200 40 | ColorMask RGB 41 | 42 | CGPROGRAM 43 | #pragma surface surf Lambert vertex:WavingGrassBillboardVert addshadow 44 | #pragma exclude_renderers flash 45 | 46 | sampler2D _MainTex; 47 | fixed _Cutoff; 48 | 49 | struct Input { 50 | float2 uv_MainTex; 51 | fixed4 color : COLOR; 52 | }; 53 | 54 | void surf (Input IN, inout SurfaceOutput o) { 55 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * IN.color; 56 | o.Albedo = c.rgb; 57 | o.Alpha = c.a; 58 | clip (o.Alpha - _Cutoff); 59 | o.Alpha *= IN.color.a; 60 | } 61 | 62 | ENDCG 63 | } 64 | 65 | SubShader { 66 | Tags { 67 | "Queue" = "Geometry+200" 68 | "IgnoreProjector"="True" 69 | "RenderType"="GrassBillboard" 70 | } 71 | 72 | ColorMask RGB 73 | Cull Off 74 | Lighting On 75 | 76 | Pass { 77 | CGPROGRAM 78 | #pragma vertex BillboardVert 79 | #pragma exclude_renderers shaderonly 80 | ENDCG 81 | 82 | AlphaTest Greater [_Cutoff] 83 | 84 | SetTexture [_MainTex] { combine texture * primary DOUBLE, texture * primary } 85 | } 86 | } 87 | 88 | Fallback Off 89 | } 90 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/TerrainShaders/Splats/AddPass.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/TerrainEngine/Splatmap/Lightmap-AddPass" { 2 | Properties { 3 | _Control ("Control (RGBA)", 2D) = "black" {} 4 | _Splat3 ("Layer 3 (A)", 2D) = "white" {} 5 | _Splat2 ("Layer 2 (B)", 2D) = "white" {} 6 | _Splat1 ("Layer 1 (G)", 2D) = "white" {} 7 | _Splat0 ("Layer 0 (R)", 2D) = "white" {} 8 | } 9 | 10 | SubShader { 11 | Tags { 12 | "SplatCount" = "4" 13 | "Queue" = "Geometry-99" 14 | "IgnoreProjector"="True" 15 | "RenderType" = "Opaque" 16 | } 17 | 18 | CGPROGRAM 19 | #pragma surface surf Lambert decal:add 20 | struct Input { 21 | float2 uv_Control : TEXCOORD0; 22 | float2 uv_Splat0 : TEXCOORD1; 23 | float2 uv_Splat1 : TEXCOORD2; 24 | float2 uv_Splat2 : TEXCOORD3; 25 | float2 uv_Splat3 : TEXCOORD4; 26 | }; 27 | 28 | sampler2D _Control; 29 | sampler2D _Splat0,_Splat1,_Splat2,_Splat3; 30 | 31 | void surf (Input IN, inout SurfaceOutput o) { 32 | fixed4 splat_control = tex2D (_Control, IN.uv_Control); 33 | fixed3 col; 34 | col = splat_control.r * tex2D (_Splat0, IN.uv_Splat0).rgb; 35 | col += splat_control.g * tex2D (_Splat1, IN.uv_Splat1).rgb; 36 | col += splat_control.b * tex2D (_Splat2, IN.uv_Splat2).rgb; 37 | col += splat_control.a * tex2D (_Splat3, IN.uv_Splat3).rgb; 38 | o.Albedo = col; 39 | o.Alpha = 0.0; 40 | } 41 | ENDCG 42 | } 43 | 44 | Fallback off 45 | } 46 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/TerrainShaders/Splats/FirstPass.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/TerrainEngine/Splatmap/Lightmap-FirstPass" { 2 | Properties { 3 | _Control ("Control (RGBA)", 2D) = "red" {} 4 | _Splat3 ("Layer 3 (A)", 2D) = "white" {} 5 | _Splat2 ("Layer 2 (B)", 2D) = "white" {} 6 | _Splat1 ("Layer 1 (G)", 2D) = "white" {} 7 | _Splat0 ("Layer 0 (R)", 2D) = "white" {} 8 | // used in fallback on old cards 9 | _MainTex ("BaseMap (RGB)", 2D) = "white" {} 10 | _Color ("Main Color", Color) = (1,1,1,1) 11 | } 12 | 13 | SubShader { 14 | Tags { 15 | "SplatCount" = "4" 16 | "Queue" = "Geometry-100" 17 | "RenderType" = "Opaque" 18 | } 19 | CGPROGRAM 20 | #pragma surface surf Lambert 21 | struct Input { 22 | float2 uv_Control : TEXCOORD0; 23 | float2 uv_Splat0 : TEXCOORD1; 24 | float2 uv_Splat1 : TEXCOORD2; 25 | float2 uv_Splat2 : TEXCOORD3; 26 | float2 uv_Splat3 : TEXCOORD4; 27 | }; 28 | 29 | sampler2D _Control; 30 | sampler2D _Splat0,_Splat1,_Splat2,_Splat3; 31 | 32 | void surf (Input IN, inout SurfaceOutput o) { 33 | fixed4 splat_control = tex2D (_Control, IN.uv_Control); 34 | fixed3 col; 35 | col = splat_control.r * tex2D (_Splat0, IN.uv_Splat0).rgb; 36 | col += splat_control.g * tex2D (_Splat1, IN.uv_Splat1).rgb; 37 | col += splat_control.b * tex2D (_Splat2, IN.uv_Splat2).rgb; 38 | col += splat_control.a * tex2D (_Splat3, IN.uv_Splat3).rgb; 39 | o.Albedo = col; 40 | o.Alpha = 0.0; 41 | } 42 | ENDCG 43 | } 44 | 45 | // Fallback to Diffuse 46 | Fallback "Diffuse" 47 | } 48 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/TerrainShaders/Trees/BillboardTree.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/TerrainEngine/BillboardTree" { 2 | Properties { 3 | _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {} 4 | } 5 | 6 | SubShader { 7 | Tags { "Queue" = "Transparent-100" "IgnoreProjector"="True" "RenderType"="TreeBillboard" } 8 | 9 | Pass { 10 | ColorMask rgb 11 | Blend SrcAlpha OneMinusSrcAlpha 12 | ZWrite Off Cull Off 13 | 14 | CGPROGRAM 15 | #pragma vertex vert 16 | #include "UnityCG.cginc" 17 | #include "TerrainEngine.cginc" 18 | #pragma fragment frag 19 | 20 | struct v2f { 21 | float4 pos : POSITION; 22 | fixed4 color : COLOR0; 23 | float2 uv : TEXCOORD0; 24 | }; 25 | 26 | v2f vert (appdata_tree_billboard v) { 27 | v2f o; 28 | TerrainBillboardTree(v.vertex, v.texcoord1.xy, v.texcoord.y); 29 | o.pos = mul (UNITY_MATRIX_MVP, v.vertex); 30 | o.uv.x = v.texcoord.x; 31 | o.uv.y = v.texcoord.y > 0; 32 | o.color = v.color; 33 | return o; 34 | } 35 | 36 | sampler2D _MainTex; 37 | fixed4 frag(v2f input) : COLOR 38 | { 39 | fixed4 col = tex2D( _MainTex, input.uv); 40 | col.rgb *= input.color.rgb; 41 | clip(col.a); 42 | return col; 43 | } 44 | ENDCG 45 | } 46 | } 47 | 48 | SubShader { 49 | Tags { "Queue" = "Transparent-100" "IgnoreProjector"="True" "RenderType"="TreeBillboard" } 50 | 51 | Pass { 52 | 53 | CGPROGRAM 54 | #pragma vertex vert 55 | #pragma exclude_renderers shaderonly 56 | #include "UnityCG.cginc" 57 | #include "TerrainEngine.cginc" 58 | 59 | struct v2f { 60 | float4 pos : POSITION; 61 | fixed4 color : COLOR0; 62 | float2 uv : TEXCOORD0; 63 | }; 64 | 65 | v2f vert (appdata_tree_billboard v) { 66 | v2f o; 67 | TerrainBillboardTree(v.vertex, v.texcoord1.xy, v.texcoord.y); 68 | o.pos = mul (UNITY_MATRIX_MVP, v.vertex); 69 | o.uv.x = v.texcoord.x; 70 | o.uv.y = v.texcoord.y > 0; 71 | o.color = v.color; 72 | return o; 73 | } 74 | ENDCG 75 | 76 | ColorMask rgb 77 | Blend SrcAlpha OneMinusSrcAlpha 78 | ZWrite Off Cull Off 79 | 80 | AlphaTest Greater 0 81 | SetTexture [_MainTex] { combine texture * primary, texture } 82 | } 83 | } 84 | 85 | Fallback Off 86 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResources/skybox cubed.shader: -------------------------------------------------------------------------------- 1 | Shader "RenderFX/Skybox Cubed" { 2 | Properties { 3 | _Tint ("Tint Color", Color) = (.5, .5, .5, .5) 4 | _Tex ("Cubemap", Cube) = "white" {} 5 | } 6 | 7 | SubShader { 8 | Tags { "Queue"="Background" "RenderType"="Background" } 9 | Cull Off ZWrite Off Fog { Mode Off } 10 | 11 | Pass { 12 | 13 | CGPROGRAM 14 | #pragma vertex vert 15 | #pragma fragment frag 16 | #pragma fragmentoption ARB_precision_hint_fastest 17 | 18 | #include "UnityCG.cginc" 19 | 20 | samplerCUBE _Tex; 21 | fixed4 _Tint; 22 | 23 | struct appdata_t { 24 | float4 vertex : POSITION; 25 | float3 texcoord : TEXCOORD0; 26 | }; 27 | 28 | struct v2f { 29 | float4 vertex : POSITION; 30 | float3 texcoord : TEXCOORD0; 31 | }; 32 | 33 | v2f vert (appdata_t v) 34 | { 35 | v2f o; 36 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 37 | o.texcoord = v.texcoord; 38 | return o; 39 | } 40 | 41 | fixed4 frag (v2f i) : COLOR 42 | { 43 | fixed4 tex = texCUBE (_Tex, i.texcoord); 44 | fixed4 col; 45 | col.rgb = tex.rgb + _Tint.rgb - unity_ColorSpaceGrey; 46 | col.a = tex.a * _Tint.a; 47 | return col; 48 | } 49 | ENDCG 50 | } 51 | } 52 | 53 | 54 | SubShader { 55 | Tags { "Queue"="Background" "RenderType"="Background" } 56 | Cull Off ZWrite Off Fog { Mode Off } 57 | Color [_Tint] 58 | Pass { 59 | SetTexture [_Tex] { combine texture +- primary, texture * primary } 60 | } 61 | } 62 | 63 | Fallback Off 64 | 65 | } 66 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Lightmap-BumpSpec.shader: -------------------------------------------------------------------------------- 1 | Shader "Legacy Shaders/Lightmapped/Bumped Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) 5 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 6 | _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} 7 | _BumpMap ("Normalmap", 2D) = "bump" {} 8 | _LightMap ("Lightmap (RGB)", 2D) = "lightmap" { LightmapMode } 9 | } 10 | FallBack "Legacy Shaders/Lightmapped/Bumped Diffuse" 11 | } 12 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Lightmap-Bumped.shader: -------------------------------------------------------------------------------- 1 | Shader "Legacy Shaders/Lightmapped/Bumped Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _MainTex ("Base (RGB)", 2D) = "white" {} 5 | _BumpMap ("Normalmap", 2D) = "bump" {} 6 | _LightMap ("Lightmap (RGB)", 2D) = "black" {} 7 | } 8 | 9 | SubShader { 10 | LOD 300 11 | Tags { "RenderType" = "Opaque" } 12 | CGPROGRAM 13 | #pragma surface surf Lambert 14 | struct Input { 15 | float2 uv_MainTex; 16 | float2 uv_BumpMap; 17 | float2 uv2_LightMap; 18 | }; 19 | sampler2D _MainTex; 20 | sampler2D _BumpMap; 21 | sampler2D _LightMap; 22 | fixed4 _Color; 23 | void surf (Input IN, inout SurfaceOutput o) 24 | { 25 | o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb * _Color; 26 | half4 lm = tex2D (_LightMap, IN.uv2_LightMap); 27 | o.Emission = lm.rgb*o.Albedo.rgb; 28 | o.Alpha = lm.a * _Color.a; 29 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 30 | } 31 | ENDCG 32 | } 33 | FallBack "Legacy Shaders/Lightmapped/Diffuse" 34 | } 35 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Lightmap-Diffuse.shader: -------------------------------------------------------------------------------- 1 | Shader "Legacy Shaders/Lightmapped/Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _MainTex ("Base (RGB)", 2D) = "white" {} 5 | _LightMap ("Lightmap (RGB)", 2D) = "black" {} 6 | } 7 | 8 | SubShader { 9 | LOD 200 10 | Tags { "RenderType" = "Opaque" } 11 | CGPROGRAM 12 | #pragma surface surf Lambert 13 | struct Input { 14 | float2 uv_MainTex; 15 | float2 uv2_LightMap; 16 | }; 17 | sampler2D _MainTex; 18 | sampler2D _LightMap; 19 | fixed4 _Color; 20 | void surf (Input IN, inout SurfaceOutput o) 21 | { 22 | o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb * _Color; 23 | half4 lm = tex2D (_LightMap, IN.uv2_LightMap); 24 | o.Emission = lm.rgb*o.Albedo.rgb; 25 | o.Alpha = lm.a * _Color.a; 26 | } 27 | ENDCG 28 | } 29 | FallBack "Legacy Shaders/Lightmapped/VertexLit" 30 | } 31 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Lightmap-Glossy.shader: -------------------------------------------------------------------------------- 1 | Shader "Legacy Shaders/Lightmapped/Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) 5 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 6 | _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} 7 | _LightMap ("Lightmap (RGB)", 2D) = "lightmap" { LightmapMode } 8 | } 9 | FallBack "Legacy Shaders/Lightmapped/Diffuse" 10 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Lightmap-VertexLit.shader: -------------------------------------------------------------------------------- 1 | Shader "Legacy Shaders/Lightmapped/VertexLit" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _SpecColor ("Spec Color", Color) = (1,1,1,1) 5 | _Shininess ("Shininess", Range (0.01, 1)) = 0.7 6 | _MainTex ("Base (RGB)", 2D) = "white" {} 7 | _LightMap ("Lightmap (RGB)", 2D) = "lightmap" { LightmapMode } 8 | } 9 | 10 | // ------------------------------------------------------------------ 11 | // Three texture cards (Radeons, GeForce3/4Ti and up) 12 | 13 | SubShader { 14 | LOD 100 15 | Tags { "RenderType"="Opaque" } 16 | 17 | Pass { 18 | Name "BASE" 19 | Tags {"LightMode" = "Vertex"} 20 | Material { 21 | Diffuse [_Color] 22 | Shininess [_Shininess] 23 | Specular [_SpecColor] 24 | } 25 | 26 | Lighting On 27 | SeparateSpecular On 28 | 29 | BindChannels { 30 | Bind "Vertex", vertex 31 | Bind "normal", normal 32 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 33 | Bind "texcoord1", texcoord1 // lightmap uses 2nd uv 34 | Bind "texcoord", texcoord2 // main uses 1st uv 35 | } 36 | 37 | SetTexture [_LightMap] { 38 | constantColor [_Color] 39 | combine texture * constant 40 | } 41 | SetTexture [_LightMap] { 42 | constantColor (0.5,0.5,0.5,0.5) 43 | combine previous * constant + primary 44 | } 45 | SetTexture [_MainTex] { 46 | combine texture * previous DOUBLE, texture * primary 47 | } 48 | } 49 | } 50 | 51 | // ------------------------------------------------------------------ 52 | // Dual texture cards - draw in two passes 53 | 54 | SubShader { 55 | LOD 100 56 | Tags { "RenderType"="Opaque" } 57 | 58 | // Always drawn base pass: texture * lightmap 59 | Pass { 60 | Name "BASE" 61 | Tags {"LightMode" = "Always"} 62 | BindChannels { 63 | Bind "Vertex", vertex 64 | Bind "normal", normal 65 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 66 | Bind "texcoord", texcoord1 // main uses 1st uv 67 | } 68 | SetTexture [_LightMap] { 69 | constantColor [_Color] 70 | combine texture * constant 71 | } 72 | SetTexture [_MainTex] { 73 | combine texture * previous, texture * primary 74 | } 75 | } 76 | 77 | // Vertex lights: add lighting on top of base pass 78 | Pass { 79 | Name "BASE" 80 | Tags {"LightMode" = "Vertex"} 81 | Blend One One ZWrite Off Fog { Color (0,0,0,0) } 82 | Material { 83 | Diffuse [_Color] 84 | Shininess [_Shininess] 85 | Specular [_SpecColor] 86 | } 87 | 88 | Lighting On 89 | SeparateSpecular On 90 | 91 | ColorMask RGB 92 | 93 | SetTexture [_MainTex] { 94 | combine texture * primary DOUBLE, texture 95 | } 96 | } 97 | } 98 | 99 | // ------------------------------------------------------------------ 100 | // Single texture cards - lightmap and texture in two passes; no lighting 101 | 102 | SubShader { 103 | LOD 100 104 | Tags { "RenderType"="Opaque" } 105 | 106 | // Base pass: lightmap 107 | Pass { 108 | Name "BASE" 109 | Tags {"LightMode" = "Always"} 110 | BindChannels { 111 | Bind "Vertex", vertex 112 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 113 | } 114 | SetTexture [_LightMap] { constantColor [_Color] combine texture * constant } 115 | } 116 | 117 | // Second pass: modulate with texture 118 | Pass { 119 | Name "BASE" 120 | Tags {"LightMode" = "Always"} 121 | BindChannels { 122 | Bind "Vertex", vertex 123 | Bind "texcoord", texcoord0 // main uses 1st uv 124 | } 125 | Blend Zero SrcColor 126 | Fog { Color (0,0,0,0) } 127 | SetTexture [_MainTex] { combine texture } 128 | } 129 | } 130 | 131 | Fallback "VertexLit" 132 | } 133 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Mobile/Mobile-BumpSpec-1DirectionalLight.shader: -------------------------------------------------------------------------------- 1 | // Simplified Bumped Specular shader. Differences from regular Bumped Specular one: 2 | // - no Main Color nor Specular Color 3 | // - specular lighting directions are approximated per vertex 4 | // - writes zero to alpha channel 5 | // - Normalmap uses Tiling/Offset of the Base texture 6 | // - no Deferred Lighting support 7 | // - no Lightmap support 8 | // - supports ONLY 1 directional light. Other lights are completely ignored. 9 | 10 | Shader "Mobile/Bumped Specular (1 Directional Light)" { 11 | Properties { 12 | _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 13 | _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} 14 | _BumpMap ("Normalmap", 2D) = "bump" {} 15 | } 16 | SubShader { 17 | Tags { "RenderType"="Opaque" } 18 | LOD 250 19 | 20 | CGPROGRAM 21 | #pragma surface surf MobileBlinnPhong exclude_path:prepass nolightmap noforwardadd halfasview novertexlights 22 | 23 | inline fixed4 LightingMobileBlinnPhong (SurfaceOutput s, fixed3 lightDir, fixed3 halfDir, fixed atten) 24 | { 25 | fixed diff = max (0, dot (s.Normal, lightDir)); 26 | fixed nh = max (0, dot (s.Normal, halfDir)); 27 | fixed spec = pow (nh, s.Specular*128) * s.Gloss; 28 | 29 | fixed4 c; 30 | c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec) * (atten*2); 31 | c.a = 0.0; 32 | return c; 33 | } 34 | 35 | sampler2D _MainTex; 36 | sampler2D _BumpMap; 37 | half _Shininess; 38 | 39 | struct Input { 40 | float2 uv_MainTex; 41 | }; 42 | 43 | void surf (Input IN, inout SurfaceOutput o) { 44 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 45 | o.Albedo = tex.rgb; 46 | o.Gloss = tex.a; 47 | o.Alpha = tex.a; 48 | o.Specular = _Shininess; 49 | o.Normal = UnpackNormal (tex2D(_BumpMap, IN.uv_MainTex)); 50 | } 51 | ENDCG 52 | } 53 | 54 | FallBack "Mobile/VertexLit" 55 | } 56 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Mobile/Mobile-BumpSpec.shader: -------------------------------------------------------------------------------- 1 | // Simplified Bumped Specular shader. Differences from regular Bumped Specular one: 2 | // - no Main Color nor Specular Color 3 | // - specular lighting directions are approximated per vertex 4 | // - writes zero to alpha channel 5 | // - Normalmap uses Tiling/Offset of the Base texture 6 | // - no Deferred Lighting support 7 | // - no Lightmap support 8 | // - fully supports only 1 directional light. Other lights can affect it, but it will be per-vertex/SH. 9 | 10 | Shader "Mobile/Bumped Specular" { 11 | Properties { 12 | _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 13 | _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} 14 | _BumpMap ("Normalmap", 2D) = "bump" {} 15 | } 16 | SubShader { 17 | Tags { "RenderType"="Opaque" } 18 | LOD 250 19 | 20 | CGPROGRAM 21 | #pragma surface surf MobileBlinnPhong exclude_path:prepass nolightmap noforwardadd halfasview 22 | 23 | inline fixed4 LightingMobileBlinnPhong (SurfaceOutput s, fixed3 lightDir, fixed3 halfDir, fixed atten) 24 | { 25 | fixed diff = max (0, dot (s.Normal, lightDir)); 26 | fixed nh = max (0, dot (s.Normal, halfDir)); 27 | fixed spec = pow (nh, s.Specular*128) * s.Gloss; 28 | 29 | fixed4 c; 30 | c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec) * (atten*2); 31 | c.a = 0.0; 32 | return c; 33 | } 34 | 35 | sampler2D _MainTex; 36 | sampler2D _BumpMap; 37 | half _Shininess; 38 | 39 | struct Input { 40 | float2 uv_MainTex; 41 | }; 42 | 43 | void surf (Input IN, inout SurfaceOutput o) { 44 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 45 | o.Albedo = tex.rgb; 46 | o.Gloss = tex.a; 47 | o.Alpha = tex.a; 48 | o.Specular = _Shininess; 49 | o.Normal = UnpackNormal (tex2D(_BumpMap, IN.uv_MainTex)); 50 | } 51 | ENDCG 52 | } 53 | 54 | FallBack "Mobile/VertexLit" 55 | } 56 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Mobile/Mobile-Bumped.shader: -------------------------------------------------------------------------------- 1 | // Simplified Bumped shader. Differences from regular Bumped one: 2 | // - no Main Color 3 | // - Normalmap uses Tiling/Offset of the Base texture 4 | // - fully supports only 1 directional light. Other lights can affect it, but it will be per-vertex/SH. 5 | 6 | Shader "Mobile/Bumped Diffuse" { 7 | Properties { 8 | _MainTex ("Base (RGB)", 2D) = "white" {} 9 | _BumpMap ("Normalmap", 2D) = "bump" {} 10 | } 11 | 12 | SubShader { 13 | Tags { "RenderType"="Opaque" } 14 | LOD 250 15 | 16 | CGPROGRAM 17 | #pragma surface surf Lambert noforwardadd 18 | 19 | sampler2D _MainTex; 20 | sampler2D _BumpMap; 21 | 22 | struct Input { 23 | float2 uv_MainTex; 24 | }; 25 | 26 | void surf (Input IN, inout SurfaceOutput o) { 27 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex); 28 | o.Albedo = c.rgb; 29 | o.Alpha = c.a; 30 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex)); 31 | } 32 | ENDCG 33 | } 34 | 35 | FallBack "Mobile/Diffuse" 36 | } 37 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Mobile/Mobile-Diffuse.shader: -------------------------------------------------------------------------------- 1 | // Simplified Diffuse shader. Differences from regular Diffuse one: 2 | // - no Main Color 3 | // - fully supports only 1 directional light. Other lights can affect it, but it will be per-vertex/SH. 4 | 5 | Shader "Mobile/Diffuse" { 6 | Properties { 7 | _MainTex ("Base (RGB)", 2D) = "white" {} 8 | } 9 | SubShader { 10 | Tags { "RenderType"="Opaque" } 11 | LOD 150 12 | 13 | CGPROGRAM 14 | #pragma surface surf Lambert noforwardadd 15 | 16 | sampler2D _MainTex; 17 | 18 | struct Input { 19 | float2 uv_MainTex; 20 | }; 21 | 22 | void surf (Input IN, inout SurfaceOutput o) { 23 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex); 24 | o.Albedo = c.rgb; 25 | o.Alpha = c.a; 26 | } 27 | ENDCG 28 | } 29 | 30 | Fallback "Mobile/VertexLit" 31 | } 32 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Mobile/Mobile-Lightmap-Unlit.shader: -------------------------------------------------------------------------------- 1 | // Unlit shader. Simplest possible textured shader. 2 | // - SUPPORTS lightmap 3 | // - no lighting 4 | // - no per-material color 5 | 6 | Shader "Mobile/Unlit (Supports Lightmap)" { 7 | Properties { 8 | _MainTex ("Base (RGB)", 2D) = "white" {} 9 | } 10 | 11 | SubShader { 12 | Tags { "RenderType"="Opaque" } 13 | LOD 100 14 | 15 | // Non-lightmapped 16 | Pass { 17 | Tags { "LightMode" = "Vertex" } 18 | Lighting Off 19 | SetTexture [_MainTex] { combine texture } 20 | } 21 | 22 | // Lightmapped, encoded as dLDR 23 | Pass { 24 | Tags { "LightMode" = "VertexLM" } 25 | 26 | Lighting Off 27 | BindChannels { 28 | Bind "Vertex", vertex 29 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 30 | Bind "texcoord", texcoord1 // main uses 1st uv 31 | } 32 | 33 | SetTexture [unity_Lightmap] { 34 | matrix [unity_LightmapMatrix] 35 | combine texture 36 | } 37 | SetTexture [_MainTex] { 38 | combine texture * previous DOUBLE, texture * primary 39 | } 40 | } 41 | 42 | // Lightmapped, encoded as RGBM 43 | Pass { 44 | Tags { "LightMode" = "VertexLMRGBM" } 45 | 46 | Lighting Off 47 | BindChannels { 48 | Bind "Vertex", vertex 49 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 50 | Bind "texcoord", texcoord1 // main uses 1st uv 51 | } 52 | 53 | SetTexture [unity_Lightmap] { 54 | matrix [unity_LightmapMatrix] 55 | combine texture * texture alpha DOUBLE 56 | } 57 | SetTexture [_MainTex] { 58 | combine texture * previous QUAD, texture * primary 59 | } 60 | } 61 | 62 | 63 | } 64 | } 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Mobile/Mobile-Particle-Add.shader: -------------------------------------------------------------------------------- 1 | // Simplified Additive Particle shader. Differences from regular Additive Particle one: 2 | // - no Tint color 3 | // - no Smooth particle support 4 | // - no AlphaTest 5 | // - no ColorMask 6 | 7 | Shader "Mobile/Particles/Additive" { 8 | Properties { 9 | _MainTex ("Particle Texture", 2D) = "white" {} 10 | } 11 | 12 | Category { 13 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 14 | Blend SrcAlpha One 15 | Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) } 16 | 17 | BindChannels { 18 | Bind "Color", color 19 | Bind "Vertex", vertex 20 | Bind "TexCoord", texcoord 21 | } 22 | 23 | SubShader { 24 | Pass { 25 | SetTexture [_MainTex] { 26 | combine texture * primary 27 | } 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Mobile/Mobile-Particle-Alpha-VertexLit.shader: -------------------------------------------------------------------------------- 1 | // Simplified VertexLit Blended Particle shader. Differences from regular VertexLit Blended Particle one: 2 | // - no AlphaTest 3 | // - no ColorMask 4 | 5 | Shader "Mobile/Particles/VertexLit Blended" { 6 | Properties { 7 | _EmisColor ("Emissive Color", Color) = (.2,.2,.2,0) 8 | _MainTex ("Particle Texture", 2D) = "white" {} 9 | } 10 | 11 | Category { 12 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 13 | Blend SrcAlpha OneMinusSrcAlpha 14 | Cull Off ZWrite Off Fog { Color (0,0,0,0) } 15 | 16 | Lighting On 17 | Material { Emission [_EmisColor] } 18 | ColorMaterial AmbientAndDiffuse 19 | 20 | SubShader { 21 | Pass { 22 | SetTexture [_MainTex] { 23 | combine texture * primary 24 | } 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Mobile/Mobile-Particle-Alpha.shader: -------------------------------------------------------------------------------- 1 | // Simplified Alpha Blended Particle shader. Differences from regular Alpha Blended Particle one: 2 | // - no Tint color 3 | // - no Smooth particle support 4 | // - no AlphaTest 5 | // - no ColorMask 6 | 7 | Shader "Mobile/Particles/Alpha Blended" { 8 | Properties { 9 | _MainTex ("Particle Texture", 2D) = "white" {} 10 | } 11 | 12 | Category { 13 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 14 | Blend SrcAlpha OneMinusSrcAlpha 15 | Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) } 16 | 17 | BindChannels { 18 | Bind "Color", color 19 | Bind "Vertex", vertex 20 | Bind "TexCoord", texcoord 21 | } 22 | 23 | SubShader { 24 | Pass { 25 | SetTexture [_MainTex] { 26 | combine texture * primary 27 | } 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Mobile/Mobile-Particle-Multiply.shader: -------------------------------------------------------------------------------- 1 | // Simplified Multiply Particle shader. Differences from regular Multiply Particle one: 2 | // - no Smooth particle support 3 | // - no AlphaTest 4 | // - no ColorMask 5 | 6 | Shader "Mobile/Particles/Multiply" { 7 | Properties { 8 | _MainTex ("Particle Texture", 2D) = "white" {} 9 | } 10 | 11 | Category { 12 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 13 | Blend Zero SrcColor 14 | Cull Off Lighting Off ZWrite Off Fog { Color (1,1,1,1) } 15 | 16 | BindChannels { 17 | Bind "Color", color 18 | Bind "Vertex", vertex 19 | Bind "TexCoord", texcoord 20 | } 21 | 22 | // ---- Dual texture cards 23 | SubShader { 24 | Pass { 25 | SetTexture [_MainTex] { 26 | combine texture * primary 27 | } 28 | SetTexture [_MainTex] { 29 | constantColor (1,1,1,1) 30 | combine previous lerp (previous) constant 31 | } 32 | } 33 | } 34 | 35 | // ---- Single texture cards (does not do particle colors) 36 | SubShader { 37 | Pass { 38 | SetTexture [_MainTex] { 39 | constantColor (1,1,1,1) 40 | combine texture lerp(texture) constant 41 | } 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Mobile/Mobile-Skybox.shader: -------------------------------------------------------------------------------- 1 | // Simplified Skybox shader. Differences from regular Skybox one: 2 | // - no tint color 3 | 4 | Shader "Mobile/Skybox" { 5 | Properties { 6 | _FrontTex ("Front (+Z)", 2D) = "white" {} 7 | _BackTex ("Back (-Z)", 2D) = "white" {} 8 | _LeftTex ("Left (+X)", 2D) = "white" {} 9 | _RightTex ("Right (-X)", 2D) = "white" {} 10 | _UpTex ("Up (+Y)", 2D) = "white" {} 11 | _DownTex ("down (-Y)", 2D) = "white" {} 12 | } 13 | 14 | SubShader { 15 | Tags { "Queue"="Background" "RenderType"="Background" } 16 | Cull Off ZWrite Off Fog { Mode Off } 17 | Pass { 18 | SetTexture [_FrontTex] { combine texture } 19 | } 20 | Pass { 21 | SetTexture [_BackTex] { combine texture } 22 | } 23 | Pass { 24 | SetTexture [_LeftTex] { combine texture } 25 | } 26 | Pass { 27 | SetTexture [_RightTex] { combine texture } 28 | } 29 | Pass { 30 | SetTexture [_UpTex] { combine texture } 31 | } 32 | Pass { 33 | SetTexture [_DownTex] { combine texture } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Mobile/Mobile-VertexLit-OnlyDirectionalLights.shader: -------------------------------------------------------------------------------- 1 | // Simplified VertexLit shader, optimized for high-poly meshes. Differences from regular VertexLit one: 2 | // - less per-vertex work compared with Mobile-VertexLit 3 | // - supports only DIRECTIONAL lights and ambient term, saves some vertex processing power 4 | // - no per-material color 5 | // - no specular 6 | // - no emission 7 | 8 | Shader "Mobile/VertexLit (Only Directional Lights)" { 9 | Properties { 10 | _MainTex ("Base (RGB)", 2D) = "white" {} 11 | } 12 | SubShader { 13 | Tags { "RenderType"="Opaque" } 14 | LOD 80 15 | 16 | Pass { 17 | Name "FORWARD" 18 | Tags { "LightMode" = "ForwardBase" } 19 | CGPROGRAM 20 | #pragma vertex vert_surf 21 | #pragma fragment frag_surf 22 | #pragma fragmentoption ARB_precision_hint_fastest 23 | #pragma multi_compile_fwdbase 24 | #include "HLSLSupport.cginc" 25 | #define UNITY_PASS_FORWARDBASE 26 | #include "UnityCG.cginc" 27 | #include "Lighting.cginc" 28 | #include "AutoLight.cginc" 29 | 30 | #define INTERNAL_DATA 31 | #define WorldReflectionVector(data,normal) data.worldRefl 32 | #define WorldNormalVector(data,normal) normal 33 | 34 | inline float3 LightingLambertVS (float3 normal, float3 lightDir) 35 | { 36 | fixed diff = max (0, dot (normal, lightDir)); 37 | 38 | return _LightColor0.rgb * (diff * 2); 39 | } 40 | 41 | #pragma debug 42 | //#pragma surface surf Lambert 43 | 44 | sampler2D _MainTex; 45 | 46 | struct Input { 47 | float2 uv_MainTex; 48 | }; 49 | 50 | void surf (Input IN, inout SurfaceOutput o) { 51 | half4 c = tex2D (_MainTex, IN.uv_MainTex); 52 | o.Albedo = c.rgb; 53 | o.Alpha = c.a; 54 | } 55 | struct v2f_surf { 56 | float4 pos : SV_POSITION; 57 | float2 pack0 : TEXCOORD0; 58 | #ifdef LIGHTMAP_OFF 59 | fixed3 normal : TEXCOORD1; 60 | #endif 61 | #ifndef LIGHTMAP_OFF 62 | float2 lmap : TEXCOORD2; 63 | #endif 64 | #ifdef LIGHTMAP_OFF 65 | fixed3 vlight : TEXCOORD2; 66 | #endif 67 | LIGHTING_COORDS(3,4) 68 | }; 69 | #ifndef LIGHTMAP_OFF 70 | float4 unity_LightmapST; 71 | float4 unity_LightmapFade; 72 | #endif 73 | float4 _MainTex_ST; 74 | v2f_surf vert_surf (appdata_full v) { 75 | v2f_surf o; 76 | o.pos = mul (UNITY_MATRIX_MVP, v.vertex); 77 | o.pack0.xy = TRANSFORM_TEX(v.texcoord, _MainTex); 78 | #ifndef LIGHTMAP_OFF 79 | o.lmap.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw; 80 | #endif 81 | float3 worldN = mul((float3x3)_Object2World, SCALED_NORMAL); 82 | #ifdef LIGHTMAP_OFF 83 | o.normal = worldN; 84 | #endif 85 | #ifdef LIGHTMAP_OFF 86 | 87 | o.vlight = ShadeSH9 (float4(worldN,1.0)); 88 | o.vlight += LightingLambertVS (worldN, _WorldSpaceLightPos0.xyz); 89 | 90 | #endif // LIGHTMAP_OFF 91 | TRANSFER_VERTEX_TO_FRAGMENT(o); 92 | return o; 93 | } 94 | #ifndef LIGHTMAP_OFF 95 | sampler2D unity_Lightmap; 96 | #endif 97 | fixed4 frag_surf (v2f_surf IN) : COLOR { 98 | Input surfIN; 99 | surfIN.uv_MainTex = IN.pack0.xy; 100 | SurfaceOutput o; 101 | o.Albedo = 0.0; 102 | o.Emission = 0.0; 103 | o.Specular = 0.0; 104 | o.Alpha = 0.0; 105 | o.Gloss = 0.0; 106 | #ifdef LIGHTMAP_OFF 107 | o.Normal = IN.normal; 108 | #endif 109 | surf (surfIN, o); 110 | fixed atten = LIGHT_ATTENUATION(IN); 111 | fixed4 c = 0; 112 | #ifdef LIGHTMAP_OFF 113 | c.rgb = o.Albedo * IN.vlight * atten; 114 | #endif // LIGHTMAP_OFF 115 | #ifndef LIGHTMAP_OFF 116 | fixed3 lm = DecodeLightmap (tex2D(unity_Lightmap, IN.lmap.xy)); 117 | #ifdef SHADOWS_SCREEN 118 | c.rgb += o.Albedo * min(lm, atten*2); 119 | #else 120 | c.rgb += o.Albedo * lm; 121 | #endif 122 | c.a = o.Alpha; 123 | #endif // !LIGHTMAP_OFF 124 | return c; 125 | } 126 | 127 | ENDCG 128 | } 129 | } 130 | 131 | FallBack "Mobile/VertexLit" 132 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Mobile/Mobile-VertexLit.shader: -------------------------------------------------------------------------------- 1 | // Simplified VertexLit shader. Differences from regular VertexLit one: 2 | // - no per-material color 3 | // - no specular 4 | // - no emission 5 | 6 | Shader "Mobile/VertexLit" { 7 | Properties { 8 | _MainTex ("Base (RGB)", 2D) = "white" {} 9 | } 10 | 11 | // ---- Dual texture cards 12 | SubShader { 13 | Tags { "RenderType"="Opaque" } 14 | LOD 80 15 | 16 | // Non-lightmapped 17 | Pass { 18 | Tags { "LightMode" = "Vertex" } 19 | 20 | Material { 21 | Diffuse (1,1,1,1) 22 | Ambient (1,1,1,1) 23 | } 24 | Lighting On 25 | SetTexture [_MainTex] { 26 | Combine texture * primary DOUBLE, texture * primary 27 | } 28 | } 29 | 30 | // Lightmapped, encoded as dLDR 31 | Pass { 32 | Tags { "LightMode" = "VertexLM" } 33 | 34 | BindChannels { 35 | Bind "Vertex", vertex 36 | Bind "normal", normal 37 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 38 | Bind "texcoord", texcoord1 // main uses 1st uv 39 | } 40 | 41 | SetTexture [unity_Lightmap] { 42 | matrix [unity_LightmapMatrix] 43 | combine texture 44 | } 45 | SetTexture [_MainTex] { 46 | combine texture * previous DOUBLE, texture * primary 47 | } 48 | } 49 | 50 | // Lightmapped, encoded as RGBM 51 | Pass { 52 | Tags { "LightMode" = "VertexLMRGBM" } 53 | 54 | BindChannels { 55 | Bind "Vertex", vertex 56 | Bind "normal", normal 57 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 58 | Bind "texcoord", texcoord1 // main uses 1st uv 59 | } 60 | 61 | SetTexture [unity_Lightmap] { 62 | matrix [unity_LightmapMatrix] 63 | combine texture * texture alpha DOUBLE 64 | } 65 | SetTexture [_MainTex] { 66 | combine texture * previous QUAD, texture * primary 67 | } 68 | } 69 | } 70 | 71 | // ---- Single texture cards (requires 2 passes for lightmapped) 72 | SubShader { 73 | Tags { "RenderType"="Opaque" } 74 | LOD 100 75 | 76 | // Non-lightmapped 77 | Pass { 78 | Tags { "LightMode" = "Vertex" } 79 | 80 | Material { 81 | Diffuse (1,1,1,1) 82 | Ambient (1,1,1,1) 83 | } 84 | Lighting On 85 | SetTexture [_MainTex] { 86 | Combine texture * primary DOUBLE, texture * primary 87 | } 88 | } 89 | // Lightmapped, encoded as dLDR 90 | Pass { 91 | // 1st pass - sample Lightmap 92 | Tags { "LightMode" = "VertexLM" } 93 | 94 | BindChannels { 95 | Bind "Vertex", vertex 96 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 97 | } 98 | SetTexture [unity_Lightmap] { 99 | matrix [unity_LightmapMatrix] 100 | combine texture 101 | } 102 | } 103 | 104 | Pass 105 | { 106 | // 2nd pass - multiply with _MainTex 107 | Tags { "LightMode" = "VertexLM" } 108 | ZWrite Off 109 | Fog {Mode Off} 110 | Blend DstColor Zero 111 | SetTexture [_MainTex] { 112 | combine texture 113 | } 114 | } 115 | 116 | // Pass to render object as a shadow caster 117 | Pass 118 | { 119 | Name "ShadowCaster" 120 | Tags { "LightMode" = "ShadowCaster" } 121 | 122 | Fog {Mode Off} 123 | ZWrite On ZTest LEqual Cull Off 124 | Offset 1, 1 125 | 126 | CGPROGRAM 127 | #pragma vertex vert 128 | #pragma fragment frag 129 | #pragma multi_compile_shadowcaster 130 | #pragma fragmentoption ARB_precision_hint_fastest 131 | #include "UnityCG.cginc" 132 | 133 | struct v2f { 134 | V2F_SHADOW_CASTER; 135 | }; 136 | 137 | v2f vert( appdata_base v ) 138 | { 139 | v2f o; 140 | TRANSFER_SHADOW_CASTER(o) 141 | return o; 142 | } 143 | 144 | float4 frag( v2f i ) : COLOR 145 | { 146 | SHADOW_CASTER_FRAGMENT(i) 147 | } 148 | ENDCG 149 | } 150 | 151 | // Pass to render object as a shadow collector 152 | Pass 153 | { 154 | Name "ShadowCollector" 155 | Tags { "LightMode" = "ShadowCollector" } 156 | 157 | Fog {Mode Off} 158 | ZWrite On ZTest LEqual 159 | 160 | CGPROGRAM 161 | #pragma vertex vert 162 | #pragma fragment frag 163 | #pragma fragmentoption ARB_precision_hint_fastest 164 | #pragma multi_compile_shadowcollector 165 | 166 | #define SHADOW_COLLECTOR_PASS 167 | #include "UnityCG.cginc" 168 | 169 | struct appdata { 170 | float4 vertex : POSITION; 171 | }; 172 | 173 | struct v2f { 174 | V2F_SHADOW_COLLECTOR; 175 | }; 176 | 177 | v2f vert (appdata v) 178 | { 179 | v2f o; 180 | TRANSFER_SHADOW_COLLECTOR(o) 181 | return o; 182 | } 183 | 184 | fixed4 frag (v2f i) : COLOR 185 | { 186 | SHADOW_COLLECTOR_FRAGMENT(i) 187 | } 188 | ENDCG 189 | } 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Nature/SoftOcclusion/SH_Vertex.cginc: -------------------------------------------------------------------------------- 1 | #include "HLSLSupport.cginc" 2 | #include "UnityCG.cginc" 3 | #include "TerrainEngine.cginc" 4 | 5 | float _Occlusion, _AO, _BaseLight; 6 | fixed4 _Color; 7 | float3 _TerrainTreeLightDirections[4]; 8 | float4 _TerrainTreeLightColors[4]; 9 | 10 | struct v2f { 11 | float4 pos : POSITION; 12 | float4 uv : TEXCOORD0; 13 | fixed4 color : COLOR0; 14 | }; 15 | 16 | float4x4 _CameraToWorld; 17 | float _HalfOverCutoff; 18 | 19 | v2f leaves(appdata_tree v) 20 | { 21 | v2f o; 22 | 23 | TerrainAnimateTree(v.vertex, v.color.w); 24 | 25 | float3 viewpos = mul(UNITY_MATRIX_MV, v.vertex); 26 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 27 | o.uv = v.texcoord; 28 | 29 | float4 lightDir = 0; 30 | float4 lightColor = 0; 31 | lightDir.w = _AO; 32 | 33 | float4 light = UNITY_LIGHTMODEL_AMBIENT; 34 | 35 | for (int i = 0; i < 4; i++) { 36 | float atten = 1.0; 37 | #ifdef USE_CUSTOM_LIGHT_DIR 38 | lightDir.xyz = _TerrainTreeLightDirections[i]; 39 | lightColor = _TerrainTreeLightColors[i]; 40 | #else 41 | float3 toLight = unity_LightPosition[i].xyz - viewpos.xyz * unity_LightPosition[i].w; 42 | toLight.z *= -1.0; 43 | lightDir.xyz = mul( (float3x3)_CameraToWorld, normalize(toLight) ); 44 | float lengthSq = dot(toLight, toLight); 45 | atten = 1.0 / (1.0 + lengthSq * unity_LightAtten[i].z); 46 | 47 | lightColor.rgb = unity_LightColor[i].rgb; 48 | #endif 49 | 50 | lightDir.xyz *= _Occlusion; 51 | float occ = dot (v.tangent, lightDir); 52 | occ = max(0, occ); 53 | occ += _BaseLight; 54 | light += lightColor * (occ * atten); 55 | } 56 | 57 | o.color = light * _Color; 58 | o.color.a = 0.5 * _HalfOverCutoff; 59 | 60 | return o; 61 | } 62 | 63 | v2f bark(appdata_tree v) 64 | { 65 | v2f o; 66 | 67 | TerrainAnimateTree(v.vertex, v.color.w); 68 | 69 | float3 viewpos = mul(UNITY_MATRIX_MV, v.vertex); 70 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 71 | o.uv = v.texcoord; 72 | 73 | float4 lightDir = 0; 74 | float4 lightColor = 0; 75 | lightDir.w = _AO; 76 | 77 | float4 light = UNITY_LIGHTMODEL_AMBIENT; 78 | 79 | for (int i = 0; i < 4; i++) { 80 | float atten = 1.0; 81 | #ifdef USE_CUSTOM_LIGHT_DIR 82 | lightDir.xyz = _TerrainTreeLightDirections[i]; 83 | lightColor = _TerrainTreeLightColors[i]; 84 | #else 85 | float3 toLight = unity_LightPosition[i].xyz - viewpos.xyz * unity_LightPosition[i].w; 86 | toLight.z *= -1.0; 87 | lightDir.xyz = mul( (float3x3)_CameraToWorld, normalize(toLight) ); 88 | float lengthSq = dot(toLight, toLight); 89 | atten = 1.0 / (1.0 + lengthSq * unity_LightAtten[i].z); 90 | 91 | lightColor.rgb = unity_LightColor[i].rgb; 92 | #endif 93 | 94 | 95 | float diffuse = dot (v.normal, lightDir.xyz); 96 | diffuse = max(0, diffuse); 97 | diffuse *= _AO * v.tangent.w + _BaseLight; 98 | light += lightColor * (diffuse * atten); 99 | } 100 | 101 | light.a = 1; 102 | o.color = light * _Color; 103 | 104 | #ifdef WRITE_ALPHA_1 105 | o.color.a = 1; 106 | #endif 107 | 108 | return o; 109 | } 110 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Nature/SoftOcclusion/TreeSoftOcclusionBark.shader: -------------------------------------------------------------------------------- 1 | Shader "Nature/Tree Soft Occlusion Bark" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,0) 4 | _MainTex ("Main Texture", 2D) = "white" {} 5 | _BaseLight ("Base Light", Range(0, 1)) = 0.35 6 | _AO ("Amb. Occlusion", Range(0, 10)) = 2.4 7 | 8 | // These are here only to provide default values 9 | _Scale ("Scale", Vector) = (1,1,1,1) 10 | _SquashAmount ("Squash", Float) = 1 11 | } 12 | 13 | SubShader { 14 | Tags { 15 | "IgnoreProjector"="True" 16 | "RenderType" = "TreeOpaque" 17 | } 18 | 19 | Pass { 20 | Lighting On 21 | 22 | CGPROGRAM 23 | #pragma vertex bark 24 | #pragma fragment frag 25 | #pragma glsl_no_auto_normalization 26 | #include "SH_Vertex.cginc" 27 | 28 | sampler2D _MainTex; 29 | 30 | fixed4 frag(v2f input) : COLOR 31 | { 32 | fixed4 col = input.color; 33 | col.rgb *= 2.0f * tex2D( _MainTex, input.uv.xy).rgb; 34 | return col; 35 | } 36 | ENDCG 37 | } 38 | 39 | Pass { 40 | Name "ShadowCaster" 41 | Tags { "LightMode" = "ShadowCaster" } 42 | 43 | Fog {Mode Off} 44 | ZWrite On ZTest LEqual Cull Off 45 | Offset 1, 1 46 | 47 | CGPROGRAM 48 | #pragma vertex vert 49 | #pragma fragment frag 50 | #pragma glsl_no_auto_normalization 51 | #pragma fragmentoption ARB_precision_hint_fastest 52 | #pragma multi_compile_shadowcaster 53 | #include "UnityCG.cginc" 54 | #include "TerrainEngine.cginc" 55 | 56 | struct v2f { 57 | V2F_SHADOW_CASTER; 58 | }; 59 | 60 | struct appdata { 61 | float4 vertex : POSITION; 62 | fixed4 color : COLOR; 63 | }; 64 | v2f vert( appdata v ) 65 | { 66 | v2f o; 67 | TerrainAnimateTree(v.vertex, v.color.w); 68 | TRANSFER_SHADOW_CASTER(o) 69 | return o; 70 | } 71 | 72 | float4 frag( v2f i ) : COLOR 73 | { 74 | SHADOW_CASTER_FRAGMENT(i) 75 | } 76 | ENDCG 77 | } 78 | } 79 | 80 | SubShader { 81 | Tags { 82 | "IgnoreProjector"="True" 83 | "RenderType" = "TreeOpaque" 84 | } 85 | 86 | Pass { 87 | CGPROGRAM 88 | #pragma exclude_renderers shaderonly 89 | #pragma vertex bark 90 | #include "SH_Vertex.cginc" 91 | ENDCG 92 | 93 | Lighting On 94 | 95 | SetTexture [_MainTex] { combine primary * texture DOUBLE, constant } 96 | } 97 | } 98 | 99 | SubShader { 100 | Tags { 101 | "IgnoreProjector"="True" 102 | "RenderType" = "Opaque" 103 | } 104 | Pass { 105 | Tags { "LightMode" = "Vertex" } 106 | Lighting On 107 | Material { 108 | Diffuse [_Color] 109 | Ambient [_Color] 110 | } 111 | SetTexture [_MainTex] { combine primary * texture DOUBLE, constant } 112 | } 113 | } 114 | 115 | Dependency "BillboardShader" = "Hidden/Nature/Tree Soft Occlusion Bark Rendertex" 116 | Fallback Off 117 | } 118 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Nature/SoftOcclusion/TreeSoftOcclusionBarkRendertex.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Nature/Tree Soft Occlusion Bark Rendertex" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,0) 4 | _MainTex ("Main Texture", 2D) = "white" {} 5 | _BaseLight ("Base Light", Range(0, 1)) = 0.35 6 | _AO ("Amb. Occlusion", Range(0, 10)) = 2.4 7 | 8 | // These are here only to provide default values 9 | _Scale ("Scale", Vector) = (1,1,1,1) 10 | _SquashAmount ("Squash", Float) = 1 11 | } 12 | 13 | SubShader { 14 | Fog { Mode Off } 15 | Pass { 16 | Lighting On 17 | 18 | CGPROGRAM 19 | #pragma vertex bark 20 | #pragma fragment frag 21 | #pragma glsl_no_auto_normalization 22 | #define WRITE_ALPHA_1 1 23 | #define USE_CUSTOM_LIGHT_DIR 1 24 | #include "SH_Vertex.cginc" 25 | 26 | sampler2D _MainTex; 27 | 28 | fixed4 frag(v2f input) : COLOR 29 | { 30 | fixed4 col = input.color; 31 | col.rgb *= 2.0f * tex2D( _MainTex, input.uv.xy).rgb; 32 | return col; 33 | } 34 | ENDCG 35 | } 36 | } 37 | 38 | SubShader { 39 | Fog { Mode Off } 40 | Pass { 41 | Lighting On 42 | 43 | CGPROGRAM 44 | #pragma exclude_renderers shaderonly 45 | #pragma vertex bark 46 | #define WRITE_ALPHA_1 1 47 | #define USE_CUSTOM_LIGHT_DIR 1 48 | #include "SH_Vertex.cginc" 49 | ENDCG 50 | 51 | SetTexture [_MainTex] { 52 | combine primary * texture double, primary 53 | } 54 | } 55 | } 56 | 57 | Fallback Off 58 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Nature/SoftOcclusion/TreeSoftOcclusionLeaves.shader: -------------------------------------------------------------------------------- 1 | Shader "Nature/Tree Soft Occlusion Leaves" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _MainTex ("Main Texture", 2D) = "white" { } 5 | _Cutoff ("Alpha cutoff", Range(0.25,0.9)) = 0.5 6 | _BaseLight ("Base Light", Range(0, 1)) = 0.35 7 | _AO ("Amb. Occlusion", Range(0, 10)) = 2.4 8 | _Occlusion ("Dir Occlusion", Range(0, 20)) = 7.5 9 | 10 | // These are here only to provide default values 11 | _Scale ("Scale", Vector) = (1,1,1,1) 12 | _SquashAmount ("Squash", Float) = 1 13 | } 14 | 15 | SubShader { 16 | Tags { 17 | "Queue" = "Transparent-99" 18 | "IgnoreProjector"="True" 19 | "RenderType" = "TreeTransparentCutout" 20 | } 21 | Cull Off 22 | ColorMask RGB 23 | 24 | Pass { 25 | Lighting On 26 | 27 | CGPROGRAM 28 | #pragma vertex leaves 29 | #pragma fragment frag 30 | #pragma glsl_no_auto_normalization 31 | #include "SH_Vertex.cginc" 32 | 33 | sampler2D _MainTex; 34 | fixed _Cutoff; 35 | 36 | fixed4 frag(v2f input) : COLOR 37 | { 38 | fixed4 c = tex2D( _MainTex, input.uv.xy); 39 | c.rgb *= 2.0f * input.color.rgb; 40 | 41 | clip (c.a - _Cutoff); 42 | 43 | return c; 44 | } 45 | ENDCG 46 | } 47 | 48 | Pass { 49 | Name "ShadowCaster" 50 | Tags { "LightMode" = "ShadowCaster" } 51 | 52 | Fog {Mode Off} 53 | ZWrite On ZTest LEqual Cull Off 54 | Offset 1, 1 55 | 56 | CGPROGRAM 57 | #pragma vertex vert 58 | #pragma fragment frag 59 | #pragma glsl_no_auto_normalization 60 | #pragma fragmentoption ARB_precision_hint_fastest 61 | #pragma multi_compile_shadowcaster 62 | #include "UnityCG.cginc" 63 | #include "TerrainEngine.cginc" 64 | 65 | struct v2f { 66 | V2F_SHADOW_CASTER; 67 | float2 uv : TEXCOORD1; 68 | }; 69 | 70 | struct appdata { 71 | float4 vertex : POSITION; 72 | fixed4 color : COLOR; 73 | float4 texcoord : TEXCOORD0; 74 | }; 75 | v2f vert( appdata v ) 76 | { 77 | v2f o; 78 | TerrainAnimateTree(v.vertex, v.color.w); 79 | TRANSFER_SHADOW_CASTER(o) 80 | o.uv = v.texcoord; 81 | return o; 82 | } 83 | 84 | sampler2D _MainTex; 85 | fixed _Cutoff; 86 | 87 | float4 frag( v2f i ) : COLOR 88 | { 89 | fixed4 texcol = tex2D( _MainTex, i.uv ); 90 | clip( texcol.a - _Cutoff ); 91 | SHADOW_CASTER_FRAGMENT(i) 92 | } 93 | ENDCG 94 | } 95 | } 96 | 97 | SubShader { 98 | Tags { 99 | "Queue" = "Transparent-99" 100 | "IgnoreProjector"="True" 101 | "RenderType" = "TreeTransparentCutout" 102 | } 103 | Cull Off 104 | ColorMask RGB 105 | 106 | Pass { 107 | CGPROGRAM 108 | #pragma exclude_renderers shaderonly 109 | #pragma vertex leaves 110 | #include "SH_Vertex.cginc" 111 | ENDCG 112 | 113 | Lighting On 114 | AlphaTest GEqual [_Cutoff] 115 | ZWrite On 116 | 117 | SetTexture [_MainTex] { combine primary * texture DOUBLE, texture } 118 | } 119 | } 120 | 121 | SubShader { 122 | Tags { 123 | "Queue" = "Transparent-99" 124 | "IgnoreProjector"="True" 125 | "RenderType" = "TransparentCutout" 126 | } 127 | Cull Off 128 | ColorMask RGB 129 | Pass { 130 | Tags { "LightMode" = "Vertex" } 131 | AlphaTest GEqual [_Cutoff] 132 | Lighting On 133 | Material { 134 | Diffuse [_Color] 135 | Ambient [_Color] 136 | } 137 | SetTexture [_MainTex] { combine primary * texture DOUBLE, texture } 138 | } 139 | } 140 | 141 | Dependency "BillboardShader" = "Hidden/Nature/Tree Soft Occlusion Leaves Rendertex" 142 | Fallback Off 143 | } 144 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Nature/SoftOcclusion/TreeSoftOcclusionLeavesRendertex.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Nature/Tree Soft Occlusion Leaves Rendertex" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,0) 4 | _MainTex ("Main Texture", 2D) = "white" {} 5 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 6 | _HalfOverCutoff ("0.5 / Alpha cutoff", Range(0,1)) = 1.0 7 | _BaseLight ("Base Light", Range(0, 1)) = 0.35 8 | _AO ("Amb. Occlusion", Range(0, 10)) = 2.4 9 | _Occlusion ("Dir Occlusion", Range(0, 20)) = 7.5 10 | 11 | // These are here only to provide default values 12 | _Scale ("Scale", Vector) = (1,1,1,1) 13 | _SquashAmount ("Squash", Float) = 1 14 | } 15 | SubShader { 16 | 17 | Tags { "Queue" = "Transparent-99" } 18 | Cull Off 19 | Fog { Mode Off} 20 | 21 | Pass { 22 | Lighting On 23 | ZWrite On 24 | 25 | CGPROGRAM 26 | #pragma vertex leaves 27 | #pragma fragment frag 28 | #pragma glsl_no_auto_normalization 29 | #define USE_CUSTOM_LIGHT_DIR 1 30 | #include "SH_Vertex.cginc" 31 | 32 | sampler2D _MainTex; 33 | fixed _Cutoff; 34 | 35 | fixed4 frag(v2f input) : COLOR 36 | { 37 | fixed4 col = tex2D( _MainTex, input.uv.xy); 38 | col.rgb *= 2.0f * input.color.rgb; 39 | clip(col.a - _Cutoff); 40 | col.a = 1; 41 | return col; 42 | } 43 | ENDCG 44 | } 45 | } 46 | SubShader { 47 | Tags { "Queue" = "Transparent-99" } 48 | Cull Off 49 | Fog { Mode Off} 50 | 51 | Pass { 52 | CGPROGRAM 53 | #pragma exclude_renderers shaderonly 54 | #pragma vertex leaves 55 | #define USE_CUSTOM_LIGHT_DIR 1 56 | #include "SH_Vertex.cginc" 57 | ENDCG 58 | 59 | Lighting On 60 | ZWrite On 61 | 62 | // We want to do alpha testing on cutoff, but at the same 63 | // time write 1.0 into alpha. So we multiply alpha by 0.25/cutoff 64 | // and alpha test on alpha being greater or equal to 1.0. 65 | // That will work for cutoff values in range [0.25;1]. 66 | // Remember that color gets clamped to [0;1]. 67 | AlphaTest GEqual 1.0 68 | SetTexture [_MainTex] { 69 | combine primary * texture double, primary * texture QUAD 70 | } 71 | } 72 | } 73 | 74 | Fallback Off 75 | } 76 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Nature/TreeCreator/Tree.cginc: -------------------------------------------------------------------------------- 1 | #ifndef TREE_CG_INCLUDED 2 | #define TREE_CG_INCLUDED 3 | 4 | #include "TerrainEngine.cginc" 5 | 6 | fixed4 _Color; 7 | fixed3 _TranslucencyColor; 8 | fixed _TranslucencyViewDependency; 9 | half _ShadowStrength; 10 | 11 | struct LeafSurfaceOutput { 12 | fixed3 Albedo; 13 | fixed3 Normal; 14 | fixed3 Emission; 15 | fixed Translucency; 16 | half Specular; 17 | fixed Gloss; 18 | fixed Alpha; 19 | }; 20 | 21 | inline half4 LightingTreeLeaf (LeafSurfaceOutput s, half3 lightDir, half3 viewDir, half atten) 22 | { 23 | half3 h = normalize (lightDir + viewDir); 24 | 25 | half nl = dot (s.Normal, lightDir); 26 | 27 | half nh = max (0, dot (s.Normal, h)); 28 | half spec = pow (nh, s.Specular * 128.0) * s.Gloss; 29 | 30 | // view dependent back contribution for translucency 31 | fixed backContrib = saturate(dot(viewDir, -lightDir)); 32 | 33 | // normally translucency is more like -nl, but looks better when it's view dependent 34 | backContrib = lerp(saturate(-nl), backContrib, _TranslucencyViewDependency); 35 | 36 | fixed3 translucencyColor = backContrib * s.Translucency * _TranslucencyColor; 37 | 38 | // wrap-around diffuse 39 | nl = max(0, nl * 0.6 + 0.4); 40 | 41 | fixed4 c; 42 | c.rgb = s.Albedo * (translucencyColor * 2 + nl); 43 | c.rgb = c.rgb * _LightColor0.rgb + spec; 44 | 45 | // For directional lights, apply less shadow attenuation 46 | // based on shadow strength parameter. 47 | #if defined(DIRECTIONAL) || defined(DIRECTIONAL_COOKIE) 48 | c.rgb *= lerp(2, atten * 2, _ShadowStrength); 49 | #else 50 | c.rgb *= 2*atten; 51 | #endif 52 | 53 | return c; 54 | } 55 | 56 | #endif -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorBark.shader: -------------------------------------------------------------------------------- 1 | Shader "Nature/Tree Creator Bark" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 5 | _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {} 6 | _BumpMap ("Normalmap", 2D) = "bump" {} 7 | _GlossMap ("Gloss (A)", 2D) = "black" {} 8 | 9 | // These are here only to provide default values 10 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) 11 | _Scale ("Scale", Vector) = (1,1,1,1) 12 | _SquashAmount ("Squash", Float) = 1 13 | } 14 | 15 | SubShader { 16 | Tags { "RenderType"="TreeBark" } 17 | LOD 200 18 | 19 | CGPROGRAM 20 | #pragma surface surf BlinnPhong vertex:TreeVertBark addshadow nolightmap 21 | #pragma exclude_renderers flash 22 | #pragma glsl_no_auto_normalization 23 | #include "Tree.cginc" 24 | 25 | sampler2D _MainTex; 26 | sampler2D _BumpMap; 27 | sampler2D _GlossMap; 28 | half _Shininess; 29 | 30 | struct Input { 31 | float2 uv_MainTex; 32 | fixed4 color : COLOR; 33 | }; 34 | 35 | void surf (Input IN, inout SurfaceOutput o) { 36 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex); 37 | o.Albedo = c.rgb * _Color.rgb * IN.color.a; 38 | o.Gloss = tex2D (_GlossMap, IN.uv_MainTex).a; 39 | o.Alpha = c.a; 40 | o.Specular = _Shininess; 41 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex)); 42 | } 43 | ENDCG 44 | } 45 | 46 | Dependency "OptimizedShader" = "Hidden/Nature/Tree Creator Bark Optimized" 47 | FallBack "Diffuse" 48 | } 49 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorBarkOptimized.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Nature/Tree Creator Bark Optimized" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {} 5 | _BumpSpecMap ("Normalmap (GA) Spec (R)", 2D) = "bump" {} 6 | _TranslucencyMap ("Trans (RGB) Gloss(A)", 2D) = "white" {} 7 | 8 | // These are here only to provide default values 9 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) 10 | _Scale ("Scale", Vector) = (1,1,1,1) 11 | _SquashAmount ("Squash", Float) = 1 12 | } 13 | 14 | SubShader { 15 | Tags { "RenderType"="TreeBark" } 16 | LOD 200 17 | 18 | CGPROGRAM 19 | #pragma surface surf BlinnPhong vertex:TreeVertBark addshadow nolightmap 20 | #pragma exclude_renderers flash 21 | #pragma glsl_no_auto_normalization 22 | #include "Tree.cginc" 23 | 24 | sampler2D _MainTex; 25 | sampler2D _BumpSpecMap; 26 | sampler2D _TranslucencyMap; 27 | 28 | struct Input { 29 | float2 uv_MainTex; 30 | fixed4 color : COLOR; 31 | }; 32 | 33 | void surf (Input IN, inout SurfaceOutput o) { 34 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex); 35 | o.Albedo = c.rgb * _Color.rgb * IN.color.a; 36 | 37 | fixed4 trngls = tex2D (_TranslucencyMap, IN.uv_MainTex); 38 | o.Gloss = trngls.a * _Color.r; 39 | o.Alpha = c.a; 40 | 41 | half4 norspc = tex2D (_BumpSpecMap, IN.uv_MainTex); 42 | o.Specular = norspc.r; 43 | o.Normal = UnpackNormalDXT5nm(norspc); 44 | } 45 | ENDCG 46 | } 47 | 48 | SubShader { 49 | Tags { "RenderType"="TreeBark" } 50 | Pass { 51 | Material { 52 | Diffuse (1,1,1,1) 53 | Ambient (1,1,1,1) 54 | } 55 | Lighting On 56 | SetTexture [_MainTex] { 57 | Combine texture * primary DOUBLE, texture * primary 58 | } 59 | SetTexture [_MainTex] { 60 | ConstantColor [_Color] 61 | Combine previous * constant, previous 62 | } 63 | } 64 | } 65 | 66 | Dependency "BillboardShader" = "Hidden/Nature/Tree Creator Bark Rendertex" 67 | } 68 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorBarkRendertex.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Nature/Tree Creator Bark Rendertex" { 2 | Properties { 3 | _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {} 4 | _BumpSpecMap ("Normalmap (GA) Spec (R)", 2D) = "bump" {} 5 | _TranslucencyMap ("Trans (RGB) Gloss(A)", 2D) = "white" {} 6 | 7 | // These are here only to provide default values 8 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) 9 | _Scale ("Scale", Vector) = (1,1,1,1) 10 | _SquashAmount ("Squash", Float) = 1 11 | } 12 | 13 | SubShader { 14 | Fog { Mode Off } 15 | Pass { 16 | CGPROGRAM 17 | #pragma vertex vert 18 | #pragma fragment frag 19 | #include "UnityCG.cginc" 20 | 21 | struct v2f { 22 | float4 pos : SV_POSITION; 23 | float2 uv : TEXCOORD0; 24 | float3 color : TEXCOORD1; 25 | float2 params[3]: TEXCOORD2; 26 | }; 27 | 28 | float3 _TerrainTreeLightDirections[4]; 29 | float4 _TerrainTreeLightColors[4]; 30 | 31 | v2f vert (appdata_full v) { 32 | v2f o; 33 | o.pos = mul (UNITY_MATRIX_MVP, v.vertex); 34 | o.uv = v.texcoord.xy; 35 | float3 viewDir = normalize(ObjSpaceViewDir(v.vertex)); 36 | 37 | for (int j = 0; j < 3; j++) 38 | { 39 | float3 lightDir = _TerrainTreeLightDirections[j]; 40 | 41 | half nl = dot (v.normal, lightDir); 42 | o.params[j].r = nl; 43 | 44 | half3 h = normalize (lightDir + viewDir); 45 | float nh = max (0, dot (v.normal, h)); 46 | o.params[j].g = nh; 47 | } 48 | 49 | o.color = v.color.a; 50 | return o; 51 | } 52 | 53 | sampler2D _MainTex; 54 | sampler2D _BumpSpecMap; 55 | sampler2D _TranslucencyMap; 56 | fixed4 _SpecColor; 57 | 58 | fixed4 frag (v2f i) : COLOR 59 | { 60 | fixed3 albedo = tex2D (_MainTex, i.uv).rgb * i.color; 61 | half gloss = tex2D (_TranslucencyMap, i.uv).a; 62 | half specular = tex2D (_BumpSpecMap, i.uv).r * 128.0; 63 | 64 | half3 light = UNITY_LIGHTMODEL_AMBIENT * albedo; 65 | 66 | for (int j = 0; j < 3; j++) 67 | { 68 | half3 lightColor = _TerrainTreeLightColors[j].rgb; 69 | 70 | half nl = i.params[j].r; 71 | light += albedo * lightColor * nl; 72 | 73 | float nh = i.params[j].g; 74 | float spec = pow (nh, specular) * gloss; 75 | light += lightColor * _SpecColor.rgb * spec; 76 | } 77 | 78 | fixed4 c; 79 | c.rgb = light * 2.0; 80 | c.a = 1.0; 81 | return c; 82 | } 83 | ENDCG 84 | } 85 | } 86 | 87 | SubShader { 88 | Pass { 89 | Fog { Mode Off } 90 | 91 | CGPROGRAM 92 | #pragma vertex vert 93 | #pragma exclude_renderers shaderonly 94 | #include "UnityCG.cginc" 95 | 96 | struct v2f { 97 | float4 pos : SV_POSITION; 98 | fixed4 color : COLOR; 99 | float2 uv : TEXCOORD0; 100 | }; 101 | 102 | float3 _TerrainTreeLightDirections[4]; 103 | float4 _TerrainTreeLightColors[4]; 104 | 105 | v2f vert (appdata_full v) { 106 | v2f o; 107 | o.pos = mul (UNITY_MATRIX_MVP, v.vertex); 108 | o.uv = v.texcoord.xy; 109 | 110 | float3 light = UNITY_LIGHTMODEL_AMBIENT.rgb; 111 | 112 | for (int j = 0; j < 3; j++) 113 | { 114 | half3 lightColor = _TerrainTreeLightColors[j].rgb; 115 | float3 lightDir = _TerrainTreeLightDirections[j]; 116 | 117 | half nl = dot (v.normal, lightDir); 118 | light += lightColor * nl; 119 | } 120 | 121 | // lighting * AO 122 | o.color.rgb = light * v.color.a; 123 | o.color.a = 1; 124 | return o; 125 | } 126 | ENDCG 127 | 128 | SetTexture [_MainTex] { 129 | Combine texture * primary DOUBLE, primary 130 | } 131 | } 132 | } 133 | 134 | FallBack Off 135 | } 136 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorLeaves.shader: -------------------------------------------------------------------------------- 1 | Shader "Nature/Tree Creator Leaves" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 5 | _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {} 6 | _BumpMap ("Normalmap", 2D) = "bump" {} 7 | _GlossMap ("Gloss (A)", 2D) = "black" {} 8 | _TranslucencyMap ("Translucency (A)", 2D) = "white" {} 9 | _ShadowOffset ("Shadow Offset (A)", 2D) = "black" {} 10 | 11 | // These are here only to provide default values 12 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.3 13 | _Scale ("Scale", Vector) = (1,1,1,1) 14 | _SquashAmount ("Squash", Float) = 1 15 | } 16 | 17 | SubShader { 18 | Tags { "IgnoreProjector"="True" "RenderType"="TreeLeaf" } 19 | LOD 200 20 | 21 | CGPROGRAM 22 | #pragma surface surf TreeLeaf alphatest:_Cutoff vertex:TreeVertLeaf addshadow nolightmap 23 | #pragma exclude_renderers flash 24 | #pragma glsl_no_auto_normalization 25 | #include "Tree.cginc" 26 | 27 | sampler2D _MainTex; 28 | sampler2D _BumpMap; 29 | sampler2D _GlossMap; 30 | sampler2D _TranslucencyMap; 31 | half _Shininess; 32 | 33 | struct Input { 34 | float2 uv_MainTex; 35 | fixed4 color : COLOR; // color.a = AO 36 | }; 37 | 38 | void surf (Input IN, inout LeafSurfaceOutput o) { 39 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex); 40 | o.Albedo = c.rgb * _Color.rgb * IN.color.a; 41 | o.Translucency = tex2D(_TranslucencyMap, IN.uv_MainTex).rgb; 42 | o.Gloss = tex2D(_GlossMap, IN.uv_MainTex).a; 43 | o.Alpha = c.a; 44 | o.Specular = _Shininess; 45 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex)); 46 | } 47 | ENDCG 48 | } 49 | 50 | Dependency "OptimizedShader" = "Hidden/Nature/Tree Creator Leaves Optimized" 51 | FallBack "Diffuse" 52 | } 53 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorLeavesFast.shader: -------------------------------------------------------------------------------- 1 | Shader "Nature/Tree Creator Leaves Fast" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _TranslucencyColor ("Translucency Color", Color) = (0.73,0.85,0.41,1) // (187,219,106,255) 5 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.3 6 | _TranslucencyViewDependency ("View dependency", Range(0,1)) = 0.7 7 | _ShadowStrength("Shadow Strength", Range(0,1)) = 1.0 8 | 9 | _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {} 10 | 11 | // These are here only to provide default values 12 | _Scale ("Scale", Vector) = (1,1,1,1) 13 | _SquashAmount ("Squash", Float) = 1 14 | } 15 | 16 | SubShader { 17 | Tags { 18 | "IgnoreProjector"="True" 19 | "RenderType" = "TreeLeaf" 20 | } 21 | LOD 200 22 | 23 | Pass { 24 | Tags { "LightMode" = "ForwardBase" } 25 | Name "ForwardBase" 26 | 27 | CGPROGRAM 28 | #include "TreeVertexLit.cginc" 29 | 30 | #pragma vertex VertexLeaf 31 | #pragma fragment FragmentLeaf 32 | #pragma exclude_renderers flash 33 | #pragma multi_compile_fwdbase nolightmap 34 | 35 | sampler2D _MainTex; 36 | float4 _MainTex_ST; 37 | 38 | fixed _Cutoff; 39 | sampler2D _ShadowMapTexture; 40 | 41 | struct v2f_leaf { 42 | float4 pos : SV_POSITION; 43 | fixed4 diffuse : COLOR0; 44 | #if defined(SHADOWS_SCREEN) 45 | fixed4 mainLight : COLOR1; 46 | #endif 47 | float2 uv : TEXCOORD0; 48 | #if defined(SHADOWS_SCREEN) 49 | float4 screenPos : TEXCOORD1; 50 | #endif 51 | }; 52 | 53 | v2f_leaf VertexLeaf (appdata_full v) 54 | { 55 | v2f_leaf o; 56 | TreeVertLeaf(v); 57 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 58 | 59 | fixed ao = v.color.a; 60 | ao += 0.1; ao = saturate(ao * ao * ao); // emphasize AO 61 | 62 | fixed3 color = v.color.rgb * _Color.rgb * ao; 63 | 64 | float3 worldN = mul ((float3x3)_Object2World, SCALED_NORMAL); 65 | 66 | fixed4 mainLight; 67 | mainLight.rgb = ShadeTranslucentMainLight (v.vertex, worldN) * color; 68 | mainLight.a = v.color.a; 69 | o.diffuse.rgb = ShadeTranslucentLights (v.vertex, worldN) * color; 70 | o.diffuse.a = 1; 71 | #if defined(SHADOWS_SCREEN) 72 | o.mainLight = mainLight; 73 | o.screenPos = ComputeScreenPos (o.pos); 74 | #else 75 | o.diffuse *= 0.5; 76 | o.diffuse += mainLight; 77 | #endif 78 | o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); 79 | return o; 80 | } 81 | 82 | fixed4 FragmentLeaf (v2f_leaf IN) : COLOR 83 | { 84 | fixed4 albedo = tex2D(_MainTex, IN.uv); 85 | fixed alpha = albedo.a; 86 | clip (alpha - _Cutoff); 87 | 88 | #if defined(SHADOWS_SCREEN) 89 | half4 light = IN.mainLight; 90 | half atten = tex2Dproj(_ShadowMapTexture, UNITY_PROJ_COORD(IN.screenPos)).r; 91 | light.rgb *= lerp(2, 2*atten, _ShadowStrength); 92 | light.rgb += IN.diffuse.rgb; 93 | #else 94 | half4 light = IN.diffuse; 95 | light.rgb *= 2.0; 96 | #endif 97 | 98 | return fixed4 (albedo.rgb * light, 0.0); 99 | } 100 | 101 | ENDCG 102 | } 103 | } 104 | 105 | Dependency "OptimizedShader" = "Hidden/Nature/Tree Creator Leaves Fast Optimized" 106 | FallBack "Diffuse" 107 | } 108 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorLeavesFastOptimized.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Nature/Tree Creator Leaves Fast Optimized" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _TranslucencyColor ("Translucency Color", Color) = (0.73,0.85,0.41,1) // (187,219,106,255) 5 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.3 6 | _TranslucencyViewDependency ("View dependency", Range(0,1)) = 0.7 7 | _ShadowStrength("Shadow Strength", Range(0,1)) = 1.0 8 | 9 | _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {} 10 | _ShadowTex ("Shadow (RGB)", 2D) = "white" {} 11 | 12 | // These are here only to provide default values 13 | _Scale ("Scale", Vector) = (1,1,1,1) 14 | _SquashAmount ("Squash", Float) = 1 15 | } 16 | 17 | SubShader { 18 | Tags { 19 | "IgnoreProjector"="True" 20 | "RenderType" = "TreeLeaf" 21 | } 22 | LOD 200 23 | 24 | Pass { 25 | Tags { "LightMode" = "ForwardBase" } 26 | Name "ForwardBase" 27 | 28 | CGPROGRAM 29 | #include "TreeVertexLit.cginc" 30 | 31 | #pragma vertex VertexLeaf 32 | #pragma fragment FragmentLeaf 33 | #pragma exclude_renderers flash 34 | #pragma multi_compile_fwdbase nolightmap 35 | 36 | sampler2D _MainTex; 37 | float4 _MainTex_ST; 38 | 39 | fixed _Cutoff; 40 | sampler2D _ShadowMapTexture; 41 | 42 | struct v2f_leaf { 43 | float4 pos : SV_POSITION; 44 | fixed4 diffuse : COLOR0; 45 | #if defined(SHADOWS_SCREEN) 46 | fixed4 mainLight : COLOR1; 47 | #endif 48 | float2 uv : TEXCOORD0; 49 | #if defined(SHADOWS_SCREEN) 50 | float4 screenPos : TEXCOORD1; 51 | #endif 52 | }; 53 | 54 | v2f_leaf VertexLeaf (appdata_full v) 55 | { 56 | v2f_leaf o; 57 | TreeVertLeaf(v); 58 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 59 | 60 | fixed ao = v.color.a; 61 | ao += 0.1; ao = saturate(ao * ao * ao); // emphasize AO 62 | 63 | fixed3 color = v.color.rgb * _Color.rgb * ao; 64 | 65 | float3 worldN = mul ((float3x3)_Object2World, SCALED_NORMAL); 66 | 67 | fixed4 mainLight; 68 | mainLight.rgb = ShadeTranslucentMainLight (v.vertex, worldN) * color; 69 | mainLight.a = v.color.a; 70 | o.diffuse.rgb = ShadeTranslucentLights (v.vertex, worldN) * color; 71 | o.diffuse.a = 1; 72 | #if defined(SHADOWS_SCREEN) 73 | o.mainLight = mainLight; 74 | o.screenPos = ComputeScreenPos (o.pos); 75 | #else 76 | o.diffuse *= 0.5; 77 | o.diffuse += mainLight; 78 | #endif 79 | o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); 80 | return o; 81 | } 82 | 83 | fixed4 FragmentLeaf (v2f_leaf IN) : COLOR 84 | { 85 | fixed4 albedo = tex2D(_MainTex, IN.uv); 86 | fixed alpha = albedo.a; 87 | clip (alpha - _Cutoff); 88 | 89 | #if defined(SHADOWS_SCREEN) 90 | half4 light = IN.mainLight; 91 | half atten = tex2Dproj(_ShadowMapTexture, UNITY_PROJ_COORD(IN.screenPos)).r; 92 | light.rgb *= lerp(2, 2*atten, _ShadowStrength); 93 | light.rgb += IN.diffuse.rgb; 94 | #else 95 | half4 light = IN.diffuse; 96 | light.rgb *= 2.0; 97 | #endif 98 | 99 | return fixed4 (albedo.rgb * light, 0.0); 100 | } 101 | 102 | ENDCG 103 | } 104 | 105 | // Pass to render object as a shadow caster 106 | Pass { 107 | Name "ShadowCaster" 108 | Tags { "LightMode" = "ShadowCaster" } 109 | 110 | Fog {Mode Off} 111 | ZWrite On ZTest LEqual 112 | Offset 1, 1 113 | 114 | CGPROGRAM 115 | #pragma vertex vert_surf 116 | #pragma fragment frag_surf 117 | #pragma exclude_renderers noshadows 118 | #pragma fragmentoption ARB_precision_hint_fastest 119 | #pragma multi_compile_shadowcaster 120 | #include "HLSLSupport.cginc" 121 | #include "UnityCG.cginc" 122 | #include "Lighting.cginc" 123 | 124 | #define INTERNAL_DATA 125 | #define WorldReflectionVector(data,normal) data.worldRefl 126 | 127 | #include "Tree.cginc" 128 | 129 | sampler2D _ShadowTex; 130 | 131 | struct v2f_surf { 132 | V2F_SHADOW_CASTER; 133 | float2 hip_pack0 : TEXCOORD1; 134 | }; 135 | 136 | float4 _ShadowTex_ST; 137 | 138 | v2f_surf vert_surf (appdata_full v) { 139 | v2f_surf o; 140 | TreeVertLeaf (v); 141 | o.hip_pack0.xy = TRANSFORM_TEX(v.texcoord, _ShadowTex); 142 | TRANSFER_SHADOW_CASTER(o) 143 | return o; 144 | } 145 | 146 | fixed _Cutoff; 147 | 148 | half4 frag_surf (v2f_surf IN) : COLOR { 149 | fixed alpha = tex2D(_ShadowTex, IN.hip_pack0.xy).r; 150 | clip (alpha - _Cutoff); 151 | SHADOW_CASTER_FRAGMENT(IN) 152 | } 153 | 154 | ENDCG 155 | 156 | } 157 | 158 | // Pass to render object as a shadow collector 159 | Pass { 160 | Name "ShadowCollector" 161 | Tags { "LightMode" = "ShadowCollector" } 162 | 163 | Fog {Mode Off} 164 | ZWrite On ZTest LEqual 165 | 166 | CGPROGRAM 167 | #pragma vertex vert 168 | #pragma fragment frag 169 | #pragma exclude_renderers noshadows 170 | #pragma fragmentoption ARB_precision_hint_fastest 171 | #pragma multi_compile_shadowcollector 172 | 173 | #define SHADOW_COLLECTOR_PASS 174 | #include "UnityCG.cginc" 175 | #include "TerrainEngine.cginc" 176 | 177 | struct v2f { 178 | V2F_SHADOW_COLLECTOR; 179 | float2 uv : TEXCOORD5; 180 | }; 181 | 182 | uniform float4 _MainTex_ST; 183 | 184 | v2f vert (appdata_full v) 185 | { 186 | v2f o; 187 | TreeVertLeaf(v); 188 | TRANSFER_SHADOW_COLLECTOR(o) 189 | o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); 190 | return o; 191 | } 192 | 193 | uniform sampler2D _MainTex; 194 | uniform fixed _Cutoff; 195 | 196 | half4 frag (v2f i) : COLOR 197 | { 198 | fixed4 texcol = tex2D( _MainTex, i.uv ); 199 | clip( texcol.a - _Cutoff ); 200 | 201 | SHADOW_COLLECTOR_FRAGMENT(i) 202 | } 203 | ENDCG 204 | 205 | } 206 | 207 | } 208 | 209 | SubShader { 210 | Tags { 211 | "IgnoreProjector"="True" 212 | "RenderType"="TreeLeaf" 213 | } 214 | 215 | Lighting On 216 | 217 | Pass { 218 | CGPROGRAM 219 | #pragma exclude_renderers shaderonly 220 | #pragma vertex TreeVertLit 221 | #include "UnityCG.cginc" 222 | #include "TreeVertexLit.cginc" 223 | #include "TerrainEngine.cginc" 224 | struct v2f { 225 | float4 pos : SV_POSITION; 226 | fixed4 color : COLOR; 227 | float4 uv : TEXCOORD0; 228 | }; 229 | v2f TreeVertLit (appdata_full v) { 230 | v2f o; 231 | TreeVertLeaf(v); 232 | 233 | o.color.rgb = ShadeVertexLights (v.vertex, v.normal); 234 | 235 | o.pos = mul (UNITY_MATRIX_MVP, v.vertex); 236 | o.uv = v.texcoord; 237 | o.color.a = 1.0f; 238 | return o; 239 | } 240 | ENDCG 241 | 242 | AlphaTest Greater [_Cutoff] 243 | ColorMask RGB 244 | SetTexture [_MainTex] { combine texture * primary DOUBLE, texture } 245 | SetTexture [_MainTex] { 246 | ConstantColor [_Color] 247 | Combine previous * constant, previous 248 | } 249 | } 250 | } 251 | 252 | SubShader { 253 | Tags { "RenderType"="TreeLeaf" } 254 | Pass { 255 | Material { 256 | Diffuse (1,1,1,1) 257 | Ambient (1,1,1,1) 258 | } 259 | Lighting On 260 | AlphaTest Greater [_Cutoff] 261 | ColorMask RGB 262 | SetTexture [_MainTex] { Combine texture * primary DOUBLE, texture } 263 | SetTexture [_MainTex] { 264 | ConstantColor [_Color] 265 | Combine previous * constant, previous 266 | } 267 | } 268 | } 269 | 270 | Dependency "BillboardShader" = "Hidden/Nature/Tree Creator Leaves Rendertex" 271 | } 272 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorLeavesOptimized.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Nature/Tree Creator Leaves Optimized" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _TranslucencyColor ("Translucency Color", Color) = (0.73,0.85,0.41,1) // (187,219,106,255) 5 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.3 6 | _TranslucencyViewDependency ("View dependency", Range(0,1)) = 0.7 7 | _ShadowStrength("Shadow Strength", Range(0,1)) = 0.8 8 | _ShadowOffsetScale ("Shadow Offset Scale", Float) = 1 9 | 10 | _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {} 11 | _ShadowTex ("Shadow (RGB)", 2D) = "white" {} 12 | _BumpSpecMap ("Normalmap (GA) Spec (R) Shadow Offset (B)", 2D) = "bump" {} 13 | _TranslucencyMap ("Trans (B) Gloss(A)", 2D) = "white" {} 14 | 15 | // These are here only to provide default values 16 | _Scale ("Scale", Vector) = (1,1,1,1) 17 | _SquashAmount ("Squash", Float) = 1 18 | } 19 | 20 | SubShader { 21 | Tags { 22 | "IgnoreProjector"="True" 23 | "RenderType"="TreeLeaf" 24 | } 25 | LOD 200 26 | 27 | CGPROGRAM 28 | #pragma surface surf TreeLeaf alphatest:_Cutoff vertex:TreeVertLeaf nolightmap 29 | #pragma exclude_renderers flash 30 | #pragma glsl_no_auto_normalization 31 | #include "Tree.cginc" 32 | 33 | sampler2D _MainTex; 34 | sampler2D _BumpSpecMap; 35 | sampler2D _TranslucencyMap; 36 | 37 | struct Input { 38 | float2 uv_MainTex; 39 | fixed4 color : COLOR; // color.a = AO 40 | }; 41 | 42 | void surf (Input IN, inout LeafSurfaceOutput o) { 43 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex); 44 | o.Albedo = c.rgb * _Color.rgb * IN.color.a; 45 | 46 | fixed4 trngls = tex2D (_TranslucencyMap, IN.uv_MainTex); 47 | o.Translucency = trngls.b; 48 | o.Gloss = trngls.a * _Color.r; 49 | o.Alpha = c.a; 50 | 51 | half4 norspc = tex2D (_BumpSpecMap, IN.uv_MainTex); 52 | o.Specular = norspc.r; 53 | o.Normal = UnpackNormalDXT5nm(norspc); 54 | } 55 | ENDCG 56 | 57 | // Pass to render object as a shadow caster 58 | Pass { 59 | Name "ShadowCaster" 60 | Tags { "LightMode" = "ShadowCaster" } 61 | 62 | Fog {Mode Off} 63 | ZWrite On ZTest LEqual Cull Off 64 | Offset 1, 1 65 | 66 | CGPROGRAM 67 | #pragma vertex vert_surf 68 | #pragma fragment frag_surf 69 | #pragma exclude_renderers noshadows flash 70 | #pragma glsl_no_auto_normalization 71 | #pragma fragmentoption ARB_precision_hint_fastest 72 | #pragma multi_compile_shadowcaster 73 | #include "HLSLSupport.cginc" 74 | #include "UnityCG.cginc" 75 | #include "Lighting.cginc" 76 | 77 | #define INTERNAL_DATA 78 | #define WorldReflectionVector(data,normal) data.worldRefl 79 | 80 | #include "Tree.cginc" 81 | 82 | sampler2D _ShadowTex; 83 | 84 | struct Input { 85 | float2 uv_MainTex; 86 | }; 87 | 88 | struct v2f_surf { 89 | V2F_SHADOW_CASTER; 90 | float2 hip_pack0 : TEXCOORD1; 91 | }; 92 | float4 _ShadowTex_ST; 93 | v2f_surf vert_surf (appdata_full v) { 94 | v2f_surf o; 95 | TreeVertLeaf (v); 96 | o.hip_pack0.xy = TRANSFORM_TEX(v.texcoord, _ShadowTex); 97 | TRANSFER_SHADOW_CASTER(o) 98 | return o; 99 | } 100 | fixed _Cutoff; 101 | float4 frag_surf (v2f_surf IN) : COLOR { 102 | half alpha = tex2D(_ShadowTex, IN.hip_pack0.xy).r; 103 | clip (alpha - _Cutoff); 104 | SHADOW_CASTER_FRAGMENT(IN) 105 | } 106 | ENDCG 107 | } 108 | 109 | // Pass to render object as a shadow collector 110 | Pass { 111 | Name "ShadowCollector" 112 | Tags { "LightMode" = "ShadowCollector" } 113 | 114 | Fog {Mode Off} 115 | ZWrite On ZTest LEqual 116 | 117 | CGPROGRAM 118 | #pragma vertex vert_surf 119 | #pragma fragment frag_surf 120 | #pragma exclude_renderers noshadows flash 121 | #pragma fragmentoption ARB_precision_hint_fastest 122 | #pragma multi_compile_shadowcollector 123 | #pragma glsl_no_auto_normalization 124 | #include "HLSLSupport.cginc" 125 | #define SHADOW_COLLECTOR_PASS 126 | #include "UnityCG.cginc" 127 | #include "Lighting.cginc" 128 | 129 | #define INTERNAL_DATA 130 | #define WorldReflectionVector(data,normal) data.worldRefl 131 | 132 | #include "Tree.cginc" 133 | 134 | sampler2D _MainTex; 135 | sampler2D _BumpSpecMap; 136 | sampler2D _TranslucencyMap; 137 | float _ShadowOffsetScale; 138 | 139 | struct Input { 140 | float2 uv_MainTex; 141 | }; 142 | 143 | struct v2f_surf { 144 | V2F_SHADOW_COLLECTOR; 145 | float2 hip_pack0 : TEXCOORD5; 146 | float3 normal : TEXCOORD6; 147 | }; 148 | 149 | float4 _MainTex_ST; 150 | 151 | v2f_surf vert_surf (appdata_full v) { 152 | v2f_surf o; 153 | TreeVertLeaf (v); 154 | o.hip_pack0.xy = TRANSFORM_TEX(v.texcoord, _MainTex); 155 | 156 | float3 worldN = mul((float3x3)_Object2World, SCALED_NORMAL); 157 | o.normal = mul(_World2Shadow, half4(worldN, 0)).xyz; 158 | 159 | TRANSFER_SHADOW_COLLECTOR(o) 160 | return o; 161 | } 162 | 163 | fixed _Cutoff; 164 | 165 | half4 frag_surf (v2f_surf IN) : COLOR { 166 | half alpha = tex2D(_MainTex, IN.hip_pack0.xy).a; 167 | 168 | float3 shadowOffset = _ShadowOffsetScale * IN.normal * tex2D (_BumpSpecMap, IN.hip_pack0.xy).b; 169 | clip (alpha - _Cutoff); 170 | 171 | IN._ShadowCoord0 += shadowOffset; 172 | IN._ShadowCoord1 += shadowOffset; 173 | IN._ShadowCoord2 += shadowOffset; 174 | IN._ShadowCoord3 += shadowOffset; 175 | 176 | SHADOW_COLLECTOR_FRAGMENT(IN) 177 | } 178 | ENDCG 179 | } 180 | } 181 | 182 | SubShader { 183 | Tags { 184 | "IgnoreProjector"="True" 185 | "RenderType"="TreeLeaf" 186 | } 187 | 188 | ColorMask RGB 189 | Lighting On 190 | 191 | Pass { 192 | CGPROGRAM 193 | #pragma vertex TreeVertLit 194 | #pragma exclude_renderers shaderonly 195 | 196 | #include "UnityCG.cginc" 197 | #include "Tree.cginc" 198 | 199 | struct v2f { 200 | float4 pos : SV_POSITION; 201 | fixed4 color : COLOR; 202 | float4 uv : TEXCOORD0; 203 | }; 204 | 205 | v2f TreeVertLit (appdata_full v) { 206 | v2f o; 207 | TreeVertLeaf(v); 208 | 209 | o.color.rgb = ShadeVertexLights (v.vertex, v.normal); 210 | 211 | o.pos = mul (UNITY_MATRIX_MVP, v.vertex); 212 | o.uv = v.texcoord; 213 | o.color.a = 1.0f; 214 | return o; 215 | } 216 | ENDCG 217 | 218 | AlphaTest Greater [_Cutoff] 219 | SetTexture [_MainTex] { combine texture * primary DOUBLE, texture } 220 | SetTexture [_MainTex] { 221 | ConstantColor [_Color] 222 | Combine previous * constant, previous 223 | } 224 | } 225 | } 226 | 227 | SubShader { 228 | Tags { "RenderType"="TreeLeaf" } 229 | Pass { 230 | ColorMask RGB 231 | 232 | Material { 233 | Diffuse (1,1,1,1) 234 | Ambient (1,1,1,1) 235 | } 236 | Lighting On 237 | 238 | AlphaTest Greater [_Cutoff] 239 | SetTexture [_MainTex] { Combine texture * primary DOUBLE, texture } 240 | SetTexture [_MainTex] { 241 | ConstantColor [_Color] 242 | Combine previous * constant, previous 243 | } 244 | } 245 | } 246 | 247 | Dependency "BillboardShader" = "Hidden/Nature/Tree Creator Leaves Rendertex" 248 | } 249 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorLeavesRendertex.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Nature/Tree Creator Leaves Rendertex" { 2 | Properties { 3 | _TranslucencyColor ("Translucency Color", Color) = (0.73,0.85,0.41,1) // (187,219,106,255) 4 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 5 | _HalfOverCutoff ("0.5 / alpha cutoff", Range(0,1)) = 1.0 6 | _TranslucencyViewDependency ("View dependency", Range(0,1)) = 0.7 7 | 8 | _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {} 9 | _BumpSpecMap ("Normalmap (GA) Spec (R) Shadow Offset (B)", 2D) = "bump" {} 10 | _TranslucencyMap ("Trans (B) Gloss(A)", 2D) = "white" {} 11 | } 12 | 13 | SubShader { 14 | Fog { Mode Off } 15 | 16 | Pass { 17 | CGPROGRAM 18 | #pragma vertex vert 19 | #pragma fragment frag 20 | #include "UnityCG.cginc" 21 | #include "Lighting.cginc" 22 | #include "Tree.cginc" 23 | 24 | struct v2f { 25 | float4 pos : SV_POSITION; 26 | float2 uv : TEXCOORD0; 27 | float3 color : TEXCOORD1; 28 | float3 backContrib : TEXCOORD2; 29 | float3 nl : TEXCOORD3; 30 | float3 nh : TEXCOORD4; 31 | }; 32 | 33 | float3 _TerrainTreeLightDirections[4]; 34 | float4 _TerrainTreeLightColors[4]; 35 | 36 | v2f vert (appdata_full v) { 37 | v2f o; 38 | ExpandBillboard (UNITY_MATRIX_IT_MV, v.vertex, v.normal, v.tangent); 39 | o.pos = mul (UNITY_MATRIX_MVP, v.vertex); 40 | o.uv = v.texcoord.xy; 41 | float3 viewDir = normalize(ObjSpaceViewDir(v.vertex)); 42 | 43 | for (int j = 0; j < 3; j++) 44 | { 45 | float3 lightDir = _TerrainTreeLightDirections[j]; 46 | 47 | half nl = dot (v.normal, lightDir); 48 | 49 | // view dependent back contribution for translucency 50 | half backContrib = saturate(dot(viewDir, -lightDir)); 51 | 52 | // normally translucency is more like -nl, but looks better when it's view dependent 53 | backContrib = lerp(saturate(-nl), backContrib, _TranslucencyViewDependency); 54 | o.backContrib[j] = backContrib * 2; 55 | 56 | // wrap-around diffuse 57 | nl = max (0, nl * 0.6 + 0.4); 58 | o.nl[j] = nl; 59 | 60 | half3 h = normalize (lightDir + viewDir); 61 | float nh = max (0, dot (v.normal, h)); 62 | o.nh[j] = nh; 63 | } 64 | 65 | o.color = v.color.a; 66 | return o; 67 | } 68 | 69 | sampler2D _MainTex; 70 | sampler2D _BumpSpecMap; 71 | sampler2D _TranslucencyMap; 72 | fixed _Cutoff; 73 | 74 | fixed4 frag (v2f i) : COLOR { 75 | fixed4 col = tex2D (_MainTex, i.uv); 76 | clip (col.a - _Cutoff); 77 | 78 | fixed3 albedo = col.rgb * i.color; 79 | 80 | half specular = tex2D (_BumpSpecMap, i.uv).r * 128.0; 81 | 82 | fixed4 trngls = tex2D (_TranslucencyMap, i.uv); 83 | half gloss = trngls.a; 84 | 85 | half3 light = UNITY_LIGHTMODEL_AMBIENT * albedo; 86 | 87 | half3 backContribs = i.backContrib * trngls.b; 88 | 89 | for (int j = 0; j < 3; j++) 90 | { 91 | half3 lightColor = _TerrainTreeLightColors[j].rgb; 92 | half3 translucencyColor = backContribs[j] * _TranslucencyColor; 93 | 94 | half nl = i.nl[j]; 95 | half nh = i.nh[j]; 96 | half spec = pow (nh, specular) * gloss; 97 | light += (albedo * (translucencyColor + nl) + _SpecColor.rgb * spec) * lightColor; 98 | } 99 | 100 | fixed4 c; 101 | c.rgb = light * 2.0; 102 | c.a = 1; 103 | return c; 104 | } 105 | ENDCG 106 | } 107 | } 108 | 109 | SubShader { 110 | Pass { 111 | Fog { Mode Off } 112 | 113 | CGPROGRAM 114 | #pragma vertex vert 115 | #pragma exclude_renderers shaderonly 116 | #include "UnityCG.cginc" 117 | 118 | struct v2f { 119 | float4 pos : SV_POSITION; 120 | fixed4 color : COLOR; 121 | float2 uv : TEXCOORD0; 122 | }; 123 | 124 | float3 _TerrainTreeLightDirections[4]; 125 | float4 _TerrainTreeLightColors[4]; 126 | float _HalfOverCutoff; 127 | 128 | v2f vert (appdata_full v) { 129 | v2f o; 130 | o.pos = mul (UNITY_MATRIX_MVP, v.vertex); 131 | o.uv = v.texcoord.xy; 132 | 133 | float3 light = UNITY_LIGHTMODEL_AMBIENT.rgb; 134 | 135 | for (int j = 0; j < 3; j++) 136 | { 137 | half3 lightColor = _TerrainTreeLightColors[j].rgb; 138 | float3 lightDir = _TerrainTreeLightDirections[j]; 139 | 140 | half nl = dot (v.normal, lightDir); 141 | light += lightColor * nl; 142 | } 143 | 144 | // lighting * AO 145 | o.color.rgb = light * v.color.a; 146 | 147 | // We want to do alpha testing on cutoff, but at the same 148 | // time write 1.0 into alpha. So we multiply alpha by 0.25/cutoff 149 | // and alpha test on alpha being greater or equal to 1.0. 150 | // That will work for cutoff values in range [0.25;1]. 151 | // Remember that color gets clamped to [0;1]. 152 | o.color.a = 0.5 * _HalfOverCutoff; 153 | return o; 154 | } 155 | ENDCG 156 | 157 | AlphaTest GEqual 1 158 | SetTexture [_MainTex] { 159 | Combine texture * primary DOUBLE, texture * primary QUAD 160 | } 161 | } 162 | } 163 | 164 | FallBack Off 165 | } 166 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Nature/TreeCreator/TreeVertexLit.cginc: -------------------------------------------------------------------------------- 1 | #ifndef TREE_VERTEXLIT_CG_INCLUDED 2 | #define TREE_VERTEXLIT_CG_INCLUDED 3 | 4 | #include "UnityCG.cginc" 5 | #include "TerrainEngine.cginc" 6 | 7 | fixed4 _Color; 8 | fixed3 _TranslucencyColor; 9 | fixed _TranslucencyViewDependency; 10 | half _ShadowStrength; 11 | 12 | // --- Lighting ---------------------------------------------------------------- 13 | 14 | fixed3 _LightColor0; 15 | fixed3 ShadeTranslucentMainLight (float4 vertex, float3 normal) 16 | { 17 | float3 viewDir = normalize(WorldSpaceViewDir(vertex)); 18 | float3 lightDir = normalize(WorldSpaceLightDir(vertex)); 19 | fixed3 lightColor = _LightColor0.rgb; 20 | 21 | float nl = dot (normal, lightDir); 22 | 23 | // view dependent back contribution for translucency 24 | fixed backContrib = saturate(dot(viewDir, -lightDir)); 25 | 26 | // normally translucency is more like -nl, but looks better when it's view dependent 27 | backContrib = lerp(saturate(-nl), backContrib, _TranslucencyViewDependency); 28 | 29 | // wrap-around diffuse 30 | fixed diffuse = max(0, nl * 0.6 + 0.4); 31 | 32 | return lightColor.rgb * (diffuse + backContrib * _TranslucencyColor); 33 | } 34 | 35 | 36 | fixed3 ShadeTranslucentLights (float4 vertex, float3 normal) 37 | { 38 | float3 viewDir = normalize(WorldSpaceViewDir(vertex)); 39 | float3 mainLightDir = normalize(WorldSpaceLightDir(vertex)); 40 | float3 frontlight = ShadeSH9 (float4(normal,1.0)); 41 | float3 backlight = ShadeSH9 (float4(-normal,1.0)); 42 | #ifdef VERTEXLIGHT_ON 43 | float3 worldPos = mul(_Object2World, vertex).xyz; 44 | frontlight += Shade4PointLights ( 45 | unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, 46 | unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb, 47 | unity_4LightAtten0, worldPos, normal); 48 | backlight += Shade4PointLights ( 49 | unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, 50 | unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb, 51 | unity_4LightAtten0, worldPos, -normal); 52 | #endif 53 | 54 | // view dependent back contribution for translucency using main light as a cue 55 | fixed backContrib = saturate(dot(viewDir, -mainLightDir)); 56 | backlight = lerp(backlight, backlight * backContrib, _TranslucencyViewDependency); 57 | 58 | // as we integrate over whole sphere instead of normal hemi-sphere 59 | // lighting gets too washed out, so let's half it down 60 | return 0.5 * (frontlight + backlight * _TranslucencyColor); 61 | } 62 | 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Unlit/Unlit-Alpha.shader: -------------------------------------------------------------------------------- 1 | // Unlit alpha-blended shader. 2 | // - no lighting 3 | // - no lightmap support 4 | // - no per-material color 5 | 6 | Shader "Unlit/Transparent" { 7 | Properties { 8 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 9 | } 10 | 11 | SubShader { 12 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 13 | LOD 100 14 | 15 | ZWrite Off 16 | Blend SrcAlpha OneMinusSrcAlpha 17 | 18 | Pass { 19 | Lighting Off 20 | SetTexture [_MainTex] { combine texture } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Unlit/Unlit-AlphaTest.shader: -------------------------------------------------------------------------------- 1 | // Unlit alpha-cutout shader. 2 | // - no lighting 3 | // - no lightmap support 4 | // - no per-material color 5 | 6 | Shader "Unlit/Transparent Cutout" { 7 | Properties { 8 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 9 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 10 | } 11 | 12 | SubShader { 13 | Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"} 14 | LOD 100 15 | 16 | Pass { 17 | Lighting Off 18 | Alphatest Greater [_Cutoff] 19 | SetTexture [_MainTex] { combine texture } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/DefaultResourcesExtra/Unlit/Unlit-Normal.shader: -------------------------------------------------------------------------------- 1 | // Unlit shader. Simplest possible textured shader. 2 | // - no lighting 3 | // - no lightmap support 4 | // - no per-material color 5 | 6 | Shader "Unlit/Texture" { 7 | Properties { 8 | _MainTex ("Base (RGB)", 2D) = "white" {} 9 | } 10 | 11 | SubShader { 12 | Tags { "RenderType"="Opaque" } 13 | LOD 100 14 | 15 | Pass { 16 | Lighting Off 17 | SetTexture [_MainTex] { combine texture } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Unity3D内置Shader源码/buildInShader/Particle Alpha Blend ZWrite Off.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/Alpha Blended ZWrite Off" { 2 | Properties { 3 | _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5) 4 | _MainTex ("Particle Texture", 2D) = "white" {} 5 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 6 | } 7 | 8 | Category { 9 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 10 | Blend SrcAlpha OneMinusSrcAlpha 11 | AlphaTest Greater .01 12 | ColorMask RGB 13 | Cull Off Lighting Off ZWrite Off 14 | BindChannels { 15 | Bind "Color", color 16 | Bind "Vertex", vertex 17 | Bind "TexCoord", texcoord 18 | } 19 | 20 | // ---- Fragment program cards 21 | SubShader { 22 | Pass { 23 | 24 | CGPROGRAM 25 | #pragma vertex vert 26 | #pragma fragment frag 27 | #pragma fragmentoption ARB_precision_hint_fastest 28 | #pragma multi_compile_particles 29 | 30 | #include "UnityCG.cginc" 31 | 32 | sampler2D _MainTex; 33 | fixed4 _TintColor; 34 | 35 | struct appdata_t { 36 | float4 vertex : POSITION; 37 | fixed4 color : COLOR; 38 | float2 texcoord : TEXCOORD0; 39 | }; 40 | 41 | struct v2f { 42 | float4 vertex : POSITION; 43 | fixed4 color : COLOR; 44 | float2 texcoord : TEXCOORD0; 45 | #ifdef SOFTPARTICLES_ON 46 | float4 projPos : TEXCOORD1; 47 | #endif 48 | }; 49 | 50 | float4 _MainTex_ST; 51 | 52 | v2f vert (appdata_t v) 53 | { 54 | v2f o; 55 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 56 | #ifdef SOFTPARTICLES_ON 57 | o.projPos = ComputeScreenPos (o.vertex); 58 | COMPUTE_EYEDEPTH(o.projPos.z); 59 | #endif 60 | o.color = v.color; 61 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 62 | return o; 63 | } 64 | 65 | sampler2D _CameraDepthTexture; 66 | float _InvFade; 67 | 68 | fixed4 frag (v2f i) : COLOR 69 | { 70 | #ifdef SOFTPARTICLES_ON 71 | float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))); 72 | float partZ = i.projPos.z; 73 | float fade = saturate (_InvFade * (sceneZ-partZ)); 74 | i.color.a *= fade; 75 | #endif 76 | 77 | return 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord); 78 | } 79 | ENDCG 80 | } 81 | } 82 | 83 | // ---- Dual texture cards 84 | SubShader { 85 | Pass { 86 | SetTexture [_MainTex] { 87 | constantColor [_TintColor] 88 | combine constant * primary 89 | } 90 | SetTexture [_MainTex] { 91 | combine texture * previous DOUBLE 92 | } 93 | } 94 | } 95 | 96 | // ---- Single texture cards (does not do color tint) 97 | SubShader { 98 | Pass { 99 | SetTexture [_MainTex] { 100 | combine texture * primary 101 | } 102 | } 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Unity3D内部Shader详解.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x522758754/Graphics-books/af4c41eec6b53dc367772e2e93af77df422fe7ad/Unity3D内部Shader详解.doc -------------------------------------------------------------------------------- /Unity3D内部Shader详解.doc.f1471951feb1ea9e6e3f344c6ea4ef00bb89d573: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x522758754/Graphics-books/af4c41eec6b53dc367772e2e93af77df422fe7ad/Unity3D内部Shader详解.doc.f1471951feb1ea9e6e3f344c6ea4ef00bb89d573 -------------------------------------------------------------------------------- /实时计算机图形学第2版.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x522758754/Graphics-books/af4c41eec6b53dc367772e2e93af77df422fe7ad/实时计算机图形学第2版.pdf -------------------------------------------------------------------------------- /游戏引擎架.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x522758754/Graphics-books/af4c41eec6b53dc367772e2e93af77df422fe7ad/游戏引擎架.txt -------------------------------------------------------------------------------- /计算机图形学.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x522758754/Graphics-books/af4c41eec6b53dc367772e2e93af77df422fe7ad/计算机图形学.chm -------------------------------------------------------------------------------- /顶点动画.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x522758754/Graphics-books/af4c41eec6b53dc367772e2e93af77df422fe7ad/顶点动画.xlsx --------------------------------------------------------------------------------