├── Includes.meta ├── Includes ├── URP2DPass.hlsl ├── URP2DPass.hlsl.meta ├── URPDepthNormalsPass.hlsl ├── URPDepthNormalsPass.hlsl.meta ├── URPDepthOnlyPass.hlsl ├── URPDepthOnlyPass.hlsl.meta ├── URPLightingPass.hlsl ├── URPLightingPass.hlsl.meta ├── URPLitGBufferPass.hlsl ├── URPLitGBufferPass.hlsl.meta ├── URPMacros.hlsl ├── URPMacros.hlsl.meta ├── URPMetaPass.hlsl ├── URPMetaPass.hlsl.meta ├── URPMotionVectorPass.hlsl ├── URPMotionVectorPass.hlsl.meta ├── URPShaderInputs.hlsl ├── URPShaderInputs.hlsl.meta ├── URPShadowsPass.hlsl ├── URPShadowsPass.hlsl.meta ├── URPUnlitDepthNormalsPass.hlsl ├── URPUnlitDepthNormalsPass.hlsl.meta ├── URPUnlitDepthOnlyPass.hlsl ├── URPUnlitDepthOnlyPass.hlsl.meta ├── URPUnlitForwardPass.hlsl ├── URPUnlitForwardPass.hlsl.meta ├── URPUnlitGBufferPass.hlsl ├── URPUnlitGBufferPass.hlsl.meta ├── URPUnlitMetaPass.hlsl ├── URPUnlitMetaPass.hlsl.meta ├── URPUnlitMotionVectorPass.hlsl ├── URPUnlitMotionVectorPass.hlsl.meta ├── URPUnlitShaderInputs.hlsl ├── URPUnlitShaderInputs.hlsl.meta ├── URPUnlitShadowsPass.hlsl └── URPUnlitShadowsPass.hlsl.meta ├── LICENSE ├── LICENSE.meta ├── README.md ├── README.md.meta ├── Shaders.meta ├── Shaders ├── Example Shader.meta ├── Example Shader │ ├── ExampleShader.hlsl │ ├── ExampleShader.hlsl.meta │ ├── ExampleShader.shader │ └── ExampleShader.shader.meta ├── Example Unlit Shader.meta ├── Example Unlit Shader │ ├── ExampleUnlitShader.hlsl │ ├── ExampleUnlitShader.hlsl.meta │ ├── ExampleUnlitShader.shader │ └── ExampleUnlitShader.shader.meta ├── URPSurfaceShader.shader ├── URPSurfaceShader.shader.meta ├── URPUnlit.shader ├── URPUnlit.shader.meta ├── Unlit Shadows.meta ├── Unlit Shadows │ ├── Unlit Shadows.shader │ └── Unlit Shadows.shader.meta ├── Vertex Color.meta └── Vertex Color │ ├── VertexColorLit.hlsl │ ├── VertexColorLit.hlsl.meta │ ├── VertexColorLit.shader │ └── VertexColorLit.shader.meta ├── package.json └── package.json.meta /Includes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73eaf7fd98358924ea6a184bf6a0a6e8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Includes/URP2DPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_2D_INCLUDED 2 | #define URP_SURFACE_SHADER_2D_INCLUDED 3 | 4 | #include "URPShaderInputs.hlsl" 5 | #include "URPMacros.hlsl" 6 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" 7 | 8 | Varyings vert(Attributes input) 9 | { 10 | Varyings output = (Varyings)0; 11 | 12 | UNITY_SETUP_INSTANCE_ID(input); 13 | UNITY_TRANSFER_INSTANCE_ID(input, output); 14 | 15 | //////////////////////////////// 16 | UPDATE_INPUT_VERTEX(input); 17 | //////////////////////////////// 18 | 19 | VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz); 20 | output.positionCS = vertexInput.positionCS; 21 | output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); 22 | 23 | 24 | #if defined(REQUIRES_VERTEX_COLOR) 25 | //output.color = input.color; 26 | #endif 27 | 28 | //////////////////////////////// 29 | UPDATE_OUTPUT_VERTEX(output); 30 | //////////////////////////////// 31 | 32 | return output; 33 | } 34 | 35 | half4 frag(Varyings input) : SV_Target 36 | { 37 | UNITY_SETUP_INSTANCE_ID(input); 38 | 39 | half2 uv = input.uv; 40 | half4 texColor = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, uv); 41 | half3 color = texColor.rgb * _BaseColor.rgb; 42 | half alpha = texColor.a * _BaseColor.a; 43 | AlphaDiscard(alpha, _Cutoff); 44 | 45 | #ifdef _ALPHAPREMULTIPLY_ON 46 | color *= alpha; 47 | #endif 48 | return half4(color, alpha); 49 | } 50 | 51 | #endif //URP_SURFACE_SHADER_2D_INCLUDED 52 | -------------------------------------------------------------------------------- /Includes/URP2DPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7bfb6c21b6c748b4e97d9ffccff91d15 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Includes/URPDepthNormalsPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_DEPTH_NORMALS_PASS_INCLUDED 2 | #define URP_SURFACE_SHADER_DEPTH_NORMALS_PASS_INCLUDED 3 | 4 | #include "URPShaderInputs.hlsl" 5 | #include "URPMacros.hlsl" 6 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 7 | #if defined(LOD_FADE_CROSSFADE) 8 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" 9 | #endif 10 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RealtimeLights.hlsl" 11 | 12 | Varyings DepthNormalsVertex(Attributes input) 13 | { 14 | Varyings output = (Varyings)0; 15 | 16 | UNITY_SETUP_INSTANCE_ID(input); 17 | UNITY_TRANSFER_INSTANCE_ID(input, output); 18 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); 19 | 20 | //////////////////////////////// 21 | UPDATE_INPUT_VERTEX(input); 22 | //////////////////////////////// 23 | 24 | #if defined(_ALPHATEST_ON) 25 | output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); 26 | #endif 27 | 28 | output.positionCS = TransformObjectToHClip(input.positionOS.xyz); 29 | 30 | VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS, input.tangentOS); 31 | output.normalWS = NormalizeNormalPerVertex(normalInput.normalWS); 32 | 33 | //////////////////////////////// 34 | UPDATE_OUTPUT_VERTEX(output); 35 | //////////////////////////////// 36 | 37 | return output; 38 | } 39 | 40 | void DepthNormalsFragment(Varyings input, out half4 outNormalWS : SV_Target0 41 | #ifdef _WRITE_RENDERING_LAYERS 42 | , out float4 outRenderingLayers : SV_Target1 43 | #endif 44 | ) 45 | { 46 | UNITY_SETUP_INSTANCE_ID(input); 47 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); 48 | 49 | #if defined(_ALPHATEST_ON) 50 | Alpha(SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)).a, _BaseColor, _Cutoff); 51 | #endif 52 | 53 | #if defined(LOD_FADE_CROSSFADE) 54 | LODFadeCrossFade(input.positionCS); 55 | #endif 56 | 57 | #if defined(_GBUFFER_NORMALS_OCT) 58 | float3 normalWS = normalize(input.normalWS); 59 | float2 octNormalWS = PackNormalOctQuadEncode(normalWS); // values between [-1, +1], must use fp32 on some platforms. 60 | float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); // values between [ 0, 1] 61 | half3 packedNormalWS = PackFloat2To888(remappedOctNormalWS); // values between [ 0, 1] 62 | outNormalWS = half4(packedNormalWS, 0.0); 63 | #else 64 | float3 normalWS = NormalizeNormalPerPixel(input.normalWS); 65 | outNormalWS = half4(normalWS, 0.0); 66 | #endif 67 | 68 | #ifdef _WRITE_RENDERING_LAYERS 69 | uint renderingLayers = GetMeshRenderingLayer(); 70 | outRenderingLayers = float4(EncodeMeshRenderingLayer(renderingLayers), 0, 0, 0); 71 | #endif 72 | } 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /Includes/URPDepthNormalsPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 741fe5a89ec0fb8479a91c9b1d2d3916 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Includes/URPDepthOnlyPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_DEPTH_ONLY_PASS_INCLUDED 2 | #define URP_SURFACE_SHADER_DEPTH_ONLY_PASS_INCLUDED 3 | 4 | #include "URPShaderInputs.hlsl" 5 | #include "URPMacros.hlsl" 6 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 7 | #if defined(LOD_FADE_CROSSFADE) 8 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" 9 | #endif 10 | 11 | Varyings DepthOnlyVertex(Attributes input) 12 | { 13 | Varyings output = (Varyings)0; 14 | 15 | UNITY_SETUP_INSTANCE_ID(input); 16 | UNITY_TRANSFER_INSTANCE_ID(input, output); 17 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); 18 | 19 | //////////////////////////////// 20 | UPDATE_INPUT_VERTEX(input); 21 | //////////////////////////////// 22 | 23 | #if defined(_ALPHATEST_ON) 24 | output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); 25 | #endif 26 | output.positionCS = TransformObjectToHClip(input.positionOS.xyz); 27 | 28 | //////////////////////////////// 29 | UPDATE_OUTPUT_VERTEX(output); 30 | //////////////////////////////// 31 | 32 | return output; 33 | } 34 | 35 | half4 DepthOnlyFragment(Varyings input) : SV_TARGET 36 | { 37 | UNITY_SETUP_INSTANCE_ID(input); 38 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); 39 | 40 | #if defined(_ALPHATEST_ON) 41 | Alpha(SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)).a, _BaseColor, _Cutoff); 42 | #endif 43 | 44 | #if defined(LOD_FADE_CROSSFADE) 45 | LODFadeCrossFade(input.positionCS); 46 | #endif 47 | 48 | return 0; 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /Includes/URPDepthOnlyPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 388a71d4e0953764e92140c4dafc2d27 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Includes/URPLightingPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_LIGHTING_INCLUDED 2 | #define URP_SURFACE_SHADER_LIGHTING_INCLUDED 3 | 4 | #include "URPShaderInputs.hlsl" 5 | #include "URPMacros.hlsl" 6 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" 7 | #if defined(LOD_FADE_CROSSFADE) 8 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" 9 | #endif 10 | 11 | void InitializeInputData(Varyings input, half3 normalTS, out InputData inputData) 12 | { 13 | inputData = (InputData)0; 14 | 15 | #if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR) 16 | inputData.positionWS = input.positionWS; 17 | #endif 18 | 19 | #if defined(DEBUG_DISPLAY) 20 | inputData.positionCS = input.positionCS; 21 | #endif 22 | 23 | half3 viewDirWS = GetWorldSpaceNormalizeViewDir(input.positionWS); 24 | #if defined(_NORMALMAP) || defined(_DETAIL) 25 | float sgn = input.tangentWS.w; // should be either +1 or -1 26 | float3 bitangent = sgn * cross(input.normalWS.xyz, input.tangentWS.xyz); 27 | half3x3 tangentToWorld = half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWS.xyz); 28 | 29 | #if defined(_NORMALMAP) 30 | inputData.tangentToWorld = tangentToWorld; 31 | #endif 32 | inputData.normalWS = TransformTangentToWorld(normalTS, tangentToWorld); 33 | #else 34 | inputData.normalWS = input.normalWS; 35 | #endif 36 | 37 | inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS); 38 | inputData.viewDirectionWS = viewDirWS; 39 | 40 | #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) 41 | inputData.shadowCoord = input.shadowCoord; 42 | #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS) 43 | inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS); 44 | #else 45 | inputData.shadowCoord = float4(0, 0, 0, 0); 46 | #endif 47 | #ifdef _ADDITIONAL_LIGHTS_VERTEX 48 | inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS, 1.0), input.fogFactorAndVertexLight.x); 49 | inputData.vertexLighting = input.fogFactorAndVertexLight.yzw; 50 | #else 51 | inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS, 1.0), input.fogFactor); 52 | #endif 53 | 54 | inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS); 55 | 56 | #if defined(DEBUG_DISPLAY) 57 | #if defined(DYNAMICLIGHTMAP_ON) 58 | inputData.dynamicLightmapUV = input.dynamicLightmapUV; 59 | #endif 60 | #if defined(LIGHTMAP_ON) 61 | inputData.staticLightmapUV = input.staticLightmapUV; 62 | #else 63 | inputData.vertexSH = input.vertexSH; 64 | #endif 65 | #if defined(USE_APV_PROBE_OCCLUSION) 66 | inputData.probeOcclusion = input.probeOcclusion; 67 | #endif 68 | #endif 69 | } 70 | 71 | void InitializeBakedGIData(Varyings input, inout InputData inputData) 72 | { 73 | #if defined(DYNAMICLIGHTMAP_ON) 74 | inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.dynamicLightmapUV, input.vertexSH, inputData.normalWS); 75 | inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV); 76 | #elif !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)) 77 | inputData.bakedGI = SAMPLE_GI(input.vertexSH, 78 | GetAbsolutePositionWS(inputData.positionWS), 79 | inputData.normalWS, 80 | inputData.viewDirectionWS, 81 | input.positionCS.xy, 82 | input.probeOcclusion, 83 | inputData.shadowMask); 84 | #else 85 | inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.vertexSH, inputData.normalWS); 86 | inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV); 87 | #endif 88 | } 89 | 90 | /////////////////////////////////////////////////////////////////////////////// 91 | // Vertex and Fragment functions // 92 | /////////////////////////////////////////////////////////////////////////////// 93 | 94 | // Used in Standard (Physically Based) shader 95 | Varyings LitPassVertex(Attributes input) 96 | { 97 | Varyings output = (Varyings)0; 98 | 99 | UNITY_SETUP_INSTANCE_ID(input); 100 | UNITY_TRANSFER_INSTANCE_ID(input, output); 101 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); 102 | 103 | //////////////////////////////// 104 | UPDATE_INPUT_VERTEX(input); 105 | //////////////////////////////// 106 | 107 | VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz); 108 | 109 | // normalWS and tangentWS already normalize. 110 | // this is required to avoid skewing the direction during interpolation 111 | // also required for per-vertex lighting and SH evaluation 112 | VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS, input.tangentOS); 113 | 114 | half3 vertexLight = VertexLighting(vertexInput.positionWS, normalInput.normalWS); 115 | 116 | half fogFactor = 0; 117 | #if !defined(_FOG_FRAGMENT) 118 | fogFactor = ComputeFogFactor(vertexInput.positionCS.z); 119 | #endif 120 | 121 | output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); 122 | 123 | // already normalized from normal transform to WS. 124 | output.normalWS = normalInput.normalWS; 125 | #if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR) || defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR) 126 | real sign = input.tangentOS.w * GetOddNegativeScale(); 127 | half4 tangentWS = half4(normalInput.tangentWS.xyz, sign); 128 | #endif 129 | #if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR) 130 | output.tangentWS = tangentWS; 131 | #endif 132 | 133 | #if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR) 134 | half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS); 135 | half3 viewDirTS = GetViewDirectionTangentSpace(tangentWS, output.normalWS, viewDirWS); 136 | output.viewDirTS = viewDirTS; 137 | #endif 138 | 139 | OUTPUT_LIGHTMAP_UV(input.staticLightmapUV, unity_LightmapST, output.staticLightmapUV); 140 | #ifdef DYNAMICLIGHTMAP_ON 141 | output.dynamicLightmapUV = input.dynamicLightmapUV.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw; 142 | #endif 143 | OUTPUT_SH4(vertexInput.positionWS, output.normalWS.xyz, GetWorldSpaceNormalizeViewDir(vertexInput.positionWS), output.vertexSH, output.probeOcclusion); 144 | #ifdef _ADDITIONAL_LIGHTS_VERTEX 145 | output.fogFactorAndVertexLight = half4(fogFactor, vertexLight); 146 | #else 147 | output.fogFactor = fogFactor; 148 | #endif 149 | 150 | #if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR) 151 | output.positionWS = vertexInput.positionWS; 152 | #endif 153 | 154 | #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) 155 | output.shadowCoord = GetShadowCoord(vertexInput); 156 | #endif 157 | 158 | output.positionCS = vertexInput.positionCS; 159 | 160 | //////////////////////////////// 161 | UPDATE_OUTPUT_VERTEX(output); 162 | //////////////////////////////// 163 | 164 | return output; 165 | } 166 | 167 | // Used in Standard (Physically Based) shader 168 | void LitPassFragment( 169 | Varyings input 170 | , out half4 outColor : SV_Target0 171 | #ifdef _WRITE_RENDERING_LAYERS 172 | , out float4 outRenderingLayers : SV_Target1 173 | #endif 174 | ) 175 | { 176 | UNITY_SETUP_INSTANCE_ID(input); 177 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); 178 | 179 | #if defined(_PARALLAXMAP) 180 | #if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR) 181 | half3 viewDirTS = input.viewDirTS; 182 | #else 183 | half3 viewDirWS = GetWorldSpaceNormalizeViewDir(input.positionWS); 184 | half3 viewDirTS = GetViewDirectionTangentSpace(input.tangentWS, input.normalWS, viewDirWS); 185 | #endif 186 | ApplyPerPixelDisplacement(viewDirTS, input.uv); 187 | #endif 188 | 189 | //////////////////////////////// 190 | SurfaceData surfaceData = GET_SURFACE_PROPERTIES(input); 191 | //////////////////////////////// 192 | 193 | #ifdef LOD_FADE_CROSSFADE 194 | LODFadeCrossFade(input.positionCS); 195 | #endif 196 | 197 | InputData inputData; 198 | InitializeInputData(input, surfaceData.normalTS, inputData); 199 | SETUP_DEBUG_TEXTURE_DATA(inputData, UNDO_TRANSFORM_TEX(input.uv, _BaseMap)); 200 | 201 | #if defined(_DBUFFER) 202 | ApplyDecalToSurfaceData(input.positionCS, surfaceData, inputData); 203 | #endif 204 | 205 | InitializeBakedGIData(input, inputData); 206 | 207 | half4 color = UniversalFragmentPBR(inputData, surfaceData); 208 | color.rgb = MixFog(color.rgb, inputData.fogCoord); 209 | color.a = OutputAlpha(color.a, IsSurfaceTypeTransparent(_Surface)); 210 | 211 | outColor = color; 212 | 213 | #ifdef _WRITE_RENDERING_LAYERS 214 | uint renderingLayers = GetMeshRenderingLayer(); 215 | outRenderingLayers = float4(EncodeMeshRenderingLayer(renderingLayers), 0, 0, 0); 216 | #endif 217 | } 218 | 219 | #endif 220 | -------------------------------------------------------------------------------- /Includes/URPLightingPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f37345aa8746f964e9f6177dd292b34c 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Includes/URPLitGBufferPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_GBUFFER_PASS_INCLUDED 2 | #define URP_SURFACE_SHADER_GBUFFER_PASS_INCLUDED 3 | 4 | #include "URPShaderInputs.hlsl" 5 | #include "URPMacros.hlsl" 6 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" 7 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" 8 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityGBuffer.hlsl" 9 | 10 | void InitializeInputData(Varyings input, half3 normalTS, out InputData inputData) 11 | { 12 | inputData = (InputData)0; 13 | 14 | #if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR) 15 | inputData.positionWS = input.positionWS; 16 | #endif 17 | 18 | inputData.positionCS = input.positionCS; 19 | half3 viewDirWS = GetWorldSpaceNormalizeViewDir(input.positionWS); 20 | #if defined(_NORMALMAP) || defined(_DETAIL) 21 | float sgn = input.tangentWS.w; // should be either +1 or -1 22 | float3 bitangent = sgn * cross(input.normalWS.xyz, input.tangentWS.xyz); 23 | inputData.normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWS.xyz)); 24 | #else 25 | inputData.normalWS = input.normalWS; 26 | #endif 27 | 28 | inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS); 29 | inputData.viewDirectionWS = viewDirWS; 30 | 31 | #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) 32 | inputData.shadowCoord = input.shadowCoord; 33 | #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS) 34 | inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS); 35 | #else 36 | inputData.shadowCoord = float4(0, 0, 0, 0); 37 | #endif 38 | 39 | inputData.fogCoord = 0.0; // we don't apply fog in the guffer pass 40 | 41 | #ifdef _ADDITIONAL_LIGHTS_VERTEX 42 | inputData.vertexLighting = input.vertexLighting.xyz; 43 | #else 44 | inputData.vertexLighting = half3(0, 0, 0); 45 | #endif 46 | 47 | inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS); 48 | } 49 | 50 | void InitializeBakedGIData(Varyings input, inout InputData inputData) 51 | { 52 | #if defined(DYNAMICLIGHTMAP_ON) 53 | inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.dynamicLightmapUV, input.vertexSH, inputData.normalWS); 54 | inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV); 55 | #elif !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)) 56 | inputData.bakedGI = SAMPLE_GI(input.vertexSH, 57 | GetAbsolutePositionWS(inputData.positionWS), 58 | inputData.normalWS, 59 | inputData.viewDirectionWS, 60 | inputData.positionCS.xy, 61 | input.probeOcclusion, 62 | inputData.shadowMask); 63 | #else 64 | inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.vertexSH, inputData.normalWS); 65 | inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV); 66 | #endif 67 | } 68 | 69 | /////////////////////////////////////////////////////////////////////////////// 70 | // Vertex and Fragment functions // 71 | /////////////////////////////////////////////////////////////////////////////// 72 | 73 | // Used in Standard (Physically Based) shader 74 | Varyings LitGBufferPassVertex(Attributes input) 75 | { 76 | Varyings output = (Varyings)0; 77 | 78 | UNITY_SETUP_INSTANCE_ID(input); 79 | UNITY_TRANSFER_INSTANCE_ID(input, output); 80 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); 81 | 82 | //////////////////////////////// 83 | UPDATE_INPUT_VERTEX(input); 84 | //////////////////////////////// 85 | 86 | VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz); 87 | 88 | // normalWS and tangentWS already normalize. 89 | // this is required to avoid skewing the direction during interpolation 90 | // also required for per-vertex lighting and SH evaluation 91 | VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS, input.tangentOS); 92 | 93 | output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); 94 | 95 | // already normalized from normal transform to WS. 96 | output.normalWS = normalInput.normalWS; 97 | 98 | #if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR) || defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR) 99 | real sign = input.tangentOS.w * GetOddNegativeScale(); 100 | half4 tangentWS = half4(normalInput.tangentWS.xyz, sign); 101 | #endif 102 | 103 | #if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR) 104 | output.tangentWS = tangentWS; 105 | #endif 106 | 107 | #if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR) 108 | half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS); 109 | half3 viewDirTS = GetViewDirectionTangentSpace(tangentWS, output.normalWS, viewDirWS); 110 | output.viewDirTS = viewDirTS; 111 | #endif 112 | 113 | OUTPUT_LIGHTMAP_UV(input.staticLightmapUV, unity_LightmapST, output.staticLightmapUV); 114 | #ifdef DYNAMICLIGHTMAP_ON 115 | output.dynamicLightmapUV = input.dynamicLightmapUV.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw; 116 | #endif 117 | OUTPUT_SH4(vertexInput.positionWS, output.normalWS.xyz, GetWorldSpaceNormalizeViewDir(vertexInput.positionWS), output.vertexSH, output.probeOcclusion); 118 | 119 | #ifdef _ADDITIONAL_LIGHTS_VERTEX 120 | half3 vertexLight = VertexLighting(vertexInput.positionWS, normalInput.normalWS); 121 | output.vertexLighting = vertexLight; 122 | #endif 123 | 124 | #if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR) 125 | output.positionWS = vertexInput.positionWS; 126 | #endif 127 | 128 | #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) 129 | output.shadowCoord = GetShadowCoord(vertexInput); 130 | #endif 131 | 132 | output.positionCS = vertexInput.positionCS; 133 | 134 | #if defined(REQUIRES_VERTEX_COLOR) 135 | output.color = input.color; 136 | #endif 137 | 138 | //////////////////////////////// 139 | UPDATE_OUTPUT_VERTEX(output); 140 | //////////////////////////////// 141 | 142 | return output; 143 | } 144 | 145 | // Used in Standard (Physically Based) shader 146 | FragmentOutput LitGBufferPassFragment(Varyings input) 147 | { 148 | UNITY_SETUP_INSTANCE_ID(input); 149 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); 150 | 151 | #if defined(_PARALLAXMAP) 152 | #if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR) 153 | half3 viewDirTS = input.viewDirTS; 154 | #else 155 | half3 viewDirWS = GetWorldSpaceNormalizeViewDir(input.positionWS); 156 | half3 viewDirTS = GetViewDirectionTangentSpace(input.tangentWS, input.normalWS, viewDirWS); 157 | #endif 158 | ApplyPerPixelDisplacement(viewDirTS, input.uv); 159 | #endif 160 | 161 | //////////////////////////////// 162 | SurfaceData surfaceData = GET_SURFACE_PROPERTIES(input); 163 | //////////////////////////////// 164 | 165 | #ifdef LOD_FADE_CROSSFADE 166 | LODFadeCrossFade(input.positionCS); 167 | #endif 168 | 169 | InputData inputData; 170 | InitializeInputData(input, surfaceData.normalTS, inputData); 171 | SETUP_DEBUG_TEXTURE_DATA(inputData, UNDO_TRANSFORM_TEX(input.uv, _BaseMap)); 172 | 173 | #if defined(_DBUFFER) 174 | ApplyDecalToSurfaceData(input.positionCS, surfaceData, inputData); 175 | #endif 176 | 177 | InitializeBakedGIData(input, inputData); 178 | 179 | // Stripped down version of UniversalFragmentPBR(). 180 | 181 | // in LitForwardPass GlobalIllumination (and temporarily LightingPhysicallyBased) are called inside UniversalFragmentPBR 182 | // in Deferred rendering we store the sum of these values (and of emission as well) in the GBuffer 183 | BRDFData brdfData; 184 | InitializeBRDFData(surfaceData.albedo, surfaceData.metallic, surfaceData.specular, surfaceData.smoothness, surfaceData.alpha, brdfData); 185 | 186 | Light mainLight = GetMainLight(inputData.shadowCoord, inputData.positionWS, inputData.shadowMask); 187 | MixRealtimeAndBakedGI(mainLight, inputData.normalWS, inputData.bakedGI, inputData.shadowMask); 188 | half3 color = GlobalIllumination(brdfData, inputData.bakedGI, surfaceData.occlusion, inputData.positionWS, inputData.normalWS, inputData.viewDirectionWS); 189 | 190 | return BRDFDataToGbuffer(brdfData, inputData, surfaceData.smoothness, surfaceData.emission + color, surfaceData.occlusion); 191 | } 192 | 193 | #endif 194 | -------------------------------------------------------------------------------- /Includes/URPLitGBufferPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb1ce0fb41f22f24abf3ef1586a24407 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Includes/URPMacros.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_MACROS_INCLUDED 2 | #define URP_SURFACE_SHADER_MACROS_INCLUDED 3 | 4 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" 5 | 6 | /////////////////////////////////////////////////////////////////////////////// 7 | // Surface Functions // 8 | /////////////////////////////////////////////////////////////////////////////// 9 | 10 | #ifndef GET_SURFACE_PROPERTIES 11 | 12 | #define GET_SURFACE_PROPERTIES GetDefaultSurfaceData 13 | 14 | inline SurfaceData GetDefaultSurfaceData(Varyings input) 15 | { 16 | SurfaceData surfaceOutput; 17 | InitializeStandardLitSurfaceData(input.uv, surfaceOutput); 18 | return surfaceOutput; 19 | } 20 | 21 | #endif 22 | 23 | #ifndef UPDATE_SHADOW_SURFACE 24 | 25 | #define UPDATE_SHADOW_SURFACE UpdateDefaultShadowSurfaceData 26 | 27 | inline void UpdateDefaultShadowSurfaceData(Varyings input) 28 | { 29 | 30 | } 31 | 32 | #endif 33 | 34 | #ifndef GET_UNLIT_SURFACE_PROPERTIES 35 | 36 | #define GET_UNLIT_SURFACE_PROPERTIES GetDefaultUnlitSurfaceData 37 | 38 | inline void GetDefaultUnlitSurfaceData(Varyings input, out half3 color, out float alpha) 39 | { 40 | half4 texColor = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv); 41 | color = texColor.rgb * _BaseColor.rgb; 42 | alpha = texColor.a * _BaseColor.a; 43 | } 44 | 45 | #endif 46 | 47 | /////////////////////////////////////////////////////////////////////////////// 48 | // Vertex functions // 49 | /////////////////////////////////////////////////////////////////////////////// 50 | 51 | #ifndef UPDATE_INPUT_VERTEX 52 | 53 | #define UPDATE_INPUT_VERTEX DontModifyInputVertex 54 | 55 | inline void DontModifyInputVertex(inout Attributes i) 56 | { 57 | 58 | } 59 | 60 | #endif 61 | 62 | #ifndef UPDATE_OUTPUT_VERTEX 63 | 64 | #define UPDATE_OUTPUT_VERTEX DontModifyOutputVertex 65 | 66 | inline void DontModifyOutputVertex(inout Varyings i) 67 | { 68 | 69 | } 70 | 71 | #endif 72 | 73 | #endif //URP_SURFACE_SHADER_MACROS_INCLUDED 74 | -------------------------------------------------------------------------------- /Includes/URPMacros.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4be306904e9f06241bb36ca1b5d1e634 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Includes/URPMetaPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_META_PASS_INCLUDED 2 | #define URP_SURFACE_SHADER_META_PASS_INCLUDED 3 | 4 | #include "URPShaderInputs.hlsl" 5 | #include "URPMacros.hlsl" 6 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MetaInput.hlsl" 7 | 8 | Varyings UniversalVertexMeta(Attributes input) 9 | { 10 | Varyings output; 11 | 12 | //////////////////////////////// 13 | UPDATE_INPUT_VERTEX(input); 14 | //////////////////////////////// 15 | 16 | output.positionCS = UnityMetaVertexPosition(input.positionOS.xyz, input.texcoord2, input.texcoord3); 17 | output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); 18 | 19 | //////////////////////////////// 20 | UPDATE_OUTPUT_VERTEX(output); 21 | //////////////////////////////// 22 | 23 | #ifdef EDITOR_VISUALIZATION 24 | UnityEditorVizData(input.positionOS.xyz, input.uv0, input.uv1, input.uv2, output.VizUV, output.LightCoord); 25 | #endif 26 | 27 | return output; 28 | } 29 | 30 | half4 UniversalFragmentMetaLit(Varyings input) : SV_Target 31 | { 32 | //////////////////////////////// 33 | SurfaceData surfaceData = GET_SURFACE_PROPERTIES(input); 34 | //////////////////////////////// 35 | 36 | BRDFData brdfData; 37 | InitializeBRDFData(surfaceData.albedo, surfaceData.metallic, surfaceData.specular, surfaceData.smoothness, surfaceData.alpha, brdfData); 38 | 39 | MetaInput metaInput; 40 | metaInput.Albedo = brdfData.diffuse + brdfData.specular * brdfData.roughness * 0.5; 41 | metaInput.Emission = surfaceData.emission; 42 | 43 | #ifdef EDITOR_VISUALIZATION 44 | metaInput.VizUV = fragIn.VizUV; 45 | metaInput.LightCoord = fragIn.LightCoord; 46 | #endif 47 | 48 | return UnityMetaFragment(metaInput); 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /Includes/URPMetaPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21e8e595585eaf64885d9114a5e4770c 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Includes/URPMotionVectorPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_OBJECT_MOTION_VECTORS_INCLUDED 2 | #define URP_SURFACE_SHADER_OBJECT_MOTION_VECTORS_INCLUDED 3 | 4 | #include "URPShaderInputs.hlsl" 5 | #include "URPMacros.hlsl" 6 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityInput.hlsl" 7 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 8 | 9 | #if defined(LOD_FADE_CROSSFADE) 10 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" 11 | #endif 12 | 13 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MotionVectorsCommon.hlsl" 14 | 15 | Varyings MotionVectorVertex(Attributes input) 16 | { 17 | Varyings output = (Varyings)0; 18 | 19 | UNITY_SETUP_INSTANCE_ID(input); 20 | UNITY_TRANSFER_INSTANCE_ID(input, output); 21 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); 22 | 23 | //////////////////////////////// 24 | UPDATE_INPUT_VERTEX(input); 25 | //////////////////////////////// 26 | 27 | const VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz); 28 | 29 | output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); 30 | 31 | #if defined(APLICATION_SPACE_WARP_MOTION) 32 | // We do not need jittered position in ASW 33 | output.positionCSNoJitter = mul(_NonJitteredViewProjMatrix, mul(UNITY_MATRIX_M, input.positionOS));; 34 | output.positionCS = output.positionCSNoJitter; 35 | #else 36 | // Jittered. Match the frame. 37 | output.positionCS = vertexInput.positionCS; 38 | output.positionCSNoJitter = mul(_NonJitteredViewProjMatrix, mul(UNITY_MATRIX_M, input.positionOS)); 39 | #endif 40 | 41 | float4 prevPos = (unity_MotionVectorsParams.x == 1) ? float4(input.positionOld, 1) : input.positionOS; 42 | 43 | #if _ADD_PRECOMPUTED_VELOCITY 44 | prevPos = prevPos - float4(input.alembicMotionVector, 0); 45 | #endif 46 | 47 | output.previousPositionCSNoJitter = mul(_PrevViewProjMatrix, mul(UNITY_PREV_MATRIX_M, prevPos)); 48 | 49 | return output; 50 | } 51 | 52 | // ------------------------------------- 53 | // Fragment 54 | float4 MotionVectorVertexFragment(Varyings input) : SV_Target 55 | { 56 | UNITY_SETUP_INSTANCE_ID(input); 57 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); 58 | 59 | #if defined(_ALPHATEST_ON) 60 | Alpha(SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)).a, _BaseColor, _Cutoff); 61 | #endif 62 | 63 | #if defined(LOD_FADE_CROSSFADE) 64 | LODFadeCrossFade(input.positionCS); 65 | #endif 66 | 67 | #if defined(APLICATION_SPACE_WARP_MOTION) 68 | return float4(CalcAswNdcMotionVectorFromCsPositions(input.positionCSNoJitter, input.previousPositionCSNoJitter), 1); 69 | #else 70 | return float4(CalcNdcMotionVectorFromCsPositions(input.positionCSNoJitter, input.previousPositionCSNoJitter), 0, 0); 71 | #endif 72 | } 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /Includes/URPMotionVectorPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be9379c9139a0fb439887fbacff6bbba 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Includes/URPShaderInputs.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_INPUTS_INCLUDED 2 | #define URP_SURFACE_SHADER_INPUTS_INCLUDED 3 | 4 | // TODO: Currently we support viewDirTS caclulated in vertex shader and in fragments shader. 5 | // As both solutions have their advantages and disadvantages (etc. shader target 2.0 has only 8 interpolators). 6 | // We need to find out if we can stick to one solution, which we needs testing. 7 | // So keeping this until I get manaul QA pass. 8 | #if defined(_PARALLAXMAP) && (SHADER_TARGET >= 30) 9 | #define REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR 10 | #endif 11 | 12 | #if (defined(_NORMALMAP) || (defined(_PARALLAXMAP) && !defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR))) || defined(_DETAIL) 13 | #define REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR 14 | #endif 15 | 16 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 17 | 18 | #if defined(FORWARD_PASS) || defined(GBUFFER_PASS) 19 | 20 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" 21 | 22 | #endif 23 | 24 | ///////////////////////////////////////// 25 | // Forward Lighting 26 | ///////////////////////////////////////// 27 | 28 | #if defined(FORWARD_PASS) 29 | 30 | struct Attributes 31 | { 32 | float4 positionOS : POSITION; 33 | float3 normalOS : NORMAL; 34 | float4 tangentOS : TANGENT; 35 | float4 color : COLOR; 36 | float2 texcoord : TEXCOORD0; 37 | float2 staticLightmapUV : TEXCOORD1; 38 | float2 dynamicLightmapUV : TEXCOORD2; 39 | UNITY_VERTEX_INPUT_INSTANCE_ID 40 | }; 41 | 42 | struct Varyings 43 | { 44 | float2 uv : TEXCOORD0; 45 | 46 | #if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR) 47 | float3 positionWS : TEXCOORD1; 48 | #endif 49 | 50 | float3 normalWS : TEXCOORD2; 51 | #if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR) 52 | half4 tangentWS : TEXCOORD3; // xyz: tangent, w: sign 53 | #endif 54 | float3 viewDirWS : TEXCOORD4; 55 | 56 | #ifdef _ADDITIONAL_LIGHTS_VERTEX 57 | half4 fogFactorAndVertexLight : TEXCOORD5; // x: fogFactor, yzw: vertex light 58 | #else 59 | half fogFactor : TEXCOORD5; 60 | #endif 61 | 62 | #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) 63 | float4 shadowCoord : TEXCOORD6; 64 | #endif 65 | 66 | #if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR) 67 | half3 viewDirTS : TEXCOORD7; 68 | #endif 69 | 70 | DECLARE_LIGHTMAP_OR_SH(staticLightmapUV, vertexSH, 8); 71 | #ifdef DYNAMICLIGHTMAP_ON 72 | float2 dynamicLightmapUV : TEXCOORD9; // Dynamic lightmap UVs 73 | #endif 74 | 75 | #if defined(REQUIRES_VERTEX_COLOR) 76 | float4 color : COLOR; 77 | #endif 78 | 79 | float4 positionCS : SV_POSITION; 80 | UNITY_VERTEX_INPUT_INSTANCE_ID 81 | UNITY_VERTEX_OUTPUT_STEREO 82 | }; 83 | 84 | ///////////////////////////////////////// 85 | // SHADOWS 86 | ///////////////////////////////////////// 87 | 88 | #elif defined(SHADOWS_PASS) 89 | 90 | struct Attributes 91 | { 92 | float4 positionOS : POSITION; 93 | float3 normalOS : NORMAL; 94 | float2 texcoord : TEXCOORD0; 95 | UNITY_VERTEX_INPUT_INSTANCE_ID 96 | }; 97 | 98 | struct Varyings 99 | { 100 | float2 uv : TEXCOORD0; 101 | float4 positionCS : SV_POSITION; 102 | }; 103 | 104 | ///////////////////////////////////////// 105 | // G Buffer 106 | ///////////////////////////////////////// 107 | 108 | #elif defined(GBUFFER_PASS) 109 | 110 | struct Attributes 111 | { 112 | float4 positionOS : POSITION; 113 | float3 normalOS : NORMAL; 114 | float4 tangentOS : TANGENT; 115 | float2 texcoord : TEXCOORD0; 116 | float4 color : COLOR; 117 | float2 staticLightmapUV : TEXCOORD1; 118 | float2 dynamicLightmapUV : TEXCOORD2; 119 | 120 | UNITY_VERTEX_INPUT_INSTANCE_ID 121 | }; 122 | 123 | struct Varyings 124 | { 125 | float2 uv : TEXCOORD0; 126 | 127 | #if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR) 128 | float3 positionWS : TEXCOORD1; 129 | #endif 130 | 131 | half3 normalWS : TEXCOORD2; 132 | #if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR) 133 | half4 tangentWS : TEXCOORD3; // xyz: tangent, w: sign 134 | #endif 135 | #ifdef _ADDITIONAL_LIGHTS_VERTEX 136 | half3 vertexLighting : TEXCOORD4; // xyz: vertex lighting 137 | #endif 138 | 139 | #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) 140 | float4 shadowCoord : TEXCOORD5; 141 | #endif 142 | 143 | #if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR) 144 | half3 viewDirTS : TEXCOORD6; 145 | #endif 146 | 147 | DECLARE_LIGHTMAP_OR_SH(staticLightmapUV, vertexSH, 7); 148 | #ifdef DYNAMICLIGHTMAP_ON 149 | float2 dynamicLightmapUV : TEXCOORD8; // Dynamic lightmap UVs 150 | #endif 151 | 152 | #ifdef USE_APV_PROBE_OCCLUSION 153 | float4 probeOcclusion : TEXCOORD9; 154 | #endif 155 | 156 | float4 positionCS : SV_POSITION; 157 | 158 | #if defined(REQUIRES_VERTEX_COLOR) 159 | float4 color : COLOR; 160 | #endif 161 | 162 | UNITY_VERTEX_INPUT_INSTANCE_ID 163 | UNITY_VERTEX_OUTPUT_STEREO 164 | }; 165 | 166 | ///////////////////////////////////////// 167 | // Depth Only 168 | ///////////////////////////////////////// 169 | 170 | #elif defined(DEPTH_ONLY_PASS) 171 | 172 | struct Attributes 173 | { 174 | float4 positionOS : POSITION; 175 | float2 texcoord : TEXCOORD0; 176 | float3 normalOS : NORMAL; 177 | UNITY_VERTEX_INPUT_INSTANCE_ID 178 | }; 179 | 180 | struct Varyings 181 | { 182 | float2 uv : TEXCOORD0; 183 | float4 positionCS : SV_POSITION; 184 | UNITY_VERTEX_INPUT_INSTANCE_ID 185 | UNITY_VERTEX_OUTPUT_STEREO 186 | }; 187 | 188 | ///////////////////////////////////////// 189 | // Depth Normals 190 | ///////////////////////////////////////// 191 | 192 | #elif defined(DEPTH_NORMALS_PASS) 193 | 194 | struct Attributes 195 | { 196 | float4 positionOS : POSITION; 197 | float4 tangentOS : TANGENT; 198 | float2 texcoord : TEXCOORD0; 199 | float3 normalOS : NORMAL; 200 | UNITY_VERTEX_INPUT_INSTANCE_ID 201 | }; 202 | 203 | struct Varyings 204 | { 205 | float4 positionCS : SV_POSITION; 206 | float2 uv : TEXCOORD1; 207 | float3 normalWS : TEXCOORD2; 208 | 209 | UNITY_VERTEX_INPUT_INSTANCE_ID 210 | UNITY_VERTEX_OUTPUT_STEREO 211 | }; 212 | 213 | ///////////////////////////////////////// 214 | // Meta 215 | ///////////////////////////////////////// 216 | 217 | #elif defined(META_PASS) 218 | 219 | struct Attributes 220 | { 221 | float4 positionOS : POSITION; 222 | float3 normalOS : NORMAL; 223 | float2 texcoord : TEXCOORD0; 224 | float2 texcoord2 : TEXCOORD1; 225 | float2 texcoord3 : TEXCOORD2; 226 | UNITY_VERTEX_INPUT_INSTANCE_ID 227 | }; 228 | 229 | struct Varyings 230 | { 231 | float4 positionCS : SV_POSITION; 232 | float2 uv : TEXCOORD0; 233 | #ifdef EDITOR_VISUALIZATION 234 | float2 VizUV : TEXCOORD1; 235 | float4 LightCoord : TEXCOORD2; 236 | #endif 237 | }; 238 | 239 | ///////////////////////////////////////// 240 | // 2D 241 | ///////////////////////////////////////// 242 | 243 | #elif defined(UNIVERSAL_2D_PASS) 244 | 245 | struct Attributes 246 | { 247 | float4 positionOS : POSITION; 248 | float3 normalOS : NORMAL; 249 | float2 texcoord : TEXCOORD0; 250 | }; 251 | 252 | struct Varyings 253 | { 254 | float4 positionCS : SV_POSITION; 255 | float2 uv : TEXCOORD0; 256 | 257 | #if defined(REQUIRES_VERTEX_COLOR) 258 | float4 color : COLOR; 259 | #endif 260 | }; 261 | 262 | ///////////////////////////////////////// 263 | // Motion Vectors 264 | ///////////////////////////////////////// 265 | 266 | #elif defined(MOTION_VECTOR_PASS) 267 | 268 | struct Attributes 269 | { 270 | float4 positionOS : POSITION; 271 | float3 normalOS : NORMAL; 272 | float2 texcoord : TEXCOORD0; 273 | 274 | float3 positionOld : TEXCOORD4; 275 | 276 | #if _ADD_PRECOMPUTED_VELOCITY 277 | float3 alembicMotionVector : TEXCOORD5; 278 | #endif 279 | 280 | UNITY_VERTEX_INPUT_INSTANCE_ID 281 | }; 282 | 283 | struct Varyings 284 | { 285 | float4 positionCS : SV_POSITION; 286 | float4 positionCSNoJitter : POSITION_CS_NO_JITTER; 287 | float4 previousPositionCSNoJitter : PREV_POSITION_CS_NO_JITTER; 288 | float2 uv : TEXCOORD0; 289 | 290 | UNITY_VERTEX_INPUT_INSTANCE_ID 291 | UNITY_VERTEX_OUTPUT_STEREO 292 | }; 293 | 294 | #endif 295 | 296 | #endif //URP_SURFACE_SHADER_INPUTS_INCLUDED 297 | -------------------------------------------------------------------------------- /Includes/URPShaderInputs.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d2524c3f748f5a468766375b0b40889 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Includes/URPShadowsPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_SHADOWS_INCLUDED 2 | #define URP_SURFACE_SHADER_SHADOWS_INCLUDED 3 | 4 | #include "URPShaderInputs.hlsl" 5 | #include "URPMacros.hlsl" 6 | 7 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 8 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl" 9 | #if defined(LOD_FADE_CROSSFADE) 10 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" 11 | #endif 12 | 13 | // Shadow Casting Light geometric parameters. These variables are used when applying the shadow Normal Bias and are set by UnityEngine.Rendering.Universal.ShadowUtils.SetupShadowCasterConstantBuffer in com.unity.render-pipelines.universal/Runtime/ShadowUtils.cs 14 | // For Directional lights, _LightDirection is used when applying shadow Normal Bias. 15 | // For Spot lights and Point lights, _LightPosition is used to compute the actual light direction because it is different at each shadow caster geometry vertex. 16 | float3 _LightDirection; 17 | float3 _LightPosition; 18 | 19 | float4 GetShadowPositionHClip(Attributes input) 20 | { 21 | float3 positionWS = TransformObjectToWorld(input.positionOS.xyz); 22 | float3 normalWS = TransformObjectToWorldNormal(input.normalOS); 23 | 24 | #if _CASTING_PUNCTUAL_LIGHT_SHADOW 25 | float3 lightDirectionWS = normalize(_LightPosition - positionWS); 26 | #else 27 | float3 lightDirectionWS = _LightDirection; 28 | #endif 29 | 30 | float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDirectionWS)); 31 | positionCS = ApplyShadowClamping(positionCS); 32 | return positionCS; 33 | } 34 | 35 | Varyings ShadowPassVertex(Attributes input) 36 | { 37 | Varyings output; 38 | 39 | UNITY_SETUP_INSTANCE_ID(input); 40 | UNITY_TRANSFER_INSTANCE_ID(input, output); 41 | 42 | //////////////////////////////// 43 | UPDATE_INPUT_VERTEX(input); 44 | //////////////////////////////// 45 | 46 | output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); 47 | output.positionCS = GetShadowPositionHClip(input); 48 | 49 | //////////////////////////////// 50 | UPDATE_OUTPUT_VERTEX(output); 51 | //////////////////////////////// 52 | 53 | return output; 54 | } 55 | 56 | half4 ShadowPassFragment(Varyings input) : SV_TARGET 57 | { 58 | UNITY_SETUP_INSTANCE_ID(input); 59 | 60 | //////////////////////////////// 61 | UPDATE_SHADOW_SURFACE(input); 62 | //////////////////////////////// 63 | 64 | #if defined(_ALPHATEST_ON) 65 | Alpha(SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)).a, _BaseColor, _Cutoff); 66 | #endif 67 | 68 | #if defined(LOD_FADE_CROSSFADE) 69 | LODFadeCrossFade(input.positionCS); 70 | #endif 71 | 72 | return 0; 73 | } 74 | 75 | #endif // URP_SURFACE_SHADER_SHADOWS_INCLUDED -------------------------------------------------------------------------------- /Includes/URPShadowsPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 45d7aa7e45eeddd45bd9784ed9398790 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Includes/URPUnlitDepthNormalsPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_UNLIT_DEPTH_NORMALS_PASS_INCLUDED 2 | #define URP_SURFACE_SHADER_UNLIT_DEPTH_NORMALS_PASS_INCLUDED 3 | 4 | #include "URPUnlitShaderInputs.hlsl" 5 | #include "URPMacros.hlsl" 6 | 7 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 8 | #if defined(LOD_FADE_CROSSFADE) 9 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" 10 | #endif 11 | 12 | Varyings DepthNormalsVertex(Attributes input) 13 | { 14 | Varyings output = (Varyings)0; 15 | 16 | UNITY_SETUP_INSTANCE_ID(input); 17 | UNITY_TRANSFER_INSTANCE_ID(input, output); 18 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); 19 | 20 | //////////////////////////////// 21 | UPDATE_INPUT_VERTEX(input); 22 | //////////////////////////////// 23 | 24 | #if defined(_ALPHATEST_ON) 25 | output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); 26 | #endif 27 | output.positionCS = TransformObjectToHClip(input.positionOS.xyz); 28 | 29 | VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS, input.tangentOS); 30 | output.normalWS = NormalizeNormalPerVertex(normalInput.normalWS); 31 | 32 | //////////////////////////////// 33 | UPDATE_OUTPUT_VERTEX(output); 34 | //////////////////////////////// 35 | 36 | return output; 37 | } 38 | 39 | void DepthNormalsFragment( 40 | Varyings input 41 | , out half4 outNormalWS : SV_Target0 42 | #ifdef _WRITE_RENDERING_LAYERS 43 | , out float4 outRenderingLayers : SV_Target1 44 | #endif 45 | ) 46 | { 47 | UNITY_SETUP_INSTANCE_ID(input); 48 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); 49 | 50 | #if defined(_ALPHATEST_ON) 51 | Alpha(SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)).a, _BaseColor, _Cutoff); 52 | #endif 53 | 54 | #if defined(LOD_FADE_CROSSFADE) 55 | LODFadeCrossFade(input.positionCS); 56 | #endif 57 | 58 | // Output... 59 | #if defined(_GBUFFER_NORMALS_OCT) 60 | float3 normalWS = normalize(input.normalWS); 61 | float2 octNormalWS = PackNormalOctQuadEncode(normalWS); // values between [-1, +1], must use fp32 on some platforms 62 | float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); // values between [ 0, 1] 63 | half3 packedNormalWS = half3(PackFloat2To888(remappedOctNormalWS)); // values between [ 0, 1] 64 | outNormalWS = half4(packedNormalWS, 0.0); 65 | #else 66 | outNormalWS = half4(NormalizeNormalPerPixel(input.normalWS), 0.0); 67 | #endif 68 | 69 | #ifdef _WRITE_RENDERING_LAYERS 70 | uint renderingLayers = GetMeshRenderingLayer(); 71 | outRenderingLayers = float4(EncodeMeshRenderingLayer(renderingLayers), 0, 0, 0); 72 | #endif 73 | } 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /Includes/URPUnlitDepthNormalsPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d0610c87794b1aa4696451f43c1f022c 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Includes/URPUnlitDepthOnlyPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_UNLIT_DEPTH_ONLY_PASS_INCLUDED 2 | #define URP_SURFACE_SHADER_UNLIT_DEPTH_ONLY_PASS_INCLUDED 3 | 4 | #include "URPUnlitShaderInputs.hlsl" 5 | #include "URPMacros.hlsl" 6 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 7 | #if defined(LOD_FADE_CROSSFADE) 8 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" 9 | #endif 10 | 11 | Varyings DepthOnlyVertex(Attributes input) 12 | { 13 | Varyings output = (Varyings)0; 14 | 15 | UNITY_SETUP_INSTANCE_ID(input); 16 | UNITY_TRANSFER_INSTANCE_ID(input, output); 17 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); 18 | 19 | //////////////////////////////// 20 | UPDATE_INPUT_VERTEX(input); 21 | //////////////////////////////// 22 | 23 | #if defined(_ALPHATEST_ON) 24 | output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); 25 | #endif 26 | output.positionCS = TransformObjectToHClip(input.positionOS.xyz); 27 | 28 | //////////////////////////////// 29 | UPDATE_OUTPUT_VERTEX(output); 30 | //////////////////////////////// 31 | 32 | return output; 33 | } 34 | 35 | half DepthOnlyFragment(Varyings input) : SV_TARGET 36 | { 37 | UNITY_SETUP_INSTANCE_ID(input); 38 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); 39 | 40 | #if defined(_ALPHATEST_ON) 41 | Alpha(SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)).a, _BaseColor, _Cutoff); 42 | #endif 43 | 44 | #if defined(LOD_FADE_CROSSFADE) 45 | LODFadeCrossFade(input.positionCS); 46 | #endif 47 | 48 | return input.positionCS.z; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /Includes/URPUnlitDepthOnlyPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0f990a4225a0b144ab25e6566e24939e 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Includes/URPUnlitForwardPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_UNLIT_FORWARD_PASS_INCLUDED 2 | #define URP_SURFACE_SHADER_UNLIT_FORWARD_PASS_INCLUDED 3 | 4 | #include "URPUnlitShaderInputs.hlsl" 5 | #include "URPMacros.hlsl" 6 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Unlit.hlsl" 7 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" 8 | #if defined(LOD_FADE_CROSSFADE) 9 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" 10 | #endif 11 | 12 | void InitializeInputData(Varyings input, out InputData inputData) 13 | { 14 | inputData = (InputData)0; 15 | 16 | #if defined(DEBUG_DISPLAY) 17 | inputData.positionWS = input.positionWS; 18 | inputData.positionCS = input.positionCS; 19 | inputData.normalWS = input.normalWS; 20 | inputData.viewDirectionWS = input.viewDirWS; 21 | #else 22 | inputData.positionWS = float3(0, 0, 0); 23 | inputData.normalWS = half3(0, 0, 1); 24 | inputData.viewDirectionWS = half3(0, 0, 1); 25 | #endif 26 | inputData.shadowCoord = 0; 27 | inputData.fogCoord = 0; 28 | inputData.vertexLighting = half3(0, 0, 0); 29 | inputData.bakedGI = half3(0, 0, 0); 30 | inputData.normalizedScreenSpaceUV = 0; 31 | inputData.shadowMask = half4(1, 1, 1, 1); 32 | } 33 | 34 | Varyings UnlitPassVertex(Attributes input) 35 | { 36 | Varyings output = (Varyings)0; 37 | 38 | UNITY_SETUP_INSTANCE_ID(input); 39 | UNITY_TRANSFER_INSTANCE_ID(input, output); 40 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); 41 | 42 | //////////////////////////////// 43 | UPDATE_INPUT_VERTEX(input); 44 | //////////////////////////////// 45 | 46 | VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz); 47 | 48 | output.positionCS = vertexInput.positionCS; 49 | output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); 50 | #if defined(_FOG_FRAGMENT) 51 | output.fogCoord = vertexInput.positionVS.z; 52 | #else 53 | output.fogCoord = ComputeFogFactor(vertexInput.positionCS.z); 54 | #endif 55 | 56 | #if defined(DEBUG_DISPLAY) 57 | // normalWS and tangentWS already normalize. 58 | // this is required to avoid skewing the direction during interpolation 59 | // also required for per-vertex lighting and SH evaluation 60 | VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS, input.tangentOS); 61 | half3 viewDirWS = GetWorldSpaceViewDir(vertexInput.positionWS); 62 | 63 | // already normalized from normal transform to WS. 64 | output.positionWS = vertexInput.positionWS; 65 | output.normalWS = normalInput.normalWS; 66 | output.viewDirWS = viewDirWS; 67 | #endif 68 | 69 | //////////////////////////////// 70 | UPDATE_OUTPUT_VERTEX(output); 71 | //////////////////////////////// 72 | 73 | return output; 74 | } 75 | 76 | void UnlitPassFragment( 77 | Varyings input 78 | , out half4 outColor : SV_Target0 79 | #ifdef _WRITE_RENDERING_LAYERS 80 | , out float4 outRenderingLayers : SV_Target1 81 | #endif 82 | ) 83 | { 84 | UNITY_SETUP_INSTANCE_ID(input); 85 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); 86 | 87 | //////////////////////////////// 88 | half3 color; 89 | float alpha; 90 | GET_UNLIT_SURFACE_PROPERTIES(input, color, alpha); 91 | //////////////////////////////// 92 | 93 | alpha = AlphaDiscard(alpha, _Cutoff); 94 | color = AlphaModulate(color, alpha); 95 | 96 | #ifdef LOD_FADE_CROSSFADE 97 | LODFadeCrossFade(input.positionCS); 98 | #endif 99 | 100 | InputData inputData; 101 | InitializeInputData(input, inputData); 102 | SETUP_DEBUG_TEXTURE_DATA(inputData, UNDO_TRANSFORM_TEX(input.uv, _BaseMap)); 103 | 104 | #ifdef _DBUFFER 105 | ApplyDecalToBaseColor(input.positionCS, color); 106 | #endif 107 | 108 | half4 finalColor = UniversalFragmentUnlit(inputData, color, alpha); 109 | 110 | #if defined(_SCREEN_SPACE_OCCLUSION) && !defined(_SURFACE_TYPE_TRANSPARENT) 111 | float2 normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS); 112 | AmbientOcclusionFactor aoFactor = GetScreenSpaceAmbientOcclusion(normalizedScreenSpaceUV); 113 | finalColor.rgb *= aoFactor.directAmbientOcclusion; 114 | #endif 115 | 116 | #if defined(_FOG_FRAGMENT) 117 | #if (defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2)) 118 | float viewZ = -input.fogCoord; 119 | float nearToFarZ = max(viewZ - _ProjectionParams.y, 0); 120 | half fogFactor = ComputeFogFactorZ0ToFar(nearToFarZ); 121 | #else 122 | half fogFactor = 0; 123 | #endif 124 | #else 125 | half fogFactor = input.fogCoord; 126 | #endif 127 | finalColor.rgb = MixFog(finalColor.rgb, fogFactor); 128 | finalColor.a = OutputAlpha(finalColor.a, IsSurfaceTypeTransparent(_Surface)); 129 | 130 | outColor = finalColor; 131 | 132 | #ifdef _WRITE_RENDERING_LAYERS 133 | uint renderingLayers = GetMeshRenderingLayer(); 134 | outRenderingLayers = float4(EncodeMeshRenderingLayer(renderingLayers), 0, 0, 0); 135 | #endif 136 | } 137 | 138 | #endif 139 | -------------------------------------------------------------------------------- /Includes/URPUnlitForwardPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e243f300399fb64a9d0fb921688f1ea 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Includes/URPUnlitGBufferPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_UNLIT_GBUFFER_PASS_INCLUDED 2 | #define URP_SURFACE_SHADER_UNLIT_GBUFFER_PASS_INCLUDED 3 | 4 | #include "URPUnlitShaderInputs.hlsl" 5 | #include "URPMacros.hlsl" 6 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Unlit.hlsl" 7 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityGBuffer.hlsl" 8 | #if defined(LOD_FADE_CROSSFADE) 9 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" 10 | #endif 11 | 12 | 13 | void InitializeInputData(Varyings input, out InputData inputData) 14 | { 15 | inputData = (InputData)0; 16 | 17 | inputData.normalWS = NormalizeNormalPerPixel(input.normalWS); 18 | 19 | inputData.positionWS = float3(0, 0, 0); 20 | inputData.viewDirectionWS = half3(0, 0, 1); 21 | inputData.shadowCoord = 0; 22 | inputData.fogCoord = 0; 23 | inputData.vertexLighting = half3(0, 0, 0); 24 | inputData.bakedGI = half3(0, 0, 0); 25 | inputData.normalizedScreenSpaceUV = 0; 26 | inputData.shadowMask = half4(1, 1, 1, 1); 27 | } 28 | 29 | /////////////////////////////////////////////////////////////////////////////// 30 | // Vertex and Fragment functions // 31 | /////////////////////////////////////////////////////////////////////////////// 32 | 33 | Varyings UnlitPassVertex(Attributes input) 34 | { 35 | Varyings output = (Varyings)0; 36 | 37 | UNITY_SETUP_INSTANCE_ID(input); 38 | UNITY_TRANSFER_INSTANCE_ID(input, output); 39 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); 40 | 41 | //////////////////////////////// 42 | UPDATE_INPUT_VERTEX(input); 43 | //////////////////////////////// 44 | 45 | VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz); 46 | output.positionCS = vertexInput.positionCS; 47 | 48 | output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); 49 | 50 | VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS); 51 | output.normalWS = normalInput.normalWS; 52 | 53 | #if defined(REQUIRES_VERTEX_COLOR) 54 | output.color = input.color; 55 | #endif 56 | 57 | //////////////////////////////// 58 | UPDATE_OUTPUT_VERTEX(output); 59 | //////////////////////////////// 60 | 61 | return output; 62 | } 63 | 64 | FragmentOutput UnlitPassFragment(Varyings input) 65 | { 66 | UNITY_SETUP_INSTANCE_ID(input); 67 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); 68 | 69 | //////////////////////////////// 70 | half3 color; 71 | float alpha; 72 | GET_UNLIT_SURFACE_PROPERTIES(input, color, alpha); 73 | //////////////////////////////// 74 | 75 | alpha = AlphaDiscard(alpha, _Cutoff); 76 | color = AlphaModulate(color, alpha); 77 | 78 | #ifdef LOD_FADE_CROSSFADE 79 | LODFadeCrossFade(input.positionCS); 80 | #endif 81 | 82 | InputData inputData; 83 | InitializeInputData(input, inputData); 84 | 85 | #ifdef _DBUFFER 86 | ApplyDecalToBaseColor(input.positionCS, color); 87 | #endif 88 | 89 | SurfaceData surfaceData = (SurfaceData)0; 90 | surfaceData.albedo = color; 91 | surfaceData.alpha = alpha; 92 | 93 | #if defined(_SCREEN_SPACE_OCCLUSION) // GBuffer never has transparents 94 | float2 normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS); 95 | AmbientOcclusionFactor aoFactor = GetScreenSpaceAmbientOcclusion(normalizedScreenSpaceUV); 96 | surfaceData.occlusion = aoFactor.directAmbientOcclusion; 97 | #else 98 | surfaceData.occlusion = 1; 99 | #endif 100 | 101 | return SurfaceDataToGbuffer(surfaceData, inputData, float3(0,0,0), kLightingInvalid); 102 | } 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /Includes/URPUnlitGBufferPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5942c44060cd9348acf104d2ff1fd93 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Includes/URPUnlitMetaPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_UNLIT_META_PASS_INCLUDED 2 | #define URP_SURFACE_SHADER_UNLIT_META_PASS_INCLUDED 3 | 4 | #include "URPUnlitShaderInputs.hlsl" 5 | #include "URPMacros.hlsl" 6 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MetaInput.hlsl" 7 | 8 | Varyings UniversalVertexMeta(Attributes input) 9 | { 10 | Varyings output; 11 | 12 | //////////////////////////////// 13 | UPDATE_INPUT_VERTEX(input); 14 | //////////////////////////////// 15 | 16 | output.positionCS = UnityMetaVertexPosition(input.positionOS.xyz, input.texcoord2, input.texcoord3); 17 | output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); 18 | 19 | #ifdef EDITOR_VISUALIZATION 20 | UnityEditorVizData(input.positionOS.xyz, input.texcoord, input.texcoord2, input.texcoord3, output.VizUV, output.LightCoord); 21 | #endif 22 | 23 | //////////////////////////////// 24 | UPDATE_OUTPUT_VERTEX(output); 25 | //////////////////////////////// 26 | 27 | return output; 28 | } 29 | 30 | half4 UniversalFragmentMetaUnlit(Varyings input) : SV_Target 31 | { 32 | MetaInput metaInput = (MetaInput)0; 33 | 34 | //////////////////////////////// 35 | half3 color; 36 | float alpha; 37 | GET_UNLIT_SURFACE_PROPERTIES(input, color, alpha); 38 | //////////////////////////////// 39 | 40 | AlphaDiscard(alpha, _Cutoff); 41 | color = AlphaModulate(color, alpha); 42 | 43 | metaInput.Albedo = color; 44 | 45 | #ifdef EDITOR_VISUALIZATION 46 | metaInput.VizUV = fragIn.VizUV; 47 | metaInput.LightCoord = fragIn.LightCoord; 48 | #endif 49 | 50 | return UnityMetaFragment(metaInput); 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /Includes/URPUnlitMetaPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a729f4d28e28b264a95d103adfb35584 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Includes/URPUnlitMotionVectorPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_UNLIT_OBJECT_MOTION_VECTORS_INCLUDED 2 | #define URP_SURFACE_SHADER_UNLIT_OBJECT_MOTION_VECTORS_INCLUDED 3 | 4 | #include "URPUnlitShaderInputs.hlsl" 5 | #include "URPMacros.hlsl" 6 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityInput.hlsl" 7 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 8 | 9 | #if defined(LOD_FADE_CROSSFADE) 10 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" 11 | #endif 12 | 13 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MotionVectorsCommon.hlsl" 14 | 15 | Varyings MotionVectorVertex(Attributes input) 16 | { 17 | Varyings output = (Varyings)0; 18 | 19 | UNITY_SETUP_INSTANCE_ID(input); 20 | UNITY_TRANSFER_INSTANCE_ID(input, output); 21 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); 22 | 23 | //////////////////////////////// 24 | UPDATE_INPUT_VERTEX(input); 25 | //////////////////////////////// 26 | 27 | const VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz); 28 | 29 | output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); 30 | 31 | #if defined(APLICATION_SPACE_WARP_MOTION) 32 | // We do not need jittered position in ASW 33 | output.positionCSNoJitter = mul(_NonJitteredViewProjMatrix, mul(UNITY_MATRIX_M, input.positionOS));; 34 | output.positionCS = output.positionCSNoJitter; 35 | #else 36 | // Jittered. Match the frame. 37 | output.positionCS = vertexInput.positionCS; 38 | output.positionCSNoJitter = mul(_NonJitteredViewProjMatrix, mul(UNITY_MATRIX_M, input.positionOS)); 39 | #endif 40 | 41 | float4 prevPos = (unity_MotionVectorsParams.x == 1) ? float4(input.positionOld, 1) : input.positionOS; 42 | 43 | #if _ADD_PRECOMPUTED_VELOCITY 44 | prevPos = prevPos - float4(input.alembicMotionVector, 0); 45 | #endif 46 | 47 | output.previousPositionCSNoJitter = mul(_PrevViewProjMatrix, mul(UNITY_PREV_MATRIX_M, prevPos)); 48 | 49 | return output; 50 | } 51 | 52 | // ------------------------------------- 53 | // Fragment 54 | float4 MotionVectorVertexFragment(Varyings input) : SV_Target 55 | { 56 | UNITY_SETUP_INSTANCE_ID(input); 57 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); 58 | 59 | #if defined(_ALPHATEST_ON) 60 | Alpha(SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)).a, _BaseColor, _Cutoff); 61 | #endif 62 | 63 | #if defined(LOD_FADE_CROSSFADE) 64 | LODFadeCrossFade(input.positionCS); 65 | #endif 66 | 67 | #if defined(APLICATION_SPACE_WARP_MOTION) 68 | return float4(CalcAswNdcMotionVectorFromCsPositions(input.positionCSNoJitter, input.previousPositionCSNoJitter), 1); 69 | #else 70 | return float4(CalcNdcMotionVectorFromCsPositions(input.positionCSNoJitter, input.previousPositionCSNoJitter), 0, 0); 71 | #endif 72 | } 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /Includes/URPUnlitMotionVectorPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dbae0f3fe40be6d44b812f7d87f3f56c 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Includes/URPUnlitShaderInputs.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_UNLIT_INPUT_INCLUDED 2 | #define URP_SURFACE_SHADER_UNLIT_INPUT_INCLUDED 3 | 4 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 5 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" 6 | 7 | #if defined(GBUFFER_PASS) 8 | 9 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" 10 | 11 | #endif 12 | 13 | ///////////////////////////////////////// 14 | // Forward Lighting 15 | ///////////////////////////////////////// 16 | 17 | #if defined(FORWARD_PASS) 18 | 19 | struct Attributes 20 | { 21 | float4 positionOS : POSITION; 22 | float2 texcoord : TEXCOORD0; 23 | float3 normalOS : NORMAL; 24 | float4 color : COLOR; 25 | #if defined(DEBUG_DISPLAY) 26 | float4 tangentOS : TANGENT; 27 | #endif 28 | 29 | UNITY_VERTEX_INPUT_INSTANCE_ID 30 | }; 31 | 32 | struct Varyings 33 | { 34 | float2 uv : TEXCOORD0; 35 | float fogCoord : TEXCOORD1; 36 | float4 positionCS : SV_POSITION; 37 | 38 | #if defined(REQUIRES_VERTEX_COLOR) 39 | float4 color : COLOR; 40 | #endif 41 | 42 | #if defined(DEBUG_DISPLAY) 43 | float3 positionWS : TEXCOORD2; 44 | float3 normalWS : TEXCOORD3; 45 | float3 viewDirWS : TEXCOORD4; 46 | #endif 47 | 48 | UNITY_VERTEX_INPUT_INSTANCE_ID 49 | UNITY_VERTEX_OUTPUT_STEREO 50 | }; 51 | 52 | ///////////////////////////////////////// 53 | // SHADOWS 54 | ///////////////////////////////////////// 55 | 56 | #elif defined(SHADOWS_PASS) 57 | 58 | struct Attributes 59 | { 60 | float4 positionOS : POSITION; 61 | float3 normalOS : NORMAL; 62 | float2 texcoord : TEXCOORD0; 63 | UNITY_VERTEX_INPUT_INSTANCE_ID 64 | }; 65 | 66 | struct Varyings 67 | { 68 | float2 uv : TEXCOORD0; 69 | float4 positionCS : SV_POSITION; 70 | }; 71 | 72 | ///////////////////////////////////////// 73 | // G Buffer 74 | ///////////////////////////////////////// 75 | 76 | #elif defined(GBUFFER_PASS) 77 | 78 | struct Attributes 79 | { 80 | float4 positionOS : POSITION; 81 | float2 texcoord : TEXCOORD0; 82 | float3 normalOS : NORMAL; 83 | float4 color : COLOR; 84 | 85 | UNITY_VERTEX_INPUT_INSTANCE_ID 86 | }; 87 | 88 | struct Varyings 89 | { 90 | float4 positionCS : SV_POSITION; 91 | float2 uv : TEXCOORD0; 92 | float3 normalWS : TEXCOORD1; 93 | 94 | #if defined(REQUIRES_VERTEX_COLOR) 95 | float4 color : COLOR; 96 | #endif 97 | 98 | UNITY_VERTEX_INPUT_INSTANCE_ID 99 | UNITY_VERTEX_OUTPUT_STEREO 100 | }; 101 | 102 | ///////////////////////////////////////// 103 | // Depth Only 104 | ///////////////////////////////////////// 105 | 106 | #elif defined(DEPTH_ONLY_PASS) 107 | 108 | struct Attributes 109 | { 110 | float4 positionOS : POSITION; 111 | float2 texcoord : TEXCOORD0; 112 | float3 normalOS : NORMAL; 113 | 114 | UNITY_VERTEX_INPUT_INSTANCE_ID 115 | }; 116 | 117 | struct Varyings 118 | { 119 | float2 uv : TEXCOORD0; 120 | float4 positionCS : SV_POSITION; 121 | UNITY_VERTEX_INPUT_INSTANCE_ID 122 | UNITY_VERTEX_OUTPUT_STEREO 123 | }; 124 | 125 | ///////////////////////////////////////// 126 | // Depth Normals 127 | ///////////////////////////////////////// 128 | 129 | #elif defined(DEPTH_NORMALS_PASS) 130 | 131 | struct Attributes 132 | { 133 | float3 normalOS : NORMAL; 134 | float4 positionOS : POSITION; 135 | float2 texcoord : TEXCOORD0; 136 | float4 tangentOS : TANGENT; 137 | UNITY_VERTEX_INPUT_INSTANCE_ID 138 | }; 139 | 140 | struct Varyings 141 | { 142 | float4 positionCS : SV_POSITION; 143 | float3 normalWS : TEXCOORD1; 144 | float2 uv : TEXCOORD2; 145 | 146 | UNITY_VERTEX_INPUT_INSTANCE_ID 147 | UNITY_VERTEX_OUTPUT_STEREO 148 | }; 149 | 150 | 151 | ///////////////////////////////////////// 152 | // Meta 153 | ///////////////////////////////////////// 154 | 155 | #elif defined(META_PASS) 156 | 157 | struct Attributes 158 | { 159 | float4 positionOS : POSITION; 160 | float3 normalOS : NORMAL; 161 | float2 texcoord : TEXCOORD0; 162 | float2 texcoord2 : TEXCOORD1; 163 | float2 texcoord3 : TEXCOORD2; 164 | UNITY_VERTEX_INPUT_INSTANCE_ID 165 | }; 166 | 167 | struct Varyings 168 | { 169 | float4 positionCS : SV_POSITION; 170 | float2 uv : TEXCOORD0; 171 | #ifdef EDITOR_VISUALIZATION 172 | float2 VizUV : TEXCOORD1; 173 | float4 LightCoord : TEXCOORD2; 174 | #endif 175 | }; 176 | 177 | ///////////////////////////////////////// 178 | // Motion Vectors 179 | ///////////////////////////////////////// 180 | 181 | #elif defined(MOTION_VECTOR_PASS) 182 | 183 | struct Attributes 184 | { 185 | float4 positionOS : POSITION; 186 | float3 normalOS : NORMAL; 187 | float2 texcoord : TEXCOORD0; 188 | float3 positionOld : TEXCOORD4; 189 | 190 | #if _ADD_PRECOMPUTED_VELOCITY 191 | float3 alembicMotionVector : TEXCOORD5; 192 | #endif 193 | 194 | UNITY_VERTEX_INPUT_INSTANCE_ID 195 | }; 196 | 197 | struct Varyings 198 | { 199 | float4 positionCS : SV_POSITION; 200 | float4 positionCSNoJitter : POSITION_CS_NO_JITTER; 201 | float4 previousPositionCSNoJitter : PREV_POSITION_CS_NO_JITTER; 202 | float2 uv : TEXCOORD0; 203 | 204 | UNITY_VERTEX_INPUT_INSTANCE_ID 205 | UNITY_VERTEX_OUTPUT_STEREO 206 | }; 207 | 208 | #endif 209 | 210 | #endif 211 | -------------------------------------------------------------------------------- /Includes/URPUnlitShaderInputs.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8396be06737b5c84c8b70a20243d5d66 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Includes/URPUnlitShadowsPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_SURFACE_SHADER_UNLIT_SHADOWS_INCLUDED 2 | #define URP_SURFACE_SHADER_UNLIT_SHADOWS_INCLUDED 3 | 4 | #include "URPUnlitShaderInputs.hlsl" 5 | #include "URPMacros.hlsl" 6 | 7 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 8 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl" 9 | #if defined(LOD_FADE_CROSSFADE) 10 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" 11 | #endif 12 | 13 | // Shadow Casting Light geometric parameters. These variables are used when applying the shadow Normal Bias and are set by UnityEngine.Rendering.Universal.ShadowUtils.SetupShadowCasterConstantBuffer in com.unity.render-pipelines.universal/Runtime/ShadowUtils.cs 14 | // For Directional lights, _LightDirection is used when applying shadow Normal Bias. 15 | // For Spot lights and Point lights, _LightPosition is used to compute the actual light direction because it is different at each shadow caster geometry vertex. 16 | float3 _LightDirection; 17 | float3 _LightPosition; 18 | 19 | float4 GetShadowPositionHClip(Attributes input) 20 | { 21 | float3 positionWS = TransformObjectToWorld(input.positionOS.xyz); 22 | float3 normalWS = TransformObjectToWorldNormal(input.normalOS); 23 | 24 | #if _CASTING_PUNCTUAL_LIGHT_SHADOW 25 | float3 lightDirectionWS = normalize(_LightPosition - positionWS); 26 | #else 27 | float3 lightDirectionWS = _LightDirection; 28 | #endif 29 | 30 | float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDirectionWS)); 31 | positionCS = ApplyShadowClamping(positionCS); 32 | return positionCS; 33 | } 34 | 35 | Varyings ShadowPassVertex(Attributes input) 36 | { 37 | Varyings output; 38 | 39 | UNITY_SETUP_INSTANCE_ID(input); 40 | UNITY_TRANSFER_INSTANCE_ID(input, output); 41 | 42 | //////////////////////////////// 43 | UPDATE_INPUT_VERTEX(input); 44 | //////////////////////////////// 45 | 46 | output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); 47 | output.positionCS = GetShadowPositionHClip(input); 48 | 49 | //////////////////////////////// 50 | UPDATE_OUTPUT_VERTEX(output); 51 | //////////////////////////////// 52 | 53 | return output; 54 | } 55 | 56 | half4 ShadowPassFragment(Varyings input) : SV_TARGET 57 | { 58 | UNITY_SETUP_INSTANCE_ID(input); 59 | 60 | //////////////////////////////// 61 | UPDATE_SHADOW_SURFACE(input); 62 | //////////////////////////////// 63 | 64 | #if defined(_ALPHATEST_ON) 65 | Alpha(SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)).a, _BaseColor, _Cutoff); 66 | #endif 67 | 68 | #if defined(LOD_FADE_CROSSFADE) 69 | LODFadeCrossFade(input.positionCS); 70 | #endif 71 | 72 | return 0; 73 | } 74 | 75 | #endif // URP_SURFACE_SHADER_SHADOWS_INCLUDED -------------------------------------------------------------------------------- /Includes/URPUnlitShadowsPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e0c9b79f86661624fb57d399e3c50c6c 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Todd Rivers 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed7bba4d729d4bc48be1ee8a7385a1f8 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity Universal Render Pipeline Surface Shader 2 | 3 | An easy to extend version of Unity's default lit URP shader. 4 | It allows you to extend and customise the default shader, or convert old Surface shaders into URP by overridding simple macros. 5 | 6 | See ExampleShader.shader and ExampleShader.cginc to see how to extend or customise a shader. 7 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e745d3c99e235274e87e0b00e9c777e1 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: de82db2516e2f6549afd05230c6fab08 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Shaders/Example Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f91450fbbf2fb8844b751f891595f19f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Shaders/Example Shader/ExampleShader.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_EXAMPLE_SURFACE_SHADER_INCLUDED 2 | #define URP_EXAMPLE_SURFACE_SHADER_INCLUDED 3 | 4 | ///////////////////////////////////////// 5 | // Include this at the start of your file 6 | ///////////////////////////////////////// 7 | 8 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPShaderInputs.hlsl" 9 | 10 | //////////////////////////////////////////// 11 | // Use this define to modify an input vertex 12 | //////////////////////////////////////////// 13 | 14 | #define UPDATE_INPUT_VERTEX ModifyInputVertex 15 | 16 | inline void ModifyInputVertex(inout Attributes i) 17 | { 18 | //Stretch vertex position over time 19 | float3 wobble = _CosTime[3] * i.positionOS.x; 20 | i.positionOS.xyz += wobble; 21 | } 22 | 23 | ///////////////////////////////////////////// 24 | // Use this to change the surfaces properties 25 | ///////////////////////////////////////////// 26 | 27 | #if defined(FORWARD_PASS) || defined(GBUFFER_PASS) 28 | 29 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" 30 | 31 | #define GET_SURFACE_PROPERTIES GetSurfaceProperties 32 | 33 | inline SurfaceData GetSurfaceProperties(Varyings input) 34 | { 35 | SurfaceData outSurfaceData; 36 | 37 | float2 uv = input.uv; 38 | 39 | ///////////////////////////////////////////////////////////////////////////////////////// 40 | // Default PBR surface properties match InitializeStandardLitSurfaceData in LitInput.hlsl 41 | ///////////////////////////////////////////////////////////////////////////////////////// 42 | 43 | half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)); 44 | outSurfaceData.alpha = Alpha(albedoAlpha.a, _BaseColor, _Cutoff); 45 | 46 | half4 specGloss = SampleMetallicSpecGloss(uv, albedoAlpha.a); 47 | outSurfaceData.albedo = albedoAlpha.rgb * _BaseColor.rgb; 48 | 49 | #if _SPECULAR_SETUP 50 | outSurfaceData.metallic = 1.0h; 51 | outSurfaceData.specular = specGloss.rgb; 52 | #else 53 | outSurfaceData.metallic = specGloss.r; 54 | outSurfaceData.specular = half3(0.0h, 0.0h, 0.0h); 55 | #endif 56 | 57 | outSurfaceData.smoothness = specGloss.a; 58 | outSurfaceData.normalTS = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale); 59 | outSurfaceData.occlusion = SampleOcclusion(uv); 60 | outSurfaceData.emission = SampleEmission(uv, _EmissionColor.rgb, TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap)); 61 | 62 | #if defined(_CLEARCOAT) || defined(_CLEARCOATMAP) 63 | half2 clearCoat = SampleClearCoat(uv); 64 | outSurfaceData.clearCoatMask = clearCoat.r; 65 | outSurfaceData.clearCoatSmoothness = clearCoat.g; 66 | #else 67 | outSurfaceData.clearCoatMask = 0.0h; 68 | outSurfaceData.clearCoatSmoothness = 0.0h; 69 | #endif 70 | 71 | #if defined(_DETAIL) 72 | half detailMask = SAMPLE_TEXTURE2D(_DetailMask, sampler_DetailMask, uv).a; 73 | float2 detailUv = uv * _DetailAlbedoMap_ST.xy + _DetailAlbedoMap_ST.zw; 74 | outSurfaceData.albedo = ApplyDetailAlbedo(detailUv, outSurfaceData.albedo, detailMask); 75 | outSurfaceData.normalTS = ApplyDetailNormal(detailUv, outSurfaceData.normalTS, detailMask); 76 | 77 | #endif 78 | 79 | /////////////////////////////////// 80 | // Animate emission to red over time 81 | ////////////////////////////////// 82 | 83 | float flash = (_SinTime[3] + 1) * 0.5; 84 | outSurfaceData.emission = lerp(outSurfaceData.albedo, half3(1,0,0), flash); 85 | 86 | return outSurfaceData; 87 | } 88 | 89 | #endif 90 | 91 | ///////////////////////////////////////////////////////// 92 | // Use this to change the surfaces properties for shadows 93 | ///////////////////////////////////////////////////////// 94 | 95 | #if defined(SHADOWS_PASS) 96 | 97 | #define UPDATE_SHADOW_SURFACE UpdateShadowSurfaceProperties 98 | 99 | inline void UpdateShadowSurfaceProperties(Varyings input) 100 | { 101 | //Update input to alter the shadows if needed 102 | } 103 | 104 | #endif 105 | 106 | #endif // URP_EXAMPLE_SURFACE_SHADER_INCLUDED -------------------------------------------------------------------------------- /Shaders/Example Shader/ExampleShader.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fcd71ce2917673b4392e2ebfc9d818b3 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shaders/Example Shader/ExampleShader.shader: -------------------------------------------------------------------------------- 1 | Shader "Universal Render Pipeline/Example Surface Shader" 2 | { 3 | Properties 4 | { 5 | // Specular vs Metallic workflow 6 | _WorkflowMode("WorkflowMode", Float) = 1.0 7 | 8 | [MainTexture] _BaseMap("Albedo", 2D) = "white" {} 9 | [MainColor] _BaseColor("Color", Color) = (1,1,1,1) 10 | 11 | _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 12 | 13 | _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 14 | _SmoothnessTextureChannel("Smoothness texture channel", Float) = 0 15 | 16 | _Metallic("Metallic", Range(0.0, 1.0)) = 0.0 17 | _MetallicGlossMap("Metallic", 2D) = "white" {} 18 | 19 | _SpecColor("Specular", Color) = (0.2, 0.2, 0.2) 20 | _SpecGlossMap("Specular", 2D) = "white" {} 21 | 22 | [ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0 23 | [ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0 24 | 25 | _BumpScale("Scale", Float) = 1.0 26 | _BumpMap("Normal Map", 2D) = "bump" {} 27 | 28 | _Parallax("Scale", Range(0.005, 0.08)) = 0.005 29 | _ParallaxMap("Height Map", 2D) = "black" {} 30 | 31 | _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0 32 | _OcclusionMap("Occlusion", 2D) = "white" {} 33 | 34 | [HDR] _EmissionColor("Color", Color) = (0,0,0) 35 | _EmissionMap("Emission", 2D) = "white" {} 36 | 37 | _DetailMask("Detail Mask", 2D) = "white" {} 38 | _DetailAlbedoMapScale("Scale", Range(0.0, 2.0)) = 1.0 39 | _DetailAlbedoMap("Detail Albedo x2", 2D) = "linearGrey" {} 40 | _DetailNormalMapScale("Scale", Range(0.0, 2.0)) = 1.0 41 | [Normal] _DetailNormalMap("Normal Map", 2D) = "bump" {} 42 | 43 | // SRP batching compatibility for Clear Coat (Not used in Lit) 44 | [HideInInspector] _ClearCoatMask("_ClearCoatMask", Float) = 0.0 45 | [HideInInspector] _ClearCoatSmoothness("_ClearCoatSmoothness", Float) = 0.0 46 | 47 | // Blending state 48 | _Surface("__surface", Float) = 0.0 49 | _Blend("__blend", Float) = 0.0 50 | _Cull("__cull", Float) = 2.0 51 | [ToggleUI] _AlphaClip("__clip", Float) = 0.0 52 | [HideInInspector] _SrcBlend("__src", Float) = 1.0 53 | [HideInInspector] _DstBlend("__dst", Float) = 0.0 54 | [HideInInspector] _SrcBlendAlpha("__srcA", Float) = 1.0 55 | [HideInInspector] _DstBlendAlpha("__dstA", Float) = 0.0 56 | [HideInInspector] _ZWrite("__zw", Float) = 1.0 57 | [HideInInspector] _BlendModePreserveSpecular("_BlendModePreserveSpecular", Float) = 1.0 58 | [HideInInspector] _AlphaToMask("__alphaToMask", Float) = 0.0 59 | [HideInInspector] _AddPrecomputedVelocity("_AddPrecomputedVelocity", Float) = 0.0 60 | 61 | [ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0 62 | // Editmode props 63 | _QueueOffset("Queue offset", Float) = 0.0 64 | 65 | // ObsoleteProperties 66 | [HideInInspector] _MainTex("BaseMap", 2D) = "white" {} 67 | [HideInInspector] _Color("Base Color", Color) = (1, 1, 1, 1) 68 | [HideInInspector] _GlossMapScale("Smoothness", Float) = 0.0 69 | [HideInInspector] _Glossiness("Smoothness", Float) = 0.0 70 | [HideInInspector] _GlossyReflections("EnvironmentReflections", Float) = 0.0 71 | 72 | [HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {} 73 | [HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {} 74 | [HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {} 75 | } 76 | 77 | SubShader 78 | { 79 | // Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings 80 | // this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this 81 | // material work with both Universal Render Pipeline and Builtin Unity Pipeline 82 | Tags 83 | { 84 | "RenderType" = "Opaque" 85 | "RenderPipeline" = "UniversalPipeline" 86 | "UniversalMaterialType" = "Lit" 87 | "IgnoreProjector" = "True" 88 | } 89 | LOD 300 90 | 91 | // ------------------------------------------------------------------ 92 | // Forward pass. Shades all light in a single pass. GI + emission + Fog 93 | Pass 94 | { 95 | // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with 96 | // no LightMode tag are also rendered by Universal Render Pipeline 97 | Name "ForwardLit" 98 | Tags 99 | { 100 | "LightMode" = "UniversalForward" 101 | } 102 | 103 | // ------------------------------------- 104 | // Render State Commands 105 | Blend[_SrcBlend][_DstBlend], [_SrcBlendAlpha][_DstBlendAlpha] 106 | ZWrite[_ZWrite] 107 | Cull[_Cull] 108 | AlphaToMask[_AlphaToMask] 109 | 110 | HLSLPROGRAM 111 | #pragma target 2.0 112 | 113 | // ------------------------------------- 114 | // Shader Stages 115 | #pragma vertex LitPassVertex 116 | #pragma fragment LitPassFragment 117 | 118 | // ------------------------------------- 119 | // Material Keywords 120 | #pragma shader_feature_local _NORMALMAP 121 | #pragma shader_feature_local _PARALLAXMAP 122 | #pragma shader_feature_local _RECEIVE_SHADOWS_OFF 123 | #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED 124 | #pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT 125 | #pragma shader_feature_local_fragment _ALPHATEST_ON 126 | #pragma shader_feature_local_fragment _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON 127 | #pragma shader_feature_local_fragment _EMISSION 128 | #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP 129 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 130 | #pragma shader_feature_local_fragment _OCCLUSIONMAP 131 | #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF 132 | #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF 133 | #pragma shader_feature_local_fragment _SPECULAR_SETUP 134 | 135 | // ------------------------------------- 136 | // Universal Pipeline keywords 137 | #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN 138 | #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS 139 | #pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX 140 | #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS 141 | #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING 142 | #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION 143 | #pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH 144 | #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION 145 | #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 146 | #pragma multi_compile_fragment _ _LIGHT_COOKIES 147 | #pragma multi_compile _ _LIGHT_LAYERS 148 | #pragma multi_compile _ _FORWARD_PLUS 149 | #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" 150 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 151 | 152 | 153 | // ------------------------------------- 154 | // Unity defined keywords 155 | #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING 156 | #pragma multi_compile _ SHADOWS_SHADOWMASK 157 | #pragma multi_compile _ DIRLIGHTMAP_COMBINED 158 | #pragma multi_compile _ LIGHTMAP_ON 159 | #pragma multi_compile _ DYNAMICLIGHTMAP_ON 160 | #pragma multi_compile _ USE_LEGACY_LIGHTMAPS 161 | #pragma multi_compile _ LOD_FADE_CROSSFADE 162 | #pragma multi_compile_fog 163 | #pragma multi_compile_fragment _ DEBUG_DISPLAY 164 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl" 165 | 166 | //-------------------------------------- 167 | // GPU Instancing 168 | #pragma multi_compile_instancing 169 | #pragma instancing_options renderinglayer 170 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 171 | 172 | #define FORWARD_PASS 173 | 174 | #include "ExampleShader.hlsl" 175 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPLightingPass.hlsl" 176 | 177 | ENDHLSL 178 | } 179 | 180 | Pass 181 | { 182 | Name "ShadowCaster" 183 | Tags 184 | { 185 | "LightMode" = "ShadowCaster" 186 | } 187 | 188 | // ------------------------------------- 189 | // Render State Commands 190 | ZWrite On 191 | ZTest LEqual 192 | ColorMask 0 193 | Cull[_Cull] 194 | 195 | HLSLPROGRAM 196 | #pragma target 2.0 197 | 198 | // ------------------------------------- 199 | // Shader Stages 200 | #pragma vertex ShadowPassVertex 201 | #pragma fragment ShadowPassFragment 202 | 203 | // ------------------------------------- 204 | // Material Keywords 205 | #pragma shader_feature_local _ALPHATEST_ON 206 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 207 | 208 | //-------------------------------------- 209 | // GPU Instancing 210 | #pragma multi_compile_instancing 211 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 212 | 213 | // ------------------------------------- 214 | // Universal Pipeline keywords 215 | 216 | // ------------------------------------- 217 | // Unity defined keywords 218 | #pragma multi_compile _ LOD_FADE_CROSSFADE 219 | 220 | // This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias 221 | #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW 222 | 223 | // ------------------------------------- 224 | // Includes 225 | 226 | #define SHADOWS_PASS 227 | 228 | #include "ExampleShader.hlsl" 229 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPShadowsPass.hlsl" 230 | 231 | ENDHLSL 232 | } 233 | 234 | Pass 235 | { 236 | // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with 237 | // no LightMode tag are also rendered by Universal Render Pipeline 238 | Name "GBuffer" 239 | Tags 240 | { 241 | "LightMode" = "UniversalGBuffer" 242 | } 243 | 244 | // ------------------------------------- 245 | // Render State Commands 246 | ZWrite[_ZWrite] 247 | ZTest LEqual 248 | Cull[_Cull] 249 | 250 | HLSLPROGRAM 251 | #pragma target 4.5 252 | 253 | // Deferred Rendering Path does not support the OpenGL-based graphics API: 254 | // Desktop OpenGL, OpenGL ES 3.0, WebGL 2.0. 255 | #pragma exclude_renderers gles3 glcore 256 | 257 | // ------------------------------------- 258 | // Shader Stages 259 | #pragma vertex LitGBufferPassVertex 260 | #pragma fragment LitGBufferPassFragment 261 | 262 | // ------------------------------------- 263 | // Material Keywords 264 | #pragma shader_feature_local _NORMALMAP 265 | #pragma shader_feature_local_fragment _ALPHATEST_ON 266 | //#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON 267 | #pragma shader_feature_local_fragment _EMISSION 268 | #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP 269 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 270 | #pragma shader_feature_local_fragment _OCCLUSIONMAP 271 | #pragma shader_feature_local _PARALLAXMAP 272 | #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED 273 | 274 | #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF 275 | #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF 276 | #pragma shader_feature_local_fragment _SPECULAR_SETUP 277 | #pragma shader_feature_local _RECEIVE_SHADOWS_OFF 278 | 279 | // ------------------------------------- 280 | // Universal Pipeline keywords 281 | #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN 282 | //#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS 283 | //#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS 284 | #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING 285 | #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION 286 | #pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH 287 | #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 288 | #pragma multi_compile_fragment _ _RENDER_PASS_ENABLED 289 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 290 | 291 | // ------------------------------------- 292 | // Unity defined keywords 293 | #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING 294 | #pragma multi_compile _ SHADOWS_SHADOWMASK 295 | #pragma multi_compile _ DIRLIGHTMAP_COMBINED 296 | #pragma multi_compile _ LIGHTMAP_ON 297 | #pragma multi_compile _ DYNAMICLIGHTMAP_ON 298 | #pragma multi_compile _ USE_LEGACY_LIGHTMAPS 299 | #pragma multi_compile _ LOD_FADE_CROSSFADE 300 | #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT 301 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl" 302 | 303 | //-------------------------------------- 304 | // GPU Instancing 305 | #pragma multi_compile_instancing 306 | #pragma instancing_options renderinglayer 307 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 308 | 309 | // ------------------------------------- 310 | // Includes 311 | 312 | #define GBUFFER_PASS 313 | 314 | #include "ExampleShader.hlsl" 315 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPLitGBufferPass.hlsl" 316 | 317 | ENDHLSL 318 | } 319 | 320 | Pass 321 | { 322 | Name "DepthOnly" 323 | Tags 324 | { 325 | "LightMode" = "DepthOnly" 326 | } 327 | 328 | // ------------------------------------- 329 | // Render State Commands 330 | ZWrite On 331 | ColorMask R 332 | Cull[_Cull] 333 | 334 | HLSLPROGRAM 335 | #pragma target 2.0 336 | 337 | // ------------------------------------- 338 | // Shader Stages 339 | #pragma vertex DepthOnlyVertex 340 | #pragma fragment DepthOnlyFragment 341 | 342 | // ------------------------------------- 343 | // Material Keywords 344 | #pragma shader_feature_local _ALPHATEST_ON 345 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 346 | 347 | // ------------------------------------- 348 | // Unity defined keywords 349 | #pragma multi_compile _ LOD_FADE_CROSSFADE 350 | 351 | //-------------------------------------- 352 | // GPU Instancing 353 | #pragma multi_compile_instancing 354 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 355 | 356 | // ------------------------------------- 357 | // Includes 358 | 359 | #define DEPTH_ONLY_PASS 360 | 361 | #include "ExampleShader.hlsl" 362 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPDepthOnlyPass.hlsl" 363 | 364 | ENDHLSL 365 | } 366 | 367 | // This pass is used when drawing to a _CameraNormalsTexture texture 368 | Pass 369 | { 370 | Name "DepthNormals" 371 | Tags 372 | { 373 | "LightMode" = "DepthNormals" 374 | } 375 | 376 | // ------------------------------------- 377 | // Render State Commands 378 | ZWrite On 379 | Cull[_Cull] 380 | 381 | HLSLPROGRAM 382 | #pragma target 2.0 383 | 384 | // ------------------------------------- 385 | // Shader Stages 386 | #pragma vertex DepthNormalsVertex 387 | #pragma fragment DepthNormalsFragment 388 | 389 | // ------------------------------------- 390 | // Material Keywords 391 | #pragma shader_feature_local _NORMALMAP 392 | #pragma shader_feature_local _PARALLAXMAP 393 | #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED 394 | #pragma shader_feature_local _ALPHATEST_ON 395 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 396 | 397 | // ------------------------------------- 398 | // Unity defined keywords 399 | #pragma multi_compile _ LOD_FADE_CROSSFADE 400 | 401 | // ------------------------------------- 402 | // Universal Pipeline keywords 403 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 404 | 405 | //-------------------------------------- 406 | // GPU Instancing 407 | #pragma multi_compile_instancing 408 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 409 | 410 | // ------------------------------------- 411 | // Includes 412 | 413 | #define DEPTH_NORMALS_PASS 414 | 415 | #include "ExampleShader.hlsl" 416 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPDepthNormalsPass.hlsl" 417 | 418 | ENDHLSL 419 | } 420 | 421 | // This pass it not used during regular rendering, only for lightmap baking. 422 | Pass 423 | { 424 | Name "Meta" 425 | Tags 426 | { 427 | "LightMode" = "Meta" 428 | } 429 | 430 | // ------------------------------------- 431 | // Render State Commands 432 | Cull Off 433 | 434 | HLSLPROGRAM 435 | #pragma target 2.0 436 | 437 | // ------------------------------------- 438 | // Shader Stages 439 | #pragma vertex UniversalVertexMeta 440 | #pragma fragment UniversalFragmentMetaLit 441 | 442 | // ------------------------------------- 443 | // Material Keywords 444 | #pragma shader_feature_local_fragment _SPECULAR_SETUP 445 | #pragma shader_feature_local_fragment _EMISSION 446 | #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP 447 | #pragma shader_feature_local_fragment _ALPHATEST_ON 448 | #pragma shader_feature_local_fragment _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 449 | #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED 450 | #pragma shader_feature_local_fragment _SPECGLOSSMAP 451 | #pragma shader_feature EDITOR_VISUALIZATION 452 | 453 | // ------------------------------------- 454 | // Includes 455 | 456 | #define META_PASS 457 | 458 | #include "ExampleShader.hlsl" 459 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPMetaPass.hlsl" 460 | 461 | ENDHLSL 462 | } 463 | 464 | Pass 465 | { 466 | Name "Universal2D" 467 | Tags 468 | { 469 | "LightMode" = "Universal2D" 470 | } 471 | 472 | // ------------------------------------- 473 | // Render State Commands 474 | Blend[_SrcBlend][_DstBlend] 475 | ZWrite[_ZWrite] 476 | Cull[_Cull] 477 | 478 | HLSLPROGRAM 479 | #pragma target 2.0 480 | 481 | // ------------------------------------- 482 | // Shader Stages 483 | #pragma vertex vert 484 | #pragma fragment frag 485 | 486 | // ------------------------------------- 487 | // Material Keywords 488 | #pragma shader_feature_local_fragment _ALPHATEST_ON 489 | #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON 490 | 491 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 492 | 493 | // ------------------------------------- 494 | // Includes 495 | 496 | #define UNIVERSAL_2D_PASS 497 | 498 | #include "ExampleShader.hlsl" 499 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URP2DPass.hlsl" 500 | 501 | ENDHLSL 502 | } 503 | 504 | Pass 505 | { 506 | Name "MotionVectors" 507 | Tags { "LightMode" = "MotionVectors" } 508 | ColorMask RG 509 | 510 | HLSLPROGRAM 511 | 512 | // ------------------------------------- 513 | // Shader Stages 514 | #pragma vertex MotionVectorVertex 515 | #pragma fragment MotionVectorVertexFragment 516 | 517 | // ------------------------------------- 518 | // Material Keywords 519 | #pragma shader_feature_local _ALPHATEST_ON 520 | #pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY 521 | 522 | // ------------------------------------- 523 | // Unity defined keywords 524 | #pragma multi_compile _ LOD_FADE_CROSSFADE 525 | 526 | // ------------------------------------- 527 | // Includes 528 | 529 | #define MOTION_VECTOR_PASS 530 | 531 | #include "ExampleShader.hlsl" 532 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPMotionVectorPass.hlsl" 533 | 534 | ENDHLSL 535 | } 536 | 537 | Pass 538 | { 539 | Name "XRMotionVectors" 540 | Tags { "LightMode" = "XRMotionVectors" } 541 | ColorMask RGBA 542 | 543 | // Stencil write for obj motion pixels 544 | Stencil 545 | { 546 | WriteMask 1 547 | Ref 1 548 | Comp Always 549 | Pass Replace 550 | } 551 | 552 | HLSLPROGRAM 553 | 554 | // ------------------------------------- 555 | // Shader Stages 556 | #pragma vertex MotionVectorVertex 557 | #pragma fragment MotionVectorVertexFragment 558 | 559 | // ------------------------------------- 560 | // Material Keywords 561 | #pragma shader_feature_local _ALPHATEST_ON 562 | #pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY 563 | 564 | // ------------------------------------- 565 | // Unity defined keywords 566 | #pragma multi_compile _ LOD_FADE_CROSSFADE 567 | #define APLICATION_SPACE_WARP_MOTION 1 568 | 569 | // ------------------------------------- 570 | // Includes 571 | 572 | #define MOTION_VECTOR_PASS 573 | 574 | #include "ExampleShader.hlsl" 575 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPMotionVectorPass.hlsl" 576 | 577 | ENDHLSL 578 | } 579 | } 580 | 581 | FallBack "Hidden/Universal Render Pipeline/FallbackError" 582 | CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.LitShader" 583 | } 584 | -------------------------------------------------------------------------------- /Shaders/Example Shader/ExampleShader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d53dbed6577e7e443a384d74218abc3a 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shaders/Example Unlit Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a71171d872d65d24e9c6af697739da87 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Shaders/Example Unlit Shader/ExampleUnlitShader.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef URP_EXAMPLE_SURFACE_SHADER_INCLUDED 2 | #define URP_EXAMPLE_SURFACE_SHADER_INCLUDED 3 | 4 | ///////////////////////////////////////// 5 | // Include this at the start of your file 6 | ///////////////////////////////////////// 7 | 8 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitShaderInputs.hlsl" 9 | 10 | //////////////////////////////////////////// 11 | // Use this define to modify an input vertex 12 | //////////////////////////////////////////// 13 | 14 | #define UPDATE_INPUT_VERTEX ModifyInputVertex 15 | 16 | inline void ModifyInputVertex(inout Attributes i) 17 | { 18 | //Stretch vertex position over time 19 | float3 wobble = _CosTime[3] * i.positionOS.x; 20 | i.positionOS.xyz += wobble; 21 | } 22 | 23 | ///////////////////////////////////////////// 24 | // Use this to change the surfaces properties 25 | ///////////////////////////////////////////// 26 | 27 | #define GET_UNLIT_SURFACE_PROPERTIES GetUnlitSurfaceData 28 | 29 | inline void GetUnlitSurfaceData(Varyings input, out half3 color, out float alpha) 30 | { 31 | half4 texColor = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv); 32 | color = texColor.rgb * _BaseColor.rgb; 33 | alpha = texColor.a * _BaseColor.a; 34 | 35 | /////////////////////////////////// 36 | // Animate color to red over time 37 | ////////////////////////////////// 38 | 39 | float flash = (_SinTime[3] + 1) * 0.5; 40 | color = lerp(color, half3(1,0,0), flash); 41 | } 42 | 43 | #endif // URP_EXAMPLE_SURFACE_SHADER_INCLUDED -------------------------------------------------------------------------------- /Shaders/Example Unlit Shader/ExampleUnlitShader.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9805df67d4f7dff47954ea86590807e4 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Shaders/Example Unlit Shader/ExampleUnlitShader.shader: -------------------------------------------------------------------------------- 1 | Shader "Universal Render Pipeline/Example Unlit Shader" 2 | { 3 | Properties 4 | { 5 | [MainTexture] _BaseMap("Texture", 2D) = "white" {} 6 | [MainColor] _BaseColor("Color", Color) = (1, 1, 1, 1) 7 | _Cutoff("AlphaCutout", Range(0.0, 1.0)) = 0.5 8 | 9 | // BlendMode 10 | _Surface("__surface", Float) = 0.0 11 | _Blend("__mode", Float) = 0.0 12 | _Cull("__cull", Float) = 2.0 13 | [ToggleUI] _AlphaClip("__clip", Float) = 0.0 14 | [HideInInspector] _BlendOp("__blendop", Float) = 0.0 15 | [HideInInspector] _SrcBlend("__src", Float) = 1.0 16 | [HideInInspector] _DstBlend("__dst", Float) = 0.0 17 | [HideInInspector] _SrcBlendAlpha("__srcA", Float) = 1.0 18 | [HideInInspector] _DstBlendAlpha("__dstA", Float) = 0.0 19 | [HideInInspector] _ZWrite("__zw", Float) = 1.0 20 | [HideInInspector] _AlphaToMask("__alphaToMask", Float) = 0.0 21 | [HideInInspector] _AddPrecomputedVelocity("_AddPrecomputedVelocity", Float) = 0.0 22 | 23 | // Editmode props 24 | _QueueOffset("Queue offset", Float) = 0.0 25 | 26 | // ObsoleteProperties 27 | [HideInInspector] _MainTex("BaseMap", 2D) = "white" {} 28 | [HideInInspector] _Color("Base Color", Color) = (0.5, 0.5, 0.5, 1) 29 | [HideInInspector] _SampleGI("SampleGI", float) = 0.0 // needed from bakedlit 30 | } 31 | 32 | SubShader 33 | { 34 | Tags 35 | { 36 | "RenderType" = "Opaque" 37 | "IgnoreProjector" = "True" 38 | "UniversalMaterialType" = "Unlit" 39 | "RenderPipeline" = "UniversalPipeline" 40 | } 41 | LOD 100 42 | 43 | // ------------------------------------- 44 | // Render State Commands 45 | Blend [_SrcBlend][_DstBlend], [_SrcBlendAlpha][_DstBlendAlpha] 46 | ZWrite [_ZWrite] 47 | Cull [_Cull] 48 | 49 | Pass 50 | { 51 | Name "Unlit" 52 | 53 | // ------------------------------------- 54 | // Render State Commands 55 | AlphaToMask[_AlphaToMask] 56 | 57 | HLSLPROGRAM 58 | #pragma target 2.0 59 | 60 | // ------------------------------------- 61 | // Shader Stages 62 | #pragma vertex UnlitPassVertex 63 | #pragma fragment UnlitPassFragment 64 | 65 | // ------------------------------------- 66 | // Material Keywords 67 | #pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT 68 | #pragma shader_feature_local_fragment _ALPHATEST_ON 69 | #pragma shader_feature_local_fragment _ALPHAMODULATE_ON 70 | 71 | // ------------------------------------- 72 | // Unity defined keywords 73 | #pragma multi_compile_fog 74 | #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION 75 | #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 76 | #pragma multi_compile _ DEBUG_DISPLAY 77 | #pragma multi_compile _ LOD_FADE_CROSSFADE 78 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 79 | 80 | //-------------------------------------- 81 | // GPU Instancing 82 | #pragma multi_compile_instancing 83 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 84 | 85 | // ------------------------------------- 86 | // Includes 87 | 88 | #define FORWARD_PASS 89 | 90 | #include "ExampleUnlitShader.hlsl" 91 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitForwardPass.hlsl" 92 | 93 | ENDHLSL 94 | } 95 | 96 | // Fill GBuffer data to prevent "holes", just in case someone wants to reuse GBuffer for non-lighting effects. 97 | // Deferred lighting is stenciled out. 98 | Pass 99 | { 100 | Name "GBuffer" 101 | Tags 102 | { 103 | "LightMode" = "UniversalGBuffer" 104 | } 105 | 106 | HLSLPROGRAM 107 | #pragma target 4.5 108 | 109 | // Deferred Rendering Path does not support the OpenGL-based graphics API: 110 | // Desktop OpenGL, OpenGL ES 3.0, WebGL 2.0. 111 | #pragma exclude_renderers gles3 glcore 112 | 113 | // ------------------------------------- 114 | // Shader Stages 115 | #pragma vertex UnlitPassVertex 116 | #pragma fragment UnlitPassFragment 117 | 118 | // ------------------------------------- 119 | // Material Keywords 120 | #pragma shader_feature_local_fragment _ALPHATEST_ON 121 | #pragma shader_feature_local_fragment _ALPHAMODULATE_ON 122 | 123 | // ------------------------------------- 124 | // Unity defined keywords 125 | #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION 126 | #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 127 | #pragma multi_compile _ LOD_FADE_CROSSFADE 128 | #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT 129 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 130 | 131 | //-------------------------------------- 132 | // GPU Instancing 133 | #pragma multi_compile_instancing 134 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 135 | 136 | // ------------------------------------- 137 | // Includes 138 | 139 | #define GBUFFER_PASS 140 | 141 | #include "ExampleUnlitShader.hlsl" 142 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitGBufferPass.hlsl" 143 | 144 | ENDHLSL 145 | } 146 | 147 | Pass 148 | { 149 | Name "DepthOnly" 150 | Tags 151 | { 152 | "LightMode" = "DepthOnly" 153 | } 154 | 155 | // ------------------------------------- 156 | // Render State Commands 157 | ZWrite On 158 | ColorMask R 159 | 160 | HLSLPROGRAM 161 | #pragma target 2.0 162 | 163 | // ------------------------------------- 164 | // Shader Stages 165 | #pragma vertex DepthOnlyVertex 166 | #pragma fragment DepthOnlyFragment 167 | 168 | // ------------------------------------- 169 | // Material Keywords 170 | #pragma shader_feature_local _ALPHATEST_ON 171 | 172 | // ------------------------------------- 173 | // Unity defined keywords 174 | #pragma multi_compile _ LOD_FADE_CROSSFADE 175 | 176 | //-------------------------------------- 177 | // GPU Instancing 178 | #pragma multi_compile_instancing 179 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 180 | 181 | // ------------------------------------- 182 | // Includes 183 | 184 | #define DEPTH_ONLY_PASS 185 | 186 | #include "ExampleUnlitShader.hlsl" 187 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitDepthOnlyPass.hlsl" 188 | 189 | ENDHLSL 190 | } 191 | 192 | Pass 193 | { 194 | Name "DepthNormalsOnly" 195 | Tags 196 | { 197 | "LightMode" = "DepthNormalsOnly" 198 | } 199 | 200 | // ------------------------------------- 201 | // Render State Commands 202 | ZWrite On 203 | 204 | HLSLPROGRAM 205 | #pragma target 2.0 206 | 207 | // ------------------------------------- 208 | // Shader Stages 209 | #pragma vertex DepthNormalsVertex 210 | #pragma fragment DepthNormalsFragment 211 | 212 | // ------------------------------------- 213 | // Material Keywords 214 | #pragma shader_feature_local _ALPHATEST_ON 215 | 216 | // ------------------------------------- 217 | // Universal Pipeline keywords 218 | #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT // forward-only variant 219 | #pragma multi_compile _ LOD_FADE_CROSSFADE 220 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 221 | 222 | //-------------------------------------- 223 | // GPU Instancing 224 | #pragma multi_compile_instancing 225 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 226 | 227 | // ------------------------------------- 228 | // Includes 229 | 230 | #define DEPTH_NORMALS_PASS 231 | 232 | #include "ExampleUnlitShader.hlsl" 233 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitDepthNormalsPass.hlsl" 234 | 235 | ENDHLSL 236 | } 237 | 238 | // This pass it not used during regular rendering, only for lightmap baking. 239 | Pass 240 | { 241 | Name "Meta" 242 | Tags 243 | { 244 | "LightMode" = "Meta" 245 | } 246 | 247 | // ------------------------------------- 248 | // Render State Commands 249 | Cull Off 250 | 251 | HLSLPROGRAM 252 | #pragma target 2.0 253 | 254 | // ------------------------------------- 255 | // Shader Stages 256 | #pragma vertex UniversalVertexMeta 257 | #pragma fragment UniversalFragmentMetaUnlit 258 | 259 | // ------------------------------------- 260 | // Unity defined keywords 261 | #pragma shader_feature EDITOR_VISUALIZATION 262 | 263 | // ------------------------------------- 264 | // Includes 265 | 266 | #define META_PASS 267 | 268 | #include "ExampleUnlitShader.hlsl" 269 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitMetaPass.hlsl" 270 | 271 | ENDHLSL 272 | } 273 | 274 | Pass 275 | { 276 | Name "MotionVectors" 277 | Tags { "LightMode" = "MotionVectors" } 278 | ColorMask RG 279 | 280 | HLSLPROGRAM 281 | 282 | // ------------------------------------- 283 | // Shader Stages 284 | #pragma vertex MotionVectorVertex 285 | #pragma fragment MotionVectorVertexFragment 286 | 287 | // ------------------------------------- 288 | // Material Keywords 289 | #pragma shader_feature_local _ALPHATEST_ON 290 | #pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY 291 | 292 | // ------------------------------------- 293 | // Unity defined keywords 294 | #pragma multi_compile _ LOD_FADE_CROSSFADE 295 | 296 | // ------------------------------------- 297 | // Includes 298 | 299 | #define MOTION_VECTOR_PASS 300 | 301 | #include "ExampleUnlitShader.hlsl" 302 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitMotionVectorPass.hlsl" 303 | 304 | ENDHLSL 305 | } 306 | 307 | Pass 308 | { 309 | Name "XRMotionVectors" 310 | Tags { "LightMode" = "XRMotionVectors" } 311 | ColorMask RGBA 312 | 313 | // Stencil write for obj motion pixels 314 | Stencil 315 | { 316 | WriteMask 1 317 | Ref 1 318 | Comp Always 319 | Pass Replace 320 | } 321 | 322 | HLSLPROGRAM 323 | 324 | // ------------------------------------- 325 | // Shader Stages 326 | #pragma vertex MotionVectorVertex 327 | #pragma fragment MotionVectorVertexFragment 328 | 329 | // ------------------------------------- 330 | // Material Keywords 331 | #pragma shader_feature_local _ALPHATEST_ON 332 | #pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY 333 | 334 | // ------------------------------------- 335 | // Unity defined keywords 336 | #pragma multi_compile _ LOD_FADE_CROSSFADE 337 | #define APLICATION_SPACE_WARP_MOTION 1 338 | 339 | // ------------------------------------- 340 | // Includes 341 | 342 | #define MOTION_VECTOR_PASS 343 | 344 | #include "ExampleUnlitShader.hlsl" 345 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitMotionVectorPass.hlsl" 346 | 347 | ENDHLSL 348 | } 349 | } 350 | 351 | FallBack "Hidden/Universal Render Pipeline/FallbackError" 352 | CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.UnlitShader" 353 | } 354 | -------------------------------------------------------------------------------- /Shaders/Example Unlit Shader/ExampleUnlitShader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1f488d254af351b48aff8133504bd38a 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shaders/URPSurfaceShader.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Surface Shader" 2 | { 3 | Properties 4 | { 5 | // Specular vs Metallic workflow 6 | _WorkflowMode("WorkflowMode", Float) = 1.0 7 | 8 | [MainTexture] _BaseMap("Albedo", 2D) = "white" {} 9 | [MainColor] _BaseColor("Color", Color) = (1,1,1,1) 10 | 11 | _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 12 | 13 | _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 14 | _SmoothnessTextureChannel("Smoothness texture channel", Float) = 0 15 | 16 | _Metallic("Metallic", Range(0.0, 1.0)) = 0.0 17 | _MetallicGlossMap("Metallic", 2D) = "white" {} 18 | 19 | _SpecColor("Specular", Color) = (0.2, 0.2, 0.2) 20 | _SpecGlossMap("Specular", 2D) = "white" {} 21 | 22 | [ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0 23 | [ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0 24 | 25 | _BumpScale("Scale", Float) = 1.0 26 | _BumpMap("Normal Map", 2D) = "bump" {} 27 | 28 | _Parallax("Scale", Range(0.005, 0.08)) = 0.005 29 | _ParallaxMap("Height Map", 2D) = "black" {} 30 | 31 | _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0 32 | _OcclusionMap("Occlusion", 2D) = "white" {} 33 | 34 | [HDR] _EmissionColor("Color", Color) = (0,0,0) 35 | _EmissionMap("Emission", 2D) = "white" {} 36 | 37 | _DetailMask("Detail Mask", 2D) = "white" {} 38 | _DetailAlbedoMapScale("Scale", Range(0.0, 2.0)) = 1.0 39 | _DetailAlbedoMap("Detail Albedo x2", 2D) = "linearGrey" {} 40 | _DetailNormalMapScale("Scale", Range(0.0, 2.0)) = 1.0 41 | [Normal] _DetailNormalMap("Normal Map", 2D) = "bump" {} 42 | 43 | // SRP batching compatibility for Clear Coat (Not used in Lit) 44 | [HideInInspector] _ClearCoatMask("_ClearCoatMask", Float) = 0.0 45 | [HideInInspector] _ClearCoatSmoothness("_ClearCoatSmoothness", Float) = 0.0 46 | 47 | // Blending state 48 | _Surface("__surface", Float) = 0.0 49 | _Blend("__blend", Float) = 0.0 50 | _Cull("__cull", Float) = 2.0 51 | [ToggleUI] _AlphaClip("__clip", Float) = 0.0 52 | [HideInInspector] _SrcBlend("__src", Float) = 1.0 53 | [HideInInspector] _DstBlend("__dst", Float) = 0.0 54 | [HideInInspector] _SrcBlendAlpha("__srcA", Float) = 1.0 55 | [HideInInspector] _DstBlendAlpha("__dstA", Float) = 0.0 56 | [HideInInspector] _ZWrite("__zw", Float) = 1.0 57 | [HideInInspector] _BlendModePreserveSpecular("_BlendModePreserveSpecular", Float) = 1.0 58 | [HideInInspector] _AlphaToMask("__alphaToMask", Float) = 0.0 59 | [HideInInspector] _AddPrecomputedVelocity("_AddPrecomputedVelocity", Float) = 0.0 60 | 61 | [ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0 62 | // Editmode props 63 | _QueueOffset("Queue offset", Float) = 0.0 64 | 65 | // ObsoleteProperties 66 | [HideInInspector] _MainTex("BaseMap", 2D) = "white" {} 67 | [HideInInspector] _Color("Base Color", Color) = (1, 1, 1, 1) 68 | [HideInInspector] _GlossMapScale("Smoothness", Float) = 0.0 69 | [HideInInspector] _Glossiness("Smoothness", Float) = 0.0 70 | [HideInInspector] _GlossyReflections("EnvironmentReflections", Float) = 0.0 71 | 72 | [HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {} 73 | [HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {} 74 | [HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {} 75 | } 76 | 77 | SubShader 78 | { 79 | // Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings 80 | // this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this 81 | // material work with both Universal Render Pipeline and Builtin Unity Pipeline 82 | Tags 83 | { 84 | "RenderType" = "Opaque" 85 | "RenderPipeline" = "UniversalPipeline" 86 | "UniversalMaterialType" = "Lit" 87 | "IgnoreProjector" = "True" 88 | } 89 | LOD 300 90 | 91 | // ------------------------------------------------------------------ 92 | // Forward pass. Shades all light in a single pass. GI + emission + Fog 93 | Pass 94 | { 95 | // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with 96 | // no LightMode tag are also rendered by Universal Render Pipeline 97 | Name "ForwardLit" 98 | Tags 99 | { 100 | "LightMode" = "UniversalForward" 101 | } 102 | 103 | // ------------------------------------- 104 | // Render State Commands 105 | Blend[_SrcBlend][_DstBlend], [_SrcBlendAlpha][_DstBlendAlpha] 106 | ZWrite[_ZWrite] 107 | Cull[_Cull] 108 | AlphaToMask[_AlphaToMask] 109 | 110 | HLSLPROGRAM 111 | #pragma target 2.0 112 | 113 | // ------------------------------------- 114 | // Shader Stages 115 | #pragma vertex LitPassVertex 116 | #pragma fragment LitPassFragment 117 | 118 | // ------------------------------------- 119 | // Material Keywords 120 | #pragma shader_feature_local _NORMALMAP 121 | #pragma shader_feature_local _PARALLAXMAP 122 | #pragma shader_feature_local _RECEIVE_SHADOWS_OFF 123 | #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED 124 | #pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT 125 | #pragma shader_feature_local_fragment _ALPHATEST_ON 126 | #pragma shader_feature_local_fragment _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON 127 | #pragma shader_feature_local_fragment _EMISSION 128 | #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP 129 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 130 | #pragma shader_feature_local_fragment _OCCLUSIONMAP 131 | #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF 132 | #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF 133 | #pragma shader_feature_local_fragment _SPECULAR_SETUP 134 | 135 | // ------------------------------------- 136 | // Universal Pipeline keywords 137 | #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN 138 | #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS 139 | #pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX 140 | #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS 141 | #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING 142 | #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION 143 | #pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH 144 | #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION 145 | #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 146 | #pragma multi_compile_fragment _ _LIGHT_COOKIES 147 | #pragma multi_compile _ _LIGHT_LAYERS 148 | #pragma multi_compile _ _FORWARD_PLUS 149 | #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" 150 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 151 | 152 | 153 | // ------------------------------------- 154 | // Unity defined keywords 155 | #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING 156 | #pragma multi_compile _ SHADOWS_SHADOWMASK 157 | #pragma multi_compile _ DIRLIGHTMAP_COMBINED 158 | #pragma multi_compile _ LIGHTMAP_ON 159 | #pragma multi_compile _ DYNAMICLIGHTMAP_ON 160 | #pragma multi_compile _ USE_LEGACY_LIGHTMAPS 161 | #pragma multi_compile _ LOD_FADE_CROSSFADE 162 | #pragma multi_compile_fog 163 | #pragma multi_compile_fragment _ DEBUG_DISPLAY 164 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl" 165 | 166 | //-------------------------------------- 167 | // GPU Instancing 168 | #pragma multi_compile_instancing 169 | #pragma instancing_options renderinglayer 170 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 171 | 172 | #define FORWARD_PASS 173 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPLightingPass.hlsl" 174 | 175 | ENDHLSL 176 | } 177 | 178 | Pass 179 | { 180 | Name "ShadowCaster" 181 | Tags 182 | { 183 | "LightMode" = "ShadowCaster" 184 | } 185 | 186 | // ------------------------------------- 187 | // Render State Commands 188 | ZWrite On 189 | ZTest LEqual 190 | ColorMask 0 191 | Cull[_Cull] 192 | 193 | HLSLPROGRAM 194 | #pragma target 2.0 195 | 196 | // ------------------------------------- 197 | // Shader Stages 198 | #pragma vertex ShadowPassVertex 199 | #pragma fragment ShadowPassFragment 200 | 201 | // ------------------------------------- 202 | // Material Keywords 203 | #pragma shader_feature_local _ALPHATEST_ON 204 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 205 | 206 | //-------------------------------------- 207 | // GPU Instancing 208 | #pragma multi_compile_instancing 209 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 210 | 211 | // ------------------------------------- 212 | // Universal Pipeline keywords 213 | 214 | // ------------------------------------- 215 | // Unity defined keywords 216 | #pragma multi_compile _ LOD_FADE_CROSSFADE 217 | 218 | // This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias 219 | #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW 220 | 221 | // ------------------------------------- 222 | // Includes 223 | 224 | #define SHADOWS_PASS 225 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPShadowsPass.hlsl" 226 | 227 | ENDHLSL 228 | } 229 | 230 | Pass 231 | { 232 | // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with 233 | // no LightMode tag are also rendered by Universal Render Pipeline 234 | Name "GBuffer" 235 | Tags 236 | { 237 | "LightMode" = "UniversalGBuffer" 238 | } 239 | 240 | // ------------------------------------- 241 | // Render State Commands 242 | ZWrite[_ZWrite] 243 | ZTest LEqual 244 | Cull[_Cull] 245 | 246 | HLSLPROGRAM 247 | #pragma target 4.5 248 | 249 | // Deferred Rendering Path does not support the OpenGL-based graphics API: 250 | // Desktop OpenGL, OpenGL ES 3.0, WebGL 2.0. 251 | #pragma exclude_renderers gles3 glcore 252 | 253 | // ------------------------------------- 254 | // Shader Stages 255 | #pragma vertex LitGBufferPassVertex 256 | #pragma fragment LitGBufferPassFragment 257 | 258 | // ------------------------------------- 259 | // Material Keywords 260 | #pragma shader_feature_local _NORMALMAP 261 | #pragma shader_feature_local_fragment _ALPHATEST_ON 262 | //#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON 263 | #pragma shader_feature_local_fragment _EMISSION 264 | #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP 265 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 266 | #pragma shader_feature_local_fragment _OCCLUSIONMAP 267 | #pragma shader_feature_local _PARALLAXMAP 268 | #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED 269 | 270 | #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF 271 | #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF 272 | #pragma shader_feature_local_fragment _SPECULAR_SETUP 273 | #pragma shader_feature_local _RECEIVE_SHADOWS_OFF 274 | 275 | // ------------------------------------- 276 | // Universal Pipeline keywords 277 | #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN 278 | //#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS 279 | //#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS 280 | #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING 281 | #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION 282 | #pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH 283 | #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 284 | #pragma multi_compile_fragment _ _RENDER_PASS_ENABLED 285 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 286 | 287 | // ------------------------------------- 288 | // Unity defined keywords 289 | #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING 290 | #pragma multi_compile _ SHADOWS_SHADOWMASK 291 | #pragma multi_compile _ DIRLIGHTMAP_COMBINED 292 | #pragma multi_compile _ LIGHTMAP_ON 293 | #pragma multi_compile _ DYNAMICLIGHTMAP_ON 294 | #pragma multi_compile _ USE_LEGACY_LIGHTMAPS 295 | #pragma multi_compile _ LOD_FADE_CROSSFADE 296 | #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT 297 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl" 298 | 299 | //-------------------------------------- 300 | // GPU Instancing 301 | #pragma multi_compile_instancing 302 | #pragma instancing_options renderinglayer 303 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 304 | 305 | // ------------------------------------- 306 | // Includes 307 | 308 | #define GBUFFER_PASS 309 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPLitGBufferPass.hlsl" 310 | 311 | ENDHLSL 312 | } 313 | 314 | Pass 315 | { 316 | Name "DepthOnly" 317 | Tags 318 | { 319 | "LightMode" = "DepthOnly" 320 | } 321 | 322 | // ------------------------------------- 323 | // Render State Commands 324 | ZWrite On 325 | ColorMask R 326 | Cull[_Cull] 327 | 328 | HLSLPROGRAM 329 | #pragma target 2.0 330 | 331 | // ------------------------------------- 332 | // Shader Stages 333 | #pragma vertex DepthOnlyVertex 334 | #pragma fragment DepthOnlyFragment 335 | 336 | // ------------------------------------- 337 | // Material Keywords 338 | #pragma shader_feature_local _ALPHATEST_ON 339 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 340 | 341 | // ------------------------------------- 342 | // Unity defined keywords 343 | #pragma multi_compile _ LOD_FADE_CROSSFADE 344 | 345 | //-------------------------------------- 346 | // GPU Instancing 347 | #pragma multi_compile_instancing 348 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 349 | 350 | // ------------------------------------- 351 | // Includes 352 | 353 | #define DEPTH_ONLY_PASS 354 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPDepthOnlyPass.hlsl" 355 | 356 | ENDHLSL 357 | } 358 | 359 | // This pass is used when drawing to a _CameraNormalsTexture texture 360 | Pass 361 | { 362 | Name "DepthNormals" 363 | Tags 364 | { 365 | "LightMode" = "DepthNormals" 366 | } 367 | 368 | // ------------------------------------- 369 | // Render State Commands 370 | ZWrite On 371 | Cull[_Cull] 372 | 373 | HLSLPROGRAM 374 | #pragma target 2.0 375 | 376 | // ------------------------------------- 377 | // Shader Stages 378 | #pragma vertex DepthNormalsVertex 379 | #pragma fragment DepthNormalsFragment 380 | 381 | // ------------------------------------- 382 | // Material Keywords 383 | #pragma shader_feature_local _NORMALMAP 384 | #pragma shader_feature_local _PARALLAXMAP 385 | #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED 386 | #pragma shader_feature_local _ALPHATEST_ON 387 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 388 | 389 | // ------------------------------------- 390 | // Unity defined keywords 391 | #pragma multi_compile _ LOD_FADE_CROSSFADE 392 | 393 | // ------------------------------------- 394 | // Universal Pipeline keywords 395 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 396 | 397 | //-------------------------------------- 398 | // GPU Instancing 399 | #pragma multi_compile_instancing 400 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 401 | 402 | // ------------------------------------- 403 | // Includes 404 | 405 | #define DEPTH_NORMALS_PASS 406 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPDepthNormalsPass.hlsl" 407 | 408 | ENDHLSL 409 | } 410 | 411 | // This pass it not used during regular rendering, only for lightmap baking. 412 | Pass 413 | { 414 | Name "Meta" 415 | Tags 416 | { 417 | "LightMode" = "Meta" 418 | } 419 | 420 | // ------------------------------------- 421 | // Render State Commands 422 | Cull Off 423 | 424 | HLSLPROGRAM 425 | #pragma target 2.0 426 | 427 | // ------------------------------------- 428 | // Shader Stages 429 | #pragma vertex UniversalVertexMeta 430 | #pragma fragment UniversalFragmentMetaLit 431 | 432 | // ------------------------------------- 433 | // Material Keywords 434 | #pragma shader_feature_local_fragment _SPECULAR_SETUP 435 | #pragma shader_feature_local_fragment _EMISSION 436 | #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP 437 | #pragma shader_feature_local_fragment _ALPHATEST_ON 438 | #pragma shader_feature_local_fragment _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 439 | #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED 440 | #pragma shader_feature_local_fragment _SPECGLOSSMAP 441 | #pragma shader_feature EDITOR_VISUALIZATION 442 | 443 | // ------------------------------------- 444 | // Includes 445 | 446 | #define META_PASS 447 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPMetaPass.hlsl" 448 | 449 | ENDHLSL 450 | } 451 | 452 | Pass 453 | { 454 | Name "Universal2D" 455 | Tags 456 | { 457 | "LightMode" = "Universal2D" 458 | } 459 | 460 | // ------------------------------------- 461 | // Render State Commands 462 | Blend[_SrcBlend][_DstBlend] 463 | ZWrite[_ZWrite] 464 | Cull[_Cull] 465 | 466 | HLSLPROGRAM 467 | #pragma target 2.0 468 | 469 | // ------------------------------------- 470 | // Shader Stages 471 | #pragma vertex vert 472 | #pragma fragment frag 473 | 474 | // ------------------------------------- 475 | // Material Keywords 476 | #pragma shader_feature_local_fragment _ALPHATEST_ON 477 | #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON 478 | 479 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 480 | 481 | // ------------------------------------- 482 | // Includes 483 | 484 | #define UNIVERSAL_2D_PASS 485 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URP2DPass.hlsl" 486 | 487 | ENDHLSL 488 | } 489 | 490 | Pass 491 | { 492 | Name "MotionVectors" 493 | Tags { "LightMode" = "MotionVectors" } 494 | ColorMask RG 495 | 496 | HLSLPROGRAM 497 | 498 | // ------------------------------------- 499 | // Shader Stages 500 | #pragma vertex MotionVectorVertex 501 | #pragma fragment MotionVectorVertexFragment 502 | 503 | // ------------------------------------- 504 | // Material Keywords 505 | #pragma shader_feature_local _ALPHATEST_ON 506 | #pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY 507 | 508 | // ------------------------------------- 509 | // Unity defined keywords 510 | #pragma multi_compile _ LOD_FADE_CROSSFADE 511 | 512 | // ------------------------------------- 513 | // Includes 514 | 515 | #define MOTION_VECTOR_PASS 516 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPMotionVectorPass.hlsl" 517 | 518 | ENDHLSL 519 | } 520 | 521 | Pass 522 | { 523 | Name "XRMotionVectors" 524 | Tags { "LightMode" = "XRMotionVectors" } 525 | ColorMask RGBA 526 | 527 | // Stencil write for obj motion pixels 528 | Stencil 529 | { 530 | WriteMask 1 531 | Ref 1 532 | Comp Always 533 | Pass Replace 534 | } 535 | 536 | HLSLPROGRAM 537 | 538 | // ------------------------------------- 539 | // Shader Stages 540 | #pragma vertex MotionVectorVertex 541 | #pragma fragment MotionVectorVertexFragment 542 | 543 | // ------------------------------------- 544 | // Material Keywords 545 | #pragma shader_feature_local _ALPHATEST_ON 546 | #pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY 547 | 548 | // ------------------------------------- 549 | // Unity defined keywords 550 | #pragma multi_compile _ LOD_FADE_CROSSFADE 551 | #define APLICATION_SPACE_WARP_MOTION 1 552 | 553 | // ------------------------------------- 554 | // Includes 555 | 556 | #define MOTION_VECTOR_PASS 557 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPMotionVectorPass.hlsl" 558 | 559 | ENDHLSL 560 | } 561 | } 562 | 563 | FallBack "Hidden/Universal Render Pipeline/FallbackError" 564 | CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.LitShader" 565 | } 566 | -------------------------------------------------------------------------------- /Shaders/URPSurfaceShader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c9bbb8edbba979c4d822094e1101b40b 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shaders/URPUnlit.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Unlit Surface Shader" 2 | { 3 | Properties 4 | { 5 | [MainTexture] _BaseMap("Texture", 2D) = "white" {} 6 | [MainColor] _BaseColor("Color", Color) = (1, 1, 1, 1) 7 | _Cutoff("AlphaCutout", Range(0.0, 1.0)) = 0.5 8 | 9 | // BlendMode 10 | _Surface("__surface", Float) = 0.0 11 | _Blend("__mode", Float) = 0.0 12 | _Cull("__cull", Float) = 2.0 13 | [ToggleUI] _AlphaClip("__clip", Float) = 0.0 14 | [HideInInspector] _BlendOp("__blendop", Float) = 0.0 15 | [HideInInspector] _SrcBlend("__src", Float) = 1.0 16 | [HideInInspector] _DstBlend("__dst", Float) = 0.0 17 | [HideInInspector] _SrcBlendAlpha("__srcA", Float) = 1.0 18 | [HideInInspector] _DstBlendAlpha("__dstA", Float) = 0.0 19 | [HideInInspector] _ZWrite("__zw", Float) = 1.0 20 | [HideInInspector] _AlphaToMask("__alphaToMask", Float) = 0.0 21 | [HideInInspector] _AddPrecomputedVelocity("_AddPrecomputedVelocity", Float) = 0.0 22 | 23 | // Editmode props 24 | _QueueOffset("Queue offset", Float) = 0.0 25 | 26 | // ObsoleteProperties 27 | [HideInInspector] _MainTex("BaseMap", 2D) = "white" {} 28 | [HideInInspector] _Color("Base Color", Color) = (0.5, 0.5, 0.5, 1) 29 | [HideInInspector] _SampleGI("SampleGI", float) = 0.0 // needed from bakedlit 30 | } 31 | 32 | SubShader 33 | { 34 | Tags 35 | { 36 | "RenderType" = "Opaque" 37 | "IgnoreProjector" = "True" 38 | "UniversalMaterialType" = "Unlit" 39 | "RenderPipeline" = "UniversalPipeline" 40 | } 41 | LOD 100 42 | 43 | // ------------------------------------- 44 | // Render State Commands 45 | Blend [_SrcBlend][_DstBlend], [_SrcBlendAlpha][_DstBlendAlpha] 46 | ZWrite [_ZWrite] 47 | Cull [_Cull] 48 | 49 | Pass 50 | { 51 | Name "Unlit" 52 | 53 | // ------------------------------------- 54 | // Render State Commands 55 | AlphaToMask[_AlphaToMask] 56 | 57 | HLSLPROGRAM 58 | #pragma target 2.0 59 | 60 | // ------------------------------------- 61 | // Shader Stages 62 | #pragma vertex UnlitPassVertex 63 | #pragma fragment UnlitPassFragment 64 | 65 | // ------------------------------------- 66 | // Material Keywords 67 | #pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT 68 | #pragma shader_feature_local_fragment _ALPHATEST_ON 69 | #pragma shader_feature_local_fragment _ALPHAMODULATE_ON 70 | 71 | // ------------------------------------- 72 | // Unity defined keywords 73 | #pragma multi_compile_fog 74 | #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION 75 | #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 76 | #pragma multi_compile _ DEBUG_DISPLAY 77 | #pragma multi_compile _ LOD_FADE_CROSSFADE 78 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 79 | 80 | //-------------------------------------- 81 | // GPU Instancing 82 | #pragma multi_compile_instancing 83 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 84 | 85 | // ------------------------------------- 86 | // Includes 87 | 88 | #define FORWARD_PASS 89 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitForwardPass.hlsl" 90 | 91 | ENDHLSL 92 | } 93 | 94 | // Fill GBuffer data to prevent "holes", just in case someone wants to reuse GBuffer for non-lighting effects. 95 | // Deferred lighting is stenciled out. 96 | Pass 97 | { 98 | Name "GBuffer" 99 | Tags 100 | { 101 | "LightMode" = "UniversalGBuffer" 102 | } 103 | 104 | HLSLPROGRAM 105 | #pragma target 4.5 106 | 107 | // Deferred Rendering Path does not support the OpenGL-based graphics API: 108 | // Desktop OpenGL, OpenGL ES 3.0, WebGL 2.0. 109 | #pragma exclude_renderers gles3 glcore 110 | 111 | // ------------------------------------- 112 | // Shader Stages 113 | #pragma vertex UnlitPassVertex 114 | #pragma fragment UnlitPassFragment 115 | 116 | // ------------------------------------- 117 | // Material Keywords 118 | #pragma shader_feature_local_fragment _ALPHATEST_ON 119 | #pragma shader_feature_local_fragment _ALPHAMODULATE_ON 120 | 121 | // ------------------------------------- 122 | // Unity defined keywords 123 | #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION 124 | #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 125 | #pragma multi_compile _ LOD_FADE_CROSSFADE 126 | #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT 127 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 128 | 129 | //-------------------------------------- 130 | // GPU Instancing 131 | #pragma multi_compile_instancing 132 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 133 | 134 | // ------------------------------------- 135 | // Includes 136 | 137 | #define GBUFFER_PASS 138 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitGBufferPass.hlsl" 139 | 140 | ENDHLSL 141 | } 142 | 143 | Pass 144 | { 145 | Name "DepthOnly" 146 | Tags 147 | { 148 | "LightMode" = "DepthOnly" 149 | } 150 | 151 | // ------------------------------------- 152 | // Render State Commands 153 | ZWrite On 154 | ColorMask R 155 | 156 | HLSLPROGRAM 157 | #pragma target 2.0 158 | 159 | // ------------------------------------- 160 | // Shader Stages 161 | #pragma vertex DepthOnlyVertex 162 | #pragma fragment DepthOnlyFragment 163 | 164 | // ------------------------------------- 165 | // Material Keywords 166 | #pragma shader_feature_local _ALPHATEST_ON 167 | 168 | // ------------------------------------- 169 | // Unity defined keywords 170 | #pragma multi_compile _ LOD_FADE_CROSSFADE 171 | 172 | //-------------------------------------- 173 | // GPU Instancing 174 | #pragma multi_compile_instancing 175 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 176 | 177 | // ------------------------------------- 178 | // Includes 179 | 180 | #define DEPTH_ONLY_PASS 181 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitDepthOnlyPass.hlsl" 182 | 183 | ENDHLSL 184 | } 185 | 186 | Pass 187 | { 188 | Name "DepthNormalsOnly" 189 | Tags 190 | { 191 | "LightMode" = "DepthNormalsOnly" 192 | } 193 | 194 | // ------------------------------------- 195 | // Render State Commands 196 | ZWrite On 197 | 198 | HLSLPROGRAM 199 | #pragma target 2.0 200 | 201 | // ------------------------------------- 202 | // Shader Stages 203 | #pragma vertex DepthNormalsVertex 204 | #pragma fragment DepthNormalsFragment 205 | 206 | // ------------------------------------- 207 | // Material Keywords 208 | #pragma shader_feature_local _ALPHATEST_ON 209 | 210 | // ------------------------------------- 211 | // Universal Pipeline keywords 212 | #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT // forward-only variant 213 | #pragma multi_compile _ LOD_FADE_CROSSFADE 214 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 215 | 216 | //-------------------------------------- 217 | // GPU Instancing 218 | #pragma multi_compile_instancing 219 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 220 | 221 | // ------------------------------------- 222 | // Includes 223 | 224 | #define DEPTH_NORMALS_PASS 225 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitDepthNormalsPass.hlsl" 226 | 227 | ENDHLSL 228 | } 229 | 230 | // This pass it not used during regular rendering, only for lightmap baking. 231 | Pass 232 | { 233 | Name "Meta" 234 | Tags 235 | { 236 | "LightMode" = "Meta" 237 | } 238 | 239 | // ------------------------------------- 240 | // Render State Commands 241 | Cull Off 242 | 243 | HLSLPROGRAM 244 | #pragma target 2.0 245 | 246 | // ------------------------------------- 247 | // Shader Stages 248 | #pragma vertex UniversalVertexMeta 249 | #pragma fragment UniversalFragmentMetaUnlit 250 | 251 | // ------------------------------------- 252 | // Unity defined keywords 253 | #pragma shader_feature EDITOR_VISUALIZATION 254 | 255 | // ------------------------------------- 256 | // Includes 257 | 258 | #define META_PASS 259 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitMetaPass.hlsl" 260 | 261 | ENDHLSL 262 | } 263 | 264 | Pass 265 | { 266 | Name "MotionVectors" 267 | Tags { "LightMode" = "MotionVectors" } 268 | ColorMask RG 269 | 270 | HLSLPROGRAM 271 | 272 | // ------------------------------------- 273 | // Shader Stages 274 | #pragma vertex MotionVectorVertex 275 | #pragma fragment MotionVectorVertexFragment 276 | 277 | // ------------------------------------- 278 | // Material Keywords 279 | #pragma shader_feature_local _ALPHATEST_ON 280 | #pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY 281 | 282 | // ------------------------------------- 283 | // Unity defined keywords 284 | #pragma multi_compile _ LOD_FADE_CROSSFADE 285 | 286 | // ------------------------------------- 287 | // Includes 288 | 289 | #define MOTION_VECTOR_PASS 290 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitMotionVectorPass.hlsl" 291 | 292 | ENDHLSL 293 | } 294 | 295 | Pass 296 | { 297 | Name "XRMotionVectors" 298 | Tags { "LightMode" = "XRMotionVectors" } 299 | ColorMask RGBA 300 | 301 | // Stencil write for obj motion pixels 302 | Stencil 303 | { 304 | WriteMask 1 305 | Ref 1 306 | Comp Always 307 | Pass Replace 308 | } 309 | 310 | HLSLPROGRAM 311 | 312 | // ------------------------------------- 313 | // Shader Stages 314 | #pragma vertex MotionVectorVertex 315 | #pragma fragment MotionVectorVertexFragment 316 | 317 | // ------------------------------------- 318 | // Material Keywords 319 | #pragma shader_feature_local _ALPHATEST_ON 320 | #pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY 321 | 322 | // ------------------------------------- 323 | // Unity defined keywords 324 | #pragma multi_compile _ LOD_FADE_CROSSFADE 325 | #define APLICATION_SPACE_WARP_MOTION 1 326 | 327 | // ------------------------------------- 328 | // Includes 329 | 330 | #define MOTION_VECTOR_PASS 331 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitMotionVectorPass.hlsl" 332 | 333 | ENDHLSL 334 | } 335 | } 336 | 337 | FallBack "Hidden/Universal Render Pipeline/FallbackError" 338 | CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.UnlitShader" 339 | } 340 | -------------------------------------------------------------------------------- /Shaders/URPUnlit.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b21f8343f51da44b9b0b9111236cc33 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shaders/Unlit Shadows.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5edfe2747df1a144db0e84935080e45f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Shaders/Unlit Shadows/Unlit Shadows.shader: -------------------------------------------------------------------------------- 1 | Shader "Universal Render Pipeline/Unlit Shadows" 2 | { 3 | Properties 4 | { 5 | [MainTexture] _BaseMap("Texture", 2D) = "white" {} 6 | [MainColor] _BaseColor("Color", Color) = (1, 1, 1, 1) 7 | _Cutoff("AlphaCutout", Range(0.0, 1.0)) = 0.5 8 | 9 | // BlendMode 10 | _Surface("__surface", Float) = 0.0 11 | _Blend("__mode", Float) = 0.0 12 | _Cull("__cull", Float) = 2.0 13 | [ToggleUI] _AlphaClip("__clip", Float) = 0.0 14 | [HideInInspector] _BlendOp("__blendop", Float) = 0.0 15 | [HideInInspector] _SrcBlend("__src", Float) = 1.0 16 | [HideInInspector] _DstBlend("__dst", Float) = 0.0 17 | [HideInInspector] _SrcBlendAlpha("__srcA", Float) = 1.0 18 | [HideInInspector] _DstBlendAlpha("__dstA", Float) = 0.0 19 | [HideInInspector] _ZWrite("__zw", Float) = 1.0 20 | [HideInInspector] _AlphaToMask("__alphaToMask", Float) = 0.0 21 | [HideInInspector] _AddPrecomputedVelocity("_AddPrecomputedVelocity", Float) = 0.0 22 | 23 | // Editmode props 24 | _QueueOffset("Queue offset", Float) = 0.0 25 | 26 | // ObsoleteProperties 27 | [HideInInspector] _MainTex("BaseMap", 2D) = "white" {} 28 | [HideInInspector] _Color("Base Color", Color) = (0.5, 0.5, 0.5, 1) 29 | [HideInInspector] _SampleGI("SampleGI", float) = 0.0 // needed from bakedlit 30 | } 31 | 32 | SubShader 33 | { 34 | Tags 35 | { 36 | "RenderType" = "Opaque" 37 | "IgnoreProjector" = "True" 38 | "UniversalMaterialType" = "Unlit" 39 | "RenderPipeline" = "UniversalPipeline" 40 | } 41 | LOD 100 42 | 43 | // ------------------------------------- 44 | // Render State Commands 45 | Blend [_SrcBlend][_DstBlend], [_SrcBlendAlpha][_DstBlendAlpha] 46 | ZWrite [_ZWrite] 47 | Cull [_Cull] 48 | 49 | Pass 50 | { 51 | Name "Unlit" 52 | 53 | // ------------------------------------- 54 | // Render State Commands 55 | AlphaToMask[_AlphaToMask] 56 | 57 | HLSLPROGRAM 58 | #pragma target 2.0 59 | 60 | // ------------------------------------- 61 | // Shader Stages 62 | #pragma vertex UnlitPassVertex 63 | #pragma fragment UnlitPassFragment 64 | 65 | // ------------------------------------- 66 | // Material Keywords 67 | #pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT 68 | #pragma shader_feature_local_fragment _ALPHATEST_ON 69 | #pragma shader_feature_local_fragment _ALPHAMODULATE_ON 70 | 71 | // ------------------------------------- 72 | // Unity defined keywords 73 | #pragma multi_compile_fog 74 | #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION 75 | #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 76 | #pragma multi_compile _ DEBUG_DISPLAY 77 | #pragma multi_compile _ LOD_FADE_CROSSFADE 78 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 79 | 80 | //-------------------------------------- 81 | // GPU Instancing 82 | #pragma multi_compile_instancing 83 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 84 | 85 | // ------------------------------------- 86 | // Includes 87 | 88 | #define FORWARD_PASS 89 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitForwardPass.hlsl" 90 | 91 | ENDHLSL 92 | } 93 | 94 | Pass 95 | { 96 | Name "ShadowCaster" 97 | Tags 98 | { 99 | "LightMode" = "ShadowCaster" 100 | } 101 | 102 | // ------------------------------------- 103 | // Render State Commands 104 | ZWrite On 105 | ZTest LEqual 106 | ColorMask 0 107 | Cull[_Cull] 108 | 109 | HLSLPROGRAM 110 | #pragma target 2.0 111 | 112 | // ------------------------------------- 113 | // Shader Stages 114 | #pragma vertex ShadowPassVertex 115 | #pragma fragment ShadowPassFragment 116 | 117 | // ------------------------------------- 118 | // Material Keywords 119 | #pragma shader_feature_local _ALPHATEST_ON 120 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 121 | 122 | //-------------------------------------- 123 | // GPU Instancing 124 | #pragma multi_compile_instancing 125 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 126 | 127 | // ------------------------------------- 128 | // Universal Pipeline keywords 129 | 130 | // ------------------------------------- 131 | // Unity defined keywords 132 | #pragma multi_compile _ LOD_FADE_CROSSFADE 133 | 134 | // This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias 135 | #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW 136 | 137 | // ------------------------------------- 138 | // Includes 139 | 140 | #define SHADOWS_PASS 141 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitShadowsPass.hlsl" 142 | 143 | ENDHLSL 144 | } 145 | 146 | // Fill GBuffer data to prevent "holes", just in case someone wants to reuse GBuffer for non-lighting effects. 147 | // Deferred lighting is stenciled out. 148 | Pass 149 | { 150 | Name "GBuffer" 151 | Tags 152 | { 153 | "LightMode" = "UniversalGBuffer" 154 | } 155 | 156 | HLSLPROGRAM 157 | #pragma target 4.5 158 | 159 | // Deferred Rendering Path does not support the OpenGL-based graphics API: 160 | // Desktop OpenGL, OpenGL ES 3.0, WebGL 2.0. 161 | #pragma exclude_renderers gles3 glcore 162 | 163 | // ------------------------------------- 164 | // Shader Stages 165 | #pragma vertex UnlitPassVertex 166 | #pragma fragment UnlitPassFragment 167 | 168 | // ------------------------------------- 169 | // Material Keywords 170 | #pragma shader_feature_local_fragment _ALPHATEST_ON 171 | #pragma shader_feature_local_fragment _ALPHAMODULATE_ON 172 | 173 | // ------------------------------------- 174 | // Unity defined keywords 175 | #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION 176 | #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 177 | #pragma multi_compile _ LOD_FADE_CROSSFADE 178 | #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT 179 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 180 | 181 | //-------------------------------------- 182 | // GPU Instancing 183 | #pragma multi_compile_instancing 184 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 185 | 186 | // ------------------------------------- 187 | // Includes 188 | 189 | #define GBUFFER_PASS 190 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitGBufferPass.hlsl" 191 | 192 | ENDHLSL 193 | } 194 | 195 | Pass 196 | { 197 | Name "DepthOnly" 198 | Tags 199 | { 200 | "LightMode" = "DepthOnly" 201 | } 202 | 203 | // ------------------------------------- 204 | // Render State Commands 205 | ZWrite On 206 | ColorMask R 207 | 208 | HLSLPROGRAM 209 | #pragma target 2.0 210 | 211 | // ------------------------------------- 212 | // Shader Stages 213 | #pragma vertex DepthOnlyVertex 214 | #pragma fragment DepthOnlyFragment 215 | 216 | // ------------------------------------- 217 | // Material Keywords 218 | #pragma shader_feature_local _ALPHATEST_ON 219 | 220 | // ------------------------------------- 221 | // Unity defined keywords 222 | #pragma multi_compile _ LOD_FADE_CROSSFADE 223 | 224 | //-------------------------------------- 225 | // GPU Instancing 226 | #pragma multi_compile_instancing 227 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 228 | 229 | // ------------------------------------- 230 | // Includes 231 | 232 | #define DEPTH_ONLY_PASS 233 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitDepthOnlyPass.hlsl" 234 | 235 | ENDHLSL 236 | } 237 | 238 | Pass 239 | { 240 | Name "DepthNormalsOnly" 241 | Tags 242 | { 243 | "LightMode" = "DepthNormalsOnly" 244 | } 245 | 246 | // ------------------------------------- 247 | // Render State Commands 248 | ZWrite On 249 | 250 | HLSLPROGRAM 251 | #pragma target 2.0 252 | 253 | // ------------------------------------- 254 | // Shader Stages 255 | #pragma vertex DepthNormalsVertex 256 | #pragma fragment DepthNormalsFragment 257 | 258 | // ------------------------------------- 259 | // Material Keywords 260 | #pragma shader_feature_local _ALPHATEST_ON 261 | 262 | // ------------------------------------- 263 | // Universal Pipeline keywords 264 | #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT // forward-only variant 265 | #pragma multi_compile _ LOD_FADE_CROSSFADE 266 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 267 | 268 | //-------------------------------------- 269 | // GPU Instancing 270 | #pragma multi_compile_instancing 271 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 272 | 273 | // ------------------------------------- 274 | // Includes 275 | 276 | #define DEPTH_NORMALS_PASS 277 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitDepthNormalsPass.hlsl" 278 | 279 | ENDHLSL 280 | } 281 | 282 | // This pass it not used during regular rendering, only for lightmap baking. 283 | Pass 284 | { 285 | Name "Meta" 286 | Tags 287 | { 288 | "LightMode" = "Meta" 289 | } 290 | 291 | // ------------------------------------- 292 | // Render State Commands 293 | Cull Off 294 | 295 | HLSLPROGRAM 296 | #pragma target 2.0 297 | 298 | // ------------------------------------- 299 | // Shader Stages 300 | #pragma vertex UniversalVertexMeta 301 | #pragma fragment UniversalFragmentMetaUnlit 302 | 303 | // ------------------------------------- 304 | // Unity defined keywords 305 | #pragma shader_feature EDITOR_VISUALIZATION 306 | 307 | // ------------------------------------- 308 | // Includes 309 | 310 | #define META_PASS 311 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitMetaPass.hlsl" 312 | 313 | ENDHLSL 314 | } 315 | 316 | Pass 317 | { 318 | Name "MotionVectors" 319 | Tags { "LightMode" = "MotionVectors" } 320 | ColorMask RG 321 | 322 | HLSLPROGRAM 323 | 324 | // ------------------------------------- 325 | // Shader Stages 326 | #pragma vertex MotionVectorVertex 327 | #pragma fragment MotionVectorVertexFragment 328 | 329 | // ------------------------------------- 330 | // Material Keywords 331 | #pragma shader_feature_local _ALPHATEST_ON 332 | #pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY 333 | 334 | // ------------------------------------- 335 | // Unity defined keywords 336 | #pragma multi_compile _ LOD_FADE_CROSSFADE 337 | 338 | // ------------------------------------- 339 | // Includes 340 | 341 | #define MOTION_VECTOR_PASS 342 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitMotionVectorPass.hlsl" 343 | 344 | ENDHLSL 345 | } 346 | 347 | Pass 348 | { 349 | Name "XRMotionVectors" 350 | Tags { "LightMode" = "XRMotionVectors" } 351 | ColorMask RGBA 352 | 353 | // Stencil write for obj motion pixels 354 | Stencil 355 | { 356 | WriteMask 1 357 | Ref 1 358 | Comp Always 359 | Pass Replace 360 | } 361 | 362 | HLSLPROGRAM 363 | 364 | // ------------------------------------- 365 | // Shader Stages 366 | #pragma vertex MotionVectorVertex 367 | #pragma fragment MotionVectorVertexFragment 368 | 369 | // ------------------------------------- 370 | // Material Keywords 371 | #pragma shader_feature_local _ALPHATEST_ON 372 | #pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY 373 | 374 | // ------------------------------------- 375 | // Unity defined keywords 376 | #pragma multi_compile _ LOD_FADE_CROSSFADE 377 | #define APLICATION_SPACE_WARP_MOTION 1 378 | 379 | // ------------------------------------- 380 | // Includes 381 | 382 | #define MOTION_VECTOR_PASS 383 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPUnlitMotionVectorPass.hlsl" 384 | 385 | ENDHLSL 386 | } 387 | } 388 | 389 | FallBack "Hidden/Universal Render Pipeline/FallbackError" 390 | CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.UnlitShader" 391 | } 392 | -------------------------------------------------------------------------------- /Shaders/Unlit Shadows/Unlit Shadows.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9eb44fd541bb16d4bb9d222ce6bcdce1 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Shaders/Vertex Color.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0b5860feff25b154dab7e5d9731dc8cc 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Shaders/Vertex Color/VertexColorLit.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef VERTEX_COLOR_LIT_INCLUDED 2 | #define VERTEX_COLOR_LIT_INCLUDED 3 | 4 | #define REQUIRES_VERTEX_COLOR 5 | 6 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPShaderInputs.hlsl" 7 | 8 | #if defined(FORWARD_PASS) || defined(GBUFFER_PASS) 9 | 10 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" 11 | 12 | #define GET_SURFACE_PROPERTIES GetSurfaceProperties 13 | 14 | inline SurfaceData GetSurfaceProperties(Varyings input) 15 | { 16 | SurfaceData outSurfaceData; 17 | 18 | float2 uv = input.uv; 19 | 20 | half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)); 21 | outSurfaceData.alpha = Alpha(albedoAlpha.a, _BaseColor * input.color, _Cutoff); 22 | 23 | half4 specGloss = SampleMetallicSpecGloss(uv, albedoAlpha.a); 24 | outSurfaceData.albedo = albedoAlpha.rgb * input.color.rgb * _BaseColor.rgb; 25 | 26 | #if _SPECULAR_SETUP 27 | outSurfaceData.metallic = 1.0h; 28 | outSurfaceData.specular = specGloss.rgb; 29 | #else 30 | outSurfaceData.metallic = specGloss.r; 31 | outSurfaceData.specular = half3(0.0h, 0.0h, 0.0h); 32 | #endif 33 | 34 | outSurfaceData.smoothness = specGloss.a; 35 | outSurfaceData.normalTS = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale); 36 | outSurfaceData.occlusion = SampleOcclusion(uv); 37 | outSurfaceData.emission = SampleEmission(uv, _EmissionColor.rgb, TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap)); 38 | 39 | #if defined(_CLEARCOAT) || defined(_CLEARCOATMAP) 40 | half2 clearCoat = SampleClearCoat(uv); 41 | outSurfaceData.clearCoatMask = clearCoat.r; 42 | outSurfaceData.clearCoatSmoothness = clearCoat.g; 43 | #else 44 | outSurfaceData.clearCoatMask = 0.0h; 45 | outSurfaceData.clearCoatSmoothness = 0.0h; 46 | #endif 47 | 48 | #if defined(_DETAIL) 49 | half detailMask = SAMPLE_TEXTURE2D(_DetailMask, sampler_DetailMask, uv).a; 50 | float2 detailUv = uv * _DetailAlbedoMap_ST.xy + _DetailAlbedoMap_ST.zw; 51 | outSurfaceData.albedo = ApplyDetailAlbedo(detailUv, outSurfaceData.albedo, detailMask); 52 | outSurfaceData.normalTS = ApplyDetailNormal(detailUv, outSurfaceData.normalTS, detailMask); 53 | 54 | #endif 55 | 56 | 57 | return outSurfaceData; 58 | } 59 | 60 | #endif 61 | 62 | 63 | #endif // VERTEX_COLOR_LIT_INCLUDED -------------------------------------------------------------------------------- /Shaders/Vertex Color/VertexColorLit.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89ddefecbb5e8d147892bc573fc80b75 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Shaders/Vertex Color/VertexColorLit.shader: -------------------------------------------------------------------------------- 1 | Shader "Universal Render Pipeline/Vertex Color Lit" 2 | { 3 | Properties 4 | { 5 | // Specular vs Metallic workflow 6 | _WorkflowMode("WorkflowMode", Float) = 1.0 7 | 8 | [MainTexture] _BaseMap("Albedo", 2D) = "white" {} 9 | [MainColor] _BaseColor("Color", Color) = (1,1,1,1) 10 | 11 | _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 12 | 13 | _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 14 | _SmoothnessTextureChannel("Smoothness texture channel", Float) = 0 15 | 16 | _Metallic("Metallic", Range(0.0, 1.0)) = 0.0 17 | _MetallicGlossMap("Metallic", 2D) = "white" {} 18 | 19 | _SpecColor("Specular", Color) = (0.2, 0.2, 0.2) 20 | _SpecGlossMap("Specular", 2D) = "white" {} 21 | 22 | [ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0 23 | [ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0 24 | 25 | _BumpScale("Scale", Float) = 1.0 26 | _BumpMap("Normal Map", 2D) = "bump" {} 27 | 28 | _Parallax("Scale", Range(0.005, 0.08)) = 0.005 29 | _ParallaxMap("Height Map", 2D) = "black" {} 30 | 31 | _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0 32 | _OcclusionMap("Occlusion", 2D) = "white" {} 33 | 34 | [HDR] _EmissionColor("Color", Color) = (0,0,0) 35 | _EmissionMap("Emission", 2D) = "white" {} 36 | 37 | _DetailMask("Detail Mask", 2D) = "white" {} 38 | _DetailAlbedoMapScale("Scale", Range(0.0, 2.0)) = 1.0 39 | _DetailAlbedoMap("Detail Albedo x2", 2D) = "linearGrey" {} 40 | _DetailNormalMapScale("Scale", Range(0.0, 2.0)) = 1.0 41 | [Normal] _DetailNormalMap("Normal Map", 2D) = "bump" {} 42 | 43 | // SRP batching compatibility for Clear Coat (Not used in Lit) 44 | [HideInInspector] _ClearCoatMask("_ClearCoatMask", Float) = 0.0 45 | [HideInInspector] _ClearCoatSmoothness("_ClearCoatSmoothness", Float) = 0.0 46 | 47 | // Blending state 48 | _Surface("__surface", Float) = 0.0 49 | _Blend("__blend", Float) = 0.0 50 | _Cull("__cull", Float) = 2.0 51 | [ToggleUI] _AlphaClip("__clip", Float) = 0.0 52 | [HideInInspector] _SrcBlend("__src", Float) = 1.0 53 | [HideInInspector] _DstBlend("__dst", Float) = 0.0 54 | [HideInInspector] _SrcBlendAlpha("__srcA", Float) = 1.0 55 | [HideInInspector] _DstBlendAlpha("__dstA", Float) = 0.0 56 | [HideInInspector] _ZWrite("__zw", Float) = 1.0 57 | [HideInInspector] _BlendModePreserveSpecular("_BlendModePreserveSpecular", Float) = 1.0 58 | [HideInInspector] _AlphaToMask("__alphaToMask", Float) = 0.0 59 | [HideInInspector] _AddPrecomputedVelocity("_AddPrecomputedVelocity", Float) = 0.0 60 | 61 | [ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0 62 | // Editmode props 63 | _QueueOffset("Queue offset", Float) = 0.0 64 | 65 | // ObsoleteProperties 66 | [HideInInspector] _MainTex("BaseMap", 2D) = "white" {} 67 | [HideInInspector] _Color("Base Color", Color) = (1, 1, 1, 1) 68 | [HideInInspector] _GlossMapScale("Smoothness", Float) = 0.0 69 | [HideInInspector] _Glossiness("Smoothness", Float) = 0.0 70 | [HideInInspector] _GlossyReflections("EnvironmentReflections", Float) = 0.0 71 | 72 | [HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {} 73 | [HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {} 74 | [HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {} 75 | } 76 | 77 | SubShader 78 | { 79 | // Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings 80 | // this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this 81 | // material work with both Universal Render Pipeline and Builtin Unity Pipeline 82 | Tags 83 | { 84 | "RenderType" = "Opaque" 85 | "RenderPipeline" = "UniversalPipeline" 86 | "UniversalMaterialType" = "Lit" 87 | "IgnoreProjector" = "True" 88 | } 89 | LOD 300 90 | 91 | // ------------------------------------------------------------------ 92 | // Forward pass. Shades all light in a single pass. GI + emission + Fog 93 | Pass 94 | { 95 | // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with 96 | // no LightMode tag are also rendered by Universal Render Pipeline 97 | Name "ForwardLit" 98 | Tags 99 | { 100 | "LightMode" = "UniversalForward" 101 | } 102 | 103 | // ------------------------------------- 104 | // Render State Commands 105 | Blend[_SrcBlend][_DstBlend], [_SrcBlendAlpha][_DstBlendAlpha] 106 | ZWrite[_ZWrite] 107 | Cull[_Cull] 108 | AlphaToMask[_AlphaToMask] 109 | 110 | HLSLPROGRAM 111 | #pragma target 2.0 112 | 113 | // ------------------------------------- 114 | // Shader Stages 115 | #pragma vertex LitPassVertex 116 | #pragma fragment LitPassFragment 117 | 118 | // ------------------------------------- 119 | // Material Keywords 120 | #pragma shader_feature_local _NORMALMAP 121 | #pragma shader_feature_local _PARALLAXMAP 122 | #pragma shader_feature_local _RECEIVE_SHADOWS_OFF 123 | #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED 124 | #pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT 125 | #pragma shader_feature_local_fragment _ALPHATEST_ON 126 | #pragma shader_feature_local_fragment _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON 127 | #pragma shader_feature_local_fragment _EMISSION 128 | #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP 129 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 130 | #pragma shader_feature_local_fragment _OCCLUSIONMAP 131 | #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF 132 | #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF 133 | #pragma shader_feature_local_fragment _SPECULAR_SETUP 134 | 135 | // ------------------------------------- 136 | // Universal Pipeline keywords 137 | #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN 138 | #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS 139 | #pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX 140 | #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS 141 | #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING 142 | #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION 143 | #pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH 144 | #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION 145 | #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 146 | #pragma multi_compile_fragment _ _LIGHT_COOKIES 147 | #pragma multi_compile _ _LIGHT_LAYERS 148 | #pragma multi_compile _ _FORWARD_PLUS 149 | #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" 150 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 151 | 152 | 153 | // ------------------------------------- 154 | // Unity defined keywords 155 | #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING 156 | #pragma multi_compile _ SHADOWS_SHADOWMASK 157 | #pragma multi_compile _ DIRLIGHTMAP_COMBINED 158 | #pragma multi_compile _ LIGHTMAP_ON 159 | #pragma multi_compile _ DYNAMICLIGHTMAP_ON 160 | #pragma multi_compile _ USE_LEGACY_LIGHTMAPS 161 | #pragma multi_compile _ LOD_FADE_CROSSFADE 162 | #pragma multi_compile_fog 163 | #pragma multi_compile_fragment _ DEBUG_DISPLAY 164 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl" 165 | 166 | //-------------------------------------- 167 | // GPU Instancing 168 | #pragma multi_compile_instancing 169 | #pragma instancing_options renderinglayer 170 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 171 | 172 | #define FORWARD_PASS 173 | 174 | #include "VertexColorLit.hlsl" 175 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPLightingPass.hlsl" 176 | 177 | ENDHLSL 178 | } 179 | 180 | Pass 181 | { 182 | Name "ShadowCaster" 183 | Tags 184 | { 185 | "LightMode" = "ShadowCaster" 186 | } 187 | 188 | // ------------------------------------- 189 | // Render State Commands 190 | ZWrite On 191 | ZTest LEqual 192 | ColorMask 0 193 | Cull[_Cull] 194 | 195 | HLSLPROGRAM 196 | #pragma target 2.0 197 | 198 | // ------------------------------------- 199 | // Shader Stages 200 | #pragma vertex ShadowPassVertex 201 | #pragma fragment ShadowPassFragment 202 | 203 | // ------------------------------------- 204 | // Material Keywords 205 | #pragma shader_feature_local _ALPHATEST_ON 206 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 207 | 208 | //-------------------------------------- 209 | // GPU Instancing 210 | #pragma multi_compile_instancing 211 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 212 | 213 | // ------------------------------------- 214 | // Universal Pipeline keywords 215 | 216 | // ------------------------------------- 217 | // Unity defined keywords 218 | #pragma multi_compile _ LOD_FADE_CROSSFADE 219 | 220 | // This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias 221 | #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW 222 | 223 | // ------------------------------------- 224 | // Includes 225 | 226 | #define SHADOWS_PASS 227 | 228 | #include "VertexColorLit.hlsl" 229 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPShadowsPass.hlsl" 230 | 231 | ENDHLSL 232 | } 233 | 234 | Pass 235 | { 236 | // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with 237 | // no LightMode tag are also rendered by Universal Render Pipeline 238 | Name "GBuffer" 239 | Tags 240 | { 241 | "LightMode" = "UniversalGBuffer" 242 | } 243 | 244 | // ------------------------------------- 245 | // Render State Commands 246 | ZWrite[_ZWrite] 247 | ZTest LEqual 248 | Cull[_Cull] 249 | 250 | HLSLPROGRAM 251 | #pragma target 4.5 252 | 253 | // Deferred Rendering Path does not support the OpenGL-based graphics API: 254 | // Desktop OpenGL, OpenGL ES 3.0, WebGL 2.0. 255 | #pragma exclude_renderers gles3 glcore 256 | 257 | // ------------------------------------- 258 | // Shader Stages 259 | #pragma vertex LitGBufferPassVertex 260 | #pragma fragment LitGBufferPassFragment 261 | 262 | // ------------------------------------- 263 | // Material Keywords 264 | #pragma shader_feature_local _NORMALMAP 265 | #pragma shader_feature_local_fragment _ALPHATEST_ON 266 | //#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON 267 | #pragma shader_feature_local_fragment _EMISSION 268 | #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP 269 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 270 | #pragma shader_feature_local_fragment _OCCLUSIONMAP 271 | #pragma shader_feature_local _PARALLAXMAP 272 | #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED 273 | 274 | #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF 275 | #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF 276 | #pragma shader_feature_local_fragment _SPECULAR_SETUP 277 | #pragma shader_feature_local _RECEIVE_SHADOWS_OFF 278 | 279 | // ------------------------------------- 280 | // Universal Pipeline keywords 281 | #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN 282 | //#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS 283 | //#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS 284 | #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING 285 | #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION 286 | #pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH 287 | #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 288 | #pragma multi_compile_fragment _ _RENDER_PASS_ENABLED 289 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 290 | 291 | // ------------------------------------- 292 | // Unity defined keywords 293 | #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING 294 | #pragma multi_compile _ SHADOWS_SHADOWMASK 295 | #pragma multi_compile _ DIRLIGHTMAP_COMBINED 296 | #pragma multi_compile _ LIGHTMAP_ON 297 | #pragma multi_compile _ DYNAMICLIGHTMAP_ON 298 | #pragma multi_compile _ USE_LEGACY_LIGHTMAPS 299 | #pragma multi_compile _ LOD_FADE_CROSSFADE 300 | #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT 301 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl" 302 | 303 | //-------------------------------------- 304 | // GPU Instancing 305 | #pragma multi_compile_instancing 306 | #pragma instancing_options renderinglayer 307 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 308 | 309 | // ------------------------------------- 310 | // Includes 311 | 312 | #define GBUFFER_PASS 313 | 314 | #include "VertexColorLit.hlsl" 315 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPLitGBufferPass.hlsl" 316 | 317 | ENDHLSL 318 | } 319 | 320 | Pass 321 | { 322 | Name "DepthOnly" 323 | Tags 324 | { 325 | "LightMode" = "DepthOnly" 326 | } 327 | 328 | // ------------------------------------- 329 | // Render State Commands 330 | ZWrite On 331 | ColorMask R 332 | Cull[_Cull] 333 | 334 | HLSLPROGRAM 335 | #pragma target 2.0 336 | 337 | // ------------------------------------- 338 | // Shader Stages 339 | #pragma vertex DepthOnlyVertex 340 | #pragma fragment DepthOnlyFragment 341 | 342 | // ------------------------------------- 343 | // Material Keywords 344 | #pragma shader_feature_local _ALPHATEST_ON 345 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 346 | 347 | // ------------------------------------- 348 | // Unity defined keywords 349 | #pragma multi_compile _ LOD_FADE_CROSSFADE 350 | 351 | //-------------------------------------- 352 | // GPU Instancing 353 | #pragma multi_compile_instancing 354 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 355 | 356 | // ------------------------------------- 357 | // Includes 358 | 359 | #define DEPTH_ONLY_PASS 360 | 361 | #include "VertexColorLit.hlsl" 362 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPDepthOnlyPass.hlsl" 363 | 364 | ENDHLSL 365 | } 366 | 367 | // This pass is used when drawing to a _CameraNormalsTexture texture 368 | Pass 369 | { 370 | Name "DepthNormals" 371 | Tags 372 | { 373 | "LightMode" = "DepthNormals" 374 | } 375 | 376 | // ------------------------------------- 377 | // Render State Commands 378 | ZWrite On 379 | Cull[_Cull] 380 | 381 | HLSLPROGRAM 382 | #pragma target 2.0 383 | 384 | // ------------------------------------- 385 | // Shader Stages 386 | #pragma vertex DepthNormalsVertex 387 | #pragma fragment DepthNormalsFragment 388 | 389 | // ------------------------------------- 390 | // Material Keywords 391 | #pragma shader_feature_local _NORMALMAP 392 | #pragma shader_feature_local _PARALLAXMAP 393 | #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED 394 | #pragma shader_feature_local _ALPHATEST_ON 395 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 396 | 397 | // ------------------------------------- 398 | // Unity defined keywords 399 | #pragma multi_compile _ LOD_FADE_CROSSFADE 400 | 401 | // ------------------------------------- 402 | // Universal Pipeline keywords 403 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" 404 | 405 | //-------------------------------------- 406 | // GPU Instancing 407 | #pragma multi_compile_instancing 408 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 409 | 410 | // ------------------------------------- 411 | // Includes 412 | 413 | #define DEPTH_NORMALS_PASS 414 | 415 | #include "VertexColorLit.hlsl" 416 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPDepthNormalsPass.hlsl" 417 | 418 | ENDHLSL 419 | } 420 | 421 | // This pass it not used during regular rendering, only for lightmap baking. 422 | Pass 423 | { 424 | Name "Meta" 425 | Tags 426 | { 427 | "LightMode" = "Meta" 428 | } 429 | 430 | // ------------------------------------- 431 | // Render State Commands 432 | Cull Off 433 | 434 | HLSLPROGRAM 435 | #pragma target 2.0 436 | 437 | // ------------------------------------- 438 | // Shader Stages 439 | #pragma vertex UniversalVertexMeta 440 | #pragma fragment UniversalFragmentMetaLit 441 | 442 | // ------------------------------------- 443 | // Material Keywords 444 | #pragma shader_feature_local_fragment _SPECULAR_SETUP 445 | #pragma shader_feature_local_fragment _EMISSION 446 | #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP 447 | #pragma shader_feature_local_fragment _ALPHATEST_ON 448 | #pragma shader_feature_local_fragment _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 449 | #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED 450 | #pragma shader_feature_local_fragment _SPECGLOSSMAP 451 | #pragma shader_feature EDITOR_VISUALIZATION 452 | 453 | // ------------------------------------- 454 | // Includes 455 | 456 | #define META_PASS 457 | 458 | #include "VertexColorLit.hlsl" 459 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPMetaPass.hlsl" 460 | 461 | ENDHLSL 462 | } 463 | 464 | Pass 465 | { 466 | Name "Universal2D" 467 | Tags 468 | { 469 | "LightMode" = "Universal2D" 470 | } 471 | 472 | // ------------------------------------- 473 | // Render State Commands 474 | Blend[_SrcBlend][_DstBlend] 475 | ZWrite[_ZWrite] 476 | Cull[_Cull] 477 | 478 | HLSLPROGRAM 479 | #pragma target 2.0 480 | 481 | // ------------------------------------- 482 | // Shader Stages 483 | #pragma vertex vert 484 | #pragma fragment frag 485 | 486 | // ------------------------------------- 487 | // Material Keywords 488 | #pragma shader_feature_local_fragment _ALPHATEST_ON 489 | #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON 490 | 491 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" 492 | 493 | // ------------------------------------- 494 | // Includes 495 | 496 | #define UNIVERSAL_2D_PASS 497 | 498 | #include "VertexColorLit.hlsl" 499 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URP2DPass.hlsl" 500 | 501 | ENDHLSL 502 | } 503 | 504 | Pass 505 | { 506 | Name "MotionVectors" 507 | Tags { "LightMode" = "MotionVectors" } 508 | ColorMask RG 509 | 510 | HLSLPROGRAM 511 | 512 | // ------------------------------------- 513 | // Shader Stages 514 | #pragma vertex MotionVectorVertex 515 | #pragma fragment MotionVectorVertexFragment 516 | 517 | // ------------------------------------- 518 | // Material Keywords 519 | #pragma shader_feature_local _ALPHATEST_ON 520 | #pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY 521 | 522 | // ------------------------------------- 523 | // Unity defined keywords 524 | #pragma multi_compile _ LOD_FADE_CROSSFADE 525 | 526 | // ------------------------------------- 527 | // Includes 528 | 529 | #define MOTION_VECTOR_PASS 530 | 531 | #include "VertexColorLit.hlsl" 532 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPMotionVectorPass.hlsl" 533 | 534 | ENDHLSL 535 | } 536 | 537 | Pass 538 | { 539 | Name "XRMotionVectors" 540 | Tags { "LightMode" = "XRMotionVectors" } 541 | ColorMask RGBA 542 | 543 | // Stencil write for obj motion pixels 544 | Stencil 545 | { 546 | WriteMask 1 547 | Ref 1 548 | Comp Always 549 | Pass Replace 550 | } 551 | 552 | HLSLPROGRAM 553 | 554 | // ------------------------------------- 555 | // Shader Stages 556 | #pragma vertex MotionVectorVertex 557 | #pragma fragment MotionVectorVertexFragment 558 | 559 | // ------------------------------------- 560 | // Material Keywords 561 | #pragma shader_feature_local _ALPHATEST_ON 562 | #pragma shader_feature_local_vertex _ADD_PRECOMPUTED_VELOCITY 563 | 564 | // ------------------------------------- 565 | // Unity defined keywords 566 | #pragma multi_compile _ LOD_FADE_CROSSFADE 567 | #define APLICATION_SPACE_WARP_MOTION 1 568 | 569 | // ------------------------------------- 570 | // Includes 571 | 572 | #define MOTION_VECTOR_PASS 573 | 574 | #include "VertexColorLit.hlsl" 575 | #include "Packages/com.clarky.urpsurfaceshader/Includes/URPMotionVectorPass.hlsl" 576 | 577 | ENDHLSL 578 | } 579 | } 580 | 581 | FallBack "Hidden/Universal Render Pipeline/FallbackError" 582 | CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.LitShader" 583 | } 584 | -------------------------------------------------------------------------------- /Shaders/Vertex Color/VertexColorLit.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8847d07baed36d4382482270689294c 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.clarky.urpsurfaceshader", 3 | "version": "1.0.0", 4 | "license": "MIT", 5 | "dependencies": { 6 | "com.unity.render-pipelines.universal": "12.1.7" 7 | }, 8 | "displayName": "Unity URP Surface Shader Extensions", 9 | "description": "A set of macro based shaders that allow easier customisation of the standard URP surface shader.", 10 | "unity": "2020.1", 11 | "author": "Clarky Cat (https://github.com/traggett)" 12 | } 13 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 43dac286ad712554da61712b1ca61203 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------