├── .github └── FUNDING.yml ├── .gitignore ├── Data └── Definitions.db ├── LICENSE ├── Library ├── BuiltinShaders │ ├── CGIncludes │ │ ├── AutoLight.html │ │ ├── GLSLSupport.html │ │ ├── HLSLSupport.html │ │ ├── Lighting.html │ │ ├── SpeedTree8Common.html │ │ ├── SpeedTreeBillboardCommon.html │ │ ├── TerrainPreview.html │ │ ├── TerrainTool.html │ │ ├── Tessellation.html │ │ ├── UnityCG.html │ │ ├── UnityDeferredLibrary.html │ │ ├── UnityDeprecated.html │ │ ├── UnityGBuffer.html │ │ ├── UnityGlobalIllumination.html │ │ ├── UnityImageBasedLighting.html │ │ ├── UnityInstancing.html │ │ ├── UnityLightingCommon.html │ │ ├── UnityMetaPass.html │ │ ├── UnityPBSLighting.html │ │ ├── UnityShaderUtilities.html │ │ ├── UnityShaderVariables.html │ │ ├── UnityShadowLibrary.html │ │ ├── UnitySprites.html │ │ ├── UnityStandardBRDF.html │ │ ├── UnityStandardConfig.html │ │ ├── UnityStandardCore.html │ │ ├── UnityStandardCoreForward.html │ │ ├── UnityStandardCoreForwardSimple.html │ │ ├── UnityStandardInput.html │ │ ├── UnityStandardMeta.html │ │ └── UnityStandardUtils.html │ ├── DefaultResources │ │ ├── Font.html │ │ ├── Internal-Colored.html │ │ ├── Internal-ErrorShader.html │ │ ├── Internal-Skinning-Util.html │ │ └── PerformanceTools │ │ │ └── FrameDebuggerRenderTargetDisplay.html │ └── DefaultResourcesExtra │ │ ├── Internal-DeferredReflections.html │ │ ├── Internal-DeferredShading.html │ │ ├── Internal-DepthNormalsTexture.html │ │ ├── Internal-ScreenSpaceShadows.html │ │ ├── Particle Add.html │ │ ├── Reflect-Bumped.html │ │ ├── Reflect-Diffuse.html │ │ ├── Reflect-Glossy.html │ │ ├── Reflect-Parallax.html │ │ ├── Reflect-ParallaxSpec.html │ │ ├── Reflect-VertexLit.html │ │ ├── Skybox-Cubed.html │ │ ├── Skybox-Panoramic.html │ │ ├── Skybox-Procedural.html │ │ ├── Skybox.html │ │ ├── Sprites-Default.html │ │ ├── Sprites-Diffuse.html │ │ ├── Sprites-Mask.html │ │ ├── Standard.html │ │ ├── StandardSpecular.html │ │ └── Unlit │ │ └── Unlit-Alpha.html └── PostProcessing │ ├── Builtins │ ├── Bloom.html │ ├── Copy.html │ ├── CopyStd.html │ ├── CopyStdFromDoubleWide.html │ ├── CopyStdFromTexArray.html │ ├── DeferredFog.html │ ├── DepthOField.html │ ├── DepthOfField.html │ ├── DiscardAlpha.html │ ├── DiskKernels.html │ ├── FastApproximateAntialiasing.html │ ├── FinalPass.html │ ├── Fog.html │ ├── GrainBaker.html │ ├── Lut2DBaker.html │ ├── MotionBlur.html │ ├── MultiScaleVO.html │ ├── SMAA.html │ ├── ScalableAO.html │ ├── ScreenSpaceReflections.html │ ├── SubpixelMorphologicalAntialiasing.html │ ├── SubpixelMorphologicalAntialiasingBridge.html │ ├── TemporalAntialiasing.html │ ├── Texture2DLerp.html │ └── Uber.html │ ├── Colors.html │ └── StdLib.html ├── README.md ├── Scripts ├── link_definitions.js ├── prettify.js ├── run_prettify.js ├── sql-wasm.js ├── sql-wasm.wasm ├── viewer.js └── worker.sql-wasm.js ├── Styles ├── Fonts │ ├── FontAwesome.otf │ ├── fa-brands-400.eot │ ├── fa-brands-400.svg │ ├── fa-brands-400.ttf │ ├── fa-brands-400.woff │ ├── fa-brands-400.woff2 │ ├── fontawesome-webfont.eot │ ├── fontawesome-webfont.svg │ ├── fontawesome-webfont.ttf │ ├── fontawesome-webfont.woff │ └── fontawesome-webfont.woff2 ├── Style.css ├── prettify.css └── vscode.css ├── Tools ├── DynamicViewer.html ├── Paste.html └── Viewer.html └── index.html /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | patreon: teamdogpit 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Bb]uilds/ 6 | Assets/AssetStoreTools* 7 | 8 | # Visual Studio cache directory 9 | .vs/ 10 | 11 | # Autogenerated VS/MD/Consulo solution and project files 12 | ExportedObj/ 13 | .consulo/ 14 | *.csproj 15 | *.unityproj 16 | *.sln 17 | *.suo 18 | *.tmp 19 | *.user 20 | *.userprefs 21 | *.pidb 22 | *.booproj 23 | *.svd 24 | *.pdb 25 | *.opendb 26 | 27 | # Unity3D generated meta files 28 | *.pidb.meta 29 | *.pdb.meta 30 | 31 | # Unity3D Generated File On Crash Reports 32 | sysinfo.txt 33 | 34 | # Builds 35 | *.apk 36 | *.unitypackage 37 | -------------------------------------------------------------------------------- /Data/Definitions.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xibanya/UnityShaderViewer/4572f325f73a5052cf7ed45c2c03d126b35ebb91/Data/Definitions.db -------------------------------------------------------------------------------- /Library/BuiltinShaders/CGIncludes/GLSLSupport.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 6 | 
 7 | #ifndef GLSL_SUPPORT_INCLUDED
 8 | #define GLSL_SUPPORT_INCLUDED
 9 | 
10 | // Automatically included in raw GLSL (GLSLPROGRAM) shader snippets, to map from some of the legacy OpenGL
11 | // variable names to uniform names used by Unity.
12 | 
13 | #ifdef GL_FRAGMENT_PRECISION_HIGH
14 |     precision highp float;
15 | #else
16 |     precision mediump float;
17 | #endif
18 | 
19 | uniform mat4 unity_ObjectToWorld;
20 | uniform mat4 unity_WorldToObject;
21 | uniform mat4 unity_MatrixVP;
22 | uniform mat4 unity_MatrixV;
23 | uniform mat4 unity_MatrixInvV;
24 | uniform mat4 glstate_matrix_projection;
25 | 
26 | #define gl_ModelViewProjectionMatrix        (unity_MatrixVP * unity_ObjectToWorld)
27 | #define gl_ModelViewMatrix                  (unity_MatrixV * unity_ObjectToWorld)
28 | #define gl_ModelViewMatrixTranspose         (transpose(unity_MatrixV * unity_ObjectToWorld))
29 | #define gl_ModelViewMatrixInverseTranspose  (transpose(unity_WorldToObject * unity_MatrixInvV))
30 | #define gl_NormalMatrix                     (transpose(mat3(unity_WorldToObject * unity_MatrixInvV)))
31 | #define gl_ProjectionMatrix                 glstate_matrix_projection
32 | 
33 | #if __VERSION__ < 120
34 | #ifndef UNITY_GLSL_STRIP_TRANSPOSE
35 | mat3 transpose(mat3 mtx)
36 | {
37 |     vec3 c0 = mtx[0];
38 |     vec3 c1 = mtx[1];
39 |     vec3 c2 = mtx[2];
40 | 
41 |     return mat3(
42 |         vec3(c0.x, c1.x, c2.x),
43 |         vec3(c0.y, c1.y, c2.y),
44 |         vec3(c0.z, c1.z, c2.z)
45 |     );
46 | }
47 | mat4 transpose(mat4 mtx)
48 | {
49 |     vec4 c0 = mtx[0];
50 |     vec4 c1 = mtx[1];
51 |     vec4 c2 = mtx[2];
52 |     vec4 c3 = mtx[3];
53 | 
54 |     return mat4(
55 |         vec4(c0.x, c1.x, c2.x, c3.x),
56 |         vec4(c0.y, c1.y, c2.y, c3.y),
57 |         vec4(c0.z, c1.z, c2.z, c3.z),
58 |         vec4(c0.w, c1.w, c2.w, c3.w)
59 |     );
60 | }
61 | #endif
62 | #endif // __VERSION__ < 120
63 | 
64 | #endif // GLSL_SUPPORT_INCLUDED
65 | 
66 | 67 | 68 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/CGIncludes/Lighting.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  6 | 
  7 | #ifndef LIGHTING_INCLUDED
  8 | #define LIGHTING_INCLUDED
  9 | 
 10 | #include "UnityLightingCommon.cginc"
 11 | #include "UnityGBuffer.cginc"
 12 | #include "UnityGlobalIllumination.cginc"
 13 | 
 14 | struct SurfaceOutput {
 15 |     fixed3 Albedo;
 16 |     fixed3 Normal;
 17 |     fixed3 Emission;
 18 |     half Specular;
 19 |     fixed Gloss;
 20 |     fixed Alpha;
 21 | };
 22 | 
 23 | #ifndef USING_DIRECTIONAL_LIGHT
 24 | #if defined (DIRECTIONAL_COOKIE) || defined (DIRECTIONAL)
 25 | #define USING_DIRECTIONAL_LIGHT
 26 | #endif
 27 | #endif
 28 | 
 29 | #if defined(UNITY_SHOULD_SAMPLE_SH) || defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
 30 |     #define UNITY_LIGHT_FUNCTION_APPLY_INDIRECT
 31 | #endif
 32 | 
 33 | inline fixed4 UnityLambertLight (SurfaceOutput s, UnityLight light)
 34 | {
 35 |     fixed diff = max (0, dot (s.Normal, light.dir));
 36 | 
 37 |     fixed4 c;
 38 |     c.rgb = s.Albedo * light.color * diff;
 39 |     c.a = s.Alpha;
 40 |     return c;
 41 | }
 42 | 
 43 | inline fixed4 LightingLambert (SurfaceOutput s, UnityGI gi)
 44 | {
 45 |     fixed4 c;
 46 |     c = UnityLambertLight (s, gi.light);
 47 | 
 48 |     #ifdef UNITY_LIGHT_FUNCTION_APPLY_INDIRECT
 49 |         c.rgb += s.Albedo * gi.indirect.diffuse;
 50 |     #endif
 51 | 
 52 |     return c;
 53 | }
 54 | 
 55 | inline half4 LightingLambert_Deferred (SurfaceOutput s, UnityGI gi, out half4 outGBuffer0, out half4 outGBuffer1, out half4 outGBuffer2)
 56 | {
 57 |     UnityStandardData data;
 58 |     data.diffuseColor   = s.Albedo;
 59 |     data.occlusion      = 1;
 60 |     data.specularColor  = 0;
 61 |     data.smoothness     = 0;
 62 |     data.normalWorld    = s.Normal;
 63 | 
 64 |     UnityStandardDataToGbuffer(data, outGBuffer0, outGBuffer1, outGBuffer2);
 65 | 
 66 |     half4 emission = half4(s.Emission, 1);
 67 | 
 68 |     #ifdef UNITY_LIGHT_FUNCTION_APPLY_INDIRECT
 69 |         emission.rgb += s.Albedo * gi.indirect.diffuse;
 70 |     #endif
 71 | 
 72 |     return emission;
 73 | }
 74 | 
 75 | inline void LightingLambert_GI (
 76 |     SurfaceOutput s,
 77 |     UnityGIInput data,
 78 |     inout UnityGI gi)
 79 | {
 80 |     gi = UnityGlobalIllumination (data, 1.0, s.Normal);
 81 | }
 82 | 
 83 | inline fixed4 LightingLambert_PrePass (SurfaceOutput s, half4 light)
 84 | {
 85 |     fixed4 c;
 86 |     c.rgb = s.Albedo * light.rgb;
 87 |     c.a = s.Alpha;
 88 |     return c;
 89 | }
 90 | 
 91 | // NOTE: some intricacy in shader compiler on some GLES2.0 platforms (iOS) needs 'viewDir' & 'h'
 92 | // to be mediump instead of lowp, otherwise specular highlight becomes too bright.
 93 | inline fixed4 UnityBlinnPhongLight (SurfaceOutput s, half3 viewDir, UnityLight light)
 94 | {
 95 |     half3 h = normalize (light.dir + viewDir);
 96 | 
 97 |     fixed diff = max (0, dot (s.Normal, light.dir));
 98 | 
 99 |     float nh = max (0, dot (s.Normal, h));
100 |     float spec = pow (nh, s.Specular*128.0) * s.Gloss;
101 | 
102 |     fixed4 c;
103 |     c.rgb = s.Albedo * light.color * diff + light.color * _SpecColor.rgb * spec;
104 |     c.a = s.Alpha;
105 | 
106 |     return c;
107 | }
108 | 
109 | inline fixed4 LightingBlinnPhong (SurfaceOutput s, half3 viewDir, UnityGI gi)
110 | {
111 |     fixed4 c;
112 |     c = UnityBlinnPhongLight (s, viewDir, gi.light);
113 | 
114 |     #ifdef UNITY_LIGHT_FUNCTION_APPLY_INDIRECT
115 |         c.rgb += s.Albedo * gi.indirect.diffuse;
116 |     #endif
117 | 
118 |     return c;
119 | }
120 | 
121 | inline half4 LightingBlinnPhong_Deferred (SurfaceOutput s, half3 viewDir, UnityGI gi, out half4 outGBuffer0, out half4 outGBuffer1, out half4 outGBuffer2)
122 | {
123 |     UnityStandardData data;
124 |     data.diffuseColor   = s.Albedo;
125 |     data.occlusion      = 1;
126 |     // PI factor come from StandardBDRF (UnityStandardBRDF.cginc:351 for explanation)
127 |     data.specularColor  = _SpecColor.rgb * s.Gloss * (1/UNITY_PI);
128 |     data.smoothness     = s.Specular;
129 |     data.normalWorld    = s.Normal;
130 | 
131 |     UnityStandardDataToGbuffer(data, outGBuffer0, outGBuffer1, outGBuffer2);
132 | 
133 |     half4 emission = half4(s.Emission, 1);
134 | 
135 |     #ifdef UNITY_LIGHT_FUNCTION_APPLY_INDIRECT
136 |         emission.rgb += s.Albedo * gi.indirect.diffuse;
137 |     #endif
138 | 
139 |     return emission;
140 | }
141 | 
142 | inline void LightingBlinnPhong_GI (
143 |     SurfaceOutput s,
144 |     UnityGIInput data,
145 |     inout UnityGI gi)
146 | {
147 |     gi = UnityGlobalIllumination (data, 1.0, s.Normal);
148 | }
149 | 
150 | inline fixed4 LightingBlinnPhong_PrePass (SurfaceOutput s, half4 light)
151 | {
152 |     fixed spec = light.a * s.Gloss;
153 | 
154 |     fixed4 c;
155 |     c.rgb = (s.Albedo * light.rgb + light.rgb * _SpecColor.rgb * spec);
156 |     c.a = s.Alpha;
157 |     return c;
158 | }
159 | 
160 | #ifdef UNITY_CAN_COMPILE_TESSELLATION
161 | struct UnityTessellationFactors {
162 |     float edge[3] : SV_TessFactor;
163 |     float inside : SV_InsideTessFactor;
164 | };
165 | #endif // UNITY_CAN_COMPILE_TESSELLATION
166 | 
167 | // Deprecated, kept around for existing user shaders.
168 | #define UNITY_DIRBASIS \
169 | const half3x3 unity_DirBasis = half3x3( \
170 |   half3( 0.81649658,  0.0,        0.57735027), \
171 |   half3(-0.40824830,  0.70710678, 0.57735027), \
172 |   half3(-0.40824830, -0.70710678, 0.57735027) \
173 | );
174 | 
175 | // Deprecated, kept around for existing user shaders. Only sampling the flat lightmap now.
176 | half3 DirLightmapDiffuse(in half3x3 dirBasis, fixed4 color, fixed4 scale, half3 normal, bool surfFuncWritesNormal, out half3 scalePerBasisVector)
177 | {
178 |     scalePerBasisVector = 1;
179 |     return DecodeLightmap (color);
180 | }
181 | 
182 | #endif
183 | 
184 | 185 | 186 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/CGIncludes/SpeedTreeBillboardCommon.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  6 | 
  7 | #ifndef SPEEDTREE_BILLBOARD_COMMON_INCLUDED
  8 | #define SPEEDTREE_BILLBOARD_COMMON_INCLUDED
  9 | 
 10 | #define SPEEDTREE_ALPHATEST
 11 | fixed _Cutoff;
 12 | 
 13 | #include "SpeedTreeCommon.cginc"
 14 | 
 15 | CBUFFER_START(UnityBillboardPerCamera)
 16 |     float3 unity_BillboardNormal;
 17 |     float3 unity_BillboardTangent;
 18 |     float4 unity_BillboardCameraParams;
 19 |     #define unity_BillboardCameraPosition (unity_BillboardCameraParams.xyz)
 20 |     #define unity_BillboardCameraXZAngle (unity_BillboardCameraParams.w)
 21 | CBUFFER_END
 22 | 
 23 | CBUFFER_START(UnityBillboardPerBatch)
 24 |     float4 unity_BillboardInfo; // x: num of billboard slices; y: 1.0f / (delta angle between slices)
 25 |     float4 unity_BillboardSize; // x: width; y: height; z: bottom
 26 |     float4 unity_BillboardImageTexCoords[16];
 27 | CBUFFER_END
 28 | 
 29 | struct SpeedTreeBillboardData
 30 | {
 31 |     float4 vertex       : POSITION;
 32 |     float2 texcoord     : TEXCOORD0;
 33 |     float4 texcoord1    : TEXCOORD1;
 34 |     float3 normal       : NORMAL;
 35 |     float4 tangent      : TANGENT;
 36 |     float4 color        : COLOR;
 37 |     UNITY_VERTEX_INPUT_INSTANCE_ID
 38 | };
 39 | 
 40 | void SpeedTreeBillboardVert(inout SpeedTreeBillboardData IN, out Input OUT)
 41 | {
 42 |     UNITY_INITIALIZE_OUTPUT(Input, OUT);
 43 | 
 44 |     // assume no scaling & rotation
 45 |     float3 worldPos = IN.vertex.xyz + float3(unity_ObjectToWorld[0].w, unity_ObjectToWorld[1].w, unity_ObjectToWorld[2].w);
 46 | 
 47 | #ifdef BILLBOARD_FACE_CAMERA_POS
 48 |     float3 eyeVec = normalize(unity_BillboardCameraPosition - worldPos);
 49 |     float3 billboardTangent = normalize(float3(-eyeVec.z, 0, eyeVec.x));            // cross(eyeVec, {0,1,0})
 50 |     float3 billboardNormal = float3(billboardTangent.z, 0, -billboardTangent.x);    // cross({0,1,0},billboardTangent)
 51 |     float3 angle = atan2(billboardNormal.z, billboardNormal.x);                     // signed angle between billboardNormal to {0,0,1}
 52 |     angle += angle < 0 ? 2 * UNITY_PI : 0;
 53 | #else
 54 |     float3 billboardTangent = unity_BillboardTangent;
 55 |     float3 billboardNormal = unity_BillboardNormal;
 56 |     float angle = unity_BillboardCameraXZAngle;
 57 | #endif
 58 | 
 59 |     float widthScale = IN.texcoord1.x;
 60 |     float heightScale = IN.texcoord1.y;
 61 |     float rotation = IN.texcoord1.z;
 62 | 
 63 |     float2 percent = IN.texcoord.xy;
 64 |     float3 billboardPos = (percent.x - 0.5f) * unity_BillboardSize.x * widthScale * billboardTangent;
 65 |     billboardPos.y += (percent.y * unity_BillboardSize.y + unity_BillboardSize.z) * heightScale;
 66 | 
 67 | #ifdef ENABLE_WIND
 68 |     if (_WindQuality * _WindEnabled > 0)
 69 |         billboardPos = GlobalWind(billboardPos, worldPos, true, _ST_WindVector.xyz, IN.texcoord1.w);
 70 | #endif
 71 | 
 72 |     IN.vertex.xyz += billboardPos;
 73 |     IN.vertex.w = 1.0f;
 74 |     IN.normal = billboardNormal.xyz;
 75 |     IN.tangent = float4(billboardTangent.xyz,-1);
 76 | 
 77 |     float slices = unity_BillboardInfo.x;
 78 |     float invDelta = unity_BillboardInfo.y;
 79 |     angle += rotation;
 80 | 
 81 |     float imageIndex = fmod(floor(angle * invDelta + 0.5f), slices);
 82 |     float4 imageTexCoords = unity_BillboardImageTexCoords[imageIndex];
 83 |     if (imageTexCoords.w < 0)
 84 |     {
 85 |         OUT.mainTexUV = imageTexCoords.xy - imageTexCoords.zw * percent.yx;
 86 |     }
 87 |     else
 88 |     {
 89 |         OUT.mainTexUV = imageTexCoords.xy + imageTexCoords.zw * percent;
 90 |     }
 91 | 
 92 |     OUT.color = _Color;
 93 | 
 94 | #ifdef EFFECT_HUE_VARIATION
 95 |     float hueVariationAmount = frac(worldPos.x + worldPos.y + worldPos.z);
 96 |     OUT.HueVariationAmount = saturate(hueVariationAmount * _HueVariation.a);
 97 | #endif
 98 | }
 99 | 
100 | #endif // SPEEDTREE_BILLBOARD_COMMON_INCLUDED
101 | 
102 | 103 | 104 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/CGIncludes/TerrainPreview.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 6 | 
 7 | #ifndef TERRAIN_PREVIEW_INCLUDED
 8 | #define TERRAIN_PREVIEW_INCLUDED
 9 | 
10 | 
11 | // function to convert paint context pixels to heightmap uv
12 | sampler2D _Heightmap;
13 | float2 _HeightmapUV_PCPixelsX;
14 | float2 _HeightmapUV_PCPixelsY;
15 | float2 _HeightmapUV_Offset;
16 | float2 PaintContextPixelsToHeightmapUV(float2 pcPixels)
17 | {
18 |     return _HeightmapUV_PCPixelsX * pcPixels.x +
19 |         _HeightmapUV_PCPixelsY * pcPixels.y +
20 |         _HeightmapUV_Offset;
21 | }
22 | 
23 | // function to convert paint context pixels to object position (terrain position)
24 | float3 _ObjectPos_PCPixelsX;
25 | float3 _ObjectPos_PCPixelsY;
26 | float3 _ObjectPos_HeightMapSample;
27 | float3 _ObjectPos_Offset;
28 | float3 PaintContextPixelsToObjectPosition(float2 pcPixels, float heightmapSample)
29 | {
30 |     // note: we could assume no object space rotation and make this dramatically simpler
31 |     return _ObjectPos_PCPixelsX * pcPixels.x +
32 |         _ObjectPos_PCPixelsY * pcPixels.y +
33 |         _ObjectPos_HeightMapSample * heightmapSample +
34 |         _ObjectPos_Offset;
35 | }
36 | 
37 | // function to convert paint context pixels to brush uv
38 | float2 _BrushUV_PCPixelsX;
39 | float2 _BrushUV_PCPixelsY;
40 | float2 _BrushUV_Offset;
41 | float2 PaintContextPixelsToBrushUV(float2 pcPixels)
42 | {
43 |     return _BrushUV_PCPixelsX * pcPixels.x +
44 |         _BrushUV_PCPixelsY * pcPixels.y +
45 |         _BrushUV_Offset;
46 | }
47 | 
48 | // function to convert terrain object position to world position
49 | // We would normally use the ObjectToWorld / ObjectToClip calls to do this, but DrawProcedural does not set them
50 | // 'luckily' terrains cannot be rotated or scaled, so this transform is very simple
51 | float3 _TerrainObjectToWorldOffset;
52 | float3 TerrainObjectToWorldPosition(float3 objectPosition)
53 | {
54 |     return objectPosition + _TerrainObjectToWorldOffset;
55 | }
56 | 
57 | // function to build a procedural quad mesh
58 | // based on the quad resolution defined by _QuadRez
59 | // returns integer positions, starting with (0, 0), and ending with (_QuadRez.xy - 1)
60 | float3 _QuadRez;    // quads X, quads Y, vertexCount
61 | float2 BuildProceduralQuadMeshVertex(uint vertexID)
62 | {
63 |     int quadIndex = vertexID / 6;                       // quad index, each quad is made of 6 vertices
64 |     int vertIndex = vertexID - quadIndex * 6;           // vertex index within the quad [0..5]
65 |     int qY = floor((quadIndex + 0.5f) / _QuadRez.x);    // quad coords for current quad (Y)
66 |     int qX = round(quadIndex - qY * _QuadRez.x);        // quad coords for current quad (X)
67 | 
68 |     // each quad is defined by 6 vertices (two triangles), offset from (qX,qY) as follows:
69 |     // vX = 0, 0, 1, 1, 1, 0
70 |     // vY = 0, 1, 1, 1, 0, 0
71 |     float sequence[6] = { 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f };
72 |     float vX = sequence[vertIndex];
73 |     float vY = sequence[5 - vertIndex];     // vY is just vX reversed
74 |     float2 coord = float2(qX + vX, qY + vY);
75 |     return coord;
76 | }
77 | 
78 | 
79 | float Stripe(in float x, in float stripeX, in float pixelWidth)
80 | {
81 |     // compute derivatives to get ddx / pixel
82 |     float2 derivatives = float2(ddx(x), ddy(x));
83 |     float derivLen = length(derivatives);
84 |     float sharpen = 1.0f / max(derivLen, 0.00001f);
85 |     return saturate(0.5f + 0.5f * (0.5f * pixelWidth - sharpen * abs(x - stripeX)));
86 | }
87 | 
88 | #endif
89 | 
90 | 91 | 92 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/CGIncludes/TerrainTool.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 6 | 
 7 | #ifndef TERRAIN_TOOL_INCLUDED
 8 | #define TERRAIN_TOOL_INCLUDED
 9 | 
