diff --git a/README.md b/README.md index 6df06be..72f9b31 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ If in doubt try to import the sample you want to use and start from there. - **Universal Render Pipeline:** Add the renderer feature `Order Independent Transparency Renderer` to your Universal Renderer Asset. - **Post-Processing Stack v2:** Add the post-processing override `Order Independent Transparency` to a post-processing volume in your scene. -2. Change the material of every object that shall be rendered with order-independent transparency. They have to be rendered with a shader writing to the buffer used by the order-independent transparency implementation. Two sample shaders that you can use are included in this project: `OrderIndependentTransparency/Unlit` for all pipelines and additionally `OrderIndependentTransparency/Standard` for the built-in pipeline. +2. Change the material of every object that shall be rendered with order-independent transparency. They have to be rendered with a shader writing to the buffer used by the order-independent transparency implementation. Two sample shaders that you can use are included in this project: `OrderIndependentTransparency/Unlit` for all pipelines, `OrderIndependentTransparency/Standard` for the built-in pipeline and `OrderIndependentTransparency/URP/Lit` for the Universal Render Pipeline. 3. Run your scene. diff --git a/Samples~/URP Demo/Materials/BlueTransparent.mat b/Samples~/URP Demo/Materials/BlueTransparent.mat index 5df4e8b..5cf4604 100644 --- a/Samples~/URP Demo/Materials/BlueTransparent.mat +++ b/Samples~/URP Demo/Materials/BlueTransparent.mat @@ -8,16 +8,18 @@ Material: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_Name: BlueTransparent - m_Shader: {fileID: 4800000, guid: fb32df2ea84beb3469051c4a2fde36e4, type: 3} + m_Shader: {fileID: 4800000, guid: c20571aee5e15994a94948a184fd2028, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 m_ValidKeywords: [] - m_InvalidKeywords: - - _ALPHAPREMULTIPLY_ON + m_InvalidKeywords: [] m_LightmapFlags: 4 m_EnableInstancingVariants: 0 m_DoubleSidedGI: 0 m_CustomRenderQueue: -1 stringTagMap: {} disabledShaderPasses: [] + m_LockedProperties: m_SavedProperties: serializedVersion: 3 m_TexEnvs: @@ -25,6 +27,10 @@ Material: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} - _BumpMap: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} @@ -61,17 +67,39 @@ Material: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} m_Ints: [] m_Floats: - _Alpha: 0.5 + - _AlphaClip: 0 - _Amount: 1 - _Amplitude: 1 + - _BlendModePreserveSpecular: 1 - _BumpScale: 1 + - _ClearCoatMask: 0 + - _ClearCoatSmoothness: 0 - _Cutoff: 0.5 - _CutoutThresh: 0.2 + - _DetailAlbedoMapScale: 1 - _DetailNormalMapScale: 1 - _Distance: 1 - _DstBlend: 10 + - _EnvironmentReflections: 1 - _GlossMapScale: 1 - _Glossiness: 0.5 - _GlossyReflections: 1 @@ -79,15 +107,21 @@ Material: - _Mode: 3 - _OcclusionStrength: 1 - _Parallax: 0.02 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _Smoothness: 0.5 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - _Speed: 1 - _SrcBlend: 1 - _Transparency: 0.5 - _UVSec: 0 + - _WorkflowMode: 1 - _ZWrite: 0 m_Colors: - - _Color: {r: 0, g: 0.14112902, b: 1, a: 0.59607846} + - _BaseColor: {r: 0, g: 0.14117648, b: 1, a: 0.59607846} + - _Color: {r: 0, g: 0.14117643, b: 1, a: 0.59607846} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} - _TintColor: {r: 0.100138426, g: 1, b: 0, a: 1} m_BuildTextureStacks: [] diff --git a/Samples~/URP Demo/Materials/GreenTransparent.mat b/Samples~/URP Demo/Materials/GreenTransparent.mat index 99584a6..8c02a5d 100644 --- a/Samples~/URP Demo/Materials/GreenTransparent.mat +++ b/Samples~/URP Demo/Materials/GreenTransparent.mat @@ -8,16 +8,18 @@ Material: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_Name: GreenTransparent - m_Shader: {fileID: 4800000, guid: fb32df2ea84beb3469051c4a2fde36e4, type: 3} + m_Shader: {fileID: 4800000, guid: c20571aee5e15994a94948a184fd2028, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 m_ValidKeywords: [] - m_InvalidKeywords: - - _ALPHAPREMULTIPLY_ON + m_InvalidKeywords: [] m_LightmapFlags: 4 m_EnableInstancingVariants: 0 m_DoubleSidedGI: 0 m_CustomRenderQueue: -1 stringTagMap: {} disabledShaderPasses: [] + m_LockedProperties: m_SavedProperties: serializedVersion: 3 m_TexEnvs: @@ -25,6 +27,10 @@ Material: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} - _BumpMap: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} @@ -61,17 +67,39 @@ Material: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} m_Ints: [] m_Floats: - _Alpha: 0.5 + - _AlphaClip: 0 - _Amount: 1 - _Amplitude: 1 + - _BlendModePreserveSpecular: 1 - _BumpScale: 1 + - _ClearCoatMask: 0 + - _ClearCoatSmoothness: 0 - _Cutoff: 0.5 - _CutoutThresh: 0.2 + - _DetailAlbedoMapScale: 1 - _DetailNormalMapScale: 1 - _Distance: 1 - _DstBlend: 10 + - _EnvironmentReflections: 1 - _GlossMapScale: 1 - _Glossiness: 0.5 - _GlossyReflections: 1 @@ -79,15 +107,21 @@ Material: - _Mode: 3 - _OcclusionStrength: 1 - _Parallax: 0.02 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _Smoothness: 0.5 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - _Speed: 1 - _SrcBlend: 1 - _Transparency: 0.5 - _UVSec: 0 + - _WorkflowMode: 1 - _ZWrite: 0 m_Colors: - - _Color: {r: 0, g: 0.9705882, b: 0.13725491, a: 0.4745098} + - _BaseColor: {r: 0, g: 0.96862745, b: 0.13725491, a: 0.4745098} + - _Color: {r: 0, g: 0.9686274, b: 0.13725486, a: 0.4745098} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} - _TintColor: {r: 0.100138426, g: 1, b: 0, a: 1} m_BuildTextureStacks: [] diff --git a/Samples~/URP Demo/Materials/RedTransparent.mat b/Samples~/URP Demo/Materials/RedTransparent.mat index 50f330c..de134d4 100644 --- a/Samples~/URP Demo/Materials/RedTransparent.mat +++ b/Samples~/URP Demo/Materials/RedTransparent.mat @@ -8,16 +8,18 @@ Material: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_Name: RedTransparent - m_Shader: {fileID: 4800000, guid: fb32df2ea84beb3469051c4a2fde36e4, type: 3} + m_Shader: {fileID: 4800000, guid: c20571aee5e15994a94948a184fd2028, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 m_ValidKeywords: [] - m_InvalidKeywords: - - _ALPHAPREMULTIPLY_ON + m_InvalidKeywords: [] m_LightmapFlags: 4 m_EnableInstancingVariants: 0 m_DoubleSidedGI: 0 m_CustomRenderQueue: -1 stringTagMap: {} disabledShaderPasses: [] + m_LockedProperties: m_SavedProperties: serializedVersion: 3 m_TexEnvs: @@ -25,6 +27,10 @@ Material: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} - _BumpMap: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} @@ -61,13 +67,35 @@ Material: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} m_Ints: [] m_Floats: - _Alpha: 0.5 + - _AlphaClip: 0 + - _BlendModePreserveSpecular: 1 - _BumpScale: 1 + - _ClearCoatMask: 0 + - _ClearCoatSmoothness: 0 - _Cutoff: 0.5 + - _DetailAlbedoMapScale: 1 - _DetailNormalMapScale: 1 - _DstBlend: 10 + - _EnvironmentReflections: 1 - _GlossMapScale: 0.57 - _Glossiness: 0.5 - _GlossyReflections: 1 @@ -75,14 +103,20 @@ Material: - _Mode: 3 - _OcclusionStrength: 1 - _Parallax: 0.02 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _Smoothness: 0.5 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - _SrcBlend: 1 - _Transparency: 0.5 - _UVSec: 0 + - _WorkflowMode: 1 - _ZWrite: 0 m_Colors: - - _Color: {r: 1, g: 0, b: 0.14227676, a: 0.3882353} + - _BaseColor: {r: 1, g: 0, b: 0.14117648, a: 0.3882353} + - _Color: {r: 1, g: 0, b: 0.14117643, a: 0.3882353} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} - _TintColor: {r: 0.990566, g: 0.07008721, b: 0.07008721, a: 1} m_BuildTextureStacks: [] diff --git a/Samples~/URP Demo/Scenes/URP Demo.unity b/Samples~/URP Demo/Scenes/URP Demo.unity index 4f77dc4..236fd97 100644 --- a/Samples~/URP Demo/Scenes/URP Demo.unity +++ b/Samples~/URP Demo/Scenes/URP Demo.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.18028352, g: 0.22571376, b: 0.30692244, a: 1} + m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -104,7 +104,7 @@ NavMeshSettings: serializedVersion: 2 m_ObjectHideFlags: 0 m_BuildSettings: - serializedVersion: 2 + serializedVersion: 3 agentTypeID: 0 agentRadius: 0.5 agentHeight: 2 @@ -117,7 +117,7 @@ NavMeshSettings: cellSize: 0.16666667 manualTileSize: 0 tileSize: 256 - accuratePlacement: 0 + buildHeightMesh: 0 maxJobWorkers: 0 preserveTilesOutsideBounds: 0 debug: @@ -148,13 +148,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 110769479} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068} m_LocalPosition: {x: -1.669, y: 0, z: -0.614} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1222857699} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0} --- !u!23 &110769481 MeshRenderer: @@ -229,6 +229,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 143856929} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} @@ -238,7 +239,6 @@ Transform: - {fileID: 224005536} - {fileID: 1513958291} m_Father: {fileID: 0} - m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &203844586 GameObject: @@ -270,14 +270,17 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3} m_Name: m_EditorClassIdentifier: - m_Version: 1 + m_Version: 3 m_UsePipelineSettings: 1 m_AdditionalLightsShadowResolutionTier: 2 m_LightLayerMask: 1 + m_RenderingLayers: 1 m_CustomShadowLayers: 0 m_ShadowLayerMask: 1 + m_ShadowRenderingLayers: 1 m_LightCookieSize: {x: 1, y: 1} m_LightCookieOffset: {x: 0, y: 0} + m_SoftShadowQuality: 1 --- !u!108 &203844588 Light: m_ObjectHideFlags: 0 @@ -347,13 +350,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 203844586} + serializedVersion: 2 m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} m_LocalPosition: {x: 0, y: 3, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!1 &224005535 GameObject: @@ -381,13 +384,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 224005535} + serializedVersion: 2 m_LocalRotation: {x: -0, y: 0.09998343, z: -0, w: 0.99498916} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1.1, y: 1.1, z: 1.1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 143856930} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 11.476001, z: 0} --- !u!64 &224005537 MeshCollider: @@ -397,9 +400,17 @@ MeshCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 224005535} m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 m_IsTrigger: 0 + m_ProvidesContacts: 0 m_Enabled: 1 - serializedVersion: 4 + serializedVersion: 5 m_Convex: 0 m_CookingOptions: 30 m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} @@ -478,13 +489,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 602626346} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068} m_LocalPosition: {x: 1.73, y: 0, z: 0.96} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1222857699} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0} --- !u!23 &602626348 MeshRenderer: @@ -585,9 +596,20 @@ MonoBehaviour: m_Dithering: 1 m_ClearDepth: 1 m_AllowXRRendering: 1 + m_AllowHDROutput: 1 + m_UseScreenCoordOverride: 0 + m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0} + m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0} m_RequiresDepthTexture: 0 m_RequiresColorTexture: 0 m_Version: 2 + m_TaaSettings: + quality: 3 + frameInfluence: 0.1 + jitterScale: 1 + mipBias: 0 + varianceClampScale: 0.9 + contrastAdaptiveSharpening: 0 --- !u!81 &961739751 AudioListener: m_ObjectHideFlags: 0 @@ -610,9 +632,17 @@ Camera: m_projectionMatrixMode: 1 m_GateFitMode: 2 m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 m_SensorSize: {x: 36, y: 24} m_LensShift: {x: 0, y: 0} - m_FocalLength: 50 m_NormalizedViewPortRect: serializedVersion: 2 x: 0 @@ -646,13 +676,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 961739749} + serializedVersion: 2 m_LocalRotation: {x: 0.094127685, y: 0.70081383, z: -0.094127685, w: 0.70081383} m_LocalPosition: {x: -3.63, y: 1, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 15.299, y: 90, z: 0} --- !u!1 &1160234425 GameObject: @@ -695,13 +725,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1160234425} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1222857698 GameObject: @@ -726,6 +756,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1222857698} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} @@ -734,7 +765,6 @@ Transform: - {fileID: 602626347} - {fileID: 110769480} m_Father: {fileID: 0} - m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1513958290 GameObject: @@ -762,13 +792,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1513958290} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0.21933535, z: 0, w: 0.9756496} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0.39, y: 0.75, z: 1.12} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 143856930} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 25.34, z: 0} --- !u!65 &1513958292 BoxCollider: @@ -778,9 +808,17 @@ BoxCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1513958290} m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 m_IsTrigger: 0 + m_ProvidesContacts: 0 m_Enabled: 1 - serializedVersion: 2 + serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &1513958293 @@ -860,9 +898,17 @@ MeshCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1757967213} m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 m_IsTrigger: 0 + m_ProvidesContacts: 0 m_Enabled: 1 - serializedVersion: 4 + serializedVersion: 5 m_Convex: 0 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} @@ -923,13 +969,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1757967213} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: -0.5, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1946236695 GameObject: @@ -957,13 +1003,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1946236695} + serializedVersion: 2 m_LocalRotation: {x: -0, y: -0.44048807, z: -0, w: 0.8977585} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 143856930} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: -52.270004, z: 0} --- !u!64 &1946236697 MeshCollider: @@ -973,9 +1019,17 @@ MeshCollider: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1946236695} m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 m_IsTrigger: 0 + m_ProvidesContacts: 0 m_Enabled: 1 - serializedVersion: 4 + serializedVersion: 5 m_Convex: 0 m_CookingOptions: 30 m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} @@ -1029,3 +1083,13 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1946236695} m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 961739753} + - {fileID: 203844589} + - {fileID: 1160234427} + - {fileID: 143856930} + - {fileID: 1222857699} + - {fileID: 1757967217} diff --git a/Shaders/LinkedListCreation.hlsl b/Shaders/LinkedListCreation.hlsl index 1f3a471..187cece 100644 --- a/Shaders/LinkedListCreation.hlsl +++ b/Shaders/LinkedListCreation.hlsl @@ -1,7 +1,6 @@ #ifndef OIT_LINKED_LIST_INCLUDED #define OIT_LINKED_LIST_INCLUDED -#include "UnityCG.cginc" #include "OitUtils.hlsl" struct FragmentAndLinkBuffer_STRUCT @@ -26,7 +25,7 @@ void createFragmentEntry(float4 col, float3 pos, uint uSampleIdx) { //add new Fragment Entry in FragmentAndLinkBuffer FragmentAndLinkBuffer_STRUCT Element; Element.pixelColor = PackRGBA(col); - Element.uDepthSampleIdx = PackDepthSampleIdx(Linear01Depth(pos.z), uSampleIdx); + Element.uDepthSampleIdx = PackDepthSampleIdx(OitLinear01Depth(pos.z), uSampleIdx); Element.next = uOldStartOffset; FLBuffer[uPixelCount] = Element; } diff --git a/Shaders/OitUtils.hlsl b/Shaders/OitUtils.hlsl index a6eab95..f30855b 100644 --- a/Shaders/OitUtils.hlsl +++ b/Shaders/OitUtils.hlsl @@ -39,4 +39,10 @@ uint PackDepthSampleIdx(float depth, uint uSampleIdx) { return d << 8UL | uSampleIdx; } +// Z buffer to linear 0..1 depth +inline float OitLinear01Depth( float z ) +{ + return 1.0 / (_ZBufferParams.x * z + _ZBufferParams.y); +} + #endif // OIT_UTILS_INCLUDED \ No newline at end of file diff --git a/URP/Shaders.meta b/URP/Shaders.meta new file mode 100644 index 0000000..31b07d3 --- /dev/null +++ b/URP/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3c66fc08103baab4383fdf946814ac9c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/URP/Shaders/OitLitForwardPassURP.hlsl b/URP/Shaders/OitLitForwardPassURP.hlsl new file mode 100644 index 0000000..4af2562 --- /dev/null +++ b/URP/Shaders/OitLitForwardPassURP.hlsl @@ -0,0 +1,249 @@ +#ifndef UNIVERSAL_FORWARD_LIT_PASS_INCLUDED +#define UNIVERSAL_FORWARD_LIT_PASS_INCLUDED + +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" +#if defined(LOD_FADE_CROSSFADE) + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl" +#endif +#include "Packages/org.happy-turtle.order-independent-transparency/Shaders/LinkedListCreation.hlsl" + +// GLES2 has limited amount of interpolators +#if defined(_PARALLAXMAP) && !defined(SHADER_API_GLES) +#define REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR +#endif + +#if (defined(_NORMALMAP) || (defined(_PARALLAXMAP) && !defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR))) || defined(_DETAIL) +#define REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR +#endif + +// keep this file in sync with LitGBufferPass.hlsl + +struct Attributes +{ + float4 positionOS : POSITION; + float3 normalOS : NORMAL; + float4 tangentOS : TANGENT; + float2 texcoord : TEXCOORD0; + float2 staticLightmapUV : TEXCOORD1; + float2 dynamicLightmapUV : TEXCOORD2; + UNITY_VERTEX_INPUT_INSTANCE_ID +}; + +struct Varyings +{ + float2 uv : TEXCOORD0; + +#if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR) + float3 positionWS : TEXCOORD1; +#endif + + float3 normalWS : TEXCOORD2; +#if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR) + half4 tangentWS : TEXCOORD3; // xyz: tangent, w: sign +#endif + +#ifdef _ADDITIONAL_LIGHTS_VERTEX + half4 fogFactorAndVertexLight : TEXCOORD5; // x: fogFactor, yzw: vertex light +#else + half fogFactor : TEXCOORD5; +#endif + +#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) + float4 shadowCoord : TEXCOORD6; +#endif + +#if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR) + half3 viewDirTS : TEXCOORD7; +#endif + + DECLARE_LIGHTMAP_OR_SH(staticLightmapUV, vertexSH, 8); +#ifdef DYNAMICLIGHTMAP_ON + float2 dynamicLightmapUV : TEXCOORD9; // Dynamic lightmap UVs +#endif + + float4 positionCS : SV_POSITION; + UNITY_VERTEX_INPUT_INSTANCE_ID + UNITY_VERTEX_OUTPUT_STEREO +}; + +void InitializeInputData(Varyings input, half3 normalTS, out InputData inputData) +{ + inputData = (InputData)0; + +#if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR) + inputData.positionWS = input.positionWS; +#endif + + half3 viewDirWS = GetWorldSpaceNormalizeViewDir(input.positionWS); +#if defined(_NORMALMAP) || defined(_DETAIL) + float sgn = input.tangentWS.w; // should be either +1 or -1 + float3 bitangent = sgn * cross(input.normalWS.xyz, input.tangentWS.xyz); + half3x3 tangentToWorld = half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWS.xyz); + + #if defined(_NORMALMAP) + inputData.tangentToWorld = tangentToWorld; + #endif + inputData.normalWS = TransformTangentToWorld(normalTS, tangentToWorld); +#else + inputData.normalWS = input.normalWS; +#endif + + inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS); + inputData.viewDirectionWS = viewDirWS; + +#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) + inputData.shadowCoord = input.shadowCoord; +#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS) + inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS); +#else + inputData.shadowCoord = float4(0, 0, 0, 0); +#endif +#ifdef _ADDITIONAL_LIGHTS_VERTEX + inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS, 1.0), input.fogFactorAndVertexLight.x); + inputData.vertexLighting = input.fogFactorAndVertexLight.yzw; +#else + inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS, 1.0), input.fogFactor); +#endif + +#if defined(DYNAMICLIGHTMAP_ON) + inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.dynamicLightmapUV, input.vertexSH, inputData.normalWS); +#else + inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.vertexSH, inputData.normalWS); +#endif + + inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS); + inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV); + + #if defined(DEBUG_DISPLAY) + #if defined(DYNAMICLIGHTMAP_ON) + inputData.dynamicLightmapUV = input.dynamicLightmapUV; + #endif + #if defined(LIGHTMAP_ON) + inputData.staticLightmapUV = input.staticLightmapUV; + #else + inputData.vertexSH = input.vertexSH; + #endif + #endif +} + +/////////////////////////////////////////////////////////////////////////////// +// Vertex and Fragment functions // +/////////////////////////////////////////////////////////////////////////////// + +// Used in Standard (Physically Based) shader +Varyings LitPassVertex(Attributes input) +{ + Varyings output = (Varyings)0; + + UNITY_SETUP_INSTANCE_ID(input); + UNITY_TRANSFER_INSTANCE_ID(input, output); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); + + VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz); + + // normalWS and tangentWS already normalize. + // this is required to avoid skewing the direction during interpolation + // also required for per-vertex lighting and SH evaluation + VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS, input.tangentOS); + + half3 vertexLight = VertexLighting(vertexInput.positionWS, normalInput.normalWS); + + half fogFactor = 0; + #if !defined(_FOG_FRAGMENT) + fogFactor = ComputeFogFactor(vertexInput.positionCS.z); + #endif + + output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap); + + // already normalized from normal transform to WS. + output.normalWS = normalInput.normalWS; +#if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR) || defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR) + real sign = input.tangentOS.w * GetOddNegativeScale(); + half4 tangentWS = half4(normalInput.tangentWS.xyz, sign); +#endif +#if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR) + output.tangentWS = tangentWS; +#endif + +#if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR) + half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS); + half3 viewDirTS = GetViewDirectionTangentSpace(tangentWS, output.normalWS, viewDirWS); + output.viewDirTS = viewDirTS; +#endif + + OUTPUT_LIGHTMAP_UV(input.staticLightmapUV, unity_LightmapST, output.staticLightmapUV); +#ifdef DYNAMICLIGHTMAP_ON + output.dynamicLightmapUV = input.dynamicLightmapUV.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw; +#endif + OUTPUT_SH(output.normalWS.xyz, output.vertexSH); +#ifdef _ADDITIONAL_LIGHTS_VERTEX + output.fogFactorAndVertexLight = half4(fogFactor, vertexLight); +#else + output.fogFactor = fogFactor; +#endif + +#if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR) + output.positionWS = vertexInput.positionWS; +#endif + +#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) + output.shadowCoord = GetShadowCoord(vertexInput); +#endif + + output.positionCS = vertexInput.positionCS; + + return output; +} + +[earlydepthstencil] +// Used in Standard (Physically Based) shader +void LitPassFragment( + Varyings input + , out half4 outColor : SV_Target0 +#ifdef _WRITE_RENDERING_LAYERS + , out float4 outRenderingLayers : SV_Target1 +#endif + , uint uSampleIdx : SV_SampleIndex +) +{ + UNITY_SETUP_INSTANCE_ID(input); + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + +#if defined(_PARALLAXMAP) +#if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR) + half3 viewDirTS = input.viewDirTS; +#else + half3 viewDirWS = GetWorldSpaceNormalizeViewDir(input.positionWS); + half3 viewDirTS = GetViewDirectionTangentSpace(input.tangentWS, input.normalWS, viewDirWS); +#endif + ApplyPerPixelDisplacement(viewDirTS, input.uv); +#endif + + SurfaceData surfaceData; + InitializeStandardLitSurfaceData(input.uv, surfaceData); + +#ifdef LOD_FADE_CROSSFADE + LODFadeCrossFade(input.positionCS); +#endif + + InputData inputData; + InitializeInputData(input, surfaceData.normalTS, inputData); + SETUP_DEBUG_TEXTURE_DATA(inputData, input.uv, _BaseMap); + +#ifdef _DBUFFER + ApplyDecalToSurfaceData(input.positionCS, surfaceData, inputData); +#endif + + half4 color = UniversalFragmentPBR(inputData, surfaceData); + color.rgb = MixFog(color.rgb, inputData.fogCoord); + + createFragmentEntry(color, input.positionCS.xyz, uSampleIdx); + outColor = color; + +#ifdef _WRITE_RENDERING_LAYERS + uint renderingLayers = GetMeshRenderingLayer(); + outRenderingLayers = float4(EncodeMeshRenderingLayer(renderingLayers), 0, 0, 0); +#endif +} + +#endif diff --git a/URP/Shaders/OitLitForwardPassURP.hlsl.meta b/URP/Shaders/OitLitForwardPassURP.hlsl.meta new file mode 100644 index 0000000..4e3b8c6 --- /dev/null +++ b/URP/Shaders/OitLitForwardPassURP.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d9d04fa8cd4786b488fe234bcb29d463 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/URP/Shaders/OitLitURP.shader b/URP/Shaders/OitLitURP.shader new file mode 100644 index 0000000..8752882 --- /dev/null +++ b/URP/Shaders/OitLitURP.shader @@ -0,0 +1,424 @@ +Shader "OrderIndependentTransparency/URP/Lit" +{ + Properties + { + // Specular vs Metallic workflow + _WorkflowMode("WorkflowMode", Float) = 1.0 + + [MainTexture] _BaseMap("Albedo", 2D) = "white" {} + [MainColor] _BaseColor("Color", Color) = (1,1,1,1) + + _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + + _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 + _SmoothnessTextureChannel("Smoothness texture channel", Float) = 0 + + _Metallic("Metallic", Range(0.0, 1.0)) = 0.0 + _MetallicGlossMap("Metallic", 2D) = "white" {} + + _SpecColor("Specular", Color) = (0.2, 0.2, 0.2) + _SpecGlossMap("Specular", 2D) = "white" {} + + [ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0 + [ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0 + + _BumpScale("Scale", Float) = 1.0 + _BumpMap("Normal Map", 2D) = "bump" {} + + _Parallax("Scale", Range(0.005, 0.08)) = 0.005 + _ParallaxMap("Height Map", 2D) = "black" {} + + _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0 + _OcclusionMap("Occlusion", 2D) = "white" {} + + [HDR] _EmissionColor("Color", Color) = (0,0,0) + _EmissionMap("Emission", 2D) = "white" {} + + _DetailMask("Detail Mask", 2D) = "white" {} + _DetailAlbedoMapScale("Scale", Range(0.0, 2.0)) = 1.0 + _DetailAlbedoMap("Detail Albedo x2", 2D) = "linearGrey" {} + _DetailNormalMapScale("Scale", Range(0.0, 2.0)) = 1.0 + [Normal] _DetailNormalMap("Normal Map", 2D) = "bump" {} + + // SRP batching compatibility for Clear Coat (Not used in Lit) + [HideInInspector] _ClearCoatMask("_ClearCoatMask", Float) = 0.0 + [HideInInspector] _ClearCoatSmoothness("_ClearCoatSmoothness", Float) = 0.0 + + // Blending state + [ToggleUI] _AlphaClip("__clip", Float) = 0.0 + [HideInInspector] _BlendModePreserveSpecular("_BlendModePreserveSpecular", Float) = 1.0 + + [ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0 + // Editmode props + _QueueOffset("Queue offset", Float) = 0.0 + + // ObsoleteProperties + [HideInInspector] _MainTex("BaseMap", 2D) = "white" {} + [HideInInspector] _Color("Base Color", Color) = (1, 1, 1, 1) + [HideInInspector] _GlossMapScale("Smoothness", Float) = 0.0 + [HideInInspector] _Glossiness("Smoothness", Float) = 0.0 + [HideInInspector] _GlossyReflections("EnvironmentReflections", Float) = 0.0 + + [HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {} + [HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {} + [HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {} + } + + SubShader + { + // Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings + // this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this + // material work with both Universal Render Pipeline and Builtin Unity Pipeline + Tags + { + "RenderType" = "Opaque" + "RenderPipeline" = "UniversalPipeline" + "UniversalMaterialType" = "Lit" + "IgnoreProjector" = "True" + } + LOD 300 + + // ------------------------------------------------------------------ + // Forward pass. Shades all light in a single pass. GI + emission + Fog + Pass + { + // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with + // no LightMode tag are also rendered by Universal Render Pipeline + Name "ForwardLit" + Tags + { + "LightMode" = "UniversalForward" + } + + // ------------------------------------- + // Render State Commands + ZTest LEqual + ZWrite Off + ColorMask 0 + Cull Off + + HLSLPROGRAM + #pragma target 5.0 + #pragma require randomwrite + + // ------------------------------------- + // Shader Stages + #pragma vertex LitPassVertex + #pragma fragment LitPassFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _NORMALMAP + #pragma shader_feature_local _PARALLAXMAP + #pragma shader_feature_local _RECEIVE_SHADOWS_OFF + #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local_fragment _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON + #pragma shader_feature_local_fragment _EMISSION + #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP + #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + #pragma shader_feature_local_fragment _OCCLUSIONMAP + #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF + #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF + #pragma shader_feature_local_fragment _SPECULAR_SETUP + + // ------------------------------------- + // Universal Pipeline keywords + #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN + #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS + #pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX + #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS + #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING + #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION + #pragma multi_compile_fragment _ _SHADOWS_SOFT + #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION + #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 + #pragma multi_compile_fragment _ _LIGHT_LAYERS + #pragma multi_compile_fragment _ _LIGHT_COOKIES + #pragma multi_compile _ _FORWARD_PLUS + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" + + + // ------------------------------------- + // Unity defined keywords + #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING + #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE + #pragma multi_compile_fog + #pragma multi_compile_fragment _ DEBUG_DISPLAY + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" + #include "OitLitForwardPassURP.hlsl" + ENDHLSL + } + + Pass + { + Name "ShadowCaster" + Tags + { + "LightMode" = "ShadowCaster" + } + + // ------------------------------------- + // Render State Commands + ZWrite On + ZTest LEqual + ColorMask 0 + Cull[_Cull] + + HLSLPROGRAM + #pragma target 5.0 + + // ------------------------------------- + // Shader Stages + #pragma vertex ShadowPassVertex + #pragma fragment ShadowPassFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + + // ------------------------------------- + // Universal Pipeline keywords + + // ------------------------------------- + // Unity defined keywords + #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE + + // This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias + #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW + + // ------------------------------------- + // Includes + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl" + ENDHLSL + } + + Pass + { + // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with + // no LightMode tag are also rendered by Universal Render Pipeline + Name "GBuffer" + Tags + { + "LightMode" = "UniversalGBuffer" + } + + // ------------------------------------- + // Render State Commands + ZWrite[_ZWrite] + ZTest LEqual + Cull[_Cull] + + HLSLPROGRAM + #pragma target 4.5 + + // Deferred Rendering Path does not support the OpenGL-based graphics API: + // Desktop OpenGL, OpenGL ES 3.0, WebGL 2.0. + #pragma exclude_renderers gles3 glcore + + // ------------------------------------- + // Shader Stages + #pragma vertex LitGBufferPassVertex + #pragma fragment LitGBufferPassFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _NORMALMAP + #pragma shader_feature_local_fragment _ALPHATEST_ON + //#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON + #pragma shader_feature_local_fragment _EMISSION + #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP + #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + #pragma shader_feature_local_fragment _OCCLUSIONMAP + #pragma shader_feature_local _PARALLAXMAP + #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED + + #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF + #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF + #pragma shader_feature_local_fragment _SPECULAR_SETUP + #pragma shader_feature_local _RECEIVE_SHADOWS_OFF + + // ------------------------------------- + // Universal Pipeline keywords + #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN + //#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS + //#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS + #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING + #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION + #pragma multi_compile_fragment _ _SHADOWS_SOFT + #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 + #pragma multi_compile_fragment _ _RENDER_PASS_ENABLED + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" + + // ------------------------------------- + // Unity defined keywords + #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING + #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE + #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + + // ------------------------------------- + // Includes + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitGBufferPass.hlsl" + ENDHLSL + } + + // This pass is used when drawing to a _CameraNormalsTexture texture + Pass + { + Name "DepthNormals" + Tags + { + "LightMode" = "DepthNormals" + } + + // ------------------------------------- + // Render State Commands + ZWrite On + Cull[_Cull] + + HLSLPROGRAM + #pragma target 5.0 + + // ------------------------------------- + // Shader Stages + #pragma vertex DepthNormalsVertex + #pragma fragment DepthNormalsFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _NORMALMAP + #pragma shader_feature_local _PARALLAXMAP + #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + // ------------------------------------- + // Unity defined keywords + #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE + + // ------------------------------------- + // Universal Pipeline keywords + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + + // ------------------------------------- + // Includes + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitDepthNormalsPass.hlsl" + ENDHLSL + } + + // This pass it not used during regular rendering, only for lightmap baking. + Pass + { + Name "Meta" + Tags + { + "LightMode" = "Meta" + } + + // ------------------------------------- + // Render State Commands + Cull Off + + HLSLPROGRAM + #pragma target 5.0 + + // ------------------------------------- + // Shader Stages + #pragma vertex UniversalVertexMeta + #pragma fragment UniversalFragmentMetaLit + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local_fragment _SPECULAR_SETUP + #pragma shader_feature_local_fragment _EMISSION + #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local_fragment _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED + #pragma shader_feature_local_fragment _SPECGLOSSMAP + #pragma shader_feature EDITOR_VISUALIZATION + + // ------------------------------------- + // Includes + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitMetaPass.hlsl" + + ENDHLSL + } + + Pass + { + Name "Universal2D" + Tags + { + "LightMode" = "Universal2D" + } + + // ------------------------------------- + // Render State Commands + ZTest LEqual + ZWrite Off + ColorMask 0 + Cull Off + + HLSLPROGRAM + #pragma target 5.0 + + // ------------------------------------- + // Shader Stages + #pragma vertex vert + #pragma fragment frag + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON + + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + + // ------------------------------------- + // Includes + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl" + ENDHLSL + } + } + + FallBack "Hidden/Universal Render Pipeline/FallbackError" + CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.LitShader" +} diff --git a/URP/Shaders/OitLitURP.shader.meta b/URP/Shaders/OitLitURP.shader.meta new file mode 100644 index 0000000..a519576 --- /dev/null +++ b/URP/Shaders/OitLitURP.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c20571aee5e15994a94948a184fd2028 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: