├── .github └── FUNDING.yml ├── .gitignore ├── Editor.meta ├── Editor ├── Nodes.meta ├── Nodes │ ├── AudioLink.meta │ ├── AudioLink │ │ ├── AudioLink4BandAmplitudeFilteredNode.cs │ │ ├── AudioLink4BandAmplitudeFilteredNode.cs.meta │ │ ├── AudioLink4BandAmplitudeLerpNode.cs │ │ ├── AudioLink4BandAmplitudeLerpNode.cs.meta │ │ ├── AudioLink4BandAmplitudeNode.cs │ │ ├── AudioLink4BandAmplitudeNode.cs.meta │ │ ├── AudioLink4BandChronotensityNode.cs │ │ ├── AudioLink4BandChronotensityNode.cs.meta │ │ ├── AudioLinkExistsNode.cs │ │ ├── AudioLinkExistsNode.cs.meta │ │ ├── AudioLinkWaveformNode.cs │ │ └── AudioLinkWaveformNode.cs.meta │ ├── FwidthNode.cs │ ├── FwidthNode.cs.meta │ ├── LuminanceNode.cs │ ├── LuminanceNode.cs.meta │ ├── MainLightData.cs │ ├── MainLightData.cs.meta │ ├── Outline.meta │ ├── Outline │ │ ├── OutlinePassNode.cs │ │ ├── OutlinePassNode.cs.meta │ │ ├── OutlinePositionOffsetNode.cs │ │ └── OutlinePositionOffsetNode.cs.meta │ ├── RealBranchNode.cs │ ├── RealBranchNode.cs.meta │ ├── SubGraphs.meta │ ├── SubGraphs │ │ ├── Shadow Layer.shadersubgraph │ │ └── Shadow Layer.shadersubgraph.meta │ ├── VRChatIsInMirrorNode.cs │ └── VRChatIsInMirrorNode.cs.meta ├── ShaderGraph.meta ├── ShaderGraph │ ├── AssetCallbacks.meta │ ├── AssetCallbacks │ │ ├── CreateLitShaderGraph.cs │ │ ├── CreateLitShaderGraph.cs.meta │ │ ├── CreateUnlitShaderGraph.cs │ │ └── CreateUnlitShaderGraph.cs.meta │ ├── BuiltInFields.cs │ ├── BuiltInFields.cs.meta │ ├── BuiltInProperties.cs │ ├── BuiltInProperties.cs.meta │ ├── BuiltInStructFields.cs │ ├── BuiltInStructFields.cs.meta │ ├── BuiltInStructs.cs │ ├── BuiltInStructs.cs.meta │ ├── Includes.meta │ ├── Includes │ │ ├── BuildInputData.hlsl │ │ ├── BuildInputData.hlsl.meta │ │ ├── DepthOnlyPass.hlsl │ │ ├── DepthOnlyPass.hlsl.meta │ │ ├── LegacyBuilding.hlsl │ │ ├── LegacyBuilding.hlsl.meta │ │ ├── LegacySurfaceVertex.hlsl │ │ ├── LegacySurfaceVertex.hlsl.meta │ │ ├── LightingMetaPass.hlsl │ │ ├── LightingMetaPass.hlsl.meta │ │ ├── PBRDeferredPass.hlsl │ │ ├── PBRDeferredPass.hlsl.meta │ │ ├── PBRForwardAddPass.hlsl │ │ ├── PBRForwardAddPass.hlsl.meta │ │ ├── PBRForwardPass.hlsl │ │ ├── PBRForwardPass.hlsl.meta │ │ ├── PBRGBufferPass.hlsl │ │ ├── PBRGBufferPass.hlsl.meta │ │ ├── ShaderPass.hlsl │ │ ├── ShaderPass.hlsl.meta │ │ ├── ShadowCasterPass.hlsl │ │ ├── ShadowCasterPass.hlsl.meta │ │ ├── SpriteUnlitPass.hlsl │ │ ├── SpriteUnlitPass.hlsl.meta │ │ ├── UnlitPass.hlsl │ │ ├── UnlitPass.hlsl.meta │ │ ├── Varyings.hlsl │ │ └── Varyings.hlsl.meta │ ├── Inspector.meta │ ├── Inspector │ │ ├── BaseShaderGUI.cs │ │ ├── BaseShaderGUI.cs.meta │ │ ├── BuiltInLitGUI.cs │ │ ├── BuiltInLitGUI.cs.meta │ │ ├── BuiltInUnlitGUI.cs │ │ └── BuiltInUnlitGUI.cs.meta │ ├── Targets.meta │ ├── Targets │ │ ├── BuiltInLitSubTarget.cs │ │ ├── BuiltInLitSubTarget.cs.meta │ │ ├── BuiltInSubTarget.cs │ │ ├── BuiltInSubTarget.cs.meta │ │ ├── BuiltInTarget.cs │ │ ├── BuiltInTarget.cs.meta │ │ ├── BuiltInUnlitSubTarget.cs │ │ ├── BuiltInUnlitSubTarget.cs.meta │ │ ├── GraphInspectorGUI.cs │ │ └── GraphInspectorGUI.cs.meta │ ├── Templates.meta │ └── Templates │ │ ├── GrabPass.template │ │ ├── GrabPass.template.meta │ │ ├── ShaderPass.template │ │ ├── ShaderPass.template.meta │ │ ├── SharedCode.template.hlsl │ │ └── SharedCode.template.hlsl.meta ├── VRCFallbackTags.cs ├── VRCFallbackTags.cs.meta ├── io.z3y.github.shadergraphtarget.editor.asmref └── io.z3y.github.shadergraphtarget.editor.asmref.meta ├── LICENSE ├── LICENSE.meta ├── README.md ├── README.md.meta ├── ShaderLibrary.meta ├── ShaderLibrary ├── Alpha.hlsl ├── Alpha.hlsl.meta ├── Bakery.hlsl ├── Bakery.hlsl.meta ├── Bicubic.hlsl ├── Bicubic.hlsl.meta ├── BuiltInDOTSInstancing.hlsl ├── BuiltInDOTSInstancing.hlsl.meta ├── Core.hlsl ├── Core.hlsl.meta ├── DeclareDepthTexture.hlsl ├── DeclareDepthTexture.hlsl.meta ├── DeclareNormalsTexture.hlsl ├── DeclareNormalsTexture.hlsl.meta ├── DeclareOpaqueTexture.hlsl ├── DeclareOpaqueTexture.hlsl.meta ├── ForwardLighting.hlsl ├── ForwardLighting.hlsl.meta ├── Fragment.hlsl ├── Fragment.hlsl.meta ├── FragmentMeta.hlsl ├── FragmentMeta.hlsl.meta ├── FragmentShadowCaster.hlsl ├── FragmentShadowCaster.hlsl.meta ├── FragmentUnlit.hlsl ├── FragmentUnlit.hlsl.meta ├── LDR_LLL1_0.png ├── LDR_LLL1_0.png.meta ├── LightFunctions.hlsl ├── LightFunctions.hlsl.meta ├── SSR.hlsl ├── SSR.hlsl.meta ├── ShaderGraphFunctions.hlsl ├── ShaderGraphFunctions.hlsl.meta ├── ShaderPass.hlsl ├── ShaderPass.hlsl.meta ├── Structs.hlsl ├── Structs.hlsl.meta ├── SurfaceData.hlsl ├── SurfaceData.hlsl.meta ├── TerrainInput.hlsl ├── TerrainInput.hlsl.meta ├── UnityCG.meta ├── UnityCG │ ├── ShaderVariablesMatrixDefsLegacyUnity.hlsl │ ├── ShaderVariablesMatrixDefsLegacyUnity.hlsl.meta │ ├── UnityCG.hlsl │ ├── UnityCG.hlsl.meta │ ├── license.txt │ └── license.txt.meta ├── Vertex.hlsl ├── Vertex.hlsl.meta ├── dfg-multiscatter.exr └── dfg-multiscatter.exr.meta ├── package.json └── package.json.meta /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | patreon: z3y 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | 13 | # Asset meta data should only be ignored when the corresponding asset is also ignored 14 | !/[Aa]ssets/**/*.meta 15 | 16 | # Uncomment this line if you wish to ignore the asset store tools plugin 17 | # /[Aa]ssets/AssetStoreTools* 18 | 19 | # Autogenerated Jetbrains Rider plugin 20 | [Aa]ssets/Plugins/Editor/JetBrains* 21 | 22 | # Visual Studio cache directory 23 | .vs/ 24 | 25 | # Gradle cache directory 26 | .gradle/ 27 | 28 | # Autogenerated VS/MD/Consulo solution and project files 29 | ExportedObj/ 30 | .consulo/ 31 | *.csproj 32 | *.unityproj 33 | *.sln 34 | *.suo 35 | *.tmp 36 | *.user 37 | *.userprefs 38 | *.pidb 39 | *.booproj 40 | *.svd 41 | *.pdb 42 | *.mdb 43 | *.opendb 44 | *.VC.db 45 | 46 | # Unity3D generated meta files 47 | *.pidb.meta 48 | *.pdb.meta 49 | *.mdb.meta 50 | 51 | # Unity3D generated file on crash reports 52 | sysinfo.txt 53 | 54 | # Builds 55 | *.apk 56 | *.unitypackage 57 | 58 | # Crashlytics generated file 59 | crashlytics-build.properties 60 | 61 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db42249e537fc8a43b959048e702d8cc 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Nodes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7b69769150146274daecd8545968e565 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Nodes/AudioLink.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29506bbf41798914e8a2847aec52d558 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Nodes/AudioLink/AudioLink4BandAmplitudeFilteredNode.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using UnityEditor.ShaderGraph; 3 | 4 | namespace z3y.BuiltIn.ShaderGraph.Nodes 5 | { 6 | [Title("AudioLink", "4Band Amplitude Filtered")] 7 | class AudioLink4BandAmplitudeFilteredNode : CodeFunctionNode, IMayRequireTime 8 | { 9 | public AudioLink4BandAmplitudeFilteredNode() 10 | { 11 | name = "4 Band Amplitude Filtered"; 12 | } 13 | 14 | protected override MethodInfo GetFunctionToConvert() 15 | { 16 | return GetType().GetMethod("AudioLink_4BandAmplitudeNodeFiltered", BindingFlags.Static | BindingFlags.NonPublic); 17 | } 18 | 19 | 20 | static string AudioLink_4BandAmplitudeNodeFiltered( 21 | [Slot(0, Binding.None)] Vector1 Band, 22 | [Slot(1, Binding.None)] Vector1 FilterAmount, 23 | [Slot(2, Binding.None)] out Vector1 Out) 24 | { 25 | return 26 | @" 27 | { 28 | Out = AudioLinkLerp( ALPASS_FILTEREDAUDIOLINK + float2( FilterAmount, Band ) ).r; 29 | } 30 | "; 31 | } 32 | 33 | public bool RequiresTime() => true; 34 | 35 | public override void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode) 36 | { 37 | AudioLinkExistsNode.AddAudioLinkInclude(registry); 38 | base.GenerateNodeFunction(registry, generationMode); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Editor/Nodes/AudioLink/AudioLink4BandAmplitudeFilteredNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b101b155c30b4f97841d0c7c8db65ca8 3 | timeCreated: 1671493528 -------------------------------------------------------------------------------- /Editor/Nodes/AudioLink/AudioLink4BandAmplitudeLerpNode.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using UnityEditor.ShaderGraph; 3 | 4 | namespace z3y.BuiltIn.ShaderGraph.Nodes 5 | { 6 | [Title("AudioLink", "4Band Amplitude Lerp")] 7 | class AudioLink4BandAmplitudeLerpNode : CodeFunctionNode, IMayRequireTime 8 | { 9 | public AudioLink4BandAmplitudeLerpNode() 10 | { 11 | name = "4 Band Amplitude Lerp"; 12 | } 13 | 14 | protected override MethodInfo GetFunctionToConvert() 15 | { 16 | return GetType().GetMethod("AudioLink_4BandAmplitudeNodeLerp", BindingFlags.Static | BindingFlags.NonPublic); 17 | } 18 | 19 | 20 | static string AudioLink_4BandAmplitudeNodeLerp( 21 | [Slot(0, Binding.None)] Vector1 Band, 22 | [Slot(1, Binding.None)] Vector1 Delay, 23 | [Slot(2, Binding.None)] out Vector1 Out) 24 | { 25 | return 26 | @" 27 | { 28 | Out = AudioLinkLerp( ALPASS_AUDIOLINK + float2( Delay, Band ) ).r; 29 | } 30 | "; 31 | } 32 | 33 | public bool RequiresTime() => true; 34 | 35 | public override void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode) 36 | { 37 | AudioLinkExistsNode.AddAudioLinkInclude(registry); 38 | base.GenerateNodeFunction(registry, generationMode); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Editor/Nodes/AudioLink/AudioLink4BandAmplitudeLerpNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99bbc3de4818428f8e8b0e93d3bede2d 3 | timeCreated: 1671559211 -------------------------------------------------------------------------------- /Editor/Nodes/AudioLink/AudioLink4BandAmplitudeNode.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using UnityEditor.ShaderGraph; 3 | 4 | namespace z3y.BuiltIn.ShaderGraph.Nodes 5 | { 6 | [Title("AudioLink", "4Band Amplitude")] 7 | class AudioLink4BandAmplitudeNode : CodeFunctionNode, IMayRequireTime 8 | { 9 | public AudioLink4BandAmplitudeNode() 10 | { 11 | name = "4 Band Amplitude"; 12 | } 13 | 14 | protected override MethodInfo GetFunctionToConvert() 15 | { 16 | return GetType().GetMethod("AudioLink_4BandAmplitudeNode", BindingFlags.Static | BindingFlags.NonPublic); 17 | } 18 | 19 | 20 | static string AudioLink_4BandAmplitudeNode( 21 | [Slot(0, Binding.None)] Vector1 Band, 22 | [Slot(1, Binding.None)] Vector1 Delay, 23 | [Slot(2, Binding.None)] out Vector1 Out) 24 | { 25 | return 26 | @" 27 | { 28 | Out = AudioLinkData(ALPASS_AUDIOLINK + uint2( Delay, Band ) ).r; 29 | } 30 | "; 31 | } 32 | 33 | 34 | public bool RequiresTime() => true; 35 | 36 | public override void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode) 37 | { 38 | AudioLinkExistsNode.AddAudioLinkInclude(registry); 39 | base.GenerateNodeFunction(registry, generationMode); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Editor/Nodes/AudioLink/AudioLink4BandAmplitudeNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7f2bd64382ac49e9be56f6bfafc5bf57 3 | timeCreated: 1671490911 -------------------------------------------------------------------------------- /Editor/Nodes/AudioLink/AudioLink4BandChronotensityNode.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using UnityEditor.ShaderGraph; 3 | 4 | namespace z3y.BuiltIn.ShaderGraph.Nodes 5 | { 6 | [Title("AudioLink", "4Band Chronotensity")] 7 | class AudioLink4BandChronotensityNode : CodeFunctionNode, IMayRequireTime 8 | { 9 | public AudioLink4BandChronotensityNode() 10 | { 11 | name = "4 Band Chronotensity"; 12 | } 13 | 14 | protected override MethodInfo GetFunctionToConvert() 15 | { 16 | return GetType().GetMethod("AudioLink_4BandChronotensityNode", BindingFlags.Static | BindingFlags.NonPublic); 17 | } 18 | 19 | 20 | static string AudioLink_4BandChronotensityNode( 21 | [Slot(0, Binding.None)] Vector1 Mode, 22 | [Slot(1, Binding.None)] Vector1 Band, 23 | [Slot(5, Binding.None)] out Vector1 Out) 24 | { 25 | return 26 | @" 27 | { 28 | Out = (AudioLinkDecodeDataAsUInt( ALPASS_CHRONOTENSITY + int2(Mode, Band)) % 628319 ) / 100000.0; 29 | } 30 | "; 31 | } 32 | 33 | public bool RequiresTime() => true; 34 | 35 | public override void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode) 36 | { 37 | AudioLinkExistsNode.AddAudioLinkInclude(registry); 38 | base.GenerateNodeFunction(registry, generationMode); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Editor/Nodes/AudioLink/AudioLink4BandChronotensityNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ada5d41353ce45e6937d5ee48b515f75 3 | timeCreated: 1671559469 -------------------------------------------------------------------------------- /Editor/Nodes/AudioLink/AudioLinkExistsNode.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using UnityEditor.Graphing; 3 | using UnityEditor.ShaderGraph; 4 | 5 | namespace z3y.BuiltIn.ShaderGraph.Nodes 6 | { 7 | [Title("AudioLink", "Available")] 8 | sealed class AudioLinkExistsNode : AbstractMaterialNode, IMayRequireTime, IGeneratesFunction 9 | { 10 | 11 | public AudioLinkExistsNode() 12 | { 13 | name = "Audio Link Available"; 14 | UpdateNodeAfterDeserialization(); 15 | } 16 | 17 | public override void UpdateNodeAfterDeserialization() 18 | { 19 | AddSlot(new BooleanMaterialSlot(0, "Out", "Out", SlotType.Output, false)); 20 | RemoveSlotsNameNotMatching(new[] { 0 }); 21 | } 22 | 23 | public override string GetVariableNameForSlot(int slotId) 24 | { 25 | return @"AudioLinkIsAvailable()"; 26 | } 27 | 28 | public bool RequiresTime() 29 | { 30 | return true; 31 | } 32 | 33 | public void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode) 34 | { 35 | AddAudioLinkInclude(registry); 36 | } 37 | 38 | public static void AddAudioLinkInclude(FunctionRegistry registry) 39 | { 40 | registry.RequiresIncludePath("Packages/com.llealloo.audiolink/Runtime/Shaders/AudioLink.cginc"); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Editor/Nodes/AudioLink/AudioLinkExistsNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f7c75714f58397478b2e27d79550fb7 3 | timeCreated: 1671325660 -------------------------------------------------------------------------------- /Editor/Nodes/AudioLink/AudioLinkWaveformNode.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using UnityEditor.ShaderGraph; 3 | using UnityEngine; 4 | 5 | namespace z3y.BuiltIn.ShaderGraph.Nodes 6 | { 7 | [Title("AudioLink", "Waveform Preview")] 8 | class AudioLinkWaveformNode : CodeFunctionNode, IMayRequireTime, IGeneratesFunction 9 | { 10 | public AudioLinkWaveformNode() 11 | { 12 | name = "Waveform Preview"; 13 | } 14 | 15 | protected override MethodInfo GetFunctionToConvert() 16 | { 17 | return GetType().GetMethod("AudioLink_WaveformPreviewNode", BindingFlags.Static | BindingFlags.NonPublic); 18 | } 19 | 20 | 21 | static string AudioLink_WaveformPreviewNode( 22 | [Slot(0, Binding.MeshUV0)] Vector2 UV, 23 | [Slot(1, Binding.None)] out Vector1 Out) 24 | { 25 | return 26 | @" 27 | { 28 | float Sample = AudioLinkLerpMultiline( ALPASS_WAVEFORM + float2( 200. * UV.x, 0 ) ).r; 29 | Out = 1 - 50 * abs( Sample - UV.y * 2. + 1 ); 30 | } 31 | "; 32 | } 33 | 34 | public bool RequiresTime() => true; 35 | 36 | public override void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode) 37 | { 38 | AudioLinkExistsNode.AddAudioLinkInclude(registry); 39 | base.GenerateNodeFunction(registry, generationMode); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Editor/Nodes/AudioLink/AudioLinkWaveformNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a266ef57a534a6e844efc55bcb8394e 3 | timeCreated: 1671564169 -------------------------------------------------------------------------------- /Editor/Nodes/FwidthNode.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using UnityEditor.ShaderGraph; 3 | 4 | namespace z3y.BuiltIn.ShaderGraph.Nodes 5 | { 6 | [Title("z3y", "fwidth")] 7 | class FwidthNode : CodeFunctionNode 8 | { 9 | public FwidthNode() 10 | { 11 | name = "fwidth"; 12 | } 13 | 14 | public override bool hasPreview => false; 15 | 16 | protected override MethodInfo GetFunctionToConvert() 17 | { 18 | return GetType().GetMethod("Node_fwidth", BindingFlags.Static | BindingFlags.NonPublic); 19 | } 20 | 21 | static string Node_fwidth( 22 | [Slot(0, Binding.None)] in DynamicDimensionVector In, 23 | [Slot(1, Binding.None)] out DynamicDimensionVector Out 24 | ) 25 | { 26 | return 27 | @" 28 | { 29 | Out = fwidth(In); 30 | } 31 | "; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Editor/Nodes/FwidthNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f0f74b26fb368e429500cc056ca3ce5 3 | timeCreated: 1671565630 -------------------------------------------------------------------------------- /Editor/Nodes/LuminanceNode.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using UnityEditor.ShaderGraph; 3 | 4 | namespace z3y.BuiltIn.ShaderGraph.Nodes 5 | { 6 | [Title("z3y", "Luminance")] 7 | class LuminanceNode : CodeFunctionNode 8 | { 9 | public LuminanceNode() 10 | { 11 | name = "Luminance"; 12 | } 13 | 14 | protected override MethodInfo GetFunctionToConvert() 15 | { 16 | return GetType().GetMethod("Luminance_Node", BindingFlags.Static | BindingFlags.NonPublic); 17 | } 18 | 19 | 20 | static string Luminance_Node( 21 | [Slot(0, Binding.None)] in UnityEngine.Vector3 Color, 22 | [Slot(1, Binding.None)] out Vector1 Out 23 | ) 24 | { 25 | return 26 | @" 27 | { 28 | Out = dot(Color, float3(0.0396819152, 0.458021790, 0.00609653955)); 29 | } 30 | "; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Editor/Nodes/LuminanceNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33f33d70d0ce82b42b7be633739ce77d 3 | timeCreated: 1672064505 -------------------------------------------------------------------------------- /Editor/Nodes/MainLightData.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using UnityEditor.ShaderGraph; 3 | using UnityEngine; 4 | 5 | namespace z3y.BuiltIn.ShaderGraph.Nodes 6 | { 7 | [Title("z3y", "Main Light Data")] 8 | class MainLightDataNode : CodeFunctionNode 9 | { 10 | public MainLightDataNode() 11 | { 12 | name = "Main Light"; 13 | } 14 | 15 | public override bool hasPreview => false; 16 | 17 | protected override MethodInfo GetFunctionToConvert() 18 | { 19 | return GetType().GetMethod("Node_GetMainLightData", BindingFlags.Static | BindingFlags.NonPublic); 20 | } 21 | 22 | static string Node_GetMainLightData( 23 | [Slot(0, Binding.None)] out UnityEngine.Vector3 Color, 24 | [Slot(1, Binding.None)] out UnityEngine.Vector3 Direction, 25 | [Slot(3, Binding.None)] out UnityEngine.Vector3 AverageDirection, 26 | [Slot(2, Binding.None)] out Vector1 Attenuation, 27 | [Slot(4, Binding.WorldSpacePosition)] in Vector3 PositionWS 28 | ) 29 | { 30 | Color = default; 31 | Direction = default; 32 | AverageDirection = default; 33 | return 34 | @" 35 | { 36 | #if defined(SHADERGRAPH_PREVIEW) 37 | Color = 0.5; 38 | Direction = normalize(float3(1, 1, 0)); 39 | AverageDirection = normalize(float3(1, 1, 0)); 40 | Attenuation = 1.0; 41 | #elif SHADERPASS == SHADERPASS_UNLIT 42 | Color = _LightColor0.rgb; 43 | Direction = Unity_SafeNormalize(UnityWorldSpaceLightDir(PositionWS)); 44 | AverageDirection = Direction; 45 | Attenuation = 1; 46 | #elif (defined(UNITY_PASS_FORWARDBASE) || defined(UNITY_PASS_FORWARDADD)) && !defined(SHADERGRAPH_PREVIEW) 47 | UnityLightData lightData = GetCustomMainLightData(staticVaryings); 48 | Color = lightData.color; 49 | Direction = Unity_SafeNormalize(UnityWorldSpaceLightDir(PositionWS)); 50 | Attenuation = lightData.attenuation; 51 | #if !defined(LIGHTMAP_ON) && defined(UNITY_PASS_FORWARDBASE) 52 | half3 lightProbeDirection = unity_SHAr.xyz + unity_SHAg.xyz + unity_SHAb.xyz; 53 | //AverageDirection = normalize(lerp(Direction + lightProbeDirection, Direction, saturate(dot(Color, 1.0)))); 54 | AverageDirection = normalize(Direction + lightProbeDirection); 55 | #else 56 | AverageDirection = Direction; 57 | #endif 58 | #endif 59 | } 60 | "; 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Editor/Nodes/MainLightData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c1798d5de229664ebf3a78482fbc31c 3 | timeCreated: 1671565630 -------------------------------------------------------------------------------- /Editor/Nodes/Outline.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 98d7d6d9898f9684394ffc169c55fee6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Nodes/Outline/OutlinePassNode.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using UnityEditor.ShaderGraph; 3 | 4 | namespace z3y.BuiltIn.ShaderGraph.Nodes 5 | { 6 | [Title("z3y", "Outline", "Pass Define")] 7 | class OutlinePassNode : CodeFunctionNode 8 | { 9 | public OutlinePassNode() 10 | { 11 | name = "Outline Pass"; 12 | } 13 | 14 | protected override MethodInfo GetFunctionToConvert() 15 | { 16 | return GetType().GetMethod("OutlinePassSwitch", BindingFlags.Static | BindingFlags.NonPublic); 17 | } 18 | 19 | 20 | static string OutlinePassSwitch( 21 | [Slot(0, Binding.None)] in DynamicDimensionVector True, 22 | [Slot(1, Binding.None)] in DynamicDimensionVector False, 23 | [Slot(2, Binding.None)] out DynamicDimensionVector Out) 24 | { 25 | return 26 | @" 27 | { 28 | #if (SHADERPASS == SHADERPASS_OUTLINE) && !defined(SHADERGRAPH_PREVIEW) 29 | Out = True; 30 | #else 31 | Out = False; 32 | #endif 33 | } 34 | "; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Editor/Nodes/Outline/OutlinePassNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f16dacabcf88f0f4b8ecdd56e854e03b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Nodes/Outline/OutlinePositionOffsetNode.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using UnityEditor.ShaderGraph; 3 | using UnityEngine; 4 | 5 | namespace z3y.BuiltIn.ShaderGraph.Nodes 6 | { 7 | [Title("z3y", "Outline", "Scale")] 8 | class OutlinePositionScaleNode : CodeFunctionNode 9 | { 10 | public OutlinePositionScaleNode() 11 | { 12 | name = "Outline Scale"; 13 | } 14 | 15 | protected override MethodInfo GetFunctionToConvert() 16 | { 17 | return GetType().GetMethod("OutlinePositionScaleFunction", BindingFlags.Static | BindingFlags.NonPublic); 18 | } 19 | 20 | public override PreviewMode previewMode => PreviewMode.Preview3D; 21 | 22 | static string OutlinePositionScaleFunction( 23 | [Slot(0, Binding.ObjectSpaceNormal)] in Vector3 Normal, 24 | [Slot(1, Binding.ObjectSpacePosition)] in Vector3 Position, 25 | [Slot(2, Binding.None, 0.1f, 0.1f, 0.1f, 0.1f)] in Vector1 Scale, 26 | [Slot(3, Binding.None)] out Vector3 PositionOS) 27 | { 28 | PositionOS = default; 29 | return 30 | @" 31 | { 32 | #if ((SHADERPASS == SHADERPASS_OUTLINE) && !defined(SHADERGRAPH_PREVIEW)) || defined(UNITY_PASS_SHADOWCASTER) 33 | PositionOS = Position + (Normal * Scale); 34 | #else 35 | PositionOS = Position; 36 | #endif 37 | } 38 | "; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Editor/Nodes/Outline/OutlinePositionOffsetNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 82fbb28d4b736d84ea8d72cae01115d4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/Nodes/RealBranchNode.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using UnityEditor.ShaderGraph; 3 | 4 | namespace z3y.BuiltIn.ShaderGraph.Nodes 5 | { 6 | [Title("Utility", "Logic", "Real Branch")] 7 | class RealBranchNode : CodeFunctionNode 8 | { 9 | public RealBranchNode() 10 | { 11 | name = "Real Branch"; 12 | } 13 | 14 | protected override MethodInfo GetFunctionToConvert() 15 | { 16 | return GetType().GetMethod("Real_BranchNode", BindingFlags.Static | BindingFlags.NonPublic); 17 | } 18 | 19 | 20 | static string Real_BranchNode( 21 | [Slot(0, Binding.None)] in Boolean Predicate, 22 | [Slot(1, Binding.None, 1,1,1,1)] in DynamicDimensionVector True, 23 | [Slot(2, Binding.None)] in DynamicDimensionVector False, 24 | [Slot(3, Binding.None)] out DynamicDimensionVector Out) 25 | { 26 | return 27 | @" 28 | { 29 | UNITY_BRANCH 30 | if (Predicate) Out = True; 31 | else Out = False; 32 | } 33 | "; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Editor/Nodes/RealBranchNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5977114b7b7d4a81b8d6a68155d409dd 3 | timeCreated: 1672064505 -------------------------------------------------------------------------------- /Editor/Nodes/SubGraphs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e00dff7ba7de9b749b7c20ad3a37a93b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Nodes/SubGraphs/Shadow Layer.shadersubgraph.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a568525fb5d83542b32578bb98ca63d 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3} 11 | -------------------------------------------------------------------------------- /Editor/Nodes/VRChatIsInMirrorNode.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using UnityEditor.ShaderGraph; 3 | 4 | namespace z3y.BuiltIn.ShaderGraph.Nodes 5 | { 6 | [Title("VRChat", "In Mirror")] 7 | class VRChatIsInMirrorNode : CodeFunctionNode 8 | { 9 | public VRChatIsInMirrorNode() 10 | { 11 | name = "VRC Mirror"; 12 | } 13 | 14 | public override bool hasPreview => false; 15 | 16 | protected override MethodInfo GetFunctionToConvert() 17 | { 18 | return GetType().GetMethod("VRChat_IsInMirrorNode", BindingFlags.Static | BindingFlags.NonPublic); 19 | } 20 | 21 | 22 | static string VRChat_IsInMirrorNode( 23 | [Slot(0, Binding.None)] out Boolean NotInMirror, 24 | [Slot(1, Binding.None)] out Boolean InMirrorVR, 25 | [Slot(2, Binding.None)] out Boolean InMirrorDesktop) 26 | { 27 | return 28 | @" 29 | { 30 | NotInMirror = _VRChatMirrorMode == 0; 31 | InMirrorVR = _VRChatMirrorMode == 1; 32 | InMirrorDesktop = _VRChatMirrorMode == 2; 33 | } 34 | "; 35 | } 36 | 37 | public override void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode) 38 | { 39 | registry.ProvideFunction("_VRChatMirrorMode", builder => 40 | { 41 | builder.Append("half _VRChatMirrorMode;"); 42 | }); 43 | base.GenerateNodeFunction(registry, generationMode); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /Editor/Nodes/VRChatIsInMirrorNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ac92c127b944461ae70a417a0ebe63b 3 | timeCreated: 1671565630 -------------------------------------------------------------------------------- /Editor/ShaderGraph.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 59ae617cc21ff68419b02ee267b6c41f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/AssetCallbacks.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 88ee3e487f150714cafc3bd5277d068d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/AssetCallbacks/CreateLitShaderGraph.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEditor.ShaderGraph; 4 | using UnityEngine.Rendering; 5 | 6 | namespace z3y.BuiltIn.ShaderGraph 7 | { 8 | static class CreateLitShaderGraph 9 | { 10 | [MenuItem("Assets/Create/Shader Graph/BuiltIn VRC/Lit Shader Graph", priority = CoreUtils.Sections.section1 + CoreUtils.Priorities.assetsCreateShaderMenuPriority)] 11 | public static void CreateLitGraph() 12 | { 13 | //var target = (BuiltInTarget)Activator.CreateInstance(typeof(BuiltInTarget)); 14 | BuiltInTarget target; 15 | BlockFieldDescriptor[] blockDescriptors; 16 | CreateBaseLitShader(out target, out blockDescriptors); 17 | 18 | var lit = (BuiltInLitSubTarget)target.activeSubTarget; 19 | lit.specular = true; 20 | GraphUtil.CreateNewGraphWithOutputs(new[] { target }, blockDescriptors); 21 | } 22 | 23 | [MenuItem("Assets/Create/Shader Graph/BuiltIn VRC/Flat-Lit Shader Graph", priority = CoreUtils.Sections.section1 + CoreUtils.Priorities.assetsCreateShaderMenuPriority)] 24 | public static void CreateFlatLitGraph() 25 | { 26 | //var target = (BuiltInTarget)Activator.CreateInstance(typeof(BuiltInTarget)); 27 | BuiltInTarget target; 28 | BlockFieldDescriptor[] blockDescriptors; 29 | CreateBaseLitShader(out target, out blockDescriptors); 30 | 31 | var lit = (BuiltInLitSubTarget)target.activeSubTarget; 32 | lit.specular = false; 33 | lit.flatLit = true; 34 | 35 | GraphUtil.CreateNewGraphWithOutputs(new[] { target }, blockDescriptors); 36 | } 37 | 38 | 39 | private static void CreateBaseLitShader(out BuiltInTarget target, out BlockFieldDescriptor[] blockDescriptors) 40 | { 41 | target = new BuiltInTarget(); 42 | target.TrySetActiveSubTarget(typeof(BuiltInLitSubTarget)); 43 | target.allowMaterialOverride = true; 44 | 45 | blockDescriptors = new[] 46 | { 47 | BlockFields.VertexDescription.Position, 48 | BlockFields.VertexDescription.Normal, 49 | BlockFields.VertexDescription.Tangent, 50 | BlockFields.SurfaceDescription.BaseColor, 51 | BlockFields.SurfaceDescription.NormalTS, 52 | BlockFields.SurfaceDescription.Metallic, 53 | BlockFields.SurfaceDescription.Smoothness, 54 | BlockFields.SurfaceDescription.Emission, 55 | BlockFields.SurfaceDescription.Occlusion, 56 | BlockFields.SurfaceDescription.AlphaClipThreshold, 57 | BlockFields.SurfaceDescription.Alpha, 58 | BuiltInLitSubTarget.AdditionalSurfaceDescription.Reflectance, 59 | BuiltInLitSubTarget.AdditionalSurfaceDescription.SpecularOcclusion, 60 | }; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/AssetCallbacks/CreateLitShaderGraph.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da26bf7b606d071428d3ae99d6671a64 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/AssetCallbacks/CreateUnlitShaderGraph.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEditor.ShaderGraph; 4 | using UnityEngine.Rendering; 5 | 6 | namespace z3y.BuiltIn.ShaderGraph 7 | { 8 | static class CreateUnlitShaderGraph 9 | { 10 | [MenuItem("Assets/Create/Shader Graph/BuiltIn VRC/Unlit Shader Graph", priority = CoreUtils.Sections.section1 + CoreUtils.Priorities.assetsCreateShaderMenuPriority)] 11 | public static void CreateUnlitGraph() 12 | { 13 | //var target = (BuiltInTarget)Activator.CreateInstance(typeof(BuiltInTarget)); 14 | var target = new BuiltInTarget(); 15 | target.TrySetActiveSubTarget(typeof(BuiltInUnlitSubTarget)); 16 | 17 | target.vrcFallbackTags.type = VRCFallbackTags.ShaderType.Unlit; 18 | target.allowMaterialOverride = true; 19 | 20 | var blockDescriptors = new[] 21 | { 22 | BlockFields.VertexDescription.Position, 23 | BlockFields.VertexDescription.Normal, 24 | BlockFields.VertexDescription.Tangent, 25 | BlockFields.SurfaceDescription.BaseColor, 26 | BlockFields.SurfaceDescription.Alpha, 27 | BlockFields.SurfaceDescription.AlphaClipThreshold, 28 | }; 29 | 30 | GraphUtil.CreateNewGraphWithOutputs(new[] { target }, blockDescriptors); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/AssetCallbacks/CreateUnlitShaderGraph.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 138054a871bb86242a80d59dc316d898 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/BuiltInFields.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor.ShaderGraph; 2 | 3 | namespace z3y.BuiltIn.ShaderGraph 4 | { 5 | internal static class BuiltInFields 6 | { 7 | #region Tags 8 | public const string kFeatures = "features"; 9 | public const string kSurfaceType = "SurfaceType"; 10 | public const string kBlendMode = "BlendMode"; 11 | #endregion 12 | 13 | #region Fields 14 | // TODO: figure which ones are actually URP only, leave those here and put others shared/core Fields in Fields.cs 15 | public static FieldDescriptor SurfaceOpaque = new FieldDescriptor(kSurfaceType, "Opaque", "_SURFACE_TYPE_OPAQUE 1"); 16 | public static FieldDescriptor SurfaceTransparent = new FieldDescriptor(kSurfaceType, "Transparent", "_SURFACE_TYPE_TRANSPARENT 1"); 17 | public static FieldDescriptor BlendAdd = new FieldDescriptor(kBlendMode, "Add", "_BLENDMODE_ADD 1"); 18 | public static FieldDescriptor BlendPremultiply = new FieldDescriptor(kBlendMode, "Premultiply", "_ALPHAPREMULTIPLY_ON 1"); 19 | public static FieldDescriptor BlendMultiply = new FieldDescriptor(kBlendMode, "Multiply", "_BLENDMODE_MULTIPLY 1"); 20 | public static FieldDescriptor VelocityPrecomputed = new FieldDescriptor(string.Empty, "AddPrecomputedVelocity", "_ADD_PRECOMPUTED_VELOCITY"); 21 | public static FieldDescriptor SpecularSetup = new FieldDescriptor(string.Empty, "SpecularSetup", "_SPECULAR_SETUP"); 22 | public static FieldDescriptor Normal = new FieldDescriptor(string.Empty, "Normal", "_NORMALMAP 1"); 23 | public static FieldDescriptor NormalDropOffTS = new FieldDescriptor(string.Empty, "NormalDropOffTS", "_NORMAL_DROPOFF_TS 1"); 24 | public static FieldDescriptor NormalDropOffOS = new FieldDescriptor(string.Empty, "NormalDropOffOS", "_NORMAL_DROPOFF_OS 1"); 25 | public static FieldDescriptor NormalDropOffWS = new FieldDescriptor(string.Empty, "NormalDropOffWS", "_NORMAL_DROPOFF_WS 1"); 26 | #endregion 27 | 28 | // A predicate is field that has a matching template command, for example: $ 29 | // It is only used to enable/disable in the tempalate 30 | #region Predicates 31 | //public static FieldDescriptor PredicateClearCoat = new FieldDescriptor(string.Empty, "ClearCoat", "_CLEARCOAT 1"); 32 | #endregion 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/BuiltInFields.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da447097da6550440ac3851c8c82b247 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/BuiltInProperties.cs: -------------------------------------------------------------------------------- 1 | using z3y.BuiltIn.ShaderGraph; 2 | using UnityEditor.ShaderGraph; 3 | using UnityEditor.ShaderGraph.Internal; 4 | using System; 5 | 6 | namespace z3y.BuiltIn 7 | { 8 | internal static class Property 9 | { 10 | public static string SpecularWorkflowMode() { return SG_SpecularWorkflowMode; } 11 | public static string Surface() { return SG_Surface; } 12 | public static string Blend() { return SG_Blend; } 13 | public static string AlphaClip() { return SG_AlphaClip; } 14 | public static string SrcBlend() { return SG_SrcBlend; } 15 | public static string DstBlend() { return SG_DstBlend; } 16 | public static string ZWrite() { return SG_ZWrite; } 17 | public static string ZWriteControl() { return SG_ZWriteControl; } 18 | public static string ZTest() { return SG_ZTest; } // no HW equivalent 19 | public static string Cull() { return SG_Cull; } 20 | public static string CastShadows() { return SG_CastShadows; } 21 | public static string ReceiveShadows() { return SG_ReceiveShadows; } 22 | public static string QueueOffset() { return SG_QueueOffset; } 23 | public static string QueueControl() { return SG_QueueControl; } 24 | 25 | // for shadergraph shaders (renamed more uniquely to avoid potential naming collisions with HDRP properties and user properties) 26 | public static readonly string SG_SpecularWorkflowMode = "_WorkflowMode"; 27 | public static readonly string SG_Surface = "_Surface"; 28 | public static readonly string SG_Blend = "_Blend"; 29 | public static readonly string SG_AlphaClip = "_AlphaClip"; 30 | public static readonly string SG_SrcBlend = "_SrcBlend"; 31 | public static readonly string SG_DstBlend = "_DstBlend"; 32 | public static readonly string SG_ZWrite = "_ZWrite"; 33 | public static readonly string SG_ZWriteControl = "_ZWriteControl"; 34 | public static readonly string SG_ZTest = "_ZTest"; 35 | public static readonly string SG_Cull = "_CullMode"; 36 | public static readonly string SG_CastShadows = "_CastShadows"; 37 | public static readonly string SG_ReceiveShadows = "_ReceiveShadows"; 38 | public static readonly string SG_QueueOffset = "_QueueOffset"; 39 | public static readonly string SG_QueueControl = "_QueueControl"; 40 | 41 | // Global Illumination requires some properties to be named specifically: 42 | public static readonly string EmissionMap = "_EmissionMap"; 43 | public static readonly string EmissionColor = "_EmissionColor"; 44 | } 45 | 46 | internal static class Keyword 47 | { 48 | // These should be used to control the above (currently in the template) 49 | public static readonly string SG_ReceiveShadowsOff = "_BUILTIN_RECEIVE_SHADOWS_OFF"; 50 | public static readonly string SG_Emission = "_EMISSION"; 51 | public static readonly string SG_AlphaTestOn = "_ALPHATEST_ON"; 52 | //public static readonly string SG_AlphaClip = "_AlphaClip"; 53 | public static readonly string SG_SurfaceTypeTransparent = "_SURFACE_TYPE_TRANSPARENT"; 54 | public static readonly string SG_AlphaPremultiplyOn = "_ALPHAPREMULTIPLY_ON"; 55 | public static readonly string SG_AlphaModulateOn = "_ALPHAMODULATE_ON"; 56 | } 57 | 58 | internal static class BuiltInMaterialInspectorUtilities 59 | { 60 | internal static void AddFloatProperty(this PropertyCollector collector, string referenceName, float defaultValue, HLSLDeclaration declarationType = HLSLDeclaration.DoNotDeclare) 61 | { 62 | collector.AddShaderProperty(new Vector1ShaderProperty 63 | { 64 | floatType = FloatType.Default, 65 | hidden = true, 66 | overrideHLSLDeclaration = true, 67 | hlslDeclarationOverride = declarationType, 68 | value = defaultValue, 69 | overrideReferenceName = referenceName, 70 | }); 71 | } 72 | 73 | internal static void AddFloatProperty(this PropertyCollector collector, string referenceName, float defaultValue, string displayName) 74 | { 75 | collector.AddShaderProperty(new Vector1ShaderProperty 76 | { 77 | floatType = FloatType.Default, 78 | hidden = false, 79 | overrideHLSLDeclaration = true, 80 | hlslDeclarationOverride = HLSLDeclaration.DoNotDeclare, 81 | value = defaultValue, 82 | overrideReferenceName = referenceName, 83 | displayName = displayName, 84 | }); 85 | } 86 | 87 | internal static void AddFloatSliderProperty(this PropertyCollector collector, string referenceName, float defaultValue, string displayName, UnityEngine.Vector2 rangeValues) 88 | { 89 | collector.AddShaderProperty(new Vector1ShaderProperty 90 | { 91 | floatType = FloatType.Slider, 92 | hidden = false, 93 | overrideHLSLDeclaration = true, 94 | hlslDeclarationOverride = HLSLDeclaration.DoNotDeclare, 95 | value = defaultValue, 96 | overrideReferenceName = referenceName, 97 | displayName = displayName, 98 | rangeValues = rangeValues 99 | }); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/BuiltInProperties.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c29534527746d33498534e552f3b0057 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/BuiltInStructFields.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor.ShaderGraph; 2 | 3 | namespace z3y.BuiltIn.ShaderGraph 4 | { 5 | static class BuiltInStructFields 6 | { 7 | public static void ApplyCentroidVertexColor() 8 | { 9 | StructFields.Varyings.color = new FieldDescriptor(Varyings.name, StructFields.Varyings.color.define, StructFields.Varyings.color.semantic, StructFields.Varyings.color.type,// preprocessor: "defined(VARYINGS_NEED_COLOR)", 10 | subscriptOptions: StructFields.Varyings.color.subscriptOptions, interpolation: "centroid"); 11 | } 12 | 13 | public struct Varyings 14 | { 15 | public static string name = "Varyings"; 16 | public static FieldDescriptor lightmapUV = new FieldDescriptor(name, "lightmapUV", "", ShaderValueType.Float2, preprocessor: "defined(LIGHTMAP_ON) && !defined(DYNAMICLIGHTMAP_ON)", subscriptOptions: StructFieldOptions.Optional, interpolation: "centroid"); 17 | public static FieldDescriptor lightmapUVAndRT = new FieldDescriptor(name, "lightmapUV", "", ShaderValueType.Float4, preprocessor: "defined(LIGHTMAP_ON) && defined(DYNAMICLIGHTMAP_ON)", subscriptOptions: StructFieldOptions.Optional, interpolation: "centroid"); 18 | //public static FieldDescriptor sh = new FieldDescriptor(Varyings.name, "sh", "", ShaderValueType.Float3, preprocessor: "!defined(LIGHTMAP_ON)", subscriptOptions: StructFieldOptions.Optional); 19 | //public static FieldDescriptor fogFactorAndVertexLight = new FieldDescriptor(Varyings.name, "fogFactorAndVertexLight", "VARYINGS_NEED_FOG_AND_VERTEX_LIGHT", ShaderValueType.Float4, subscriptOptions: StructFieldOptions.Optional); 20 | public static FieldDescriptor vertexLight = new FieldDescriptor(name, "vertexLight", "", ShaderValueType.Float3, subscriptOptions: StructFieldOptions.Optional, preprocessor:"defined(VERTEXLIGHT_ON) && !defined(VERTEXLIGHT_PS)"); 21 | public static FieldDescriptor fogCoord = new FieldDescriptor(name, "fogCoord", "", ShaderValueType.Float, subscriptOptions: StructFieldOptions.Optional, preprocessor:"defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2)"); 22 | public static FieldDescriptor shadowCoord = new FieldDescriptor(name, "shadowCoord", "VARYINGS_NEED_SHADOWCOORD", ShaderValueType.Float4, subscriptOptions: StructFieldOptions.Optional); 23 | public static FieldDescriptor editorVisualizationLightCoord = new FieldDescriptor(name, "lightCoord", "", ShaderValueType.Float4, subscriptOptions: StructFieldOptions.Optional, preprocessor:"defined(EDITOR_VISUALIZATION)"); 24 | public static FieldDescriptor editorVisualizationVizUV = new FieldDescriptor(name, "vizUV ", "", ShaderValueType.Float2, subscriptOptions: StructFieldOptions.Optional, preprocessor:"defined(EDITOR_VISUALIZATION)"); 25 | 26 | public static FieldDescriptor stereoTargetEyeIndexAsRTArrayIdx = new FieldDescriptor(name, "stereoTargetEyeIndexAsRTArrayIdx", "", ShaderValueType.Uint, "SV_RenderTargetArrayIndex", "(defined(UNITY_STEREO_INSTANCING_ENABLED))", StructFieldOptions.Generated); 27 | public static FieldDescriptor stereoTargetEyeIndexAsBlendIdx0 = new FieldDescriptor(name, "stereoTargetEyeIndexAsBlendIdx0", "", ShaderValueType.Uint, "BLENDINDICES0", "(defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))"); 28 | /* public static FieldDescriptor color = new FieldDescriptor(Varyings.name, "color", "VARYINGS_NEED_COLOR", ShaderValueType.Float4, preprocessor: "defined(VARYINGS_NEED_COLOR)", 29 | subscriptOptions: StructFieldOptions.Static, interpolation:"centroid");*/ 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/BuiltInStructFields.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e2775a8d30fcd14f825588b3bb3dbb6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/BuiltInStructs.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor.ShaderGraph; 2 | 3 | namespace z3y.BuiltIn.ShaderGraph 4 | { 5 | static class BuiltInStructs 6 | { 7 | public static StructDescriptor Varyings = new StructDescriptor() 8 | { 9 | name = "Varyings", 10 | packFields = true, 11 | populateWithCustomInterpolators = true, 12 | fields = new FieldDescriptor[] 13 | { 14 | StructFields.Varyings.positionCS, 15 | StructFields.Varyings.positionWS, 16 | StructFields.Varyings.normalWS, 17 | StructFields.Varyings.tangentWS, 18 | StructFields.Varyings.texCoord0, 19 | StructFields.Varyings.texCoord1, 20 | StructFields.Varyings.texCoord2, 21 | StructFields.Varyings.texCoord3, 22 | StructFields.Varyings.color, 23 | //BuiltInStructFields.Varyings.color, 24 | //StructFields.Varyings.viewDirectionWS, 25 | StructFields.Varyings.screenPosition, 26 | BuiltInStructFields.Varyings.lightmapUV, 27 | BuiltInStructFields.Varyings.lightmapUVAndRT, 28 | BuiltInStructFields.Varyings.editorVisualizationLightCoord, 29 | BuiltInStructFields.Varyings.editorVisualizationVizUV, 30 | //BuiltInStructFields.Varyings.sh, 31 | //BuiltInStructFields.Varyings.fogFactorAndVertexLight, 32 | BuiltInStructFields.Varyings.vertexLight, 33 | BuiltInStructFields.Varyings.fogCoord, 34 | BuiltInStructFields.Varyings.shadowCoord, 35 | StructFields.Varyings.instanceID, 36 | BuiltInStructFields.Varyings.stereoTargetEyeIndexAsBlendIdx0, 37 | BuiltInStructFields.Varyings.stereoTargetEyeIndexAsRTArrayIdx, 38 | StructFields.Varyings.cullFace, 39 | } 40 | }; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/BuiltInStructs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a3e5b21fe4ec1241a14c9aa236f699a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bac5abc43f516b44f984fcda5d2bf4ac 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/BuildInputData.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_BUILD_INTPUT_DATA_INCLUDED 2 | #define UNITY_BUILD_INTPUT_DATA_INCLUDED 3 | 4 | void BuildInputData(Varyings input, SurfaceDescription surfaceDescription, out InputData inputData) 5 | { 6 | inputData = (InputData)0; 7 | inputData.positionWS = input.positionWS; 8 | 9 | #ifdef _NORMALMAP 10 | #if _NORMAL_DROPOFF_TS 11 | // IMPORTANT! If we ever support Flip on double sided materials ensure bitangent and tangent are NOT flipped. 12 | float crossSign = (input.tangentWS.w > 0.0 ? 1.0 : -1.0) * GetOddNegativeScale(); 13 | float3 bitangent = crossSign * cross(input.normalWS.xyz, input.tangentWS.xyz); 14 | inputData.normalWS = TransformTangentToWorld(surfaceDescription.NormalTS, half3x3(input.tangentWS.xyz, bitangent, input.normalWS.xyz)); 15 | #elif _NORMAL_DROPOFF_OS 16 | inputData.normalWS = TransformObjectToWorldNormal(surfaceDescription.NormalOS); 17 | #elif _NORMAL_DROPOFF_WS 18 | inputData.normalWS = surfaceDescription.NormalWS; 19 | #endif 20 | #else 21 | inputData.normalWS = input.normalWS; 22 | #endif 23 | inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS); 24 | inputData.viewDirectionWS = normalize(UnityWorldSpaceViewDir(inputData.positionWS)); 25 | 26 | #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) 27 | inputData.shadowCoord = input.shadowCoord; 28 | #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS) 29 | inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS); 30 | #else 31 | inputData.shadowCoord = float4(0, 0, 0, 0); 32 | #endif 33 | 34 | // inputData.fogCoord = input.fog; 35 | // inputData.vertexLighting = input.fogFactorAndVertexLight.yzw; 36 | #if defined(LIGHTMAP_ON) 37 | inputData.bakedGI = SAMPLE_GI(input.lightmapUV, input.sh, inputData.normalWS); 38 | inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV); 39 | #endif 40 | inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS); 41 | } 42 | 43 | #endif // UNITY_BUILD_INTPUT_DATA_INCLUDED 44 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/BuildInputData.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ed6dfda31630ac488a75f3385900bb4 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/DepthOnlyPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef SG_DEPTH_ONLY_PASS_INCLUDED 2 | #define SG_DEPTH_ONLY_PASS_INCLUDED 3 | 4 | PackedVaryings vert(Attributes input) 5 | { 6 | Varyings output = (Varyings)0; 7 | output = BuildVaryings(input); 8 | PackedVaryings packedOutput = (PackedVaryings)0; 9 | packedOutput = PackVaryings(output); 10 | return packedOutput; 11 | } 12 | 13 | half4 frag(PackedVaryings packedInput) : SV_TARGET 14 | { 15 | Varyings unpacked = UnpackVaryings(packedInput); 16 | UNITY_SETUP_INSTANCE_ID(unpacked); 17 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 18 | 19 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 20 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 21 | 22 | #if _AlphaClip 23 | clip(surfaceDescription.Alpha - surfaceDescription.AlphaClipThreshold); 24 | #endif 25 | 26 | float4 outColor = 0; 27 | #ifdef SCENESELECTIONPASS 28 | // We use depth prepass for scene selection in the editor, this code allow to output the outline correctly 29 | outColor = float4(_ObjectId, _PassValue, 1.0, 1.0); 30 | #elif defined(SCENEPICKINGPASS) 31 | outColor = _SelectionID; 32 | #endif 33 | 34 | return outColor; 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/DepthOnlyPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e7a374b4b5b6bf4fbb5efa6ec63af20 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/LegacyBuilding.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_LEGACY_BUILDING_INCLUDED 2 | #define UNITY_LEGACY_BUILDING_INCLUDED 3 | 4 | #include "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/SurfaceData.hlsl" 5 | 6 | SurfaceData SurfaceDescriptionToSurfaceData(SurfaceDescription surfaceDescription) 7 | { 8 | #if _AlphaClip 9 | half alpha = surfaceDescription.Alpha; 10 | clip(alpha - surfaceDescription.AlphaClipThreshold); 11 | #elif _SURFACE_TYPE_TRANSPARENT 12 | half alpha = surfaceDescription.Alpha; 13 | #else 14 | half alpha = 1; 15 | #endif 16 | 17 | #ifdef _SPECULAR_SETUP 18 | float3 specular = surfaceDescription.Specular; 19 | float metallic = 1; 20 | #else 21 | float3 specular = 0; 22 | float metallic = surfaceDescription.Metallic; 23 | #endif 24 | 25 | SurfaceData surface = (SurfaceData)0; 26 | surface.albedo = surfaceDescription.BaseColor; 27 | surface.metallic = saturate(metallic); 28 | surface.specular = specular; 29 | surface.smoothness = saturate(surfaceDescription.Smoothness), 30 | surface.occlusion = surfaceDescription.Occlusion, 31 | surface.emission = surfaceDescription.Emission, 32 | surface.alpha = saturate(alpha); 33 | surface.clearCoatMask = 0; 34 | surface.clearCoatSmoothness = 1; 35 | return surface; 36 | } 37 | 38 | SurfaceOutputStandard BuildStandardSurfaceOutput(SurfaceDescription surfaceDescription, InputData inputData) 39 | { 40 | SurfaceData surface = SurfaceDescriptionToSurfaceData(surfaceDescription); 41 | 42 | SurfaceOutputStandard o = (SurfaceOutputStandard)0; 43 | o.Albedo = surface.albedo; 44 | o.Normal = inputData.normalWS; 45 | o.Metallic = surface.metallic; 46 | o.Smoothness = surface.smoothness; 47 | o.Occlusion = surface.occlusion; 48 | o.Emission = surface.emission; 49 | o.Alpha = surface.alpha; 50 | return o; 51 | } 52 | 53 | 54 | #endif // UNITY_LEGACY_BUILDING_INCLUDED 55 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/LegacyBuilding.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e84375567a2baef4abcdac2caed50ba2 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/LegacySurfaceVertex.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_LEGACY_SURFACE_VERTEX 2 | #define UNITY_LEGACY_SURFACE_VERTEX 3 | 4 | struct v2f_surf { 5 | float4 pos;//UNITY_POSITION(pos); 6 | float3 worldNormal;// : TEXCOORD1; 7 | float3 worldPos;// : TEXCOORD2; 8 | float3 viewDir; 9 | float4 lmap;// : TEXCOORD3; 10 | #if UNITY_SHOULD_SAMPLE_SH 11 | half3 sh;// : TEXCOORD3; // SH 12 | #endif 13 | float1 fogCoord; //UNITY_FOG_COORDS(4) 14 | DECLARE_LIGHT_COORDS(4)//unityShadowCoord4 _LightCoord; 15 | UNITY_SHADOW_COORDS(5)//unityShadowCoord4 _ShadowCoord; 16 | 17 | // In SS, if kPassFlagShadowCaster adds V2F_SHADOW_CASTER_NOPOS which is defined as "float3 vec : TEXCOORD0;" 18 | float3 vec; 19 | 20 | //#ifdef DIRLIGHTMAP_COMBINED 21 | float4 tSpace0 : TEXCOORD6; 22 | float4 tSpace1 : TEXCOORD7; 23 | float4 tSpace2 : TEXCOORD8; 24 | //#endif 25 | UNITY_VERTEX_INPUT_INSTANCE_ID 26 | UNITY_VERTEX_OUTPUT_STEREO 27 | }; 28 | 29 | #endif // UNITY_LEGACY_SURFACE_VERTEX 30 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/LegacySurfaceVertex.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1aedf3fb41e0fd140aafcadf800bbb07 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/LightingMetaPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef SG_LIT_META_INCLUDED 2 | #define SG_LIT_META_INCLUDED 3 | 4 | #include "UnityMetaPass.cginc" 5 | #include "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/SurfaceData.hlsl" 6 | 7 | SurfaceData SurfaceDescriptionToSurfaceData(SurfaceDescription surfaceDescription) 8 | { 9 | #if _AlphaClip 10 | half alpha = surfaceDescription.Alpha; 11 | clip(alpha - surfaceDescription.AlphaClipThreshold); 12 | #elif _SURFACE_TYPE_TRANSPARENT 13 | half alpha = surfaceDescription.Alpha; 14 | #else 15 | half alpha = 1; 16 | #endif 17 | 18 | SurfaceData surface = (SurfaceData)0; 19 | surface.albedo = surfaceDescription.BaseColor; 20 | surface.alpha = saturate(alpha); 21 | surface.clearCoatMask = 0; 22 | surface.clearCoatSmoothness = 1; 23 | surface.emission = surfaceDescription.Emission; 24 | return surface; 25 | } 26 | 27 | SurfaceOutputStandard BuildStandardSurfaceOutput(SurfaceDescription surfaceDescription) 28 | { 29 | SurfaceData surface = SurfaceDescriptionToSurfaceData(surfaceDescription); 30 | 31 | SurfaceOutputStandard o = (SurfaceOutputStandard)0; 32 | o.Albedo = surface.albedo; 33 | o.Metallic = surface.metallic; 34 | o.Smoothness = surface.smoothness; 35 | o.Occlusion = surface.occlusion; 36 | o.Emission = surface.emission; 37 | o.Alpha = surface.alpha; 38 | return o; 39 | } 40 | 41 | v2f_surf MetaVertex(appdata_full v) 42 | { 43 | UNITY_SETUP_INSTANCE_ID(v); 44 | v2f_surf o; 45 | UNITY_INITIALIZE_OUTPUT(v2f_surf,o); 46 | UNITY_TRANSFER_INSTANCE_ID(v,o); 47 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 48 | o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST); 49 | #ifdef EDITOR_VISUALIZATION 50 | o.vizUV = 0; 51 | o.lightCoord = 0; 52 | if (unity_VisualizationMode == EDITORVIZ_TEXTURE) 53 | o.vizUV = UnityMetaVizUV(unity_EditorViz_UVIndex, v.texcoord.xy, v.texcoord1.xy, v.texcoord2.xy, unity_EditorViz_Texture_ST); 54 | else if (unity_VisualizationMode == EDITORVIZ_SHOWLIGHTMASK) 55 | { 56 | o.vizUV = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw; 57 | o.lightCoord = mul(unity_EditorViz_WorldToLight, mul(unity_ObjectToWorld, float4(v.vertex.xyz, 1))); 58 | } 59 | #endif 60 | 61 | float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; 62 | float3 worldNormal = UnityObjectToWorldNormal(v.normal); 63 | fixed3 worldTangent = UnityObjectToWorldDir(v.tangent.xyz); 64 | fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w; 65 | fixed3 worldBinormal = cross(worldNormal, worldTangent) * tangentSign; 66 | o.tSpace0 = float4(worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x); 67 | o.tSpace1 = float4(worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y); 68 | o.tSpace2 = float4(worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z); 69 | o.worldPos.xyz = worldPos; 70 | return o; 71 | } 72 | 73 | void MetaVertex(Attributes input, VertexDescription vertexDescription, inout Varyings varyings) 74 | { 75 | appdata_full v; 76 | ZERO_INITIALIZE(appdata_full, v); 77 | BuildAppDataFull(input, vertexDescription, v); 78 | 79 | v2f_surf o = MetaVertex(v); 80 | SurfaceVertexToVaryings(o, varyings); 81 | } 82 | 83 | half4 MetaFragment(v2f_surf IN, SurfaceOutputStandard o) 84 | { 85 | UNITY_SETUP_INSTANCE_ID(IN); 86 | #ifdef FOG_COMBINED_WITH_TSPACE 87 | UNITY_EXTRACT_FOG_FROM_TSPACE(IN); 88 | #elif defined FOG_COMBINED_WITH_WORLD_POS 89 | UNITY_EXTRACT_FOG_FROM_WORLD_POS(IN); 90 | #else 91 | UNITY_EXTRACT_FOG(IN); 92 | #endif 93 | #ifdef FOG_COMBINED_WITH_TSPACE 94 | UNITY_RECONSTRUCT_TBN(IN); 95 | #else 96 | UNITY_EXTRACT_TBN(IN); 97 | #endif 98 | 99 | float3 worldPos = IN.worldPos.xyz;//float3(IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w); 100 | #ifndef USING_DIRECTIONAL_LIGHT 101 | fixed3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos)); 102 | #else 103 | fixed3 lightDir = _WorldSpaceLightPos0.xyz; 104 | #endif 105 | fixed3 normalWorldVertex = fixed3(0,0,1); 106 | 107 | UnityMetaInput metaIN; 108 | UNITY_INITIALIZE_OUTPUT(UnityMetaInput, metaIN); 109 | metaIN.Albedo = o.Albedo; 110 | metaIN.Emission = o.Emission; 111 | #ifdef EDITOR_VISUALIZATION 112 | metaIN.VizUV = IN.vizUV; 113 | metaIN.LightCoord = IN.lightCoord; 114 | #endif 115 | return UnityMetaFragment(metaIN); 116 | } 117 | 118 | half4 MetaFragment(SurfaceDescription surfaceDescription, Varyings varyings) 119 | { 120 | v2f_surf vertexSurf; 121 | ZERO_INITIALIZE(v2f_surf, vertexSurf); 122 | VaryingsToSurfaceVertex(varyings, vertexSurf); 123 | 124 | SurfaceOutputStandard o = BuildStandardSurfaceOutput(surfaceDescription); 125 | return MetaFragment(vertexSurf, o); 126 | } 127 | 128 | PackedVaryings vert(Attributes input) 129 | { 130 | Varyings output; 131 | ZERO_INITIALIZE(Varyings, output); 132 | output = BuildVaryings(input); 133 | 134 | VertexDescriptionInputs vertexDescriptionInputs = BuildVertexDescriptionInputs(input); 135 | VertexDescription vertexDescription = VertexDescriptionFunction(vertexDescriptionInputs); 136 | MetaVertex(input, vertexDescription, output); 137 | 138 | PackedVaryings packedOutput = (PackedVaryings)0; 139 | packedOutput = PackVaryings(output); 140 | return packedOutput; 141 | } 142 | 143 | half4 frag(PackedVaryings packedInput) : SV_TARGET 144 | { 145 | Varyings unpacked = UnpackVaryings(packedInput); 146 | UNITY_SETUP_INSTANCE_ID(unpacked); 147 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 148 | 149 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 150 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 151 | 152 | half4 color = MetaFragment(surfaceDescription, unpacked); 153 | return color; 154 | } 155 | 156 | #endif 157 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/LightingMetaPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df077e0f10cfb0f48ae350bf09a993ec 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/PBRDeferredPass.hlsl: -------------------------------------------------------------------------------- 1 | 2 | #include "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/LegacyBuilding.hlsl" 3 | #include "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/BuildInputData.hlsl" 4 | #include "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/UnityGBuffer.hlsl" 5 | 6 | v2f_surf PBRDeferredVertex(appdata_full v) 7 | { 8 | UNITY_SETUP_INSTANCE_ID(v); 9 | v2f_surf o; 10 | UNITY_INITIALIZE_OUTPUT(v2f_surf,o); 11 | UNITY_TRANSFER_INSTANCE_ID(v,o); 12 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 13 | o.pos = UnityObjectToClipPos(v.vertex); 14 | float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; 15 | float3 worldNormal = UnityObjectToWorldNormal(v.normal); 16 | o.worldPos.xyz = worldPos; 17 | o.worldNormal = worldNormal; 18 | float3 viewDirForLight = UnityWorldSpaceViewDir(worldPos); 19 | #ifndef DIRLIGHTMAP_OFF 20 | o.viewDir = viewDirForLight; 21 | #endif 22 | #ifdef DYNAMICLIGHTMAP_ON 23 | o.lmap.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw; 24 | #else 25 | o.lmap.zw = 0; 26 | #endif 27 | #ifdef LIGHTMAP_ON 28 | o.lmap.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw; 29 | #ifdef DIRLIGHTMAP_OFF 30 | o.lmapFadePos.xyz = (mul(unity_ObjectToWorld, v.vertex).xyz - unity_ShadowFadeCenterAndType.xyz) * unity_ShadowFadeCenterAndType.w; 31 | o.lmapFadePos.w = (-UnityObjectToViewPos(v.vertex).z) * (1.0 - unity_ShadowFadeCenterAndType.w); 32 | #endif 33 | #else 34 | o.lmap.xy = 0; 35 | #if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL 36 | o.sh = 0; 37 | o.sh = ShadeSHPerVertex (worldNormal, o.sh); 38 | #endif 39 | #endif 40 | return o; 41 | } 42 | 43 | void PBRDeferredVertex(Attributes input, VertexDescription vertexDescription, inout Varyings varyings) 44 | { 45 | appdata_full v; 46 | ZERO_INITIALIZE(appdata_full, v); 47 | BuildAppDataFull(input, vertexDescription, v); 48 | 49 | v2f_surf o = PBRDeferredVertex(v); 50 | SurfaceVertexToVaryings(o, varyings); 51 | } 52 | 53 | void PBRDeferredFragment(v2f_surf IN, SurfaceOutputStandard o, 54 | out half4 outGBuffer0 : SV_Target0, 55 | out half4 outGBuffer1 : SV_Target1, 56 | out half4 outGBuffer2 : SV_Target2, 57 | out half4 outEmission : SV_Target3 58 | #if defined(SHADOWS_SHADOWMASK) && (UNITY_ALLOWED_MRT_COUNT > 4) 59 | , out half4 outShadowMask : SV_Target4 60 | #endif 61 | ) 62 | { 63 | UNITY_SETUP_INSTANCE_ID(IN); 64 | // prepare and unpack data 65 | #ifdef FOG_COMBINED_WITH_TSPACE 66 | UNITY_EXTRACT_FOG_FROM_TSPACE(IN); 67 | #elif defined FOG_COMBINED_WITH_WORLD_POS 68 | UNITY_EXTRACT_FOG_FROM_WORLD_POS(IN); 69 | #else 70 | UNITY_EXTRACT_FOG(IN); 71 | #endif 72 | float3 worldPos = IN.worldPos.xyz; 73 | #ifndef USING_DIRECTIONAL_LIGHT 74 | fixed3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos)); 75 | #else 76 | fixed3 lightDir = _WorldSpaceLightPos0.xyz; 77 | #endif 78 | float3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos)); 79 | 80 | fixed3 normalWorldVertex = fixed3(0,0,1); 81 | 82 | normalWorldVertex = IN.worldNormal; 83 | 84 | // call surface function 85 | 86 | fixed3 originalNormal = o.Normal; 87 | half atten = 1; 88 | 89 | // Setup lighting environment 90 | UnityGI gi; 91 | UNITY_INITIALIZE_OUTPUT(UnityGI, gi); 92 | gi.indirect.diffuse = 0; 93 | gi.indirect.specular = 0; 94 | gi.light.color = 0; 95 | gi.light.dir = half3(0,1,0); 96 | // Call GI (lightmaps/SH/reflections) lighting function 97 | UnityGIInput giInput; 98 | UNITY_INITIALIZE_OUTPUT(UnityGIInput, giInput); 99 | giInput.light = gi.light; 100 | giInput.worldPos = worldPos; 101 | giInput.worldViewDir = worldViewDir; 102 | giInput.atten = atten; 103 | #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON) 104 | giInput.lightmapUV = IN.lmap; 105 | #else 106 | giInput.lightmapUV = 0.0; 107 | #endif 108 | #if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL 109 | giInput.ambient = IN.sh; 110 | #else 111 | giInput.ambient.rgb = 0.0; 112 | #endif 113 | giInput.probeHDR[0] = unity_SpecCube0_HDR; 114 | giInput.probeHDR[1] = unity_SpecCube1_HDR; 115 | #if defined(UNITY_SPECCUBE_BLENDING) || defined(UNITY_SPECCUBE_BOX_PROJECTION) 116 | giInput.boxMin[0] = unity_SpecCube0_BoxMin; // .w holds lerp value for blending 117 | #endif 118 | #ifdef UNITY_SPECCUBE_BOX_PROJECTION 119 | giInput.boxMax[0] = unity_SpecCube0_BoxMax; 120 | giInput.probePosition[0] = unity_SpecCube0_ProbePosition; 121 | giInput.boxMax[1] = unity_SpecCube1_BoxMax; 122 | giInput.boxMin[1] = unity_SpecCube1_BoxMin; 123 | giInput.probePosition[1] = unity_SpecCube1_ProbePosition; 124 | #endif 125 | LightingStandard_GI(o, giInput, gi); 126 | 127 | // call lighting function to output g-buffer 128 | outEmission = LightingStandard_Deferred (o, worldViewDir, gi, outGBuffer0, outGBuffer1, outGBuffer2); 129 | #if defined(SHADOWS_SHADOWMASK) && (UNITY_ALLOWED_MRT_COUNT > 4) 130 | outShadowMask = UnityGetRawBakedOcclusions (IN.lmap.xy, worldPos); 131 | #endif 132 | #ifndef UNITY_HDR_ON 133 | outEmission.rgb = exp2(-outEmission.rgb); 134 | #endif 135 | } 136 | 137 | FragmentOutput PBRDeferredFragment(SurfaceDescription surfaceDescription, InputData inputData, Varyings varyings) 138 | { 139 | v2f_surf vertexSurf; 140 | ZERO_INITIALIZE(v2f_surf, vertexSurf); 141 | VaryingsToSurfaceVertex(varyings, vertexSurf); 142 | 143 | SurfaceOutputStandard o = BuildStandardSurfaceOutput(surfaceDescription, inputData); 144 | FragmentOutput result; 145 | PBRDeferredFragment(vertexSurf, o, result.GBuffer0, result.GBuffer1, result.GBuffer2, result.GBuffer3 146 | #if OUTPUT_SHADOWMASK 147 | , result.GBuffer4 148 | #endif 149 | ); 150 | return result; 151 | } 152 | 153 | PackedVaryings vert(Attributes input) 154 | { 155 | Varyings output; 156 | ZERO_INITIALIZE(Varyings, output); 157 | output = BuildVaryings(input); 158 | 159 | VertexDescriptionInputs vertexDescriptionInputs = BuildVertexDescriptionInputs(input); 160 | VertexDescription vertexDescription = VertexDescriptionFunction(vertexDescriptionInputs); 161 | PBRDeferredVertex(input, vertexDescription, output); 162 | 163 | PackedVaryings packedOutput = (PackedVaryings)0; 164 | packedOutput = PackVaryings(output); 165 | return packedOutput; 166 | } 167 | 168 | FragmentOutput frag(PackedVaryings packedInput) 169 | { 170 | Varyings unpacked = UnpackVaryings(packedInput); 171 | UNITY_SETUP_INSTANCE_ID(unpacked); 172 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 173 | 174 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 175 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 176 | 177 | InputData inputData; 178 | BuildInputData(unpacked, surfaceDescription, inputData); 179 | 180 | return PBRDeferredFragment(surfaceDescription, inputData, unpacked); 181 | } 182 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/PBRDeferredPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 943d0e7e4040b7642aa32bee8ebab0b7 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/PBRForwardAddPass.hlsl: -------------------------------------------------------------------------------- 1 | 2 | #include "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/LegacyBuilding.hlsl" 3 | #include "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/BuildInputData.hlsl" 4 | 5 | v2f_surf PBRForwardAddVertex(appdata_full v) 6 | { 7 | UNITY_SETUP_INSTANCE_ID(v); 8 | v2f_surf o; 9 | UNITY_INITIALIZE_OUTPUT(v2f_surf,o); 10 | UNITY_TRANSFER_INSTANCE_ID(v,o); 11 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 12 | 13 | o.pos = UnityObjectToClipPos(v.vertex); 14 | float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; 15 | float3 worldNormal = UnityObjectToWorldNormal(v.normal); 16 | o.worldPos.xyz = worldPos; 17 | o.worldNormal = worldNormal; 18 | 19 | UNITY_TRANSFER_LIGHTING(o,v.texcoord1.xy); // pass shadow and, possibly, light cookie coordinates to pixel shader 20 | UNITY_TRANSFER_FOG(o,o.pos); // pass fog coordinates to pixel shader 21 | return o; 22 | } 23 | 24 | void PBRForwardAddVertex(Attributes input, VertexDescription vertexDescription, inout Varyings varyings) 25 | { 26 | appdata_full v; 27 | ZERO_INITIALIZE(appdata_full, v); 28 | BuildAppDataFull(input, vertexDescription, v); 29 | 30 | v2f_surf o = PBRForwardAddVertex(v); 31 | SurfaceVertexToVaryings(o, varyings); 32 | } 33 | 34 | half4 PBRForwardAddFragment(v2f_surf vertexSurf, SurfaceOutputStandard o) 35 | { 36 | v2f_surf IN = vertexSurf; 37 | UNITY_SETUP_INSTANCE_ID(IN); 38 | 39 | #ifdef FOG_COMBINED_WITH_TSPACE 40 | UNITY_EXTRACT_FOG_FROM_TSPACE(IN); 41 | #elif defined FOG_COMBINED_WITH_WORLD_POS 42 | UNITY_EXTRACT_FOG_FROM_WORLD_POS(IN); 43 | #else 44 | UNITY_EXTRACT_FOG(IN); 45 | #endif 46 | 47 | float3 worldPos = IN.worldPos.xyz; 48 | #ifndef USING_DIRECTIONAL_LIGHT 49 | fixed3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos)); 50 | #else 51 | fixed3 lightDir = _WorldSpaceLightPos0.xyz; 52 | #endif 53 | float3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos)); 54 | 55 | fixed3 normalWorldVertex = fixed3(0,0,1); 56 | normalWorldVertex = IN.worldNormal; 57 | 58 | UNITY_LIGHT_ATTENUATION(atten, IN, worldPos) 59 | fixed4 c = 0; 60 | 61 | // Setup lighting environment 62 | UnityGI gi; 63 | UNITY_INITIALIZE_OUTPUT(UnityGI, gi); 64 | gi.indirect.diffuse = 0; 65 | gi.indirect.specular = 0; 66 | gi.light.color = _LightColor0.rgb; 67 | gi.light.dir = lightDir; 68 | gi.light.color *= atten; 69 | c += LightingStandard (o, worldViewDir, gi); 70 | 71 | UNITY_APPLY_FOG(_unity_fogCoord, c); // apply fog 72 | #ifndef _SURFACE_TYPE_TRANSPARENT 73 | UNITY_OPAQUE_ALPHA(c.a); 74 | #endif 75 | return c; 76 | } 77 | 78 | half4 PBRForwardAddFragment(SurfaceDescription surfaceDescription, InputData inputData, Varyings varyings) 79 | { 80 | v2f_surf vertexSurf; 81 | ZERO_INITIALIZE(v2f_surf, vertexSurf); 82 | VaryingsToSurfaceVertex(varyings, vertexSurf); 83 | 84 | SurfaceOutputStandard o = BuildStandardSurfaceOutput(surfaceDescription, inputData); 85 | return PBRForwardAddFragment(vertexSurf, o); 86 | } 87 | 88 | PackedVaryings vert(Attributes input) 89 | { 90 | Varyings output; 91 | ZERO_INITIALIZE(Varyings, output); 92 | output = BuildVaryings(input); 93 | 94 | VertexDescriptionInputs vertexDescriptionInputs = BuildVertexDescriptionInputs(input); 95 | VertexDescription vertexDescription = VertexDescriptionFunction(vertexDescriptionInputs); 96 | PBRForwardAddVertex(input, vertexDescription, output); 97 | 98 | PackedVaryings packedOutput = (PackedVaryings)0; 99 | packedOutput = PackVaryings(output); 100 | return packedOutput; 101 | } 102 | 103 | half4 frag(PackedVaryings packedInput) : SV_TARGET 104 | { 105 | Varyings unpacked = UnpackVaryings(packedInput); 106 | UNITY_SETUP_INSTANCE_ID(unpacked); 107 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 108 | 109 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 110 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 111 | 112 | InputData inputData; 113 | BuildInputData(unpacked, surfaceDescription, inputData); 114 | 115 | half4 color = PBRForwardAddFragment(surfaceDescription, inputData, unpacked); 116 | return color; 117 | } 118 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/PBRForwardAddPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c0a86922e8eadc04cbd7ef24710dca57 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/PBRForwardPass.hlsl: -------------------------------------------------------------------------------- 1 | 2 | #include "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/LegacyBuilding.hlsl" 3 | #include "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/BuildInputData.hlsl" 4 | 5 | v2f_surf PBRStandardVertex(appdata_full v) 6 | { 7 | UNITY_SETUP_INSTANCE_ID(v); 8 | v2f_surf o; 9 | UNITY_INITIALIZE_OUTPUT(v2f_surf,o); 10 | UNITY_TRANSFER_INSTANCE_ID(v,o); 11 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 12 | 13 | o.pos = UnityObjectToClipPos(v.vertex); 14 | float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; 15 | float3 worldNormal = UnityObjectToWorldNormal(v.normal); 16 | #if defined(LIGHTMAP_ON) && defined(DIRLIGHTMAP_COMBINED) 17 | fixed3 worldTangent = UnityObjectToWorldDir(v.tangent.xyz); 18 | fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w; 19 | fixed3 worldBinormal = cross(worldNormal, worldTangent) * tangentSign; 20 | #endif 21 | #if defined(LIGHTMAP_ON) && defined(DIRLIGHTMAP_COMBINED) && !defined(UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS) 22 | o.tSpace0 = float4(worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x); 23 | o.tSpace1 = float4(worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y); 24 | o.tSpace2 = float4(worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z); 25 | #endif 26 | o.worldPos.xyz = worldPos; 27 | o.worldNormal = worldNormal; 28 | #ifdef DYNAMICLIGHTMAP_ON 29 | o.lmap.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw; 30 | #endif 31 | #ifdef LIGHTMAP_ON 32 | o.lmap.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw; 33 | #endif 34 | 35 | // SH/ambient and vertex lights 36 | #ifndef LIGHTMAP_ON 37 | #if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL 38 | o.sh = 0; 39 | // Approximated illumination from non-important point lights 40 | #ifdef VERTEXLIGHT_ON 41 | o.sh += Shade4PointLights ( 42 | unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, 43 | unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb, 44 | unity_4LightAtten0, worldPos, worldNormal); 45 | #endif 46 | o.sh = ShadeSHPerVertex (worldNormal, o.sh); 47 | #endif 48 | #endif // !LIGHTMAP_ON 49 | 50 | UNITY_TRANSFER_LIGHTING(o,v.texcoord1.xy); // pass shadow and, possibly, light cookie coordinates to pixel shader 51 | #ifdef FOG_COMBINED_WITH_TSPACE 52 | UNITY_TRANSFER_FOG_COMBINED_WITH_TSPACE(o,o.pos); // pass fog coordinates to pixel shader 53 | #elif defined FOG_COMBINED_WITH_WORLD_POS 54 | UNITY_TRANSFER_FOG_COMBINED_WITH_WORLD_POS(o,o.pos); // pass fog coordinates to pixel shader 55 | #else 56 | UNITY_TRANSFER_FOG(o,o.pos); // pass fog coordinates to pixel shader 57 | #endif 58 | return o; 59 | } 60 | 61 | void PBRStandardVertex(Attributes input, VertexDescription vertexDescription, inout Varyings varyings) 62 | { 63 | appdata_full v; 64 | ZERO_INITIALIZE(appdata_full, v); 65 | BuildAppDataFull(input, vertexDescription, v); 66 | 67 | v2f_surf o = PBRStandardVertex(v); 68 | SurfaceVertexToVaryings(o, varyings); 69 | } 70 | 71 | half4 PBRStandardFragment(v2f_surf vertexSurf, SurfaceOutputStandard o) 72 | { 73 | v2f_surf IN = vertexSurf; 74 | UNITY_SETUP_INSTANCE_ID(IN); 75 | 76 | #ifdef FOG_COMBINED_WITH_TSPACE 77 | UNITY_EXTRACT_FOG_FROM_TSPACE(IN); 78 | #elif defined FOG_COMBINED_WITH_WORLD_POS 79 | UNITY_EXTRACT_FOG_FROM_WORLD_POS(IN); 80 | #else 81 | UNITY_EXTRACT_FOG(IN); 82 | #endif 83 | 84 | float3 worldPos = IN.worldPos.xyz; 85 | #ifndef USING_DIRECTIONAL_LIGHT 86 | fixed3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos)); 87 | #else 88 | fixed3 lightDir = _WorldSpaceLightPos0.xyz; 89 | #endif 90 | float3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos)); 91 | 92 | fixed3 normalWorldVertex = fixed3(0,0,1); 93 | normalWorldVertex = IN.worldNormal; 94 | 95 | // compute lighting & shadowing factor 96 | UNITY_LIGHT_ATTENUATION(atten, IN, worldPos) 97 | fixed4 c = 0; 98 | 99 | // Setup lighting environment 100 | UnityGI gi; 101 | UNITY_INITIALIZE_OUTPUT(UnityGI, gi); 102 | gi.indirect.diffuse = 0; 103 | gi.indirect.specular = 0; 104 | gi.light.color = _LightColor0.rgb; 105 | gi.light.dir = lightDir; 106 | // Call GI (lightmaps/SH/reflections) lighting function 107 | UnityGIInput giInput; 108 | UNITY_INITIALIZE_OUTPUT(UnityGIInput, giInput); 109 | giInput.light = gi.light; 110 | giInput.worldPos = worldPos; 111 | giInput.worldViewDir = worldViewDir; 112 | giInput.atten = atten; 113 | #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON) 114 | giInput.lightmapUV = IN.lmap; 115 | #else 116 | giInput.lightmapUV = 0.0; 117 | #endif 118 | #if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL 119 | giInput.ambient = IN.sh; 120 | #else 121 | giInput.ambient.rgb = 0.0; 122 | #endif 123 | giInput.probeHDR[0] = unity_SpecCube0_HDR; 124 | giInput.probeHDR[1] = unity_SpecCube1_HDR; 125 | #if defined(UNITY_SPECCUBE_BLENDING) || defined(UNITY_SPECCUBE_BOX_PROJECTION) 126 | giInput.boxMin[0] = unity_SpecCube0_BoxMin; // .w holds lerp value for blending 127 | #endif 128 | #ifdef UNITY_SPECCUBE_BOX_PROJECTION 129 | giInput.boxMax[0] = unity_SpecCube0_BoxMax; 130 | giInput.probePosition[0] = unity_SpecCube0_ProbePosition; 131 | giInput.boxMax[1] = unity_SpecCube1_BoxMax; 132 | giInput.boxMin[1] = unity_SpecCube1_BoxMin; 133 | giInput.probePosition[1] = unity_SpecCube1_ProbePosition; 134 | #endif 135 | LightingStandard_GI(o, giInput, gi); 136 | 137 | // realtime lighting: call lighting function 138 | c += LightingStandard (o, worldViewDir, gi); 139 | c.rgb += o.Emission; 140 | UNITY_APPLY_FOG(_unity_fogCoord, c); // apply fog 141 | #ifndef _SURFACE_TYPE_TRANSPARENT 142 | UNITY_OPAQUE_ALPHA(c.a); 143 | #endif 144 | return c; 145 | } 146 | 147 | half4 PBRStandardFragment(SurfaceDescription surfaceDescription, InputData inputData, Varyings varyings) 148 | { 149 | v2f_surf vertexSurf; 150 | ZERO_INITIALIZE(v2f_surf, vertexSurf); 151 | VaryingsToSurfaceVertex(varyings, vertexSurf); 152 | 153 | SurfaceOutputStandard o = BuildStandardSurfaceOutput(surfaceDescription, inputData); 154 | return PBRStandardFragment(vertexSurf, o); 155 | } 156 | 157 | PackedVaryings vert(Attributes input) 158 | { 159 | Varyings output; 160 | ZERO_INITIALIZE(Varyings, output); 161 | output = BuildVaryings(input); 162 | 163 | VertexDescriptionInputs vertexDescriptionInputs = BuildVertexDescriptionInputs(input); 164 | VertexDescription vertexDescription = VertexDescriptionFunction(vertexDescriptionInputs); 165 | PBRStandardVertex(input, vertexDescription, output); 166 | 167 | PackedVaryings packedOutput = (PackedVaryings)0; 168 | packedOutput = PackVaryings(output); 169 | return packedOutput; 170 | } 171 | 172 | half4 frag(PackedVaryings packedInput) : SV_TARGET 173 | { 174 | Varyings unpacked = UnpackVaryings(packedInput); 175 | UNITY_SETUP_INSTANCE_ID(unpacked); 176 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 177 | 178 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 179 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 180 | 181 | InputData inputData; 182 | BuildInputData(unpacked, surfaceDescription, inputData); 183 | 184 | half4 color = PBRStandardFragment(surfaceDescription, inputData, unpacked); 185 | return color; 186 | } 187 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/PBRForwardPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7382139251017d4d96c35fbcb2b1d22 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/PBRGBufferPass.hlsl: -------------------------------------------------------------------------------- 1 | void BuildInputData(Varyings input, SurfaceDescription surfaceDescription, out InputData inputData) 2 | { 3 | inputData.positionWS = input.positionWS; 4 | #ifdef _NORMALMAP 5 | 6 | #if _NORMAL_DROPOFF_TS 7 | // IMPORTANT! If we ever support Flip on double sided materials ensure bitangent and tangent are NOT flipped. 8 | float crossSign = (input.tangentWS.w > 0.0 ? 1.0 : -1.0) * GetOddNegativeScale(); 9 | float3 bitangent = crossSign * cross(input.normalWS.xyz, input.tangentWS.xyz); 10 | inputData.normalWS = TransformTangentToWorld(surfaceDescription.NormalTS, half3x3(input.tangentWS.xyz, bitangent, input.normalWS.xyz)); 11 | #elif _NORMAL_DROPOFF_OS 12 | inputData.normalWS = TransformObjectToWorldNormal(surfaceDescription.NormalOS); 13 | #elif _NORMAL_DROPOFF_WS 14 | inputData.normalWS = surfaceDescription.NormalWS; 15 | #endif 16 | #else 17 | inputData.normalWS = input.normalWS; 18 | #endif 19 | inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS); 20 | inputData.viewDirectionWS = SafeNormalize(input.viewDirectionWS); 21 | 22 | #if defined(MAIN_LIGHT_CALCULATE_SHADOWS) 23 | inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS); 24 | #else 25 | inputData.shadowCoord = float4(0, 0, 0, 0); 26 | #endif 27 | 28 | inputData.fogCoord = input.fogFactorAndVertexLight.x; 29 | inputData.vertexLighting = input.fogFactorAndVertexLight.yzw; 30 | inputData.bakedGI = SAMPLE_GI(input.lightmapUV, input.sh, inputData.normalWS); 31 | inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS); 32 | inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV); 33 | } 34 | 35 | PackedVaryings vert(Attributes input) 36 | { 37 | Varyings output = (Varyings)0; 38 | output = BuildVaryings(input); 39 | PackedVaryings packedOutput = (PackedVaryings)0; 40 | packedOutput = PackVaryings(output); 41 | return packedOutput; 42 | } 43 | 44 | FragmentOutput frag(PackedVaryings packedInput) 45 | { 46 | Varyings unpacked = UnpackVaryings(packedInput); 47 | UNITY_SETUP_INSTANCE_ID(unpacked); 48 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 49 | 50 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 51 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 52 | 53 | #if _AlphaClip 54 | half alpha = surfaceDescription.Alpha; 55 | clip(alpha - surfaceDescription.AlphaClipThreshold); 56 | #elif _SURFACE_TYPE_TRANSPARENT 57 | half alpha = surfaceDescription.Alpha; 58 | #else 59 | half alpha = 1; 60 | #endif 61 | 62 | InputData inputData; 63 | BuildInputData(unpacked, surfaceDescription, inputData); 64 | 65 | #ifdef _SPECULAR_SETUP 66 | float3 specular = surfaceDescription.Specular; 67 | float metallic = 1; 68 | #else 69 | float3 specular = 0; 70 | float metallic = surfaceDescription.Metallic; 71 | #endif 72 | 73 | // in LitForwardPass GlobalIllumination (and temporarily LightingPhysicallyBased) are called inside BuiltInFragmentPBR 74 | // in Deferred rendering we store the sum of these values (and of emission as well) in the GBuffer 75 | BRDFData brdfData; 76 | InitializeBRDFData(surfaceDescription.BaseColor, metallic, specular, surfaceDescription.Smoothness, alpha, brdfData); 77 | 78 | Light mainLight = GetMainLight(inputData.shadowCoord, inputData.positionWS, inputData.shadowMask); 79 | MixRealtimeAndBakedGI(mainLight, inputData.normalWS, inputData.bakedGI, inputData.shadowMask); 80 | half3 color = GlobalIllumination(brdfData, inputData.bakedGI, surfaceDescription.Occlusion, inputData.normalWS, inputData.viewDirectionWS); 81 | 82 | return BRDFDataToGbuffer(brdfData, inputData, surfaceDescription.Smoothness, surfaceDescription.Emission + color, surfaceDescription.Occlusion); 83 | } 84 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/PBRGBufferPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 581c133072f09b742bcea238ed51dcd6 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/ShaderPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef BUILTIN_SHADERPASS_INCLUDED 2 | #define BUILTIN_SHADERPASS_INCLUDED 3 | 4 | #define SHADERPASS_FORWARD (0) 5 | #define SHADERPASS_GBUFFER (1) 6 | #define SHADERPASS_DEPTHONLY (2) 7 | #define SHADERPASS_SHADOWCASTER (3) 8 | #define SHADERPASS_META (4) 9 | #define SHADERPASS_UNLIT (5) 10 | #define SHADERPASS_SPRITELIT (6) 11 | #define SHADERPASS_SPRITENORMAL (7) 12 | #define SHADERPASS_SPRITEFORWARD (8) 13 | #define SHADERPASS_SPRITEUNLIT (9) 14 | #endif 15 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/ShaderPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c13698abbd309f41931df0c47d2bc36 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/ShadowCasterPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef SG_SHADOW_PASS_INCLUDED 2 | #define SG_SHADOW_PASS_INCLUDED 3 | 4 | v2f_surf ShadowCasterVertex(appdata_full v) 5 | { 6 | UNITY_SETUP_INSTANCE_ID(v); 7 | v2f_surf o; 8 | UNITY_INITIALIZE_OUTPUT(v2f_surf,o); 9 | UNITY_TRANSFER_INSTANCE_ID(v,o); 10 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); 11 | 12 | float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; 13 | float3 worldNormal = UnityObjectToWorldNormal(v.normal); 14 | o.worldPos.xyz = worldPos; 15 | TRANSFER_SHADOW_CASTER_NORMALOFFSET(o) 16 | return o; 17 | } 18 | 19 | void ShadowCasterVertex(Attributes input, VertexDescription vertexDescription, inout Varyings varyings) 20 | { 21 | appdata_full v; 22 | ZERO_INITIALIZE(appdata_full, v); 23 | BuildAppDataFull(input, vertexDescription, v); 24 | 25 | v2f_surf o = ShadowCasterVertex(v); 26 | SurfaceVertexToVaryings(o, varyings); 27 | } 28 | 29 | half4 ShadowCasterFragment(v2f_surf IN) 30 | { 31 | UNITY_SETUP_INSTANCE_ID(IN); 32 | #ifdef FOG_COMBINED_WITH_TSPACE 33 | UNITY_EXTRACT_FOG_FROM_TSPACE(IN); 34 | #elif defined FOG_COMBINED_WITH_WORLD_POS 35 | UNITY_EXTRACT_FOG_FROM_WORLD_POS(IN); 36 | #else 37 | UNITY_EXTRACT_FOG(IN); 38 | #endif 39 | float3 worldPos = IN.worldPos.xyz; 40 | #ifndef USING_DIRECTIONAL_LIGHT 41 | fixed3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos)); 42 | #else 43 | fixed3 lightDir = _WorldSpaceLightPos0.xyz; 44 | #endif 45 | fixed3 normalWorldVertex = fixed3(0,0,1); 46 | 47 | SHADOW_CASTER_FRAGMENT(IN) 48 | } 49 | 50 | half4 ShadowCasterFragment(Varyings varyings) 51 | { 52 | v2f_surf vertexSurf; 53 | ZERO_INITIALIZE(v2f_surf, vertexSurf); 54 | VaryingsToSurfaceVertex(varyings, vertexSurf); 55 | 56 | return ShadowCasterFragment(vertexSurf); 57 | } 58 | 59 | PackedVaryings vert(Attributes input) 60 | { 61 | Varyings output; 62 | ZERO_INITIALIZE(Varyings, output); 63 | output = BuildVaryings(input); 64 | 65 | VertexDescriptionInputs vertexDescriptionInputs = BuildVertexDescriptionInputs(input); 66 | VertexDescription vertexDescription = VertexDescriptionFunction(vertexDescriptionInputs); 67 | ShadowCasterVertex(input, vertexDescription, output); 68 | 69 | PackedVaryings packedOutput = (PackedVaryings)0; 70 | packedOutput = PackVaryings(output); 71 | return packedOutput; 72 | } 73 | 74 | half4 frag(PackedVaryings packedInput) : SV_TARGET 75 | { 76 | Varyings unpacked = UnpackVaryings(packedInput); 77 | UNITY_SETUP_INSTANCE_ID(unpacked); 78 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 79 | 80 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 81 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 82 | 83 | #if _AlphaClip 84 | half alpha = surfaceDescription.Alpha; 85 | clip(alpha - surfaceDescription.AlphaClipThreshold); 86 | #endif 87 | 88 | half4 color = ShadowCasterFragment(unpacked); 89 | return color; 90 | } 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/ShadowCasterPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81f39e64625461345b68ecea55d07cda 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/SpriteUnlitPass.hlsl: -------------------------------------------------------------------------------- 1 | half4 _RendererColor; 2 | 3 | PackedVaryings vert(Attributes input) 4 | { 5 | Varyings output = (Varyings)0; 6 | output = BuildVaryings(input); 7 | output.color *= _RendererColor; 8 | PackedVaryings packedOutput = PackVaryings(output); 9 | return packedOutput; 10 | } 11 | 12 | half4 frag(PackedVaryings packedInput) : SV_TARGET 13 | { 14 | Varyings unpacked = UnpackVaryings(packedInput); 15 | UNITY_SETUP_INSTANCE_ID(unpacked); 16 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 17 | 18 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 19 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 20 | 21 | #ifdef BUILTIN_USELEGACYSPRITEBLOCKS 22 | half4 color = surfaceDescription.SpriteColor; 23 | #else 24 | half4 color = half4(surfaceDescription.BaseColor, surfaceDescription.Alpha); 25 | #endif 26 | 27 | color *= unpacked.color; 28 | return color; 29 | } 30 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/SpriteUnlitPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e3e44f62d327fd42bde9719e8d8e8f4 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/UnlitPass.hlsl: -------------------------------------------------------------------------------- 1 | PackedVaryings vert(Attributes input) 2 | { 3 | Varyings output = (Varyings)0; 4 | output = BuildVaryings(input); 5 | PackedVaryings packedOutput = PackVaryings(output); 6 | return packedOutput; 7 | } 8 | 9 | half4 frag(PackedVaryings packedInput) : SV_TARGET 10 | { 11 | Varyings unpacked = UnpackVaryings(packedInput); 12 | UNITY_SETUP_INSTANCE_ID(unpacked); 13 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 14 | 15 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 16 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 17 | 18 | #if _AlphaClip 19 | half alpha = surfaceDescription.Alpha; 20 | clip(alpha - surfaceDescription.AlphaClipThreshold); 21 | #elif _SURFACE_TYPE_TRANSPARENT 22 | half alpha = surfaceDescription.Alpha; 23 | #else 24 | half alpha = 1; 25 | #endif 26 | 27 | #ifdef _ALPHAPREMULTIPLY_ON 28 | surfaceDescription.BaseColor *= alpha; 29 | #endif 30 | 31 | return half4(surfaceDescription.BaseColor, alpha); 32 | } 33 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/UnlitPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8fa9eca682523524da8ee53c00ae717a 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/Varyings.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef BUILTIN_TARGET_API 2 | #if (SHADERPASS == SHADERPASS_SHADOWCASTER) 3 | // Shadow Casting Light geometric parameters. These variables are used when applying the shadow Normal Bias and are set by UnityEngine.Rendering.Universal.ShadowUtils.SetupShadowCasterConstantBuffer in com.unity.render-pipelines.universal/Runtime/ShadowUtils.cs 4 | // For Directional lights, _LightDirection is used when applying shadow Normal Bias. 5 | // For Spot lights and Point lights, _LightPosition is used to compute the actual light direction because it is different at each shadow caster geometry vertex. 6 | float3 _LightDirection; 7 | float3 _LightPosition; 8 | #endif 9 | #endif 10 | 11 | Varyings BuildVaryings(Attributes input) 12 | { 13 | Varyings output = (Varyings)0; 14 | 15 | UNITY_SETUP_INSTANCE_ID(input); 16 | UNITY_TRANSFER_INSTANCE_ID(input, output); 17 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); 18 | 19 | #if defined(FEATURES_GRAPH_VERTEX) 20 | // Evaluate Vertex Graph 21 | VertexDescriptionInputs vertexDescriptionInputs = BuildVertexDescriptionInputs(input); 22 | VertexDescription vertexDescription = VertexDescriptionFunction(vertexDescriptionInputs); 23 | 24 | #if defined(CUSTOMINTERPOLATOR_VARYPASSTHROUGH_FUNC) 25 | CustomInterpolatorPassThroughFunc(output, vertexDescription); 26 | #endif 27 | 28 | // Assign modified vertex attributes 29 | input.positionOS = vertexDescription.Position; 30 | #if defined(VARYINGS_NEED_NORMAL_WS) 31 | input.normalOS = vertexDescription.Normal; 32 | #endif //FEATURES_GRAPH_NORMAL 33 | #if defined(VARYINGS_NEED_TANGENT_WS) 34 | input.tangentOS.xyz = vertexDescription.Tangent.xyz; 35 | #endif //FEATURES GRAPH TANGENT 36 | #endif //FEATURES_GRAPH_VERTEX 37 | 38 | // TODO: Avoid path via VertexPositionInputs (BuiltIn) 39 | VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz); 40 | 41 | // Returns the camera relative position (if enabled) 42 | float3 positionWS = TransformObjectToWorld(input.positionOS); 43 | 44 | #ifdef ATTRIBUTES_NEED_NORMAL 45 | float3 normalWS = TransformObjectToWorldNormal(input.normalOS); 46 | #else 47 | // Required to compile ApplyVertexModification that doesn't use normal. 48 | float3 normalWS = float3(0.0, 0.0, 0.0); 49 | #endif 50 | 51 | #ifdef ATTRIBUTES_NEED_TANGENT 52 | float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w); 53 | #endif 54 | 55 | // TODO: Change to inline ifdef 56 | // Do vertex modification in camera relative space (if enabled) 57 | #if defined(HAVE_VERTEX_MODIFICATION) 58 | ApplyVertexModification(input, normalWS, positionWS, _TimeParameters.xyz); 59 | #endif 60 | 61 | #ifdef VARYINGS_NEED_POSITION_WS 62 | output.positionWS = positionWS; 63 | #endif 64 | 65 | #ifdef VARYINGS_NEED_NORMAL_WS 66 | output.normalWS = normalWS; // normalized in TransformObjectToWorldNormal() 67 | #endif 68 | 69 | #ifdef VARYINGS_NEED_TANGENT_WS 70 | output.tangentWS = tangentWS; // normalized in TransformObjectToWorldDir() 71 | #endif 72 | 73 | // Handled by the legacy pipeline 74 | #ifndef BUILTIN_TARGET_API 75 | #if (SHADERPASS == SHADERPASS_SHADOWCASTER) 76 | // Define shadow pass specific clip position for BuiltIn 77 | #if _CASTING_PUNCTUAL_LIGHT_SHADOW 78 | float3 lightDirectionWS = normalize(_LightPosition - positionWS); 79 | #else 80 | float3 lightDirectionWS = _LightDirection; 81 | #endif 82 | output.positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDirectionWS)); 83 | #if UNITY_REVERSED_Z 84 | output.positionCS.z = min(output.positionCS.z, UNITY_NEAR_CLIP_VALUE); 85 | #else 86 | output.positionCS.z = max(output.positionCS.z, UNITY_NEAR_CLIP_VALUE); 87 | #endif 88 | #elif (SHADERPASS == SHADERPASS_META) 89 | output.positionCS = MetaVertexPosition(float4(input.positionOS, 0), input.uv1, input.uv2, unity_LightmapST, unity_DynamicLightmapST); 90 | #else 91 | output.positionCS = TransformWorldToHClip(positionWS); 92 | #endif 93 | #else 94 | output.positionCS = TransformWorldToHClip(positionWS); 95 | #endif 96 | 97 | #if defined(VARYINGS_NEED_TEXCOORD0) || defined(VARYINGS_DS_NEED_TEXCOORD0) 98 | output.texCoord0 = input.uv0; 99 | #endif 100 | #if defined(VARYINGS_NEED_TEXCOORD1) || defined(VARYINGS_DS_NEED_TEXCOORD1) 101 | output.texCoord1 = input.uv1; 102 | #endif 103 | #if defined(VARYINGS_NEED_TEXCOORD2) || defined(VARYINGS_DS_NEED_TEXCOORD2) 104 | output.texCoord2 = input.uv2; 105 | #endif 106 | #if defined(VARYINGS_NEED_TEXCOORD3) || defined(VARYINGS_DS_NEED_TEXCOORD3) 107 | output.texCoord3 = input.uv3; 108 | #endif 109 | 110 | #if defined(VARYINGS_NEED_COLOR) || defined(VARYINGS_DS_NEED_COLOR) 111 | output.color = input.color; 112 | #endif 113 | 114 | #ifdef VARYINGS_NEED_VIEWDIRECTION_WS 115 | output.viewDirectionWS = GetWorldSpaceViewDir(positionWS); 116 | #endif 117 | 118 | #ifdef VARYINGS_NEED_SCREENPOSITION 119 | output.screenPosition = vertexInput.positionNDC; 120 | #endif 121 | 122 | // Handled by the legacy pipeline 123 | #ifndef BUILTIN_TARGET_API 124 | #if (SHADERPASS == SHADERPASS_FORWARD) || (SHADERPASS == SHADERPASS_GBUFFER) 125 | OUTPUT_LIGHTMAP_UV(input.uv1, unity_LightmapST, output.lightmapUV); 126 | OUTPUT_SH(normalWS, output.sh); 127 | #endif 128 | #ifdef VARYINGS_NEED_FOG_AND_VERTEX_LIGHT 129 | half3 vertexLight = VertexLighting(positionWS, normalWS); 130 | half fogFactor = ComputeFogFactor(output.positionCS.z); 131 | output.fogFactorAndVertexLight = half4(fogFactor, vertexLight); 132 | #endif 133 | #endif 134 | 135 | #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) 136 | output.shadowCoord = GetShadowCoord(vertexInput); 137 | #endif 138 | 139 | return output; 140 | } 141 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Includes/Varyings.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87be70d25d85f8b479001ded499d82fb 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Inspector.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7eb01a79b14cedc4380bacb82b33d3df 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Inspector/BaseShaderGUI.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a619583bf634d0d46aaa53d9fcfb334b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Inspector/BuiltInLitGUI.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace z3y.BuiltIn.ShaderGraph 4 | { 5 | // Currently this is just the base shader gui, but was put in place in case they're separate later 6 | public class BuiltInLitGUI : BuiltInBaseShaderGUI 7 | { 8 | public static void UpdateMaterial(Material material) 9 | { 10 | SetupSurface(material); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Inspector/BuiltInLitGUI.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4714e7ad8b1374842b3d0c9017f50da2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Inspector/BuiltInUnlitGUI.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace z3y.BuiltIn.ShaderGraph 4 | { 5 | // Currently this is just the base shader gui, but was put in place in case they're separate later 6 | public class BuiltInUnlitGUI : BuiltInBaseShaderGUI 7 | { 8 | public static void UpdateMaterial(Material material) 9 | { 10 | SetupSurface(material); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Inspector/BuiltInUnlitGUI.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0244922def866ea4ba7efce5fc19149b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Targets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fee37c7a6824a344eab0a22522d1c9d9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Targets/BuiltInLitSubTarget.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: abffa6af2d0406140b707b5cf48edc42 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Targets/BuiltInSubTarget.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEditor.Rendering.BuiltIn; 3 | using UnityEditor.Rendering.BuiltIn.ShaderGraph; 4 | using UnityEditor.ShaderGraph; 5 | using UnityEngine; 6 | using static UnityEditor.Rendering.BuiltIn.ShaderUtils; 7 | 8 | namespace z3y.BuiltIn.ShaderGraph 9 | { 10 | abstract class BuiltInSubTarget : SubTarget, IHasMetadata 11 | { 12 | static readonly GUID kSourceCodeGuid = new GUID("d1e7332d56ab0fd42b58c47b03ad1500"); // BuiltInSubTarget.cs 13 | 14 | public override void Setup(ref TargetSetupContext context) 15 | { 16 | context.AddAssetDependency(kSourceCodeGuid, AssetCollection.Flags.SourceDependency); 17 | } 18 | 19 | protected abstract ShaderID shaderID { get; } 20 | 21 | public virtual string identifier => GetType().Name; 22 | public virtual ScriptableObject GetMetadataObject(GraphDataReadOnly graph) 23 | { 24 | var bultInMetadata = ScriptableObject.CreateInstance(); 25 | bultInMetadata.shaderID = shaderID; 26 | return bultInMetadata; 27 | } 28 | 29 | public override object saveContext 30 | { 31 | get 32 | { 33 | // Currently all SG properties are duplicated inside the material, so changing a value on the SG does not 34 | // impact any already created material 35 | bool needsUpdate = false; 36 | return new BuiltInShaderGraphSaveContext { updateMaterials = needsUpdate }; 37 | } 38 | } 39 | } 40 | 41 | internal static class SubShaderUtils 42 | { 43 | // Overloads to do inline PassDescriptor modifications 44 | // NOTE: param order should match PassDescriptor field order for consistency 45 | #region PassVariant 46 | internal static PassDescriptor PassVariant(in PassDescriptor source, PragmaCollection pragmas) 47 | { 48 | var result = source; 49 | result.pragmas = pragmas; 50 | return result; 51 | } 52 | 53 | #endregion 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Targets/BuiltInSubTarget.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d1e7332d56ab0fd42b58c47b03ad1500 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Targets/BuiltInTarget.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d0a134923fab594581784302f860efb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Targets/BuiltInUnlitSubTarget.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections.Generic; 4 | using UnityEditor; 5 | using UnityEditor.Rendering.BuiltIn.ShaderGraph; 6 | using UnityEngine; 7 | using UnityEditor.ShaderGraph; 8 | using UnityEngine.Rendering; 9 | using UnityEditor.UIElements; 10 | using UnityEngine.UIElements; 11 | using UnityEditor.ShaderGraph.Legacy; 12 | using static UnityEditor.Rendering.BuiltIn.ShaderUtils; 13 | 14 | namespace z3y.BuiltIn.ShaderGraph 15 | { 16 | sealed class BuiltInUnlitSubTarget : BuiltInSubTarget 17 | { 18 | static readonly GUID kSourceCodeGuid = new GUID("665766aefd1f8ca4c99e8bf6e4c4a988"); // BuiltInUnlitSubTarget.cs 19 | 20 | public BuiltInUnlitSubTarget() 21 | { 22 | displayName = "Unlit"; 23 | } 24 | 25 | protected override ShaderID shaderID => ShaderID.SG_Unlit; 26 | 27 | public override bool IsActive() => true; 28 | 29 | public override void Setup(ref TargetSetupContext context) 30 | { 31 | context.AddAssetDependency(kSourceCodeGuid, AssetCollection.Flags.SourceDependency); 32 | 33 | if (!context.HasCustomEditorForRenderPipeline("") && string.IsNullOrEmpty(target.customEditorGUI)) 34 | { 35 | context.AddCustomEditorForRenderPipeline(typeof(BuiltInUnlitGUI).FullName, ""); 36 | } 37 | 38 | // Process SubShaders 39 | context.AddSubShader(SubShaders.Unlit(target, target.renderType, target.renderQueue)); 40 | } 41 | 42 | public override void ProcessPreviewMaterial(Material material) 43 | { 44 | if (target.allowMaterialOverride) 45 | { 46 | // copy our target's default settings into the material 47 | // (technically not necessary since we are always recreating the material from the shader each time, 48 | // which will pull over the defaults from the shader definition) 49 | // but if that ever changes, this will ensure the defaults are set 50 | material.SetFloat(Property.Surface(), (float)target.surfaceType); 51 | material.SetFloat(Property.Blend(), (float)target.alphaMode); 52 | material.SetFloat(Property.AlphaClip(), target.alphaClip ? 1.0f : 0.0f); 53 | material.SetFloat(Property.Cull(), (int)target.renderFace); 54 | material.SetFloat(Property.ZWriteControl(), (float)target.zWriteControl); 55 | material.SetFloat(Property.ZTest(), (float)target.zTestMode); 56 | } 57 | 58 | // We always need these properties regardless of whether the material is allowed to override 59 | // Queue control & offset enable correct automatic render queue behavior 60 | // Control == 0 is automatic, 1 is user-specified render queue 61 | material.SetFloat(Property.QueueOffset(), 0.0f); 62 | material.SetFloat(Property.QueueControl(), (float)BuiltInBaseShaderGUI.QueueControl.Auto); 63 | 64 | // call the full unlit material setup function 65 | BuiltInUnlitGUI.UpdateMaterial(material); 66 | } 67 | 68 | public override void GetFields(ref TargetFieldContext context) 69 | { 70 | } 71 | 72 | public override void GetActiveBlocks(ref TargetActiveBlockContext context) 73 | { 74 | context.AddBlock(BlockFields.SurfaceDescription.Alpha, (target.surfaceType == SurfaceType.Transparent || target.alphaClip) || target.allowMaterialOverride); 75 | context.AddBlock(BlockFields.SurfaceDescription.AlphaClipThreshold, target.alphaClip || target.allowMaterialOverride); 76 | 77 | /*context.AddBlock(CoreBlockMasks.VertexDescriptionOutline.Position, target.generateOutlinePass); 78 | context.AddBlock(CoreBlockMasks.SurfaceDescriptionOutline.BaseColor, target.generateOutlinePass);*/ 79 | } 80 | 81 | public override void CollectShaderProperties(PropertyCollector collector, GenerationMode generationMode) 82 | { 83 | if (target.allowMaterialOverride) 84 | { 85 | base.CollectShaderProperties(collector, generationMode); 86 | 87 | // setup properties using the defaults 88 | collector.AddFloatProperty(Property.Surface(), (float)target.surfaceType); 89 | collector.AddFloatProperty(Property.Blend(), (float)target.alphaMode); 90 | collector.AddFloatProperty(Property.AlphaClip(), target.alphaClip ? 1.0f : 0.0f); 91 | collector.AddFloatProperty(Property.SrcBlend(), 1.0f); // always set by material inspector (TODO : get src/dst blend and set here?) 92 | collector.AddFloatProperty(Property.DstBlend(), 0.0f); // always set by material inspector 93 | collector.AddFloatProperty(Property.ZWrite(), (target.surfaceType == SurfaceType.Opaque) ? 1.0f : 0.0f); 94 | collector.AddFloatProperty(Property.ZWriteControl(), (float)target.zWriteControl); 95 | collector.AddFloatProperty(Property.ZTest(), (float)target.zTestMode); // ztest mode is designed to directly pass as ztest 96 | collector.AddFloatProperty(Property.Cull(), (float)target.renderFace); // render face enum is designed to directly pass as a cull mode 97 | } 98 | 99 | // We always need these properties regardless of whether the material is allowed to override other shader properties. 100 | // Queue control & offset enable correct automatic render queue behavior. Control == 0 is automatic, 1 is user-specified. 101 | // We initialize queue control to -1 to indicate to UpdateMaterial that it needs to initialize it properly on the material. 102 | collector.AddFloatProperty(Property.QueueOffset(), 0.0f); 103 | collector.AddFloatProperty(Property.QueueControl(), -1.0f); 104 | } 105 | 106 | public override void GetPropertiesGUI(ref TargetPropertyGUIContext context, Action onChange, Action registerUndo) 107 | { 108 | // show the target default surface properties 109 | var builtInTarget = (target as BuiltInTarget); 110 | builtInTarget?.AddDefaultMaterialOverrideGUI(ref context, onChange, registerUndo); 111 | //builtInTarget?.GetDefaultSurfacePropertiesGUI(ref context, onChange, registerUndo); 112 | var properties = new GraphInspectorGUI(context, onChange, registerUndo); 113 | properties.Draw(target); 114 | } 115 | 116 | #region SubShader 117 | static class SubShaders 118 | { 119 | public static SubShaderDescriptor Unlit(BuiltInTarget target, string renderType, string renderQueue) 120 | { 121 | var result = new SubShaderDescriptor() 122 | { 123 | //pipelineTag = UniversalTarget.kPipelineTag, 124 | customTags = target.AppendAdditionalTags(BuiltInTarget.kUnlitMaterialTypeTag), 125 | renderType = renderType, 126 | renderQueue = renderQueue, 127 | generatesPreview = true, 128 | passes = new PassCollection() 129 | }; 130 | 131 | if (target.grabPass) // TODO: check and disable for android 132 | { 133 | result.passes.Add(CorePasses.GrabPassDescriptor(target)); 134 | } 135 | 136 | var basePass = UnlitPasses.Unlit(target); 137 | if (target.alphaToMask) 138 | { 139 | CoreRenderStates.AppendAlphaToMask(target, basePass.renderStates); 140 | } 141 | 142 | if (target.generateOutlinePass && target.generateOutlineEarly) 143 | { 144 | result.passes.Add(CorePasses.OutlineDescriptor(basePass, target)); 145 | } 146 | result.passes.Add(basePass); 147 | if (target.generateOutlinePass && !target.generateOutlineEarly) 148 | { 149 | result.passes.Add(CorePasses.OutlineDescriptor(basePass, target)); 150 | } 151 | result.passes.Add(CorePasses.ShadowCaster(target)); 152 | 153 | return result; 154 | } 155 | } 156 | #endregion 157 | 158 | #region Pass 159 | static class UnlitPasses 160 | { 161 | public static PassDescriptor Unlit(BuiltInTarget target) 162 | { 163 | var renderStates = CoreRenderStates.Default(target); 164 | if (target.stencilEnabled) 165 | { 166 | renderStates = CoreRenderStates.CopyAndAppendStencil(target, renderStates); 167 | } 168 | 169 | var requiredFields = new FieldCollection() 170 | { 171 | BuiltInStructFields.Varyings.fogCoord, 172 | StructFields.Varyings.positionWS 173 | }; 174 | 175 | var result = new PassDescriptor 176 | { 177 | // Definition 178 | displayName = "Pass", 179 | referenceName = "SHADERPASS_UNLIT", 180 | lightMode = "ForwardBase", 181 | useInPreview = true, 182 | 183 | // Template 184 | passTemplatePath = BuiltInTarget.kTemplatePath, 185 | sharedTemplateDirectories = BuiltInTarget.kSharedTemplateDirectories, 186 | 187 | // Port Mask 188 | validVertexBlocks = CoreBlockMasks.Vertex, 189 | validPixelBlocks = CoreBlockMasks.FragmentColorAlpha, 190 | 191 | // Fields 192 | structs = CoreStructCollections.Default, 193 | fieldDependencies = CoreFieldDependencies.Default, 194 | requiredFields = requiredFields, 195 | 196 | // Conditional State 197 | renderStates = renderStates, 198 | pragmas = CorePragmas.ForwardUnlit, // i guess we need keywords for certain things to work, so not ForwardUnlit 199 | defines = new DefineCollection(), 200 | keywords = new KeywordCollection(), 201 | includes = UnlitIncludes.Unlit, 202 | 203 | // Custom Interpolator Support 204 | customInterpolators = CoreCustomInterpDescriptors.Common 205 | }; 206 | BuiltInLitSubTarget.LitKeywords.DeclareAndAppend(ref result, "ALPHATOCOVERAGE_ON", true, target.alphaToMask); 207 | 208 | CorePasses.AddTargetSurfaceControlsToPass(ref result, target); 209 | return result; 210 | } 211 | } 212 | #endregion 213 | 214 | #region Keywords 215 | static class UnlitKeywords 216 | { 217 | public static KeywordCollection Unlit(BuiltInTarget target) 218 | { 219 | var result = new KeywordCollection 220 | { 221 | 222 | }; 223 | 224 | return result; 225 | } 226 | } 227 | #endregion 228 | 229 | #region Includes 230 | static class UnlitIncludes 231 | { 232 | const string kUnlitFragment = "Packages/io.z3y.github.shadergraph/ShaderLibrary/FragmentUnlit.hlsl"; 233 | 234 | public static IncludeCollection Unlit = new IncludeCollection 235 | { 236 | // Pre-graph 237 | { CoreIncludes.CorePregraph }, 238 | { CoreIncludes.ShaderGraphPregraph }, 239 | 240 | // Post-graph 241 | { CoreIncludes.CorePostgraph }, 242 | { kUnlitFragment, IncludeLocation.Postgraph }, 243 | }; 244 | } 245 | #endregion 246 | } 247 | } 248 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Targets/BuiltInUnlitSubTarget.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 665766aefd1f8ca4c99e8bf6e4c4a988 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Targets/GraphInspectorGUI.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8561f7509a4e4034ab997b94411be126 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Templates.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cfef032d6d982f44b8ee90f1f38ac297 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Templates/GrabPass.template: -------------------------------------------------------------------------------- 1 | GrabPass { "_CameraOpaqueTexture" } -------------------------------------------------------------------------------- /Editor/ShaderGraph/Templates/GrabPass.template.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0daaabef7564633468fcc09ce3fb8a1e 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Templates/ShaderPass.template: -------------------------------------------------------------------------------- 1 | Pass 2 | { 3 | $splice(PassName) 4 | Tags 5 | { 6 | $splice(LightMode) 7 | } 8 | 9 | // Render State 10 | $splice(RenderState) 11 | 12 | // Debug 13 | $splice(Debug) 14 | 15 | // -------------------------------------------------- 16 | // Pass 17 | 18 | HLSLPROGRAM 19 | #define PIPELINE_BUILTIN 20 | #define GENERATION_GRAPH 21 | 22 | // Pragmas 23 | $splice(PassPragmas) 24 | 25 | $splice(DotsInstancingOptions) 26 | $splice(HybridV1InjectedBuiltinProperties) 27 | 28 | $splice(GraphKeywords) 29 | 30 | // Keywords 31 | $splice(GraphDefines) 32 | $splice(PassKeywords) 33 | 34 | // Defines 35 | $SurfaceType.Transparent: // UBER SHADER NOW: #define _SURFACE_TYPE_TRANSPARENT 1 36 | $AlphaClip: // UBER SHADER NOW: #define _AlphaClip 1 37 | $Normal: #define _NORMALMAP 1 38 | $BlendMode.Add: // UBER SHADER NOW: #define _BLENDMODE_ADD 1 39 | $BlendMode.Premultiply: // UBER SHADER NOW: #define _ALPHAPREMULTIPLY_ON 1 40 | $SpecularSetup: #define _SPECULAR_SETUP 41 | $NormalDropOffTS: #define _NORMAL_DROPOFF_TS 1 42 | $NormalDropOffOS: #define _NORMAL_DROPOFF_OS 1 43 | $NormalDropOffWS: #define _NORMAL_DROPOFF_WS 1 44 | $Attributes.normalOS: #define ATTRIBUTES_NEED_NORMAL 45 | $Attributes.tangentOS: #define ATTRIBUTES_NEED_TANGENT 46 | $Attributes.uv0: #define ATTRIBUTES_NEED_TEXCOORD0 47 | $Attributes.uv1: #define ATTRIBUTES_NEED_TEXCOORD1 48 | $Attributes.uv2: #define ATTRIBUTES_NEED_TEXCOORD2 49 | $Attributes.uv3: #define ATTRIBUTES_NEED_TEXCOORD3 50 | $Attributes.color: #define ATTRIBUTES_NEED_COLOR 51 | $Attributes.vertexID: #define ATTRIBUTES_NEED_VERTEXID 52 | $Varyings.positionWS: #define VARYINGS_NEED_POSITION_WS 53 | $Varyings.normalWS: #define VARYINGS_NEED_NORMAL_WS 54 | $Varyings.tangentWS: #define VARYINGS_NEED_TANGENT_WS 55 | $Varyings.texCoord0: #define VARYINGS_NEED_TEXCOORD0 56 | $Varyings.texCoord1: #define VARYINGS_NEED_TEXCOORD1 57 | $Varyings.texCoord2: #define VARYINGS_NEED_TEXCOORD2 58 | $Varyings.texCoord3: #define VARYINGS_NEED_TEXCOORD3 59 | $Varyings.color: #define VARYINGS_NEED_COLOR 60 | $Varyings.bitangentWS: #define VARYINGS_NEED_BITANGENT_WS 61 | $Varyings.screenPosition: #define VARYINGS_NEED_SCREENPOSITION 62 | $Varyings.fogFactorAndVertexLight: #define VARYINGS_NEED_FOG_AND_VERTEX_LIGHT 63 | $Varyings.cullFace: #define VARYINGS_NEED_CULLFACE 64 | $features.graphVertex: #define FEATURES_GRAPH_VERTEX 65 | $BuiltIn.UseLegacySpriteBlocks: #define BUILTIN_USELEGACYSPRITEBLOCKS 66 | $splice(PassInstancing) 67 | $splice(DotsInstancingVars) 68 | 69 | // custom interpolator pre-include 70 | $splice(sgci_CustomInterpolatorPreInclude) 71 | 72 | // Includes 73 | $splice(PreGraphIncludes) 74 | 75 | // -------------------------------------------------- 76 | // Structs and Packing 77 | 78 | // custom interpolators pre packing 79 | $splice(CustomInterpolatorPrePacking) 80 | 81 | $splice(PassStructs) 82 | 83 | $splice(InterpolatorPack) 84 | 85 | #include "Packages/io.z3y.github.shadergraph/ShaderLibrary/Structs.hlsl" 86 | // splice(PreGraph) 87 | 88 | // -------------------------------------------------- 89 | // Graph 90 | 91 | // Graph Properties 92 | $splice(GraphProperties) 93 | 94 | // Graph Includes 95 | $splice(GraphIncludes) 96 | 97 | // Graph Functions 98 | $splice(GraphFunctions) 99 | 100 | // Custom interpolators pre vertex 101 | $splice(CustomInterpolatorPreVertex) 102 | 103 | // Graph Vertex 104 | $splice(GraphVertex) 105 | 106 | // Custom interpolators, pre surface 107 | $splice(CustomInterpolatorPreSurface) 108 | 109 | // Graph Pixel 110 | $splice(GraphPixel) 111 | 112 | // -------------------------------------------------- 113 | // Build Graph Inputs 114 | 115 | //features.graphVertex: $include("BuildVertexDescriptionInputs.template.hlsl") 116 | $features.graphPixel: $include("SharedCode.template.hlsl") 117 | 118 | // -------------------------------------------------- 119 | // Main 120 | 121 | $splice(PostGraphIncludes) 122 | 123 | ENDHLSL 124 | } 125 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Templates/ShaderPass.template.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b06f28dd31fbd04eb8fc9190ba79356 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Templates/SharedCode.template.hlsl: -------------------------------------------------------------------------------- 1 | SurfaceDescriptionInputs BuildSurfaceDescriptionInputs(Varyings input) 2 | { 3 | SurfaceDescriptionInputs output; 4 | ZERO_INITIALIZE(SurfaceDescriptionInputs, output); 5 | 6 | $splice(CustomInterpolatorCopyToSDI) 7 | 8 | $SurfaceDescriptionInputs.WorldSpaceNormal: // must use interpolated tangent, bitangent and normal before they are normalized in the pixel shader. 9 | $SurfaceDescriptionInputs.WorldSpaceNormal: float3 unnormalizedNormalWS = input.normalWS; 10 | $SurfaceDescriptionInputs.WorldSpaceNormal: const float renormFactor = 1.0 / length(unnormalizedNormalWS); 11 | 12 | $SurfaceDescriptionInputs.WorldSpaceBiTangent: // use bitangent on the fly like in hdrp 13 | $SurfaceDescriptionInputs.WorldSpaceBiTangent: // IMPORTANT! If we ever support Flip on double sided materials ensure bitangent and tangent are NOT flipped. 14 | $SurfaceDescriptionInputs.WorldSpaceBiTangent: float crossSign = (input.tangentWS.w > 0.0 ? 1.0 : -1.0)* GetOddNegativeScale(); 15 | $SurfaceDescriptionInputs.WorldSpaceBiTangent: float3 bitang = crossSign * cross(input.normalWS.xyz, input.tangentWS.xyz); 16 | 17 | $SurfaceDescriptionInputs.WorldSpaceNormal: output.WorldSpaceNormal = renormFactor * input.normalWS.xyz; // we want a unit length Normal Vector node in shader graph 18 | $SurfaceDescriptionInputs.ObjectSpaceNormal: output.ObjectSpaceNormal = normalize(mul(output.WorldSpaceNormal, (float3x3) UNITY_MATRIX_M)); // transposed multiplication by inverse matrix to handle normal scale 19 | $SurfaceDescriptionInputs.ViewSpaceNormal: output.ViewSpaceNormal = mul(output.WorldSpaceNormal, (float3x3) UNITY_MATRIX_I_V); // transposed multiplication by inverse matrix to handle normal scale 20 | $SurfaceDescriptionInputs.TangentSpaceNormal: output.TangentSpaceNormal = float3(0.0f, 0.0f, 1.0f); 21 | 22 | $SurfaceDescriptionInputs.WorldSpaceTangent: // to preserve mikktspace compliance we use same scale renormFactor as was used on the normal. 23 | $SurfaceDescriptionInputs.WorldSpaceTangent: // This is explained in section 2.2 in "surface gradient based bump mapping framework" 24 | $SurfaceDescriptionInputs.WorldSpaceTangent: output.WorldSpaceTangent = renormFactor * input.tangentWS.xyz; 25 | $SurfaceDescriptionInputs.WorldSpaceBiTangent: output.WorldSpaceBiTangent = renormFactor * bitang; 26 | 27 | $SurfaceDescriptionInputs.ObjectSpaceTangent: output.ObjectSpaceTangent = TransformWorldToObjectDir(output.WorldSpaceTangent); 28 | $SurfaceDescriptionInputs.ViewSpaceTangent: output.ViewSpaceTangent = TransformWorldToViewDir(output.WorldSpaceTangent); 29 | $SurfaceDescriptionInputs.TangentSpaceTangent: output.TangentSpaceTangent = float3(1.0f, 0.0f, 0.0f); 30 | $SurfaceDescriptionInputs.ObjectSpaceBiTangent: output.ObjectSpaceBiTangent = TransformWorldToObjectDir(output.WorldSpaceBiTangent); 31 | $SurfaceDescriptionInputs.ViewSpaceBiTangent: output.ViewSpaceBiTangent = TransformWorldToViewDir(output.WorldSpaceBiTangent); 32 | $SurfaceDescriptionInputs.TangentSpaceBiTangent: output.TangentSpaceBiTangent = float3(0.0f, 1.0f, 0.0f); 33 | $SurfaceDescriptionInputs.WorldSpaceViewDirection: output.WorldSpaceViewDirection = normalize(UnityWorldSpaceViewDir(input.positionWS)); 34 | $SurfaceDescriptionInputs.ObjectSpaceViewDirection: output.ObjectSpaceViewDirection = TransformWorldToObjectDir(output.WorldSpaceViewDirection); 35 | $SurfaceDescriptionInputs.ViewSpaceViewDirection: output.ViewSpaceViewDirection = TransformWorldToViewDir(output.WorldSpaceViewDirection); 36 | $SurfaceDescriptionInputs.TangentSpaceViewDirection: float3x3 tangentSpaceTransform = float3x3(output.WorldSpaceTangent, output.WorldSpaceBiTangent, output.WorldSpaceNormal); 37 | $SurfaceDescriptionInputs.TangentSpaceViewDirection: output.TangentSpaceViewDirection = mul(tangentSpaceTransform, output.WorldSpaceViewDirection); 38 | $SurfaceDescriptionInputs.WorldSpacePosition: output.WorldSpacePosition = input.positionWS; 39 | $SurfaceDescriptionInputs.ObjectSpacePosition: output.ObjectSpacePosition = TransformWorldToObject(input.positionWS); 40 | $SurfaceDescriptionInputs.ViewSpacePosition: output.ViewSpacePosition = TransformWorldToView(input.positionWS); 41 | $SurfaceDescriptionInputs.TangentSpacePosition: output.TangentSpacePosition = float3(0.0f, 0.0f, 0.0f); 42 | $SurfaceDescriptionInputs.AbsoluteWorldSpacePosition: output.AbsoluteWorldSpacePosition = GetAbsolutePositionWS(input.positionWS); 43 | $SurfaceDescriptionInputs.WorldSpacePositionPredisplacement: output.WorldSpacePositionPredisplacement = input.positionWS; 44 | $SurfaceDescriptionInputs.ObjectSpacePositionPredisplacement: output.ObjectSpacePositionPredisplacement = TransformWorldToObject(input.positionWS); 45 | $SurfaceDescriptionInputs.ViewSpacePositionPredisplacement: output.ViewSpacePositionPredisplacement = TransformWorldToView(input.positionWS); 46 | $SurfaceDescriptionInputs.TangentSpacePositionPredisplacement: output.TangentSpacePositionPredisplacement = float3(0.0f, 0.0f, 0.0f); 47 | $SurfaceDescriptionInputs.AbsoluteWorldSpacePositionPredisplacement:output.AbsoluteWorldSpacePositionPredisplacement = GetAbsolutePositionWS(input.positionWS); 48 | $SurfaceDescriptionInputs.ScreenPosition: output.ScreenPosition = ComputeScreenPos(TransformWorldToHClip(input.positionWS), _ProjectionParams.x); 49 | $SurfaceDescriptionInputs.uv0: output.uv0 = input.texCoord0; 50 | $SurfaceDescriptionInputs.uv1: output.uv1 = input.texCoord1; 51 | $SurfaceDescriptionInputs.uv2: output.uv2 = input.texCoord2; 52 | $SurfaceDescriptionInputs.uv3: output.uv3 = input.texCoord3; 53 | $SurfaceDescriptionInputs.VertexColor: output.VertexColor = input.color; 54 | $SurfaceDescriptionInputs.TimeParameters: output.TimeParameters = _TimeParameters.xyz; // This is mainly for LW as HD overwrite this value 55 | 56 | #if UNITY_UV_STARTS_AT_TOP 57 | $SurfaceDescriptionInputs.PixelPosition: output.PixelPosition = float2(input.positionCS.x, (_ProjectionParams.x < 0) ? (_ScreenParams.y - input.positionCS.y) : input.positionCS.y); 58 | #else 59 | $SurfaceDescriptionInputs.PixelPosition: output.PixelPosition = float2(input.positionCS.x, (_ProjectionParams.x > 0) ? (_ScreenParams.y - input.positionCS.y) : input.positionCS.y); 60 | #endif 61 | 62 | $SurfaceDescriptionInputs.NDCPosition: output.NDCPosition = output.PixelPosition.xy / _ScreenParams.xy; 63 | $SurfaceDescriptionInputs.NDCPosition: output.NDCPosition.y = 1.0f - output.NDCPosition.y; 64 | 65 | #ifdef VARYINGS_NEED_POSITION_WS 66 | float4 positionCS = TransformWorldToHClip(input.positionWS); 67 | float4 screenPos = ComputeGrabScreenPos(positionCS); 68 | screenPos.xy /= screenPos.w; 69 | $SurfaceDescriptionInputs.NDCPosition: output.NDCPosition = screenPos.xy; 70 | $SurfaceDescriptionInputs.PixelPosition: output.PixelPosition = float2(screenPos.x, 1.0f - screenPos.y); 71 | $SurfaceDescriptionInputs.PixelPosition: output.PixelPosition *= _ScreenParams.xy; 72 | #endif 73 | 74 | 75 | #if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE) 76 | #define BUILD_SURFACE_DESCRIPTION_INPUTS_OUTPUT_FACESIGN output.FaceSign = IS_FRONT_VFACE(input.cullFace, true, false); 77 | #else 78 | #define BUILD_SURFACE_DESCRIPTION_INPUTS_OUTPUT_FACESIGN 79 | #endif 80 | $SurfaceDescriptionInputs.FaceSign: BUILD_SURFACE_DESCRIPTION_INPUTS_OUTPUT_FACESIGN 81 | #undef BUILD_SURFACE_DESCRIPTION_INPUTS_OUTPUT_FACESIGN 82 | 83 | return output; 84 | } 85 | -------------------------------------------------------------------------------- /Editor/ShaderGraph/Templates/SharedCode.template.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 42c74ffc504cb2940b0ca16fdad11b64 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/VRCFallbackTags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace z3y.BuiltIn.ShaderGraph 5 | { 6 | [Serializable] 7 | public class VRCFallbackTags 8 | { 9 | public enum ShaderType 10 | { 11 | Standard, 12 | Unlit, 13 | VertexLit, 14 | Toon, 15 | Particle, 16 | Sprite, 17 | Matcap, 18 | MobileToon, 19 | Hidden 20 | }; 21 | 22 | public enum ShaderMode 23 | { 24 | Opaque, 25 | Cutout, 26 | Transparent, 27 | Fade 28 | }; 29 | 30 | public ShaderType type = ShaderType.Standard; 31 | public ShaderMode mode = ShaderMode.Opaque; 32 | public bool doubleSided = false; 33 | 34 | public override string ToString() 35 | { 36 | if (type == 0 && mode == 0 && !doubleSided) 37 | { 38 | return string.Empty; 39 | } 40 | 41 | var sb = new StringBuilder(); 42 | sb.Append("\"VRCFallback\" = \""); 43 | if (type != 0) sb.Append(Enum.GetName(typeof(ShaderType), type)); 44 | if (mode != 0) sb.Append(Enum.GetName(typeof(ShaderMode), mode)); 45 | if (doubleSided) sb.Append("DoubleSided"); 46 | sb.Append("\""); 47 | 48 | return sb.ToString(); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Editor/VRCFallbackTags.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4fbda4d266e74024e9eabd4b774368e0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/io.z3y.github.shadergraphtarget.editor.asmref: -------------------------------------------------------------------------------- 1 | { 2 | "reference": "GUID:be0903cd8e1546f498710afdc59db5eb" 3 | } -------------------------------------------------------------------------------- /Editor/io.z3y.github.shadergraphtarget.editor.asmref.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c8fc5a45eec16248bdb06d8e22843f6 3 | AssemblyDefinitionReferenceImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 z3y 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 10a187995fc216c4d8bb6b709bb684ee 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Shader Graph VRC 2 | 3 | Modified ShaderGraph Built-in pipeline target for Unity 2022 for VRChat (Forward Rendering only). 4 | 5 | ## Installation 6 | 7 | - Add the listing in VRChat Creator Companion: https://z3y.github.io/vpm-package-listing/ 8 | 9 | 10 | - Select your project (Manage Project) and import the `Shader Graph VRC` package 11 | 12 | For non VRChat projects you can import the unity package from releases instead 13 | 14 | ## How to use 15 | 16 | - Create a new Shader Graph shader `Create > Shader Graph > BuiltIn VRC` 17 | - For already existing shaders swap the built-in active target in graph settings 18 | - In some cases `Enable Material Override` needs to be checked in order for rendering modes to work properly 19 | 20 | ## Features 21 | 22 | - Fixed GPU instancing and rendering in VR 23 | - Bakery Mono SH 24 | - Grab Pass (enable Grab Pass toggle when using Scene Color node) 25 | - Mono SH Lightmapped Specular 26 | - Geometric Specular AA 27 | - Anisotropy 28 | - Specular Occlusion 29 | - Alpha To Coverage 30 | - Bicubic Lightmap 31 | - Anisotropy 32 | - Audio Link 33 | - SSR 34 | 35 | ## Known issues 36 | 37 | - If you run into more bugs you can try out [Graphlit](https://github.com/z3y/Graphlit), a free custom node editor for the built-in pipeline, it is more reliable than this project 38 | 39 | ## Preview 40 | 41 | ![image](https://github.com/z3y/ShaderGraph/assets/33181641/5dc732c9-5518-4661-985c-073d067f412d) 42 | 43 | ## For Unity 2019 44 | 45 | https://github.com/z3y/ShaderGraph/tree/2019 46 | 47 | ## License 48 | 49 | Shader Graph target code licensed under the Unity Companion License for Unity-dependent projects [Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License). 50 | 51 | ## 52 | 53 | [Discord](https://discord.gg/bw46tKgRFT) 54 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d7d7441d49f8bed46a26a09bc0daf51d 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c787c5193a297b74eb01e649ef5068c0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ShaderLibrary/Alpha.hlsl: -------------------------------------------------------------------------------- 1 | void ApplyAlphaClip(inout SurfaceDescription surfaceDescription) 2 | { 3 | #ifndef UNITY_PASS_FORWARDBASE 4 | #undef ALPHATOCOVERAGE_ON 5 | #endif 6 | 7 | float alphaClipSharpness = 0.001; 8 | #if defined(_ALPHATEST_ON) && defined(ALPHATOCOVERAGE_ON) 9 | surfaceDescription.Alpha = (surfaceDescription.Alpha - surfaceDescription.AlphaClipThreshold) / max(fwidth(surfaceDescription.Alpha), alphaClipSharpness) + 0.5f; 10 | #endif 11 | 12 | #if defined(_ALPHATEST_ON) && !defined(ALPHATOCOVERAGE_ON) 13 | clip(surfaceDescription.Alpha - surfaceDescription.AlphaClipThreshold); 14 | #endif 15 | } 16 | 17 | void ApplyAlphaSurface(inout SurfaceDescription surfaceDescription) 18 | { 19 | #if defined(_ALPHAPREMULTIPLY_ON) 20 | surfaceDescription.BaseColor *= surfaceDescription.Alpha; 21 | 22 | #if (SHADERPASS == FORWARDBASE) || (SHADERPASS == FORWARDADD) 23 | surfaceDescription.BaseColor = lerp(surfaceDescription.Alpha, 1.0, surfaceDescription.Metallic); 24 | #endif 25 | #endif 26 | 27 | #if defined(_ALPHAMODULATE_ON) 28 | surfaceDescription.BaseColor.rgb = lerp(1.0, surfaceDescription.Albedo.rgb, surfaceDescription.Alpha); 29 | #endif 30 | } 31 | 32 | half GetAlphaValue(SurfaceDescription surfaceDescription) 33 | { 34 | #if !defined(_ALPHAFADE_ON) && !defined(_ALPHATEST_ON) && !defined(_ALPHAPREMULTIPLY_ON) && !defined(_ALPHAMODULATE_ON) && !defined(_SURFACE_TYPE_TRANSPARENT) 35 | return 1.0; 36 | #else 37 | return surfaceDescription.Alpha; 38 | #endif 39 | } -------------------------------------------------------------------------------- /ShaderLibrary/Alpha.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6744467a6ffa1b247bc640058023bfbc 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/Bakery.hlsl: -------------------------------------------------------------------------------- 1 | #ifdef BAKERY_MONOSH 2 | void BakeryMonoSH(ShaderData sd, SurfaceDescription surf, float2 lmUV, inout half3 diffuseColor, inout half3 specularColor, out half3 bentLight) 3 | { 4 | half roughness = max(sd.perceptualRoughness * sd.perceptualRoughness, 0.002); 5 | half3 L0 = diffuseColor; 6 | 7 | //float3 dominantDir = unity_LightmapInd.SampleLevel(custom_bilinear_clamp_sampler, lmUV, 0).xyz; 8 | float3 dominantDir = BicubicSampling::SampleBicubic(unity_LightmapInd, custom_bilinear_clamp_sampler, lmUV, BicubicSampling::GetTexelSize(unity_LightmapInd)).xyz; 9 | 10 | 11 | float3 nL1 = dominantDir * 2 - 1; 12 | float3 L1x = nL1.x * L0 * 2; 13 | float3 L1y = nL1.y * L0 * 2; 14 | float3 L1z = nL1.z * L0 * 2; 15 | half3 sh; 16 | 17 | bentLight = (dot(nL1, sd.reflectionDirection) + 1.0) * L0 * 2; 18 | bentLight = max(bentLight, 0.0); 19 | 20 | #ifdef NONLINEAR_LIGHTMAP_SH 21 | float lumaL0 = dot(L0, 1); 22 | float lumaL1x = dot(L1x, 1); 23 | float lumaL1y = dot(L1y, 1); 24 | float lumaL1z = dot(L1z, 1); 25 | float lumaSH = shEvaluateDiffuseL1Geomerics(lumaL0, float3(lumaL1x, lumaL1y, lumaL1z), sd.normalWS); 26 | 27 | sh = L0 + sd.normalWS.x * L1x + sd.normalWS.y * L1y + sd.normalWS.z * L1z; 28 | float regularLumaSH = dot(sh, 1); 29 | //sh *= regularLumaSH < 0.001 ? 1 : (lumaSH / regularLumaSH); 30 | sh *= lerp(1, lumaSH / regularLumaSH, saturate(regularLumaSH*16)); 31 | 32 | //sh.r = shEvaluateDiffuseL1Geomerics(L0.r, float3(L1x.r, L1y.r, L1z.r), sd.normalWS); 33 | //sh.g = shEvaluateDiffuseL1Geomerics(L0.g, float3(L1x.g, L1y.g, L1z.g), sd.normalWS); 34 | //sh.b = shEvaluateDiffuseL1Geomerics(L0.b, float3(L1x.b, L1y.b, L1z.b), sd.normalWS); 35 | 36 | #else 37 | sh = L0 + sd.normalWS.x * L1x + sd.normalWS.y * L1y + sd.normalWS.z * L1z; 38 | #endif 39 | 40 | 41 | diffuseColor = max(sh, 0.0); 42 | 43 | #ifdef APPROXIMATE_AREALIGHT_SPECULAR 44 | half smoothness = 1.0f - roughness; 45 | half3 directionLength = saturate(length(nL1)); 46 | smoothness *= sqrt(directionLength); 47 | roughness = 1.0f - smoothness; 48 | #endif 49 | 50 | specularColor = 0; 51 | #ifdef _LIGHTMAPPED_SPECULAR 52 | dominantDir = nL1; 53 | //float focus = saturate(length(dominantDir)); 54 | half3 halfDir = Unity_SafeNormalize(normalize(dominantDir) + sd.viewDirectionWS); 55 | half nh = saturate(dot(sd.normalWS, halfDir)); 56 | half spec = Filament::D_GGX(nh, roughness); 57 | 58 | sh = L0 + dominantDir.x * L1x + dominantDir.y * L1y + dominantDir.z * L1z; 59 | 60 | //specularColor = max(spec * sh, 0.0); 61 | 62 | #ifdef _ANISOTROPY 63 | half at = max(roughness * (1.0 + surf.Anisotropy), 0.001); 64 | half ab = max(roughness * (1.0 - surf.Anisotropy), 0.001); 65 | 66 | specularColor = max(Filament::D_GGX_Anisotropic(nh, halfDir, sd.tangentWS, sd.bitangentWS, at, ab) * sh, 0.0); 67 | 68 | #else 69 | specularColor = max(spec * sh, 0.0); 70 | #endif 71 | 72 | 73 | #endif 74 | 75 | 76 | } 77 | #endif -------------------------------------------------------------------------------- /ShaderLibrary/Bakery.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 36671a24ffc0db641b5b47a360cc1db3 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/Bicubic.hlsl: -------------------------------------------------------------------------------- 1 | 2 | namespace BicubicSampling 3 | { 4 | // https://ndotl.wordpress.com/2018/08/29/baking-artifact-free-lightmaps 5 | // bicubicw0, bicubicw1, bicubicw2, and bicubicw3 are the four cubic B-spline basis functions 6 | float bicubicw0(float a) 7 | { 8 | return (1.0f/6.0f)*(a*(a*(-a + 3.0f) - 3.0f) + 1.0f); // optimized 9 | } 10 | 11 | float bicubicw1(float a) 12 | { 13 | return (1.0f/6.0f)*(a*a*(3.0f*a - 6.0f) + 4.0f); 14 | } 15 | 16 | float bicubicw2(float a) 17 | { 18 | return (1.0f/6.0f)*(a*(a*(-3.0f*a + 3.0f) + 3.0f) + 1.0f); 19 | } 20 | 21 | float bicubicw3(float a) 22 | { 23 | return (1.0f/6.0f)*(a*a*a); 24 | } 25 | 26 | // bicubicg0 and bicubicg1 are the two amplitude functions 27 | float bicubicg0(float a) 28 | { 29 | return bicubicw0(a) + bicubicw1(a); 30 | } 31 | 32 | float bicubicg1(float a) 33 | { 34 | return bicubicw2(a) + bicubicw3(a); 35 | } 36 | 37 | // bicubich0 and bicubich1 are the two offset functions 38 | float bicubich0(float a) 39 | { 40 | // note +0.5 offset to compensate for CUDA linear filtering convention 41 | return -1.0f + bicubicw1(a) / (bicubicw0(a) + bicubicw1(a)) + 0.5f; 42 | } 43 | 44 | float bicubich1(float a) 45 | { 46 | return 1.0f + bicubicw3(a) / (bicubicw2(a) + bicubicw3(a)) + 0.5f; 47 | } 48 | 49 | float4 GetTexelSize(Texture2D t) 50 | { 51 | float4 texelSize; 52 | t.GetDimensions(texelSize.x, texelSize.y); 53 | texelSize.zw = 1.0 / texelSize.xy; 54 | return texelSize; 55 | } 56 | 57 | half4 SampleBicubic(Texture2D t, SamplerState s, float2 uv, float4 texelSize, float lod = 0) 58 | { 59 | #if defined(QUALITY_LOW) || !defined(BICUBIC_LIGHTMAP) 60 | return SAMPLE_TEXTURE2D_LOD(t, s, uv, lod); 61 | #else 62 | float2 xy = uv * texelSize.xy - 0.5; 63 | float2 pxy = floor(xy); 64 | float2 fxy = xy - pxy; 65 | 66 | // note: we could store these functions in a lookup table texture, but maths is cheap 67 | float bicubicg0x = bicubicg0(fxy.x); 68 | float bicubicg1x = bicubicg1(fxy.x); 69 | float bicubich0x = bicubich0(fxy.x); 70 | float bicubich1x = bicubich1(fxy.x); 71 | float bicubich0y = bicubich0(fxy.y); 72 | float bicubich1y = bicubich1(fxy.y); 73 | 74 | //float lod = ComputeTextureLOD(uv); 75 | 76 | float4 t0 = bicubicg0x * SAMPLE_TEXTURE2D_LOD(t, s, float2(pxy.x + bicubich0x, pxy.y + bicubich0y) * texelSize.zw, lod); 77 | float4 t1 = bicubicg1x * SAMPLE_TEXTURE2D_LOD(t, s, float2(pxy.x + bicubich1x, pxy.y + bicubich0y) * texelSize.zw, lod); 78 | float4 t2 = bicubicg0x * SAMPLE_TEXTURE2D_LOD(t, s, float2(pxy.x + bicubich0x, pxy.y + bicubich1y) * texelSize.zw, lod); 79 | float4 t3 = bicubicg1x * SAMPLE_TEXTURE2D_LOD(t, s, float2(pxy.x + bicubich1x, pxy.y + bicubich1y) * texelSize.zw, lod); 80 | 81 | return bicubicg0(fxy.y) * (t0 + t1) + bicubicg1(fxy.y) * (t2 + t3); 82 | #endif 83 | } 84 | } -------------------------------------------------------------------------------- /ShaderLibrary/Bicubic.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04dc5bf3aabba80418705ef11b12e5cf 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/BuiltInDOTSInstancing.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef BUILTIN_DOTS_INSTANCING_INCLUDED 2 | #define BUILTIN_DOTS_INSTANCING_INCLUDED 3 | 4 | #ifdef UNITY_DOTS_INSTANCING_ENABLED 5 | 6 | #undef unity_ObjectToWorld 7 | #undef unity_WorldToObject 8 | // TODO: This might not work correctly in all cases, double check! 9 | UNITY_DOTS_INSTANCING_START(BuiltinPropertyMetadata) 10 | UNITY_DOTS_INSTANCED_PROP(float3x4, unity_ObjectToWorld) 11 | UNITY_DOTS_INSTANCED_PROP(float3x4, unity_WorldToObject) 12 | UNITY_DOTS_INSTANCED_PROP(float4, unity_LODFade) 13 | UNITY_DOTS_INSTANCED_PROP(float4, unity_WorldTransformParams) 14 | UNITY_DOTS_INSTANCED_PROP(float4, unity_LightData) 15 | UNITY_DOTS_INSTANCED_PROP(float2x4, unity_LightIndices) 16 | UNITY_DOTS_INSTANCED_PROP(float4, unity_ProbesOcclusion) 17 | UNITY_DOTS_INSTANCED_PROP(float4, unity_SpecCube0_HDR) 18 | UNITY_DOTS_INSTANCED_PROP(float4, unity_LightmapST) 19 | UNITY_DOTS_INSTANCED_PROP(float4, unity_LightmapIndex) 20 | UNITY_DOTS_INSTANCED_PROP(float4, unity_DynamicLightmapST) 21 | UNITY_DOTS_INSTANCED_PROP(float4, unity_SHAr) 22 | UNITY_DOTS_INSTANCED_PROP(float4, unity_SHAg) 23 | UNITY_DOTS_INSTANCED_PROP(float4, unity_SHAb) 24 | UNITY_DOTS_INSTANCED_PROP(float4, unity_SHBr) 25 | UNITY_DOTS_INSTANCED_PROP(float4, unity_SHBg) 26 | UNITY_DOTS_INSTANCED_PROP(float4, unity_SHBb) 27 | UNITY_DOTS_INSTANCED_PROP(float4, unity_SHC) 28 | UNITY_DOTS_INSTANCING_END(BuiltinPropertyMetadata) 29 | 30 | // Note: Macros for unity_ObjectToWorld and unity_WorldToObject are declared in UnityInstancing.hlsl 31 | // because of some special handling 32 | #define unity_LODFade UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_LODFade) 33 | #define unity_WorldTransformParams UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_WorldTransformParams) 34 | #define unity_LightData UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_LightData) 35 | #define unity_LightIndices UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float2x4, Metadata_unity_LightIndices) 36 | #define unity_ProbesOcclusion UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_ProbesOcclusion) 37 | #define unity_SpecCube0_HDR UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_SpecCube0_HDR) 38 | #define unity_LightmapST UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_LightmapST) 39 | #define unity_LightmapIndex UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_LightmapIndex) 40 | #define unity_DynamicLightmapST UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_DynamicLightmapST) 41 | #define unity_SHAr UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_SHAr) 42 | #define unity_SHAg UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_SHAg) 43 | #define unity_SHAb UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_SHAb) 44 | #define unity_SHBr UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_SHBr) 45 | #define unity_SHBg UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_SHBg) 46 | #define unity_SHBb UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_SHBb) 47 | #define unity_SHC UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_SHC) 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /ShaderLibrary/BuiltInDOTSInstancing.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b0dc28011dadd64bbfa6be7a6ce4ae4 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/Core.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef BUILTIN_PIPELINE_CORE_INCLUDED 2 | #define BUILTIN_PIPELINE_CORE_INCLUDED 3 | 4 | // VT is not supported in URP (for now) this ensures any shaders using the VT 5 | // node work by falling to regular texture sampling. 6 | #define FORCE_VIRTUAL_TEXTURING_OFF 1 7 | 8 | #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" 9 | #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl" 10 | 11 | #if !defined(SHADER_HINT_NICE_QUALITY) 12 | #if defined(SHADER_API_MOBILE) || defined(SHADER_API_SWITCH) 13 | #define SHADER_HINT_NICE_QUALITY 0 14 | #else 15 | #define SHADER_HINT_NICE_QUALITY 1 16 | #endif 17 | #endif 18 | 19 | // Shader Quality Tiers in BuiltIn. 20 | // SRP doesn't use Graphics Settings Quality Tiers. 21 | // We should expose shader quality tiers in the pipeline asset. 22 | // Meanwhile, it's forced to be: 23 | // High Quality: Non-mobile platforms or shader explicit defined SHADER_HINT_NICE_QUALITY 24 | // Medium: Mobile aside from GLES2 25 | // Low: GLES2 26 | #if SHADER_HINT_NICE_QUALITY 27 | #define SHADER_QUALITY_HIGH 28 | #elif defined(SHADER_API_GLES) 29 | #define SHADER_QUALITY_LOW 30 | #else 31 | #define SHADER_QUALITY_MEDIUM 32 | #endif 33 | 34 | #ifndef BUMP_SCALE_NOT_SUPPORTED 35 | #define BUMP_SCALE_NOT_SUPPORTED !SHADER_HINT_NICE_QUALITY 36 | #endif 37 | 38 | 39 | #if UNITY_REVERSED_Z 40 | // TODO: workaround. There's a bug where SHADER_API_GL_CORE gets erroneously defined on switch. 41 | #if (defined(SHADER_API_GLCORE) && !defined(SHADER_API_SWITCH)) || defined(SHADER_API_GLES) || defined(SHADER_API_GLES3) 42 | //GL with reversed z => z clip range is [near, -far] -> should remap in theory but dont do it in practice to save some perf (range is close enough) 43 | #define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) max(-(coord), 0) 44 | #else 45 | //D3d with reversed Z => z clip range is [near, 0] -> remapping to [0, far] 46 | //max is required to protect ourselves from near plane not being correct/meaningfull in case of oblique matrices. 47 | #define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) max(((1.0-(coord)/_ProjectionParams.y)*_ProjectionParams.z),0) 48 | #endif 49 | #elif UNITY_UV_STARTS_AT_TOP 50 | //D3d without reversed z => z clip range is [0, far] -> nothing to do 51 | #define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) (coord) 52 | #else 53 | //Opengl => z clip range is [-near, far] -> should remap in theory but dont do it in practice to save some perf (range is close enough) 54 | #define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) (coord) 55 | #endif 56 | 57 | // Stereo-related bits 58 | #if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED) 59 | 60 | #define SLICE_ARRAY_INDEX unity_StereoEyeIndex 61 | 62 | #define TEXTURE2D_X(textureName) TEXTURE2D_ARRAY(textureName) 63 | #define TEXTURE2D_X_PARAM(textureName, samplerName) TEXTURE2D_ARRAY_PARAM(textureName, samplerName) 64 | #define TEXTURE2D_X_ARGS(textureName, samplerName) TEXTURE2D_ARRAY_ARGS(textureName, samplerName) 65 | #define TEXTURE2D_X_HALF(textureName) TEXTURE2D_ARRAY_HALF(textureName) 66 | #define TEXTURE2D_X_FLOAT(textureName) TEXTURE2D_ARRAY_FLOAT(textureName) 67 | 68 | #define LOAD_TEXTURE2D_X(textureName, unCoord2) LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, SLICE_ARRAY_INDEX) 69 | #define LOAD_TEXTURE2D_X_LOD(textureName, unCoord2, lod) LOAD_TEXTURE2D_ARRAY_LOD(textureName, unCoord2, SLICE_ARRAY_INDEX, lod) 70 | #define SAMPLE_TEXTURE2D_X(textureName, samplerName, coord2) SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, SLICE_ARRAY_INDEX) 71 | #define SAMPLE_TEXTURE2D_X_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, SLICE_ARRAY_INDEX, lod) 72 | #define GATHER_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, SLICE_ARRAY_INDEX) 73 | #define GATHER_RED_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_RED_TEXTURE2D(textureName, samplerName, float3(coord2, SLICE_ARRAY_INDEX)) 74 | #define GATHER_GREEN_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_GREEN_TEXTURE2D(textureName, samplerName, float3(coord2, SLICE_ARRAY_INDEX)) 75 | #define GATHER_BLUE_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_BLUE_TEXTURE2D(textureName, samplerName, float3(coord2, SLICE_ARRAY_INDEX)) 76 | 77 | #else 78 | #define SLICE_ARRAY_INDEX 0 79 | 80 | #define TEXTURE2D_X(textureName) TEXTURE2D(textureName) 81 | #define TEXTURE2D_X_PARAM(textureName, samplerName) TEXTURE2D_PARAM(textureName, samplerName) 82 | #define TEXTURE2D_X_ARGS(textureName, samplerName) TEXTURE2D_ARGS(textureName, samplerName) 83 | #define TEXTURE2D_X_HALF(textureName) TEXTURE2D_HALF(textureName) 84 | #define TEXTURE2D_X_FLOAT(textureName) TEXTURE2D_FLOAT(textureName) 85 | 86 | #define LOAD_TEXTURE2D_X(textureName, unCoord2) LOAD_TEXTURE2D(textureName, unCoord2) 87 | #define LOAD_TEXTURE2D_X_LOD(textureName, unCoord2, lod) LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) 88 | #define SAMPLE_TEXTURE2D_X(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2) 89 | #define SAMPLE_TEXTURE2D_X_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) 90 | #define GATHER_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_TEXTURE2D(textureName, samplerName, coord2) 91 | #define GATHER_RED_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) 92 | #define GATHER_GREEN_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) 93 | #define GATHER_BLUE_TEXTURE2D_X(textureName, samplerName, coord2) GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) 94 | #endif 95 | 96 | // Structs 97 | struct VertexPositionInputs 98 | { 99 | float3 positionWS; // World space position 100 | float3 positionVS; // View space position 101 | float4 positionCS; // Homogeneous clip space position 102 | float4 positionNDC;// Homogeneous normalized device coordinates 103 | }; 104 | 105 | struct VertexNormalInputs 106 | { 107 | real3 tangentWS; 108 | real3 bitangentWS; 109 | float3 normalWS; 110 | }; 111 | 112 | #endif 113 | -------------------------------------------------------------------------------- /ShaderLibrary/Core.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c72705836086c94f93ae672e609f382 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/DeclareDepthTexture.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_DECLARE_DEPTH_TEXTURE_INCLUDED 2 | #define UNITY_DECLARE_DEPTH_TEXTURE_INCLUDED 3 | #include "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Core.hlsl" 4 | 5 | TEXTURE2D_X_FLOAT(_CameraDepthTexture); 6 | SAMPLER(sampler_CameraDepthTexture); 7 | 8 | float SampleSceneDepth(float2 uv) 9 | { 10 | return SAMPLE_TEXTURE2D_X(_CameraDepthTexture, sampler_CameraDepthTexture, UnityStereoTransformScreenSpaceTex(uv)).r; 11 | } 12 | 13 | float LoadSceneDepth(uint2 uv) 14 | { 15 | return LOAD_TEXTURE2D_X(_CameraDepthTexture, uv).r; 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /ShaderLibrary/DeclareDepthTexture.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e6c46dd15fd4e6c46abd9f609ffbde53 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/DeclareNormalsTexture.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_DECLARE_NORMALS_TEXTURE_INCLUDED 2 | #define UNITY_DECLARE_NORMALS_TEXTURE_INCLUDED 3 | #include "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Core.hlsl" 4 | 5 | TEXTURE2D_X_FLOAT(_CameraNormalsTexture); 6 | SAMPLER(sampler_CameraNormalsTexture); 7 | 8 | float3 SampleSceneNormals(float2 uv) 9 | { 10 | float3 normal = SAMPLE_TEXTURE2D_X(_CameraNormalsTexture, sampler_CameraNormalsTexture, UnityStereoTransformScreenSpaceTex(uv)).xyz; 11 | 12 | #if defined(_GBUFFER_NORMALS_OCT) 13 | half2 remappedOctNormalWS = Unpack888ToFloat2(normal); // values between [ 0, 1] 14 | half2 octNormalWS = remappedOctNormalWS.xy * 2.0h - 1.0h; // values between [-1, +1] 15 | normal = UnpackNormalOctQuadEncode(octNormalWS); 16 | #endif 17 | 18 | return normal; 19 | } 20 | 21 | float3 LoadSceneNormals(uint2 uv) 22 | { 23 | float3 normal = LOAD_TEXTURE2D_X(_CameraNormalsTexture, uv).xyz; 24 | 25 | #if defined(_GBUFFER_NORMALS_OCT) 26 | half2 remappedOctNormalWS = Unpack888ToFloat2(normal); // values between [ 0, 1] 27 | half2 octNormalWS = remappedOctNormalWS.xy * 2.0h - 1.0h; // values between [-1, +1] 28 | normal = UnpackNormalOctQuadEncode(octNormalWS); 29 | #endif 30 | 31 | return normal; 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /ShaderLibrary/DeclareNormalsTexture.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f4fa9fb1bea7f5c4c9e227ac43c43ccc 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/DeclareOpaqueTexture.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_DECLARE_OPAQUE_TEXTURE_INCLUDED 2 | #define UNITY_DECLARE_OPAQUE_TEXTURE_INCLUDED 3 | #include "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Core.hlsl" 4 | 5 | TEXTURE2D_X(_CameraOpaqueTexture); 6 | SAMPLER(sampler_CameraOpaqueTexture); 7 | 8 | float3 SampleSceneColor(float2 uv) 9 | { 10 | return SAMPLE_TEXTURE2D_X(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, UnityStereoTransformScreenSpaceTex(uv)).rgb; 11 | } 12 | 13 | float3 LoadSceneColor(uint2 uv) 14 | { 15 | return LOAD_TEXTURE2D_X(_CameraOpaqueTexture, uv).rgb; 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /ShaderLibrary/DeclareOpaqueTexture.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c445dd7d0be7134ab1dd5e3d70e9e33 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/ForwardLighting.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9acf9bd1221b1640bb72b8c695b6256 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/Fragment.hlsl: -------------------------------------------------------------------------------- 1 | #include "ForwardLighting.hlsl" 2 | 3 | half4 frag (PackedVaryings packedInput) : SV_Target 4 | { 5 | Varyings unpacked = UnpackVaryings(packedInput); 6 | UNITY_SETUP_INSTANCE_ID(unpacked); 7 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 8 | 9 | staticVaryings = unpacked; 10 | 11 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 12 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 13 | 14 | half4 color = ComputeForwardLighting(unpacked, surfaceDescription); 15 | 16 | return color; 17 | } -------------------------------------------------------------------------------- /ShaderLibrary/Fragment.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd081484d578a0f4a86fa4e254e6c8c7 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/FragmentMeta.hlsl: -------------------------------------------------------------------------------- 1 | half _BakeryAlphaDither; 2 | #include "Alpha.hlsl" 3 | 4 | float Unity_Dither(float In, float2 ScreenPosition) 5 | { 6 | float2 uv = ScreenPosition * _ScreenParams.xy; 7 | const half4 DITHER_THRESHOLDS[4] = 8 | { 9 | half4(1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0), 10 | half4(13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0), 11 | half4(4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0), 12 | half4(16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0) 13 | }; 14 | 15 | return In - DITHER_THRESHOLDS[uint(uv.x) % 4][uint(uv.y) % 4]; 16 | } 17 | 18 | #if defined(PIPELINE_BUILTIN) 19 | inline half OneMinusReflectivityFromMetallic(half metallic) 20 | { 21 | // We'll need oneMinusReflectivity, so 22 | // 1-reflectivity = 1-lerp(dielectricSpec, 1, metallic) = lerp(1-dielectricSpec, 0, metallic) 23 | // store (1-dielectricSpec) in unity_ColorSpaceDielectricSpec.a, then 24 | // 1-reflectivity = lerp(alpha, 0, metallic) = alpha + metallic*(0 - alpha) = 25 | // = alpha - metallic * alpha 26 | half oneMinusDielectricSpec = unity_ColorSpaceDielectricSpec.a; 27 | return oneMinusDielectricSpec - metallic * oneMinusDielectricSpec; 28 | } 29 | 30 | inline half3 DiffuseAndSpecularFromMetallic(half3 albedo, half metallic, out half3 specColor, out half oneMinusReflectivity) 31 | { 32 | specColor = lerp (unity_ColorSpaceDielectricSpec.rgb, albedo, metallic); 33 | oneMinusReflectivity = OneMinusReflectivityFromMetallic(metallic); 34 | return albedo * oneMinusReflectivity; 35 | } 36 | 37 | half3 UnityLightmappingAlbedo (half3 diffuse, half3 specular, half smoothness) 38 | { 39 | half roughness = 1.0 - smoothness; 40 | half3 res = diffuse; 41 | res += specular * roughness * 0.5; 42 | return res; 43 | } 44 | 45 | 46 | #ifdef GENERATION_CODE 47 | half4 frag (Varyings unpacked) : SV_Target 48 | { 49 | #else 50 | half4 frag (PackedVaryings packedInput) : SV_Target 51 | { 52 | Varyings unpacked = UnpackVaryings(packedInput); 53 | #endif 54 | UNITY_SETUP_INSTANCE_ID(unpacked); 55 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 56 | 57 | 58 | #ifdef GENERATION_CODE 59 | SurfaceDescription surfaceDescription = InitializeSurfaceDescription(); 60 | #ifdef USE_SURFACEDESCRIPTION 61 | SurfaceDescriptionFunction(unpacked, surfaceDescription); 62 | #endif 63 | #else 64 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 65 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 66 | #endif 67 | 68 | UnityMetaInput o; 69 | UNITY_INITIALIZE_OUTPUT(UnityMetaInput, o); 70 | 71 | half3 specColor; 72 | half oneMinisReflectivity; 73 | half metallic = surfaceDescription.Metallic; 74 | half3 diffuseColor = DiffuseAndSpecularFromMetallic(surfaceDescription.BaseColor, metallic, specColor, oneMinisReflectivity); 75 | 76 | #ifdef EDITOR_VISUALIZATION 77 | o.Albedo = diffuseColor; 78 | o.VizUV = unpacked.vizUV; 79 | o.LightCoord = unpacked.lightCoord; 80 | #else 81 | o.Albedo = UnityLightmappingAlbedo(diffuseColor, specColor, surfaceDescription.Smoothness); 82 | // o.Albedo = surfaceDescription.BaseColor; 83 | #endif 84 | o.SpecularColor = specColor; 85 | o.Emission = surfaceDescription.Emission; 86 | 87 | #ifndef EDITOR_VISUALIZATION 88 | 89 | ApplyAlphaClip(surfaceDescription); 90 | ApplyAlphaSurface(surfaceDescription); 91 | half alpha = GetAlphaValue(surfaceDescription); 92 | 93 | // bakery alpha 94 | if (unity_MetaFragmentControl.w != 0) 95 | { 96 | #ifdef _ALPHAPREMULTIPLY_ON 97 | if (_BakeryAlphaDither > 0.5) 98 | { 99 | half dither = Unity_Dither(alpha, unpacked.positionCS.xy); 100 | return dither < 0.0 ? 0 : 1; 101 | } 102 | #endif 103 | return alpha; 104 | } 105 | #endif 106 | 107 | return UnityMetaFragment(o); 108 | } 109 | #endif 110 | 111 | // #if defined(PIPELINE_URP) 112 | // half4 frag (Varyings input) : SV_Target 113 | // { 114 | // UNITY_SETUP_INSTANCE_ID(input); 115 | // UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); 116 | 117 | 118 | // SurfaceDescription surfaceDescription = InitializeSurfaceDescription(); 119 | // #ifdef USE_SURFACEDESCRIPTION 120 | // SurfaceDescriptionFunction(input, surfaceDescription); 121 | // #endif 122 | 123 | // #if !defined(_ALPHAFADE_ON) && !defined(_ALPHATEST_ON) && !defined(_ALPHAPREMULTIPLY_ON) && !defined(_ALPHAMODULATE_ON) 124 | // surfaceDescription.Alpha = 1.0f; 125 | // #endif 126 | 127 | // half specular = 0; 128 | // BRDFData brdfData; 129 | // half metallic = 0;// surfaceDescription.Metallic 130 | // InitializeBRDFData(surfaceDescription.BaseColor, metallic, specular, surfaceDescription.Smoothness, surfaceDescription.Alpha, brdfData); 131 | 132 | // MetaInput metaInput = (MetaInput)0; 133 | // metaInput.BaseColor = brdfData.diffuse + brdfData.specular * brdfData.roughness * 0.5; 134 | // //metaInput.SpecularColor = specular; 135 | // metaInput.Emission = surfaceDescription.Emission; 136 | 137 | // #ifdef EDITOR_VISUALIZATION 138 | // metaInput.VizUV = input.vizUV; 139 | // metaInput.LightCoord = input.lightCoord; 140 | // #endif 141 | 142 | // // bakery alpha 143 | // if (unity_MetaFragmentControl.w != 0) 144 | // { 145 | // #ifdef _ALPHAPREMULTIPLY_ON 146 | // if (_BakeryAlphaDither > 0.5) 147 | // { 148 | // half dither = Unity_Dither(surfaceDescription.Alpha, input.positionCS.xy); 149 | // return dither < 0.0 ? 0 : 1; 150 | // } 151 | // #endif 152 | // return surfaceDescription.Alpha; 153 | // } 154 | 155 | // return MetaFragment(metaInput); 156 | // } 157 | // #endif -------------------------------------------------------------------------------- /ShaderLibrary/FragmentMeta.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00149c45ff8fb75449b3413ae1272152 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/FragmentShadowCaster.hlsl: -------------------------------------------------------------------------------- 1 | float Unity_Dither(float In, float2 ScreenPosition) 2 | { 3 | float2 uv = ScreenPosition * _ScreenParams.xy; 4 | const half4 DITHER_THRESHOLDS[4] = 5 | { 6 | half4(1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0), 7 | half4(13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0), 8 | half4(4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0), 9 | half4(16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0) 10 | }; 11 | 12 | return In - DITHER_THRESHOLDS[uint(uv.x) % 4][uint(uv.y) % 4]; 13 | } 14 | 15 | #ifdef GENERATION_CODE 16 | half4 frag (Varyings unpacked) : SV_Target 17 | { 18 | #else 19 | half4 frag (PackedVaryings packedInput) : SV_Target 20 | { 21 | Varyings unpacked = UnpackVaryings(packedInput); 22 | #endif 23 | UNITY_SETUP_INSTANCE_ID(unpacked); 24 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 25 | 26 | #ifdef LOD_FADE_CROSSFADE 27 | LODDitheringTransition(unpacked.positionCS.xy, unity_LODFade.x); 28 | #endif 29 | 30 | #ifdef GENERATION_CODE 31 | SurfaceDescription surfaceDescription = InitializeSurfaceDescription(); 32 | #ifdef USE_SURFACEDESCRIPTION 33 | SurfaceDescriptionFunction(unpacked, surfaceDescription); 34 | #endif 35 | #else 36 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 37 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 38 | #endif 39 | 40 | #if defined(_ALPHATEST_ON) 41 | clip(surfaceDescription.Alpha - surfaceDescription.AlphaClipThreshold); 42 | #endif 43 | 44 | #ifdef _ALPHAPREMULTIPLY_ON 45 | surfaceDescription.Alpha = lerp(surfaceDescription.Alpha, 1.0, surfaceDescription.Metallic); 46 | #endif 47 | 48 | #if defined(_ALPHAPREMULTIPLY_ON) || defined(_ALPHAFADE_ON) 49 | half dither = Unity_Dither(surfaceDescription.Alpha, unpacked.positionCS.xy); 50 | if (dither < 0.0) discard; 51 | #endif 52 | 53 | return 0; 54 | } -------------------------------------------------------------------------------- /ShaderLibrary/FragmentShadowCaster.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df0bb0d71b854d747bafd7452000ffba 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/FragmentUnlit.hlsl: -------------------------------------------------------------------------------- 1 | #include "Alpha.hlsl" 2 | 3 | half4 frag (PackedVaryings packedInput) : SV_Target 4 | { 5 | Varyings unpacked = UnpackVaryings(packedInput); 6 | UNITY_SETUP_INSTANCE_ID(unpacked); 7 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 8 | 9 | staticVaryings = unpacked; 10 | 11 | #ifdef LOD_FADE_CROSSFADE 12 | LODDitheringTransition(input.positionCS.xy, unity_LODFade.x); 13 | #endif 14 | 15 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 16 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 17 | 18 | ApplyAlphaClip(surfaceDescription); 19 | ApplyAlphaSurface(surfaceDescription); 20 | half alpha = GetAlphaValue(surfaceDescription); 21 | 22 | half4 result = half4(surfaceDescription.BaseColor, alpha); 23 | 24 | UNITY_APPLY_FOG(unpacked.fogCoord, result); 25 | 26 | return result; 27 | } -------------------------------------------------------------------------------- /ShaderLibrary/FragmentUnlit.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dd214e317a51feb4d86ae3c0e7aeb559 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/LDR_LLL1_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z3y/ShaderGraphVRC/06f7fe1b209c11e32045883d1a6f54e37dfb5b82/ShaderLibrary/LDR_LLL1_0.png -------------------------------------------------------------------------------- /ShaderLibrary/LDR_LLL1_0.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a9d4508aa977344889dcafe1f5bf04f 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 12 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | flipGreenChannel: 0 24 | isReadable: 0 25 | streamingMipmaps: 0 26 | streamingMipmapsPriority: 0 27 | vTOnly: 0 28 | ignoreMipmapLimit: 0 29 | grayScaleToAlpha: 0 30 | generateCubemap: 6 31 | cubemapConvolution: 0 32 | seamlessCubemap: 0 33 | textureFormat: 1 34 | maxTextureSize: 2048 35 | textureSettings: 36 | serializedVersion: 2 37 | filterMode: 1 38 | aniso: 1 39 | mipBias: 0 40 | wrapU: 0 41 | wrapV: 0 42 | wrapW: 0 43 | nPOTScale: 1 44 | lightmap: 0 45 | compressionQuality: 50 46 | spriteMode: 0 47 | spriteExtrude: 1 48 | spriteMeshType: 1 49 | alignment: 0 50 | spritePivot: {x: 0.5, y: 0.5} 51 | spritePixelsToUnits: 100 52 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 53 | spriteGenerateFallbackPhysicsShape: 1 54 | alphaUsage: 1 55 | alphaIsTransparency: 0 56 | spriteTessellationDetail: -1 57 | textureType: 0 58 | textureShape: 1 59 | singleChannelComponent: 0 60 | flipbookRows: 1 61 | flipbookColumns: 1 62 | maxTextureSizeSet: 0 63 | compressionQualitySet: 0 64 | textureFormatSet: 0 65 | ignorePngGamma: 0 66 | applyGammaDecoding: 0 67 | swizzle: 50462976 68 | cookieLightType: 0 69 | platformSettings: 70 | - serializedVersion: 3 71 | buildTarget: DefaultTexturePlatform 72 | maxTextureSize: 2048 73 | resizeAlgorithm: 0 74 | textureFormat: -1 75 | textureCompression: 0 76 | compressionQuality: 50 77 | crunchedCompression: 0 78 | allowsAlphaSplitting: 0 79 | overridden: 0 80 | ignorePlatformSupport: 0 81 | androidETC2FallbackOverride: 0 82 | forceMaximumCompressionQuality_BC6H_BC7: 0 83 | - serializedVersion: 3 84 | buildTarget: Standalone 85 | maxTextureSize: 2048 86 | resizeAlgorithm: 0 87 | textureFormat: -1 88 | textureCompression: 1 89 | compressionQuality: 50 90 | crunchedCompression: 0 91 | allowsAlphaSplitting: 0 92 | overridden: 0 93 | ignorePlatformSupport: 0 94 | androidETC2FallbackOverride: 0 95 | forceMaximumCompressionQuality_BC6H_BC7: 0 96 | - serializedVersion: 3 97 | buildTarget: Server 98 | maxTextureSize: 2048 99 | resizeAlgorithm: 0 100 | textureFormat: -1 101 | textureCompression: 1 102 | compressionQuality: 50 103 | crunchedCompression: 0 104 | allowsAlphaSplitting: 0 105 | overridden: 0 106 | ignorePlatformSupport: 0 107 | androidETC2FallbackOverride: 0 108 | forceMaximumCompressionQuality_BC6H_BC7: 0 109 | spriteSheet: 110 | serializedVersion: 2 111 | sprites: [] 112 | outline: [] 113 | physicsShape: [] 114 | bones: [] 115 | spriteID: 116 | internalID: 0 117 | vertices: [] 118 | indices: 119 | edges: [] 120 | weights: [] 121 | secondaryTextures: [] 122 | nameFileIdTable: {} 123 | mipmapLimitGroupName: 124 | pSDRemoveMatte: 0 125 | userData: 126 | assetBundleName: 127 | assetBundleVariant: 128 | -------------------------------------------------------------------------------- /ShaderLibrary/LightFunctions.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 70b4bf8e4324da245a18cb6797d6055f 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/SSR.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 608f2193528c1f94e8a2a0c4f878db22 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/ShaderGraphFunctions.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_GRAPHFUNCTIONS_LW_INCLUDED 2 | #define UNITY_GRAPHFUNCTIONS_LW_INCLUDED 3 | 4 | #define SHADERGRAPH_SAMPLE_SCENE_DEPTH(uv) shadergraph_LWSampleSceneDepth(uv) 5 | #define SHADERGRAPH_SAMPLE_SCENE_COLOR(uv) shadergraph_SampleSceneColorBuiltIn(uv) 6 | #define SHADERGRAPH_BAKED_GI(positionWS, normalWS, uvStaticLightmap, uvDynamicLightmap, applyScaling) shadergraph_LWBakedGI(positionWS, normalWS, uvStaticLightmap, uvDynamicLightmap, applyScaling) 7 | #define SHADERGRAPH_REFLECTION_PROBE(viewDir, normalOS, lod) shadergraph_LWReflectionProbe(viewDir, normalOS, lod) 8 | #define SHADERGRAPH_FOG(position, color, density) shadergraph_LWFog(position, color, density) 9 | #define SHADERGRAPH_AMBIENT_SKY unity_AmbientSky 10 | #define SHADERGRAPH_AMBIENT_EQUATOR unity_AmbientEquator 11 | #define SHADERGRAPH_AMBIENT_GROUND unity_AmbientGround 12 | 13 | #define _TimeParameters float4(_Time.y, _SinTime.w, _CosTime.w, 0) 14 | 15 | // #if defined(REQUIRE_DEPTH_TEXTURE) 16 | // #include "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/DeclareDepthTexture.hlsl" 17 | // #endif 18 | 19 | // #if defined(REQUIRE_OPAQUE_TEXTURE) 20 | // #include "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/DeclareOpaqueTexture.hlsl" 21 | // #endif 22 | 23 | 24 | #ifdef REQUIRE_DEPTH_TEXTURE 25 | TEXTURE2D_X_FLOAT(_CameraDepthTexture); 26 | SAMPLER(sampler_CameraDepthTexture); 27 | float4 _CameraDepthTexture_TexelSize; 28 | #endif 29 | 30 | float shadergraph_LWSampleSceneDepth(float2 uv) 31 | { 32 | // #if UNITY_SINGLE_PASS_STEREO 33 | // uv = TransformStereoScreenSpaceTex(uv, 1.0); 34 | // #endif 35 | 36 | #ifdef REQUIRE_DEPTH_TEXTURE 37 | return SAMPLE_TEXTURE2D_X(_CameraDepthTexture, sampler_CameraDepthTexture, uv).r; 38 | #else 39 | return 0; 40 | #endif 41 | } 42 | 43 | #ifdef REQUIRE_OPAQUE_TEXTURE 44 | TEXTURE2D_X(_CameraOpaqueTexture); 45 | SAMPLER(sampler_CameraOpaqueTexture); 46 | float4 _CameraOpaqueTexture_TexelSize; 47 | #endif 48 | 49 | float3 shadergraph_SampleSceneColorBuiltIn(float2 uv) 50 | { 51 | // #if UNITY_SINGLE_PASS_STEREO 52 | // uv = TransformStereoScreenSpaceTex(uv, 1.0); 53 | // #endif 54 | 55 | #ifdef REQUIRE_OPAQUE_TEXTURE 56 | return SAMPLE_TEXTURE2D_X(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, uv).rgb; 57 | #else 58 | return 0; 59 | #endif 60 | } 61 | 62 | // float3 shadergraph_LWSampleSceneColor(float2 uv) 63 | // { 64 | // #if defined(REQUIRE_OPAQUE_TEXTURE) 65 | // return SampleSceneColor(uv); 66 | // #else 67 | // return 0; 68 | // #endif 69 | // } 70 | 71 | float3 shadergraph_LWBakedGI(float3 positionWS, float3 normalWS, float2 uvStaticLightmap, float2 uvDynamicLightmap, bool applyScaling) 72 | { 73 | #ifdef LIGHTMAP_ON 74 | if (applyScaling) 75 | uvStaticLightmap = uvStaticLightmap * unity_LightmapST.xy + unity_LightmapST.zw; 76 | 77 | half4 lm = SAMPLE_TEXTURE2D_LOD(unity_Lightmap, samplerunity_Lightmap, uvStaticLightmap, 0); 78 | return lm; 79 | #else 80 | return ShadeSH9(float4(normalWS, 1.0)); 81 | #endif 82 | return 0; 83 | } 84 | 85 | float3 shadergraph_LWReflectionProbe(float3 viewDir, float3 normalOS, float lod) 86 | { 87 | float3 reflectVec = reflect(-viewDir, normalOS); 88 | return DecodeHDR(SAMPLE_TEXTURECUBE_LOD(unity_SpecCube0, samplerunity_SpecCube0, reflectVec, lod), unity_SpecCube0_HDR); 89 | } 90 | 91 | void shadergraph_LWFog(float3 position, out float4 color, out float density) 92 | { 93 | color = unity_FogColor; 94 | #if defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2) 95 | // ComputeFogFactor returns the fog density (0 for no fog and 1 for full fog). 96 | density = ComputeFogFactor(TransformObjectToHClip(position).z); 97 | #else 98 | density = 0.0f; 99 | #endif 100 | } 101 | 102 | // This function assumes the bitangent flip is encoded in tangentWS.w 103 | float3x3 BuildTangentToWorld(float4 tangentWS, float3 normalWS) 104 | { 105 | // tangentWS must not be normalized (mikkts requirement) 106 | 107 | // Normalize normalWS vector but keep the renormFactor to apply it to bitangent and tangent 108 | float3 unnormalizedNormalWS = normalWS; 109 | float renormFactor = 1.0 / length(unnormalizedNormalWS); 110 | 111 | // bitangent on the fly option in xnormal to reduce vertex shader outputs. 112 | // this is the mikktspace transformation (must use unnormalized attributes) 113 | float3x3 tangentToWorld = CreateTangentToWorld(unnormalizedNormalWS, tangentWS.xyz, tangentWS.w > 0.0 ? 1.0 : -1.0); 114 | 115 | // surface gradient based formulation requires a unit length initial normal. We can maintain compliance with mikkts 116 | // by uniformly scaling all 3 vectors since normalization of the perturbed normal will cancel it. 117 | tangentToWorld[0] = tangentToWorld[0] * renormFactor; 118 | tangentToWorld[1] = tangentToWorld[1] * renormFactor; 119 | tangentToWorld[2] = tangentToWorld[2] * renormFactor; // normalizes the interpolated vertex normal 120 | 121 | return tangentToWorld; 122 | } 123 | 124 | // Always include Shader Graph version 125 | // Always include last to avoid double macros 126 | #include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl" 127 | 128 | #endif // UNITY_GRAPHFUNCTIONS_LW_INCLUDED 129 | -------------------------------------------------------------------------------- /ShaderLibrary/ShaderGraphFunctions.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec84272f61936c8499c4463d316abada 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/ShaderPass.hlsl: -------------------------------------------------------------------------------- 1 | #pragma warning (disable : 1519) 2 | // #define QUALITY_LOW 3 | 4 | #define SHADERPASS_UNLIT 1 5 | #define SHADERPASS_FORWARDBASE 2 6 | #define SHADERPASS_FORWARDADD 3 7 | #define SHADERPASS_SHADOWCASTER 4 8 | #define SHADERPASS_META 5 9 | #define SHADERPASS_OUTLINE 6 10 | 11 | #if defined(UNITY_INSTANCING_ENABLED) || defined(STEREO_INSTANCING_ON) || defined(INSTANCING_ON) 12 | #define UNITY_ANY_INSTANCING_ENABLED 1 13 | #endif 14 | 15 | #ifdef STEREO_INSTANCING_ON 16 | #define UNITY_STEREO_INSTANCING_ENABLED 17 | #endif 18 | 19 | // #ifdef BUILD_TARGET_ANDROID 20 | // #define UNITY_PBS_USE_BRDF1 21 | // #define QUALITY_LOW 22 | // #endif 23 | 24 | #ifndef UNITY_PBS_USE_BRDF1 25 | #define QUALITY_LOW 26 | #endif 27 | 28 | #ifndef QUALITY_LOW 29 | #define VERTEXLIGHT_PS 30 | #endif 31 | 32 | #ifdef SHADER_API_MOBILE 33 | #define QUALITY_LOW 34 | #endif 35 | 36 | #if (SHADERPASS == SHADERPASS_OUTLINE) 37 | #undef _SSR 38 | #undef REQUIRE_DEPTH_TEXTURE 39 | #undef REQUIRE_OPAQUE_TEXTURE 40 | #undef LTCGI 41 | #undef _PARALLAXMAP 42 | #undef _AREALIT 43 | #define _NORMAL_DROPOFF_TS 0 44 | #define _NORMAL_DROPOFF_OS 0 45 | #define _NORMAL_DROPOFF_WS 0 46 | #define _GLOSSYREFLECTIONS_OFF 47 | #define _SPECULARHIGHLIGHTS_OFF 48 | #endif 49 | 50 | #ifdef QUALITY_LOW 51 | #undef _SSR 52 | #undef REQUIRE_DEPTH_TEXTURE 53 | #undef REQUIRE_OPAQUE_TEXTURE 54 | #undef LTCGI 55 | #undef _GEOMETRICSPECULAR_AA 56 | #undef NONLINEAR_LIGHTMAP_SH 57 | #undef UNITY_SPECCUBE_BLENDING 58 | #undef NONLINEAR_LIGHTPROBESH 59 | #define DISABLE_LIGHT_PROBE_PROXY_VOLUME 60 | #undef _PARALLAXMAP 61 | #undef _AREALIT 62 | 63 | #if defined(LIGHTMAP_ON) && !defined(SHADOWS_SHADOWMASK) && !defined(LIGHTMAP_SHADOW_MIXING) 64 | #undef DIRECTIONAL 65 | #endif 66 | #define DISABLE_NONIMPORTANT_LIGHTS_PER_PIXEL 67 | #endif 68 | 69 | #ifdef _SSR 70 | #define REQUIRE_DEPTH_TEXTURE 71 | #define REQUIRE_OPAQUE_TEXTURE 72 | #endif 73 | // 74 | #ifdef LTCGI_DIFFUSE_OFF 75 | #define LTCGI_DIFFUSE_DISABLED 76 | #undef LTCGI_DIFFUSE_OFF 77 | #endif 78 | 79 | #if defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2) 80 | #define FOG_ANY 81 | #endif 82 | 83 | #if defined(UNITY_PASS_FORWARDBASE) || defined(UNITY_PASS_FORWARDADD) 84 | #define UNITY_PASS_FORWARD 85 | #endif 86 | 87 | #if defined(SHADOWS_SCREEN) || defined(SHADOWS_SHADOWMASK) || defined(LIGHTMAP_SHADOW_MIXING) 88 | #define VARYINGS_NEED_SHADOWCOORD 89 | #define ATTRIBUTES_NEED_TEXCOORD1 90 | #endif 91 | 92 | #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" 93 | // #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl" 94 | #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl" 95 | #include "Packages/io.z3y.github.shadergraph/ShaderLibrary/Core.hlsl" 96 | // #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" 97 | 98 | // prevent redefinition warnings in the shader importer 99 | #undef GLOBAL_CBUFFER_START 100 | #undef SAMPLE_DEPTH_TEXTURE 101 | #undef SAMPLE_DEPTH_TEXTURE_LOD 102 | 103 | #include "Packages/io.z3y.github.shadergraph/ShaderLibrary/UnityCG/ShaderVariablesMatrixDefsLegacyUnity.hlsl" 104 | 105 | // #undef GLOBAL_CBUFFER_START // dont need reg 106 | // #define GLOBAL_CBUFFER_START(name) CBUFFER_START(name) 107 | 108 | #define Unity_SafeNormalize SafeNormalize 109 | 110 | #include "UnityShaderVariables.cginc" 111 | half4 _LightColor0; 112 | half4 _SpecColor; 113 | 114 | #include "Packages/io.z3y.github.shadergraph/ShaderLibrary/UnityCG/UnityCG.hlsl" 115 | #include "AutoLight.cginc" 116 | // #include "Packages/io.z3y.github.shadergraph/ShaderLibrary/ShaderGraphFunctions.hlsl" 117 | #include "UnityShaderUtilities.cginc" 118 | 119 | #ifdef UNITY_PASS_META 120 | #define IsGammaSpace() false 121 | #include "UnityMetaPass.cginc" 122 | #undef IsGammaSpace 123 | #endif 124 | 125 | #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityInstancing.hlsl" 126 | #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl" 127 | 128 | // #define CustomLightData UnityLightData 129 | struct UnityLightData 130 | { 131 | half3 color; 132 | float3 direction; 133 | half attenuation; 134 | }; 135 | 136 | 137 | inline float4 ComputeGrabScreenPos(float4 pos) 138 | { 139 | #if UNITY_UV_STARTS_AT_TOP 140 | float scale = -1.0; 141 | #else 142 | float scale = 1.0; 143 | #endif 144 | float4 o = pos * 0.5f; 145 | o.xy = float2(o.x, o.y*scale) + o.w; 146 | #ifdef UNITY_SINGLE_PASS_STEREO 147 | o.xy = TransformStereoScreenSpaceTexBuiltIn(o.xy, pos.w); 148 | #endif 149 | o.zw = pos.zw; 150 | return o; 151 | } 152 | 153 | #define UNITY_SHADER_VARIABLES_FUNCTIONS_DEPRECATED_INCLUDED 154 | #define BUILTIN_TARGET_API 155 | float4 _ScaledScreenParams; 156 | float4 _ScaleBiasRt; 157 | #include "Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/ShaderVariablesFunctions.hlsl" 158 | #undef BUILTIN_TARGET_API 159 | 160 | // unity macros need workaround 161 | struct LegacyAttributes 162 | { 163 | float4 vertex; 164 | float3 normal; 165 | }; 166 | 167 | struct LegacyVaryings 168 | { 169 | float4 pos; 170 | float4 _ShadowCoord; 171 | }; 172 | 173 | 174 | struct ShaderData 175 | { 176 | float3 normalWS; 177 | float3 bitangentWS; 178 | float3 tangentWS; 179 | float3 viewDirectionWS; 180 | half perceptualRoughness; 181 | half clampedRoughness; 182 | half NoV; 183 | half3 f0; 184 | half3 brdf; 185 | half3 energyCompensation; 186 | float3 reflectionDirection; 187 | }; 188 | 189 | struct GIData 190 | { 191 | half3 IndirectDiffuse; 192 | half3 Light; 193 | half3 Reflections; 194 | half3 Specular; 195 | }; 196 | 197 | #define UNITY_PI PI 198 | #define UNITY_HALF_PI PI/2. 199 | #define UNITY_TWO_PI PI*2 -------------------------------------------------------------------------------- /ShaderLibrary/ShaderPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9cd14456e254cd54782bb9c6c2e8963d 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/Structs.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e933e775e07407d45a88a274cf1bfe87 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/SurfaceData.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef BUILTIN_SURFACE_DATA_INCLUDED 2 | #define BUILTIN_SURFACE_DATA_INCLUDED 3 | 4 | // Must match BuiltIn ShaderGraph master node 5 | struct SurfaceData 6 | { 7 | half3 albedo; 8 | half3 specular; 9 | half metallic; 10 | half smoothness; 11 | half3 normalTS; 12 | half3 emission; 13 | half occlusion; 14 | half alpha; 15 | half clearCoatMask; 16 | half clearCoatSmoothness; 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /ShaderLibrary/SurfaceData.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c7c4cb4d661ae174f848a59f106fef9c 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/TerrainInput.hlsl: -------------------------------------------------------------------------------- 1 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt) 2 | 3 | // #define TERRAIN_STANDARD_SHADER 4 | #ifndef TERRAIN_SPLATMAP_COMMON_HLSL_INCLUDED 5 | #define TERRAIN_SPLATMAP_COMMON_HLSL_INCLUDED 6 | 7 | 8 | CBUFFER_START(_Terrain) 9 | float4 _Splat0_ST; 10 | float4 _Splat1_ST; 11 | float4 _Splat2_ST; 12 | float4 _Splat3_ST; 13 | 14 | float4 _Control_ST; 15 | float4 _Control_TexelSize; 16 | 17 | half _NormalScale0; 18 | half _NormalScale1; 19 | half _NormalScale2; 20 | half _NormalScale3; 21 | 22 | half _Metallic0; 23 | half _Metallic1; 24 | half _Metallic2; 25 | half _Metallic3; 26 | 27 | half _Smoothness0; 28 | half _Smoothness1; 29 | half _Smoothness2; 30 | half _Smoothness3; 31 | 32 | half _HeightTransition; 33 | 34 | #if defined(UNITY_INSTANCING_ENABLED) 35 | float4 _TerrainHeightmapRecipSize; // float4(1.0f/width, 1.0f/height, 1.0f/(width-1), 1.0f/(height-1)) 36 | float4 _TerrainHeightmapScale; // float4(hmScale.x, hmScale.y / (float)(kMaxHeight), hmScale.z, 0.0f) 37 | #endif 38 | CBUFFER_END 39 | 40 | UNITY_INSTANCING_BUFFER_START(Terrain) 41 | UNITY_DEFINE_INSTANCED_PROP(float4, _TerrainPatchInstanceData) // float4(xBase, yBase, skipScale, ~) 42 | UNITY_INSTANCING_BUFFER_END(Terrain) 43 | 44 | #if defined(UNITY_INSTANCING_ENABLED) 45 | TEXTURE2D(_TerrainHeightmapTexture); 46 | SAMPLER(sampler_TerrainHeightmapTexture); 47 | TEXTURE2D(_TerrainNormalmapTexture); 48 | SAMPLER(sampler_TerrainNormalmapTexture); 49 | #endif 50 | 51 | 52 | TEXTURE2D(_Control); SAMPLER(sampler_Control); 53 | TEXTURE2D(_Splat0); SAMPLER(sampler_Splat0); 54 | TEXTURE2D(_Splat1); 55 | TEXTURE2D(_Splat2); 56 | TEXTURE2D(_Splat3); 57 | 58 | #ifdef _NORMALMAP 59 | TEXTURE2D(_Normal0); SAMPLER(sampler_Normal0); 60 | TEXTURE2D(_Normal1); 61 | TEXTURE2D(_Normal2); 62 | TEXTURE2D(_Normal3); 63 | #endif 64 | 65 | #ifdef _MASKMAP 66 | TEXTURE2D(_Mask0); SAMPLER(sampler_Mask0); 67 | TEXTURE2D(_Mask1); 68 | TEXTURE2D(_Mask2); 69 | TEXTURE2D(_Mask3); 70 | #endif 71 | 72 | #ifdef _ALPHATEST_ON 73 | TEXTURE2D(_TerrainHolesTexture); 74 | SAMPLER(sampler_TerrainHolesTexture); 75 | 76 | void ClipHoles(float2 uv) 77 | { 78 | float hole = SAMPLE_TEXTURE2D(_TerrainHolesTexture, sampler_TerrainHolesTexture, uv).r; 79 | clip(hole == 0.0f ? -1 : 1); 80 | } 81 | #endif 82 | 83 | void TerrainInstancing(inout float3 positionOS, inout float3 normalOS, inout float2 uv) 84 | { 85 | #ifdef UNITY_INSTANCING_ENABLED 86 | float2 patchVertex = positionOS.xy; 87 | float4 instanceData = UNITY_ACCESS_INSTANCED_PROP(Terrain, _TerrainPatchInstanceData); 88 | 89 | float2 sampleCoords = (patchVertex.xy + instanceData.xy) * instanceData.z; // (xy + float2(xBase,yBase)) * skipScale 90 | float height = UnpackHeightmap(_TerrainHeightmapTexture.Load(int3(sampleCoords, 0))); 91 | 92 | positionOS.xz = sampleCoords * _TerrainHeightmapScale.xz; 93 | positionOS.y = height * _TerrainHeightmapScale.y; 94 | 95 | #ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL 96 | normalOS = float3(0, 1, 0); 97 | #else 98 | normalOS = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb * 2 - 1; 99 | #endif 100 | uv = sampleCoords * _TerrainHeightmapRecipSize.zw; 101 | #endif 102 | } 103 | 104 | float4 ComputeTerrainTangent(float3 normalOS) 105 | { 106 | float4 vertexTangent = float4(cross(normalOS, float3(0.0, 0.0, 1.0)), 1.0); 107 | return vertexTangent; 108 | } 109 | 110 | void NormalMapMix(float4 uvSplat01, float4 uvSplat23, inout half4 splatControl, inout half3 mixedNormal) 111 | { 112 | #if defined(_NORMALMAP) 113 | half3 nrm = half(0.0); 114 | nrm += splatControl.r * UnpackNormalScale(SAMPLE_TEXTURE2D(_Normal0, sampler_Normal0, uvSplat01.xy), _NormalScale0); 115 | nrm += splatControl.g * UnpackNormalScale(SAMPLE_TEXTURE2D(_Normal1, sampler_Normal0, uvSplat01.zw), _NormalScale1); 116 | nrm += splatControl.b * UnpackNormalScale(SAMPLE_TEXTURE2D(_Normal2, sampler_Normal0, uvSplat23.xy), _NormalScale2); 117 | nrm += splatControl.a * UnpackNormalScale(SAMPLE_TEXTURE2D(_Normal3, sampler_Normal0, uvSplat23.zw), _NormalScale3); 118 | 119 | // avoid risk of NaN when normalizing. 120 | #if HAS_HALF 121 | nrm.z += half(0.01); 122 | #else 123 | nrm.z += 1e-5f; 124 | #endif 125 | 126 | mixedNormal = normalize(nrm.xyz); 127 | #endif 128 | } 129 | 130 | void SplatmapMix(float4 uvSplat01, float4 uvSplat23, inout half4 splatControl, out half weight, out half4 mixedDiffuse, out half4 defaultSmoothness, inout half3 mixedNormal) 131 | { 132 | half4 diffAlbedo[4]; 133 | 134 | diffAlbedo[0] = SAMPLE_TEXTURE2D(_Splat0, sampler_Splat0, uvSplat01.xy); 135 | diffAlbedo[1] = SAMPLE_TEXTURE2D(_Splat1, sampler_Splat0, uvSplat01.zw); 136 | diffAlbedo[2] = SAMPLE_TEXTURE2D(_Splat2, sampler_Splat0, uvSplat23.xy); 137 | diffAlbedo[3] = SAMPLE_TEXTURE2D(_Splat3, sampler_Splat0, uvSplat23.zw); 138 | 139 | // This might be a bit of a gamble -- the assumption here is that if the diffuseMap has no 140 | // alpha channel, then diffAlbedo[n].a = 1.0 (and _DiffuseHasAlphaN = 0.0) 141 | // Prior to coming in, _SmoothnessN is actually set to max(_DiffuseHasAlphaN, _SmoothnessN) 142 | // This means that if we have an alpha channel, _SmoothnessN is locked to 1.0 and 143 | // otherwise, the true slider value is passed down and diffAlbedo[n].a == 1.0. 144 | defaultSmoothness = half4(diffAlbedo[0].a, diffAlbedo[1].a, diffAlbedo[2].a, diffAlbedo[3].a); 145 | defaultSmoothness *= half4(_Smoothness0, _Smoothness1, _Smoothness2, _Smoothness3); 146 | 147 | #ifndef _TERRAIN_BLEND_HEIGHT // density blending 148 | // // 20.0 is the number of steps in inputAlphaMask (Density mask. We decided 20 empirically) 149 | // half4 opacityAsDensity = saturate((half4(diffAlbedo[0].a, diffAlbedo[1].a, diffAlbedo[2].a, diffAlbedo[3].a) - (1 - splatControl)) * 20.0); 150 | // opacityAsDensity += 0.001h * splatControl; // if all weights are zero, default to what the blend mask says 151 | // half4 useOpacityAsDensityParam = { _DiffuseRemapScale0.w, _DiffuseRemapScale1.w, _DiffuseRemapScale2.w, _DiffuseRemapScale3.w }; // 1 is off 152 | // splatControl = lerp(opacityAsDensity, splatControl, useOpacityAsDensityParam); 153 | #endif 154 | 155 | // Now that splatControl has changed, we can compute the final weight and normalize 156 | weight = dot(splatControl, 1.0); 157 | 158 | #ifdef TERRAIN_SPLAT_ADDPASS 159 | clip(weight <= 0.005h ? -1.0 : 1.0); 160 | #endif 161 | 162 | #ifndef _TERRAIN_BASEMAP_GEN 163 | // Normalize weights before lighting and restore weights in final modifier functions so that the overal 164 | // lighting result can be correctly weighted. 165 | splatControl /= (weight + HALF_MIN); 166 | #endif 167 | 168 | // mixedDiffuse = 0.0; 169 | // mixedDiffuse += diffAlbedo[0] * half4(_DiffuseRemapScale0.rgb * splatControl.rrr, 1.0); 170 | // mixedDiffuse += diffAlbedo[1] * half4(_DiffuseRemapScale1.rgb * splatControl.ggg, 1.0); 171 | // mixedDiffuse += diffAlbedo[2] * half4(_DiffuseRemapScale2.rgb * splatControl.bbb, 1.0); 172 | // mixedDiffuse += diffAlbedo[3] * half4(_DiffuseRemapScale3.rgb * splatControl.aaa, 1.0); 173 | mixedDiffuse = 0.0; 174 | mixedDiffuse += diffAlbedo[0] * half4(splatControl.rrr, 1.0); 175 | mixedDiffuse += diffAlbedo[1] * half4(splatControl.ggg, 1.0); 176 | mixedDiffuse += diffAlbedo[2] * half4(splatControl.bbb, 1.0); 177 | mixedDiffuse += diffAlbedo[3] * half4(splatControl.aaa, 1.0); 178 | 179 | NormalMapMix(uvSplat01, uvSplat23, splatControl, mixedNormal); 180 | } 181 | 182 | void HeightBasedSplatModify(inout half4 splatControl, half4 masks) 183 | { 184 | half4 splatHeight = masks * splatControl.rgba; 185 | half maxHeight = max(splatHeight.r, max(splatHeight.g, max(splatHeight.b, splatHeight.a))); 186 | 187 | // Ensure that the transition height is not zero. 188 | half transition = max(_HeightTransition, 1e-5); 189 | 190 | // This sets the highest splat to "transition", and everything else to a lower value relative to that, clamping to zero 191 | // Then we clamp this to zero and normalize everything 192 | half4 weightedHeights = splatHeight + transition - maxHeight.xxxx; 193 | weightedHeights = max(0, weightedHeights); 194 | 195 | // We need to add an epsilon here for active layers (hence the blendMask again) 196 | // so that at least a layer shows up if everything's too low. 197 | weightedHeights = (weightedHeights + 1e-6) * splatControl; 198 | 199 | // Normalize (and clamp to epsilon to keep from dividing by zero) 200 | half sumHeight = max(dot(weightedHeights, half4(1, 1, 1, 1)), 1e-6); 201 | splatControl = weightedHeights / sumHeight.xxxx; 202 | } 203 | 204 | #endif 205 | -------------------------------------------------------------------------------- /ShaderLibrary/TerrainInput.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 42744151dad812545b4a502c25dcb076 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/UnityCG.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ceb517c4c02fa74db5edf262fc6f82a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ShaderLibrary/UnityCG/ShaderVariablesMatrixDefsLegacyUnity.hlsl: -------------------------------------------------------------------------------- 1 | #ifdef UNITY_SHADER_VARIABLES_MATRIX_DEFS_HDCAMERA_INCLUDED 2 | #error Mixing HDCamera and legacy Unity matrix definitions 3 | #endif 4 | 5 | #ifndef UNITY_SHADER_VARIABLES_MATRIX_DEFS_LEGACY_UNITY_INCLUDED 6 | #define UNITY_SHADER_VARIABLES_MATRIX_DEFS_LEGACY_UNITY_INCLUDED 7 | 8 | #define UNITY_MATRIX_M unity_ObjectToWorld 9 | #define UNITY_MATRIX_I_M unity_WorldToObject 10 | #define UNITY_MATRIX_V unity_MatrixV 11 | #define UNITY_MATRIX_I_V unity_MatrixInvV 12 | // #define UNITY_MATRIX_P OptimizeProjectionMatrix(glstate_matrix_projection) 13 | #define UNITY_MATRIX_I_P ERROR_UNITY_MATRIX_I_P_IS_NOT_DEFINED 14 | #define UNITY_MATRIX_VP unity_MatrixVP 15 | 16 | // #define UNITY_MATRIX_I_VP ERROR_UNITY_MATRIX_I_VP_IS_NOT_DEFINED // causes error in orthographics branch 17 | #define UNITY_MATRIX_I_VP 0 // incorrect but set to 0 to let the compiler optimized out the branch in generated code 18 | 19 | 20 | // #define UNITY_MATRIX_MV mul(UNITY_MATRIX_V, UNITY_MATRIX_M) 21 | // #define UNITY_MATRIX_T_MV transpose(UNITY_MATRIX_MV) 22 | // #define UNITY_MATRIX_IT_MV transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V)) 23 | // #define UNITY_MATRIX_MVP mul(UNITY_MATRIX_VP, UNITY_MATRIX_M) 24 | 25 | #endif // UNITY_SHADER_VARIABLES_MATRIX_DEFS_LEGACY_UNITY_INCLUDED -------------------------------------------------------------------------------- /ShaderLibrary/UnityCG/ShaderVariablesMatrixDefsLegacyUnity.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 79e560ccb923b624f8ad4c9dbb360ad9 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/UnityCG/UnityCG.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc85c324c73f59145bc3fae4a4cb6b87 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/UnityCG/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Unity Technologies 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /ShaderLibrary/UnityCG/license.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78d88399ac3cb5b4eb7f8ed2637c0d65 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/Vertex.hlsl: -------------------------------------------------------------------------------- 1 | Varyings BuildVaryings(Attributes input) 2 | { 3 | Varyings output = (Varyings)0; 4 | 5 | UNITY_SETUP_INSTANCE_ID(input); 6 | UNITY_TRANSFER_INSTANCE_ID(input, output); 7 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); 8 | 9 | VertexDescription description = VertexDescriptionFunction(BuildVertexDescriptionInputs(input)); 10 | input.positionOS = description.Position; 11 | input.normalOS.xyz = description.Normal.xyz; 12 | input.tangentOS.xyz = description.Tangent.xyz; 13 | 14 | #if defined(CUSTOMINTERPOLATOR_VARYPASSTHROUGH_FUNC) 15 | CustomInterpolatorPassThroughFunc(output, description); 16 | #endif 17 | 18 | float3 positionWS = TransformObjectToWorld(input.positionOS); 19 | #if defined(ATTRIBUTES_NEED_NORMAL) 20 | float3 normalWS = TransformObjectToWorldNormal(input.normalOS); 21 | #endif 22 | #if defined(ATTRIBUTES_NEED_TANGENT) 23 | float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w); 24 | #endif 25 | 26 | LegacyAttributes v = (LegacyAttributes)0; 27 | LegacyVaryings o = (LegacyVaryings)0; 28 | v.vertex = float4(input.positionOS.xyz, 1); 29 | #if defined(ATTRIBUTES_NEED_NORMAL) 30 | v.normal = input.normalOS.xyz; 31 | #endif 32 | 33 | #if defined(UNITY_PASS_META) 34 | output.positionCS = UnityMetaVertexPosition(float4(TransformWorldToObject(positionWS), 0), input.uv1, input.uv2, unity_LightmapST, unity_DynamicLightmapST); 35 | #elif defined(UNITY_PASS_SHADOWCASTER) 36 | output.positionCS = TransformWorldToHClip(ApplyShadowBiasNormal(positionWS, normalWS)); 37 | output.positionCS = UnityApplyLinearShadowBias(output.positionCS); 38 | #else 39 | output.positionCS = TransformWorldToHClip(positionWS); 40 | #endif 41 | 42 | #if defined(VARYINGS_NEED_NORMAL_WS) 43 | output.normalWS = normalWS; 44 | #endif 45 | #if defined(VARYINGS_NEED_TANGENT_WS) 46 | output.tangentWS = tangentWS; 47 | #endif 48 | #if defined(VARYINGS_NEED_POSITION_WS) 49 | output.positionWS = positionWS; 50 | #endif 51 | 52 | #if defined(VARYINGS_NEED_TEXCOORD0) 53 | output.texCoord0 = input.uv0; 54 | #endif 55 | #if defined(VARYINGS_NEED_TEXCOORD1) 56 | output.texCoord1 = input.uv1; 57 | #endif 58 | #if defined(VARYINGS_NEED_TEXCOORD2) 59 | output.texCoord2 = input.uv2; 60 | #endif 61 | #if defined(VARYINGS_NEED_TEXCOORD3) 62 | output.texCoord3 = input.uv3; 63 | #endif 64 | 65 | 66 | #if defined(LIGHTMAP_ON) && (SHADERPASS != SHADERPASS_UNLIT) 67 | output.lightmapUV.xy = input.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw; 68 | #endif 69 | #if defined(DYNAMICLIGHTMAP_ON) && (SHADERPASS != SHADERPASS_UNLIT) 70 | output.lightmapUV.zw = input.uv2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;; 71 | #endif 72 | 73 | #if defined(VARYINGS_NEED_COLOR) 74 | output.color = input.color; 75 | #endif 76 | 77 | #if defined(FOG_EXP) || defined(FOG_EXP2) || defined(FOG_LINEAR) 78 | UNITY_TRANSFER_FOG(output, output.positionCS); 79 | #endif 80 | 81 | #if defined(VARYINGS_NEED_SHADOWCOORD) 82 | o.pos = output.positionCS; 83 | o._ShadowCoord = output.shadowCoord; 84 | UNITY_TRANSFER_SHADOW(o, input.uv1.xy); 85 | output.shadowCoord = o._ShadowCoord; 86 | output.positionCS = o.pos; 87 | #endif 88 | 89 | #if defined(EDITOR_VISUALIZATION) 90 | output.vizUV = 0; 91 | output.lightCoord = 0; 92 | if (unity_VisualizationMode == EDITORVIZ_TEXTURE) 93 | { 94 | output.vizUV = UnityMetaVizUV(unity_EditorViz_UVIndex, input.uv0.xy, input.uv1.xy, input.uv2.xy, unity_EditorViz_Texture_ST); 95 | } 96 | else if (unity_VisualizationMode == EDITORVIZ_SHOWLIGHTMASK) 97 | { 98 | output.vizUV = input.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw; 99 | output.lightCoord = mul(unity_EditorViz_WorldToLight, mul(unity_ObjectToWorld, float4(input.positionOS.xyz, 1))); 100 | } 101 | #endif 102 | 103 | // #if defined(VERTEXLIGHT_ON) && !defined(VERTEXLIGHT_PS) 104 | // output.vertexLight = Shade4PointLights 105 | // ( 106 | // unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, 107 | // unity_LightColor[0].rgb, unity_LightColor[1].rgb, 108 | // unity_LightColor[2].rgb, unity_LightColor[3].rgb, 109 | // unity_4LightAtten0, output.positionWS, output.normalWS 110 | // ); 111 | // #endif 112 | 113 | return output; 114 | } 115 | 116 | PackedVaryings vert(Attributes input) 117 | { 118 | Varyings output = (Varyings)0; 119 | output = BuildVaryings(input); 120 | PackedVaryings packedOutput = PackVaryings(output); 121 | return packedOutput; 122 | } -------------------------------------------------------------------------------- /ShaderLibrary/Vertex.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 56b896358ee9eb041a4621a90f224864 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderLibrary/dfg-multiscatter.exr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z3y/ShaderGraphVRC/06f7fe1b209c11e32045883d1a6f54e37dfb5b82/ShaderLibrary/dfg-multiscatter.exr -------------------------------------------------------------------------------- /ShaderLibrary/dfg-multiscatter.exr.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83d5abfd23f37a645bb0bc0e39aae43a 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 12 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | vTOnly: 0 27 | ignoreMasterTextureLimit: 0 28 | grayScaleToAlpha: 0 29 | generateCubemap: 6 30 | cubemapConvolution: 0 31 | seamlessCubemap: 0 32 | textureFormat: 1 33 | maxTextureSize: 2048 34 | textureSettings: 35 | serializedVersion: 2 36 | filterMode: 1 37 | aniso: 1 38 | mipBias: 0 39 | wrapU: 1 40 | wrapV: 1 41 | wrapW: 1 42 | nPOTScale: 1 43 | lightmap: 0 44 | compressionQuality: 50 45 | spriteMode: 0 46 | spriteExtrude: 1 47 | spriteMeshType: 1 48 | alignment: 0 49 | spritePivot: {x: 0.5, y: 0.5} 50 | spritePixelsToUnits: 100 51 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 52 | spriteGenerateFallbackPhysicsShape: 1 53 | alphaUsage: 0 54 | alphaIsTransparency: 0 55 | spriteTessellationDetail: -1 56 | textureType: 0 57 | textureShape: 1 58 | singleChannelComponent: 0 59 | flipbookRows: 1 60 | flipbookColumns: 1 61 | maxTextureSizeSet: 0 62 | compressionQualitySet: 0 63 | textureFormatSet: 0 64 | ignorePngGamma: 0 65 | applyGammaDecoding: 0 66 | cookieLightType: 0 67 | platformSettings: 68 | - serializedVersion: 3 69 | buildTarget: DefaultTexturePlatform 70 | maxTextureSize: 2048 71 | resizeAlgorithm: 1 72 | textureFormat: 3 73 | textureCompression: 0 74 | compressionQuality: 50 75 | crunchedCompression: 0 76 | allowsAlphaSplitting: 0 77 | overridden: 0 78 | androidETC2FallbackOverride: 0 79 | forceMaximumCompressionQuality_BC6H_BC7: 0 80 | - serializedVersion: 3 81 | buildTarget: Standalone 82 | maxTextureSize: 2048 83 | resizeAlgorithm: 0 84 | textureFormat: -1 85 | textureCompression: 1 86 | compressionQuality: 50 87 | crunchedCompression: 0 88 | allowsAlphaSplitting: 0 89 | overridden: 0 90 | androidETC2FallbackOverride: 0 91 | forceMaximumCompressionQuality_BC6H_BC7: 0 92 | - serializedVersion: 3 93 | buildTarget: Server 94 | maxTextureSize: 2048 95 | resizeAlgorithm: 0 96 | textureFormat: -1 97 | textureCompression: 1 98 | compressionQuality: 50 99 | crunchedCompression: 0 100 | allowsAlphaSplitting: 0 101 | overridden: 0 102 | androidETC2FallbackOverride: 0 103 | forceMaximumCompressionQuality_BC6H_BC7: 0 104 | spriteSheet: 105 | serializedVersion: 2 106 | sprites: [] 107 | outline: [] 108 | physicsShape: [] 109 | bones: [] 110 | spriteID: 111 | internalID: 0 112 | vertices: [] 113 | indices: 114 | edges: [] 115 | weights: [] 116 | secondaryTextures: [] 117 | nameFileIdTable: {} 118 | spritePackingTag: 119 | pSDRemoveMatte: 0 120 | pSDShowRemoveMatteOption: 0 121 | userData: 122 | assetBundleName: 123 | assetBundleVariant: 124 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "io.z3y.github.shadergraph", 3 | "description": "Shader Graph Built-In Target for VRChat", 4 | "version": "1.1.1", 5 | "unity": "2022.3", 6 | "displayName": "Shader Graph VRC", 7 | "hideInEditor": false, 8 | "gitDependencies": {}, 9 | "vpmDependencies": {}, 10 | "legacyFolders": {}, 11 | "legacyFiles": {}, 12 | "dependencies": { 13 | "com.unity.shadergraph": "14.0.10" 14 | }, 15 | "author": { 16 | "name": "z3y", 17 | "url": "https://github.com/z3y" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f57bd24dcf3e0994b91adf51710ad33c 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------