10 | 
11 | // function to convert paint context UV to brush uv
12 | float4 _PCUVToBrushUVScales;
13 | float2 _PCUVToBrushUVOffset;
14 | float2 PaintContextUVToBrushUV(float2 pcUV)
15 | {
16 |     return _PCUVToBrushUVScales.xy * pcUV.x +
17 |            _PCUVToBrushUVScales.zw * pcUV.y +
18 |            _PCUVToBrushUVOffset;
19 | }
20 | 
21 | 
22 | float2 PaintContextUVToHeightmapUV(float2 pcUV)
23 | {
24 |     return pcUV;
25 | }
26 | 
27 | 
28 | #endif  
29 | 
30 | 31 | 32 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/CGIncludes/Tessellation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  6 | 
  7 | #ifndef TESSELLATION_CGINC_INCLUDED
  8 | #define TESSELLATION_CGINC_INCLUDED
  9 | 
 10 | #include "UnityShaderVariables.cginc"
 11 | 
 12 | // ---- utility functions
 13 | 
 14 | float UnityCalcDistanceTessFactor (float4 vertex, float minDist, float maxDist, float tess)
 15 | {
 16 |     float3 wpos = mul(unity_ObjectToWorld,vertex).xyz;
 17 |     float dist = distance (wpos, _WorldSpaceCameraPos);
 18 |     float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0) * tess;
 19 |     return f;
 20 | }
 21 | 
 22 | float4 UnityCalcTriEdgeTessFactors (float3 triVertexFactors)
 23 | {
 24 |     float4 tess;
 25 |     tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z);
 26 |     tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z);
 27 |     tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y);
 28 |     tess.w = (triVertexFactors.x + triVertexFactors.y + triVertexFactors.z) / 3.0f;
 29 |     return tess;
 30 | }
 31 | 
 32 | float UnityCalcEdgeTessFactor (float3 wpos0, float3 wpos1, float edgeLen)
 33 | {
 34 |     // distance to edge center
 35 |     float dist = distance (0.5 * (wpos0+wpos1), _WorldSpaceCameraPos);
 36 |     // length of the edge
 37 |     float len = distance(wpos0, wpos1);
 38 |     // edgeLen is approximate desired size in pixels
 39 |     float f = max(len * _ScreenParams.y / (edgeLen * dist), 1.0);
 40 |     return f;
 41 | }
 42 | 
 43 | float UnityDistanceFromPlane (float3 pos, float4 plane)
 44 | {
 45 |     float d = dot (float4(pos,1.0f), plane);
 46 |     return d;
 47 | }
 48 | 
 49 | 
 50 | // Returns true if triangle with given 3 world positions is outside of camera's view frustum.
 51 | // cullEps is distance outside of frustum that is still considered to be inside (i.e. max displacement)
 52 | bool UnityWorldViewFrustumCull (float3 wpos0, float3 wpos1, float3 wpos2, float cullEps)
 53 | {
 54 |     float4 planeTest;
 55 | 
 56 |     // left
 57 |     planeTest.x = (( UnityDistanceFromPlane(wpos0, unity_CameraWorldClipPlanes[0]) > -cullEps) ? 1.0f : 0.0f ) +
 58 |                   (( UnityDistanceFromPlane(wpos1, unity_CameraWorldClipPlanes[0]) > -cullEps) ? 1.0f : 0.0f ) +
 59 |                   (( UnityDistanceFromPlane(wpos2, unity_CameraWorldClipPlanes[0]) > -cullEps) ? 1.0f : 0.0f );
 60 |     // right
 61 |     planeTest.y = (( UnityDistanceFromPlane(wpos0, unity_CameraWorldClipPlanes[1]) > -cullEps) ? 1.0f : 0.0f ) +
 62 |                   (( UnityDistanceFromPlane(wpos1, unity_CameraWorldClipPlanes[1]) > -cullEps) ? 1.0f : 0.0f ) +
 63 |                   (( UnityDistanceFromPlane(wpos2, unity_CameraWorldClipPlanes[1]) > -cullEps) ? 1.0f : 0.0f );
 64 |     // top
 65 |     planeTest.z = (( UnityDistanceFromPlane(wpos0, unity_CameraWorldClipPlanes[2]) > -cullEps) ? 1.0f : 0.0f ) +
 66 |                   (( UnityDistanceFromPlane(wpos1, unity_CameraWorldClipPlanes[2]) > -cullEps) ? 1.0f : 0.0f ) +
 67 |                   (( UnityDistanceFromPlane(wpos2, unity_CameraWorldClipPlanes[2]) > -cullEps) ? 1.0f : 0.0f );
 68 |     // bottom
 69 |     planeTest.w = (( UnityDistanceFromPlane(wpos0, unity_CameraWorldClipPlanes[3]) > -cullEps) ? 1.0f : 0.0f ) +
 70 |                   (( UnityDistanceFromPlane(wpos1, unity_CameraWorldClipPlanes[3]) > -cullEps) ? 1.0f : 0.0f ) +
 71 |                   (( UnityDistanceFromPlane(wpos2, unity_CameraWorldClipPlanes[3]) > -cullEps) ? 1.0f : 0.0f );
 72 | 
 73 |     // has to pass all 4 plane tests to be visible
 74 |     return !all (planeTest);
 75 | }
 76 | 
 77 | 
 78 | 
 79 | // ---- functions that compute tessellation factors
 80 | 
 81 | 
 82 | // Distance based tessellation:
 83 | // Tessellation level is "tess" before "minDist" from camera, and linearly decreases to 1
 84 | // up to "maxDist" from camera.
 85 | float4 UnityDistanceBasedTess (float4 v0, float4 v1, float4 v2, float minDist, float maxDist, float tess)
 86 | {
 87 |     float3 f;
 88 |     f.x = UnityCalcDistanceTessFactor (v0,minDist,maxDist,tess);
 89 |     f.y = UnityCalcDistanceTessFactor (v1,minDist,maxDist,tess);
 90 |     f.z = UnityCalcDistanceTessFactor (v2,minDist,maxDist,tess);
 91 | 
 92 |     return UnityCalcTriEdgeTessFactors (f);
 93 | }
 94 | 
 95 | // Desired edge length based tessellation:
 96 | // Approximate resulting edge length in pixels is "edgeLength".
 97 | // Does not take viewing FOV into account, just flat out divides factor by distance.
 98 | float4 UnityEdgeLengthBasedTess (float4 v0, float4 v1, float4 v2, float edgeLength)
 99 | {
100 |     float3 pos0 = mul(unity_ObjectToWorld,v0).xyz;
101 |     float3 pos1 = mul(unity_ObjectToWorld,v1).xyz;
102 |     float3 pos2 = mul(unity_ObjectToWorld,v2).xyz;
103 |     float4 tess;
104 |     tess.x = UnityCalcEdgeTessFactor (pos1, pos2, edgeLength);
105 |     tess.y = UnityCalcEdgeTessFactor (pos2, pos0, edgeLength);
106 |     tess.z = UnityCalcEdgeTessFactor (pos0, pos1, edgeLength);
107 |     tess.w = (tess.x + tess.y + tess.z) / 3.0f;
108 |     return tess;
109 | }
110 | 
111 | 
112 | // Same as UnityEdgeLengthBasedTess, but also does patch frustum culling:
113 | // patches outside of camera's view are culled before GPU tessellation. Saves some wasted work.
114 | float4 UnityEdgeLengthBasedTessCull (float4 v0, float4 v1, float4 v2, float edgeLength, float maxDisplacement)
115 | {
116 |     float3 pos0 = mul(unity_ObjectToWorld,v0).xyz;
117 |     float3 pos1 = mul(unity_ObjectToWorld,v1).xyz;
118 |     float3 pos2 = mul(unity_ObjectToWorld,v2).xyz;
119 |     float4 tess;
120 | 
121 |     if (UnityWorldViewFrustumCull(pos0, pos1, pos2, maxDisplacement))
122 |     {
123 |         tess = 0.0f;
124 |     }
125 |     else
126 |     {
127 |         tess.x = UnityCalcEdgeTessFactor (pos1, pos2, edgeLength);
128 |         tess.y = UnityCalcEdgeTessFactor (pos2, pos0, edgeLength);
129 |         tess.z = UnityCalcEdgeTessFactor (pos0, pos1, edgeLength);
130 |         tess.w = (tess.x + tess.y + tess.z) / 3.0f;
131 |     }
132 |     return tess;
133 | }
134 | 
135 | 
136 | 
137 | #endif // TESSELLATION_CGINC_INCLUDED
138 | 
139 | 140 | 141 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/CGIncludes/UnityDeferredLibrary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  6 | #ifndef UNITY_DEFERRED_LIBRARY_INCLUDED
  7 | #define UNITY_DEFERRED_LIBRARY_INCLUDED
  8 | 
  9 | // Deferred lighting / shading helpers
 10 | 
 11 | 
 12 | // --------------------------------------------------------
 13 | // Vertex shader
 14 | 
 15 | struct unity_v2f_deferred {
 16 |     float4 pos : SV_POSITION;
 17 |     float4 uv : TEXCOORD0;
 18 |     float3 ray : TEXCOORD1;
 19 | };
 20 | 
 21 | float _LightAsQuad;
 22 | 
 23 | unity_v2f_deferred vert_deferred (float4 vertex : POSITION, float3 normal : NORMAL)
 24 | {
 25 |     unity_v2f_deferred o;
 26 |     o.pos = UnityObjectToClipPos(vertex);
 27 |     o.uv = ComputeScreenPos(o.pos);
 28 |     o.ray = UnityObjectToViewPos(vertex) * float3(-1,-1,1);
 29 | 
 30 |     // normal contains a ray pointing from the camera to one of near plane's
 31 |     // corners in camera space when we are drawing a full screen quad.
 32 |     // Otherwise, when rendering 3D shapes, use the ray calculated here.
 33 |     o.ray = lerp(o.ray, normal, _LightAsQuad);
 34 | 
 35 |     return o;
 36 | }
 37 | 
 38 | 
 39 | // --------------------------------------------------------
 40 | // Shared uniforms
 41 |     
 42 |     
 43 | UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
 44 | 
 45 | float4 _LightDir;
 46 | float4 _LightPos;
 47 | float4 _LightColor;
 48 | float4 unity_LightmapFade;
 49 | float4x4 unity_WorldToLight;
 50 | sampler2D_float _LightTextureB0;
 51 |  
 52 | #if defined (POINT_COOKIE)
 53 | samplerCUBE_float _LightTexture0;
 54 | #else
 55 | sampler2D_float _LightTexture0;
 56 | #endif
 57 | 
 58 | #if defined (SHADOWS_SCREEN)
 59 | sampler2D _ShadowMapTexture;
 60 | #endif
 61 | 
 62 | #if defined (SHADOWS_SHADOWMASK)
 63 | sampler2D _CameraGBufferTexture4;
 64 | #endif
 65 | 
 66 | // --------------------------------------------------------
 67 | // Shadow/fade helpers
 68 | 
 69 | // Receiver plane depth bias create artifacts when depth is retrieved from
 70 | // the depth buffer. see UnityGetReceiverPlaneDepthBias in UnityShadowLibrary.cginc
 71 | #ifdef UNITY_USE_RECEIVER_PLANE_BIAS
 72 |     #undef UNITY_USE_RECEIVER_PLANE_BIAS
 73 | #endif
 74 | 
 75 | #include "UnityShadowLibrary.cginc"
 76 | 
 77 | 
 78 | //Note :
 79 | // SHADOWS_SHADOWMASK + LIGHTMAP_SHADOW_MIXING -> ShadowMask mode
 80 | // SHADOWS_SHADOWMASK only -> Distance shadowmask mode
 81 | 
 82 | // --------------------------------------------------------
 83 | half UnityDeferredSampleShadowMask(float2 uv)
 84 | {
 85 |     half shadowMaskAttenuation = 1.0f;
 86 | 
 87 |     #if defined (SHADOWS_SHADOWMASK)
 88 |         half4 shadowMask = tex2D(_CameraGBufferTexture4, uv);
 89 |         shadowMaskAttenuation = saturate(dot(shadowMask, unity_OcclusionMaskSelector));
 90 |     #endif
 91 | 
 92 |     return shadowMaskAttenuation;
 93 | }
 94 | 
 95 | // --------------------------------------------------------
 96 | half UnityDeferredSampleRealtimeShadow(half fade, float3 vec, float2 uv)
 97 | {
 98 |     half shadowAttenuation = 1.0f;
 99 | 
100 |     #if defined (DIRECTIONAL) || defined (DIRECTIONAL_COOKIE)
101 |         #if defined(SHADOWS_SCREEN)
102 |             shadowAttenuation = tex2D(_ShadowMapTexture, uv).r;
103 |         #endif
104 |     #endif
105 | 
106 |     #if defined(UNITY_FAST_COHERENT_DYNAMIC_BRANCHING) && defined(SHADOWS_SOFT) && !defined(LIGHTMAP_SHADOW_MIXING)
107 |     //avoid expensive shadows fetches in the distance where coherency will be good
108 |     UNITY_BRANCH
109 |     if (fade < (1.0f - 1e-2f))
110 |     {
111 |     #endif
112 | 
113 |         #if defined(SPOT)
114 |             #if defined(SHADOWS_DEPTH)
115 |                 float4 shadowCoord = mul(unity_WorldToShadow[0], float4(vec, 1));
116 |                 shadowAttenuation = UnitySampleShadowmap(shadowCoord);
117 |             #endif
118 |         #endif
119 | 
120 |         #if defined (POINT) || defined (POINT_COOKIE)
121 |             #if defined(SHADOWS_CUBE)
122 |                 shadowAttenuation = UnitySampleShadowmap(vec);
123 |             #endif
124 |         #endif
125 | 
126 |     #if defined(UNITY_FAST_COHERENT_DYNAMIC_BRANCHING) && defined(SHADOWS_SOFT) && !defined(LIGHTMAP_SHADOW_MIXING)
127 |     }
128 |     #endif
129 | 
130 |     return shadowAttenuation;
131 | }
132 | 
133 | // --------------------------------------------------------
134 | half UnityDeferredComputeShadow(float3 vec, float fadeDist, float2 uv)
135 | {
136 | 
137 |     half fade                      = UnityComputeShadowFade(fadeDist);
138 |     half shadowMaskAttenuation     = UnityDeferredSampleShadowMask(uv);
139 |     half realtimeShadowAttenuation = UnityDeferredSampleRealtimeShadow(fade, vec, uv);
140 | 
141 |     return UnityMixRealtimeAndBakedShadows(realtimeShadowAttenuation, shadowMaskAttenuation, fade);
142 | }
143 | 
144 | // --------------------------------------------------------
145 | // Common lighting data calculation (direction, attenuation, ...)
146 | void UnityDeferredCalculateLightParams (
147 |     unity_v2f_deferred i,
148 |     out float3 outWorldPos,
149 |     out float2 outUV,
150 |     out half3 outLightDir,
151 |     out float outAtten,
152 |     out float outFadeDist)
153 | {
154 |     i.ray = i.ray * (_ProjectionParams.z / i.ray.z);
155 |     float2 uv = i.uv.xy / i.uv.w;
156 | 
157 |     // read depth and reconstruct world position
158 |     float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, uv);
159 |     depth = Linear01Depth (depth);
160 |     float4 vpos = float4(i.ray * depth,1);
161 |     float3 wpos = mul (unity_CameraToWorld, vpos).xyz;
162 | 
163 |     float fadeDist = UnityComputeShadowFadeDistance(wpos, vpos.z);
164 | 
165 |     // spot light case
166 |     #if defined (SPOT)
167 |         float3 tolight = _LightPos.xyz - wpos;
168 |         half3 lightDir = normalize (tolight);
169 | 
170 |         float4 uvCookie = mul (unity_WorldToLight, float4(wpos,1));
171 |         // negative bias because http://aras-p.info/blog/2010/01/07/screenspace-vs-mip-mapping/
172 |         float atten = tex2Dbias (_LightTexture0, float4(uvCookie.xy / uvCookie.w, 0, -8)).w;
173 |         atten *= uvCookie.w < 0;
174 |         float att = dot(tolight, tolight) * _LightPos.w;
175 |         atten *= tex2D (_LightTextureB0, att.rr).r;
176 | 
177 |         atten *= UnityDeferredComputeShadow (wpos, fadeDist, uv);
178 | 
179 |     // directional light case
180 |     #elif defined (DIRECTIONAL) || defined (DIRECTIONAL_COOKIE)
181 |         half3 lightDir = -_LightDir.xyz;
182 |         float atten = 1.0;
183 | 
184 |         atten *= UnityDeferredComputeShadow (wpos, fadeDist, uv);
185 | 
186 |         #if defined (DIRECTIONAL_COOKIE)
187 |         atten *= tex2Dbias (_LightTexture0, float4(mul(unity_WorldToLight, half4(wpos,1)).xy, 0, -8)).w;
188 |         #endif //DIRECTIONAL_COOKIE
189 | 
190 |     // point light case
191 |     #elif defined (POINT) || defined (POINT_COOKIE)
192 |         float3 tolight = wpos - _LightPos.xyz;
193 |         half3 lightDir = -normalize (tolight);
194 | 
195 |         float att = dot(tolight, tolight) * _LightPos.w;
196 |         float atten = tex2D (_LightTextureB0, att.rr).r;
197 | 
198 |         atten *= UnityDeferredComputeShadow (tolight, fadeDist, uv);
199 | 
200 |         #if defined (POINT_COOKIE)
201 |         atten *= texCUBEbias(_LightTexture0, float4(mul(unity_WorldToLight, half4(wpos,1)).xyz, -8)).w;
202 |         #endif //POINT_COOKIE
203 |     #else
204 |         half3 lightDir = 0;
205 |         float atten = 0;
206 |     #endif
207 | 
208 |     outWorldPos = wpos;
209 |     outUV = uv;
210 |     outLightDir = lightDir;
211 |     outAtten = atten;
212 |     outFadeDist = fadeDist;
213 | }
214 | 
215 | #endif // UNITY_DEFERRED_LIBRARY_INCLUDED
216 | 
217 | 
218 | 219 | 220 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/CGIncludes/UnityDeprecated.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  6 | 
  7 | //-----------------------------------------------------------------------------
  8 | // NOTICE:
  9 | // All functions in this file are deprecated and should not be use, they will be remove in a later version.
 10 | // They are let here for backward compatibility.
 11 | // This file gather several function related to different part of shader code like BRDF or image based lighting
 12 | // to avoid to create multiple deprecated file, this file include deprecated function based on a define
 13 | // to when including this file, it is expected that the caller define which deprecated function group he want to enable
 14 | // Example, following code will include all deprecated BRDF functions:
 15 | // #define INCLUDE_UNITY_STANDARD_BRDF_DEPRECATED
 16 | // #include "UnityDeprecated.cginc"
 17 | // #undef INCLUDE_UNITY_STANDARD_BRDF_DEPRECATED
 18 | //-----------------------------------------------------------------------------
 19 | 
 20 | #ifdef INCLUDE_UNITY_STANDARD_BRDF_DEPRECATED
 21 | 
 22 | inline half3 LazarovFresnelTerm (half3 F0, half roughness, half cosA)
 23 | {
 24 |     half t = Pow5 (1 - cosA);   // ala Schlick interpoliation
 25 |     t /= 4 - 3 * roughness;
 26 |     return F0 + (1-F0) * t;
 27 | }
 28 | inline half3 SebLagardeFresnelTerm (half3 F0, half roughness, half cosA)
 29 | {
 30 |     half t = Pow5 (1 - cosA);   // ala Schlick interpoliation
 31 |     return F0 + (max (F0, roughness) - F0) * t;
 32 | }
 33 | 
 34 | // Cook-Torrance visibility term, doesn't take roughness into account
 35 | inline half CookTorranceVisibilityTerm (half NdotL, half NdotV,  half NdotH, half VdotH)
 36 | {
 37 |     VdotH += 1e-5f;
 38 |     half G = min (1.0, min (
 39 |         (2.0 * NdotH * NdotV) / VdotH,
 40 |         (2.0 * NdotH * NdotL) / VdotH));
 41 |     return G / (NdotL * NdotV + 1e-4f);
 42 | }
 43 | 
 44 | // Kelemen-Szirmay-Kalos is an approximation to Cook-Torrance visibility term
 45 | // http://sirkan.iit.bme.hu/~szirmay/scook.pdf
 46 | inline half KelemenVisibilityTerm (half LdotH)
 47 | {
 48 |     return 1.0 / (LdotH * LdotH);
 49 | }
 50 | 
 51 | // Modified Kelemen-Szirmay-Kalos which takes roughness into account, based on: http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/
 52 | inline half ModifiedKelemenVisibilityTerm (half LdotH, half perceptualRoughness)
 53 | {
 54 |     half c = 0.797884560802865h; // c = sqrt(2 / Pi)
 55 |     half k = PerceptualRoughnessToRoughness(perceptualRoughness) * c;
 56 |     half gH = LdotH * (1-k) + k;
 57 |     return 1.0 / (gH * gH);
 58 | }
 59 | 
 60 | // Smith-Schlick derived for GGX
 61 | inline half SmithGGXVisibilityTerm (half NdotL, half NdotV, half perceptualRoughness)
 62 | {
 63 |     half k = (PerceptualRoughnessToRoughness(perceptualRoughness)) / 2; // derived by B. Karis, http://graphicrants.blogspot.se/2013/08/specular-brdf-reference.html
 64 |     return SmithVisibilityTerm (NdotL, NdotV, k);
 65 | }
 66 | 
 67 | inline half ImplicitVisibilityTerm ()
 68 | {
 69 |     return 1;
 70 | }
 71 | 
 72 | // BlinnPhong normalized as reflection density­sity function (RDF)
 73 | // ready for use directly as specular: spec=D
 74 | // http://www.thetenthplanet.de/archives/255
 75 | inline half RDFBlinnPhongNormalizedTerm (half NdotH, half n)
 76 | {
 77 |     half normTerm = (n + 2.0) / (8.0 * UNITY_PI);
 78 |     half specTerm = pow (NdotH, n);
 79 |     return specTerm * normTerm;
 80 | }
 81 | 
 82 | // Decodes HDR textures
 83 | // sm 2.0 is no longer supported
 84 | inline half3 DecodeHDR_NoLinearSupportInSM2 (half4 data, half4 decodeInstructions)
 85 | {
 86 |     // If Linear mode is not supported we can skip exponent part
 87 |     // In Standard shader SM2.0 and SM3.0 paths are always using different shader variations
 88 |     // SM2.0: hardware does not support Linear, we can skip exponent part
 89 | #if defined(UNITY_COLORSPACE_GAMMA) && (SHADER_TARGET < 30)
 90 |     return (data.a * decodeInstructions.x) * data.rgb;
 91 | #else
 92 |     return DecodeHDR(data, decodeInstructions);
 93 | #endif
 94 | }
 95 | 
 96 | inline half DotClamped (half3 a, half3 b)
 97 | {
 98 |     #if (SHADER_TARGET < 30)
 99 |         return saturate(dot(a, b));
100 |     #else
101 |         return max(0.0h, dot(a, b));
102 |     #endif
103 | }
104 | 
105 | inline half LambertTerm (half3 normal, half3 lightDir)
106 | {
107 |     return DotClamped (normal, lightDir);
108 | }
109 | 
110 | inline half BlinnTerm (half3 normal, half3 halfDir)
111 | {
112 |     return DotClamped (normal, halfDir);
113 | }
114 | 
115 | half RoughnessToSpecPower (half roughness)
116 | {
117 |     return PerceptualRoughnessToSpecPower (roughness);
118 | }
119 | 
120 | //-------------------------------------------------------------------------------------
121 | // Legacy, to keep backwards compatibility for (pre Unity 5.3) custom user shaders:
122 | #ifdef UNITY_COLORSPACE_GAMMA
123 | #   define unity_LightGammaCorrectionConsts_PIDiv4 ((UNITY_PI/4)*(UNITY_PI/4))
124 | #   define unity_LightGammaCorrectionConsts_HalfDivPI ((.5h/UNITY_PI)*(.5h/UNITY_PI))
125 | #   define unity_LightGammaCorrectionConsts_8 (8*8)
126 | #   define unity_LightGammaCorrectionConsts_SqrtHalfPI (2/UNITY_PI)
127 | #else
128 | #   define unity_LightGammaCorrectionConsts_PIDiv4 (UNITY_PI/4)
129 | #   define unity_LightGammaCorrectionConsts_HalfDivPI (.5h/UNITY_PI)
130 | #   define unity_LightGammaCorrectionConsts_8 (8)
131 | #   define unity_LightGammaCorrectionConsts_SqrtHalfPI (0.79788)
132 | #endif
133 | 
134 | #endif // INCLUDE_UNITY_STANDARD_BRDF_DEPRECATED
135 | 
136 | #ifdef INCLUDE_UNITY_IMAGE_BASED_LIGHTING_DEPRECATED
137 | 
138 | // Old Unity_GlossyEnvironment signature. Kept only for backward compatibility and will be removed soon
139 | half3 Unity_GlossyEnvironment (UNITY_ARGS_TEXCUBE(tex), half4 hdr, half3 worldNormal, half perceptualRoughness)
140 | {
141 |     Unity_GlossyEnvironmentData g;
142 |     g.roughness /* perceptualRoughness */ = perceptualRoughness;
143 |     g.reflUVW   = worldNormal;
144 | 
145 |     return Unity_GlossyEnvironment (UNITY_PASS_TEXCUBE(tex), hdr, g);
146 | }
147 | 
148 | #endif // INCLUDE_UNITY_IMAGE_BASED_LIGHTING_DEPRECATED
149 | 
150 | 151 | 152 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/CGIncludes/UnityGBuffer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 6 | 
 7 | #ifndef UNITY_GBUFFER_INCLUDED
 8 | #define UNITY_GBUFFER_INCLUDED
 9 | 
10 | //-----------------------------------------------------------------------------
11 | // Main structure that store the data from the standard shader (i.e user input)
12 | struct UnityStandardData 
13 | {
14 |     half3   diffuseColor;
15 |     half    occlusion;
16 | 
17 |     half3   specularColor;
18 |     half    smoothness;
19 | 
20 |     float3  normalWorld;        // normal in world space
21 | };
22 | 
23 | //-----------------------------------------------------------------------------
24 | // This will encode UnityStandardData into GBuffer
25 | void UnityStandardDataToGbuffer(UnityStandardData data, out half4 outGBuffer0, out half4 outGBuffer1, out half4 outGBuffer2)
26 | {
27 |     // RT0: diffuse color (rgb), occlusion (a) - sRGB rendertarget
28 |     outGBuffer0 = half4(data.diffuseColor, data.occlusion);
29 | 
30 |     // RT1: spec color (rgb), smoothness (a) - sRGB rendertarget
31 |     outGBuffer1 = half4(data.specularColor, data.smoothness);
32 | 
33 |     // RT2: normal (rgb), --unused, very low precision-- (a)
34 |     outGBuffer2 = half4(data.normalWorld * 0.5f + 0.5f, 1.0f);
35 | }
36 | //-----------------------------------------------------------------------------
37 | // This decode the Gbuffer in a UnityStandardData struct
38 | UnityStandardData UnityStandardDataFromGbuffer(half4 inGBuffer0, half4 inGBuffer1, half4 inGBuffer2)
39 | {
40 |     UnityStandardData data;
41 | 
42 |     data.diffuseColor   = inGBuffer0.rgb;
43 |     data.occlusion      = inGBuffer0.a;
44 | 
45 |     data.specularColor  = inGBuffer1.rgb;
46 |     data.smoothness     = inGBuffer1.a;
47 | 
48 |     data.normalWorld    = normalize((float3)inGBuffer2.rgb * 2 - 1);
49 | 
50 |     return data;
51 | }
52 | //-----------------------------------------------------------------------------
53 | // In some cases like for terrain, the user want to apply a specific weight to the attribute
54 | // The function below is use for this
55 | void UnityStandardDataApplyWeightToGbuffer(inout half4 inOutGBuffer0, inout half4 inOutGBuffer1, inout half4 inOutGBuffer2, half alpha)
56 | {
57 |     // With UnityStandardData current encoding, We can apply the weigth directly on the gbuffer
58 |     inOutGBuffer0.rgb   *= alpha; // diffuseColor
59 |     inOutGBuffer1       *= alpha; // SpecularColor and Smoothness
60 |     inOutGBuffer2.rgb   *= alpha; // Normal
61 | }
62 | //-----------------------------------------------------------------------------
63 | 
64 | #endif // #ifndef UNITY_GBUFFER_INCLUDED
65 | 
66 | 67 | 68 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/CGIncludes/UnityLightingCommon.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
 4 |     // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 5 | 
 6 |     #ifndef UNITY_LIGHTING_COMMON_INCLUDED
 7 |     #define UNITY_LIGHTING_COMMON_INCLUDED
 8 |     
 9 |     fixed4 _LightColor0;
10 |     fixed4 _SpecColor;
11 |     
12 |     struct UnityLight
13 |     {
14 |         half3 color;
15 |         half3 dir;
16 |         half  ndotl; // Deprecated: Ndotl is now calculated on the fly and is no longer stored. Do not used it.
17 |     };
18 |     
19 |     struct UnityIndirect
20 |     {
21 |         half3 diffuse;
22 |         half3 specular;
23 |     };
24 |     
25 |     struct UnityGI
26 |     {
27 |         UnityLight light;
28 |         UnityIndirect indirect;
29 |     };
30 |     
31 |     struct UnityGIInput
32 |     {
33 |         UnityLight light; // pixel light, sent from the engine
34 |     
35 |         float3 worldPos;
36 |         half3 worldViewDir;
37 |         half atten;
38 |         half3 ambient;
39 |     
40 |         // interpolated lightmap UVs are passed as full float precision data to fragment shaders
41 |         // so lightmapUV (which is used as a tmp inside of lightmap fragment shaders) should
42 |         // also be full float precision to avoid data loss before sampling a texture.
43 |         float4 lightmapUV; // .xy = static lightmap UV, .zw = dynamic lightmap UV
44 |     
45 |         #if defined(UNITY_SPECCUBE_BLENDING) || defined(UNITY_SPECCUBE_BOX_PROJECTION) || defined(UNITY_ENABLE_REFLECTION_BUFFERS)
46 |         float4 boxMin[2];
47 |         #endif
48 |         #ifdef UNITY_SPECCUBE_BOX_PROJECTION
49 |         float4 boxMax[2];
50 |         float4 probePosition[2];
51 |         #endif
52 |         // HDR cubemap properties, use to decompress HDR texture
53 |         float4 probeHDR[2];
54 |     };
55 |     
56 |     #endif
57 |     
58 | 
59 | 60 | 61 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/CGIncludes/UnityShaderUtilities.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 |     // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 6 | 
 7 |     #ifndef UNITY_SHADER_UTILITIES_INCLUDED
 8 |     #define UNITY_SHADER_UTILITIES_INCLUDED
 9 |     
