chore: ripple shader better style(slightly) and working clear coat properties
This commit is contained in:
parent
cb92720fa6
commit
5b70a11589
@ -10,22 +10,52 @@ Material:
|
||||
m_Name: URP PBR Ripples Variant
|
||||
m_Shader: {fileID: 4800000, guid: 8a7f26cb4a0b4d446b2ca031d3ff37df, type: 3}
|
||||
m_Parent: {fileID: 2100000, guid: 78cb0d90576fe15439f3fd294d5eaaba, type: 2}
|
||||
m_ModifiedSerializedProperties: 8
|
||||
m_ModifiedSerializedProperties: 24
|
||||
m_ValidKeywords:
|
||||
- _ALPHAPREMULTIPLY_ON
|
||||
- _CLEARCOAT
|
||||
- _OCCLUSIONMAP
|
||||
- _SPECULARHIGHLIGHTS_OFF
|
||||
- _SPECULAR_SETUP
|
||||
- _SURFACE_TYPE_TRANSPARENT
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_CustomRenderQueue: 3000
|
||||
stringTagMap:
|
||||
RenderType: Transparent
|
||||
disabledShaderPasses:
|
||||
- DepthOnly
|
||||
- SHADOWCASTER
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs: []
|
||||
m_TexEnvs:
|
||||
- _ClearCoatMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _Smoothness: 0.898
|
||||
m_Colors: []
|
||||
- _ClearCoat: 0
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _DstBlend: 10
|
||||
- _DstBlendAlpha: 10
|
||||
- _Emission: 0
|
||||
- _EnvironmentalReflections: 0
|
||||
- _Metallic: 1
|
||||
- _MetallicSpecGlossMapToggle: 0
|
||||
- _MetallicSpecToggle: 1
|
||||
- _NormalMapToggle: 0
|
||||
- _Smoothness: 0.897
|
||||
- _SmoothnessSource: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _Surface: 1
|
||||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0, g: 1, b: 0.029850721, a: 0.33333334}
|
||||
- _EmissionColor: {r: 1, g: 0.9481132, b: 0.9481132, a: 0}
|
||||
- _SpecColor: {r: 0.9433962, g: 0.9433962, b: 0.9433962, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
||||
@ -25,14 +25,20 @@ Material:
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _ALPHAPREMULTIPLY_ON
|
||||
- _OCCLUSIONMAP
|
||||
- _SPECULARHIGHLIGHTS_OFF
|
||||
- _SPECULAR_SETUP
|
||||
- _SURFACE_TYPE_TRANSPARENT
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
disabledShaderPasses:
|
||||
- DepthOnly
|
||||
- SHADOWCASTER
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
@ -45,6 +51,10 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ClearCoatMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
@ -105,17 +115,18 @@ Material:
|
||||
- _Amplitude: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 2.7
|
||||
- _BlendOp: 0
|
||||
- _BumpScale: 5.41
|
||||
- _ClearCoat: 0
|
||||
- _ClearCoatMask: 1
|
||||
- _ClearCoatSmoothness: 1
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _ControlTime: 0.06
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.43
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _DstBlend: 10
|
||||
- _DstBlendAlpha: 10
|
||||
- _Emission: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _EnvironmentalReflections: 0
|
||||
@ -125,22 +136,22 @@ Material:
|
||||
- _GlossyReflections: 0
|
||||
- _ImpactSpeed: 4.22
|
||||
- _MaxWaveDistortion: 1.13
|
||||
- _Metallic: 0.951
|
||||
- _Metallic: 0.967
|
||||
- _MetallicSpecGlossMapToggle: 0
|
||||
- _MetallicSpecToggle: 0
|
||||
- _MetallicSpecToggle: 1
|
||||
- _NormalMapToggle: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _OcclusionToggle: 0
|
||||
- _OcclusionToggle: 1
|
||||
- _Parallax: 0.005
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.979
|
||||
- _Smoothness: 0.914
|
||||
- _SmoothnessSource: 0
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SmoothnessTextureChannel: 1
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _Surface: 1
|
||||
- _WaveAmplitude: 0.08
|
||||
- _WaveBlend: 1.1
|
||||
- _WaveDensity: 20
|
||||
@ -150,7 +161,7 @@ Material:
|
||||
- _WaveRadius: 2
|
||||
- _WaveSpeed: 1.6
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
- _ZWrite: 0
|
||||
- _base_alpha: 0.5
|
||||
- _impact_amplitude: 6
|
||||
- _impact_anim: 0
|
||||
@ -169,10 +180,10 @@ Material:
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0, g: 1, b: 0.029850721, a: 0.45490196}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0.0051758625, g: 0.046813726, b: 0, a: 1}
|
||||
- _EmissionColor: {r: 4, g: 1.9433963, b: 1.9433963, a: 0}
|
||||
- _ImpactOrigin: {r: 1, g: 0, b: 0, a: 0}
|
||||
- _ModelOrigin: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _SpecColor: {r: 0.5471698, g: 0.5471698, b: 0.5471698, a: 1}
|
||||
- _SpecColor: {r: 0.9433962, g: 0.9433962, b: 0.9433962, a: 1}
|
||||
- _WaveOrigin: {r: 1, g: 0, b: 0, a: 0}
|
||||
- _impact_origin: {r: 1, g: 0, b: 0, a: 1}
|
||||
- _rotation: {r: 0.1, g: 0, b: 0, a: 1}
|
||||
|
||||
@ -1,59 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Hex Sphere Variant
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_Parent: {fileID: -3033667219593020291, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
m_ModifiedSerializedProperties: 18
|
||||
m_ValidKeywords:
|
||||
- _EMISSION
|
||||
- _SPECULARHIGHLIGHTS_OFF
|
||||
- _SURFACE_TYPE_TRANSPARENT
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 2
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: 3000
|
||||
stringTagMap:
|
||||
RenderType: Transparent
|
||||
disabledShaderPasses:
|
||||
- DepthOnly
|
||||
- SHADOWCASTER
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs: []
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _Blend: 1
|
||||
- _DstBlend: 10
|
||||
- _DstBlendAlpha: 10
|
||||
- _Metallic: 1
|
||||
- _Smoothness: 0.713
|
||||
- _SpecularHighlights: 0
|
||||
- _Surface: 1
|
||||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.13100708, g: 1, b: 0, a: 0.05882353}
|
||||
- _Color: {r: 0.13100705, g: 1, b: 0, a: 0.05882353}
|
||||
- _EmissionColor: {r: 0.09129923, g: 0.32117453, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
--- !u!114 &8233587454769063442
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 7
|
||||
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e79eeda1380b64c43977676d55c7e196
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -24,7 +24,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2195374933886378074}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0, y: 0, z: 30}
|
||||
m_LocalScale: {x: 25, y: 25, z: 25}
|
||||
m_ConstrainProportionsScale: 0
|
||||
|
||||
@ -235,7 +235,7 @@ Transform:
|
||||
m_GameObject: {fileID: 3628760}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -72}
|
||||
m_LocalPosition: {x: -154.1, y: 0, z: 9.4}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
@ -253,7 +253,7 @@ GameObject:
|
||||
- component: {fileID: 201450954}
|
||||
- component: {fileID: 201450953}
|
||||
m_Layer: 0
|
||||
m_Name: EventSystem
|
||||
m_Name: Event System
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -309,11 +309,6 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &513454604 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 7204143390722316419, guid: f2efefd732ebd9a49bd7cc42b38a69be, type: 3}
|
||||
m_PrefabInstance: {fileID: 724984873}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &664696267
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -325,7 +320,7 @@ GameObject:
|
||||
- component: {fileID: 664696269}
|
||||
- component: {fileID: 664696268}
|
||||
m_Layer: 0
|
||||
m_Name: PostProcessingVolume
|
||||
m_Name: Post Processing Volume
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -363,67 +358,6 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &724984873
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 341983564929455718, guid: f2efefd732ebd9a49bd7cc42b38a69be, type: 3}
|
||||
propertyPath: m_Materials.Array.data[0]
|
||||
value:
|
||||
objectReference: {fileID: 2100000, guid: 1338539d65504394f8f2dd0a628dc423, type: 2}
|
||||
- target: {fileID: 1530196321467136736, guid: f2efefd732ebd9a49bd7cc42b38a69be, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1530196321467136736, guid: f2efefd732ebd9a49bd7cc42b38a69be, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1530196321467136736, guid: f2efefd732ebd9a49bd7cc42b38a69be, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 30
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1530196321467136736, guid: f2efefd732ebd9a49bd7cc42b38a69be, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1530196321467136736, guid: f2efefd732ebd9a49bd7cc42b38a69be, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1530196321467136736, guid: f2efefd732ebd9a49bd7cc42b38a69be, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1530196321467136736, guid: f2efefd732ebd9a49bd7cc42b38a69be, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1530196321467136736, guid: f2efefd732ebd9a49bd7cc42b38a69be, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1530196321467136736, guid: f2efefd732ebd9a49bd7cc42b38a69be, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1530196321467136736, guid: f2efefd732ebd9a49bd7cc42b38a69be, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2195374933886378074, guid: f2efefd732ebd9a49bd7cc42b38a69be, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: NimbleZoneHexSphere
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: f2efefd732ebd9a49bd7cc42b38a69be, type: 3}
|
||||
--- !u!1 &754823974
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -436,7 +370,7 @@ GameObject:
|
||||
- component: {fileID: 754823977}
|
||||
- component: {fileID: 754823976}
|
||||
m_Layer: 5
|
||||
m_Name: AnnouncmentText
|
||||
m_Name: Announcment Text
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -569,7 +503,7 @@ GameObject:
|
||||
- component: {fileID: 796181415}
|
||||
- component: {fileID: 796181416}
|
||||
m_Layer: 0
|
||||
m_Name: GameManager
|
||||
m_Name: Game Manager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -768,7 +702,7 @@ GameObject:
|
||||
- component: {fileID: 1185564590}
|
||||
- component: {fileID: 1185564594}
|
||||
m_Layer: 3
|
||||
m_Name: NimbleZone
|
||||
m_Name: Nimble Zone
|
||||
m_TagString: Zone
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -831,12 +765,12 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
forcesManager: {fileID: 1659830376}
|
||||
renderedZoneObject: {fileID: 513454604}
|
||||
renderedZoneObject: {fileID: 2129209322}
|
||||
outsideGravityFunction: 0
|
||||
zone: 0
|
||||
rippleFrequency: 18
|
||||
rippleDensity: 20
|
||||
rippleAmplitude: 0.1
|
||||
rippleAmplitude: 0.08
|
||||
rippleBlend: 1
|
||||
rippleRadius: 1.62
|
||||
rippleDuration: 1.2
|
||||
@ -850,7 +784,7 @@ PrefabInstance:
|
||||
m_Modifications:
|
||||
- target: {fileID: -8098169881513260187, guid: 303177f7648454b4fb8179c1378dd1ec, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: PlayZone
|
||||
value: Play Zone
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -990798463411063789, guid: 303177f7648454b4fb8179c1378dd1ec, type: 3}
|
||||
propertyPath: m_Materials.Array.size
|
||||
@ -980,7 +914,7 @@ GameObject:
|
||||
- component: {fileID: 1659830377}
|
||||
- component: {fileID: 1659830376}
|
||||
m_Layer: 0
|
||||
m_Name: InstanceAffectingForcesManager
|
||||
m_Name: Instance Affecting Forces Manager
|
||||
m_TagString: ForceManager
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -1027,7 +961,7 @@ GameObject:
|
||||
- component: {fileID: 2052728257}
|
||||
- component: {fileID: 2052728261}
|
||||
m_Layer: 5
|
||||
m_Name: AnnouncerUI
|
||||
m_Name: Announcer UI
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -1129,6 +1063,88 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
announcementText: {fileID: 754823976}
|
||||
--- !u!1001 &2129209321
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: -8679921383154817045, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 25
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
propertyPath: m_LocalScale.y
|
||||
value: 25
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
propertyPath: m_LocalScale.z
|
||||
value: 25
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 30
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
propertyPath: m_ConstrainProportionsScale
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -7635826562936255635, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
propertyPath: m_Materials.Array.data[0]
|
||||
value:
|
||||
objectReference: {fileID: 2100000, guid: 78cb0d90576fe15439f3fd294d5eaaba, type: 2}
|
||||
- target: {fileID: 919132149155446097, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Hex Sphere
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
--- !u!1 &2129209322 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 8164078558771037576, guid: 24300c11f962a8e4f9f8125bd2843705, type: 3}
|
||||
m_PrefabInstance: {fileID: 2129209321}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1001 &1491164188991312957
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -1242,10 +1258,22 @@ PrefabInstance:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 1152287105883655159, guid: 65cd4fa5e050652409dd9b062365c7e8, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Spaceship9 Hull
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1349367779684097889, guid: 65cd4fa5e050652409dd9b062365c7e8, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Body Area (2)
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1372816401649438144, guid: 65cd4fa5e050652409dd9b062365c7e8, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Player Blue
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2236297877709258492, guid: 65cd4fa5e050652409dd9b062365c7e8, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Body Area (1)
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2704141135220834432, guid: 65cd4fa5e050652409dd9b062365c7e8, type: 3}
|
||||
propertyPath: cameraOperator
|
||||
value:
|
||||
@ -1294,6 +1322,18 @@ PrefabInstance:
|
||||
propertyPath: m_Materials.Array.data[0]
|
||||
value:
|
||||
objectReference: {fileID: 4874126678125670354, guid: 61dc60d6e44cd9f46bc21aa06f06f92b, type: 3}
|
||||
- target: {fileID: 5684360001092439170, guid: 65cd4fa5e050652409dd9b062365c7e8, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Spaceship9 Tail
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6980644068169889807, guid: 65cd4fa5e050652409dd9b062365c7e8, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Vulnerable Area
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9019135020271586677, guid: 65cd4fa5e050652409dd9b062365c7e8, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Player HUD Blue
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
@ -1306,7 +1346,7 @@ SceneRoots:
|
||||
- {fileID: 796181415}
|
||||
- {fileID: 2052728260}
|
||||
- {fileID: 963194228}
|
||||
- {fileID: 724984873}
|
||||
- {fileID: 2129209321}
|
||||
- {fileID: 1185564593}
|
||||
- {fileID: 1491164188991312957}
|
||||
- {fileID: 6412728625559011621}
|
||||
|
||||
@ -45,7 +45,7 @@ public class NimbleZoneDetection : MonoBehaviour
|
||||
{
|
||||
meshRenderer = renderedZoneObject.GetComponent<MeshRenderer>();
|
||||
material = meshRenderer.material;
|
||||
ResetShaderProperties();
|
||||
ResetRippleShaderProperties();
|
||||
}
|
||||
|
||||
private Func<Vector3, Vector3>[] gravityFunctions =
|
||||
@ -102,15 +102,12 @@ public class NimbleZoneDetection : MonoBehaviour
|
||||
Vector4[] rippleOrigins = material.GetVectorArray("_RippleOrigins");
|
||||
|
||||
float currentTime = Time.timeSinceLevelLoad;
|
||||
var whyGodWhy = material.GetVector("_TIME");
|
||||
Console.WriteLine(whyGodWhy);
|
||||
float[] startedTimes = material.GetFloatArray("_RippleStartTimes");
|
||||
float[] startedRippleDurations = material.GetFloatArray("_RippleDurations");
|
||||
|
||||
float[] rippleAmplitudes = material.GetFloatArray("_RippleAmplitudes");
|
||||
float[] rippleFrequencies = material.GetFloatArray("_RippleFrequencies");
|
||||
float[] rippleDensities = material.GetFloatArray("_RippleDensities");
|
||||
float[] rippleBlends = material.GetFloatArray("_RippleBlends");
|
||||
float[] rippleRadii = material.GetFloatArray("_RippleRadii");
|
||||
|
||||
for (int i = 0; i < startedTimes.Length; ++i)
|
||||
@ -125,14 +122,12 @@ public class NimbleZoneDetection : MonoBehaviour
|
||||
rippleAmplitudes[i] = isOutwardsRipple ? rippleAmplitude : -rippleAmplitude;
|
||||
rippleFrequencies[i] = rippleFrequency;
|
||||
rippleDensities[i] = rippleDensity;
|
||||
rippleBlends[i] = rippleBlend;
|
||||
startedRippleDurations[i] = rippleDuration;
|
||||
rippleRadii[i] = rippleRadius;
|
||||
material.SetFloatArray("_RippleAmplitudes", rippleAmplitudes);
|
||||
material.SetFloatArray("_RippleFrequencies", rippleFrequencies);
|
||||
material.SetFloatArray("_RippleDensities", rippleDensities);
|
||||
material.SetFloatArray("_RippleAmplitudes", rippleAmplitudes);
|
||||
material.SetFloatArray("_RippleBlends", rippleBlends);
|
||||
material.SetFloatArray("_RippleDurations", startedRippleDurations);
|
||||
material.SetFloatArray("_RippleRadii", rippleRadii);
|
||||
break;
|
||||
@ -141,7 +136,7 @@ public class NimbleZoneDetection : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetShaderProperties()
|
||||
private void ResetRippleShaderProperties()
|
||||
{
|
||||
Vector4[] rippleOrigins = new Vector4[maxRippleAmount];
|
||||
float[] startedTimes = new float[maxRippleAmount];
|
||||
@ -150,7 +145,6 @@ public class NimbleZoneDetection : MonoBehaviour
|
||||
float[] rippleDensities = new float[maxRippleAmount];
|
||||
float[] rippleDurations = new float[maxRippleAmount];
|
||||
float[] rippleRadii = new float[maxRippleAmount];
|
||||
float[] rippleBlends = new float[maxRippleAmount];
|
||||
|
||||
// Initialize Ripple Shader Properties
|
||||
material.SetVectorArray("_RippleOrigins", rippleOrigins);
|
||||
@ -158,7 +152,6 @@ public class NimbleZoneDetection : MonoBehaviour
|
||||
material.SetFloatArray("_RippleAmplitudes", rippleAmplitudes);
|
||||
material.SetFloatArray("_RippleFrequencies", rippleFrequencies);
|
||||
material.SetFloatArray("_RippleDensities", rippleDensities);
|
||||
material.SetFloatArray("_RippleBlends", rippleBlends);
|
||||
material.SetFloatArray("_RippleDurations", rippleDurations);
|
||||
material.SetFloatArray("_RippleRadii", rippleRadii);
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
// (note, BaseMap, BumpMap and EmissionMap is being defined by the SurfaceInput.hlsl include)
|
||||
TEXTURE2D(_MetallicSpecGlossMap); SAMPLER(sampler_MetallicSpecGlossMap);
|
||||
TEXTURE2D(_OcclusionMap); SAMPLER(sampler_OcclusionMap);
|
||||
TEXTURE2D(_ClearCoatMap); SAMPLER(sampler_ClearCoatMap);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Functions
|
||||
@ -41,6 +42,23 @@ half4 SampleMetallicSpecGloss(float2 uv, half albedoAlpha) {
|
||||
return specGloss;
|
||||
}
|
||||
|
||||
// Returns clear coat parameters
|
||||
// .x/.r == mask
|
||||
// .y/.g == smoothness
|
||||
half2 SampleClearCoat(float2 uv)
|
||||
{
|
||||
#ifdef _CLEARCOAT
|
||||
half2 clearCoatMaskSmoothness = half2(_ClearCoatMask, _ClearCoatSmoothness);
|
||||
|
||||
#if defined(_CLEARCOATMAP)
|
||||
clearCoatMaskSmoothness *= SAMPLE_TEXTURE2D(_ClearCoatMap, sampler_ClearCoatMap, uv).rg;
|
||||
#endif
|
||||
|
||||
return clearCoatMaskSmoothness;
|
||||
#endif // _CLEARCOAT
|
||||
return half2(0.0, 1.0);
|
||||
}
|
||||
|
||||
half SampleOcclusion(float2 uv) {
|
||||
#ifdef _OCCLUSIONMAP
|
||||
#if defined(SHADER_API_GLES)
|
||||
@ -79,4 +97,8 @@ void InitializeSurfaceData(Varyings IN, out SurfaceData surfaceData){
|
||||
surfaceData.specular = half3(0.0h, 0.0h, 0.0h);
|
||||
#endif
|
||||
surfaceData.smoothness = specGloss.a;
|
||||
|
||||
half2 clearCoat = SampleClearCoat(IN.uv);
|
||||
surfaceData.clearCoatMask = clearCoat.r;
|
||||
surfaceData.clearCoatSmoothness = clearCoat.g;
|
||||
}
|
||||
@ -7,11 +7,17 @@ Roughly equivalent to the URP/Lit.shader (but Forward path only)
|
||||
https://github.com/Unity-Technologies/Graphics/blob/master/Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader
|
||||
*/
|
||||
|
||||
// This template from Cyanilux is under CC0 license.
|
||||
// I modified it to work with my URP Version: 14.0.8.
|
||||
// You can spawn and edit a ripple on the surface manually over the inspector
|
||||
// or use the properties accessible via script, to spawn and animate up to 5 waves simultaneously.
|
||||
|
||||
Shader "CustomShaders/GlossyPBRRipples" {
|
||||
Properties {
|
||||
// Sorry the inspector is a little messy, but I'd rather not rely on a Custom ShaderGUI
|
||||
// or the one used by the Lit/Shader, as then adding new properties won't show
|
||||
// Tried to organise it somewhat, with spacing to help separate related parts.
|
||||
|
||||
// In the regular URP shaders provided by unity, a custom shader GUI manages
|
||||
// these properties. This is hard to extend.
|
||||
// This here is a bit messier in the inspector, but easier to extend/modify.
|
||||
|
||||
[MainTexture] _BaseMap("Base Map (RGB) Smoothness / Alpha (A)", 2D) = "white" {}
|
||||
[MainColor] _BaseColor("Base Color", Color) = (1, 1, 1, 1)
|
||||
@ -23,17 +29,23 @@ Shader "CustomShaders/GlossyPBRRipples" {
|
||||
[Space(20)]
|
||||
[Toggle(_SPECULAR_SETUP)] _MetallicSpecToggle ("Workflow, Specular (if on), Metallic (if off)", Float) = 0
|
||||
[Toggle(_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A)] _SmoothnessSource ("Smoothness Source, Albedo Alpha (if on) vs Metallic (if off)", Float) = 0
|
||||
|
||||
_Metallic("Metallic", Range(0.0, 1.0)) = 0
|
||||
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
|
||||
_SpecColor("Specular Color", Color) = (0.5, 0.5, 0.5, 0.5)
|
||||
[Toggle(_METALLICSPECGLOSSMAP)] _MetallicSpecGlossMapToggle ("Use Metallic/Specular Gloss Map", Float) = 0
|
||||
_MetallicSpecGlossMap("Specular or Metallic Map", 2D) = "black" {}
|
||||
// Usually this is split into _SpecGlossMap and _MetallicGlossMap, but I find
|
||||
// that a bit annoying as I'm not using a custom ShaderGUI to show/hide them.
|
||||
[Toggle(_ENVIRONMENTREFLECTIONS_OFF)] _EnvironmentalReflections("Turn Environmental Reflections Off", Float) = 0
|
||||
[Toggle(_SPECULARHIGHLIGHTS_OFF)] _SpecularHighlights("Turn Specular Highlights Off", Float) = 0
|
||||
_SpecColor("Specular Color (only affects specular workflow)", Color) = (0.5, 0.5, 0.5, 0.5)
|
||||
|
||||
[Space(20)]
|
||||
[ToggleUI] _ClearCoat("Clear Coat", Float) = 0.0
|
||||
_ClearCoatMask("Clear Coat Mask", Float) = 0.0
|
||||
_ClearCoatSmoothness("Clear Coat Smoothness", Float) = 0.0
|
||||
// This acts as the Metallic- or Specular Gloss Map, depending on the toggle
|
||||
[Toggle(_METALLICSPECGLOSSMAP)] _MetallicSpecGlossMapToggle ("Use Metallic/Specular Gloss Map", Float) = 0
|
||||
_MetallicSpecGlossMap("Specular or Metallic Map", 2D) = "white" {}
|
||||
|
||||
[Space(20)]
|
||||
[Toggle(_CLEARCOAT)] _ClearCoat("Use Clear Coat", Float) = 0
|
||||
_ClearCoatMap("Clear Coat Map", 2D) = "white" {}
|
||||
_ClearCoatMask("Clear Coat Mask", Range(0.0, 1.0)) = 0.0
|
||||
_ClearCoatSmoothness("Clear Coat Smoothness", Range(0.0, 1.0)) = 1.0
|
||||
|
||||
[Space(20)]
|
||||
[Toggle(_NORMALMAP)] _NormalMapToggle ("Use Normal Map", Float) = 0
|
||||
@ -52,13 +64,13 @@ Shader "CustomShaders/GlossyPBRRipples" {
|
||||
[HDR] _EmissionColor("Emission Color", Color) = (0,0,0)
|
||||
[NoScaleOffset]_EmissionMap("Emission Map", 2D) = "white" {}
|
||||
|
||||
[Space(20)]
|
||||
[Toggle(_SPECULARHIGHLIGHTS_OFF)] _SpecularHighlights("Turn Specular Highlights Off", Float) = 0
|
||||
[Toggle(_ENVIRONMENTREFLECTIONS_OFF)] _EnvironmentalReflections("Turn Environmental Reflections Off", Float) = 0
|
||||
// These are inverted fom what the URP/Lit shader does which is a bit annoying.
|
||||
// They would usually be handled by the Lit ShaderGUI but I'm using Toggle instead,
|
||||
// which assumes the keyword is more of an "on" state.
|
||||
// Not including Detail maps in this template
|
||||
|
||||
// [Space(20)]
|
||||
// [Toggle(_)]
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
@ -84,6 +96,9 @@ Shader "CustomShaders/GlossyPBRRipples" {
|
||||
half _ClearCoatMask;
|
||||
half _ClearCoatSmoothness;
|
||||
CBUFFER_END
|
||||
|
||||
// This section has the definitions for spawning multiple ripples on the surface.
|
||||
// The maximum is hard set to five right now.
|
||||
half _ShaderTime;
|
||||
|
||||
half _SpikeEase(half x){
|
||||
@ -94,20 +109,19 @@ Shader "CustomShaders/GlossyPBRRipples" {
|
||||
return min(cos(3.14159265359 * x/2.0), 1 - abs(x));
|
||||
}
|
||||
|
||||
half _FadeRipple(half dist, half blend, half radius) {
|
||||
// create a radius
|
||||
return smoothstep(radius, 0, dist);
|
||||
half _TrapezoidEase(half x){
|
||||
return 1.0 - pow(max(0.0, abs(x) * 2.0 - 1.0), 1.0);
|
||||
}
|
||||
|
||||
half _ComputeRipple(half3 vert, half3 orig, half blend, half radius, half freq, half dens, half ampl, half start_time, half duration) {
|
||||
// calculate the intensity of the impact
|
||||
// Computes the displacement of the vertice for a 3D sine wave ripple
|
||||
half _ComputeRipple(half3 vert, half3 orig, half radius, half freq, half dens, half ampl, half start_time, half duration) {
|
||||
half dist = distance(vert, orig);
|
||||
half anim = smoothstep(start_time, start_time + duration, _ShaderTime);
|
||||
half i = sin((freq * anim - dist * dens)) * ampl * _TriangleEase(anim * 2 - 1);
|
||||
return i * _FadeRipple(dist, blend, radius);
|
||||
half i = sin((freq * anim - dist * dens)) * ampl * _TrapezoidEase(anim * 2 - 1);
|
||||
// Displacement gets lower as it approaches the set max distance
|
||||
return i * smoothstep(radius, 0, dist);
|
||||
}
|
||||
|
||||
|
||||
ENDHLSL
|
||||
|
||||
Pass {
|
||||
@ -121,12 +135,11 @@ Shader "CustomShaders/GlossyPBRRipples" {
|
||||
|
||||
HLSLPROGRAM
|
||||
// Ripple Properties
|
||||
|
||||
// These can't be set in Editor but are read/writeable from script
|
||||
half3 _RippleOrigins[5];
|
||||
half _RippleFrequencies[5];
|
||||
half _RippleDensities[5];
|
||||
half _RippleAmplitudes[5];
|
||||
half _RippleBlends[5];
|
||||
half _RippleRadii[5];
|
||||
half _RippleStartTimes[5];
|
||||
half _RippleDurations[5];
|
||||
@ -152,7 +165,7 @@ Shader "CustomShaders/GlossyPBRRipples" {
|
||||
// Note, for this template not supporting parallax/height mapping or detail maps
|
||||
|
||||
// v10+ only, URP/ComplexLit shader
|
||||
#pragma shader_feature_local _ CLEARCOAT
|
||||
#pragma shader_feature_local_fragment _ _CLEARCOAT _CLEARCOATMAP
|
||||
|
||||
#pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
|
||||
#pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
|
||||
@ -246,7 +259,6 @@ Shader "CustomShaders/GlossyPBRRipples" {
|
||||
for(int i = 0; i < 5; i++)
|
||||
ripple_displacement += _ComputeRipple(IN.positionOS.xyz,
|
||||
_RippleOrigins[i],
|
||||
_RippleBlends[i],
|
||||
_RippleRadii[i],
|
||||
_RippleFrequencies[i],
|
||||
_RippleDensities[i],
|
||||
@ -255,6 +267,8 @@ Shader "CustomShaders/GlossyPBRRipples" {
|
||||
_RippleDurations[i]);
|
||||
IN.positionOS.xyz += IN.normalOS * ripple_displacement;
|
||||
|
||||
// if _TestRipple
|
||||
|
||||
VertexPositionInputs positionInputs = GetVertexPositionInputs(IN.positionOS.xyz);
|
||||
#ifdef _NORMALMAP
|
||||
VertexNormalInputs normalInputs = GetVertexNormalInputs(IN.normalOS.xyz, IN.tangentOS);
|
||||
@ -307,8 +321,6 @@ Shader "CustomShaders/GlossyPBRRipples" {
|
||||
// Setup SurfaceData
|
||||
SurfaceData surfaceData;
|
||||
InitializeSurfaceData(IN, surfaceData);
|
||||
surfaceData.clearCoatMask = _ClearCoatMask;
|
||||
surfaceData.clearCoatSmoothness = _ClearCoatSmoothness;
|
||||
|
||||
// Setup InputData
|
||||
InputData inputData;
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a4dd0cc27ff19047afabeee3eb7f78f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,121 +0,0 @@
|
||||
Creative Commons Legal Code
|
||||
|
||||
CC0 1.0 Universal
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
||||
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
||||
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
||||
HEREUNDER.
|
||||
|
||||
Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer
|
||||
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||
and subsequent owner(s) (each and all, an "owner") of an original work of
|
||||
authorship and/or a database (each, a "Work").
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for
|
||||
the purpose of contributing to a commons of creative, cultural and
|
||||
scientific works ("Commons") that the public can reliably and without fear
|
||||
of later claims of infringement build upon, modify, incorporate in other
|
||||
works, reuse and redistribute as freely as possible in any form whatsoever
|
||||
and for any purposes, including without limitation commercial purposes.
|
||||
These owners may contribute to the Commons to promote the ideal of a free
|
||||
culture and the further production of creative, cultural and scientific
|
||||
works, or to gain reputation or greater distribution for their Work in
|
||||
part through the use and efforts of others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any
|
||||
expectation of additional consideration or compensation, the person
|
||||
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
||||
is an owner of Copyright and Related Rights in the Work, voluntarily
|
||||
elects to apply CC0 to the Work and publicly distribute the Work under its
|
||||
terms, with knowledge of his or her Copyright and Related Rights in the
|
||||
Work and the meaning and intended legal effect of CC0 on those rights.
|
||||
|
||||
1. Copyright and Related Rights. A Work made available under CC0 may be
|
||||
protected by copyright and related or neighboring rights ("Copyright and
|
||||
Related Rights"). Copyright and Related Rights include, but are not
|
||||
limited to, the following:
|
||||
|
||||
i. the right to reproduce, adapt, distribute, perform, display,
|
||||
communicate, and translate a Work;
|
||||
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||
iii. publicity and privacy rights pertaining to a person's image or
|
||||
likeness depicted in a Work;
|
||||
iv. rights protecting against unfair competition in regards to a Work,
|
||||
subject to the limitations in paragraph 4(a), below;
|
||||
v. rights protecting the extraction, dissemination, use and reuse of data
|
||||
in a Work;
|
||||
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||
European Parliament and of the Council of 11 March 1996 on the legal
|
||||
protection of databases, and under any national implementation
|
||||
thereof, including any amended or successor version of such
|
||||
directive); and
|
||||
vii. other similar, equivalent or corresponding rights throughout the
|
||||
world based on applicable law or treaty, and any national
|
||||
implementations thereof.
|
||||
|
||||
2. Waiver. To the greatest extent permitted by, but not in contravention
|
||||
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
||||
irrevocably and unconditionally waives, abandons, and surrenders all of
|
||||
Affirmer's Copyright and Related Rights and associated claims and causes
|
||||
of action, whether now known or unknown (including existing as well as
|
||||
future claims and causes of action), in the Work (i) in all territories
|
||||
worldwide, (ii) for the maximum duration provided by applicable law or
|
||||
treaty (including future time extensions), (iii) in any current or future
|
||||
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
||||
including without limitation commercial, advertising or promotional
|
||||
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
||||
member of the public at large and to the detriment of Affirmer's heirs and
|
||||
successors, fully intending that such Waiver shall not be subject to
|
||||
revocation, rescission, cancellation, termination, or any other legal or
|
||||
equitable action to disrupt the quiet enjoyment of the Work by the public
|
||||
as contemplated by Affirmer's express Statement of Purpose.
|
||||
|
||||
3. Public License Fallback. Should any part of the Waiver for any reason
|
||||
be judged legally invalid or ineffective under applicable law, then the
|
||||
Waiver shall be preserved to the maximum extent permitted taking into
|
||||
account Affirmer's express Statement of Purpose. In addition, to the
|
||||
extent the Waiver is so judged Affirmer hereby grants to each affected
|
||||
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
||||
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
||||
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
||||
maximum duration provided by applicable law or treaty (including future
|
||||
time extensions), (iii) in any current or future medium and for any number
|
||||
of copies, and (iv) for any purpose whatsoever, including without
|
||||
limitation commercial, advertising or promotional purposes (the
|
||||
"License"). The License shall be deemed effective as of the date CC0 was
|
||||
applied by Affirmer to the Work. Should any part of the License for any
|
||||
reason be judged legally invalid or ineffective under applicable law, such
|
||||
partial invalidity or ineffectiveness shall not invalidate the remainder
|
||||
of the License, and in such case Affirmer hereby affirms that he or she
|
||||
will not (i) exercise any of his or her remaining Copyright and Related
|
||||
Rights in the Work or (ii) assert any associated claims and causes of
|
||||
action with respect to the Work, in either case contrary to Affirmer's
|
||||
express Statement of Purpose.
|
||||
|
||||
4. Limitations and Disclaimers.
|
||||
|
||||
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||
surrendered, licensed or otherwise affected by this document.
|
||||
b. Affirmer offers the Work as-is and makes no representations or
|
||||
warranties of any kind concerning the Work, express, implied,
|
||||
statutory or otherwise, including without limitation warranties of
|
||||
title, merchantability, fitness for a particular purpose, non
|
||||
infringement, or the absence of latent or other defects, accuracy, or
|
||||
the present or absence of errors, whether or not discoverable, all to
|
||||
the greatest extent permissible under applicable law.
|
||||
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||
that may apply to the Work or any use thereof, including without
|
||||
limitation any person's Copyright and Related Rights in the Work.
|
||||
Further, Affirmer disclaims responsibility for obtaining any necessary
|
||||
consents, permissions or other rights required for any use of the
|
||||
Work.
|
||||
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||
party to this document and has no duty or obligation with respect to
|
||||
this CC0 or use of the Work.
|
||||
@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3682d2f9dedb7674aadee68b5d47cbbe
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,93 +0,0 @@
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Includes
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Functions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#if SHADER_LIBRARY_VERSION_MAJOR < 9
|
||||
// These functions were added in URP v9.x versions, if we want to support URP versions before, we need to handle it
|
||||
// If you're in v10, should be safe to remove this if you don't care about supporting prior versions.
|
||||
// (Note, also using GetWorldSpaceViewDir in Vertex Shader)
|
||||
|
||||
// Computes the world space view direction (pointing towards the viewer).
|
||||
float3 GetWorldSpaceViewDir(float3 positionWS) {
|
||||
if (unity_OrthoParams.w == 0) {
|
||||
// Perspective
|
||||
return _WorldSpaceCameraPos - positionWS;
|
||||
} else {
|
||||
// Orthographic
|
||||
float4x4 viewMat = GetWorldToViewMatrix();
|
||||
return viewMat[2].xyz;
|
||||
}
|
||||
}
|
||||
|
||||
half3 GetWorldSpaceNormalizeViewDir(float3 positionWS) {
|
||||
float3 viewDir = GetWorldSpaceViewDir(positionWS);
|
||||
if (unity_OrthoParams.w == 0) {
|
||||
// Perspective
|
||||
return half3(normalize(viewDir));
|
||||
} else {
|
||||
// Orthographic
|
||||
return half3(viewDir);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// InputData
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void InitializeInputData(Varyings input, half3 normalTS, out InputData inputData) {
|
||||
inputData = (InputData)0; // avoids "not completely initalized" errors
|
||||
|
||||
inputData.positionWS = input.positionWS;
|
||||
|
||||
#ifdef _NORMALMAP
|
||||
half3 viewDirWS = half3(input.normalWS.w, input.tangentWS.w, input.bitangentWS.w); // viewDir has been stored in w components of these in vertex shader
|
||||
inputData.normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz));
|
||||
#else
|
||||
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(inputData.positionWS);
|
||||
inputData.normalWS = input.normalWS;
|
||||
#endif
|
||||
|
||||
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
|
||||
|
||||
viewDirWS = SafeNormalize(viewDirWS);
|
||||
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
|
||||
|
||||
// Fog
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
inputData.fogCoord = input.fogFactorAndVertexLight.x;
|
||||
inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
|
||||
#else
|
||||
inputData.fogCoord = input.fogFactor;
|
||||
inputData.vertexLighting = half3(0, 0, 0);
|
||||
#endif
|
||||
|
||||
/* in v11/v12?, could use :
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
inputData.fogCoord = InitializeInputDataFog(float4(inputData.positionWS, 1.0), input.fogFactorAndVertexLight.x);
|
||||
inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
|
||||
#else
|
||||
inputData.fogCoord = InitializeInputDataFog(float4(inputData.positionWS, 1.0), input.fogFactor);
|
||||
inputData.vertexLighting = half3(0, 0, 0);
|
||||
#endif
|
||||
*/
|
||||
|
||||
inputData.bakedGI = SAMPLE_GI(input.lightmapUV, input.vertexSH, inputData.normalWS);
|
||||
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS);
|
||||
inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV);
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c21821e52a1ca7448b8ebe83a5196544
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,81 +0,0 @@
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Includes
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Textures, Samplers & Global Properties
|
||||
// ---------------------------------------------------------------------------
|
||||
// (note, BaseMap, BumpMap and EmissionMap is being defined by the SurfaceInput.hlsl include)
|
||||
TEXTURE2D(_MetallicSpecGlossMap); SAMPLER(sampler_MetallicSpecGlossMap);
|
||||
TEXTURE2D(_OcclusionMap); SAMPLER(sampler_OcclusionMap);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Functions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
half4 SampleMetallicSpecGloss(float2 uv, half albedoAlpha) {
|
||||
half4 specGloss;
|
||||
#ifdef _METALLICSPECGLOSSMAP
|
||||
specGloss = SAMPLE_TEXTURE2D(_MetallicSpecGlossMap, sampler_MetallicSpecGlossMap, uv);
|
||||
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
specGloss.a = albedoAlpha * _Smoothness;
|
||||
#else
|
||||
specGloss.a *= _Smoothness;
|
||||
#endif
|
||||
#else // _METALLICSPECGLOSSMAP
|
||||
#if _SPECULAR_SETUP
|
||||
specGloss.rgb = _SpecColor.rgb;
|
||||
#else
|
||||
specGloss.rgb = _Metallic.rrr;
|
||||
#endif
|
||||
|
||||
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
specGloss.a = albedoAlpha * _Smoothness;
|
||||
#else
|
||||
specGloss.a = _Smoothness;
|
||||
#endif
|
||||
#endif
|
||||
return specGloss;
|
||||
}
|
||||
|
||||
half SampleOcclusion(float2 uv) {
|
||||
#ifdef _OCCLUSIONMAP
|
||||
#if defined(SHADER_API_GLES)
|
||||
return SAMPLE_TEXTURE2D(_OcclusionMap, sampler_OcclusionMap, uv).g;
|
||||
#else
|
||||
half occ = SAMPLE_TEXTURE2D(_OcclusionMap, sampler_OcclusionMap, uv).g;
|
||||
return LerpWhiteTo(occ, _OcclusionStrength);
|
||||
#endif
|
||||
#else
|
||||
return 1.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SurfaceData
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void InitializeSurfaceData(Varyings IN, out SurfaceData surfaceData){
|
||||
surfaceData = (SurfaceData)0; // avoids "not completely initalized" errors
|
||||
|
||||
half4 albedoAlpha = SampleAlbedoAlpha(IN.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap));
|
||||
surfaceData.alpha = Alpha(albedoAlpha.a, _BaseColor, _Cutoff);
|
||||
surfaceData.albedo = albedoAlpha.rgb * _BaseColor.rgb * IN.color.rgb;
|
||||
|
||||
surfaceData.normalTS = SampleNormal(IN.uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale);
|
||||
surfaceData.emission = SampleEmission(IN.uv, _EmissionColor.rgb, TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap));
|
||||
surfaceData.occlusion = SampleOcclusion(IN.uv);
|
||||
|
||||
half4 specGloss = SampleMetallicSpecGloss(IN.uv, albedoAlpha.a);
|
||||
#if _SPECULAR_SETUP
|
||||
surfaceData.metallic = 1.0h;
|
||||
surfaceData.specular = specGloss.rgb;
|
||||
#else
|
||||
surfaceData.metallic = specGloss.r;
|
||||
surfaceData.specular = half3(0.0h, 0.0h, 0.0h);
|
||||
#endif
|
||||
surfaceData.smoothness = specGloss.a;
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af71b1a3a2d26b645acd03a0dd56a301
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,297 +0,0 @@
|
||||
// Example Shader for Universal RP
|
||||
// Written by @Cyanilux
|
||||
// https://www.cyanilux.com/tutorials/urp-shader-code
|
||||
|
||||
/*
|
||||
This example reacts to Main Directional Light & Ambient/Baked light.
|
||||
Ignores additional lights.
|
||||
Diffuse/Lambert shading model.
|
||||
No specular/smoothness/metallic/etc.
|
||||
*/
|
||||
|
||||
Shader "Cyanilux/URPTemplates/DiffuseLitShaderExample" {
|
||||
Properties {
|
||||
_BaseMap ("Example Texture", 2D) = "white" {}
|
||||
_BaseColor ("Example Colour", Color) = (0, 0.66, 0.73, 1)
|
||||
[Toggle(_ALPHATEST_ON)] _AlphaTestToggle ("Alpha Clipping", Float) = 0
|
||||
_Cutoff ("Alpha Cutoff", Float) = 0.5
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderPipeline"="UniversalPipeline"
|
||||
"RenderType"="Opaque"
|
||||
"Queue"="Geometry"
|
||||
}
|
||||
|
||||
HLSLINCLUDE
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
float4 _BaseColor;
|
||||
float _Cutoff;
|
||||
CBUFFER_END
|
||||
ENDHLSL
|
||||
|
||||
Pass {
|
||||
Name "ForwardLit"
|
||||
Tags { "LightMode"="UniversalForward" }
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex LitPassVertex
|
||||
#pragma fragment LitPassFragment
|
||||
|
||||
// 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_fragment _SPECULARHIGHLIGHTS_OFF
|
||||
#pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
|
||||
#pragma shader_feature_local_fragment _SPECULAR_SETUP
|
||||
#pragma shader_feature_local _RECEIVE_SHADOWS_OFF
|
||||
|
||||
// URP Keywords
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
|
||||
// Note, v11 changes this to :
|
||||
// #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
|
||||
|
||||
#pragma multi_compile _ _SHADOWS_SOFT
|
||||
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
||||
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING // v10+ only, renamed from "_MIXED_LIGHTING_SUBTRACTIVE"
|
||||
#pragma multi_compile _ SHADOWS_SHADOWMASK // v10+ only
|
||||
|
||||
// Unity Keywords
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile_fog
|
||||
|
||||
// GPU Instancing (not supported)
|
||||
//#pragma multi_compile_instancing
|
||||
|
||||
// Includes
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
// Structs
|
||||
struct Attributes {
|
||||
float4 positionOS : POSITION;
|
||||
float4 normalOS : NORMAL;
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 lightmapUV : TEXCOORD1;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct Varyings {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 1);
|
||||
float3 normalWS : TEXCOORD2;
|
||||
float3 positionWS : TEXCOORD3;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
// Textures, Samplers & Global Properties
|
||||
TEXTURE2D(_BaseMap);
|
||||
SAMPLER(sampler_BaseMap);
|
||||
|
||||
// Vertex Shader
|
||||
Varyings LitPassVertex(Attributes IN) {
|
||||
Varyings OUT;
|
||||
|
||||
VertexPositionInputs positionInputs = GetVertexPositionInputs(IN.positionOS.xyz);
|
||||
OUT.positionCS = positionInputs.positionCS;
|
||||
OUT.positionWS = positionInputs.positionWS;
|
||||
|
||||
VertexNormalInputs normalInputs = GetVertexNormalInputs(IN.normalOS.xyz);
|
||||
OUT.normalWS = normalInputs.normalWS;
|
||||
|
||||
OUTPUT_LIGHTMAP_UV(IN.lightmapUV, unity_LightmapST, OUT.lightmapUV);
|
||||
OUTPUT_SH(OUT.normalWS.xyz, OUT.vertexSH);
|
||||
|
||||
OUT.uv = TRANSFORM_TEX(IN.uv, _BaseMap);
|
||||
OUT.color = IN.color;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
// Fragment Shader
|
||||
half4 LitPassFragment(Varyings IN) : SV_Target {
|
||||
half4 baseMap = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, IN.uv);
|
||||
|
||||
#ifdef _ALPHATEST_ON
|
||||
// Alpha Clipping
|
||||
clip(baseMap.a - _Cutoff);
|
||||
#endif
|
||||
|
||||
// Get Baked GI
|
||||
half3 bakedGI = SAMPLE_GI(IN.lightmapUV, IN.vertexSH, IN.normalWS);
|
||||
|
||||
// Main Light & Shadows
|
||||
float4 shadowCoord = TransformWorldToShadowCoord(IN.positionWS.xyz);
|
||||
Light mainLight = GetMainLight(shadowCoord);
|
||||
half3 attenuatedLightColor = mainLight.color * (mainLight.distanceAttenuation * mainLight.shadowAttenuation);
|
||||
|
||||
// Mix Realtime & Baked (if LIGHTMAP_SHADOW_MIXING / _MIXED_LIGHTING_SUBTRACTIVE is enabled)
|
||||
MixRealtimeAndBakedGI(mainLight, IN.normalWS, bakedGI);
|
||||
|
||||
// Diffuse
|
||||
half3 shading = bakedGI + LightingLambert(attenuatedLightColor, mainLight.direction, IN.normalWS);
|
||||
half4 color = baseMap * _BaseColor * IN.color;
|
||||
return half4(color.rgb * shading, color.a);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// UsePass "Universal Render Pipeline/Lit/ShadowCaster"
|
||||
// UsePass "Universal Render Pipeline/Lit/DepthOnly"
|
||||
// Would be nice if we could just use the passes from existing shaders,
|
||||
// However this breaks SRP Batcher compatibility. Instead, we should define them :
|
||||
|
||||
// ShadowCaster, for casting shadows
|
||||
Pass {
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#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
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
// Universal Pipeline Keywords
|
||||
// (v11+) This is used during shadow map generation to differentiate between directional and punctual (point/spot) light shadows, as they use different formulas to apply Normal Bias
|
||||
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
|
||||
|
||||
// Note if we do any vertex displacement, we'll need to change the vertex function. e.g. :
|
||||
/*
|
||||
#pragma vertex DisplacedShadowPassVertex (instead of ShadowPassVertex above)
|
||||
|
||||
Varyings DisplacedShadowPassVertex(Attributes input) {
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
|
||||
// Example Displacement
|
||||
input.positionOS += float4(0, _SinTime.y, 0, 0);
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = GetShadowPositionHClip(input);
|
||||
return output;
|
||||
}
|
||||
*/
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// DepthOnly, used for Camera Depth Texture (if cannot copy depth buffer instead, and the DepthNormals below isn't used)
|
||||
Pass {
|
||||
Name "DepthOnly"
|
||||
Tags { "LightMode"="DepthOnly" }
|
||||
|
||||
ColorMask 0
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex DepthOnlyVertex
|
||||
#pragma fragment DepthOnlyFragment
|
||||
|
||||
// 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
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
|
||||
|
||||
// Note if we do any vertex displacement, we'll need to change the vertex function. e.g. :
|
||||
/*
|
||||
#pragma vertex DisplacedDepthOnlyVertex (instead of DepthOnlyVertex above)
|
||||
|
||||
Varyings DisplacedDepthOnlyVertex(Attributes input) {
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
// Example Displacement
|
||||
input.positionOS += float4(0, _SinTime.y, 0, 0);
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = TransformObjectToHClip(input.position.xyz);
|
||||
return output;
|
||||
}
|
||||
*/
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// DepthNormals, used for SSAO & other custom renderer features that request it
|
||||
Pass {
|
||||
Name "DepthNormals"
|
||||
Tags { "LightMode"="DepthNormals" }
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex DepthNormalsVertex
|
||||
#pragma fragment DepthNormalsFragment
|
||||
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl"
|
||||
|
||||
// Note if we do any vertex displacement, we'll need to change the vertex function. e.g. :
|
||||
/*
|
||||
#pragma vertex DisplacedDepthNormalsVertex (instead of DepthNormalsVertex above)
|
||||
|
||||
Varyings DisplacedDepthNormalsVertex(Attributes input) {
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
// Example Displacement
|
||||
input.positionOS += float4(0, _SinTime.y, 0, 0);
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = TransformObjectToHClip(input.position.xyz);
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normal, input.tangentOS);
|
||||
output.normalWS = NormalizeNormalPerVertex(normalInput.normalWS);
|
||||
return output;
|
||||
}
|
||||
*/
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b88236c1ecbe9243b3318d347059c39
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,581 +0,0 @@
|
||||
// Example Shader for Universal RP
|
||||
// Written by @Cyanilux
|
||||
// https://www.cyanilux.com/tutorials/urp-shader-code
|
||||
|
||||
/*
|
||||
Roughly equivalent to the URP/Lit.shader (but Forward path only)
|
||||
https://github.com/Unity-Technologies/Graphics/blob/master/Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader
|
||||
*/
|
||||
|
||||
Shader "Cyanilux/URPTemplates/PBRLitShaderExample" {
|
||||
Properties {
|
||||
// Sorry the inspector is a little messy, but I'd rather not rely on a Custom ShaderGUI
|
||||
// or the one used by the Lit/Shader, as then adding new properties won't show
|
||||
// Tried to organise it somewhat, with spacing to help separate related parts.
|
||||
|
||||
[MainTexture] _BaseMap("Base Map (RGB) Smoothness / Alpha (A)", 2D) = "white" {}
|
||||
[MainColor] _BaseColor("Base Color", Color) = (1, 1, 1, 1)
|
||||
|
||||
[Space(20)]
|
||||
[Toggle(_ALPHATEST_ON)] _AlphaTestToggle ("Alpha Clipping", Float) = 0
|
||||
_Cutoff ("Alpha Cutoff", Float) = 0.5
|
||||
|
||||
[Space(20)]
|
||||
[Toggle(_SPECULAR_SETUP)] _MetallicSpecToggle ("Workflow, Specular (if on), Metallic (if off)", Float) = 0
|
||||
[Toggle(_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A)] _SmoothnessSource ("Smoothness Source, Albedo Alpha (if on) vs Metallic (if off)", Float) = 0
|
||||
_Metallic("Metallic", Range(0.0, 1.0)) = 0
|
||||
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
|
||||
_SpecColor("Specular Color", Color) = (0.5, 0.5, 0.5, 0.5)
|
||||
[Toggle(_METALLICSPECGLOSSMAP)] _MetallicSpecGlossMapToggle ("Use Metallic/Specular Gloss Map", Float) = 0
|
||||
_MetallicSpecGlossMap("Specular or Metallic Map", 2D) = "black" {}
|
||||
// Usually this is split into _SpecGlossMap and _MetallicGlossMap, but I find
|
||||
// that a bit annoying as I'm not using a custom ShaderGUI to show/hide them.
|
||||
|
||||
[Space(20)]
|
||||
[Toggle(_NORMALMAP)] _NormalMapToggle ("Use Normal Map", Float) = 0
|
||||
[NoScaleOffset] _BumpMap("Normal Map", 2D) = "bump" {}
|
||||
_BumpScale("Bump Scale", Float) = 1
|
||||
|
||||
// Not including Height (parallax) map in this example/template
|
||||
|
||||
[Space(20)]
|
||||
[Toggle(_OCCLUSIONMAP)] _OcclusionToggle ("Use Occlusion Map", Float) = 0
|
||||
[NoScaleOffset] _OcclusionMap("Occlusion Map", 2D) = "bump" {}
|
||||
_OcclusionStrength("Occlusion Strength", Range(0.0, 1.0)) = 1.0
|
||||
|
||||
[Space(20)]
|
||||
[Toggle(_EMISSION)] _Emission ("Emission", Float) = 0
|
||||
[HDR] _EmissionColor("Emission Color", Color) = (0,0,0)
|
||||
[NoScaleOffset]_EmissionMap("Emission Map", 2D) = "black" {}
|
||||
|
||||
[Space(20)]
|
||||
[Toggle(_SPECULARHIGHLIGHTS_OFF)] _SpecularHighlights("Turn Specular Highlights Off", Float) = 0
|
||||
[Toggle(_ENVIRONMENTREFLECTIONS_OFF)] _EnvironmentalReflections("Turn Environmental Reflections Off", Float) = 0
|
||||
// These are inverted fom what the URP/Lit shader does which is a bit annoying.
|
||||
// They would usually be handled by the Lit ShaderGUI but I'm using Toggle instead,
|
||||
// which assumes the keyword is more of an "on" state.
|
||||
|
||||
// Not including Detail maps in this template
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderPipeline"="UniversalPipeline"
|
||||
"RenderType"="Opaque"
|
||||
"Queue"="Geometry"
|
||||
}
|
||||
|
||||
HLSLINCLUDE
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
float4 _BaseColor;
|
||||
float4 _EmissionColor;
|
||||
float4 _SpecColor;
|
||||
float _Metallic;
|
||||
float _Smoothness;
|
||||
float _OcclusionStrength;
|
||||
float _Cutoff;
|
||||
float _BumpScale;
|
||||
CBUFFER_END
|
||||
ENDHLSL
|
||||
|
||||
Pass {
|
||||
Name "ForwardLit"
|
||||
Tags { "LightMode"="UniversalForward" }
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex LitPassVertex
|
||||
#pragma fragment LitPassFragment
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Keywords
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// 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 // v10+ only
|
||||
//#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED // v10+ only
|
||||
// Note, for this template not supporting parallax/height mapping or detail maps
|
||||
|
||||
//#pragma shader_feature_local _ _CLEARCOAT _CLEARCOATMAP // v10+ only, URP/ComplexLit shader
|
||||
|
||||
#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
|
||||
|
||||
// URP Keywords
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
|
||||
// Note, v11 changes these to :
|
||||
// #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_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT
|
||||
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION // v10+ only (for SSAO support)
|
||||
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING // v10+ only, renamed from "_MIXED_LIGHTING_SUBTRACTIVE"
|
||||
#pragma multi_compile _ SHADOWS_SHADOWMASK // v10+ only
|
||||
|
||||
// Unity Keywords
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile_fog
|
||||
|
||||
// GPU Instancing (not supported)
|
||||
//#pragma multi_compile_instancing
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Structs
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
struct Attributes {
|
||||
float4 positionOS : POSITION;
|
||||
#ifdef _NORMALMAP
|
||||
float4 tangentOS : TANGENT;
|
||||
#endif
|
||||
float4 normalOS : NORMAL;
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 lightmapUV : TEXCOORD1;
|
||||
float4 color : COLOR;
|
||||
//UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 1);
|
||||
float3 positionWS : TEXCOORD2;
|
||||
|
||||
#ifdef _NORMALMAP
|
||||
half4 normalWS : TEXCOORD3; // xyz: normal, w: viewDir.x
|
||||
half4 tangentWS : TEXCOORD4; // xyz: tangent, w: viewDir.y
|
||||
half4 bitangentWS : TEXCOORD5; // xyz: bitangent, w: viewDir.z
|
||||
#else
|
||||
half3 normalWS : TEXCOORD3;
|
||||
#endif
|
||||
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
half4 fogFactorAndVertexLight : TEXCOORD6; // x: fogFactor, yzw: vertex light
|
||||
#else
|
||||
half fogFactor : TEXCOORD6;
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
float4 shadowCoord : TEXCOORD7;
|
||||
#endif
|
||||
|
||||
float4 color : COLOR;
|
||||
//UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
//UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
#include "PBRSurface.hlsl"
|
||||
#include "PBRInput.hlsl"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Vertex Shader
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Varyings LitPassVertex(Attributes IN) {
|
||||
Varyings OUT;
|
||||
|
||||
//UNITY_SETUP_INSTANCE_ID(IN);
|
||||
//UNITY_TRANSFER_INSTANCE_ID(IN, OUT);
|
||||
//UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
||||
|
||||
VertexPositionInputs positionInputs = GetVertexPositionInputs(IN.positionOS.xyz);
|
||||
#ifdef _NORMALMAP
|
||||
VertexNormalInputs normalInputs = GetVertexNormalInputs(IN.normalOS.xyz, IN.tangentOS);
|
||||
#else
|
||||
VertexNormalInputs normalInputs = GetVertexNormalInputs(IN.normalOS.xyz);
|
||||
#endif
|
||||
|
||||
OUT.positionCS = positionInputs.positionCS;
|
||||
OUT.positionWS = positionInputs.positionWS;
|
||||
|
||||
half3 viewDirWS = GetWorldSpaceViewDir(positionInputs.positionWS);
|
||||
half3 vertexLight = VertexLighting(positionInputs.positionWS, normalInputs.normalWS);
|
||||
half fogFactor = ComputeFogFactor(positionInputs.positionCS.z);
|
||||
|
||||
#ifdef _NORMALMAP
|
||||
OUT.normalWS = half4(normalInputs.normalWS, viewDirWS.x);
|
||||
OUT.tangentWS = half4(normalInputs.tangentWS, viewDirWS.y);
|
||||
OUT.bitangentWS = half4(normalInputs.bitangentWS, viewDirWS.z);
|
||||
#else
|
||||
OUT.normalWS = NormalizeNormalPerVertex(normalInputs.normalWS);
|
||||
//OUT.viewDirWS = viewDirWS;
|
||||
#endif
|
||||
|
||||
OUTPUT_LIGHTMAP_UV(IN.lightmapUV, unity_LightmapST, OUT.lightmapUV);
|
||||
OUTPUT_SH(OUT.normalWS.xyz, OUT.vertexSH);
|
||||
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
OUT.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
|
||||
#else
|
||||
OUT.fogFactor = fogFactor;
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
OUT.shadowCoord = GetShadowCoord(positionInputs);
|
||||
#endif
|
||||
|
||||
OUT.uv = TRANSFORM_TEX(IN.uv, _BaseMap);
|
||||
OUT.color = IN.color;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Fragment Shader
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
half4 LitPassFragment(Varyings IN) : SV_Target {
|
||||
//UNITY_SETUP_INSTANCE_ID(IN);
|
||||
//UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);
|
||||
|
||||
// Setup SurfaceData
|
||||
SurfaceData surfaceData;
|
||||
InitializeSurfaceData(IN, surfaceData);
|
||||
|
||||
// Setup InputData
|
||||
InputData inputData;
|
||||
InitializeInputData(IN, surfaceData.normalTS, inputData);
|
||||
|
||||
// Simple Lighting (Lambert & BlinnPhong)
|
||||
half4 color = UniversalFragmentPBR(inputData, surfaceData);
|
||||
// See Lighting.hlsl to see how this is implemented.
|
||||
// https://github.com/Unity-Technologies/Graphics/blob/master/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl
|
||||
|
||||
// Fog
|
||||
color.rgb = MixFog(color.rgb, inputData.fogCoord);
|
||||
//color.a = OutputAlpha(color.a, _Surface);
|
||||
return color;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// UsePass "Universal Render Pipeline/Lit/ShadowCaster"
|
||||
// UsePass "Universal Render Pipeline/Lit/DepthOnly"
|
||||
// Would be nice if we could just use the passes from existing shaders,
|
||||
// However this breaks SRP Batcher compatibility. Instead, we should define them :
|
||||
|
||||
// ShadowCaster, for casting shadows
|
||||
Pass {
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#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
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
// Universal Pipeline Keywords
|
||||
// (v11+) This is used during shadow map generation to differentiate between directional and punctual (point/spot) light shadows, as they use different formulas to apply Normal Bias
|
||||
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
|
||||
|
||||
// Note if we do any vertex displacement, we'll need to change the vertex function. e.g. :
|
||||
/*
|
||||
#pragma vertex DisplacedShadowPassVertex (instead of ShadowPassVertex above)
|
||||
|
||||
Varyings DisplacedShadowPassVertex(Attributes input) {
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
|
||||
// Example Displacement
|
||||
input.positionOS += float4(0, _SinTime.y, 0, 0);
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = GetShadowPositionHClip(input);
|
||||
return output;
|
||||
}
|
||||
*/
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// DepthOnly, used for Camera Depth Texture (if cannot copy depth buffer instead, and the DepthNormals below isn't used)
|
||||
Pass {
|
||||
Name "DepthOnly"
|
||||
Tags { "LightMode"="DepthOnly" }
|
||||
|
||||
ColorMask 0
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex DepthOnlyVertex
|
||||
#pragma fragment DepthOnlyFragment
|
||||
|
||||
// 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
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
|
||||
|
||||
// Note if we do any vertex displacement, we'll need to change the vertex function. e.g. :
|
||||
/*
|
||||
#pragma vertex DisplacedDepthOnlyVertex (instead of DepthOnlyVertex above)
|
||||
|
||||
Varyings DisplacedDepthOnlyVertex(Attributes input) {
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
// Example Displacement
|
||||
input.positionOS += float4(0, _SinTime.y, 0, 0);
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = TransformObjectToHClip(input.position.xyz);
|
||||
return output;
|
||||
}
|
||||
*/
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// DepthNormals, used for SSAO & other custom renderer features that request it
|
||||
Pass {
|
||||
Name "DepthNormals"
|
||||
Tags { "LightMode"="DepthNormals" }
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex DepthNormalsVertex
|
||||
#pragma fragment DepthNormalsFragment
|
||||
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl"
|
||||
|
||||
// Note if we do any vertex displacement, we'll need to change the vertex function. e.g. :
|
||||
/*
|
||||
#pragma vertex DisplacedDepthNormalsVertex (instead of DepthNormalsVertex above)
|
||||
|
||||
Varyings DisplacedDepthNormalsVertex(Attributes input) {
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
// Example Displacement
|
||||
input.positionOS += float4(0, _SinTime.y, 0, 0);
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = TransformObjectToHClip(input.position.xyz);
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normal, input.tangentOS);
|
||||
output.normalWS = NormalizeNormalPerVertex(normalInput.normalWS);
|
||||
return output;
|
||||
}
|
||||
*/
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
// Note, while v10 versions ignore this, if you want normal mapping to affect the _CameraNormalsTexture, we could edit the DepthNormals pass
|
||||
// (or if in v12+, use the LitDepthNormalsPass.hlsl instead, which additionally includes parallax and detail normals support)
|
||||
// https://github.com/Unity-Technologies/Graphics/blob/master/com.unity.render-pipelines.universal/Shaders/LitDepthNormalsPass.hlsl
|
||||
/*
|
||||
Pass {
|
||||
Name "DepthNormals"
|
||||
Tags { "LightMode"="DepthNormals" }
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex DepthNormalsVertex
|
||||
#pragma fragment DepthNormalsFragment
|
||||
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
#define REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR
|
||||
#endif
|
||||
|
||||
struct Attributes {
|
||||
float4 positionOS : POSITION;
|
||||
float4 tangentOS : TANGENT;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float3 normal : NORMAL;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD1;
|
||||
float3 normalWS : TEXCOORD2;
|
||||
|
||||
#if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR)
|
||||
half4 tangentWS : TEXCOORD4; // xyz: tangent, w: sign
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
Varyings DepthNormalsVertex(Attributes input) {
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
// Example Displacement
|
||||
//input.positionOS += float4(0, _SinTime.y, 0, 0);
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normal, input.tangentOS);
|
||||
output.normalWS = NormalizeNormalPerVertex(normalInput.normalWS);
|
||||
|
||||
#if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR)
|
||||
float sign = input.tangentOS.w * float(GetOddNegativeScale());
|
||||
half4 tangentWS = half4(normalInput.tangentWS.xyz, sign);
|
||||
output.tangentWS = tangentWS;
|
||||
#endif
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 DepthNormalsFragment(Varyings input) : SV_TARGET {
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
Alpha(SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)).a, _BaseColor, _Cutoff);
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
float sgn = input.tangentWS.w; // should be either +1 or -1
|
||||
float3 bitangent = sgn * cross(input.normalWS.xyz, input.tangentWS.xyz);
|
||||
float3 normalTS = SampleNormal(input.uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale);
|
||||
|
||||
float3 normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWS.xyz));
|
||||
#else
|
||||
float3 normalWS = input.normalWS;
|
||||
#endif
|
||||
|
||||
return float4(PackNormalOctRectEncode(TransformWorldToViewDir(normalWS, true)), 0.0, 0.0);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
*/
|
||||
|
||||
// Meta, used for baking global illumination / lightmaps
|
||||
Pass {
|
||||
Name "Meta"
|
||||
Tags{"LightMode" = "Meta"}
|
||||
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex UniversalVertexMeta
|
||||
#pragma fragment UniversalFragmentMeta
|
||||
|
||||
#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
|
||||
|
||||
struct Attributes {
|
||||
float4 positionOS : POSITION;
|
||||
float3 normalOS : NORMAL;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float2 uv1 : TEXCOORD1;
|
||||
float2 uv2 : TEXCOORD2;
|
||||
#ifdef _TANGENT_TO_WORLD
|
||||
float4 tangentOS : TANGENT;
|
||||
#endif
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct Varyings {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
#include "PBRSurface.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MetaInput.hlsl"
|
||||
|
||||
Varyings UniversalVertexMeta(Attributes input) {
|
||||
Varyings output;
|
||||
output.positionCS = MetaVertexPosition(input.positionOS, input.uv1, input.uv2, unity_LightmapST, unity_DynamicLightmapST);
|
||||
output.uv = TRANSFORM_TEX(input.uv0, _BaseMap);
|
||||
output.color = input.color;
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 UniversalFragmentMeta(Varyings input) : SV_Target {
|
||||
SurfaceData surfaceData;
|
||||
InitializeSurfaceData(input, surfaceData);
|
||||
|
||||
BRDFData brdfData;
|
||||
InitializeBRDFData(surfaceData.albedo, surfaceData.metallic, surfaceData.specular, surfaceData.smoothness, surfaceData.alpha, brdfData);
|
||||
|
||||
MetaInput metaInput;
|
||||
metaInput.Albedo = brdfData.diffuse + brdfData.specular * brdfData.roughness * 0.5;
|
||||
metaInput.Emission = surfaceData.emission;
|
||||
|
||||
return MetaFragment(metaInput);
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// There is also other passes, e.g.
|
||||
// Universal2D, if you need the shader to support the 2D Renderer
|
||||
// UniversalGBuffer, for Deferred rendering support (v12 only)
|
||||
// but not supporting them here. See the URP Shaders source :
|
||||
// https://github.com/Unity-Technologies/Graphics/tree/master/com.unity.render-pipelines.universal/Shaders
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6816eb92a7e6b724d8546b078c69f1fa
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,457 +0,0 @@
|
||||
// Example Shader for Universal RP
|
||||
// Written by @Cyanilux
|
||||
// https://www.cyanilux.com/tutorials/urp-shader-code
|
||||
|
||||
/*
|
||||
Roughly equivalent to the URP/SimpleLit.shader (but Forward path only)
|
||||
https://github.com/Unity-Technologies/Graphics/blob/master/Packages/com.unity.render-pipelines.universal/Shaders/SimpleLit.shader
|
||||
*/
|
||||
|
||||
Shader "Cyanilux/URPTemplates/SimpleLitShaderExample" {
|
||||
Properties {
|
||||
[MainTexture] _BaseMap("Base Map (RGB) Smoothness / Alpha (A)", 2D) = "white" {}
|
||||
[MainColor] _BaseColor("Base Color", Color) = (1, 1, 1, 1)
|
||||
|
||||
[Toggle(_NORMALMAP)] _NormalMapToggle ("Normal Mapping", Float) = 0
|
||||
[NoScaleOffset] _BumpMap("Normal Map", 2D) = "bump" {}
|
||||
|
||||
[HDR] _EmissionColor("Emission Color", Color) = (0,0,0)
|
||||
[Toggle(_EMISSION)] _Emission ("Emission", Float) = 0
|
||||
[NoScaleOffset]_EmissionMap("Emission Map", 2D) = "white" {}
|
||||
|
||||
[Toggle(_ALPHATEST_ON)] _AlphaTestToggle ("Alpha Clipping", Float) = 0
|
||||
_Cutoff ("Alpha Cutoff", Float) = 0.5
|
||||
|
||||
[Toggle(_SPECGLOSSMAP)] _SpecGlossMapToggle ("Use Specular Gloss Map", Float) = 0
|
||||
_SpecColor("Specular Color", Color) = (0.5, 0.5, 0.5, 0.5)
|
||||
_SpecGlossMap("Specular Map", 2D) = "white" {}
|
||||
[Toggle(_GLOSSINESS_FROM_BASE_ALPHA)] _GlossSource ("Glossiness Source, from Albedo Alpha (if on) vs from Specular (if off)", Float) = 0
|
||||
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderPipeline"="UniversalPipeline"
|
||||
"RenderType"="Opaque"
|
||||
"Queue"="Geometry"
|
||||
}
|
||||
|
||||
HLSLINCLUDE
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
float4 _BaseColor;
|
||||
float4 _EmissionColor;
|
||||
float4 _SpecColor;
|
||||
float _Cutoff;
|
||||
float _Smoothness;
|
||||
CBUFFER_END
|
||||
ENDHLSL
|
||||
|
||||
Pass {
|
||||
Name "ForwardLit"
|
||||
Tags { "LightMode"="UniversalForward" }
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex LitPassVertex
|
||||
#pragma fragment LitPassFragment
|
||||
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
#pragma shader_feature_local _RECEIVE_SHADOWS_OFF
|
||||
//#pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
//#pragma shader_feature_local_fragment _ _SPECGLOSSMAP _SPECULAR_COLOR
|
||||
#pragma shader_feature_local_fragment _ _SPECGLOSSMAP
|
||||
#define _SPECULAR_COLOR // always on
|
||||
#pragma shader_feature_local_fragment _GLOSSINESS_FROM_BASE_ALPHA
|
||||
|
||||
// URP Keywords
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
|
||||
// Note, v11 changes this to :
|
||||
// #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
|
||||
|
||||
#pragma multi_compile _ _SHADOWS_SOFT
|
||||
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
||||
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING // v10+ only, renamed from "_MIXED_LIGHTING_SUBTRACTIVE"
|
||||
#pragma multi_compile _ SHADOWS_SHADOWMASK // v10+ only
|
||||
|
||||
// Unity Keywords
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile_fog
|
||||
|
||||
// GPU Instancing (not supported)
|
||||
//#pragma multi_compile_instancing
|
||||
|
||||
// Includes
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
|
||||
// Structs
|
||||
struct Attributes {
|
||||
float4 positionOS : POSITION;
|
||||
float4 normalOS : NORMAL;
|
||||
#ifdef _NORMALMAP
|
||||
float4 tangentOS : TANGENT;
|
||||
#endif
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 lightmapUV : TEXCOORD1;
|
||||
float4 color : COLOR;
|
||||
//UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 1);
|
||||
float3 positionWS : TEXCOORD2;
|
||||
|
||||
#ifdef _NORMALMAP
|
||||
half4 normalWS : TEXCOORD3; // xyz: normal, w: viewDir.x
|
||||
half4 tangentWS : TEXCOORD4; // xyz: tangent, w: viewDir.y
|
||||
half4 bitangentWS : TEXCOORD5; // xyz: bitangent, w: viewDir.z
|
||||
#else
|
||||
half3 normalWS : TEXCOORD3;
|
||||
#endif
|
||||
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
half4 fogFactorAndVertexLight : TEXCOORD6; // x: fogFactor, yzw: vertex light
|
||||
#else
|
||||
half fogFactor : TEXCOORD6;
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
float4 shadowCoord : TEXCOORD7;
|
||||
#endif
|
||||
|
||||
float4 color : COLOR;
|
||||
//UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
//UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
// Textures, Samplers & Global Properties
|
||||
// (note, BaseMap, BumpMap and EmissionMap is being defined by the SurfaceInput.hlsl include)
|
||||
TEXTURE2D(_SpecGlossMap); SAMPLER(sampler_SpecGlossMap);
|
||||
|
||||
// Functions
|
||||
half4 SampleSpecularSmoothness(float2 uv, half alpha, half4 specColor, TEXTURE2D_PARAM(specMap, sampler_specMap)) {
|
||||
half4 specularSmoothness = half4(0.0h, 0.0h, 0.0h, 1.0h);
|
||||
#ifdef _SPECGLOSSMAP
|
||||
specularSmoothness = SAMPLE_TEXTURE2D(specMap, sampler_specMap, uv) * specColor;
|
||||
#elif defined(_SPECULAR_COLOR)
|
||||
specularSmoothness = specColor;
|
||||
#endif
|
||||
|
||||
#if UNITY_VERSION >= 202120 // or #if SHADER_LIBRARY_VERSION_MAJOR < 12, but that versioning method is deprecated for newer versions
|
||||
// v12 is changing this, so it's calculated later. Likely so that smoothness value stays 0-1 so it can display better for debug views.
|
||||
#ifdef _GLOSSINESS_FROM_BASE_ALPHA
|
||||
specularSmoothness.a = exp2(10 * alpha + 1);
|
||||
#else
|
||||
specularSmoothness.a = exp2(10 * specularSmoothness.a + 1);
|
||||
#endif
|
||||
#endif
|
||||
return specularSmoothness;
|
||||
}
|
||||
|
||||
// SurfaceData & InputData
|
||||
void InitalizeSurfaceData(Varyings IN, out SurfaceData surfaceData){
|
||||
surfaceData = (SurfaceData)0; // avoids "not completely initalized" errors
|
||||
|
||||
half4 baseMap = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, IN.uv);
|
||||
|
||||
#ifdef _ALPHATEST_ON
|
||||
// Alpha Clipping
|
||||
clip(baseMap.a - _Cutoff);
|
||||
#endif
|
||||
|
||||
half4 diffuse = baseMap * _BaseColor * IN.color;
|
||||
surfaceData.albedo = diffuse.rgb;
|
||||
surfaceData.normalTS = SampleNormal(IN.uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap));
|
||||
surfaceData.emission = SampleEmission(IN.uv, _EmissionColor.rgb, TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap));
|
||||
surfaceData.occlusion = 1.0; // unused
|
||||
|
||||
half4 specular = SampleSpecularSmoothness(IN.uv, diffuse.a, _SpecColor, TEXTURE2D_ARGS(_SpecGlossMap, sampler_SpecGlossMap));
|
||||
surfaceData.specular = specular.rgb;
|
||||
surfaceData.smoothness = specular.a * _Smoothness;
|
||||
}
|
||||
|
||||
void InitializeInputData(Varyings input, half3 normalTS, out InputData inputData) {
|
||||
inputData = (InputData)0; // avoids "not completely initalized" errors
|
||||
|
||||
inputData.positionWS = input.positionWS;
|
||||
|
||||
#ifdef _NORMALMAP
|
||||
half3 viewDirWS = half3(input.normalWS.w, input.tangentWS.w, input.bitangentWS.w);
|
||||
inputData.normalWS = TransformTangentToWorld(normalTS,half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz));
|
||||
#else
|
||||
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(inputData.positionWS);
|
||||
inputData.normalWS = input.normalWS;
|
||||
#endif
|
||||
|
||||
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
|
||||
|
||||
viewDirWS = SafeNormalize(viewDirWS);
|
||||
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
|
||||
|
||||
// Fog
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
inputData.fogCoord = input.fogFactorAndVertexLight.x;
|
||||
inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
|
||||
#else
|
||||
inputData.fogCoord = input.fogFactor;
|
||||
inputData.vertexLighting = half3(0, 0, 0);
|
||||
#endif
|
||||
|
||||
/* in v11/v12?, could use :
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
inputData.fogCoord = InitializeInputDataFog(float4(inputData.positionWS, 1.0), input.fogFactorAndVertexLight.x);
|
||||
inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
|
||||
#else
|
||||
inputData.fogCoord = InitializeInputDataFog(float4(inputData.positionWS, 1.0), input.fogFactor);
|
||||
inputData.vertexLighting = half3(0, 0, 0);
|
||||
#endif
|
||||
*/
|
||||
|
||||
inputData.bakedGI = SAMPLE_GI(input.lightmapUV, input.vertexSH, inputData.normalWS);
|
||||
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS);
|
||||
inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV);
|
||||
}
|
||||
|
||||
// Vertex Shader
|
||||
Varyings LitPassVertex(Attributes IN) {
|
||||
Varyings OUT;
|
||||
|
||||
//UNITY_SETUP_INSTANCE_ID(IN);
|
||||
//UNITY_TRANSFER_INSTANCE_ID(IN, OUT);
|
||||
//UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
||||
|
||||
VertexPositionInputs positionInputs = GetVertexPositionInputs(IN.positionOS.xyz);
|
||||
#ifdef _NORMALMAP
|
||||
VertexNormalInputs normalInputs = GetVertexNormalInputs(IN.normalOS.xyz, IN.tangentOS);
|
||||
#else
|
||||
VertexNormalInputs normalInputs = GetVertexNormalInputs(IN.normalOS.xyz);
|
||||
#endif
|
||||
|
||||
|
||||
OUT.positionCS = positionInputs.positionCS;
|
||||
OUT.positionWS = positionInputs.positionWS;
|
||||
|
||||
half3 viewDirWS = GetWorldSpaceViewDir(positionInputs.positionWS);
|
||||
half3 vertexLight = VertexLighting(positionInputs.positionWS, normalInputs.normalWS);
|
||||
half fogFactor = ComputeFogFactor(positionInputs.positionCS.z);
|
||||
|
||||
#ifdef _NORMALMAP
|
||||
OUT.normalWS = half4(normalInputs.normalWS, viewDirWS.x);
|
||||
OUT.tangentWS = half4(normalInputs.tangentWS, viewDirWS.y);
|
||||
OUT.bitangentWS = half4(normalInputs.bitangentWS, viewDirWS.z);
|
||||
#else
|
||||
OUT.normalWS = NormalizeNormalPerVertex(normalInputs.normalWS);
|
||||
//OUT.viewDirWS = viewDirWS;
|
||||
#endif
|
||||
|
||||
OUTPUT_LIGHTMAP_UV(IN.lightmapUV, unity_LightmapST, OUT.lightmapUV);
|
||||
OUTPUT_SH(OUT.normalWS.xyz, OUT.vertexSH);
|
||||
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
OUT.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
|
||||
#else
|
||||
OUT.fogFactor = fogFactor;
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
OUT.shadowCoord = GetShadowCoord(positionInputs);
|
||||
#endif
|
||||
|
||||
OUT.uv = TRANSFORM_TEX(IN.uv, _BaseMap);
|
||||
OUT.color = IN.color;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
// Fragment Shader
|
||||
half4 LitPassFragment(Varyings IN) : SV_Target {
|
||||
//UNITY_SETUP_INSTANCE_ID(IN);
|
||||
//UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);
|
||||
|
||||
// Setup SurfaceData
|
||||
SurfaceData surfaceData;
|
||||
InitalizeSurfaceData(IN, surfaceData);
|
||||
|
||||
// Setup InputData
|
||||
InputData inputData;
|
||||
InitializeInputData(IN, surfaceData.normalTS, inputData);
|
||||
|
||||
// Simple Lighting (Lambert & BlinnPhong)
|
||||
//half4 color = UniversalFragmentBlinnPhong(inputData, surfaceData); // v12 only
|
||||
half4 color = UniversalFragmentBlinnPhong(inputData, surfaceData.albedo, half4(surfaceData.specular, 1),
|
||||
surfaceData.smoothness, surfaceData.emission, surfaceData.alpha);
|
||||
// See Lighting.hlsl to see how this is implemented.
|
||||
// https://github.com/Unity-Technologies/Graphics/blob/master/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl
|
||||
|
||||
color.rgb = MixFog(color.rgb, inputData.fogCoord);
|
||||
//color.a = OutputAlpha(color.a, _Surface);
|
||||
return color;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// UsePass "Universal Render Pipeline/Lit/ShadowCaster"
|
||||
// UsePass "Universal Render Pipeline/Lit/DepthOnly"
|
||||
// Would be nice if we could just use the passes from existing shaders,
|
||||
// However this breaks SRP Batcher compatibility. Instead, we should define them :
|
||||
|
||||
// ShadowCaster, for casting shadows
|
||||
Pass {
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#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
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
// Universal Pipeline Keywords
|
||||
// (v11+) This is used during shadow map generation to differentiate between directional and punctual (point/spot) light shadows, as they use different formulas to apply Normal Bias
|
||||
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
|
||||
|
||||
// Note if we do any vertex displacement, we'll need to change the vertex function. e.g. :
|
||||
/*
|
||||
#pragma vertex DisplacedShadowPassVertex (instead of ShadowPassVertex above)
|
||||
|
||||
Varyings DisplacedShadowPassVertex(Attributes input) {
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
|
||||
// Example Displacement
|
||||
input.positionOS += float4(0, _SinTime.y, 0, 0);
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = GetShadowPositionHClip(input);
|
||||
return output;
|
||||
}
|
||||
*/
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// DepthOnly, used for Camera Depth Texture (if cannot copy depth buffer instead, and the DepthNormals below isn't used)
|
||||
Pass {
|
||||
Name "DepthOnly"
|
||||
Tags { "LightMode"="DepthOnly" }
|
||||
|
||||
ColorMask 0
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex DepthOnlyVertex
|
||||
#pragma fragment DepthOnlyFragment
|
||||
|
||||
// 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
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
|
||||
|
||||
// Note if we do any vertex displacement, we'll need to change the vertex function. e.g. :
|
||||
/*
|
||||
#pragma vertex DisplacedDepthOnlyVertex (instead of DepthOnlyVertex above)
|
||||
|
||||
Varyings DisplacedDepthOnlyVertex(Attributes input) {
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
// Example Displacement
|
||||
input.positionOS += float4(0, _SinTime.y, 0, 0);
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = TransformObjectToHClip(input.position.xyz);
|
||||
return output;
|
||||
}
|
||||
*/
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// DepthNormals, used for SSAO & other custom renderer features that request it
|
||||
Pass {
|
||||
Name "DepthNormals"
|
||||
Tags { "LightMode"="DepthNormals" }
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex DepthNormalsVertex
|
||||
#pragma fragment DepthNormalsFragment
|
||||
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl"
|
||||
|
||||
// Note if we do any vertex displacement, we'll need to change the vertex function. e.g. :
|
||||
/*
|
||||
#pragma vertex DisplacedDepthNormalsVertex (instead of DepthNormalsVertex above)
|
||||
|
||||
Varyings DisplacedDepthNormalsVertex(Attributes input) {
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
// Example Displacement
|
||||
input.positionOS += float4(0, _SinTime.y, 0, 0);
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = TransformObjectToHClip(input.position.xyz);
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normal, input.tangentOS);
|
||||
output.normalWS = NormalizeNormalPerVertex(normalInput.normalWS);
|
||||
return output;
|
||||
}
|
||||
*/
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8edd04e63e13ee24fa199ccb87d74c63
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,79 +0,0 @@
|
||||
// Example Shader for Universal RP
|
||||
// Written by @Cyanilux
|
||||
// https://www.cyanilux.com/tutorials/urp-shader-code
|
||||
|
||||
Shader "Cyanilux/URPTemplates/TransparentUnlitShaderExample" {
|
||||
Properties {
|
||||
_BaseMap ("Example Texture", 2D) = "white" {}
|
||||
_BaseColor ("Example Colour", Color) = (0, 0.66, 0.73, 0.5)
|
||||
//_ExampleVector ("Example Vector", Vector) = (0, 1, 0, 0)
|
||||
//_ExampleFloat ("Example Float (Vector1)", Float) = 0.5
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderPipeline"="UniversalPipeline"
|
||||
"RenderType"="Transparent"
|
||||
"Queue"="Transparent"
|
||||
}
|
||||
|
||||
HLSLINCLUDE
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
float4 _BaseColor;
|
||||
//float4 _ExampleVector;
|
||||
//float _ExampleFloat;
|
||||
CBUFFER_END
|
||||
ENDHLSL
|
||||
|
||||
Pass {
|
||||
Name "Unlit"
|
||||
//Tags { "LightMode"="SRPDefaultUnlit" } // (is default anyway)
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex UnlitPassVertex
|
||||
#pragma fragment UnlitPassFragment
|
||||
|
||||
// Structs
|
||||
struct Attributes {
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct Varyings {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
// Textures, Samplers & Global Properties
|
||||
TEXTURE2D(_BaseMap);
|
||||
SAMPLER(sampler_BaseMap);
|
||||
|
||||
// Vertex Shader
|
||||
Varyings UnlitPassVertex(Attributes IN) {
|
||||
Varyings OUT;
|
||||
|
||||
VertexPositionInputs positionInputs = GetVertexPositionInputs(IN.positionOS.xyz);
|
||||
OUT.positionCS = positionInputs.positionCS;
|
||||
// Or :
|
||||
//OUT.positionCS = TransformObjectToHClip(IN.positionOS.xyz);
|
||||
OUT.uv = TRANSFORM_TEX(IN.uv, _BaseMap);
|
||||
OUT.color = IN.color;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
// Fragment Shader
|
||||
half4 UnlitPassFragment(Varyings IN) : SV_Target {
|
||||
half4 baseMap = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, IN.uv);
|
||||
|
||||
return baseMap * _BaseColor * IN.color;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0c68aaf35b97b9439cd476bb0479a20
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,236 +0,0 @@
|
||||
// Example Shader for Universal RP
|
||||
// Written by @Cyanilux
|
||||
// https://www.cyanilux.com/tutorials/urp-shader-code
|
||||
|
||||
Shader "Cyanilux/URPTemplates/Unlit+ShaderExample" {
|
||||
Properties {
|
||||
_BaseMap ("Example Texture", 2D) = "white" {}
|
||||
_BaseColor ("Example Colour", Color) = (0, 0.66, 0.73, 1)
|
||||
[Toggle(_ALPHATEST_ON)] _AlphaTestToggle ("Alpha Clipping", Float) = 0
|
||||
_Cutoff ("Alpha Cutoff", Float) = 0.5
|
||||
|
||||
[HideInInspector] _Cull("__cull", Float) = 2.0
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderPipeline"="UniversalPipeline"
|
||||
"RenderType"="Opaque"
|
||||
"Queue"="Geometry"
|
||||
"UniversalMaterialType" = "Lit" "IgnoreProjector" = "True"
|
||||
}
|
||||
|
||||
HLSLINCLUDE
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
float4 _BaseColor;
|
||||
float _Cutoff;
|
||||
CBUFFER_END
|
||||
ENDHLSL
|
||||
|
||||
Pass {
|
||||
Name "Unlit"
|
||||
//Tags { "LightMode"="SRPDefaultUnlit" } // (is default anyway)
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex UnlitPassVertex
|
||||
#pragma fragment UnlitPassFragment
|
||||
|
||||
// Material Keywords
|
||||
#pragma shader_feature _ALPHATEST_ON
|
||||
|
||||
// Structs
|
||||
struct Attributes {
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct Varyings {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
// Textures, Samplers & Global Properties
|
||||
TEXTURE2D(_BaseMap);
|
||||
SAMPLER(sampler_BaseMap);
|
||||
|
||||
// Vertex Shader
|
||||
Varyings UnlitPassVertex(Attributes IN) {
|
||||
Varyings OUT;
|
||||
|
||||
VertexPositionInputs positionInputs = GetVertexPositionInputs(IN.positionOS.xyz);
|
||||
OUT.positionCS = positionInputs.positionCS;
|
||||
// Or :
|
||||
//OUT.positionCS = TransformObjectToHClip(IN.positionOS.xyz);
|
||||
OUT.uv = TRANSFORM_TEX(IN.uv, _BaseMap);
|
||||
OUT.color = IN.color;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
// Fragment Shader
|
||||
half4 UnlitPassFragment(Varyings IN) : SV_Target {
|
||||
half4 baseMap = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, IN.uv);
|
||||
|
||||
#ifdef _ALPHATEST_ON
|
||||
// Alpha Clipping
|
||||
clip(baseMap.a - _Cutoff);
|
||||
#endif
|
||||
|
||||
return baseMap * _BaseColor * IN.color;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// UsePass "Universal Render Pipeline/Lit/ShadowCaster"
|
||||
// UsePass "Universal Render Pipeline/Lit/DepthOnly"
|
||||
// Would be nice if we could just use the passes from existing shaders,
|
||||
// However this breaks SRP Batcher compatibility. Instead, we should define them :
|
||||
|
||||
// ShadowCaster, for casting shadows
|
||||
Pass {
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
ColorMask 0
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex ShadowPassVertex
|
||||
#pragma fragment ShadowPassFragment
|
||||
|
||||
// Material Keywords
|
||||
#pragma shader_feature _ALPHATEST_ON
|
||||
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
// Universal Pipeline Keywords
|
||||
// (v11+) This is used during shadow map generation to differentiate between directional and punctual (point/spot) light shadows, as they use different formulas to apply Normal Bias
|
||||
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
|
||||
|
||||
// Note if we do any vertex displacement, we'll need to change the vertex function. e.g. :
|
||||
/*
|
||||
#pragma vertex DisplacedShadowPassVertex (instead of ShadowPassVertex above)
|
||||
|
||||
Varyings DisplacedShadowPassVertex(Attributes input) {
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
|
||||
// Example Displacement
|
||||
input.positionOS += float4(0, _SinTime.y, 0, 0);
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = GetShadowPositionHClip(input);
|
||||
return output;
|
||||
}
|
||||
*/
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// DepthOnly, used for Camera Depth Texture (if cannot copy depth buffer instead, and the DepthNormals below isn't used)
|
||||
Pass {
|
||||
Name "DepthOnly"
|
||||
Tags { "LightMode"="DepthOnly" }
|
||||
|
||||
ColorMask 0
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex DepthOnlyVertex
|
||||
#pragma fragment DepthOnlyFragment
|
||||
|
||||
// Material Keywords
|
||||
#pragma shader_feature _ALPHATEST_ON
|
||||
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
|
||||
|
||||
// Note if we do any vertex displacement, we'll need to change the vertex function. e.g. :
|
||||
/*
|
||||
#pragma vertex DisplacedDepthOnlyVertex (instead of DepthOnlyVertex above)
|
||||
|
||||
Varyings DisplacedDepthOnlyVertex(Attributes input) {
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
// Example Displacement
|
||||
input.positionOS += float4(0, _SinTime.y, 0, 0);
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = TransformObjectToHClip(input.position.xyz);
|
||||
return output;
|
||||
}
|
||||
*/
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// DepthNormals, used for SSAO & other custom renderer features that request it
|
||||
Pass {
|
||||
Name "DepthNormals"
|
||||
Tags { "LightMode"="DepthNormals" }
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex DepthNormalsVertex
|
||||
#pragma fragment DepthNormalsFragment
|
||||
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature _ALPHATEST_ON
|
||||
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
//#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl"
|
||||
|
||||
// Note if we do any vertex displacement, we'll need to change the vertex function. e.g. :
|
||||
/*
|
||||
#pragma vertex DisplacedDepthNormalsVertex (instead of DepthNormalsVertex above)
|
||||
|
||||
Varyings DisplacedDepthNormalsVertex(Attributes input) {
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
// Example Displacement
|
||||
input.positionOS += float4(0, _SinTime.y, 0, 0);
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionCS = TransformObjectToHClip(input.position.xyz);
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normal, input.tangentOS);
|
||||
output.normalWS = NormalizeNormalPerVertex(normalInput.normalWS);
|
||||
return output;
|
||||
}
|
||||
*/
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 431ebee5218e4794d891fdf9aae50bd7
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,83 +0,0 @@
|
||||
// Example Shader for Universal RP
|
||||
// Written by @Cyanilux
|
||||
// https://www.cyanilux.com/tutorials/urp-shader-code
|
||||
|
||||
/*
|
||||
Note : URP v12 (2021.3+) added a Depth Priming option :
|
||||
https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@12.1/manual/whats-new/urp-whats-new.html#depth-prepass-depth-priming-mode
|
||||
This may be auto/enabled in the URP project templates and as a result, this shader may appear invisible.
|
||||
Use the Unlit+ Template instead with the DepthOnly and DepthNormals passes to fix this.
|
||||
*/
|
||||
|
||||
Shader "Cyanilux/URPTemplates/UnlitShaderExample" {
|
||||
Properties {
|
||||
_BaseMap ("Example Texture", 2D) = "white" {}
|
||||
_BaseColor ("Example Colour", Color) = (0, 0.66, 0.73, 1)
|
||||
//_ExampleVector ("Example Vector", Vector) = (0, 1, 0, 0)
|
||||
//_ExampleFloat ("Example Float (Vector1)", Float) = 0.5
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderPipeline"="UniversalPipeline"
|
||||
"RenderType"="Opaque"
|
||||
"Queue"="Geometry"
|
||||
}
|
||||
|
||||
HLSLINCLUDE
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _BaseMap_ST;
|
||||
float4 _BaseColor;
|
||||
//float4 _ExampleVector;
|
||||
//float _ExampleFloat;
|
||||
CBUFFER_END
|
||||
ENDHLSL
|
||||
|
||||
Pass {
|
||||
Name "Unlit"
|
||||
//Tags { "LightMode"="SRPDefaultUnlit" } // (is default anyway)
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex UnlitPassVertex
|
||||
#pragma fragment UnlitPassFragment
|
||||
|
||||
// Structs
|
||||
struct Attributes {
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct Varyings {
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
// Textures, Samplers & Global Properties
|
||||
TEXTURE2D(_BaseMap);
|
||||
SAMPLER(sampler_BaseMap);
|
||||
|
||||
// Vertex Shader
|
||||
Varyings UnlitPassVertex(Attributes IN) {
|
||||
Varyings OUT;
|
||||
|
||||
VertexPositionInputs positionInputs = GetVertexPositionInputs(IN.positionOS.xyz);
|
||||
OUT.positionCS = positionInputs.positionCS;
|
||||
// Or :
|
||||
//OUT.positionCS = TransformObjectToHClip(IN.positionOS.xyz);
|
||||
OUT.uv = TRANSFORM_TEX(IN.uv, _BaseMap);
|
||||
OUT.color = IN.color;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
// Fragment Shader
|
||||
half4 UnlitPassFragment(Varyings IN) : SV_Target {
|
||||
half4 baseMap = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, IN.uv);
|
||||
return baseMap * _BaseColor * IN.color;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7431ef59f264b6f45befe166efa2f32f
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in New Issue
Block a user