10 |     // This file is always included in all unity shaders.
11 |     
12 |     #include "UnityShaderVariables.cginc"
13 |     
14 |     float3 ODSOffset(float3 worldPos, float ipd)
15 |     {
16 |         //based on google's omni-directional stereo rendering thread
17 |         const float EPSILON = 2.4414e-4;
18 |         float3 worldUp = float3(0.0, 1.0, 0.0);
19 |         float3 camOffset = worldPos.xyz - _WorldSpaceCameraPos.xyz;
20 |         float4 direction = float4(camOffset.xyz, dot(camOffset.xyz, camOffset.xyz));
21 |         direction.w = max(EPSILON, direction.w);
22 |         direction *= rsqrt(direction.w);
23 |     
24 |         float3 tangent = cross(direction.xyz, worldUp.xyz);
25 |         if (dot(tangent, tangent) < EPSILON)
26 |             return float3(0, 0, 0);
27 |         tangent = normalize(tangent);
28 |     
29 |         float directionMinusIPD = max(EPSILON, direction.w*direction.w - ipd*ipd);
30 |         float a = ipd * ipd / direction.w;
31 |         float b = ipd / direction.w * sqrt(directionMinusIPD);
32 |         float3 offset = -a*direction + b*tangent;
33 |         return offset;
34 |     }
35 |     
36 |     inline float4 UnityObjectToClipPosODS(float3 inPos)
37 |     {
38 |         float4 clipPos;
39 |         float3 posWorld = mul(unity_ObjectToWorld, float4(inPos, 1.0)).xyz;
40 |     #if defined(STEREO_CUBEMAP_RENDER_ON)
41 |         float3 offset = ODSOffset(posWorld, unity_HalfStereoSeparation.x);
42 |         clipPos = mul(UNITY_MATRIX_VP, float4(posWorld + offset, 1.0));
43 |     #else
44 |         clipPos = mul(UNITY_MATRIX_VP, float4(posWorld, 1.0));
45 |     #endif
46 |         return clipPos;
47 |     }
48 |     
49 |     // Tranforms position from object to homogenous space
50 |     inline float4 UnityObjectToClipPos(in float3 pos)
51 |     {
52 |     #if defined(STEREO_CUBEMAP_RENDER_ON)
53 |         return UnityObjectToClipPosODS(pos);
54 |     #else
55 |         // More efficient than computing M*VP matrix product
56 |         return mul(UNITY_MATRIX_VP, mul(unity_ObjectToWorld, float4(pos, 1.0)));
57 |     #endif
58 |     }
59 |     inline float4 UnityObjectToClipPos(float4 pos) // overload for float4; avoids "implicit truncation" warning for existing shaders
60 |     {
61 |         return UnityObjectToClipPos(pos.xyz);
62 |     }
63 |     
64 |     #endif
65 | 
66 | 67 | 68 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/CGIncludes/UnitySprites.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  6 | 
  7 | #ifndef UNITY_SPRITES_INCLUDED
  8 | #define UNITY_SPRITES_INCLUDED
  9 | 
 10 | #include "UnityCG.cginc"
 11 | 
 12 | #ifdef UNITY_INSTANCING_ENABLED
 13 | 
 14 |     UNITY_INSTANCING_BUFFER_START(PerDrawSprite)
 15 |         // SpriteRenderer.Color while Non-Batched/Instanced.
 16 |         UNITY_DEFINE_INSTANCED_PROP(fixed4, unity_SpriteRendererColorArray)
 17 |         // this could be smaller but that's how bit each entry is regardless of type
 18 |         UNITY_DEFINE_INSTANCED_PROP(fixed2, unity_SpriteFlipArray)
 19 |     UNITY_INSTANCING_BUFFER_END(PerDrawSprite)
 20 | 
 21 |     #define _RendererColor  UNITY_ACCESS_INSTANCED_PROP(PerDrawSprite, unity_SpriteRendererColorArray)
 22 |     #define _Flip           UNITY_ACCESS_INSTANCED_PROP(PerDrawSprite, unity_SpriteFlipArray)
 23 | 
 24 | #endif // instancing
 25 | 
 26 | CBUFFER_START(UnityPerDrawSprite)
 27 | #ifndef UNITY_INSTANCING_ENABLED
 28 |     fixed4 _RendererColor;
 29 |     fixed2 _Flip;
 30 | #endif
 31 |     float _EnableExternalAlpha;
 32 | CBUFFER_END
 33 | 
 34 | // Material Color.
 35 | fixed4 _Color;
 36 | 
 37 | struct appdata_t
 38 | {
 39 |     float4 vertex   : POSITION;
 40 |     float4 color    : COLOR;
 41 |     float2 texcoord : TEXCOORD0;
 42 |     UNITY_VERTEX_INPUT_INSTANCE_ID
 43 | };
 44 | 
 45 | struct v2f
 46 | {
 47 |     float4 vertex   : SV_POSITION;
 48 |     fixed4 color    : COLOR;
 49 |     float2 texcoord : TEXCOORD0;
 50 |     UNITY_VERTEX_OUTPUT_STEREO
 51 | };
 52 | 
 53 | inline float4 UnityFlipSprite(in float3 pos, in fixed2 flip)
 54 | {
 55 |     return float4(pos.xy * flip, pos.z, 1.0);
 56 | }
 57 | 
 58 | v2f SpriteVert(appdata_t IN)
 59 | {
 60 |     v2f OUT;
 61 | 
 62 |     UNITY_SETUP_INSTANCE_ID (IN);
 63 |     UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
 64 | 
 65 |     OUT.vertex = UnityFlipSprite(IN.vertex, _Flip);
 66 |     OUT.vertex = UnityObjectToClipPos(OUT.vertex);
 67 |     OUT.texcoord = IN.texcoord;
 68 |     OUT.color = IN.color * _Color * _RendererColor;
 69 | 
 70 |     #ifdef PIXELSNAP_ON
 71 |     OUT.vertex = UnityPixelSnap (OUT.vertex);
 72 |     #endif
 73 | 
 74 |     return OUT;
 75 | }
 76 | 
 77 | sampler2D _MainTex;
 78 | sampler2D _AlphaTex;
 79 | 
 80 | fixed4 SampleSpriteTexture(float2 uv)
 81 | {
 82 |     fixed4 color = tex2D (_MainTex, uv);
 83 | 
 84 | #if ETC1_EXTERNAL_ALPHA
 85 |     fixed4 alpha = tex2D (_AlphaTex, uv);
 86 |     color.a = lerp (color.a, alpha.r, _EnableExternalAlpha);
 87 | #endif
 88 | 
 89 |     return color;
 90 | }
 91 | 
 92 | fixed4 SpriteFrag(v2f IN) : SV_Target
 93 | {
 94 |     fixed4 c = SampleSpriteTexture (IN.texcoord) * IN.color;
 95 |     c.rgb *= c.a;
 96 |     return c;
 97 | }
 98 | 
 99 | #endif // UNITY_SPRITES_INCLUDED
100 | 
101 | 102 | 103 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/CGIncludes/UnityStandardConfig.html: -------------------------------------------------------------------------------- 1 | 2 |
  3 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt
  4 | #ifndef UNITY_STANDARD_CONFIG_INCLUDED
  5 | #define UNITY_STANDARD_CONFIG_INCLUDED
  6 | 
  7 | // Define Specular cubemap constants
  8 | #ifndef UNITY_SPECCUBE_LOD_EXPONENT
  9 | #define UNITY_SPECCUBE_LOD_EXPONENT (1.5)
 10 | #endif
 11 | #ifndef UNITY_SPECCUBE_LOD_STEPS
 12 | #define UNITY_SPECCUBE_LOD_STEPS (6)
 13 | #endif
 14 | 
 15 | // Energy conservation for Specular workflow is Monochrome. For instance: Red metal will make diffuse Black not Cyan
 16 | #ifndef UNITY_CONSERVE_ENERGY
 17 | #define UNITY_CONSERVE_ENERGY 1
 18 | #endif
 19 | #ifndef UNITY_CONSERVE_ENERGY_MONOCHROME
 20 | #define UNITY_CONSERVE_ENERGY_MONOCHROME 1
 21 | #endif
 22 | 
 23 | // "platform caps" defines: they are controlled from TierSettings (Editor will determine values and pass them to compiler)
 24 | // UNITY_SPECCUBE_BOX_PROJECTION:                   TierSettings.reflectionProbeBoxProjection
 25 | // UNITY_SPECCUBE_BLENDING:                         TierSettings.reflectionProbeBlending
 26 | // UNITY_ENABLE_DETAIL_NORMALMAP:                   TierSettings.detailNormalMap
 27 | // UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS:  TierSettings.semitransparentShadows
 28 | 
 29 | // disregarding what is set in TierSettings, some features have hardware restrictions
 30 | // so we still add safety net, otherwise we might end up with shaders failing to compile
 31 | 
 32 | #if defined(SHADER_TARGET_SURFACE_ANALYSIS)
 33 |     // For surface shader code analysis pass, disable some features that don't affect inputs/outputs
 34 |     #undef UNITY_SPECCUBE_BOX_PROJECTION
 35 |     #undef UNITY_SPECCUBE_BLENDING
 36 |     #undef UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
 37 | #elif SHADER_TARGET < 30
 38 |     #undef UNITY_SPECCUBE_BOX_PROJECTION
 39 |     #undef UNITY_SPECCUBE_BLENDING
 40 |     #undef UNITY_ENABLE_DETAIL_NORMALMAP
 41 |     #ifdef _PARALLAXMAP
 42 |         #undef _PARALLAXMAP
 43 |     #endif
 44 | #endif
 45 | #if (SHADER_TARGET < 30) || defined(SHADER_API_GLES)
 46 |     #undef UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
 47 | #endif
 48 |         
 49 | #ifndef UNITY_SAMPLE_FULL_SH_PER_PIXEL
 50 |     // Lightmap UVs and ambient color from SHL2 are shared in the vertex to pixel interpolators. Do full SH evaluation in the pixel shader when static lightmap and LIGHTPROBE_SH is enabled.
 51 |     #define UNITY_SAMPLE_FULL_SH_PER_PIXEL (LIGHTMAP_ON && LIGHTPROBE_SH)
 52 | 
 53 |     // Shaders might fail to compile due to shader instruction count limit. Leave only baked lightmaps on SM20 hardware.
 54 |     #if UNITY_SAMPLE_FULL_SH_PER_PIXEL && (SHADER_TARGET < 25)
 55 |         #undef UNITY_SAMPLE_FULL_SH_PER_PIXEL
 56 |         #undef LIGHTPROBE_SH
 57 |     #endif
 58 | #endif
 59 |         
 60 | #ifndef UNITY_BRDF_GGX
 61 | #define UNITY_BRDF_GGX 1
 62 | #endif
 63 | 
 64 | // Orthnormalize Tangent Space basis per-pixel
 65 | // Necessary to support high-quality normal-maps. Compatible with Maya and Marmoset.
 66 | // However xNormal expects oldschool non-orthnormalized basis - essentially preventing good looking normal-maps :(
 67 | // Due to the fact that xNormal is probably _the most used tool to bake out normal-maps today_ we have to stick to old ways for now.
 68 | //
 69 | // Disabled by default, until xNormal has an option to bake proper normal-maps.
 70 | #ifndef UNITY_TANGENT_ORTHONORMALIZE
 71 | #define UNITY_TANGENT_ORTHONORMALIZE 0
 72 | #endif
 73 | 
 74 | 
 75 | // Some extra optimizations
 76 | 
 77 | // Simplified Standard Shader is off by default and should not be used for Legacy Shaders
 78 | #ifndef UNITY_STANDARD_SIMPLE
 79 |     #define UNITY_STANDARD_SIMPLE 0
 80 | #endif
 81 | 
 82 | // Setup a new define with meaningful name to know if we require world pos in fragment shader
 83 | #if UNITY_STANDARD_SIMPLE
 84 |     #define UNITY_REQUIRE_FRAG_WORLDPOS 0
 85 | #else
 86 |     #define UNITY_REQUIRE_FRAG_WORLDPOS 1
 87 | #endif
 88 | 
 89 | // Should we pack worldPos along tangent (saving an interpolator)
 90 | // We want to skip this on mobile platforms, because worldpos gets packed into mediump
 91 | #if UNITY_REQUIRE_FRAG_WORLDPOS && !defined(_PARALLAXMAP) && !defined(SHADER_API_MOBILE)
 92 |     #define UNITY_PACK_WORLDPOS_WITH_TANGENT 1
 93 | #else
 94 |     #define UNITY_PACK_WORLDPOS_WITH_TANGENT 0
 95 | #endif
 96 | 
 97 | #endif // UNITY_STANDARD_CONFIG_INCLUDED
 98 | 
99 | 100 | 101 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/CGIncludes/UnityStandardCoreForward.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 6 | 
 7 | #ifndef UNITY_STANDARD_CORE_FORWARD_INCLUDED
 8 | #define UNITY_STANDARD_CORE_FORWARD_INCLUDED
 9 | 
10 | #if defined(UNITY_NO_FULL_STANDARD_SHADER)
11 | #   define UNITY_STANDARD_SIMPLE 1
12 | #endif
13 | 
14 | #include "UnityStandardConfig.cginc"
15 | 
16 | #if UNITY_STANDARD_SIMPLE
17 |     #include "UnityStandardCoreForwardSimple.cginc"
18 |     VertexOutputBaseSimple vertBase (VertexInput v) { return vertForwardBaseSimple(v); }
19 |     VertexOutputForwardAddSimple vertAdd (VertexInput v) { return vertForwardAddSimple(v); }
20 |     half4 fragBase (VertexOutputBaseSimple i) : SV_Target { return fragForwardBaseSimpleInternal(i); }
21 |     half4 fragAdd (VertexOutputForwardAddSimple i) : SV_Target { return fragForwardAddSimpleInternal(i); }
22 | #else
23 |     #include "UnityStandardCore.cginc"
24 |     VertexOutputForwardBase vertBase (VertexInput v) { return vertForwardBase(v); }
25 |     VertexOutputForwardAdd vertAdd (VertexInput v) { return vertForwardAdd(v); }
26 |     half4 fragBase (VertexOutputForwardBase i) : SV_Target { return fragForwardBaseInternal(i); }
27 |     half4 fragAdd (VertexOutputForwardAdd i) : SV_Target { return fragForwardAddInternal(i); }
28 | #endif
29 | 
30 | #endif // UNITY_STANDARD_CORE_FORWARD_INCLUDED
31 | 
32 | 33 | 34 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/CGIncludes/UnityStandardInput.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 |     // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  6 | 
  7 |     #ifndef UNITY_STANDARD_INPUT_INCLUDED
  8 |     #define UNITY_STANDARD_INPUT_INCLUDED
  9 |     
 10 |     #include "UnityCG.cginc"
 11 |     #include "UnityStandardConfig.cginc"
 12 |     #include "UnityPBSLighting.cginc" // TBD: remove
 13 |     #include "UnityStandardUtils.cginc"
 14 |     
 15 |     //---------------------------------------
 16 |     // Directional lightmaps & Parallax require tangent space too
 17 |     #if (_NORMALMAP || DIRLIGHTMAP_COMBINED || _PARALLAXMAP)
 18 |         #define _TANGENT_TO_WORLD 1
 19 |     #endif
 20 |     
 21 |     #if (_DETAIL_MULX2 || _DETAIL_MUL || _DETAIL_ADD || _DETAIL_LERP)
 22 |         #define _DETAIL 1
 23 |     #endif
 24 |     
 25 |     //---------------------------------------
 26 |     half4       _Color;
 27 |     half        _Cutoff;
 28 |     
 29 |     sampler2D   _MainTex;
 30 |     float4      _MainTex_ST;
 31 |     
 32 |     sampler2D   _DetailAlbedoMap;
 33 |     float4      _DetailAlbedoMap_ST;
 34 |     
 35 |     sampler2D   _BumpMap;
 36 |     half        _BumpScale;
 37 |     
 38 |     sampler2D   _DetailMask;
 39 |     sampler2D   _DetailNormalMap;
 40 |     half        _DetailNormalMapScale;
 41 |     
 42 |     sampler2D   _SpecGlossMap;
 43 |     sampler2D   _MetallicGlossMap;
 44 |     half        _Metallic;
 45 |     float       _Glossiness;
 46 |     float       _GlossMapScale;
 47 |     
 48 |     sampler2D   _OcclusionMap;
 49 |     half        _OcclusionStrength;
 50 |     
 51 |     sampler2D   _ParallaxMap;
 52 |     half        _Parallax;
 53 |     half        _UVSec;
 54 |     
 55 |     half4       _EmissionColor;
 56 |     sampler2D   _EmissionMap;
 57 |     
 58 |     //-------------------------------------------------------------------------------------
 59 |     // Input functions
 60 |     
 61 |     struct VertexInput
 62 |     {
 63 |         float4 vertex   : POSITION;
 64 |         half3 normal    : NORMAL;
 65 |         float2 uv0      : TEXCOORD0;
 66 |         float2 uv1      : TEXCOORD1;
 67 |     #if defined(DYNAMICLIGHTMAP_ON) || defined(UNITY_PASS_META)
 68 |         float2 uv2      : TEXCOORD2;
 69 |     #endif
 70 |     #ifdef _TANGENT_TO_WORLD
 71 |         half4 tangent   : TANGENT;
 72 |     #endif
 73 |         UNITY_VERTEX_INPUT_INSTANCE_ID
 74 |     };
 75 |     
 76 |     float4 TexCoords(VertexInput v)
 77 |     {
 78 |         float4 texcoord;
 79 |         texcoord.xy = TRANSFORM_TEX(v.uv0, _MainTex); // Always source from uv0
 80 |         texcoord.zw = TRANSFORM_TEX(((_UVSec == 0) ? v.uv0 : v.uv1), _DetailAlbedoMap);
 81 |         return texcoord;
 82 |     }
 83 |     
 84 |     half DetailMask(float2 uv)
 85 |     {
 86 |         return tex2D (_DetailMask, uv).a;
 87 |     }
 88 |     
 89 |     half3 Albedo(float4 texcoords)
 90 |     {
 91 |         half3 albedo = _Color.rgb * tex2D (_MainTex, texcoords.xy).rgb;
 92 |     #if _DETAIL
 93 |         #if (SHADER_TARGET < 30)
 94 |             // SM20: instruction count limitation
 95 |             // SM20: no detail mask
 96 |             half mask = 1;
 97 |         #else
 98 |             half mask = DetailMask(texcoords.xy);
 99 |         #endif
100 |         half3 detailAlbedo = tex2D (_DetailAlbedoMap, texcoords.zw).rgb;
101 |         #if _DETAIL_MULX2
102 |             albedo *= LerpWhiteTo (detailAlbedo * unity_ColorSpaceDouble.rgb, mask);
103 |         #elif _DETAIL_MUL
104 |             albedo *= LerpWhiteTo (detailAlbedo, mask);
105 |         #elif _DETAIL_ADD
106 |             albedo += detailAlbedo * mask;
107 |         #elif _DETAIL_LERP
108 |             albedo = lerp (albedo, detailAlbedo, mask);
109 |         #endif
110 |     #endif
111 |         return albedo;
112 |     }
113 |     
114 |     half Alpha(float2 uv)
115 |     {
116 |     #if defined(_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A)
117 |         return _Color.a;
118 |     #else
119 |         return tex2D(_MainTex, uv).a * _Color.a;
120 |     #endif
121 |     }
122 |     
123 |     half Occlusion(float2 uv)
124 |     {
125 |     #if (SHADER_TARGET < 30)
126 |         // SM20: instruction count limitation
127 |         // SM20: simpler occlusion
128 |         return tex2D(_OcclusionMap, uv).g;
129 |     #else
130 |         half occ = tex2D(_OcclusionMap, uv).g;
131 |         return LerpOneTo (occ, _OcclusionStrength);
132 |     #endif
133 |     }
134 |     
135 |     half4 SpecularGloss(float2 uv)
136 |     {
137 |         half4 sg;
138 |     #ifdef _SPECGLOSSMAP
139 |         #if defined(_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A)
140 |             sg.rgb = tex2D(_SpecGlossMap, uv).rgb;
141 |             sg.a = tex2D(_MainTex, uv).a;
142 |         #else
143 |             sg = tex2D(_SpecGlossMap, uv);
144 |         #endif
145 |         sg.a *= _GlossMapScale;
146 |     #else
147 |         sg.rgb = _SpecColor.rgb;
148 |         #ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
149 |             sg.a = tex2D(_MainTex, uv).a * _GlossMapScale;
150 |         #else
151 |             sg.a = _Glossiness;
152 |         #endif
153 |     #endif
154 |         return sg;
155 |     }
156 |     
157 |     half2 MetallicGloss(float2 uv)
158 |     {
159 |         half2 mg;
160 |     
161 |     #ifdef _METALLICGLOSSMAP
162 |         #ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
163 |             mg.r = tex2D(_MetallicGlossMap, uv).r;
164 |             mg.g = tex2D(_MainTex, uv).a;
165 |         #else
166 |             mg = tex2D(_MetallicGlossMap, uv).ra;
167 |         #endif
168 |         mg.g *= _GlossMapScale;
169 |     #else
170 |         mg.r = _Metallic;
171 |         #ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
172 |             mg.g = tex2D(_MainTex, uv).a * _GlossMapScale;
173 |         #else
174 |             mg.g = _Glossiness;
175 |         #endif
176 |     #endif
177 |         return mg;
178 |     }
179 |     
180 |     half2 MetallicRough(float2 uv)
181 |     {
182 |         half2 mg;
183 |     #ifdef _METALLICGLOSSMAP
184 |         mg.r = tex2D(_MetallicGlossMap, uv).r;
185 |     #else
186 |         mg.r = _Metallic;
187 |     #endif
188 |     
189 |     #ifdef _SPECGLOSSMAP
190 |         mg.g = 1.0f - tex2D(_SpecGlossMap, uv).r;
191 |     #else
192 |         mg.g = 1.0f - _Glossiness;
193 |     #endif
194 |         return mg;
195 |     }
196 |     
197 |     half3 Emission(float2 uv)
198 |     {
199 |     #ifndef _EMISSION
200 |         return 0;
201 |     #else
202 |         return tex2D(_EmissionMap, uv).rgb * _EmissionColor.rgb;
203 |     #endif
204 |     }
205 |     
206 |     #ifdef _NORMALMAP
207 |     half3 NormalInTangentSpace(float4 texcoords)
208 |     {
209 |         half3 normalTangent = UnpackScaleNormal(tex2D (_BumpMap, texcoords.xy), _BumpScale);
210 |     
211 |     #if _DETAIL && defined(UNITY_ENABLE_DETAIL_NORMALMAP)
212 |         half mask = DetailMask(texcoords.xy);
213 |         half3 detailNormalTangent = UnpackScaleNormal(tex2D (_DetailNormalMap, texcoords.zw), _DetailNormalMapScale);
214 |         #if _DETAIL_LERP
215 |             normalTangent = lerp(
216 |                 normalTangent,
217 |                 detailNormalTangent,
218 |                 mask);
219 |         #else
220 |             normalTangent = lerp(
221 |                 normalTangent,
222 |                 BlendNormals(normalTangent, detailNormalTangent),
223 |                 mask);
224 |         #endif
225 |     #endif
226 |     
227 |         return normalTangent;
228 |     }
229 |     #endif
230 |     
231 |     float4 Parallax (float4 texcoords, half3 viewDir)
232 |     {
233 |     #if !defined(_PARALLAXMAP) || (SHADER_TARGET < 30)
234 |         // Disable parallax on pre-SM3.0 shader target models
235 |         return texcoords;
236 |     #else
237 |         half h = tex2D (_ParallaxMap, texcoords.xy).g;
238 |         float2 offset = ParallaxOffset1Step (h, _Parallax, viewDir);
239 |         return float4(texcoords.xy + offset, texcoords.zw + offset);
240 |     #endif
241 |     
242 |     }
243 |     
244 |     #endif // UNITY_STANDARD_INPUT_INCLUDED
245 | 
246 | 247 | 248 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/CGIncludes/UnityStandardMeta.html: -------------------------------------------------------------------------------- 1 | 2 |
 3 |     // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 4 | 
 5 |     #ifndef UNITY_STANDARD_META_INCLUDED
 6 |     #define UNITY_STANDARD_META_INCLUDED
 7 |     
 8 |     // Functionality for Standard shader "meta" pass
 9 |     // (extracts albedo/emission for lightmapper etc.)
10 |     
11 |     #include "UnityCG.cginc"
12 |     #include "UnityStandardInput.cginc"
13 |     #include "UnityMetaPass.cginc"
14 |     #include "UnityStandardCore.cginc"
15 |     
16 |     struct v2f_meta
17 |     {
18 |         float4 pos      : SV_POSITION;
19 |         float4 uv       : TEXCOORD0;
20 |     #ifdef EDITOR_VISUALIZATION
21 |         float2 vizUV        : TEXCOORD1;
22 |         float4 lightCoord   : TEXCOORD2;
23 |     #endif
24 |     };
25 |     
26 |     v2f_meta vert_meta (VertexInput v)
27 |     {
28 |         v2f_meta o;
29 |         o.pos = UnityMetaVertexPosition(v.vertex, v.uv1.xy, v.uv2.xy, unity_LightmapST, unity_DynamicLightmapST);
30 |         o.uv = TexCoords(v);
31 |     #ifdef EDITOR_VISUALIZATION
32 |         o.vizUV = 0;
33 |         o.lightCoord = 0;
34 |         if (unity_VisualizationMode == EDITORVIZ_TEXTURE)
35 |             o.vizUV = UnityMetaVizUV(unity_EditorViz_UVIndex, v.uv0.xy, v.uv1.xy, v.uv2.xy, unity_EditorViz_Texture_ST);
36 |         else if (unity_VisualizationMode == EDITORVIZ_SHOWLIGHTMASK)
37 |         {
38 |             o.vizUV = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
39 |             o.lightCoord = mul(unity_EditorViz_WorldToLight, mul(unity_ObjectToWorld, float4(v.vertex.xyz, 1)));
40 |         }
41 |     #endif
42 |         return o;
43 |     }
44 |     
45 |     // Albedo for lightmapping should basically be diffuse color.
46 |     // But rough metals (black diffuse) still scatter quite a lot of light around, so
47 |     // we want to take some of that into account too.
48 |     half3 UnityLightmappingAlbedo (half3 diffuse, half3 specular, half smoothness)
49 |     {
50 |         half roughness = SmoothnessToRoughness(smoothness);
51 |         half3 res = diffuse;
52 |         res += specular * roughness * 0.5;
53 |         return res;
54 |     }
55 |     
56 |     float4 frag_meta (v2f_meta i) : SV_Target
57 |     {
58 |         // we're interested in diffuse & specular colors,
59 |         // and surface roughness to produce final albedo.
60 |         FragmentCommonData data = UNITY_SETUP_BRDF_INPUT (i.uv);
61 |     
62 |         UnityMetaInput o;
63 |         UNITY_INITIALIZE_OUTPUT(UnityMetaInput, o);
64 |     
65 |     #ifdef EDITOR_VISUALIZATION
66 |         o.Albedo = data.diffColor;
67 |         o.VizUV = i.vizUV;
68 |         o.LightCoord = i.lightCoord;
69 |     #else
70 |         o.Albedo = UnityLightmappingAlbedo (data.diffColor, data.specColor, data.smoothness);
71 |     #endif
72 |         o.SpecularColor = data.specColor;
73 |         o.Emission = Emission(i.uv.xy);
74 |     
75 |         return UnityMetaFragment(o);
76 |     }
77 |     
78 |     #endif // UNITY_STANDARD_META_INCLUDED
79 |     
80 | 
81 | 82 | 83 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResources/Font.html: -------------------------------------------------------------------------------- 1 | 2 |
 3 | Shader "GUI/Text Shader" {
 4 |     Properties {
 5 |         _MainTex ("Font Texture", 2D) = "white" {}
 6 |         _Color ("Text Color", Color) = (1,1,1,1)
 7 |     }
 8 | 
 9 |     SubShader {
10 | 
11 |         Tags {
12 |             "Queue"="Transparent"
13 |             "IgnoreProjector"="True"
14 |             "RenderType"="Transparent"
15 |             "PreviewType"="Plane"
16 |         }
17 |         Lighting Off Cull Off ZTest Always ZWrite Off
18 |         Blend SrcAlpha OneMinusSrcAlpha
19 | 
20 |         Pass {
21 |             CGPROGRAM
22 |             #pragma vertex vert
23 |             #pragma fragment frag
24 |             #pragma multi_compile _ UNITY_SINGLE_PASS_STEREO STEREO_INSTANCING_ON STEREO_MULTIVIEW_ON
25 |             #include "UnityCG.cginc"
26 | 
27 |             struct appdata_t {
28 |                 float4 vertex : POSITION;
29 |                 fixed4 color : COLOR;
30 |                 float2 texcoord : TEXCOORD0;
31 |                 UNITY_VERTEX_INPUT_INSTANCE_ID
32 |             };
33 | 
34 |             struct v2f {
35 |                 float4 vertex : SV_POSITION;
36 |                 fixed4 color : COLOR;
37 |                 float2 texcoord : TEXCOORD0;
38 |                 UNITY_VERTEX_OUTPUT_STEREO
39 |             };
40 | 
41 |             sampler2D _MainTex;
42 |             uniform float4 _MainTex_ST;
43 |             uniform fixed4 _Color;
44 | 
45 |             v2f vert (appdata_t v)
46 |             {
47 |                 v2f o;
48 |                 UNITY_SETUP_INSTANCE_ID(v);
49 |                 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
50 |                 o.vertex = UnityObjectToClipPos(v.vertex);
51 |                 o.color = v.color * _Color;
52 |                 o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
53 |                 return o;
54 |             }
55 | 
56 |             fixed4 frag (v2f i) : SV_Target
57 |             {
58 |                 fixed4 col = i.color;
59 |                 col.a *= tex2D(_MainTex, i.texcoord).a;
60 |                 return col;
61 |             }
62 |             ENDCG
63 |         }
64 |     }
65 | }
66 | 
67 | 68 | 69 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResources/Internal-Colored.html: -------------------------------------------------------------------------------- 1 | 2 |
 3 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 4 | 
 5 | // Simple "just colors" shader that's used for built-in debug visualizations,
 6 | // in the editor etc. Just outputs _Color * vertex color; and blend/Z/cull/bias
 7 | // controlled by material parameters.
 8 | 
 9 | Shader "Hidden/Internal-Colored"
10 | {
11 |     Properties
12 |     {
13 |         _Color ("Color", Color) = (1,1,1,1)
14 |         _SrcBlend ("SrcBlend", Int) = 5.0 // SrcAlpha
15 |         _DstBlend ("DstBlend", Int) = 10.0 // OneMinusSrcAlpha
16 |         _ZWrite ("ZWrite", Int) = 1.0 // On
17 |         _ZTest ("ZTest", Int) = 4.0 // LEqual
18 |         _Cull ("Cull", Int) = 0.0 // Off
19 |         _ZBias ("ZBias", Float) = 0.0
20 |     }
21 | 
22 |     SubShader
23 |     {
24 |         Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
25 |         Pass
26 |         {
27 |             Blend [_SrcBlend] [_DstBlend]
28 |             ZWrite [_ZWrite]
29 |             ZTest [_ZTest]
30 |             Cull [_Cull]
31 |             Offset [_ZBias], [_ZBias]
32 | 
33 |             CGPROGRAM
34 |             #pragma vertex vert
35 |             #pragma fragment frag
36 |             #pragma target 2.0
37 |             #pragma multi_compile _ UNITY_SINGLE_PASS_STEREO STEREO_INSTANCING_ON STEREO_MULTIVIEW_ON
38 |             #include "UnityCG.cginc"
39 | 
40 |             struct appdata_t {
41 |                 float4 vertex : POSITION;
42 |                 float4 color : COLOR;
43 |                 UNITY_VERTEX_INPUT_INSTANCE_ID
44 |             };
45 |             struct v2f {
46 |                 fixed4 color : COLOR;
47 |                 float4 vertex : SV_POSITION;
48 |                 UNITY_VERTEX_OUTPUT_STEREO
49 |             };
50 |             float4 _Color;
51 |             v2f vert (appdata_t v)
52 |             {
53 |                 v2f o;
54 |                 UNITY_SETUP_INSTANCE_ID(v);
55 |                 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
56 |                 o.vertex = UnityObjectToClipPos(v.vertex);
57 |                 o.color = v.color * _Color;
58 |                 return o;
59 |             }
60 |             fixed4 frag (v2f i) : SV_Target
61 |             {
62 |                 return i.color;
63 |             }
64 |             ENDCG
65 |         }
66 |     }
67 | }
68 | 
69 | 70 | 71 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResources/Internal-ErrorShader.html: -------------------------------------------------------------------------------- 1 | 2 |
 3 | Shader "Hidden/InternalErrorShader"
 4 | {
 5 |     SubShader
 6 |     {
 7 |         Pass
 8 |         {
 9 |             CGPROGRAM
10 |             #pragma vertex vert
11 |             #pragma fragment frag
12 |             #pragma target 2.0
13 |             #pragma multi_compile _ UNITY_SINGLE_PASS_STEREO STEREO_INSTANCING_ON STEREO_MULTIVIEW_ON
14 |             #include "UnityCG.cginc"
15 | 
16 |             struct appdata_t {
17 |                 float4 vertex : POSITION;
18 |                 UNITY_VERTEX_INPUT_INSTANCE_ID
19 |             };
20 | 
21 |             struct v2f {
22 |                 float4 vertex : SV_POSITION;
23 |                 UNITY_VERTEX_OUTPUT_STEREO
24 |             };
25 | 
26 |             v2f vert (appdata_t v)
27 |             {
28 |                 v2f o;
29 |                 UNITY_SETUP_INSTANCE_ID(v);
30 |                 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
31 |                 o.vertex = UnityObjectToClipPos(v.vertex);
32 |                 return o;
33 |             }
34 |             fixed4 frag (v2f i) : SV_Target
35 |             {
36 |                 return fixed4(1,0,1,1);
37 |             }
38 |             ENDCG
39 |         }
40 |     }
41 |     Fallback Off
42 | }      
43 | 
44 | 45 | 46 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResources/Internal-Skinning-Util.html: -------------------------------------------------------------------------------- 1 | 2 |
 3 | #if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(SHADER_API_PS4) || defined(SHADER_API_GLCORE) || defined(SHADER_API_VULKAN) || defined(SHADER_API_METAL) || defined(SHADER_API_PSSL) || defined(SHADER_API_SWITCH)
 4 | #define STRUCTURED_BUFFER_SUPPORT 1
 5 | #else
 6 | #define STRUCTURED_BUFFER_SUPPORT 0
 7 | #endif
 8 | 
 9 | struct MeshVertex
10 | {
11 |     float3 pos;
12 | #if SKIN_NORM
13 |     float3 norm;
14 | #endif
15 | #if SKIN_TANG
16 |     float4 tang;
17 | #endif
18 | };
19 | 
20 | 21 | 22 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResources/PerformanceTools/FrameDebuggerRenderTargetDisplay.html: -------------------------------------------------------------------------------- 1 | 2 |
  3 | Shader "Hidden/FrameDebuggerRenderTargetDisplay" {
  4 |     Properties {
  5 |         _MainTex ("", any) = "white" {}
  6 |     }
  7 | 
  8 |     CGINCLUDE
  9 |     #include "UnityCG.cginc"
 10 |     #include "HLSLSupport.cginc"
 11 |     struct appdata {
 12 |         float4 vertex : POSITION;
 13 |         float3 uv : TEXCOORD0;
 14 |     };
 15 | 
 16 |     struct v2f {
 17 |         float4 pos : SV_POSITION;
 18 |         float3 uv : TEXCOORD0;
 19 |     };
 20 | 
 21 |     v2f vert(appdata v) {
 22 |         v2f o;
 23 |         o.pos = UnityObjectToClipPos(v.vertex);
 24 |         o.uv = v.uv;
 25 |         return o;
 26 |     }
 27 | 
 28 |     fixed4 _Channels;
 29 |     half4 _Levels;
 30 |     bool _UndoOutputSRGB;
 31 | 
 32 |     fixed4 ProcessColor (half4 tex)
 33 |     {
 34 |         // adjust levels
 35 |         half4 col = tex;
 36 |         col -= _Levels.rrrr;
 37 |         col /= _Levels.gggg-_Levels.rrrr;
 38 | 
 39 |         // leave only channels we want to show
 40 |         col *= _Channels;
 41 | 
 42 |         // if we're showing only a single channel, display that as grayscale
 43 |         if (dot(_Channels,fixed4(1,1,1,1)) == 1.0)
 44 |         {
 45 |             half c = dot(col,half4(1,1,1,1));
 46 |             col = c;
 47 |         }
 48 | 
 49 |         // When writing to the render target, it will compress our output into
 50 |         // sRGB space. If we just want to show the linear value as-is, we need
 51 |         // to cancel the hardware's sRGB conversion, so we convert "from" sRGB
 52 |         // which the HW will revert by converting back "to" sRGB.
 53 |         if (_UndoOutputSRGB)
 54 |             col.rgb = GammaToLinearSpace(saturate(col.rgb));
 55 | 
 56 |         return col;
 57 |     }
 58 |     ENDCG
 59 | 
 60 |     SubShader {
 61 |         Cull Off ZWrite Off ZTest Always
 62 | 
 63 |         // 2D texture
 64 |         Pass {
 65 |             CGPROGRAM
 66 |             #pragma vertex vert
 67 |             #pragma fragment frag
 68 | 
 69 |             sampler2D_float _MainTex;
 70 | 
 71 |             fixed4 frag (v2f i) : SV_Target {
 72 |                 half4 tex = tex2D (_MainTex, i.uv.xy);
 73 |                 return ProcessColor (tex);
 74 |             }
 75 |             ENDCG
 76 |         }
 77 | 
 78 |         // Cubemap
 79 |         Pass {
 80 |             CGPROGRAM
 81 |             #pragma vertex vert
 82 |             #pragma fragment frag
 83 | 
 84 |             samplerCUBE_float _MainTex;
 85 | 
 86 |             fixed4 frag (v2f i) : SV_Target {
 87 |                 half4 tex = texCUBE (_MainTex, i.uv.xyz);
 88 |                 return ProcessColor (tex);
 89 |             }
 90 |             ENDCG
 91 |         }
 92 |     }
 93 | 
 94 |     SubShader{
 95 |         Cull Off ZWrite Off ZTest Always
 96 | 
 97 |         // 2D array texture
 98 |         Pass {
 99 |             CGPROGRAM
100 |             #pragma vertex vert
101 |             #pragma fragment frag
102 |             #pragma target 3.5
103 | 
104 |             UNITY_DECLARE_TEX2DARRAY(_MainTex);
105 | 
106 |             fixed4 frag(v2f i) : SV_Target{
107 |                 half4 tex = UNITY_SAMPLE_TEX2DARRAY(_MainTex, i.uv.xyz);
108 |                 return ProcessColor(tex);
109 |             }
110 |             ENDCG
111 |         }
112 |     }
113 |     Fallback Off
114 | }
115 | 
116 | 117 | 118 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResourcesExtra/Internal-DeferredReflections.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  6 | 
  7 | Shader "Hidden/Internal-DeferredReflections" {
  8 | Properties {
  9 |     _SrcBlend ("", Float) = 1
 10 |     _DstBlend ("", Float) = 1
 11 | }
 12 | SubShader {
 13 | 
 14 | // Calculates reflection contribution from a single probe (rendered as cubes) or default reflection (rendered as full screen quad)
 15 | Pass {
 16 |     ZWrite Off
 17 |     ZTest LEqual
 18 |     Blend [_SrcBlend] [_DstBlend]
 19 | CGPROGRAM
 20 | #pragma target 3.0
 21 | #pragma vertex vert_deferred
 22 | #pragma fragment frag
 23 | 
 24 | #include "UnityCG.cginc"
 25 | #include "UnityDeferredLibrary.cginc"
 26 | #include "UnityStandardUtils.cginc"
 27 | #include "UnityGBuffer.cginc"
 28 | #include "UnityStandardBRDF.cginc"
 29 | #include "UnityPBSLighting.cginc"
 30 | 
 31 | sampler2D _CameraGBufferTexture0;
 32 | sampler2D _CameraGBufferTexture1;
 33 | sampler2D _CameraGBufferTexture2;
 34 | 
 35 | half3 distanceFromAABB(half3 p, half3 aabbMin, half3 aabbMax)
 36 | {
 37 |     return max(max(p - aabbMax, aabbMin - p), half3(0.0, 0.0, 0.0));
 38 | }
 39 | 
 40 | 
 41 | half4 frag (unity_v2f_deferred i) : SV_Target
 42 | {
 43 |     // Stripped from UnityDeferredCalculateLightParams, refactor into function ?
 44 |     i.ray = i.ray * (_ProjectionParams.z / i.ray.z);
 45 |     float2 uv = i.uv.xy / i.uv.w;
 46 | 
 47 |     // read depth and reconstruct world position
 48 |     float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, uv);
 49 |     depth = Linear01Depth (depth);
 50 |     float4 viewPos = float4(i.ray * depth,1);
 51 |     float3 worldPos = mul (unity_CameraToWorld, viewPos).xyz;
 52 | 
 53 |     half4 gbuffer0 = tex2D (_CameraGBufferTexture0, uv);
 54 |     half4 gbuffer1 = tex2D (_CameraGBufferTexture1, uv);
 55 |     half4 gbuffer2 = tex2D (_CameraGBufferTexture2, uv);
 56 |     UnityStandardData data = UnityStandardDataFromGbuffer(gbuffer0, gbuffer1, gbuffer2);
 57 | 
 58 |     float3 eyeVec = normalize(worldPos - _WorldSpaceCameraPos);
 59 |     half oneMinusReflectivity = 1 - SpecularStrength(data.specularColor);
 60 | 
 61 |     half3 worldNormalRefl = reflect(eyeVec, data.normalWorld);
 62 | 
 63 |     // Unused member don't need to be initialized
 64 |     UnityGIInput d;
 65 |     d.worldPos = worldPos;
 66 |     d.worldViewDir = -eyeVec;
 67 |     d.probeHDR[0] = unity_SpecCube0_HDR;
 68 |     d.boxMin[0].w = 1; // 1 in .w allow to disable blending in UnityGI_IndirectSpecular call since it doesn't work in Deferred
 69 | 
 70 |     float blendDistance = unity_SpecCube1_ProbePosition.w; // will be set to blend distance for this probe
 71 |     #ifdef UNITY_SPECCUBE_BOX_PROJECTION
 72 |     d.probePosition[0]  = unity_SpecCube0_ProbePosition;
 73 |     d.boxMin[0].xyz     = unity_SpecCube0_BoxMin - float4(blendDistance,blendDistance,blendDistance,0);
 74 |     d.boxMax[0].xyz     = unity_SpecCube0_BoxMax + float4(blendDistance,blendDistance,blendDistance,0);
 75 |     #endif
 76 | 
 77 |     Unity_GlossyEnvironmentData g = UnityGlossyEnvironmentSetup(data.smoothness, d.worldViewDir, data.normalWorld, data.specularColor);
 78 | 
 79 |     half3 env0 = UnityGI_IndirectSpecular(d, data.occlusion, g);
 80 | 
 81 |     UnityLight light;
 82 |     light.color = half3(0, 0, 0);
 83 |     light.dir = half3(0, 1, 0);
 84 | 
 85 |     UnityIndirect ind;
 86 |     ind.diffuse = 0;
 87 |     ind.specular = env0;
 88 | 
 89 |     half3 rgb = UNITY_BRDF_PBS (0, data.specularColor, oneMinusReflectivity, data.smoothness, data.normalWorld, -eyeVec, light, ind).rgb;
 90 | 
 91 |     // Calculate falloff value, so reflections on the edges of the probe would gradually blend to previous reflection.
 92 |     // Also this ensures that pixels not located in the reflection probe AABB won't
 93 |     // accidentally pick up reflections from this probe.
 94 |     half3 distance = distanceFromAABB(worldPos, unity_SpecCube0_BoxMin.xyz, unity_SpecCube0_BoxMax.xyz);
 95 |     half falloff = saturate(1.0 - length(distance)/blendDistance);
 96 | 
 97 |     return half4(rgb, falloff);
 98 | }
 99 | 
100 | ENDCG
101 | }
102 | 
103 | // Adds reflection buffer to the lighting buffer
104 | Pass
105 | {
106 |     ZWrite Off
107 |     ZTest Always
108 |     Blend [_SrcBlend] [_DstBlend]
109 | 
110 |     CGPROGRAM
111 |         #pragma target 3.0
112 |         #pragma vertex vert
113 |         #pragma fragment frag
114 |         #pragma multi_compile ___ UNITY_HDR_ON
115 | 
116 |         #include "UnityCG.cginc"
117 | 
118 |         sampler2D _CameraReflectionsTexture;
119 | 
120 |         struct v2f {
121 |             float2 uv : TEXCOORD0;
122 |             float4 pos : SV_POSITION;
123 |         };
124 | 
125 |         v2f vert (float4 vertex : POSITION)
126 |         {
127 |             v2f o;
128 |             o.pos = UnityObjectToClipPos(vertex);
129 |             o.uv = ComputeScreenPos (o.pos).xy;
130 |             return o;
131 |         }
132 | 
133 |         half4 frag (v2f i) : SV_Target
134 |         {
135 |             half4 c = tex2D (_CameraReflectionsTexture, i.uv);
136 |             #ifdef UNITY_HDR_ON
137 |             return float4(c.rgb, 0.0f);
138 |             #else
139 |             return float4(exp2(-c.rgb), 0.0f);
140 |             #endif
141 | 
142 |         }
143 |     ENDCG
144 | }
145 | 
146 | }
147 | Fallback Off
148 | }
149 | 
150 | 151 | 152 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResourcesExtra/Internal-DeferredShading.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  6 | 
  7 | Shader "Hidden/Internal-DeferredShading" {
  8 | Properties {
  9 |     _LightTexture0 ("", any) = "" {}
 10 |     _LightTextureB0 ("", 2D) = "" {}
 11 |     _ShadowMapTexture ("", any) = "" {}
 12 |     _SrcBlend ("", Float) = 1
 13 |     _DstBlend ("", Float) = 1
 14 | }
 15 | SubShader {
 16 | 
 17 | // Pass 1: Lighting pass
 18 | //  LDR case - Lighting encoded into a subtractive ARGB8 buffer
 19 | //  HDR case - Lighting additively blended into floating point buffer
 20 | Pass {
 21 |     ZWrite Off
 22 |     Blend [_SrcBlend] [_DstBlend]
 23 | 
 24 | CGPROGRAM
 25 | #pragma target 3.0
 26 | #pragma vertex vert_deferred
 27 | #pragma fragment frag
 28 | #pragma multi_compile_lightpass
 29 | #pragma multi_compile ___ UNITY_HDR_ON
 30 | 
 31 | #pragma exclude_renderers nomrt
 32 | 
 33 | #include "UnityCG.cginc"
 34 | #include "UnityDeferredLibrary.cginc"
 35 | #include "UnityPBSLighting.cginc"
 36 | #include "UnityStandardUtils.cginc"
 37 | #include "UnityGBuffer.cginc"
 38 | #include "UnityStandardBRDF.cginc"
 39 | 
 40 | sampler2D _CameraGBufferTexture0;
 41 | sampler2D _CameraGBufferTexture1;
 42 | sampler2D _CameraGBufferTexture2;
 43 | 
 44 | half4 CalculateLight (unity_v2f_deferred i)
 45 | {
 46 |     float3 wpos;
 47 |     float2 uv;
 48 |     float atten, fadeDist;
 49 |     UnityLight light;
 50 |     UNITY_INITIALIZE_OUTPUT(UnityLight, light);
 51 |     UnityDeferredCalculateLightParams (i, wpos, uv, light.dir, atten, fadeDist);
 52 | 
 53 |     light.color = _LightColor.rgb * atten;
 54 | 
 55 |     // unpack Gbuffer
 56 |     half4 gbuffer0 = tex2D (_CameraGBufferTexture0, uv);
 57 |     half4 gbuffer1 = tex2D (_CameraGBufferTexture1, uv);
 58 |     half4 gbuffer2 = tex2D (_CameraGBufferTexture2, uv);
 59 |     UnityStandardData data = UnityStandardDataFromGbuffer(gbuffer0, gbuffer1, gbuffer2);
 60 | 
 61 |     float3 eyeVec = normalize(wpos-_WorldSpaceCameraPos);
 62 |     half oneMinusReflectivity = 1 - SpecularStrength(data.specularColor.rgb);
 63 | 
 64 |     UnityIndirect ind;
 65 |     UNITY_INITIALIZE_OUTPUT(UnityIndirect, ind);
 66 |     ind.diffuse = 0;
 67 |     ind.specular = 0;
 68 | 
 69 |     half4 res = UNITY_BRDF_PBS (data.diffuseColor, data.specularColor, oneMinusReflectivity, data.smoothness, data.normalWorld, -eyeVec, light, ind);
 70 | 
 71 |     return res;
 72 | }
 73 | 
 74 | #ifdef UNITY_HDR_ON
 75 | half4
 76 | #else
 77 | fixed4
 78 | #endif
 79 | frag (unity_v2f_deferred i) : SV_Target
 80 | {
 81 |     half4 c = CalculateLight(i);
 82 |     #ifdef UNITY_HDR_ON
 83 |     return c;
 84 |     #else
 85 |     return exp2(-c);
 86 |     #endif
 87 | }
 88 | 
 89 | ENDCG
 90 | }
 91 | 
 92 | 
 93 | // Pass 2: Final decode pass.
 94 | // Used only with HDR off, to decode the logarithmic buffer into the main RT
 95 | Pass {
 96 |     ZTest Always Cull Off ZWrite Off
 97 |     Stencil {
 98 |         ref [_StencilNonBackground]
 99 |         readmask [_StencilNonBackground]
100 |         // Normally just comp would be sufficient, but there's a bug and only front face stencil state is set (case 583207)
101 |         compback equal
102 |         compfront equal
103 |     }
104 | 
105 | CGPROGRAM
106 | #pragma target 3.0
107 | #pragma vertex vert
108 | #pragma fragment frag
109 | #pragma exclude_renderers nomrt
110 | 
111 | #include "UnityCG.cginc"
112 | 
113 | sampler2D _LightBuffer;
114 | struct v2f {
115 |     float4 vertex : SV_POSITION;
116 |     float2 texcoord : TEXCOORD0;
117 | };
118 | 
119 | v2f vert (float4 vertex : POSITION, float2 texcoord : TEXCOORD0)
120 | {
121 |     v2f o;
122 |     o.vertex = UnityObjectToClipPos(vertex);
123 |     o.texcoord = texcoord.xy;
124 | #ifdef UNITY_SINGLE_PASS_STEREO
125 |     o.texcoord = TransformStereoScreenSpaceTex(o.texcoord, 1.0f);
126 | #endif
127 |     return o;
128 | }
129 | 
130 | fixed4 frag (v2f i) : SV_Target
131 | {
132 |     return -log2(tex2D(_LightBuffer, i.texcoord));
133 | }
134 | ENDCG
135 | }
136 | 
137 | }
138 | Fallback Off
139 | }
140 | 
141 | 142 | 143 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResourcesExtra/Particle Add.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 6 | 
 7 | Shader "Legacy Shaders/Particles/Additive" {
 8 | Properties {
 9 |     _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
10 |     _MainTex ("Particle Texture", 2D) = "white" {}
11 |     _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
12 | }
13 | 
14 | Category {
15 |     Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
16 |     Blend SrcAlpha One
17 |     ColorMask RGB
18 |     Cull Off Lighting Off ZWrite Off
19 | 
20 |     SubShader {
21 |         Pass {
22 | 
23 |             CGPROGRAM
24 |             #pragma vertex vert
25 |             #pragma fragment frag
26 |             #pragma target 2.0
27 |             #pragma multi_compile_particles
28 |             #pragma multi_compile_fog
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 |                 UNITY_VERTEX_INPUT_INSTANCE_ID
40 |             };
41 | 
42 |             struct v2f {
43 |                 float4 vertex : SV_POSITION;
44 |                 fixed4 color : COLOR;
45 |                 float2 texcoord : TEXCOORD0;
46 |                 UNITY_FOG_COORDS(1)
47 |                 #ifdef SOFTPARTICLES_ON
48 |                 float4 projPos : TEXCOORD2;
49 |                 #endif
50 |                 UNITY_VERTEX_OUTPUT_STEREO
51 |             };
52 | 
53 |             float4 _MainTex_ST;
54 | 
55 |             v2f vert (appdata_t v)
56 |             {
57 |                 v2f o;
58 |                 UNITY_SETUP_INSTANCE_ID(v);
59 |                 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
60 |                 o.vertex = UnityObjectToClipPos(v.vertex);
61 |                 #ifdef SOFTPARTICLES_ON
62 |                 o.projPos = ComputeScreenPos (o.vertex);
63 |                 COMPUTE_EYEDEPTH(o.projPos.z);
64 |                 #endif
65 |                 o.color = v.color;
66 |                 o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
67 |                 UNITY_TRANSFER_FOG(o,o.vertex);
68 |                 return o;
69 |             }
70 | 
71 |             UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
72 |             float _InvFade;
73 | 
74 |             fixed4 frag (v2f i) : SV_Target
75 |             {
76 |                 #ifdef SOFTPARTICLES_ON
77 |                 float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
78 |                 float partZ = i.projPos.z;
79 |                 float fade = saturate (_InvFade * (sceneZ-partZ));
80 |                 i.color.a *= fade;
81 |                 #endif
82 | 
83 |                 fixed4 col = 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord);
84 |                 col.a = saturate(col.a); // alpha should not have double-brightness applied to it, but we can't fix that legacy behavior without breaking everyone's effects, so instead clamp the output to get sensible HDR behavior (case 967476)
85 | 
86 |                 UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode
87 |                 return col;
88 |             }
89 |             ENDCG
90 |         }
91 |     }
92 | }
93 | }
94 | 
95 | 96 | 97 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResourcesExtra/Reflect-Bumped.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 |         // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 6 | 
 7 |         Shader "Legacy Shaders/Reflective/Bumped Diffuse" {
 8 |         Properties {
 9 |             _Color ("Main Color", Color) = (1,1,1,1)
10 |             _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
11 |             _MainTex ("Base (RGB) RefStrength (A)", 2D) = "white" {}
12 |             _Cube ("Reflection Cubemap", Cube) = "_Skybox" { }
13 |             _BumpMap ("Normalmap", 2D) = "bump" {}
14 |         }
15 |         
16 |         SubShader {
17 |             Tags { "RenderType"="Opaque" }
18 |             LOD 300
19 |         
20 |         CGPROGRAM
21 |         #pragma surface surf Lambert
22 |         
23 |         sampler2D _MainTex;
24 |         sampler2D _BumpMap;
25 |         samplerCUBE _Cube;
26 |         
27 |         fixed4 _Color;
28 |         fixed4 _ReflectColor;
29 |         
30 |         struct Input {
31 |             float2 uv_MainTex;
32 |             float2 uv_BumpMap;
33 |             float3 worldRefl;
34 |             INTERNAL_DATA
35 |         };
36 |         
37 |         void surf (Input IN, inout SurfaceOutput o) {
38 |             fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
39 |             fixed4 c = tex * _Color;
40 |             o.Albedo = c.rgb;
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 "Legacy Shaders/Reflective/VertexLit"
54 |         }
55 |         
56 | 
57 | 58 | 59 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResourcesExtra/Reflect-Diffuse.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 |         // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 6 | 
 7 |         Shader "Legacy Shaders/Reflective/Diffuse" {
 8 |         Properties {
 9 |             _Color ("Main Color", Color) = (1,1,1,1)
10 |             _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
11 |             _MainTex ("Base (RGB) RefStrength (A)", 2D) = "white" {}
12 |             _Cube ("Reflection Cubemap", Cube) = "_Skybox" {}
13 |         }
14 |         SubShader {
15 |             LOD 200
16 |             Tags { "RenderType"="Opaque" }
17 |         
18 |         CGPROGRAM
19 |         #pragma surface surf Lambert
20 |         
21 |         sampler2D _MainTex;
22 |         samplerCUBE _Cube;
23 |         
24 |         fixed4 _Color;
25 |         fixed4 _ReflectColor;
26 |         
27 |         struct Input {
28 |             float2 uv_MainTex;
29 |             float3 worldRefl;
30 |         };
31 |         
32 |         void surf (Input IN, inout SurfaceOutput o) {
33 |             fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
34 |             fixed4 c = tex * _Color;
35 |             o.Albedo = c.rgb;
36 |         
37 |             fixed4 reflcol = texCUBE (_Cube, IN.worldRefl);
38 |             reflcol *= tex.a;
39 |             o.Emission = reflcol.rgb * _ReflectColor.rgb;
40 |             o.Alpha = reflcol.a * _ReflectColor.a;
41 |         }
42 |         ENDCG
43 |         }
44 |         
45 |         FallBack "Legacy Shaders/Reflective/VertexLit"
46 |         }
47 |         
48 | 
49 | 50 | 51 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResourcesExtra/Reflect-Glossy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 |         // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 6 | 
 7 |         Shader "Legacy Shaders/Reflective/Specular" {
 8 |         Properties {
 9 |             _Color ("Main Color", Color) = (1,1,1,1)
10 |             _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
11 |             [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125
12 |             _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
13 |             _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
14 |             _Cube ("Reflection Cubemap", Cube) = "_Skybox" {}
15 |         }
16 |         SubShader {
17 |             LOD 300
18 |             Tags { "RenderType"="Opaque" }
19 |         
20 |         CGPROGRAM
21 |         #pragma surface surf BlinnPhong
22 |         
23 |         sampler2D _MainTex;
24 |         samplerCUBE _Cube;
25 |         
26 |         fixed4 _Color;
27 |         fixed4 _ReflectColor;
28 |         half _Shininess;
29 |         
30 |         struct Input {
31 |             float2 uv_MainTex;
32 |             float3 worldRefl;
33 |         };
34 |         
35 |         void surf (Input IN, inout SurfaceOutput o) {
36 |             fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
37 |             fixed4 c = tex * _Color;
38 |             o.Albedo = c.rgb;
39 |             o.Gloss = tex.a;
40 |             o.Specular = _Shininess;
41 |         
42 |             fixed4 reflcol = texCUBE (_Cube, IN.worldRefl);
43 |             reflcol *= tex.a;
44 |             o.Emission = reflcol.rgb * _ReflectColor.rgb;
45 |             o.Alpha = reflcol.a * _ReflectColor.a;
46 |         }
47 |         ENDCG
48 |         }
49 |         
50 |         FallBack "Legacy Shaders/Reflective/VertexLit"
51 |         }
52 |         
53 | 
54 | 55 | 56 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResourcesExtra/Reflect-Parallax.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 |         // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 6 | 
 7 |         Shader "Legacy Shaders/Reflective/Parallax Diffuse" {
 8 |         Properties {
 9 |             _Color ("Main Color", Color) = (1,1,1,1)
10 |             _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
11 |             _Parallax ("Height", Range (0.005, 0.08)) = 0.02
12 |             _MainTex ("Base (RGB) RefStrength (A)", 2D) = "white" {}
13 |             _Cube ("Reflection Cubemap", Cube) = "_Skybox" {}
14 |             _BumpMap ("Normalmap", 2D) = "bump" {}
15 |             _ParallaxMap ("Heightmap (A)", 2D) = "black" {}
16 |         }
17 |         SubShader {
18 |             Tags { "RenderType"="Opaque" }
19 |             LOD 500
20 |         
21 |         CGPROGRAM
22 |         #pragma surface surf Lambert
23 |         #pragma target 3.0
24 |         
25 |         sampler2D _MainTex;
26 |         sampler2D _BumpMap;
27 |         samplerCUBE _Cube;
28 |         sampler2D _ParallaxMap;
29 |         
30 |         fixed4 _Color;
31 |         fixed4 _ReflectColor;
32 |         float _Parallax;
33 |         
34 |         struct Input {
35 |             float2 uv_MainTex;
36 |             float2 uv_BumpMap;
37 |             float3 worldRefl;
38 |             float3 viewDir;
39 |             INTERNAL_DATA
40 |         };
41 |         
42 |         void surf (Input IN, inout SurfaceOutput o) {
43 |             half h = tex2D (_ParallaxMap, IN.uv_BumpMap).w;
44 |             float2 offset = ParallaxOffset (h, _Parallax, IN.viewDir);
45 |             IN.uv_MainTex += offset;
46 |             IN.uv_BumpMap += offset;
47 |         
48 |             fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
49 |             fixed4 c = tex * _Color;
50 |             o.Albedo = c.rgb;
51 |         
52 |             o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
53 |         
54 |             float3 worldRefl = WorldReflectionVector (IN, o.Normal);
55 |             fixed4 reflcol = texCUBE (_Cube, worldRefl);
56 |             reflcol *= tex.a;
57 |             o.Emission = reflcol.rgb * _ReflectColor.rgb;
58 |             o.Alpha = reflcol.a * _ReflectColor.a;
59 |         }
60 |         ENDCG
61 |         }
62 |         
63 |         FallBack "Legacy Shaders/Reflective/Bumped Diffuse"
64 |         }
65 |         
66 | 
67 | 68 | 69 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResourcesExtra/Reflect-ParallaxSpec.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 |         // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 6 | 
 7 |         Shader "Legacy Shaders/Reflective/Parallax Specular" {
 8 |         Properties {
 9 |             _Color ("Main Color", Color) = (1,1,1,1)
10 |             _SpecColor ("Specular Color", Color) = (0.5,0.5,0.5,1)
11 |             [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125
12 |             _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
13 |             _Parallax ("Height", Range (0.005, 0.08)) = 0.02
14 |             _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" { }
15 |             _Cube ("Reflection Cubemap", Cube) = "_Skybox" {}
16 |             _BumpMap ("Normalmap", 2D) = "bump" { }
17 |             _ParallaxMap ("Heightmap (A)", 2D) = "black" {}
18 |         }
19 |         SubShader {
20 |             Tags { "RenderType"="Opaque" }
21 |             LOD 600
22 |         
23 |         CGPROGRAM
24 |         #pragma surface surf BlinnPhong
25 |         #pragma target 3.0
26 |         
27 |         sampler2D _MainTex;
28 |         sampler2D _BumpMap;
29 |         samplerCUBE _Cube;
30 |         sampler2D _ParallaxMap;
31 |         
32 |         fixed4 _Color;
33 |         fixed4 _ReflectColor;
34 |         half _Shininess;
35 |         float _Parallax;
36 |         
37 |         struct Input {
38 |             float2 uv_MainTex;
39 |             float2 uv_BumpMap;
40 |             float3 worldRefl;
41 |             float3 viewDir;
42 |             INTERNAL_DATA
43 |         };
44 |         
45 |         void surf (Input IN, inout SurfaceOutput o) {
46 |             half h = tex2D (_ParallaxMap, IN.uv_BumpMap).w;
47 |             float2 offset = ParallaxOffset (h, _Parallax, IN.viewDir);
48 |             IN.uv_MainTex += offset;
49 |             IN.uv_BumpMap += offset;
50 |         
51 |             fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
52 |             o.Albedo = tex.rgb * _Color.rgb;
53 |             o.Gloss = tex.a;
54 |             o.Specular = _Shininess;
55 |         
56 |             o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
57 |         
58 |             float3 worldRefl = WorldReflectionVector (IN, o.Normal);
59 |             fixed4 reflcol = texCUBE (_Cube, worldRefl);
60 |             reflcol *= tex.a;
61 |             o.Emission = reflcol.rgb * _ReflectColor.rgb;
62 |             o.Alpha = reflcol.a * _ReflectColor.a;
63 |         }
64 |         ENDCG
65 |         }
66 |         
67 |         FallBack "Legacy Shaders/Reflective/Bumped Specular"
68 |         }
69 |         
70 | 
71 | 72 | 73 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResourcesExtra/Skybox-Cubed.html: -------------------------------------------------------------------------------- 1 | 2 |
 3 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 4 | 
 5 | Shader "Skybox/Cubemap" {
 6 | Properties {
 7 |     _Tint ("Tint Color", Color) = (.5, .5, .5, .5)
 8 |     [Gamma] _Exposure ("Exposure", Range(0, 8)) = 1.0
 9 |     _Rotation ("Rotation", Range(0, 360)) = 0
10 |     [NoScaleOffset] _Tex ("Cubemap   (HDR)", Cube) = "grey" {}
11 | }
12 | 
13 | SubShader {
14 |     Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" }
15 |     Cull Off ZWrite Off
16 | 
17 |     Pass {
18 | 
19 |         CGPROGRAM
20 |         #pragma vertex vert
21 |         #pragma fragment frag
22 |         #pragma target 2.0
23 | 
24 |         #include "UnityCG.cginc"
25 | 
26 |         samplerCUBE _Tex;
27 |         half4 _Tex_HDR;
28 |         half4 _Tint;
29 |         half _Exposure;
30 |         float _Rotation;
31 | 
32 |         float3 RotateAroundYInDegrees (float3 vertex, float degrees)
33 |         {
34 |             float alpha = degrees * UNITY_PI / 180.0;
35 |             float sina, cosa;
36 |             sincos(alpha, sina, cosa);
37 |             float2x2 m = float2x2(cosa, -sina, sina, cosa);
38 |             return float3(mul(m, vertex.xz), vertex.y).xzy;
39 |         }
40 | 
41 |         struct appdata_t {
42 |             float4 vertex : POSITION;
43 |             UNITY_VERTEX_INPUT_INSTANCE_ID
44 |         };
45 | 
46 |         struct v2f {
47 |             float4 vertex : SV_POSITION;
48 |             float3 texcoord : TEXCOORD0;
49 |             UNITY_VERTEX_OUTPUT_STEREO
50 |         };
51 | 
52 |         v2f vert (appdata_t v)
53 |         {
54 |             v2f o;
55 |             UNITY_SETUP_INSTANCE_ID(v);
56 |             UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
57 |             float3 rotated = RotateAroundYInDegrees(v.vertex, _Rotation);
58 |             o.vertex = UnityObjectToClipPos(rotated);
59 |             o.texcoord = v.vertex.xyz;
60 |             return o;
61 |         }
62 | 
63 |         fixed4 frag (v2f i) : SV_Target
64 |         {
65 |             half4 tex = texCUBE (_Tex, i.texcoord);
66 |             half3 c = DecodeHDR (tex, _Tex_HDR);
67 |             c = c * _Tint.rgb * unity_ColorSpaceDouble.rgb;
68 |             c *= _Exposure;
69 |             return half4(c, 1);
70 |         }
71 |         ENDCG
72 |     }
73 | }
74 | 
75 | 
76 | Fallback Off
77 | 
78 | }
79 | 
80 | 81 | 82 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResourcesExtra/Skybox.html: -------------------------------------------------------------------------------- 1 | 2 |
  3 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  4 | 
  5 | Shader "Skybox/6 Sided" {
  6 | Properties {
  7 |     _Tint ("Tint Color", Color) = (.5, .5, .5, .5)
  8 |     [Gamma] _Exposure ("Exposure", Range(0, 8)) = 1.0
  9 |     _Rotation ("Rotation", Range(0, 360)) = 0
 10 |     [NoScaleOffset] _FrontTex ("Front [+Z]   (HDR)", 2D) = "grey" {}
 11 |     [NoScaleOffset] _BackTex ("Back [-Z]   (HDR)", 2D) = "grey" {}
 12 |     [NoScaleOffset] _LeftTex ("Left [+X]   (HDR)", 2D) = "grey" {}
 13 |     [NoScaleOffset] _RightTex ("Right [-X]   (HDR)", 2D) = "grey" {}
 14 |     [NoScaleOffset] _UpTex ("Up [+Y]   (HDR)", 2D) = "grey" {}
 15 |     [NoScaleOffset] _DownTex ("Down [-Y]   (HDR)", 2D) = "grey" {}
 16 | }
 17 | 
 18 | SubShader {
 19 |     Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" }
 20 |     Cull Off ZWrite Off
 21 | 
 22 |     CGINCLUDE
 23 |     #include "UnityCG.cginc"
 24 | 
 25 |     half4 _Tint;
 26 |     half _Exposure;
 27 |     float _Rotation;
 28 | 
 29 |     float3 RotateAroundYInDegrees (float3 vertex, float degrees)
 30 |     {
 31 |         float alpha = degrees * UNITY_PI / 180.0;
 32 |         float sina, cosa;
 33 |         sincos(alpha, sina, cosa);
 34 |         float2x2 m = float2x2(cosa, -sina, sina, cosa);
 35 |         return float3(mul(m, vertex.xz), vertex.y).xzy;
 36 |     }
 37 | 
 38 |     struct appdata_t {
 39 |         float4 vertex : POSITION;
 40 |         float2 texcoord : TEXCOORD0;
 41 |         UNITY_VERTEX_INPUT_INSTANCE_ID
 42 |     };
 43 |     struct v2f {
 44 |         float4 vertex : SV_POSITION;
 45 |         float2 texcoord : TEXCOORD0;
 46 |         UNITY_VERTEX_OUTPUT_STEREO
 47 |     };
 48 |     v2f vert (appdata_t v)
 49 |     {
 50 |         v2f o;
 51 |         UNITY_SETUP_INSTANCE_ID(v);
 52 |         UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
 53 |         float3 rotated = RotateAroundYInDegrees(v.vertex, _Rotation);
 54 |         o.vertex = UnityObjectToClipPos(rotated);
 55 |         o.texcoord = v.texcoord;
 56 |         return o;
 57 |     }
 58 |     half4 skybox_frag (v2f i, sampler2D smp, half4 smpDecode)
 59 |     {
 60 |         half4 tex = tex2D (smp, i.texcoord);
 61 |         half3 c = DecodeHDR (tex, smpDecode);
 62 |         c = c * _Tint.rgb * unity_ColorSpaceDouble.rgb;
 63 |         c *= _Exposure;
 64 |         return half4(c, 1);
 65 |     }
 66 |     ENDCG
 67 | 
 68 |     Pass {
 69 |         CGPROGRAM
 70 |         #pragma vertex vert
 71 |         #pragma fragment frag
 72 |         #pragma target 2.0
 73 |         sampler2D _FrontTex;
 74 |         half4 _FrontTex_HDR;
 75 |         half4 frag (v2f i) : SV_Target { return skybox_frag(i,_FrontTex, _FrontTex_HDR); }
 76 |         ENDCG
 77 |     }
 78 |     Pass{
 79 |         CGPROGRAM
 80 |         #pragma vertex vert
 81 |         #pragma fragment frag
 82 |         #pragma target 2.0
 83 |         sampler2D _BackTex;
 84 |         half4 _BackTex_HDR;
 85 |         half4 frag (v2f i) : SV_Target { return skybox_frag(i,_BackTex, _BackTex_HDR); }
 86 |         ENDCG
 87 |     }
 88 |     Pass{
 89 |         CGPROGRAM
 90 |         #pragma vertex vert
 91 |         #pragma fragment frag
 92 |         #pragma target 2.0
 93 |         sampler2D _LeftTex;
 94 |         half4 _LeftTex_HDR;
 95 |         half4 frag (v2f i) : SV_Target { return skybox_frag(i,_LeftTex, _LeftTex_HDR); }
 96 |         ENDCG
 97 |     }
 98 |     Pass{
 99 |         CGPROGRAM
100 |         #pragma vertex vert
101 |         #pragma fragment frag
102 |         #pragma target 2.0
103 |         sampler2D _RightTex;
104 |         half4 _RightTex_HDR;
105 |         half4 frag (v2f i) : SV_Target { return skybox_frag(i,_RightTex, _RightTex_HDR); }
106 |         ENDCG
107 |     }
108 |     Pass{
109 |         CGPROGRAM
110 |         #pragma vertex vert
111 |         #pragma fragment frag
112 |         #pragma target 2.0
113 |         sampler2D _UpTex;
114 |         half4 _UpTex_HDR;
115 |         half4 frag (v2f i) : SV_Target { return skybox_frag(i,_UpTex, _UpTex_HDR); }
116 |         ENDCG
117 |     }
118 |     Pass{
119 |         CGPROGRAM
120 |         #pragma vertex vert
121 |         #pragma fragment frag
122 |         #pragma target 2.0
123 |         sampler2D _DownTex;
124 |         half4 _DownTex_HDR;
125 |         half4 frag (v2f i) : SV_Target { return skybox_frag(i,_DownTex, _DownTex_HDR); }
126 |         ENDCG
127 |     }
128 | }
129 | }
130 | 
131 | 132 | 133 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResourcesExtra/Sprites-Default.html: -------------------------------------------------------------------------------- 1 | 2 |
 3 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 4 | 
 5 | Shader "Sprites/Default"
 6 | {
 7 |     Properties
 8 |     {
 9 |         [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
10 |         _Color ("Tint", Color) = (1,1,1,1)
11 |         [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
12 |         [HideInInspector] _RendererColor ("RendererColor", Color) = (1,1,1,1)
13 |         [HideInInspector] _Flip ("Flip", Vector) = (1,1,1,1)
14 |         [PerRendererData] _AlphaTex ("External Alpha", 2D) = "white" {}
15 |         [PerRendererData] _EnableExternalAlpha ("Enable External Alpha", Float) = 0
16 |     }
17 | 
18 |     SubShader
19 |     {
20 |         Tags
21 |         {
22 |             "Queue"="Transparent"
23 |             "IgnoreProjector"="True"
24 |             "RenderType"="Transparent"
25 |             "PreviewType"="Plane"
26 |             "CanUseSpriteAtlas"="True"
27 |         }
28 | 
29 |         Cull Off
30 |         Lighting Off
31 |         ZWrite Off
32 |         Blend One OneMinusSrcAlpha
33 | 
34 |         Pass
35 |         {
36 |         CGPROGRAM
37 |             #pragma vertex SpriteVert
38 |             #pragma fragment SpriteFrag
39 |             #pragma target 2.0
40 |             #pragma multi_compile_instancing
41 |             #pragma multi_compile_local _ PIXELSNAP_ON
42 |             #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
43 |             #include "UnitySprites.cginc"
44 |         ENDCG
45 |         }
46 |     }
47 | }
48 | 
49 | 50 | 51 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResourcesExtra/Sprites-Diffuse.html: -------------------------------------------------------------------------------- 1 | 2 |
 3 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 4 | 
 5 | Shader "Sprites/Diffuse"
 6 | {
 7 |     Properties
 8 |     {
 9 |         [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
10 |         _Color ("Tint", Color) = (1,1,1,1)
11 |         [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
12 |         [HideInInspector] _RendererColor ("RendererColor", Color) = (1,1,1,1)
13 |         [HideInInspector] _Flip ("Flip", Vector) = (1,1,1,1)
14 |         [PerRendererData] _AlphaTex ("External Alpha", 2D) = "white" {}
15 |         [PerRendererData] _EnableExternalAlpha ("Enable External Alpha", Float) = 0
16 |     }
17 | 
18 |     SubShader
19 |     {
20 |         Tags
21 |         {
22 |             "Queue"="Transparent"
23 |             "IgnoreProjector"="True"
24 |             "RenderType"="Transparent"
25 |             "PreviewType"="Plane"
26 |             "CanUseSpriteAtlas"="True"
27 |         }
28 | 
29 |         Cull Off
30 |         Lighting Off
31 |         ZWrite Off
32 |         Blend One OneMinusSrcAlpha
33 | 
34 |         CGPROGRAM
35 |         #pragma surface surf Lambert vertex:vert nofog nolightmap nodynlightmap keepalpha noinstancing
36 |         #pragma multi_compile_local _ PIXELSNAP_ON
37 |         #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
38 |         #include "UnitySprites.cginc"
39 | 
40 |         struct Input
41 |         {
42 |             float2 uv_MainTex;
43 |             fixed4 color;
44 |         };
45 | 
46 |         void vert (inout appdata_full v, out Input o)
47 |         {
48 |             v.vertex = UnityFlipSprite(v.vertex, _Flip);
49 | 
50 |             #if defined(PIXELSNAP_ON)
51 |             v.vertex = UnityPixelSnap (v.vertex);
52 |             #endif
53 | 
54 |             UNITY_INITIALIZE_OUTPUT(Input, o);
55 |             o.color = v.color * _Color * _RendererColor;
56 |         }
57 | 
58 |         void surf (Input IN, inout SurfaceOutput o)
59 |         {
60 |             fixed4 c = SampleSpriteTexture (IN.uv_MainTex) * IN.color;
61 |             o.Albedo = c.rgb * c.a;
62 |             o.Alpha = c.a;
63 |         }
64 |         ENDCG
65 |     }
66 | 
67 | Fallback "Transparent/VertexLit"
68 | }
69 | 
70 | 71 | 72 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResourcesExtra/Sprites-Mask.html: -------------------------------------------------------------------------------- 1 | 2 |
 3 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 4 | 
 5 | Shader "Sprites/Mask"
 6 | {
 7 |     Properties
 8 |     {
 9 |         [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
10 |         [PerRendererData] _AlphaTex ("External Alpha", 2D) = "white" {}
11 |         [HideInInspector] _Cutoff ("Mask alpha cutoff", Range(0.0, 1.0)) = 0.0
12 |         _Color ("Tint", Color) = (1,1,1,0.2)
13 |         [PerRendererData] _EnableExternalAlpha ("Enable External Alpha", Float) = 0
14 |         [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
15 |     }
16 | 
17 |     SubShader
18 |     {
19 |         Tags
20 |         {
21 |             "Queue"="Transparent"
22 |             "IgnoreProjector"="True"
23 |             "RenderType"="Transparent"
24 |             "PreviewType"="Plane"
25 |             "CanUseSpriteAtlas"="True"
26 |         }
27 | 
28 |         Cull Off
29 |         Lighting Off
30 |         ZWrite Off
31 |         Blend Off
32 |         ColorMask 0
33 | 
34 |         Pass
35 |         {
36 |         CGPROGRAM
37 |             #pragma vertex vert
38 |             #pragma fragment frag
39 |             #pragma multi_compile_local _ PIXELSNAP_ON
40 |             #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
41 |             #include "UnitySprites.cginc"
42 | 
43 |             // alpha below which a mask should discard a pixel, thereby preventing the stencil buffer from being marked with the Mask's presence
44 |             fixed _Cutoff;
45 | 
46 |             struct appdata_masking
47 |             {
48 |                 float4 vertex : POSITION;
49 |                 half2 texcoord : TEXCOORD0;
50 |             };
51 | 
52 |             struct v2f_masking
53 |             {
54 |                 float4 pos : SV_POSITION;
55 |                 half2 uv : TEXCOORD0;
56 |                 UNITY_VERTEX_OUTPUT_STEREO
57 |             };
58 | 
59 |             v2f_masking vert(appdata_masking IN)
60 |             {
61 |                 v2f_masking OUT;
62 | 
63 |                 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
64 | 
65 |                 OUT.pos = UnityObjectToClipPos(IN.vertex);
66 |                 OUT.uv = IN.texcoord;
67 | 
68 |                 #ifdef PIXELSNAP_ON
69 |                 OUT.pos = UnityPixelSnap (OUT.pos);
70 |                 #endif
71 | 
72 |                 return OUT;
73 |             }
74 | 
75 | 
76 |             fixed4 frag(v2f_masking IN) : SV_Target
77 |             {
78 |                 fixed4 c = SampleSpriteTexture(IN.uv);
79 |                 // for masks: discard pixel if alpha falls below MaskingCutoff
80 |                 clip (c.a - _Cutoff);
81 |                 return _Color;
82 |             }
83 |         ENDCG
84 |         }
85 |     }
86 | }
87 | 
88 | 89 | 90 | -------------------------------------------------------------------------------- /Library/BuiltinShaders/DefaultResourcesExtra/Unlit/Unlit-Alpha.html: -------------------------------------------------------------------------------- 1 | 2 |
 3 | // Unlit alpha-blended shader.
 4 | // - no lighting
 5 | // - no lightmap support
 6 | // - no per-material color
 7 | 
 8 | Shader "Unlit/Transparent" {
 9 | Properties {
10 |     _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
11 | }
12 | 
13 | SubShader {
14 |     Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
15 |     LOD 100
16 | 
17 |     ZWrite Off
18 |     Blend SrcAlpha OneMinusSrcAlpha
19 | 
20 |     Pass {
21 |         CGPROGRAM
22 |             #pragma vertex vert
23 |             #pragma fragment frag
24 |             #pragma target 2.0
25 |             #pragma multi_compile_fog
26 | 
27 |             #include "UnityCG.cginc"
28 | 
29 |             struct appdata_t {
30 |                 float4 vertex : POSITION;
31 |                 float2 texcoord : TEXCOORD0;
32 |                 UNITY_VERTEX_INPUT_INSTANCE_ID
33 |             };
34 | 
35 |             struct v2f {
36 |                 float4 vertex : SV_POSITION;
37 |                 float2 texcoord : TEXCOORD0;
38 |                 UNITY_FOG_COORDS(1)
39 |                 UNITY_VERTEX_OUTPUT_STEREO
40 |             };
41 | 
42 |             sampler2D _MainTex;
43 |             float4 _MainTex_ST;
44 | 
45 |             v2f vert (appdata_t v)
46 |             {
47 |                 v2f o;
48 |                 UNITY_SETUP_INSTANCE_ID(v);
49 |                 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
50 |                 o.vertex = UnityObjectToClipPos(v.vertex);
51 |                 o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
52 |                 UNITY_TRANSFER_FOG(o,o.vertex);
53 |                 return o;
54 |             }
55 | 
56 |             fixed4 frag (v2f i) : SV_Target
57 |             {
58 |                 fixed4 col = tex2D(_MainTex, i.texcoord);
59 |                 UNITY_APPLY_FOG(i.fogCoord, col);
60 |                 return col;
61 |             }
62 |         ENDCG
63 |     }
64 | }
65 | 
66 | }
67 | 
68 | 69 | 70 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/Bloom.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | Shader "Hidden/PostProcessing/Bloom"
  6 | {
  7 |     HLSLINCLUDE
  8 |         
  9 |         #include "../StdLib.hlsl"
 10 |         #include "../Colors.hlsl"
 11 |         #include "../Sampling.hlsl"
 12 | 
 13 |         TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
 14 |         TEXTURE2D_SAMPLER2D(_BloomTex, sampler_BloomTex);
 15 |         TEXTURE2D_SAMPLER2D(_AutoExposureTex, sampler_AutoExposureTex);
 16 | 
 17 |         float4 _MainTex_TexelSize;
 18 |         float  _SampleScale;
 19 |         float4 _ColorIntensity;
 20 |         float4 _Threshold; // x: threshold value (linear), y: threshold - knee, z: knee * 2, w: 0.25 / knee
 21 |         float4 _Params; // x: clamp, yzw: unused
 22 | 
 23 |         // ----------------------------------------------------------------------------------------
 24 |         // Prefilter
 25 | 
 26 |         half4 Prefilter(half4 color, float2 uv)
 27 |         {
 28 |             half autoExposure = SAMPLE_TEXTURE2D(_AutoExposureTex, sampler_AutoExposureTex, uv).r;
 29 |             color *= autoExposure;
 30 |             color = min(_Params.x, color); // clamp to max
 31 |             color = QuadraticThreshold(color, _Threshold.x, _Threshold.yzw);
 32 |             return color;
 33 |         }
 34 | 
 35 |         half4 FragPrefilter13(VaryingsDefault i) : SV_Target
 36 |         {
 37 |             half4 color = DownsampleBox13Tap(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, UnityStereoAdjustedTexelSize(_MainTex_TexelSize).xy);
 38 |             return Prefilter(SafeHDR(color), i.texcoord);
 39 |         }
 40 | 
 41 |         half4 FragPrefilter4(VaryingsDefault i) : SV_Target
 42 |         {
 43 |             half4 color = DownsampleBox4Tap(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, UnityStereoAdjustedTexelSize(_MainTex_TexelSize).xy);
 44 |             return Prefilter(SafeHDR(color), i.texcoord);
 45 |         }
 46 | 
 47 |         // ----------------------------------------------------------------------------------------
 48 |         // Downsample
 49 | 
 50 |         half4 FragDownsample13(VaryingsDefault i) : SV_Target
 51 |         {
 52 |             half4 color = DownsampleBox13Tap(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, UnityStereoAdjustedTexelSize(_MainTex_TexelSize).xy);
 53 |             return color;
 54 |         }
 55 | 
 56 |         half4 FragDownsample4(VaryingsDefault i) : SV_Target
 57 |         {
 58 |             half4 color = DownsampleBox4Tap(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, UnityStereoAdjustedTexelSize(_MainTex_TexelSize).xy);
 59 |             return color;
 60 |         }
 61 | 
 62 |         // ----------------------------------------------------------------------------------------
 63 |         // Upsample & combine
 64 | 
 65 |         half4 Combine(half4 bloom, float2 uv)
 66 |         {
 67 |             half4 color = SAMPLE_TEXTURE2D(_BloomTex, sampler_BloomTex, uv);
 68 |             return bloom + color;
 69 |         }
 70 | 
 71 |         half4 FragUpsampleTent(VaryingsDefault i) : SV_Target
 72 |         {
 73 |             half4 bloom = UpsampleTent(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, UnityStereoAdjustedTexelSize(_MainTex_TexelSize).xy, _SampleScale);
 74 |             return Combine(bloom, i.texcoordStereo);
 75 |         }
 76 | 
 77 |         half4 FragUpsampleBox(VaryingsDefault i) : SV_Target
 78 |         {
 79 |             half4 bloom = UpsampleBox(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, UnityStereoAdjustedTexelSize(_MainTex_TexelSize).xy, _SampleScale);
 80 |             return Combine(bloom, i.texcoordStereo);
 81 |         }
 82 | 
 83 |         // ----------------------------------------------------------------------------------------
 84 |         // Debug overlays
 85 | 
 86 |         half4 FragDebugOverlayThreshold(VaryingsDefault i) : SV_Target
 87 |         {
 88 |             half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
 89 |             return half4(Prefilter(SafeHDR(color), i.texcoord).rgb, 1.0);
 90 |         }
 91 | 
 92 |         half4 FragDebugOverlayTent(VaryingsDefault i) : SV_Target
 93 |         {
 94 |             half4 bloom = UpsampleTent(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, UnityStereoAdjustedTexelSize(_MainTex_TexelSize).xy, _SampleScale);
 95 |             return half4(bloom.rgb * _ColorIntensity.w * _ColorIntensity.rgb, 1.0);
 96 |         }
 97 | 
 98 |         half4 FragDebugOverlayBox(VaryingsDefault i) : SV_Target
 99 |         {
100 |             half4 bloom = UpsampleBox(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, UnityStereoAdjustedTexelSize(_MainTex_TexelSize).xy, _SampleScale);
101 |             return half4(bloom.rgb * _ColorIntensity.w * _ColorIntensity.rgb, 1.0);
102 |         }
103 | 
104 |     ENDHLSL
105 | 
106 |     SubShader
107 |     {
108 |         Cull Off ZWrite Off ZTest Always
109 | 
110 |         // 0: Prefilter 13 taps
111 |         Pass
112 |         {
113 |             HLSLPROGRAM
114 | 
115 |                 #pragma vertex VertDefault
116 |                 #pragma fragment FragPrefilter13
117 | 
118 |             ENDHLSL
119 |         }
120 | 
121 |         // 1: Prefilter 4 taps
122 |         Pass
123 |         {
124 |             HLSLPROGRAM
125 | 
126 |                 #pragma vertex VertDefault
127 |                 #pragma fragment FragPrefilter4
128 | 
129 |             ENDHLSL
130 |         }
131 | 
132 |         // 2: Downsample 13 taps
133 |         Pass
134 |         {
135 |             HLSLPROGRAM
136 | 
137 |                 #pragma vertex VertDefault
138 |                 #pragma fragment FragDownsample13
139 | 
140 |             ENDHLSL
141 |         }
142 | 
143 |         // 3: Downsample 4 taps
144 |         Pass
145 |         {
146 |             HLSLPROGRAM
147 | 
148 |                 #pragma vertex VertDefault
149 |                 #pragma fragment FragDownsample4
150 | 
151 |             ENDHLSL
152 |         }
153 | 
154 |         // 4: Upsample tent filter
155 |         Pass
156 |         {
157 |             HLSLPROGRAM
158 | 
159 |                 #pragma vertex VertDefault
160 |                 #pragma fragment FragUpsampleTent
161 | 
162 |             ENDHLSL
163 |         }
164 | 
165 |         // 5: Upsample box filter
166 |         Pass
167 |         {
168 |             HLSLPROGRAM
169 | 
170 |                 #pragma vertex VertDefault
171 |                 #pragma fragment FragUpsampleBox
172 | 
173 |             ENDHLSL
174 |         }
175 | 
176 |         // 6: Debug overlay (threshold)
177 |         Pass
178 |         {
179 |             HLSLPROGRAM
180 | 
181 |                 #pragma vertex VertDefault
182 |                 #pragma fragment FragDebugOverlayThreshold
183 | 
184 |             ENDHLSL
185 |         }
186 | 
187 |         // 7: Debug overlay (tent filter)
188 |         Pass
189 |         {
190 |             HLSLPROGRAM
191 | 
192 |                 #pragma vertex VertDefault
193 |                 #pragma fragment FragDebugOverlayTent
194 | 
195 |             ENDHLSL
196 |         }
197 | 
198 |         // 8: Debug overlay (box filter)
199 |         Pass
200 |         {
201 |             HLSLPROGRAM
202 | 
203 |                 #pragma vertex VertDefault
204 |                 #pragma fragment FragDebugOverlayBox
205 | 
206 |             ENDHLSL
207 |         }
208 |     }
209 | }
210 | 
211 | 212 | 213 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/Copy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 | Shader "Hidden/PostProcessing/Copy"
 6 | {
 7 |     HLSLINCLUDE
 8 | 
 9 |         #include "../StdLib.hlsl"
10 | 
11 |         TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
12 | 
13 |         float4 Frag(VaryingsDefault i) : SV_Target
14 |         {
15 |             float4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
16 |             return color;
17 |         }
18 | 
19 |         float4 FragKillNaN(VaryingsDefault i) : SV_Target
20 |         {
21 |             float4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
22 | 
23 |             if (AnyIsNan(color))
24 |             {
25 |                 color = (0.0).xxxx;
26 |             }
27 | 
28 |             return color;
29 |         }
30 | 
31 |     ENDHLSL
32 | 
33 |     SubShader
34 |     {
35 |         Cull Off ZWrite Off ZTest Always
36 | 
37 |         // 0 - Fullscreen triangle copy
38 |         Pass
39 |         {
40 |             HLSLPROGRAM
41 | 
42 |                 #pragma vertex VertDefault
43 |                 #pragma fragment Frag
44 | 
45 |             ENDHLSL
46 |         }
47 | 
48 |         // 1 - Fullscreen triangle copy + NaN killer
49 |         Pass
50 |         {
51 |             HLSLPROGRAM
52 | 
53 |                 #pragma vertex VertDefault
54 |                 #pragma fragment FragKillNaN
55 | 
56 |             ENDHLSL
57 |         }
58 |     }
59 | }
60 | 
61 | 62 | 63 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/CopyStd.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | Shader "Hidden/PostProcessing/CopyStd"
  6 | {
  7 |     //
  8 |     // We need this shader for the very first RT blit using the internal CommandBuffer.Blit() method
  9 |     // so it can handle AAResolve properly. We also need it to be separate because of VR and the
 10 |     // need for a Properties block. If we were to add this block to the other Copy shader it would
 11 |     // not allow us to manually bind _MainTex, thus breaking a few other things in the process...
 12 |     //
 13 | 
 14 |     Properties
 15 |     {
 16 |         _MainTex ("", 2D) = "white" {}
 17 |     }
 18 | 
 19 |     CGINCLUDE
 20 | 
 21 |         struct Attributes
 22 |         {
 23 |             float4 vertex : POSITION;
 24 |             float2 texcoord : TEXCOORD0;
 25 |         };
 26 | 
 27 |         struct Varyings
 28 |         {
 29 |             float4 vertex : SV_POSITION;
 30 |             float2 texcoord : TEXCOORD0;
 31 |         };
 32 | 
 33 |         sampler2D _MainTex;
 34 |         float4 _MainTex_ST;
 35 | 
 36 |         Varyings Vert(Attributes v)
 37 |         {
 38 |             Varyings o;
 39 |             o.vertex = float4(v.vertex.xy * 2.0 - 1.0, 0.0, 1.0);
 40 |             o.texcoord = v.texcoord;
 41 | 
 42 |             #if UNITY_UV_STARTS_AT_TOP
 43 |             o.texcoord = o.texcoord * float2(1.0, -1.0) + float2(0.0, 1.0);
 44 |             #endif
 45 | 
 46 |             o.texcoord = o.texcoord * _MainTex_ST.xy + _MainTex_ST.zw; // We need this for VR
 47 | 
 48 |             return o;
 49 |         }
 50 | 
 51 |         float4 Frag(Varyings i) : SV_Target
 52 |         {
 53 |             float4 color = tex2D(_MainTex, i.texcoord);
 54 |             return color;
 55 |         }
 56 | 
 57 |         //>>> We don't want to include StdLib.hlsl in this file so let's copy/paste what we need
 58 |         bool IsNan(float x)
 59 |         {
 60 |             return (x < 0.0 || x > 0.0 || x == 0.0) ? false : true;
 61 |         }
 62 | 
 63 |         bool AnyIsNan(float4 x)
 64 |         {
 65 |             return IsNan(x.x) || IsNan(x.y) || IsNan(x.z) || IsNan(x.w);
 66 |         }
 67 |         //<<<
 68 | 
 69 |         float4 FragKillNaN(Varyings i) : SV_Target
 70 |         {
 71 |             float4 color = tex2D(_MainTex, i.texcoord);
 72 | 
 73 |             if (AnyIsNan(color))
 74 |             {
 75 |                 color = (0.0).xxxx;
 76 |             }
 77 | 
 78 |             return color;
 79 |         }
 80 | 
 81 |     ENDCG
 82 | 
 83 |     SubShader
 84 |     {
 85 |         Cull Off ZWrite Off ZTest Always
 86 | 
 87 |         // 0 - Copy
 88 |         Pass
 89 |         {
 90 |             CGPROGRAM
 91 | 
 92 |                 #pragma vertex Vert
 93 |                 #pragma fragment Frag
 94 | 
 95 |             ENDCG
 96 |         }
 97 | 
 98 |         // 1 - Copy + NaN killer
 99 |         Pass
100 |         {
101 |             CGPROGRAM
102 | 
103 |                 #pragma vertex Vert
104 |                 #pragma fragment FragKillNaN
105 | 
106 |             ENDCG
107 |         }
108 |     }
109 | }
110 | 
111 | 112 | 113 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/CopyStdFromDoubleWide.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | Shader "Hidden/PostProcessing/CopyStdFromDoubleWide"
  6 | {
  7 |     //Blit from single-pass double-wide texture. Similar to CopyStd but with stereo texture as source
  8 |     //and samples from double-wide. Having separate shader is cleaner than multiple #if in the code.
  9 | 
 10 |     Properties
 11 |     {
 12 |         _MainTex ("", 2D) = "white" {}
 13 |     }
 14 | 
 15 |     CGINCLUDE
 16 | 
 17 |         struct Attributes
 18 |         {
 19 |             float4 vertex : POSITION;
 20 |             float2 texcoord : TEXCOORD0;
 21 |         };
 22 | 
 23 |         struct Varyings
 24 |         {
 25 |             float4 vertex : SV_POSITION;
 26 |             float2 texcoord : TEXCOORD0;
 27 |         };
 28 | 
 29 |         sampler2D _MainTex;
 30 |         float4 _UVScaleOffset;
 31 | 
 32 |         Varyings Vert(Attributes v)
 33 |         {
 34 |             Varyings o;
 35 |             o.vertex = float4(v.vertex.xy * 2.0 - 1.0, 0.0, 1.0);
 36 |             o.texcoord = v.texcoord;
 37 | 
 38 |             #if UNITY_UV_STARTS_AT_TOP
 39 |             o.texcoord = o.texcoord * float2(1.0, -1.0) + float2(0.0, 1.0);
 40 |             #endif
 41 | 
 42 |             o.texcoord = o.texcoord * _UVScaleOffset.xy + _UVScaleOffset.zw;
 43 | 
 44 |             return o;
 45 |         }
 46 | 
 47 |         float4 Frag(Varyings i) : SV_Target
 48 |         {
 49 |             float4 color = tex2D(_MainTex, i.texcoord);
 50 |             return color;
 51 |         }
 52 | 
 53 |         //>>> We don't want to include StdLib.hlsl in this file so let's copy/paste what we need
 54 |         bool IsNan(float x)
 55 |         {
 56 |             return (x < 0.0 || x > 0.0 || x == 0.0) ? false : true;
 57 |         }
 58 | 
 59 |         bool AnyIsNan(float4 x)
 60 |         {
 61 |             return IsNan(x.x) || IsNan(x.y) || IsNan(x.z) || IsNan(x.w);
 62 |         }
 63 |         //<<<
 64 | 
 65 |         float4 FragKillNaN(Varyings i) : SV_Target
 66 |         {
 67 |             float4 color = tex2D(_MainTex, i.texcoord);
 68 | 
 69 |             if (AnyIsNan(color))
 70 |             {
 71 |                 color = (0.0).xxxx;
 72 |             }
 73 | 
 74 |             return color;
 75 |         }
 76 | 
 77 |     ENDCG
 78 | 
 79 |     SubShader
 80 |     {
 81 |         Cull Off ZWrite Off ZTest Always
 82 | 
 83 |         // 0 - Copy
 84 |         Pass
 85 |         {
 86 |             CGPROGRAM
 87 | 
 88 |                 #pragma vertex Vert
 89 |                 #pragma fragment Frag
 90 | 
 91 |             ENDCG
 92 |         }
 93 | 
 94 |         // 1 - Copy + NaN killer
 95 |         Pass
 96 |         {
 97 |             CGPROGRAM
 98 | 
 99 |                 #pragma vertex Vert
100 |                 #pragma fragment FragKillNaN
101 | 
102 |             ENDCG
103 |         }
104 |     }
105 | }
106 | 
107 | 108 | 109 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/CopyStdFromTexArray.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | Shader "Hidden/PostProcessing/CopyStdFromTexArray"
  6 | {
  7 |     //Blit from texture array slice. Similar to CopyStd but with texture array as source
  8 |     //and sampling from texture array. Having separate shader is cleaner than multiple #if in the code.
  9 | 
 10 |     Properties
 11 |     {
 12 |         _MainTex ("", 2DArray) = "white" {}
 13 |     }
 14 | 
 15 |     CGINCLUDE
 16 |         #pragma target 3.5
 17 | 
 18 |         struct Attributes
 19 |         {
 20 |             float3 vertex : POSITION;
 21 |         };
 22 | 
 23 |         struct Varyings
 24 |         {
 25 |             float4 vertex : SV_POSITION;
 26 |             float3 texcoord : TEXCOORD0;
 27 |         };
 28 | 
 29 |         Texture2DArray _MainTex;
 30 |         SamplerState sampler_MainTex;
 31 |         float _DepthSlice;
 32 | 
 33 |         float2 TransformTriangleVertexToUV(float2 vertex)
 34 |         {
 35 |             float2 uv = (vertex + 1.0) * 0.5;
 36 |             return uv;
 37 |         }
 38 | 
 39 |         Varyings Vert(Attributes v)
 40 |         {
 41 |             Varyings o;
 42 |             o.vertex = float4(v.vertex.xy, 0.0, 1.0);
 43 |             o.texcoord.xy = TransformTriangleVertexToUV(v.vertex.xy);
 44 | 
 45 |             #if UNITY_UV_STARTS_AT_TOP
 46 |             o.texcoord.xy = o.texcoord.xy * float2(1.0, -1.0) + float2(0.0, 1.0);
 47 |             #endif
 48 |             o.texcoord.z = _DepthSlice;
 49 | 
 50 |             return o;
 51 |         }
 52 | 
 53 |         float4 Frag(Varyings i) : SV_Target
 54 |         {
 55 |             float4 color = _MainTex.Sample(sampler_MainTex, i.texcoord);
 56 |             return color;
 57 |         }
 58 | 
 59 |         bool IsNan(float x)
 60 |         {
 61 |             return (x < 0.0 || x > 0.0 || x == 0.0) ? false : true;
 62 |         }
 63 | 
 64 |         bool AnyIsNan(float4 x)
 65 |         {
 66 |             return IsNan(x.x) || IsNan(x.y) || IsNan(x.z) || IsNan(x.w);
 67 |         }
 68 | 
 69 |         float4 FragKillNaN(Varyings i) : SV_Target
 70 |         {
 71 |             float4 color = _MainTex.Sample(sampler_MainTex, i.texcoord);
 72 | 
 73 |             if (AnyIsNan(color))
 74 |             {
 75 |                 color = (0.0).xxxx;
 76 |             }
 77 | 
 78 |             return color;
 79 |         }
 80 | 
 81 |     ENDCG
 82 | 
 83 |     SubShader
 84 |     {
 85 |         Cull Off ZWrite Off ZTest Always
 86 | 
 87 |         // 0 - Copy
 88 |         Pass
 89 |         {
 90 |             CGPROGRAM
 91 | 
 92 |                 #pragma vertex Vert
 93 |                 #pragma fragment Frag
 94 | 
 95 |             ENDCG
 96 |         }
 97 | 
 98 |         // 0 - Copy + NaN killer
 99 |         Pass
100 |         {
101 |             CGPROGRAM
102 | 
103 |                 #pragma vertex Vert
104 |                 #pragma fragment FragKillNaN
105 | 
106 |             ENDCG
107 |         }
108 |     }
109 | }
110 | 
111 | 112 | 113 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/DeferredFog.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 | Shader "Hidden/PostProcessing/DeferredFog"
 6 | {
 7 |     HLSLINCLUDE
 8 | 
 9 |         #pragma multi_compile __ FOG_LINEAR FOG_EXP FOG_EXP2
10 |         #include "../StdLib.hlsl"
11 |         #include "Fog.hlsl"
12 | 
13 |         TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
14 |         TEXTURE2D_SAMPLER2D(_CameraDepthTexture, sampler_CameraDepthTexture);
15 | 
16 |         #define SKYBOX_THREASHOLD_VALUE 0.9999
17 | 
18 |         float4 Frag(VaryingsDefault i) : SV_Target
19 |         {
20 |             half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
21 | 
22 |             float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo);
23 |             depth = Linear01Depth(depth);
24 |             float dist = ComputeFogDistance(depth);
25 |             half fog = 1.0 - ComputeFog(dist);
26 | 
27 |             return lerp(color, _FogColor, fog);
28 |         }
29 | 
30 |         float4 FragExcludeSkybox(VaryingsDefault i) : SV_Target
31 |         {
32 |             half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
33 | 
34 |             float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo);
35 |             depth = Linear01Depth(depth);
36 |             float skybox = depth < SKYBOX_THREASHOLD_VALUE;
37 |             float dist = ComputeFogDistance(depth);
38 |             half fog = 1.0 - ComputeFog(dist);
39 | 
40 |             return lerp(color, _FogColor, fog * skybox);
41 |         }
42 | 
43 |     ENDHLSL
44 | 
45 |     SubShader
46 |     {
47 |         Cull Off ZWrite Off ZTest Always
48 | 
49 |         Pass
50 |         {
51 |             HLSLPROGRAM
52 | 
53 |                 #pragma vertex VertDefault
54 |                 #pragma fragment Frag
55 | 
56 |             ENDHLSL
57 |         }
58 | 
59 |         Pass
60 |         {
61 |             HLSLPROGRAM
62 | 
63 |                 #pragma vertex VertDefault
64 |                 #pragma fragment FragExcludeSkybox
65 | 
66 |             ENDHLSL
67 |         }
68 |     }
69 | }
70 | 
71 | 72 | 73 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/DepthOField.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | Shader "Hidden/PostProcessing/DepthOfField"
  6 | {
  7 |     // SubShader with SM 5.0 support
  8 |     // DX11+, OpenGL 4.3+, OpenGL ES 3.1+AEP, Vulkan, consoles
  9 |     // Gather intrinsics are used to reduce texture sample count.
 10 |     SubShader
 11 |     {
 12 |         Cull Off ZWrite Off ZTest Always
 13 | 
 14 |         Pass // 0
 15 |         {
 16 |             Name "CoC Calculation"
 17 | 
 18 |             HLSLPROGRAM
 19 |                 #pragma target 3.5
 20 |                 #pragma vertex VertDefault
 21 |                 #pragma fragment FragCoC
 22 |                 #include "DepthOfField.hlsl"
 23 |             ENDHLSL
 24 |         }
 25 | 
 26 |         Pass // 1
 27 |         {
 28 |             Name "CoC Temporal Filter"
 29 | 
 30 |             HLSLPROGRAM
 31 |                 #pragma target 5.0
 32 |                 #pragma vertex VertDefault
 33 |                 #pragma fragment FragTempFilter
 34 |                 #include "DepthOfField.hlsl"
 35 |             ENDHLSL
 36 |         }
 37 | 
 38 |         Pass // 2
 39 |         {
 40 |             Name "Downsample and Prefilter"
 41 | 
 42 |             HLSLPROGRAM
 43 |                 #pragma target 5.0
 44 |                 #pragma vertex VertDefault
 45 |                 #pragma fragment FragPrefilter
 46 |                 #include "DepthOfField.hlsl"
 47 |             ENDHLSL
 48 |         }
 49 | 
 50 |         Pass // 3
 51 |         {
 52 |             Name "Bokeh Filter (small)"
 53 | 
 54 |             HLSLPROGRAM
 55 |                 #pragma target 3.5
 56 |                 #pragma vertex VertDefault
 57 |                 #pragma fragment FragBlur
 58 |                 #define KERNEL_SMALL
 59 |                 #include "DepthOfField.hlsl"
 60 |             ENDHLSL
 61 |         }
 62 | 
 63 |         Pass // 4
 64 |         {
 65 |             Name "Bokeh Filter (medium)"
 66 | 
 67 |             HLSLPROGRAM
 68 |                 #pragma target 3.5
 69 |                 #pragma vertex VertDefault
 70 |                 #pragma fragment FragBlur
 71 |                 #define KERNEL_MEDIUM
 72 |                 #include "DepthOfField.hlsl"
 73 |             ENDHLSL
 74 |         }
 75 | 
 76 |         Pass // 5
 77 |         {
 78 |             Name "Bokeh Filter (large)"
 79 | 
 80 |             HLSLPROGRAM
 81 |                 #pragma target 3.5
 82 |                 #pragma vertex VertDefault
 83 |                 #pragma fragment FragBlur
 84 |                 #define KERNEL_LARGE
 85 |                 #include "DepthOfField.hlsl"
 86 |             ENDHLSL
 87 |         }
 88 | 
 89 |         Pass // 6
 90 |         {
 91 |             Name "Bokeh Filter (very large)"
 92 | 
 93 |             HLSLPROGRAM
 94 |                 #pragma target 3.5
 95 |                 #pragma vertex VertDefault
 96 |                 #pragma fragment FragBlur
 97 |                 #define KERNEL_VERYLARGE
 98 |                 #include "DepthOfField.hlsl"
 99 |             ENDHLSL
100 |         }
101 | 
102 |         Pass // 7
103 |         {
104 |             Name "Postfilter"
105 | 
106 |             HLSLPROGRAM
107 |                 #pragma target 3.5
108 |                 #pragma vertex VertDefault
109 |                 #pragma fragment FragPostBlur
110 |                 #include "DepthOfField.hlsl"
111 |             ENDHLSL
112 |         }
113 | 
114 |         Pass // 8
115 |         {
116 |             Name "Combine"
117 | 
118 |             HLSLPROGRAM
119 |                 #pragma target 3.5
120 |                 #pragma vertex VertDefault
121 |                 #pragma fragment FragCombine
122 |                 #include "DepthOfField.hlsl"
123 |             ENDHLSL
124 |         }
125 | 
126 |         Pass // 9
127 |         {
128 |             Name "Debug Overlay"
129 | 
130 |             HLSLPROGRAM
131 |                 #pragma target 3.5
132 |                 #pragma vertex VertDefault
133 |                 #pragma fragment FragDebugOverlay
134 |                 #include "DepthOfField.hlsl"
135 |             ENDHLSL
136 |         }
137 |     }
138 | 
139 |     // Fallback SubShader with SM 3.5
140 |     // DX11+, OpenGL 3.2+, OpenGL ES 3+, Metal, Vulkan, consoles
141 |     SubShader
142 |     {
143 |         Cull Off ZWrite Off ZTest Always
144 | 
145 |         Pass // 0
146 |         {
147 |             Name "CoC Calculation"
148 | 
149 |             HLSLPROGRAM
150 |                 #pragma target 3.5
151 |                 #pragma vertex VertDefault
152 |                 #pragma fragment FragCoC
153 |                 #include "DepthOfField.hlsl"
154 |             ENDHLSL
155 |         }
156 | 
157 |         Pass // 1
158 |         {
159 |             Name "CoC Temporal Filter"
160 | 
161 |             HLSLPROGRAM
162 |                 #pragma target 3.5
163 |                 #pragma vertex VertDefault
164 |                 #pragma fragment FragTempFilter
165 |                 #include "DepthOfField.hlsl"
166 |             ENDHLSL
167 |         }
168 | 
169 |         Pass // 2
170 |         {
171 |             Name "Downsample and Prefilter"
172 | 
173 |             HLSLPROGRAM
174 |                 #pragma target 3.5
175 |                 #pragma vertex VertDefault
176 |                 #pragma fragment FragPrefilter
177 |                 #include "DepthOfField.hlsl"
178 |             ENDHLSL
179 |         }
180 | 
181 |         Pass // 3
182 |         {
183 |             Name "Bokeh Filter (small)"
184 | 
185 |             HLSLPROGRAM
186 |                 #pragma target 3.5
187 |                 #pragma vertex VertDefault
188 |                 #pragma fragment FragBlur
189 |                 #define KERNEL_SMALL
190 |                 #include "DepthOfField.hlsl"
191 |             ENDHLSL
192 |         }
193 | 
194 |         Pass // 4
195 |         {
196 |             Name "Bokeh Filter (medium)"
197 | 
198 |             HLSLPROGRAM
199 |                 #pragma target 3.5
200 |                 #pragma vertex VertDefault
201 |                 #pragma fragment FragBlur
202 |                 #define KERNEL_MEDIUM
203 |                 #include "DepthOfField.hlsl"
204 |             ENDHLSL
205 |         }
206 | 
207 |         Pass // 5
208 |         {
209 |             Name "Bokeh Filter (large)"
210 | 
211 |             HLSLPROGRAM
212 |                 #pragma target 3.5
213 |                 #pragma vertex VertDefault
214 |                 #pragma fragment FragBlur
215 |                 #define KERNEL_LARGE
216 |                 #include "DepthOfField.hlsl"
217 |             ENDHLSL
218 |         }
219 | 
220 |         Pass // 6
221 |         {
222 |             Name "Bokeh Filter (very large)"
223 | 
224 |             HLSLPROGRAM
225 |                 #pragma target 3.5
226 |                 #pragma vertex VertDefault
227 |                 #pragma fragment FragBlur
228 |                 #define KERNEL_VERYLARGE
229 |                 #include "DepthOfField.hlsl"
230 |             ENDHLSL
231 |         }
232 | 
233 |         Pass // 7
234 |         {
235 |             Name "Postfilter"
236 | 
237 |             HLSLPROGRAM
238 |                 #pragma target 3.5
239 |                 #pragma vertex VertDefault
240 |                 #pragma fragment FragPostBlur
241 |                 #include "DepthOfField.hlsl"
242 |             ENDHLSL
243 |         }
244 | 
245 |         Pass // 8
246 |         {
247 |             Name "Combine"
248 | 
249 |             HLSLPROGRAM
250 |                 #pragma target 3.5
251 |                 #pragma vertex VertDefault
252 |                 #pragma fragment FragCombine
253 |                 #include "DepthOfField.hlsl"
254 |             ENDHLSL
255 |         }
256 | 
257 |         Pass // 9
258 |         {
259 |             Name "Debug Overlay"
260 | 
261 |             HLSLPROGRAM
262 |                 #pragma target 3.5
263 |                 #pragma vertex VertDefault
264 |                 #pragma fragment FragDebugOverlay
265 |                 #include "DepthOfField.hlsl"
266 |             ENDHLSL
267 |         }
268 |     }
269 | }
270 | 
271 | 272 | 273 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/DiscardAlpha.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 | Shader "Hidden/PostProcessing/DiscardAlpha"
 6 | {
 7 |     HLSLINCLUDE
 8 | 
 9 |         #include "../StdLib.hlsl"
10 | 
11 |         TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
12 | 
13 |         float4 Frag(VaryingsDefault i) : SV_Target
14 |         {
15 |             float4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord);
16 |             return float4(color.rgb, 1.0);
17 |         }
18 | 
19 |     ENDHLSL
20 | 
21 |     SubShader
22 |     {
23 |         Cull Off ZWrite Off ZTest Always
24 | 
25 |         Pass
26 |         {
27 |             HLSLPROGRAM
28 | 
29 |                 #pragma vertex VertDefault
30 |                 #pragma fragment Frag
31 | 
32 |             ENDHLSL
33 |         }
34 |     }
35 | }
36 | 
37 | 38 | 39 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/DiskKernels.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | #ifndef UNITY_POSTFX_DISK_KERNELS
  6 | #define UNITY_POSTFX_DISK_KERNELS
  7 | 
  8 | #if !defined(KERNEL_SMALL) && !defined(KERNEL_MEDIUM) && \
  9 |     !defined(KERNEL_LARGE) && !defined(KERNEL_VERYLARGE)
 10 | 
 11 | static const int kSampleCount = 1;
 12 | static const float2 kDiskKernel[1] = { float2(0, 0) };
 13 | 
 14 | #endif
 15 | 
 16 | #if defined(KERNEL_SMALL)
 17 | 
 18 | // rings = 2
 19 | // points per ring = 5
 20 | static const int kSampleCount = 16;
 21 | static const float2 kDiskKernel[kSampleCount] = {
 22 |     float2(0,0),
 23 |     float2(0.54545456,0),
 24 |     float2(0.16855472,0.5187581),
 25 |     float2(-0.44128203,0.3206101),
 26 |     float2(-0.44128197,-0.3206102),
 27 |     float2(0.1685548,-0.5187581),
 28 |     float2(1,0),
 29 |     float2(0.809017,0.58778524),
 30 |     float2(0.30901697,0.95105654),
 31 |     float2(-0.30901703,0.9510565),
 32 |     float2(-0.80901706,0.5877852),
 33 |     float2(-1,0),
 34 |     float2(-0.80901694,-0.58778536),
 35 |     float2(-0.30901664,-0.9510566),
 36 |     float2(0.30901712,-0.9510565),
 37 |     float2(0.80901694,-0.5877853),
 38 | };
 39 | 
 40 | #endif
 41 | 
 42 | #if defined(KERNEL_MEDIUM)
 43 | 
 44 | // rings = 3
 45 | // points per ring = 7
 46 | static const int kSampleCount = 22;
 47 | static const float2 kDiskKernel[kSampleCount] = {
 48 |     float2(0,0),
 49 |     float2(0.53333336,0),
 50 |     float2(0.3325279,0.4169768),
 51 |     float2(-0.11867785,0.5199616),
 52 |     float2(-0.48051673,0.2314047),
 53 |     float2(-0.48051673,-0.23140468),
 54 |     float2(-0.11867763,-0.51996166),
 55 |     float2(0.33252785,-0.4169769),
 56 |     float2(1,0),
 57 |     float2(0.90096885,0.43388376),
 58 |     float2(0.6234898,0.7818315),
 59 |     float2(0.22252098,0.9749279),
 60 |     float2(-0.22252095,0.9749279),
 61 |     float2(-0.62349,0.7818314),
 62 |     float2(-0.90096885,0.43388382),
 63 |     float2(-1,0),
 64 |     float2(-0.90096885,-0.43388376),
 65 |     float2(-0.6234896,-0.7818316),
 66 |     float2(-0.22252055,-0.974928),
 67 |     float2(0.2225215,-0.9749278),
 68 |     float2(0.6234897,-0.7818316),
 69 |     float2(0.90096885,-0.43388376),
 70 | };
 71 | 
 72 | #endif
 73 | 
 74 | #if defined(KERNEL_LARGE)
 75 | 
 76 | // rings = 4
 77 | // points per ring = 7
 78 | static const int kSampleCount = 43;
 79 | static const float2 kDiskKernel[kSampleCount] = {
 80 |     float2(0,0),
 81 |     float2(0.36363637,0),
 82 |     float2(0.22672357,0.28430238),
 83 |     float2(-0.08091671,0.35451925),
 84 |     float2(-0.32762504,0.15777594),
 85 |     float2(-0.32762504,-0.15777591),
 86 |     float2(-0.08091656,-0.35451928),
 87 |     float2(0.22672352,-0.2843024),
 88 |     float2(0.6818182,0),
 89 |     float2(0.614297,0.29582983),
 90 |     float2(0.42510667,0.5330669),
 91 |     float2(0.15171885,0.6647236),
 92 |     float2(-0.15171883,0.6647236),
 93 |     float2(-0.4251068,0.53306687),
 94 |     float2(-0.614297,0.29582986),
 95 |     float2(-0.6818182,0),
 96 |     float2(-0.614297,-0.29582983),
 97 |     float2(-0.42510656,-0.53306705),
 98 |     float2(-0.15171856,-0.66472363),
 99 |     float2(0.1517192,-0.6647235),
100 |     float2(0.4251066,-0.53306705),
101 |     float2(0.614297,-0.29582983),
102 |     float2(1,0),
103 |     float2(0.9555728,0.2947552),
104 |     float2(0.82623875,0.5633201),
105 |     float2(0.6234898,0.7818315),
106 |     float2(0.36534098,0.93087375),
107 |     float2(0.07473,0.9972038),
108 |     float2(-0.22252095,0.9749279),
109 |     float2(-0.50000006,0.8660254),
110 |     float2(-0.73305196,0.6801727),
111 |     float2(-0.90096885,0.43388382),
112 |     float2(-0.98883086,0.14904208),
113 |     float2(-0.9888308,-0.14904249),
114 |     float2(-0.90096885,-0.43388376),
115 |     float2(-0.73305184,-0.6801728),
116 |     float2(-0.4999999,-0.86602545),
117 |     float2(-0.222521,-0.9749279),
118 |     float2(0.07473029,-0.99720377),
119 |     float2(0.36534148,-0.9308736),
120 |     float2(0.6234897,-0.7818316),
121 |     float2(0.8262388,-0.56332),
122 |     float2(0.9555729,-0.29475483),
123 | };
124 | 
125 | #endif
126 | 
127 | #if defined(KERNEL_VERYLARGE)
128 | 
129 | // rings = 5
130 | // points per ring = 7
131 | static const int kSampleCount = 71;
132 | static const float2 kDiskKernel[kSampleCount] = {
133 |     float2(0,0),
134 |     float2(0.2758621,0),
135 |     float2(0.1719972,0.21567768),
136 |     float2(-0.061385095,0.26894566),
137 |     float2(-0.24854316,0.1196921),
138 |     float2(-0.24854316,-0.11969208),
139 |     float2(-0.061384983,-0.2689457),
140 |     float2(0.17199717,-0.21567771),
141 |     float2(0.51724136,0),
142 |     float2(0.46601835,0.22442262),
143 |     float2(0.32249472,0.40439558),
144 |     float2(0.11509705,0.50427306),
145 |     float2(-0.11509704,0.50427306),
146 |     float2(-0.3224948,0.40439552),
147 |     float2(-0.46601835,0.22442265),
148 |     float2(-0.51724136,0),
149 |     float2(-0.46601835,-0.22442262),
150 |     float2(-0.32249463,-0.40439564),
151 |     float2(-0.11509683,-0.5042731),
152 |     float2(0.11509732,-0.504273),
153 |     float2(0.32249466,-0.40439564),
154 |     float2(0.46601835,-0.22442262),
155 |     float2(0.7586207,0),
156 |     float2(0.7249173,0.22360738),
157 |     float2(0.6268018,0.4273463),
158 |     float2(0.47299224,0.59311354),
159 |     float2(0.27715522,0.7061801),
160 |     float2(0.056691725,0.75649947),
161 |     float2(-0.168809,0.7396005),
162 |     float2(-0.3793104,0.65698475),
163 |     float2(-0.55610836,0.51599306),
164 |     float2(-0.6834936,0.32915324),
165 |     float2(-0.7501475,0.113066405),
166 |     float2(-0.7501475,-0.11306671),
167 |     float2(-0.6834936,-0.32915318),
168 |     float2(-0.5561083,-0.5159932),
169 |     float2(-0.37931028,-0.6569848),
170 |     float2(-0.16880904,-0.7396005),
171 |     float2(0.056691945,-0.7564994),
172 |     float2(0.2771556,-0.7061799),
173 |     float2(0.47299215,-0.59311366),
174 |     float2(0.62680185,-0.4273462),
175 |     float2(0.72491735,-0.22360711),
176 |     float2(1,0),
177 |     float2(0.9749279,0.22252093),
178 |     float2(0.90096885,0.43388376),
179 |     float2(0.7818315,0.6234898),
180 |     float2(0.6234898,0.7818315),
181 |     float2(0.43388364,0.9009689),
182 |     float2(0.22252098,0.9749279),
183 |     float2(0,1),
184 |     float2(-0.22252095,0.9749279),
185 |     float2(-0.43388385,0.90096885),
186 |     float2(-0.62349,0.7818314),
187 |     float2(-0.7818317,0.62348956),
188 |     float2(-0.90096885,0.43388382),
189 |     float2(-0.9749279,0.22252093),
190 |     float2(-1,0),
191 |     float2(-0.9749279,-0.22252087),
192 |     float2(-0.90096885,-0.43388376),
193 |     float2(-0.7818314,-0.6234899),
194 |     float2(-0.6234896,-0.7818316),
195 |     float2(-0.43388346,-0.900969),
196 |     float2(-0.22252055,-0.974928),
197 |     float2(0,-1),
198 |     float2(0.2225215,-0.9749278),
199 |     float2(0.4338835,-0.90096897),
200 |     float2(0.6234897,-0.7818316),
201 |     float2(0.78183144,-0.62348986),
202 |     float2(0.90096885,-0.43388376),
203 |     float2(0.9749279,-0.22252086),
204 | };
205 | 
206 | #endif
207 | 
208 | #endif // UNITY_POSTFX_DISK_KERNELS
209 | 
210 | 211 | 212 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/FinalPass.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | Shader "Hidden/PostProcessing/FinalPass"
  6 | {
  7 |     HLSLINCLUDE
  8 | 
  9 |         #pragma multi_compile __ FXAA FXAA_LOW
 10 |         #pragma multi_compile __ FXAA_KEEP_ALPHA
 11 | 
 12 |         #pragma vertex VertUVTransform
 13 |         #pragma fragment Frag
 14 | 
 15 |         #include "../StdLib.hlsl"
 16 |         #include "../Colors.hlsl"
 17 |         #include "Dithering.hlsl"
 18 | 
 19 |         // PS3 and XBOX360 aren't supported in Unity anymore, only use the PC variant
 20 |         #define FXAA_PC 1
 21 | 
 22 |         #if FXAA_KEEP_ALPHA
 23 |             // Luma hasn't been encoded in alpha
 24 |             #define FXAA_GREEN_AS_LUMA 1
 25 |         #else
 26 |             // Luma is encoded in alpha after the first Uber pass
 27 |             #define FXAA_GREEN_AS_LUMA 0
 28 |         #endif
 29 | 
 30 |         #if FXAA_LOW
 31 |             #define FXAA_QUALITY__PRESET 12
 32 |             #define FXAA_QUALITY_SUBPIX 1.0
 33 |             #define FXAA_QUALITY_EDGE_THRESHOLD 0.166
 34 |             #define FXAA_QUALITY_EDGE_THRESHOLD_MIN 0.0625
 35 |         #else
 36 |             #define FXAA_QUALITY__PRESET 28
 37 |             #define FXAA_QUALITY_SUBPIX 1.0
 38 |             #define FXAA_QUALITY_EDGE_THRESHOLD 0.063
 39 |             #define FXAA_QUALITY_EDGE_THRESHOLD_MIN 0.0312
 40 |         #endif
 41 | 
 42 |         #include "FastApproximateAntialiasing.hlsl"
 43 | 
 44 |         TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
 45 |         float4 _MainTex_TexelSize;
 46 | 
 47 |         float4 Frag(VaryingsDefault i) : SV_Target
 48 |         {
 49 |             half4 color = 0.0;
 50 | 
 51 |             // Fast Approximate Anti-aliasing
 52 |             #if FXAA || FXAA_LOW
 53 |             {
 54 |                 #if FXAA_HLSL_4 || FXAA_HLSL_5
 55 |                     FxaaTex mainTex;
 56 |                     mainTex.tex = _MainTex;
 57 |                     mainTex.smpl = sampler_MainTex;
 58 |                 #else
 59 |                     FxaaTex mainTex = _MainTex;
 60 |                 #endif
 61 | 
 62 |                 color = FxaaPixelShader(
 63 |                     i.texcoord,                 // pos
 64 |                     0.0,                        // fxaaConsolePosPos (unused)
 65 |                     mainTex,                    // tex
 66 |                     mainTex,                    // fxaaConsole360TexExpBiasNegOne (unused)
 67 |                     mainTex,                    // fxaaConsole360TexExpBiasNegTwo (unused)
 68 |                     _MainTex_TexelSize.xy,      // fxaaQualityRcpFrame
 69 |                     0.0,                        // fxaaConsoleRcpFrameOpt (unused)
 70 |                     0.0,                        // fxaaConsoleRcpFrameOpt2 (unused)
 71 |                     0.0,                        // fxaaConsole360RcpFrameOpt2 (unused)
 72 |                     FXAA_QUALITY_SUBPIX,
 73 |                     FXAA_QUALITY_EDGE_THRESHOLD,
 74 |                     FXAA_QUALITY_EDGE_THRESHOLD_MIN,
 75 |                     0.0,                        // fxaaConsoleEdgeSharpness (unused)
 76 |                     0.0,                        // fxaaConsoleEdgeThreshold (unused)
 77 |                     0.0,                        // fxaaConsoleEdgeThresholdMin (unused)
 78 |                     0.0                         // fxaaConsole360ConstDir (unused)
 79 |                 );
 80 | 
 81 |                 #if FXAA_KEEP_ALPHA
 82 |                 {
 83 |                     color.a = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo).a;
 84 |                 }
 85 |                 #endif
 86 |             }
 87 |             #else
 88 |             {
 89 |                 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
 90 |             }
 91 |             #endif
 92 | 
 93 |             color.rgb = Dither(color.rgb, i.texcoord);
 94 |             return color;
 95 |         }
 96 | 
 97 |     ENDHLSL
 98 | 
 99 |     SubShader
100 |     {
101 |         Cull Off ZWrite Off ZTest Always
102 | 
103 |         Pass
104 |         {
105 |             HLSLPROGRAM
106 |                 #pragma exclude_renderers gles vulkan switch
107 | 
108 |                 #pragma multi_compile __ STEREO_INSTANCING_ENABLED STEREO_DOUBLEWIDE_TARGET
109 |                 #pragma target 5.0
110 | 
111 |             ENDHLSL
112 |         }
113 |     }
114 | 
115 |     SubShader
116 |     {
117 |         Cull Off ZWrite Off ZTest Always
118 | 
119 |         Pass
120 |         {
121 |             HLSLPROGRAM
122 |                 #pragma exclude_renderers gles vulkan switch
123 | 
124 |                 #pragma multi_compile __ STEREO_INSTANCING_ENABLED STEREO_DOUBLEWIDE_TARGET
125 |                 #pragma target 3.0
126 | 
127 |             ENDHLSL
128 |         }
129 |     }
130 | 
131 |     SubShader
132 |     {
133 |         Cull Off ZWrite Off ZTest Always
134 | 
135 |         Pass
136 |         {
137 |             HLSLPROGRAM
138 |                 #pragma only_renderers gles
139 | 
140 |                 #pragma multi_compile __ STEREO_INSTANCING_ENABLED STEREO_DOUBLEWIDE_TARGET
141 |                 #pragma target es3.0
142 | 
143 |             ENDHLSL
144 |         }
145 |     }
146 | 
147 |     SubShader
148 |     {
149 |         Cull Off ZWrite Off ZTest Always
150 | 
151 |         Pass
152 |         {
153 |             HLSLPROGRAM
154 |                 #pragma only_renderers gles vulkan switch
155 | 
156 |                 #pragma multi_compile __ STEREO_DOUBLEWIDE_TARGET //not supporting STEREO_INSTANCING_ENABLED
157 |             ENDHLSL
158 |         }
159 |     }
160 | }
161 | 
162 | 163 | 164 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/Fog.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 | #ifndef UNITY_POSTFX_FOG
 6 | #define UNITY_POSTFX_FOG
 7 | 
 8 | half4 _FogColor;
 9 | float3 _FogParams;
10 | 
11 | #define FOG_DENSITY _FogParams.x
12 | #define FOG_START _FogParams.y
13 | #define FOG_END _FogParams.z
14 | 
15 | half ComputeFog(float z)
16 | {
17 |     half fog = 0.0;
18 | #if FOG_LINEAR
19 |     fog = (FOG_END - z) / (FOG_END - FOG_START);
20 | #elif FOG_EXP
21 |     fog = exp2(-FOG_DENSITY * z);
22 | #else // FOG_EXP2
23 |     fog = FOG_DENSITY * z;
24 |     fog = exp2(-fog * fog);
25 | #endif
26 |     return saturate(fog);
27 | }
28 | 
29 | float ComputeFogDistance(float depth)
30 | {
31 |     float dist = depth * _ProjectionParams.z;
32 |     dist -= _ProjectionParams.y;
33 |     return dist;
34 | }
35 | 
36 | #endif // UNITY_POSTFX_FOG
37 | 
38 | 39 | 40 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/GrainBaker.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | Shader "Hidden/PostProcessing/GrainBaker"
  6 | {
  7 |     HLSLINCLUDE
  8 | 
  9 |         #pragma exclude_renderers d3d11_9x
 10 |         #pragma target 3.0
 11 |         #include "../StdLib.hlsl"
 12 | 
 13 |         float _Phase;
 14 |         float3 _NoiseParameters;
 15 | 
 16 |         // Implementation based on Timothy Lottes' "Large Grain"
 17 |         // Reference code: https://www.shadertoy.com/view/4sSXDW
 18 |         // Other article of interest: http://devlog-martinsh.blogspot.fr/2013/05/image-imperfections-and-film-grain-post.html
 19 |         float Noise(float2 n, float x)
 20 |         {
 21 |             n += x;
 22 |             return frac(sin(dot(n.xy, _NoiseParameters.xy)) * _NoiseParameters.z);
 23 |         }
 24 | 
 25 |         float Step1(float2 uv, float n)
 26 |         {
 27 |             float b = 2.0, c = -12.0;
 28 |             return (1.0 / (4.0 + b * 4.0 + abs(c))) * (
 29 |                 Noise(uv + float2(-1.0, -1.0), n) +
 30 |                 Noise(uv + float2( 0.0, -1.0), n) * b +
 31 |                 Noise(uv + float2( 1.0, -1.0), n) +
 32 |                 Noise(uv + float2(-1.0,  0.0), n) * b +
 33 |                 Noise(uv + float2( 0.0,  0.0), n) * c +
 34 |                 Noise(uv + float2( 1.0,  0.0), n) * b +
 35 |                 Noise(uv + float2(-1.0,  1.0), n) +
 36 |                 Noise(uv + float2( 0.0,  1.0), n) * b +
 37 |                 Noise(uv + float2( 1.0,  1.0), n)
 38 |             );
 39 |         }
 40 | 
 41 |         float Step2(float2 uv, float n)
 42 |         {
 43 |             float b = 2.0, c = 4.0;
 44 |             return (1.0 / (4.0 + b * 4.0 + abs(c))) * (
 45 |                 Step1(uv + float2(-1.0, -1.0), n) +
 46 |                 Step1(uv + float2( 0.0, -1.0), n) * b +
 47 |                 Step1(uv + float2( 1.0, -1.0), n) +
 48 |                 Step1(uv + float2(-1.0,  0.0), n) * b +
 49 |                 Step1(uv + float2( 0.0,  0.0), n) * c +
 50 |                 Step1(uv + float2( 1.0,  0.0), n) * b +
 51 |                 Step1(uv + float2(-1.0,  1.0), n) +
 52 |                 Step1(uv + float2( 0.0,  1.0), n) * b +
 53 |                 Step1(uv + float2( 1.0,  1.0), n)
 54 |             );
 55 |         }
 56 | 
 57 |         float Step3BW(float2 uv)
 58 |         {
 59 |             return Step2(uv, frac(_Phase));
 60 |         }
 61 | 
 62 |         float3 Step3(float2 uv)
 63 |         {
 64 |             float a = Step2(uv, 0.07 * frac(_Phase));
 65 |             float b = Step2(uv, 0.11 * frac(_Phase));
 66 |             float c = Step2(uv, 0.13 * frac(_Phase));
 67 |             return float3(a, b, c);
 68 |         }
 69 | 
 70 |         float4 FragGrain(VaryingsDefault i) : SV_Target
 71 |         {
 72 |             float grain = Step3BW(i.texcoordStereo * float2(128.0, 128.0));
 73 |             return float4(grain.xxx, 1.0);
 74 |         }
 75 | 
 76 |         float4 FragGrainColored(VaryingsDefault i) : SV_Target
 77 |         {
 78 |             float3 grain = Step3(i.texcoordStereo * float2(128.0, 128.0));
 79 |             return float4(grain, 1.0);
 80 |         }
 81 | 
 82 |     ENDHLSL
 83 | 
 84 |     SubShader
 85 |     {
 86 |         Cull Off ZWrite Off ZTest Always
 87 | 
 88 |         Pass
 89 |         {
 90 |             HLSLPROGRAM
 91 | 
 92 |                 #pragma vertex VertDefault
 93 |                 #pragma fragment FragGrain
 94 | 
 95 |             ENDHLSL
 96 |         }
 97 | 
 98 |         Pass
 99 |         {
100 |             HLSLPROGRAM
101 | 
102 |                 #pragma vertex VertDefault
103 |                 #pragma fragment FragGrainColored
104 | 
105 |             ENDHLSL
106 |         }
107 |     }
108 | }
109 | 
110 | 111 | 112 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/MultiScaleVO.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | Shader "Hidden/PostProcessing/MultiScaleVO"
  6 | {
  7 |     HLSLINCLUDE
  8 | 
  9 |         #pragma exclude_renderers gles gles3 d3d11_9x
 10 |         #pragma target 4.5
 11 | 
 12 |         #include "../StdLib.hlsl"
 13 |         #include "Fog.hlsl"
 14 | 
 15 |         TEXTURE2D_SAMPLER2D(_CameraDepthTexture, sampler_CameraDepthTexture);
 16 |         TEXTURE2D_SAMPLER2D(_MSVOcclusionTexture, sampler_MSVOcclusionTexture);
 17 |         float3 _AOColor;
 18 | 
 19 |     ENDHLSL
 20 | 
 21 |     SubShader
 22 |     {
 23 |         Cull Off ZWrite Off ZTest Always
 24 | 
 25 |         // 0 - Depth copy with procedural draw
 26 |         Pass
 27 |         {
 28 |             HLSLPROGRAM
 29 | 
 30 |                 #pragma vertex VertDefault
 31 |                 #pragma fragment Frag
 32 | 
 33 |                 float4 Frag(VaryingsDefault i) : SV_Target
 34 |                 {
 35 |                     return SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo);
 36 |                 }
 37 | 
 38 |             ENDHLSL
 39 |         }
 40 | 
 41 |         // 1 - Composite to G-buffer with procedural draw
 42 |         Pass
 43 |         {
 44 |             Blend Zero OneMinusSrcColor, Zero OneMinusSrcAlpha
 45 | 
 46 |             HLSLPROGRAM
 47 | 
 48 |                 #pragma vertex VertDefault
 49 |                 #pragma fragment Frag
 50 | 
 51 |                 struct Output
 52 |                 {
 53 |                     float4 gbuffer0 : SV_Target0;
 54 |                     float4 gbuffer3 : SV_Target1;
 55 |                 };
 56 | 
 57 |                 Output Frag(VaryingsDefault i)
 58 |                 {
 59 |                     float ao = 1.0 - SAMPLE_TEXTURE2D(_MSVOcclusionTexture, sampler_MSVOcclusionTexture, i.texcoordStereo).r;
 60 |                     Output o;
 61 |                     o.gbuffer0 = float4(0.0, 0.0, 0.0, ao);
 62 |                     o.gbuffer3 = float4(ao * _AOColor, 0.0);
 63 |                     return o;
 64 |                 }
 65 | 
 66 |             ENDHLSL
 67 |         }
 68 | 
 69 |         // 2 - Composite to the frame buffer
 70 |         Pass
 71 |         {
 72 |             Blend Zero OneMinusSrcColor, Zero OneMinusSrcAlpha
 73 | 
 74 |             HLSLPROGRAM
 75 | 
 76 |                 #pragma multi_compile _ APPLY_FORWARD_FOG
 77 |                 #pragma multi_compile _ FOG_LINEAR FOG_EXP FOG_EXP2
 78 |                 #pragma vertex VertDefault
 79 |                 #pragma fragment Frag
 80 | 
 81 |                 float4 Frag(VaryingsDefault i) : SV_Target
 82 |                 {
 83 |                     half ao = 1.0 - SAMPLE_TEXTURE2D(_MSVOcclusionTexture, sampler_MSVOcclusionTexture, i.texcoordStereo).r;
 84 | 
 85 |                     // Apply fog when enabled (forward-only)
 86 |                 #if (APPLY_FORWARD_FOG)
 87 |                     float d = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo));
 88 |                     d = ComputeFogDistance(d);
 89 |                     ao *= ComputeFog(d);
 90 |                 #endif
 91 | 
 92 |                     return float4(ao * _AOColor, 0.0);
 93 |                 }
 94 | 
 95 |             ENDHLSL
 96 |         }
 97 | 
 98 |         // 3 - Debug overlay
 99 |         Pass
100 |         {
101 |             HLSLPROGRAM
102 | 
103 |                 #pragma vertex VertDefault
104 |                 #pragma fragment Frag
105 | 
106 |                 float4 Frag(VaryingsDefault i) : SV_Target
107 |                 {
108 |                     half ao = SAMPLE_TEXTURE2D(_MSVOcclusionTexture, sampler_MSVOcclusionTexture, i.texcoordStereo).r;
109 |                     return float4(ao.rrr, 1.0);
110 |                 }
111 | 
112 |             ENDHLSL
113 |         }
114 |     }
115 | }
116 | 
117 | 118 | 119 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/SMAA.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | Shader "Hidden/PostProcessing/SubpixelMorphologicalAntialiasing"
  6 | {
  7 |     HLSLINCLUDE
  8 | 
  9 |         #pragma exclude_renderers d3d11_9x
 10 | 
 11 |     ENDHLSL
 12 | 
 13 |     SubShader
 14 |     {
 15 |         Cull Off ZWrite Off ZTest Always
 16 | 
 17 |         // 0 - Edge detection (Low)
 18 |         Pass
 19 |         {
 20 |             HLSLPROGRAM
 21 | 
 22 |                 #pragma vertex VertEdge
 23 |                 #pragma fragment FragEdge
 24 |                 #define SMAA_PRESET_LOW
 25 |                 #include "SubpixelMorphologicalAntialiasingBridge.hlsl"
 26 | 
 27 |             ENDHLSL
 28 |         }
 29 | 
 30 |         // 1 - Edge detection (Medium)
 31 |         Pass
 32 |         {
 33 |             HLSLPROGRAM
 34 | 
 35 |                 #pragma vertex VertEdge
 36 |                 #pragma fragment FragEdge
 37 |                 #define SMAA_PRESET_MEDIUM
 38 |                 #include "SubpixelMorphologicalAntialiasingBridge.hlsl"
 39 | 
 40 |             ENDHLSL
 41 |         }
 42 | 
 43 |         // 2 - Edge detection (High)
 44 |         Pass
 45 |         {
 46 |             HLSLPROGRAM
 47 | 
 48 |                 #pragma vertex VertEdge
 49 |                 #pragma fragment FragEdge
 50 |                 #define SMAA_PRESET_HIGH
 51 |                 #include "SubpixelMorphologicalAntialiasingBridge.hlsl"
 52 | 
 53 |             ENDHLSL
 54 |         }
 55 | 
 56 |         // 3 - Blend Weights Calculation (Low)
 57 |         Pass
 58 |         {
 59 |             HLSLPROGRAM
 60 | 
 61 |                 #pragma vertex VertBlend
 62 |                 #pragma fragment FragBlend
 63 |                 #define SMAA_PRESET_LOW
 64 |                 #include "SubpixelMorphologicalAntialiasingBridge.hlsl"
 65 | 
 66 |             ENDHLSL
 67 |         }
 68 | 
 69 |         // 4 - Blend Weights Calculation (Medium)
 70 |         Pass
 71 |         {
 72 |             HLSLPROGRAM
 73 | 
 74 |                 #pragma vertex VertBlend
 75 |                 #pragma fragment FragBlend
 76 |                 #define SMAA_PRESET_MEDIUM
 77 |                 #include "SubpixelMorphologicalAntialiasingBridge.hlsl"
 78 | 
 79 |             ENDHLSL
 80 |         }
 81 | 
 82 |         // 5 - Blend Weights Calculation (High)
 83 |         Pass
 84 |         {
 85 |             HLSLPROGRAM
 86 | 
 87 |                 #pragma vertex VertBlend
 88 |                 #pragma fragment FragBlend
 89 |                 #define SMAA_PRESET_HIGH
 90 |                 #include "SubpixelMorphologicalAntialiasingBridge.hlsl"
 91 | 
 92 |             ENDHLSL
 93 |         }
 94 | 
 95 |         // 6 - Neighborhood Blending
 96 |         Pass
 97 |         {
 98 |             HLSLPROGRAM
 99 | 
100 |                 #pragma vertex VertNeighbor
101 |                 #pragma fragment FragNeighbor
102 |                 #include "SubpixelMorphologicalAntialiasingBridge.hlsl"
103 | 
104 |             ENDHLSL
105 |         }
106 |     }
107 | }
108 | 
109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/ScalableAO.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | Shader "Hidden/PostProcessing/ScalableAO"
  6 | {
  7 |     HLSLINCLUDE
  8 | 
  9 |         #pragma exclude_renderers psp2
 10 |         #pragma target 3.0
 11 |   
 12 |     ENDHLSL
 13 | 
 14 |     SubShader
 15 |     {
 16 |         Cull Off ZWrite Off ZTest Always
 17 | 
 18 |         // 0 - Occlusion estimation with CameraDepthTexture
 19 |         Pass
 20 |         {
 21 |             HLSLPROGRAM
 22 | 
 23 |                 #pragma vertex VertDefault
 24 |                 #pragma fragment FragAO
 25 |                 #pragma multi_compile _ APPLY_FORWARD_FOG
 26 |                 #pragma multi_compile _ FOG_LINEAR FOG_EXP FOG_EXP2
 27 |                 #define SOURCE_DEPTH
 28 |                 #include "ScalableAO.hlsl"
 29 | 
 30 |             ENDHLSL
 31 |         }
 32 | 
 33 |         // 1 - Occlusion estimation with G-Buffer
 34 |         Pass
 35 |         {
 36 |             HLSLPROGRAM
 37 | 
 38 |                 #pragma vertex VertDefault
 39 |                 #pragma fragment FragAO
 40 |                 #pragma multi_compile _ APPLY_FORWARD_FOG
 41 |                 #pragma multi_compile _ FOG_LINEAR FOG_EXP FOG_EXP2
 42 |                 #define SOURCE_GBUFFER
 43 |                 #include "ScalableAO.hlsl"
 44 | 
 45 |             ENDHLSL
 46 |         }
 47 | 
 48 |         // 2 - Separable blur (horizontal pass) with CameraDepthNormalsTexture
 49 |         Pass
 50 |         {
 51 |             HLSLPROGRAM
 52 | 
 53 |                 #pragma vertex VertDefault
 54 |                 #pragma fragment FragBlur
 55 |                 #define SOURCE_DEPTHNORMALS
 56 |                 #define BLUR_HORIZONTAL
 57 |                 #define BLUR_SAMPLE_CENTER_NORMAL
 58 |                 #include "ScalableAO.hlsl"
 59 | 
 60 |             ENDHLSL
 61 |         }
 62 | 
 63 |         // 3 - Separable blur (horizontal pass) with G-Buffer
 64 |         Pass
 65 |         {
 66 |             HLSLPROGRAM
 67 | 
 68 |                 #pragma vertex VertDefault
 69 |                 #pragma fragment FragBlur
 70 |                 #define SOURCE_GBUFFER
 71 |                 #define BLUR_HORIZONTAL
 72 |                 #define BLUR_SAMPLE_CENTER_NORMAL
 73 |                 #include "ScalableAO.hlsl"
 74 | 
 75 |             ENDHLSL
 76 |         }
 77 | 
 78 |         // 4 - Separable blur (vertical pass)
 79 |         Pass
 80 |         {
 81 |             HLSLPROGRAM
 82 | 
 83 |                 #pragma vertex VertDefault
 84 |                 #pragma fragment FragBlur
 85 |                 #define BLUR_VERTICAL
 86 |                 #include "ScalableAO.hlsl"
 87 | 
 88 |             ENDHLSL
 89 |         }
 90 | 
 91 |         // 5 - Final composition
 92 |         Pass
 93 |         {
 94 |             Blend Zero OneMinusSrcColor, Zero OneMinusSrcAlpha
 95 | 
 96 |             HLSLPROGRAM
 97 | 
 98 |                 #pragma vertex VertDefault
 99 |                 #pragma fragment FragComposition
100 |                 #include "ScalableAO.hlsl"
101 | 
102 |             ENDHLSL
103 |         }
104 | 
105 |         // 6 - Final composition (ambient only mode)
106 |         Pass
107 |         {
108 |             Blend Zero OneMinusSrcColor, Zero OneMinusSrcAlpha
109 | 
110 |             HLSLPROGRAM
111 | 
112 |                 #pragma vertex VertDefault
113 |                 #pragma fragment FragCompositionGBuffer
114 |                 #include "ScalableAO.hlsl"
115 | 
116 |             ENDHLSL
117 |         }
118 | 
119 |         // 7 - Debug overlay
120 |         Pass
121 |         {
122 |             HLSLPROGRAM
123 | 
124 |                 #pragma vertex VertDefault
125 |                 #pragma fragment FragDebugOverlay
126 |                 #include "ScalableAO.hlsl"
127 | 
128 |             ENDHLSL
129 |         }
130 |     }
131 | }
132 | 
133 | 134 | 135 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/ScreenSpaceReflections.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 | Shader "Hidden/PostProcessing/ScreenSpaceReflections"
 6 | {
 7 |     // We need to use internal Unity lighting structures and functions for this effect so we have to
 8 |     // stick to CGPROGRAM instead of HLSLPROGRAM
 9 | 
10 |     CGINCLUDE
11 | 
12 |         #include "UnityCG.cginc"
13 |         #pragma target 5.0
14 | 
15 |         // Ported from StdLib, we can't include it as it'll conflict with internal Unity includes
16 |         struct AttributesDefault
17 |         {
18 |             float3 vertex : POSITION;
19 |         };
20 | 
21 |         struct VaryingsDefault
22 |         {
23 |             float4 vertex : SV_POSITION;
24 |             float2 texcoord : TEXCOORD0;
25 |             float2 texcoordStereo : TEXCOORD1;
26 |         };
27 | 
28 |         VaryingsDefault VertDefault(AttributesDefault v)
29 |         {
30 |             VaryingsDefault o;
31 |             o.vertex = float4(v.vertex.xy, 0.0, 1.0);
32 |             o.texcoord = (v.vertex.xy + 1.0) * 0.5;
33 | 
34 |         #if UNITY_UV_STARTS_AT_TOP
35 |             o.texcoord = o.texcoord * float2(1.0, -1.0) + float2(0.0, 1.0);
36 |         #endif
37 | 
38 |             o.texcoordStereo = TransformStereoScreenSpaceTex(o.texcoord, 1.0);
39 | 
40 |             return o;
41 |         }
42 | 
43 |         #include "ScreenSpaceReflections.hlsl"
44 | 
45 |     ENDCG
46 | 
47 |     SubShader
48 |     {
49 |         Cull Off ZWrite Off ZTest Always
50 | 
51 |         // 0 - Test
52 |         Pass
53 |         {
54 |             CGPROGRAM
55 | 
56 |                 #pragma vertex VertDefault
57 |                 #pragma fragment FragTest
58 | 
59 |             ENDCG
60 |         }
61 | 
62 |         // 1 - Resolve
63 |         Pass
64 |         {
65 |             CGPROGRAM
66 | 
67 |                 #pragma vertex VertDefault
68 |                 #pragma fragment FragResolve
69 | 
70 |             ENDCG
71 |         }
72 | 
73 |         // 2 - Reproject
74 |         Pass
75 |         {
76 |             CGPROGRAM
77 | 
78 |                 #pragma vertex VertDefault
79 |                 #pragma fragment FragReproject
80 | 
81 |             ENDCG
82 |         }
83 | 
84 |         // 3 - Composite
85 |         Pass
86 |         {
87 |             CGPROGRAM
88 | 
89 |                 #pragma vertex VertDefault
90 |                 #pragma fragment FragComposite
91 | 
92 |             ENDCG
93 |         }
94 |     }
95 | }
96 | 
97 | 98 | 99 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/SubpixelMorphologicalAntialiasingBridge.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | #ifndef UNITY_POSTFX_SMAA_BRIDGE
  6 | #define UNITY_POSTFX_SMAA_BRIDGE
  7 | 
  8 | #include "../StdLib.hlsl"
  9 | 
 10 | TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
 11 | TEXTURE2D_SAMPLER2D(_BlendTex, sampler_BlendTex);
 12 | TEXTURE2D_SAMPLER2D(_AreaTex, sampler_AreaTex);
 13 | TEXTURE2D_SAMPLER2D(_SearchTex, sampler_SearchTex);
 14 | float4 _MainTex_TexelSize;
 15 | 
 16 | #define SMAA_RT_METRICS _MainTex_TexelSize
 17 | #define SMAA_AREATEX_SELECT(s) s.rg
 18 | #define SMAA_SEARCHTEX_SELECT(s) s.a
 19 | #define LinearSampler sampler_MainTex
 20 | #define PointSampler sampler_MainTex
 21 | 
 22 | #include "SubpixelMorphologicalAntialiasing.hlsl"
 23 | 
 24 | // ----------------------------------------------------------------------------------------
 25 | // Edge Detection
 26 | 
 27 | struct VaryingsEdge
 28 | {
 29 |     float4 vertex : SV_POSITION;
 30 |     float2 texcoord : TEXCOORD0;
 31 |     float4 offsets[3] : TEXCOORD1;
 32 | };
 33 | 
 34 | VaryingsEdge VertEdge(AttributesDefault v)
 35 | {
 36 |     VaryingsEdge o;
 37 |     o.vertex = float4(v.vertex.xy, 0.0, 1.0);
 38 |     o.texcoord = TransformTriangleVertexToUV(v.vertex.xy);
 39 | 
 40 | #if UNITY_UV_STARTS_AT_TOP
 41 |     o.texcoord = o.texcoord * float2(1.0, -1.0) + float2(0.0, 1.0);
 42 | #endif
 43 | 
 44 |     o.offsets[0] = mad(SMAA_RT_METRICS.xyxy, float4(-1.0, 0.0, 0.0, -1.0), o.texcoord.xyxy);
 45 |     o.offsets[1] = mad(SMAA_RT_METRICS.xyxy, float4( 1.0, 0.0, 0.0,  1.0), o.texcoord.xyxy);
 46 |     o.offsets[2] = mad(SMAA_RT_METRICS.xyxy, float4(-2.0, 0.0, 0.0, -2.0), o.texcoord.xyxy);
 47 | 
 48 |     return o;
 49 | }
 50 | 
 51 | float4 FragEdge(VaryingsEdge i) : SV_Target
 52 | {
 53 |     return float4(SMAAColorEdgeDetectionPS(i.texcoord, i.offsets, _MainTex), 0.0, 0.0);
 54 | }
 55 | 
 56 | // ----------------------------------------------------------------------------------------
 57 | // Blend Weights Calculation
 58 | 
 59 | struct VaryingsBlend
 60 | {
 61 |     float4 vertex : SV_POSITION;
 62 |     float2 texcoord : TEXCOORD0;
 63 |     float2 pixcoord : TEXCOORD1;
 64 |     float4 offsets[3] : TEXCOORD2;
 65 | };
 66 | 
 67 | VaryingsBlend VertBlend(AttributesDefault v)
 68 | {
 69 |     VaryingsBlend o;
 70 |     o.vertex = float4(v.vertex.xy, 0.0, 1.0);
 71 |     o.texcoord = TransformTriangleVertexToUV(v.vertex.xy);
 72 | 
 73 | #if UNITY_UV_STARTS_AT_TOP
 74 |     o.texcoord = o.texcoord * float2(1.0, -1.0) + float2(0.0, 1.0);
 75 | #endif
 76 | 
 77 |     o.pixcoord = o.texcoord * SMAA_RT_METRICS.zw;
 78 | 
 79 |     // We will use these offsets for the searches later on (see @PSEUDO_GATHER4):
 80 |     o.offsets[0] = mad(SMAA_RT_METRICS.xyxy, float4(-0.250, -0.125,  1.250, -0.125), o.texcoord.xyxy);
 81 |     o.offsets[1] = mad(SMAA_RT_METRICS.xyxy, float4(-0.125, -0.250, -0.125,  1.250), o.texcoord.xyxy);
 82 | 
 83 |     // And these for the searches, they indicate the ends of the loops:
 84 |     o.offsets[2] = mad(SMAA_RT_METRICS.xxyy, float4(-2.0, 2.0, -2.0, 2.0) * float(SMAA_MAX_SEARCH_STEPS),
 85 |         float4(o.offsets[0].xz, o.offsets[1].yw));
 86 | 
 87 |     return o;
 88 | }
 89 | 
 90 | float4 FragBlend(VaryingsBlend i) : SV_Target
 91 | {
 92 |     return SMAABlendingWeightCalculationPS(i.texcoord, i.pixcoord, i.offsets, _MainTex, _AreaTex, _SearchTex, 0);
 93 | }
 94 | 
 95 | // ----------------------------------------------------------------------------------------
 96 | // Neighborhood Blending
 97 | 
 98 | struct VaryingsNeighbor
 99 | {
100 |     float4 vertex : SV_POSITION;
101 |     float2 texcoord : TEXCOORD0;
102 |     float4 offset : TEXCOORD1;
103 | };
104 | 
105 | VaryingsNeighbor VertNeighbor(AttributesDefault v)
106 | {
107 |     VaryingsNeighbor o;
108 |     o.vertex = float4(v.vertex.xy, 0.0, 1.0);
109 |     o.texcoord = TransformTriangleVertexToUV(v.vertex.xy);
110 | 
111 | #if UNITY_UV_STARTS_AT_TOP
112 |     o.texcoord = o.texcoord * float2(1.0, -1.0) + float2(0.0, 1.0);
113 | #endif
114 | 
115 |     o.offset = mad(SMAA_RT_METRICS.xyxy, float4(1.0, 0.0, 0.0, 1.0), o.texcoord.xyxy);
116 |     return o;
117 | }
118 | 
119 | float4 FragNeighbor(VaryingsNeighbor i) : SV_Target
120 | {
121 |     return SMAANeighborhoodBlendingPS(i.texcoord, i.offset, _MainTex, _BlendTex);
122 | }
123 | 
124 | #endif
125 | 
126 | 127 | 128 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/TemporalAntialiasing.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
  5 | Shader "Hidden/PostProcessing/TemporalAntialiasing"
  6 | {
  7 |     HLSLINCLUDE
  8 | 
  9 |         #pragma exclude_renderers gles psp2
 10 |         #include "../StdLib.hlsl"
 11 |         #include "../Colors.hlsl"
 12 | 
 13 |     #if UNITY_VERSION >= 201710
 14 |         #define _MainTexSampler sampler_LinearClamp
 15 |     #else
 16 |         #define _MainTexSampler sampler_MainTex
 17 |     #endif
 18 | 
 19 |         TEXTURE2D_SAMPLER2D(_MainTex, _MainTexSampler);
 20 |         float4 _MainTex_TexelSize;
 21 | 
 22 |         TEXTURE2D_SAMPLER2D(_HistoryTex, sampler_HistoryTex);
 23 | 
 24 |         TEXTURE2D_SAMPLER2D(_CameraDepthTexture, sampler_CameraDepthTexture);
 25 |         float4 _CameraDepthTexture_TexelSize;
 26 | 
 27 |         TEXTURE2D_SAMPLER2D(_CameraMotionVectorsTexture, sampler_CameraMotionVectorsTexture);
 28 | 
 29 |         float2 _Jitter;
 30 |         float4 _FinalBlendParameters; // x: static, y: dynamic, z: motion amplification
 31 |         float _Sharpness;
 32 | 
 33 |         float2 GetClosestFragment(float2 uv)
 34 |         {
 35 |             const float2 k = _CameraDepthTexture_TexelSize.xy;
 36 | 
 37 |             const float4 neighborhood = float4(
 38 |                 SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, UnityStereoClamp(uv - k)),
 39 |                 SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, UnityStereoClamp(uv + float2(k.x, -k.y))),
 40 |                 SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, UnityStereoClamp(uv + float2(-k.x, k.y))),
 41 |                 SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, UnityStereoClamp(uv + k))
 42 |             );
 43 | 
 44 |         #if defined(UNITY_REVERSED_Z)
 45 |             #define COMPARE_DEPTH(a, b) step(b, a)
 46 |         #else
 47 |             #define COMPARE_DEPTH(a, b) step(a, b)
 48 |         #endif
 49 | 
 50 |             float3 result = float3(0.0, 0.0, SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, uv));
 51 |             result = lerp(result, float3(-1.0, -1.0, neighborhood.x), COMPARE_DEPTH(neighborhood.x, result.z));
 52 |             result = lerp(result, float3( 1.0, -1.0, neighborhood.y), COMPARE_DEPTH(neighborhood.y, result.z));
 53 |             result = lerp(result, float3(-1.0,  1.0, neighborhood.z), COMPARE_DEPTH(neighborhood.z, result.z));
 54 |             result = lerp(result, float3( 1.0,  1.0, neighborhood.w), COMPARE_DEPTH(neighborhood.w, result.z));
 55 | 
 56 |             return (uv + result.xy * k);
 57 |         }
 58 | 
 59 |         float4 ClipToAABB(float4 color, float3 minimum, float3 maximum)
 60 |         {
 61 |             // Note: only clips towards aabb center (but fast!)
 62 |             float3 center = 0.5 * (maximum + minimum);
 63 |             float3 extents = 0.5 * (maximum - minimum);
 64 | 
 65 |             // This is actually `distance`, however the keyword is reserved
 66 |             float3 offset = color.rgb - center;
 67 | 
 68 |             float3 ts = abs(extents / (offset + 0.0001));
 69 |             float t = saturate(Min3(ts.x, ts.y, ts.z));
 70 |             color.rgb = center + offset * t;
 71 |             return color;
 72 |         }
 73 | 
 74 |         struct OutputSolver
 75 |         {
 76 |             float4 destination : SV_Target0;
 77 |             float4 history     : SV_Target1;
 78 |         };
 79 | 
 80 |         OutputSolver Solve(float2 motion, float2 texcoord)
 81 |         {
 82 |             const float2 k = _MainTex_TexelSize.xy;
 83 |             float2 uv = UnityStereoClamp(texcoord - _Jitter);
 84 | 
 85 |             float4 color = SAMPLE_TEXTURE2D(_MainTex, _MainTexSampler, uv);
 86 | 
 87 |             float4 topLeft = SAMPLE_TEXTURE2D(_MainTex, _MainTexSampler, UnityStereoClamp(uv - k * 0.5));
 88 |             float4 bottomRight = SAMPLE_TEXTURE2D(_MainTex, _MainTexSampler, UnityStereoClamp(uv + k * 0.5));
 89 | 
 90 |             float4 corners = 4.0 * (topLeft + bottomRight) - 2.0 * color;
 91 | 
 92 |             // Sharpen output
 93 |             color += (color - (corners * 0.166667)) * 2.718282 * _Sharpness;
 94 |             color = clamp(color, 0.0, HALF_MAX_MINUS1);
 95 | 
 96 |             // Tonemap color and history samples
 97 |             float4 average = (corners + color) * 0.142857;
 98 | 
 99 |             float4 history = SAMPLE_TEXTURE2D(_HistoryTex, sampler_HistoryTex, UnityStereoClamp(texcoord - motion));
100 | 
101 |             float motionLength = length(motion);
102 |             float2 luma = float2(Luminance(average), Luminance(color));
103 |             //float nudge = 4.0 * abs(luma.x - luma.y);
104 |             float nudge = lerp(4.0, 0.25, saturate(motionLength * 100.0)) * abs(luma.x - luma.y);
105 | 
106 |             float4 minimum = min(bottomRight, topLeft) - nudge;
107 |             float4 maximum = max(topLeft, bottomRight) + nudge;
108 | 
109 |             // Clip history samples
110 |             history = ClipToAABB(history, minimum.xyz, maximum.xyz);
111 | 
112 |             // Blend method
113 |             float weight = clamp(
114 |                 lerp(_FinalBlendParameters.x, _FinalBlendParameters.y, motionLength * _FinalBlendParameters.z),
115 |                 _FinalBlendParameters.y, _FinalBlendParameters.x
116 |             );
117 | 
118 |             color = lerp(color, history, weight);
119 |             color = clamp(color, 0.0, HALF_MAX_MINUS1);
120 | 
121 |             OutputSolver output;
122 |             output.destination = color;
123 |             output.history = color;
124 |             return output;
125 |         }
126 | 
127 |         OutputSolver FragSolverDilate(VaryingsDefault i)
128 |         {
129 |             float2 closest = GetClosestFragment(i.texcoordStereo);
130 |             float2 motion = SAMPLE_TEXTURE2D(_CameraMotionVectorsTexture, sampler_CameraMotionVectorsTexture, closest).xy;
131 |             return Solve(motion, i.texcoordStereo);
132 |         }
133 | 
134 |         OutputSolver FragSolverNoDilate(VaryingsDefault i)
135 |         {
136 |             // Don't dilate in ortho !
137 |             float2 motion = SAMPLE_TEXTURE2D(_CameraMotionVectorsTexture, sampler_CameraMotionVectorsTexture, i.texcoordStereo).xy;
138 |             return Solve(motion, i.texcoordStereo);
139 |         }
140 | 
141 |     ENDHLSL
142 | 
143 |     SubShader
144 |     {
145 |         Cull Off ZWrite Off ZTest Always
146 | 
147 |         // 0: Perspective
148 |         Pass
149 |         {
150 |             HLSLPROGRAM
151 | 
152 |                 #pragma vertex VertDefault
153 |                 #pragma fragment FragSolverDilate
154 | 
155 |             ENDHLSL
156 |         }
157 | 
158 |         // 1: Ortho
159 |         Pass
160 |         {
161 |             HLSLPROGRAM
162 | 
163 |                 #pragma vertex VertDefault
164 |                 #pragma fragment FragSolverNoDilate
165 | 
166 |             ENDHLSL
167 |         }
168 |     }
169 | }
170 | 
171 | 172 | 173 | -------------------------------------------------------------------------------- /Library/PostProcessing/Builtins/Texture2DLerp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
 5 | Shader "Hidden/PostProcessing/Texture2DLerp"
 6 | {
 7 |     HLSLINCLUDE
 8 | 
 9 |         #include "../StdLib.hlsl"
10 | 
11 |         TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex); // From
12 |         TEXTURE2D_SAMPLER2D(_To, sampler_To);
13 |         float _Interp;
14 |         float4 _TargetColor;
15 | 
16 |         float4 Frag(VaryingsDefault i) : SV_Target
17 |         {
18 |             float4 from = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord);
19 |             float4 to = SAMPLE_TEXTURE2D(_To, sampler_To, i.texcoord);
20 |             return lerp(from, to, _Interp);
21 |         }
22 | 
23 |         float4 FragColor(VaryingsDefault i) : SV_Target
24 |         {
25 |             float4 from = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord);
26 |             float4 to = _TargetColor;
27 |             return lerp(from, to, _Interp);
28 |         }
29 |     ENDHLSL
30 | 
31 |     SubShader
32 |     {
33 |         Cull Off ZWrite Off ZTest Always
34 | 
35 |         Pass
36 |         {
37 |             HLSLPROGRAM
38 | 
39 |                 #pragma vertex VertDefault
40 |                 #pragma fragment Frag
41 | 
42 |             ENDHLSL
43 |         }
44 |         Pass
45 |         {
46 |             HLSLPROGRAM
47 | 
48 |                 #pragma vertex VertDefault
49 |                 #pragma fragment FragColor
50 | 
51 |             ENDHLSL
52 |         }
53 |     }
54 | }
55 | 
56 | 57 | 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UnityShaderViewer 2 | Tool for viewing Unity shaders online, with auto-generated links to definitions 3 | 4 | ## Directory 5 | https://xibanya.github.io/UnityShaderViewer/ 6 | Browse all the shaders and includes that have been added to the database so far 7 | 8 | ## Search 9 | https://xibanya.github.io/UnityShaderViewer/Tools/DynamicViewer.html 10 | Search for the definition of built-in functions and variables. (probably the most useful tool in this repository, I use it all the time myself!) 11 | 12 | ## Pastebin 13 | https://xibanya.github.io/UnityShaderViewer/Tools/Paste.html 14 | Paste or type in some ShaderLab code and it will be instantly formatted with nice colors and links to definitions 15 | 16 | ## Viewer 17 | https://xibanya.github.io/UnityShaderViewer/Tools/Viewer.html 18 | paste the url of a raw shader file and it'll be parsed with links to definitions added 19 | -------------------------------------------------------------------------------- /Scripts/sql-wasm.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xibanya/UnityShaderViewer/4572f325f73a5052cf7ed45c2c03d126b35ebb91/Scripts/sql-wasm.wasm -------------------------------------------------------------------------------- /Styles/Fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xibanya/UnityShaderViewer/4572f325f73a5052cf7ed45c2c03d126b35ebb91/Styles/Fonts/FontAwesome.otf -------------------------------------------------------------------------------- /Styles/Fonts/fa-brands-400.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xibanya/UnityShaderViewer/4572f325f73a5052cf7ed45c2c03d126b35ebb91/Styles/Fonts/fa-brands-400.eot -------------------------------------------------------------------------------- /Styles/Fonts/fa-brands-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xibanya/UnityShaderViewer/4572f325f73a5052cf7ed45c2c03d126b35ebb91/Styles/Fonts/fa-brands-400.ttf -------------------------------------------------------------------------------- /Styles/Fonts/fa-brands-400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xibanya/UnityShaderViewer/4572f325f73a5052cf7ed45c2c03d126b35ebb91/Styles/Fonts/fa-brands-400.woff -------------------------------------------------------------------------------- /Styles/Fonts/fa-brands-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xibanya/UnityShaderViewer/4572f325f73a5052cf7ed45c2c03d126b35ebb91/Styles/Fonts/fa-brands-400.woff2 -------------------------------------------------------------------------------- /Styles/Fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xibanya/UnityShaderViewer/4572f325f73a5052cf7ed45c2c03d126b35ebb91/Styles/Fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /Styles/Fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xibanya/UnityShaderViewer/4572f325f73a5052cf7ed45c2c03d126b35ebb91/Styles/Fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /Styles/Fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xibanya/UnityShaderViewer/4572f325f73a5052cf7ed45c2c03d126b35ebb91/Styles/Fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /Styles/Fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xibanya/UnityShaderViewer/4572f325f73a5052cf7ed45c2c03d126b35ebb91/Styles/Fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /Styles/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.clo,.opn,.pun{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.kwd,.tag,.typ{font-weight:700}.str{color:#060}.kwd{color:#006}.com{color:#600;font-style:italic}.typ{color:#404}.lit{color:#044}.clo,.opn,.pun{color:#440}.tag{color:#006}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} 2 | -------------------------------------------------------------------------------- /Styles/vscode.css: -------------------------------------------------------------------------------- 1 | code.prettyprint, 2 | pre.prettyprint 3 | { 4 | background-color:#1E1E1E; 5 | border-radius:8px 6 | } 7 | pre.prettyprint 8 | { 9 | width:95%; 10 | margin:0.5em auto; 11 | padding:0.5em; 12 | white-space:pre-wrap; 13 | } 14 | pre .str { color: #ce9178 } /* string */ 15 | pre .kwd { color: #569cd6; font-weight: bold } 16 | pre .com { color: #6A9955 } /* comment - skyblue */ 17 | pre .typ 18 | { 19 | color: #9cdcfe; 20 | } /* type */ 21 | pre .typ > a 22 | { 23 | color: #03edf9; 24 | text-shadow: 0 0 2px #001716, 0 0 3px #03edf975, 0 0 5px #03edf975, 0 0 8px #03edf975; 25 | } 26 | pre .lit { color: #b5cea8 } /* literal */ 27 | pre .pun { color: #fff } /* punctuation */ 28 | pre .pln { color: #fff } /* plaintext */ 29 | pre .tag { color: #f0e68c; font-weight: bold } /* html/xml tag - lightyellow */ 30 | pre .atn { color: #bdb76b; font-weight: bold } /* attribute name - khaki */ 31 | pre .atv { color: #ce9178 } /* attribute value */ 32 | pre .dec { color: #b5cea8 } /* decimal */ 33 | pre .dir { color: #C586C0 } /* directive */ 34 | pre .dir a 35 | { 36 | color: #f92aad; 37 | text-shadow: 0 0 2px #100c0f, 0 0 5px #dc078e33, 0 0 10px #fff3; 38 | } 39 | pre a 40 | { 41 | color: inherit; 42 | font-size: 115%; 43 | } 44 | 45 | /* Specify class=linenums on a pre to get line numbering */ 46 | ol.linenums { margin-top: 0; margin-bottom: 0; color: #AEAEAE } /* IE indents via margin-left */ 47 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: decimal !important; } -------------------------------------------------------------------------------- /Tools/DynamicViewer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 14 |
15 |
16 | 
17 | 
18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Tools/Paste.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Shader Pastebin 4 | 5 | 6 | 7 | 8 | 9 |
10 |
11 | 12 |
13 |
14 |
15 |
16 | 
17 | 
18 |
19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Tools/Viewer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

How to use

8 |

paste in the URL of a shader (such as the raw file from GitHub), then press load. Allow a few moments for links to show up.

9 | 10 | 11 |
12 | 
13 | 
14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 |

Tools

9 |

✨ Viewer

10 |

View your own shaders (or anyone else's) with auto-generated formatting, colors, and links to definitions.

11 |

✨ Search

12 |

(Experimental) Search the built-in includes as if there were actually an IDE capable of maybe parsing them reasonably well.

13 |

✨ Pastebin

14 |

Paste in shader code and see it instantly have links to definition and color markup inserted.

15 |
16 |
17 | 18 |
19 |

Browse Built-In Includes

20 |
21 |

Browse Built-In Shaders

22 |
23 |
24 | 25 | 26 | 27 | 28 | --------------------------------------------------------------------------------