├── .github └── FUNDING.yml ├── .gitignore ├── CoreRP.meta ├── CoreRP ├── ShaderLibrary.meta ├── ShaderLibrary │ ├── ACES.hlsl │ ├── ACES.hlsl.meta │ ├── API.meta │ ├── API │ │ ├── D3D11.hlsl │ │ ├── D3D11.hlsl.meta │ │ ├── GLCore.hlsl │ │ ├── GLCore.hlsl.meta │ │ ├── GLES2.hlsl │ │ ├── GLES2.hlsl.meta │ │ ├── GLES3.hlsl │ │ ├── GLES3.hlsl.meta │ │ ├── Metal.hlsl │ │ ├── Metal.hlsl.meta │ │ ├── Switch.hlsl │ │ ├── Switch.hlsl.meta │ │ ├── Validate.hlsl │ │ ├── Validate.hlsl.meta │ │ ├── Vulkan.hlsl │ │ └── Vulkan.hlsl.meta │ ├── AreaLighting.hlsl │ ├── AreaLighting.hlsl.meta │ ├── BC6H.hlsl │ ├── BC6H.hlsl.meta │ ├── BSDF.hlsl │ ├── BSDF.hlsl.meta │ ├── Color.hlsl │ ├── Color.hlsl.meta │ ├── Common.hlsl │ ├── Common.hlsl.meta │ ├── CommonDeprecated.hlsl │ ├── CommonDeprecated.hlsl.meta │ ├── CommonLighting.hlsl │ ├── CommonLighting.hlsl.meta │ ├── CommonMaterial.hlsl │ ├── CommonMaterial.hlsl.meta │ ├── CommonShadow.hlsl │ ├── CommonShadow.hlsl.meta │ ├── Debug.hlsl │ ├── Debug.hlsl.meta │ ├── EntityLighting.hlsl │ ├── EntityLighting.hlsl.meta │ ├── Filtering.hlsl │ ├── Filtering.hlsl.meta │ ├── GeometricTools.hlsl │ ├── GeometricTools.hlsl.meta │ ├── GraniteShaderLibBase.hlsl │ ├── GraniteShaderLibBase.hlsl.meta │ ├── ImageBasedLighting.hlsl │ ├── ImageBasedLighting.hlsl.meta │ ├── Macros.hlsl │ ├── Macros.hlsl.meta │ ├── MetaPass.hlsl │ ├── MetaPass.hlsl.meta │ ├── NormalSurfaceGradient.hlsl │ ├── NormalSurfaceGradient.hlsl.meta │ ├── Packing.hlsl │ ├── Packing.hlsl.meta │ ├── ParallaxMapping.hlsl │ ├── ParallaxMapping.hlsl.meta │ ├── PerPixelDisplacement.hlsl │ ├── PerPixelDisplacement.hlsl.meta │ ├── PhysicalCamera.hlsl │ ├── PhysicalCamera.hlsl.meta │ ├── Random.hlsl │ ├── Random.hlsl.meta │ ├── Refraction.hlsl │ ├── Refraction.hlsl.meta │ ├── SDF2D.hlsl │ ├── SDF2D.hlsl.meta │ ├── Sampling.meta │ ├── Sampling │ │ ├── Fibonacci.hlsl │ │ ├── Fibonacci.hlsl.meta │ │ ├── Hammersley.hlsl │ │ ├── Hammersley.hlsl.meta │ │ ├── SampleUVMapping.hlsl │ │ ├── SampleUVMapping.hlsl.meta │ │ ├── SampleUVMappingInternal.hlsl │ │ ├── SampleUVMappingInternal.hlsl.meta │ │ ├── SampleUVMappingNormalInternal.hlsl │ │ ├── SampleUVMappingNormalInternal.hlsl.meta │ │ ├── Sampling.hlsl │ │ └── Sampling.hlsl.meta │ ├── Shadow.meta │ ├── Shadow │ │ ├── ShadowSamplingTent.hlsl │ │ └── ShadowSamplingTent.hlsl.meta │ ├── SpaceFillingCurves.hlsl │ ├── SpaceFillingCurves.hlsl.meta │ ├── SpaceTransforms.hlsl │ ├── SpaceTransforms.hlsl.meta │ ├── Tessellation.hlsl │ ├── Tessellation.hlsl.meta │ ├── Texture.hlsl │ ├── Texture.hlsl.meta │ ├── TextureStack.hlsl │ ├── TextureStack.hlsl.meta │ ├── UnityDOTSInstancing.hlsl │ ├── UnityDOTSInstancing.hlsl.meta │ ├── UnityInstancing.hlsl │ ├── UnityInstancing.hlsl.meta │ ├── Version.hlsl │ ├── Version.hlsl.meta │ ├── VirtualTexturing.hlsl │ ├── VirtualTexturing.hlsl.meta │ ├── VolumeRendering.hlsl │ └── VolumeRendering.hlsl.meta ├── Unity LICENSE.txt └── Unity LICENSE.txt.meta ├── CustomLighting.meta ├── CustomLighting ├── Bakery.cginc ├── Bakery.cginc.meta ├── BicubicSampling.cginc ├── BicubicSampling.cginc.meta ├── CommonFunctions.cginc ├── CommonFunctions.cginc.meta ├── Core.cginc ├── Core.cginc.meta ├── EnvironmentBRDF.cginc ├── EnvironmentBRDF.cginc.meta ├── FlatLit.cginc ├── FlatLit.cginc.meta ├── LICENSE.txt ├── LICENSE.txt.meta ├── NonImportantLights.cginc ├── NonImportantLights.cginc.meta ├── SurfaceData.cginc └── SurfaceData.cginc.meta ├── Editor.meta ├── Editor ├── Importer.cs ├── Importer.cs.meta ├── ImporterEditor.cs ├── ImporterEditor.cs.meta ├── ImporterSettings.cs ├── ImporterSettings.cs.meta ├── LICENSE.txt ├── LICENSE.txt.meta ├── Resources.meta ├── Resources │ ├── ShaderGraphImporterIcon0.png │ ├── ShaderGraphImporterIcon0.png.meta │ ├── ShaderGraphImporterIcon1.png │ └── ShaderGraphImporterIcon1.png.meta ├── ShaderGraphInspector.cs ├── ShaderGraphInspector.cs.meta ├── VRCFallbackTags.cs ├── VRCFallbackTags.cs.meta ├── com.z3y.shadergraph-builtin.asmdef ├── com.z3y.shadergraph-builtin.asmdef.meta ├── dfg-multiscatter.exr └── dfg-multiscatter.exr.meta ├── README.md ├── README.md.meta ├── Samples.meta ├── Samples ├── .shader ├── Flat Lit.asset ├── Flat Lit.asset.meta ├── Flat Lit.shader ├── Flat Lit.shader.meta ├── Standard.asset ├── Standard.asset.meta ├── Standard.shader └── Standard.shader.meta ├── ShaderGraph.meta ├── ShaderGraph ├── Editor.meta ├── Editor │ ├── Generation.meta │ └── Generation │ │ ├── Targets.meta │ │ └── Targets │ │ ├── BuiltIn.meta │ │ └── BuiltIn │ │ ├── Editor.meta │ │ ├── Editor │ │ ├── ShaderGraph.meta │ │ └── ShaderGraph │ │ │ ├── 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 │ │ │ ├── SpriteForwardPass.hlsl │ │ │ ├── SpriteForwardPass.hlsl.meta │ │ │ ├── SpriteLitPass.hlsl │ │ │ ├── SpriteLitPass.hlsl.meta │ │ │ ├── SpriteNormalPass.hlsl │ │ │ ├── SpriteNormalPass.hlsl.meta │ │ │ ├── SpriteUnlitPass.hlsl │ │ │ ├── SpriteUnlitPass.hlsl.meta │ │ │ ├── UnlitPass.hlsl │ │ │ ├── UnlitPass.hlsl.meta │ │ │ ├── Varyings.hlsl │ │ │ └── Varyings.hlsl.meta │ │ ├── ShaderLibrary.meta │ │ └── ShaderLibrary │ │ ├── AdditionalFunctions.hlsl │ │ ├── AdditionalFunctions.hlsl.meta │ │ ├── Bakery.hlsl │ │ ├── Bakery.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 │ │ ├── Deprecated.hlsl │ │ ├── Deprecated.hlsl.meta │ │ ├── Input.hlsl │ │ ├── Input.hlsl.meta │ │ ├── Lighting.hlsl │ │ ├── Lighting.hlsl.meta │ │ ├── MetaInput.hlsl │ │ ├── MetaInput.hlsl.meta │ │ ├── Particles.hlsl │ │ ├── Particles.hlsl.meta │ │ ├── ParticlesInstancing.hlsl │ │ ├── ParticlesInstancing.hlsl.meta │ │ ├── SSAO.hlsl │ │ ├── SSAO.hlsl.meta │ │ ├── ShaderGraphFunctions.hlsl │ │ ├── ShaderGraphFunctions.hlsl.meta │ │ ├── ShaderTypes.cs.hlsl │ │ ├── ShaderTypes.cs.hlsl.meta │ │ ├── ShaderVariablesFunctions.deprecated.hlsl │ │ ├── ShaderVariablesFunctions.deprecated.hlsl.meta │ │ ├── ShaderVariablesFunctions.hlsl │ │ ├── ShaderVariablesFunctions.hlsl.meta │ │ ├── Shadows.hlsl │ │ ├── Shadows.hlsl.meta │ │ ├── Shim.meta │ │ ├── Shim │ │ ├── HLSLSupportShim.hlsl │ │ ├── HLSLSupportShim.hlsl.meta │ │ ├── InputsShim.hlsl │ │ ├── InputsShim.hlsl.meta │ │ ├── Shims.hlsl │ │ ├── Shims.hlsl.meta │ │ ├── SurfaceShaderProxy.hlsl │ │ └── SurfaceShaderProxy.hlsl.meta │ │ ├── SurfaceData.hlsl │ │ ├── SurfaceData.hlsl.meta │ │ ├── SurfaceInput.hlsl │ │ ├── SurfaceInput.hlsl.meta │ │ ├── UnityGBuffer.hlsl │ │ ├── UnityGBuffer.hlsl.meta │ │ ├── UnityInput.hlsl │ │ └── UnityInput.hlsl.meta ├── ShaderGraphLibrary.meta ├── ShaderGraphLibrary │ ├── Functions.hlsl │ ├── Functions.hlsl.meta │ ├── GeometricTools.hlsl │ ├── GeometricTools.hlsl.meta │ ├── LODDitheringTransition.hlsl │ ├── LODDitheringTransition.hlsl.meta │ ├── Nature.meta │ ├── Nature │ │ ├── SpeedTree8Billboard.shadersubgraph │ │ ├── SpeedTree8Billboard.shadersubgraph.meta │ │ ├── SpeedTree8ColorAlpha.shadersubgraph │ │ ├── SpeedTree8ColorAlpha.shadersubgraph.meta │ │ ├── SpeedTree8InterpolatedNormals.shadersubgraph │ │ ├── SpeedTree8InterpolatedNormals.shadersubgraph.meta │ │ ├── SpeedTree8Wind.hlsl │ │ ├── SpeedTree8Wind.hlsl.meta │ │ ├── SpeedTree8Wind.shadersubgraph │ │ └── SpeedTree8Wind.shadersubgraph.meta │ ├── PreviewPass.hlsl │ ├── PreviewPass.hlsl.meta │ ├── PreviewVaryings.hlsl │ ├── PreviewVaryings.hlsl.meta │ ├── ShaderConfig.cs.hlsl │ ├── ShaderConfig.cs.hlsl.meta │ ├── ShaderVariables.hlsl │ ├── ShaderVariables.hlsl.meta │ ├── ShaderVariablesFunctions.hlsl │ ├── ShaderVariablesFunctions.hlsl.meta │ ├── ShaderVariablesMatrixDefsLegacyUnity.hlsl │ └── ShaderVariablesMatrixDefsLegacyUnity.hlsl.meta ├── Unity LICENSE.txt └── Unity LICENSE.txt.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/main/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Uu]ser[Ss]ettings/ 12 | 13 | # MemoryCaptures can get excessive in size. 14 | # They also could contain extremely sensitive data 15 | /[Mm]emoryCaptures/ 16 | 17 | # Recordings can get excessive in size 18 | /[Rr]ecordings/ 19 | 20 | # Uncomment this line if you wish to ignore the asset store tools plugin 21 | # /[Aa]ssets/AssetStoreTools* 22 | 23 | # Autogenerated Jetbrains Rider plugin 24 | /[Aa]ssets/Plugins/Editor/JetBrains* 25 | 26 | # Visual Studio cache directory 27 | .vs/ 28 | 29 | # Gradle cache directory 30 | .gradle/ 31 | 32 | # Autogenerated VS/MD/Consulo solution and project files 33 | ExportedObj/ 34 | .consulo/ 35 | *.csproj 36 | *.unityproj 37 | *.sln 38 | *.suo 39 | *.tmp 40 | *.user 41 | *.userprefs 42 | *.pidb 43 | *.booproj 44 | *.svd 45 | *.pdb 46 | *.mdb 47 | *.opendb 48 | *.VC.db 49 | 50 | # Unity3D generated meta files 51 | *.pidb.meta 52 | *.pdb.meta 53 | *.mdb.meta 54 | 55 | # Unity3D generated file on crash reports 56 | sysinfo.txt 57 | 58 | # Builds 59 | *.apk 60 | *.aab 61 | *.unitypackage 62 | *.app 63 | 64 | # Crashlytics generated file 65 | crashlytics-build.properties 66 | 67 | # Packed Addressables 68 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 69 | 70 | # Temporary auto-generated Android Assets 71 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 72 | /[Aa]ssets/[Ss]treamingAssets/aa/* 73 | 74 | 75 | /[Aa]ssets/Bakery/ 76 | /[Aa]ssets/Editor/x64/Bakery/ -------------------------------------------------------------------------------- /CoreRP.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e69c4d32d771c9e4c8e8fbf50ba70ab0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0ce949b41433dc4b809d122e42d6e98 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/ACES.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8416bb2be4d3d35479de80c3c518cae7 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/API.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd2a46640ca7f9f45a71bbfa4ec7e426 3 | folderAsset: yes 4 | timeCreated: 1472140530 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/API/D3D11.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a37069d5f2219774fb3afad2661a0527 3 | timeCreated: 1472140530 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/API/GLCore.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 982ca921f8bc1da409f73744200da6cd 3 | timeCreated: 1506072929 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/API/GLES2.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 01036028ae448e3498cc6424e1d6c76c 3 | timeCreated: 1506072929 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/API/GLES3.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9b0b2b690c4842941884fd8e575deca2 3 | timeCreated: 1506072929 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/API/Metal.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 77eda81953df6914087de7e6b9e30a92 3 | timeCreated: 1484817807 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/API/Switch.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a87fa262a4824ce4abce06d4f322f38a 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/API/Validate.hlsl: -------------------------------------------------------------------------------- 1 | // Wait for a fix from Trunk #error not supported yet 2 | /* 3 | #define REQUIRE_DEFINED(X_) \ 4 | #ifndef X_ \ 5 | #error X_ must be defined (in) the platform include \ 6 | #endif X_ \ 7 | 8 | REQUIRE_DEFINED(UNITY_UV_STARTS_AT_TOP) 9 | REQUIRE_DEFINED(UNITY_REVERSED_Z) 10 | REQUIRE_DEFINED(UNITY_NEAR_CLIP_VALUE) 11 | REQUIRE_DEFINED(FACE) 12 | 13 | REQUIRE_DEFINED(CBUFFER_START) 14 | REQUIRE_DEFINED(CBUFFER_END) 15 | 16 | REQUIRE_DEFINED(INITIALIZE_OUTPUT) 17 | 18 | */ 19 | 20 | 21 | // Default values for things that have not been defined in the platform headers 22 | 23 | // default flow control attributes 24 | #ifndef UNITY_BRANCH 25 | # define UNITY_BRANCH 26 | #endif 27 | #ifndef UNITY_FLATTEN 28 | # define UNITY_FLATTEN 29 | #endif 30 | #ifndef UNITY_UNROLL 31 | # define UNITY_UNROLL 32 | #endif 33 | #ifndef UNITY_UNROLLX 34 | # define UNITY_UNROLLX(_x) 35 | #endif 36 | #ifndef UNITY_LOOP 37 | # define UNITY_LOOP 38 | #endif 39 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/API/Validate.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab842b2dab244c64bad8afb7942b1163 3 | timeCreated: 1474895361 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/API/Vulkan.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 418372ade59f4434e8c2346156d36a3b 3 | timeCreated: 1506072929 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/AreaLighting.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb5a2503ae8374743b327368810de096 3 | timeCreated: 1476726533 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/BC6H.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d832f0d54cbbca409d478ffabd3685f 3 | timeCreated: 1507282342 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/BSDF.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 13a54236a1543724eb1cf63cf1effee0 3 | timeCreated: 1472140530 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Color.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5950736cd6ad0e741b4c2eb5a49696b0 3 | timeCreated: 1472140529 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Common.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed730e03283c93141a7101f026f3641d 3 | timeCreated: 1472140530 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/CommonDeprecated.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_COMMON_DEPRECATED_INCLUDED 2 | #define UNITY_COMMON_DEPRECATED_INCLUDED 3 | 4 | // Function that are in this file shouldn't be use. they are obsolete and could be removed in the future 5 | // they are here to keep compatibility with previous version 6 | #if !defined(SHADER_API_GLES) 7 | // Please use void LODDitheringTransition(uint2 fadeMaskSeed, float ditherFactor) 8 | void LODDitheringTransition(uint3 fadeMaskSeed, float ditherFactor) 9 | { 10 | ditherFactor = ditherFactor < 0.0 ? 1 + ditherFactor : ditherFactor; 11 | 12 | float p = GenerateHashedRandomFloat(fadeMaskSeed); 13 | p = (ditherFactor >= 0.5) ? p : 1 - p; 14 | clip(ditherFactor - p); 15 | } 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/CommonDeprecated.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc7054fa5dd804f4cada8aa298a38ae3 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/CommonLighting.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 838375cad6b27004693e5b50d2f7eac5 3 | timeCreated: 1474465931 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/CommonMaterial.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1184b1d317a54a24498ea26fbaec0ad3 3 | timeCreated: 1477404191 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/CommonShadow.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_COMMON_SHADOW_INCLUDED 2 | #define UNITY_COMMON_SHADOW_INCLUDED 3 | 4 | // Ref: https://mynameismjp.wordpress.com/2015/02/18/shadow-sample-update/ 5 | // Calculates the offset to use for sampling the shadow map, based on the surface normal 6 | real3 GetShadowPosOffset(real NdotL, real3 normalWS, real2 invShadowMapSize) 7 | { 8 | real texelSize = 2.0 * invShadowMapSize.x; 9 | real offsetScaleNormalize = saturate(1.0 - NdotL); 10 | // return texelSize * OffsetScale * offsetScaleNormalize * normalWS; 11 | return texelSize * offsetScaleNormalize * normalWS; 12 | } 13 | 14 | #endif // UNITY_COMMON_SHADOW_INCLUDED 15 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/CommonShadow.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a29a6b9b0990c745b9b8866a5befbd9 3 | timeCreated: 1477397630 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Debug.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8f0ae852054f6a24cbdd293ed1854920 3 | timeCreated: 1476051069 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/EntityLighting.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f3c633f6a475b941843fea5680b7276 3 | timeCreated: 1477930471 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Filtering.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4669766c0907c9c4595751745d621dbf 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/GeometricTools.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6479db80c093bab46be62af271c5c5c9 3 | timeCreated: 1472140530 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/GraniteShaderLibBase.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a2f9de39f2d28443aca92bb0da346eb 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Any: 16 | second: 17 | enabled: 1 18 | settings: {} 19 | - first: 20 | Editor: Editor 21 | second: 22 | enabled: 0 23 | settings: 24 | DefaultValueInitialized: true 25 | userData: 26 | assetBundleName: 27 | assetBundleVariant: 28 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/ImageBasedLighting.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32c7fa43d57357e41a15637918b62cd2 3 | timeCreated: 1476117021 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Macros.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 26e15c32553e64c43a2621696e91dd13 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/MetaPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6502473801be52d4fbc71a6eec9679e9 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/NormalSurfaceGradient.hlsl: -------------------------------------------------------------------------------- 1 | // this produces an orthonormal basis of the tangent and bitangent WITHOUT vertex level tangent/bitangent for any UV including procedurally generated 2 | // method released with the demo for publication of "bump mapping unparametrized surfaces on the GPU" 3 | // http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html 4 | void SurfaceGradientGenBasisTB(float3 nrmVertexNormal, float3 sigmaX, float3 sigmaY, float flipSign, float2 texST, out float3 vT, out float3 vB) 5 | { 6 | float2 dSTdx = ddx_fine(texST), dSTdy = ddy_fine(texST); 7 | 8 | float det = dot(dSTdx, float2(dSTdy.y, -dSTdy.x)); 9 | float sign_det = det < 0 ? -1 : 1; 10 | 11 | // invC0 represents (dXds, dYds); but we don't divide by determinant (scale by sign instead) 12 | float2 invC0 = sign_det * float2(dSTdy.y, -dSTdx.y); 13 | vT = sigmaX * invC0.x + sigmaY * invC0.y; 14 | if (abs(det) > 0.0) 15 | vT = normalize(vT); 16 | vB = (sign_det * flipSign) * cross(nrmVertexNormal, vT); 17 | } 18 | 19 | // surface gradient from an on the fly TBN (deriv obtained using tspaceNormalToDerivative()) or from conventional vertex level TBN (mikktspace compliant and deriv obtained using tspaceNormalToDerivative()) 20 | real3 SurfaceGradientFromTBN(real2 deriv, real3 vT, real3 vB) 21 | { 22 | return deriv.x * vT + deriv.y * vB; 23 | } 24 | 25 | // surface gradient from an already generated "normal" such as from an object or world space normal map 26 | // CAUTION: nrmVertexNormal and v must be in the same space. i.e world or object 27 | // this allows us to mix the contribution together with a series of other contributions including tangent space normals 28 | // v does not need to be unit length as long as it establishes the direction. 29 | real3 SurfaceGradientFromPerturbedNormal(real3 nrmVertexNormal, real3 v) 30 | { 31 | real3 n = nrmVertexNormal; 32 | real s = 1.0 / max(REAL_EPS, abs(dot(n, v))); 33 | return s * (dot(n, v) * n - v); 34 | } 35 | 36 | // used to produce a surface gradient from the gradient of a volume bump function such as a volume of perlin noise. 37 | // equation 2. in "bump mapping unparametrized surfaces on the GPU". 38 | // Observe the difference in figure 2. between using the gradient vs. the surface gradient to do bump mapping (the original method is proved wrong in the paper!). 39 | real3 SurfaceGradientFromVolumeGradient(real3 nrmVertexNormal, real3 grad) 40 | { 41 | return grad - dot(nrmVertexNormal, grad) * nrmVertexNormal; 42 | } 43 | 44 | // triplanar projection considered special case of volume bump map 45 | // described here: http://mmikkelsen3d.blogspot.com/2013/10/volume-height-maps-and-triplanar-bump.html 46 | // derivs obtained using tspaceNormalToDerivative() and weights using computeTriplanarWeights(). 47 | real3 SurfaceGradientFromTriplanarProjection(real3 nrmVertexNormal, real3 triplanarWeights, real2 deriv_xplane, real2 deriv_yplane, real2 deriv_zplane) 48 | { 49 | const real w0 = triplanarWeights.x, w1 = triplanarWeights.y, w2 = triplanarWeights.z; 50 | 51 | // Assume derivXplane, derivYPlane and derivZPlane sampled using (z,y), (x,z) and (x,y) respectively 52 | // (ie using Morten's convention http://jcgt.org/published/0009/03/04/ p80-81 for left handed worldspace) 53 | // positive scales of the look-up coordinate will work as well but for negative scales the derivative components will need to be negated accordingly. 54 | real3 volumeGrad = real3(w2 * deriv_zplane.x + w1 * deriv_yplane.x, w2 * deriv_zplane.y + w0 * deriv_xplane.y, w0 * deriv_xplane.x + w1 * deriv_yplane.y); 55 | 56 | return SurfaceGradientFromVolumeGradient(nrmVertexNormal, volumeGrad); 57 | } 58 | 59 | real3 SurfaceGradientResolveNormal(real3 nrmVertexNormal, real3 surfGrad) 60 | { 61 | return SafeNormalize(nrmVertexNormal - surfGrad); 62 | } 63 | 64 | real2 ConvertTangentSpaceNormalToHeightMapGradient(real2 normalXY, real rcpNormalZ, real scale) 65 | { 66 | // scale * (-normal.xy / normal.z) 67 | return normalXY * (-rcpNormalZ * scale); 68 | } 69 | 70 | real3 SurfaceGradientFromTangentSpaceNormalAndFromTBN(real3 normalTS, real3 vT, real3 vB, real scale = 1.0) 71 | { 72 | float2 deriv = ConvertTangentSpaceNormalToHeightMapGradient(normalTS.xy, rcp(max(normalTS.z, REAL_EPS)), scale); 73 | return SurfaceGradientFromTBN(deriv, vT, vB); 74 | } 75 | 76 | // Converts tangent space normal to slopes (height map gradient). 77 | real2 UnpackDerivativeNormalRGB(real4 packedNormal, real scale = 1.0) 78 | { 79 | real3 vT = packedNormal.rgb * 2.0 - 1.0; // Unsigned to signed 80 | real rcpZ = rcp(max(vT.z, REAL_EPS)); // Clamp to avoid INF 81 | 82 | return ConvertTangentSpaceNormalToHeightMapGradient(vT.xy, rcpZ, scale); 83 | } 84 | 85 | // Converts tangent space normal to slopes (height map gradient). 86 | real2 UnpackDerivativeNormalAG(real4 packedNormal, real scale = 1.0) 87 | { 88 | real2 vT = packedNormal.ag * 2.0 - 1.0; // Unsigned to signed 89 | real rcpZ = rsqrt(max(1 - Sq(vT.x) - Sq(vT.y), HALF_MIN_SQRT)); // Clamp to avoid INF 90 | 91 | return ConvertTangentSpaceNormalToHeightMapGradient(vT.xy, rcpZ, scale); 92 | } 93 | 94 | // Unpack normal as DXT5nm (1, y, 0, x) or BC5 (x, y, 0, 1) 95 | real2 UnpackDerivativeNormalRGorAG(real4 packedNormal, real scale = 1.0) 96 | { 97 | // Convert to (?, y, 0, x) 98 | packedNormal.a *= packedNormal.r; 99 | return UnpackDerivativeNormalAG(packedNormal, scale); 100 | } 101 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/NormalSurfaceGradient.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d941214dc9887474cb5e88491e0da43d 3 | timeCreated: 1487475828 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Packing.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d8ca8372c10f058428318e6907e774ac 3 | timeCreated: 1472140530 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/ParallaxMapping.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNIVERSAL_PARALLAX_MAPPING_INCLUDED 2 | #define UNIVERSAL_PARALLAX_MAPPING_INCLUDED 3 | 4 | // Return view direction in tangent space, make sure tangentWS.w is already multiplied by GetOddNegativeScale() 5 | half3 GetViewDirectionTangentSpace(half4 tangentWS, half3 normalWS, half3 viewDirWS) 6 | { 7 | // must use interpolated tangent, bitangent and normal before they are normalized in the pixel shader. 8 | half3 unnormalizedNormalWS = normalWS; 9 | const half renormFactor = 1.0 / length(unnormalizedNormalWS); 10 | 11 | // use bitangent on the fly like in hdrp 12 | // IMPORTANT! If we ever support Flip on double sided materials ensure bitangent and tangent are NOT flipped. 13 | half crossSign = (tangentWS.w > 0.0 ? 1.0 : -1.0); // we do not need to multiple GetOddNegativeScale() here, as it is done in vertex shader 14 | half3 bitang = crossSign * cross(normalWS.xyz, tangentWS.xyz); 15 | 16 | half3 WorldSpaceNormal = renormFactor * normalWS.xyz; // we want a unit length Normal Vector node in shader graph 17 | 18 | // to preserve mikktspace compliance we use same scale renormFactor as was used on the normal. 19 | // This is explained in section 2.2 in "surface gradient based bump mapping framework" 20 | half3 WorldSpaceTangent = renormFactor * tangentWS.xyz; 21 | half3 WorldSpaceBiTangent = renormFactor * bitang; 22 | 23 | half3x3 tangentSpaceTransform = half3x3(WorldSpaceTangent, WorldSpaceBiTangent, WorldSpaceNormal); 24 | half3 viewDirTS = mul(tangentSpaceTransform, viewDirWS); 25 | 26 | return viewDirTS; 27 | } 28 | 29 | #ifndef BUILTIN_TARGET_API 30 | half2 ParallaxOffset1Step(half height, half amplitude, half3 viewDirTS) 31 | { 32 | height = height * amplitude - amplitude / 2.0; 33 | half3 v = normalize(viewDirTS); 34 | v.z += 0.42; 35 | return height * (v.xy / v.z); 36 | } 37 | #endif 38 | 39 | float2 ParallaxMapping(TEXTURE2D_PARAM(heightMap, sampler_heightMap), half3 viewDirTS, half scale, float2 uv) 40 | { 41 | half h = SAMPLE_TEXTURE2D(heightMap, sampler_heightMap, uv).g; 42 | float2 offset = ParallaxOffset1Step(h, scale, viewDirTS); 43 | return offset; 44 | } 45 | 46 | #endif // UNIVERSAL_PARALLAX_MAPPING_INCLUDED 47 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/ParallaxMapping.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1fd2718c0ddb646488907d04c8a714eb 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/PerPixelDisplacement.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44b5b6d63a4b0b847afae1b937797fa5 3 | timeCreated: 1486045136 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/PhysicalCamera.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_PHYSICAL_CAMERA_INCLUDED 2 | #define UNITY_PHYSICAL_CAMERA_INCLUDED 3 | 4 | // Has to be kept in sync with ColorUtils.cs 5 | 6 | // References: 7 | // "Moving Frostbite to PBR" (Sebastien Lagarde & Charles de Rousiers) 8 | // https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf 9 | // "Implementing a Physically Based Camera" (Padraic Hennessy) 10 | // https://placeholderart.wordpress.com/2014/11/16/implementing-a-physically-based-camera-understanding-exposure/ 11 | 12 | float ComputeEV100(float aperture, float shutterSpeed, float ISO) 13 | { 14 | // EV number is defined as: 15 | // 2^ EV_s = N^2 / t and EV_s = EV_100 + log2 (S /100) 16 | // This gives 17 | // EV_s = log2 (N^2 / t) 18 | // EV_100 + log2 (S /100) = log2 (N^2 / t) 19 | // EV_100 = log2 (N^2 / t) - log2 (S /100) 20 | // EV_100 = log2 (N^2 / t . 100 / S) 21 | return log2((aperture * aperture) / shutterSpeed * 100.0 / ISO); 22 | } 23 | 24 | float ComputeEV100FromAvgLuminance(float avgLuminance, float calibrationConstant) 25 | { 26 | const float K = calibrationConstant; 27 | return log2(avgLuminance * 100.0 / K); 28 | } 29 | 30 | float ComputeEV100FromAvgLuminance(float avgLuminance) 31 | { 32 | // We later use the middle gray at 12.7% in order to have 33 | // a middle gray at 18% with a sqrt(2) room for specular highlights 34 | // But here we deal with the spot meter measuring the middle gray 35 | // which is fixed at 12.5 for matching standard camera 36 | // constructor settings (i.e. calibration constant K = 12.5) 37 | // Reference: http://en.wikipedia.org/wiki/Film_speed 38 | const float K = 12.5; // Reflected-light meter calibration constant 39 | return ComputeEV100FromAvgLuminance(avgLuminance, K); 40 | } 41 | 42 | float ConvertEV100ToExposure(float EV100, float exposureScale) 43 | { 44 | // Compute the maximum luminance possible with H_sbs sensitivity 45 | // maxLum = 78 / ( S * q ) * N^2 / t 46 | // = 78 / ( S * q ) * 2^ EV_100 47 | // = 78 / (100 * s_LensAttenuation) * 2^ EV_100 48 | // = exposureScale * 2^ EV 49 | // Reference: http://en.wikipedia.org/wiki/Film_speed 50 | float maxLuminance = exposureScale * pow(2.0, EV100); 51 | return 1.0 / maxLuminance; 52 | } 53 | 54 | float ConvertEV100ToExposure(float EV100) 55 | { 56 | const float exposureScale = 1.2; 57 | return ConvertEV100ToExposure(EV100, exposureScale); 58 | } 59 | 60 | float ComputeISO(float aperture, float shutterSpeed, float targetEV100) 61 | { 62 | // Compute the required ISO to reach the target EV100 63 | return ((aperture * aperture) * 100.0) / (shutterSpeed * pow(2.0, targetEV100)); 64 | } 65 | 66 | float ComputeLuminanceAdaptation(float previousLuminance, float currentLuminance, float speedDarkToLight, float speedLightToDark, float deltaTime) 67 | { 68 | float delta = currentLuminance - previousLuminance; 69 | float speed = delta > 0.0 ? speedDarkToLight : speedLightToDark; 70 | 71 | // Exponential decay 72 | return previousLuminance + delta * (1.0 - exp2(-deltaTime * speed)); 73 | } 74 | 75 | #endif // UNITY_PHYSICAL_CAMERA_INCLUDED 76 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/PhysicalCamera.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 735b541ccfd52fa4fa93ca1bf6765880 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Random.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_RANDOM_INCLUDED 2 | #define UNITY_RANDOM_INCLUDED 3 | 4 | // Safe for GLES2: HLSLcc will emulate the missing operator ^, >> and rcp 5 | float Hash(uint s) 6 | { 7 | s = s ^ 2747636419u; 8 | s = s * 2654435769u; 9 | s = s ^ (s >> 16); 10 | s = s * 2654435769u; 11 | s = s ^ (s >> 16); 12 | s = s * 2654435769u; 13 | return float(s) * rcp(4294967296.0); // 2^-32 14 | } 15 | 16 | #if !defined(SHADER_API_GLES) 17 | 18 | // A single iteration of Bob Jenkins' One-At-A-Time hashing algorithm. 19 | uint JenkinsHash(uint x) 20 | { 21 | x += (x << 10u); 22 | x ^= (x >> 6u); 23 | x += (x << 3u); 24 | x ^= (x >> 11u); 25 | x += (x << 15u); 26 | return x; 27 | } 28 | 29 | // Compound versions of the hashing algorithm. 30 | uint JenkinsHash(uint2 v) 31 | { 32 | return JenkinsHash(v.x ^ JenkinsHash(v.y)); 33 | } 34 | 35 | uint JenkinsHash(uint3 v) 36 | { 37 | return JenkinsHash(v.x ^ JenkinsHash(v.yz)); 38 | } 39 | 40 | uint JenkinsHash(uint4 v) 41 | { 42 | return JenkinsHash(v.x ^ JenkinsHash(v.yzw)); 43 | } 44 | 45 | // Construct a float with half-open range [0, 1) using low 23 bits. 46 | // All zeros yields 0, all ones yields the next smallest representable value below 1. 47 | float ConstructFloat(int m) { 48 | const int ieeeMantissa = 0x007FFFFF; // Binary FP32 mantissa bitmask 49 | const int ieeeOne = 0x3F800000; // 1.0 in FP32 IEEE 50 | 51 | m &= ieeeMantissa; // Keep only mantissa bits (fractional part) 52 | m |= ieeeOne; // Add fractional part to 1.0 53 | 54 | float f = asfloat(m); // Range [1, 2) 55 | return f - 1; // Range [0, 1) 56 | } 57 | 58 | float ConstructFloat(uint m) 59 | { 60 | return ConstructFloat(asint(m)); 61 | } 62 | 63 | // Pseudo-random value in half-open range [0, 1). The distribution is reasonably uniform. 64 | // Ref: https://stackoverflow.com/a/17479300 65 | float GenerateHashedRandomFloat(uint x) 66 | { 67 | return ConstructFloat(JenkinsHash(x)); 68 | } 69 | 70 | float GenerateHashedRandomFloat(uint2 v) 71 | { 72 | return ConstructFloat(JenkinsHash(v)); 73 | } 74 | 75 | float GenerateHashedRandomFloat(uint3 v) 76 | { 77 | return ConstructFloat(JenkinsHash(v)); 78 | } 79 | 80 | float GenerateHashedRandomFloat(uint4 v) 81 | { 82 | return ConstructFloat(JenkinsHash(v)); 83 | } 84 | 85 | float2 InitRandom(float2 input) 86 | { 87 | float2 r; 88 | r.x = Hash(uint(input.x * UINT_MAX)); 89 | r.y = Hash(uint(input.y * UINT_MAX)); 90 | 91 | return r; 92 | } 93 | #endif // SHADER_API_GLES 94 | 95 | //From Next Generation Post Processing in Call of Duty: Advanced Warfare [Jimenez 2014] 96 | // http://advances.realtimerendering.com/s2014/index.html 97 | float InterleavedGradientNoise(float2 pixCoord, int frameCount) 98 | { 99 | const float3 magic = float3(0.06711056f, 0.00583715f, 52.9829189f); 100 | float2 frameMagicScale = float2(2.083f, 4.867f); 101 | pixCoord += frameCount * frameMagicScale; 102 | return frac(magic.z * frac(dot(pixCoord, magic.xy))); 103 | } 104 | 105 | // 32-bit Xorshift random number generator 106 | uint XorShift(inout uint rngState) 107 | { 108 | rngState ^= rngState << 13; 109 | rngState ^= rngState >> 17; 110 | rngState ^= rngState << 5; 111 | return rngState; 112 | } 113 | 114 | #endif // UNITY_RANDOM_INCLUDED 115 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Random.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 551e556ffcaa1be4ca09e7627121064e 3 | timeCreated: 1504012042 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Refraction.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_REFRACTION_INCLUDED 2 | #define UNITY_REFRACTION_INCLUDED 3 | 4 | //----------------------------------------------------------------------------- 5 | // Util refraction 6 | //----------------------------------------------------------------------------- 7 | 8 | struct RefractionModelResult 9 | { 10 | real dist; // length of the transmission during refraction through the shape 11 | float3 positionWS; // out ray position 12 | real3 rayWS; // out ray direction 13 | }; 14 | 15 | RefractionModelResult RefractionModelSphere(real3 V, float3 positionWS, real3 normalWS, real ior, real thickness) 16 | { 17 | // Sphere shape model: 18 | // We approximate locally the shape of the object as sphere, that is tangent to the shape. 19 | // The sphere has a diameter of {thickness} 20 | // The center of the sphere is at {positionWS} - {normalWS} * {thickness} * 0.5 21 | // 22 | // So the light is refracted twice: in and out of the tangent sphere 23 | 24 | // First refraction (tangent sphere in) 25 | // Refracted ray 26 | real3 R1 = refract(-V, normalWS, 1.0 / ior); 27 | // Center of the tangent sphere 28 | real3 C = positionWS - normalWS * thickness * 0.5; 29 | 30 | // Second refraction (tangent sphere out) 31 | real NoR1 = dot(normalWS, R1); 32 | // Optical depth within the sphere 33 | real dist = -NoR1 * thickness; 34 | // Out hit point in the tangent sphere 35 | real3 P1 = positionWS + R1 * dist; 36 | // Out normal 37 | real3 N1 = normalize(C - P1); 38 | // Out refracted ray 39 | real3 R2 = refract(R1, N1, ior); 40 | real N1oR2 = dot(N1, R2); 41 | real VoR1 = dot(V, R1); 42 | 43 | RefractionModelResult result; 44 | result.dist = dist; 45 | result.positionWS = P1; 46 | result.rayWS = R2; 47 | 48 | return result; 49 | } 50 | 51 | RefractionModelResult RefractionModelBox(real3 V, float3 positionWS, real3 normalWS, real ior, real thickness) 52 | { 53 | // Plane shape model: 54 | // We approximate locally the shape of the object as a plane with normal {normalWS} at {positionWS} 55 | // with a thickness {thickness} 56 | 57 | // Refracted ray 58 | real3 R = refract(-V, normalWS, 1.0 / ior); 59 | 60 | // Optical depth within the thin plane 61 | real dist = thickness / max(dot(R, -normalWS), 1e-5f); 62 | 63 | RefractionModelResult result; 64 | result.dist = dist; 65 | result.positionWS = positionWS + R * dist; 66 | result.rayWS = -V; 67 | 68 | return result; 69 | } 70 | #endif 71 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Refraction.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 440515dcf6109cc48b156ae652647ee9 3 | timeCreated: 1509090550 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/SDF2D.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_SDF2D_INCLUDED 2 | #define UNITY_SDF2D_INCLUDED 3 | 4 | // Ref: https://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm 5 | 6 | float CircleSDF(float2 position, float radius) 7 | { 8 | return length(position) - radius; 9 | } 10 | 11 | float RectangleSDF(float2 position, float2 bound) 12 | { 13 | float2 d = abs(position) - bound; 14 | return length(max(d, float2(0, 0))) + min(max(d.x, d.y), 0.0); 15 | } 16 | 17 | float EllipseSDF(float2 position, float2 r) 18 | { 19 | float2 p = position; 20 | float2 r2 = r*r; 21 | 22 | float k0 = length(p/r); 23 | float k1 = length(p/r2); 24 | 25 | return k0*(k0 - 1.0)/k1; 26 | } 27 | 28 | #endif // UNITY_SDF2D_INCLUDED 29 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/SDF2D.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d652c40023c6db64ca43c9524cf12928 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Sampling.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0fb67397e068f3a4880a04af34b3950f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Sampling/Fibonacci.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49cd227344ded7c42bf8080be4c6bb8a 3 | timeCreated: 1482325231 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Sampling/Hammersley.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b7a17f8235a9fc5498abcc886215e071 3 | timeCreated: 1482325231 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Sampling/SampleUVMapping.hlsl: -------------------------------------------------------------------------------- 1 | // This structure abstract uv mapping inside one struct. 2 | // It represent a mapping of any uv (with its associated tangent space for derivative if SurfaceGradient mode) - UVSet0 to 4, planar, triplanar 3 | 4 | #ifndef __SAMPLEUVMAPPING_HLSL__ 5 | #define __SAMPLEUVMAPPING_HLSL__ 6 | 7 | #include "Packages/com.z3y.shadergraph-builtin/CoreRP/ShaderLibrary/NormalSurfaceGradient.hlsl" 8 | 9 | #define UV_MAPPING_UVSET 0 10 | #define UV_MAPPING_PLANAR 1 11 | #define UV_MAPPING_TRIPLANAR 2 12 | 13 | struct UVMapping 14 | { 15 | int mappingType; 16 | float2 uv; // Current uv or planar uv 17 | 18 | // Triplanar specific 19 | float2 uvZY; 20 | float2 uvXZ; 21 | float2 uvXY; 22 | 23 | float3 normalWS; // vertex normal 24 | float3 triplanarWeights; 25 | 26 | #ifdef SURFACE_GRADIENT 27 | // tangent basis to use when mappingType is UV_MAPPING_UVSET 28 | // these are vertex level in world space 29 | float3 tangentWS; 30 | float3 bitangentWS; 31 | // TODO: store also object normal map for object triplanar 32 | #endif 33 | }; 34 | 35 | // Multiple includes of the file to handle all variations of textures sampling for regular, lod and bias 36 | 37 | // Regular sampling functions 38 | #define ADD_FUNC_SUFFIX(Name) Name 39 | #define SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping, unused) SAMPLE_TEXTURE2D(textureName, samplerName, uvMapping) 40 | #include "Packages/com.z3y.shadergraph-builtin/CoreRP/ShaderLibrary/Sampling/SampleUVMappingInternal.hlsl" 41 | #undef ADD_FUNC_SUFFIX 42 | #undef SAMPLE_TEXTURE_FUNC 43 | 44 | // Lod sampling functions 45 | #define ADD_FUNC_SUFFIX(Name) MERGE_NAME(Name, Lod) 46 | #define SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, uvMapping, lod) 47 | #include "Packages/com.z3y.shadergraph-builtin/CoreRP/ShaderLibrary/Sampling/SampleUVMappingInternal.hlsl" 48 | #undef ADD_FUNC_SUFFIX 49 | #undef SAMPLE_TEXTURE_FUNC 50 | 51 | // Bias sampling functions 52 | #define ADD_FUNC_SUFFIX(Name) MERGE_NAME(Name, Bias) 53 | #define SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping, bias) SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, uvMapping, bias) 54 | #include "Packages/com.z3y.shadergraph-builtin/CoreRP/ShaderLibrary/Sampling/SampleUVMappingInternal.hlsl" 55 | #undef ADD_FUNC_SUFFIX 56 | #undef SAMPLE_TEXTURE_FUNC 57 | 58 | // Macro to improve readibility of surface data 59 | #define SAMPLE_UVMAPPING_TEXTURE2D(textureName, samplerName, uvMapping) SampleUVMapping(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, 0.0) // Last 0.0 is unused 60 | #define SAMPLE_UVMAPPING_TEXTURE2D_LOD(textureName, samplerName, uvMapping, lod) SampleUVMappingLod(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, lod) 61 | #define SAMPLE_UVMAPPING_TEXTURE2D_BIAS(textureName, samplerName, uvMapping, bias) SampleUVMappingBias(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, bias) 62 | 63 | #define SAMPLE_UVMAPPING_NORMALMAP(textureName, samplerName, uvMapping, scale) SampleUVMappingNormal(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, 0.0) 64 | #define SAMPLE_UVMAPPING_NORMALMAP_LOD(textureName, samplerName, uvMapping, scale, lod) SampleUVMappingNormalLod(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, lod) 65 | #define SAMPLE_UVMAPPING_NORMALMAP_BIAS(textureName, samplerName, uvMapping, scale, bias) SampleUVMappingNormalBias(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, bias) 66 | 67 | #define SAMPLE_UVMAPPING_NORMALMAP_AG(textureName, samplerName, uvMapping, scale) SampleUVMappingNormalAG(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, 0.0) 68 | #define SAMPLE_UVMAPPING_NORMALMAP_AG_LOD(textureName, samplerName, uvMapping, scale, lod) SampleUVMappingNormalAGLod(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, lod) 69 | #define SAMPLE_UVMAPPING_NORMALMAP_AG_BIAS(textureName, samplerName, uvMapping, scale, bias) SampleUVMappingNormalAGBias(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, bias) 70 | 71 | #define SAMPLE_UVMAPPING_NORMALMAP_RGB(textureName, samplerName, uvMapping, scale) SampleUVMappingNormalRGB(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, 0.0) 72 | #define SAMPLE_UVMAPPING_NORMALMAP_RGB_LOD(textureName, samplerName, uvMapping, scale, lod) SampleUVMappingNormalRGBLod(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, lod) 73 | #define SAMPLE_UVMAPPING_NORMALMAP_RGB_BIAS(textureName, samplerName, uvMapping, scale, bias) SampleUVMappingNormalRGBBias(TEXTURE2D_ARGS(textureName, samplerName), uvMapping, scale, bias) 74 | 75 | #endif //__SAMPLEUVMAPPING_HLSL__ 76 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Sampling/SampleUVMapping.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc6bcd7c0e23e6342982f80657c05727 3 | timeCreated: 1485260584 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Sampling/SampleUVMappingInternal.hlsl: -------------------------------------------------------------------------------- 1 | 2 | // These functions are use to hide the handling of triplanar mapping 3 | // Normal need a specific treatment as they use special encoding for both base and detail map 4 | // Also we use multiple inclusion to handle the various variation for lod and bias 5 | 6 | // param can be unused, lod or bias 7 | real4 ADD_FUNC_SUFFIX(SampleUVMapping)(TEXTURE2D_PARAM(textureName, samplerName), UVMapping uvMapping, real param) 8 | { 9 | if (uvMapping.mappingType == UV_MAPPING_TRIPLANAR) 10 | { 11 | real3 triplanarWeights = uvMapping.triplanarWeights; 12 | real4 val = real4(0.0, 0.0, 0.0, 0.0); 13 | 14 | if (triplanarWeights.x > 0.0) 15 | val += triplanarWeights.x * SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvZY, param); 16 | if (triplanarWeights.y > 0.0) 17 | val += triplanarWeights.y * SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvXZ, param); 18 | if (triplanarWeights.z > 0.0) 19 | val += triplanarWeights.z * SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvXY, param); 20 | 21 | return val; 22 | } 23 | else // UV_MAPPING_UVSET / UV_MAPPING_PLANAR 24 | { 25 | return SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uv, param); 26 | } 27 | } 28 | 29 | // Nested multiple includes of the file to handle all variations of normal map (AG, RG or RGB) 30 | 31 | // This version is use for the base normal map (BC5 or DXT5nm) 32 | #define ADD_NORMAL_FUNC_SUFFIX(Name) Name 33 | #if defined(UNITY_ASTC_NORMALMAP_ENCODING) 34 | #define UNPACK_NORMAL_FUNC UnpackNormalAG 35 | #define UNPACK_DERIVATIVE_FUNC UnpackDerivativeNormalAG 36 | #elif defined(UNITY_NO_DXT5nm) 37 | #define UNPACK_NORMAL_FUNC UnpackNormalRGB 38 | #define UNPACK_DERIVATIVE_FUNC UnpackDerivativeNormalRGB 39 | #else 40 | #define UNPACK_NORMAL_FUNC UnpackNormalmapRGorAG 41 | #define UNPACK_DERIVATIVE_FUNC UnpackDerivativeNormalRGorAG 42 | #endif 43 | #include "Packages/com.z3y.shadergraph-builtin/CoreRP/ShaderLibrary/Sampling/SampleUVMappingNormalInternal.hlsl" 44 | #undef ADD_NORMAL_FUNC_SUFFIX 45 | #undef UNPACK_NORMAL_FUNC 46 | #undef UNPACK_DERIVATIVE_FUNC 47 | 48 | // This version is for normalmap with AG encoding only. Use with details map encoded with others properties (like smoothness). 49 | #define ADD_NORMAL_FUNC_SUFFIX(Name) MERGE_NAME(Name, AG) 50 | #define UNPACK_NORMAL_FUNC UnpackNormalAG 51 | #define UNPACK_DERIVATIVE_FUNC UnpackDerivativeNormalAG 52 | #include "Packages/com.z3y.shadergraph-builtin/CoreRP/ShaderLibrary/Sampling/SampleUVMappingNormalInternal.hlsl" 53 | #undef ADD_NORMAL_FUNC_SUFFIX 54 | #undef UNPACK_NORMAL_FUNC 55 | #undef UNPACK_DERIVATIVE_FUNC 56 | 57 | // This version is for normalmap with RGB encoding only, i.e uncompress or BC7. 58 | #define ADD_NORMAL_FUNC_SUFFIX(Name) MERGE_NAME(Name, RGB) 59 | #define UNPACK_NORMAL_FUNC UnpackNormalRGB 60 | #define UNPACK_DERIVATIVE_FUNC UnpackDerivativeNormalRGB 61 | #include "Packages/com.z3y.shadergraph-builtin/CoreRP/ShaderLibrary/Sampling/SampleUVMappingNormalInternal.hlsl" 62 | #undef ADD_NORMAL_FUNC_SUFFIX 63 | #undef UNPACK_NORMAL_FUNC 64 | #undef UNPACK_DERIVATIVE_FUNC 65 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Sampling/SampleUVMappingInternal.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b5f04fd4cffc21c46944174d88588ec1 3 | timeCreated: 1485250177 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Sampling/SampleUVMappingNormalInternal.hlsl: -------------------------------------------------------------------------------- 1 | real3 ADD_FUNC_SUFFIX(ADD_NORMAL_FUNC_SUFFIX(SampleUVMappingNormal))(TEXTURE2D_PARAM(textureName, samplerName), UVMapping uvMapping, real scale, real param) 2 | { 3 | if (uvMapping.mappingType == UV_MAPPING_TRIPLANAR) 4 | { 5 | real3 triplanarWeights = uvMapping.triplanarWeights; 6 | 7 | #ifdef SURFACE_GRADIENT 8 | // Height map gradient. Basically, it encodes height map slopes along S and T axes. 9 | real2 derivXplane; 10 | real2 derivYPlane; 11 | real2 derivZPlane; 12 | derivXplane = derivYPlane = derivZPlane = real2(0.0, 0.0); 13 | 14 | if (triplanarWeights.x > 0.0) 15 | derivXplane = triplanarWeights.x * UNPACK_DERIVATIVE_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvZY, param), scale); 16 | if (triplanarWeights.y > 0.0) 17 | derivYPlane = triplanarWeights.y * UNPACK_DERIVATIVE_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvXZ, param), scale); 18 | if (triplanarWeights.z > 0.0) 19 | derivZPlane = triplanarWeights.z * UNPACK_DERIVATIVE_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvXY, param), scale); 20 | 21 | // Assume derivXplane, derivYPlane and derivZPlane sampled using (z,y), (x,z) and (x,y) respectively 22 | // ie using Morten's convention http://jcgt.org/published/0009/03/04/ p80-81 23 | real3 volumeGrad = real3(derivZPlane.x + derivYPlane.x, derivZPlane.y + derivXplane.y, derivXplane.x + derivYPlane.y); 24 | return SurfaceGradientFromVolumeGradient(uvMapping.normalWS, volumeGrad); 25 | #else 26 | real3 val = real3(0.0, 0.0, 0.0); 27 | 28 | if (triplanarWeights.x > 0.0) 29 | val += triplanarWeights.x * UNPACK_NORMAL_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvZY, param), scale); 30 | if (triplanarWeights.y > 0.0) 31 | val += triplanarWeights.y * UNPACK_NORMAL_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvXZ, param), scale); 32 | if (triplanarWeights.z > 0.0) 33 | val += triplanarWeights.z * UNPACK_NORMAL_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uvXY, param), scale); 34 | 35 | return normalize(val); 36 | #endif 37 | } 38 | #ifdef SURFACE_GRADIENT 39 | else if (uvMapping.mappingType == UV_MAPPING_PLANAR) 40 | { 41 | // Note: Planar is on uv coordinate (and not uvXZ) 42 | real2 derivYPlane = UNPACK_DERIVATIVE_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uv, param), scale); 43 | // See comment above 44 | real3 volumeGrad = real3(derivYPlane.x, 0.0, derivYPlane.y); 45 | return SurfaceGradientFromVolumeGradient(uvMapping.normalWS, volumeGrad); 46 | } 47 | #endif 48 | else 49 | { 50 | #ifdef SURFACE_GRADIENT 51 | real2 deriv = UNPACK_DERIVATIVE_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uv, param), scale); 52 | return SurfaceGradientFromTBN(deriv, uvMapping.tangentWS, uvMapping.bitangentWS); 53 | #else 54 | return UNPACK_NORMAL_FUNC(SAMPLE_TEXTURE_FUNC(textureName, samplerName, uvMapping.uv, param), scale); 55 | #endif 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Sampling/SampleUVMappingNormalInternal.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1512feb483bc13e4c8c31200a4f9e862 3 | timeCreated: 1487475828 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Sampling/Sampling.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a4e15c16c134634bba20d914dd2c613 3 | timeCreated: 1472140530 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Shadow.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e306b1b7618cde044a48301247f1edcd 3 | folderAsset: yes 4 | timeCreated: 1491314187 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Shadow/ShadowSamplingTent.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2283803c0fcd5ea4ebfd0ced67133066 3 | timeCreated: 1491321444 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/SpaceFillingCurves.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_SPACE_FILLING_CURVES_INCLUDED 2 | #define UNITY_SPACE_FILLING_CURVES_INCLUDED 3 | 4 | // "Insert" a 0 bit after each of the 16 low bits of x. 5 | // Ref: https://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/ 6 | uint Part1By1(uint x) 7 | { 8 | x &= 0x0000ffff; // x = ---- ---- ---- ---- fedc ba98 7654 3210 9 | x = (x ^ (x << 8)) & 0x00ff00ff; // x = ---- ---- fedc ba98 ---- ---- 7654 3210 10 | x = (x ^ (x << 4)) & 0x0f0f0f0f; // x = ---- fedc ---- ba98 ---- 7654 ---- 3210 11 | x = (x ^ (x << 2)) & 0x33333333; // x = --fe --dc --ba --98 --76 --54 --32 --10 12 | x = (x ^ (x << 1)) & 0x55555555; // x = -f-e -d-c -b-a -9-8 -7-6 -5-4 -3-2 -1-0 13 | return x; 14 | } 15 | 16 | // "Insert" two 0 bits after each of the 10 low bits of x. 17 | // Ref: https://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/ 18 | uint Part1By2(uint x) 19 | { 20 | x &= 0x000003ff; // x = ---- ---- ---- ---- ---- --98 7654 3210 21 | x = (x ^ (x << 16)) & 0xff0000ff; // x = ---- --98 ---- ---- ---- ---- 7654 3210 22 | x = (x ^ (x << 8)) & 0x0300f00f; // x = ---- --98 ---- ---- 7654 ---- ---- 3210 23 | x = (x ^ (x << 4)) & 0x030c30c3; // x = ---- --98 ---- 76-- --54 ---- 32-- --10 24 | x = (x ^ (x << 2)) & 0x09249249; // x = ---- 9--8 --7- -6-- 5--4 --3- -2-- 1--0 25 | return x; 26 | } 27 | 28 | // Inverse of Part1By1 - "delete" all odd-indexed bits. 29 | // Ref: https://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/ 30 | uint Compact1By1(uint x) 31 | { 32 | x &= 0x55555555; // x = -f-e -d-c -b-a -9-8 -7-6 -5-4 -3-2 -1-0 33 | x = (x ^ (x >> 1)) & 0x33333333; // x = --fe --dc --ba --98 --76 --54 --32 --10 34 | x = (x ^ (x >> 2)) & 0x0f0f0f0f; // x = ---- fedc ---- ba98 ---- 7654 ---- 3210 35 | x = (x ^ (x >> 4)) & 0x00ff00ff; // x = ---- ---- fedc ba98 ---- ---- 7654 3210 36 | x = (x ^ (x >> 8)) & 0x0000ffff; // x = ---- ---- ---- ---- fedc ba98 7654 3210 37 | return x; 38 | } 39 | 40 | // Inverse of Part1By2 - "delete" all bits not at positions divisible by 3. 41 | // Ref: https://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/ 42 | uint Compact1By2(uint x) 43 | { 44 | x &= 0x09249249; // x = ---- 9--8 --7- -6-- 5--4 --3- -2-- 1--0 45 | x = (x ^ (x >> 2)) & 0x030c30c3; // x = ---- --98 ---- 76-- --54 ---- 32-- --10 46 | x = (x ^ (x >> 4)) & 0x0300f00f; // x = ---- --98 ---- ---- 7654 ---- ---- 3210 47 | x = (x ^ (x >> 8)) & 0xff0000ff; // x = ---- --98 ---- ---- ---- ---- 7654 3210 48 | x = (x ^ (x >> 16)) & 0x000003ff; // x = ---- ---- ---- ---- ---- --98 7654 3210 49 | return x; 50 | } 51 | 52 | uint EncodeMorton2D(uint2 coord) 53 | { 54 | return (Part1By1(coord.y) << 1) + Part1By1(coord.x); 55 | } 56 | 57 | uint EncodeMorton3D(uint3 coord) 58 | { 59 | return (Part1By2(coord.z) << 2) + (Part1By2(coord.y) << 1) + Part1By2(coord.x); 60 | } 61 | 62 | uint2 DecodeMorton2D(uint code) 63 | { 64 | return uint2(Compact1By1(code >> 0), Compact1By1(code >> 1)); 65 | } 66 | 67 | uint3 DecodeMorton3D(uint code) 68 | { 69 | return uint3(Compact1By2(code >> 0), Compact1By2(code >> 1), Compact1By2(code >> 2)); 70 | } 71 | 72 | uint InterleaveQuad(uint2 quad) 73 | { 74 | return quad.x + 2 * quad.y; 75 | } 76 | 77 | uint2 DeinterleaveQuad(uint code) 78 | { 79 | return uint2(code & 1, (code >> 1) & 1); 80 | } 81 | 82 | #endif // UNITY_SPACE_FILLING_CURVES_INCLUDED 83 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/SpaceFillingCurves.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e59586631eea404e93c7025219edfd6 3 | timeCreated: 1500391830 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/SpaceTransforms.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 10c1ef46793a20245a158d197d817894 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Tessellation.hlsl: -------------------------------------------------------------------------------- 1 | #define TESSELLATION_INTERPOLATE_BARY(name, bary) output.name = input0.name * bary.x + input1.name * bary.y + input2.name * bary.z 2 | 3 | // p0, p1, p2 triangle world position 4 | // p0, p1, p2 triangle world vertex normal 5 | real3 PhongTessellation(real3 positionWS, real3 p0, real3 p1, real3 p2, real3 n0, real3 n1, real3 n2, real3 baryCoords, real shape) 6 | { 7 | real3 c0 = ProjectPointOnPlane(positionWS, p0, n0); 8 | real3 c1 = ProjectPointOnPlane(positionWS, p1, n1); 9 | real3 c2 = ProjectPointOnPlane(positionWS, p2, n2); 10 | 11 | real3 phongPositionWS = baryCoords.x * c0 + baryCoords.y * c1 + baryCoords.z * c2; 12 | 13 | return lerp(positionWS, phongPositionWS, shape); 14 | } 15 | 16 | // Reference: http://twvideo01.ubm-us.net/o1/vault/gdc10/slides/Bilodeau_Bill_Direct3D11TutorialTessellation.pdf 17 | 18 | // Compute both screen and distance based adaptation - return factor between 0 and 1 19 | real3 GetScreenSpaceTessFactor(real3 p0, real3 p1, real3 p2, real4x4 viewProjectionMatrix, real4 screenSize, real triangleSize) 20 | { 21 | // Get screen space adaptive scale factor 22 | real2 edgeScreenPosition0 = ComputeNormalizedDeviceCoordinates(p0, viewProjectionMatrix) * screenSize.xy; 23 | real2 edgeScreenPosition1 = ComputeNormalizedDeviceCoordinates(p1, viewProjectionMatrix) * screenSize.xy; 24 | real2 edgeScreenPosition2 = ComputeNormalizedDeviceCoordinates(p2, viewProjectionMatrix) * screenSize.xy; 25 | 26 | real EdgeScale = 1.0 / triangleSize; // Edge size in reality, but name is simpler 27 | real3 tessFactor; 28 | tessFactor.x = saturate(distance(edgeScreenPosition1, edgeScreenPosition2) * EdgeScale); 29 | tessFactor.y = saturate(distance(edgeScreenPosition0, edgeScreenPosition2) * EdgeScale); 30 | tessFactor.z = saturate(distance(edgeScreenPosition0, edgeScreenPosition1) * EdgeScale); 31 | 32 | return tessFactor; 33 | } 34 | 35 | real3 GetDistanceBasedTessFactor(real3 p0, real3 p1, real3 p2, real3 cameraPosWS, real tessMinDist, real tessMaxDist) 36 | { 37 | real3 edgePosition0 = 0.5 * (p1 + p2); 38 | real3 edgePosition1 = 0.5 * (p0 + p2); 39 | real3 edgePosition2 = 0.5 * (p0 + p1); 40 | 41 | // In case camera-relative rendering is enabled, 'cameraPosWS' is statically known to be 0, 42 | // so the compiler will be able to optimize distance() to length(). 43 | real dist0 = distance(edgePosition0, cameraPosWS); 44 | real dist1 = distance(edgePosition1, cameraPosWS); 45 | real dist2 = distance(edgePosition2, cameraPosWS); 46 | 47 | // The saturate will handle the produced NaN in case min == max 48 | real fadeDist = tessMaxDist - tessMinDist; 49 | real3 tessFactor; 50 | tessFactor.x = saturate(1.0 - (dist0 - tessMinDist) / fadeDist); 51 | tessFactor.y = saturate(1.0 - (dist1 - tessMinDist) / fadeDist); 52 | tessFactor.z = saturate(1.0 - (dist2 - tessMinDist) / fadeDist); 53 | 54 | return tessFactor; 55 | } 56 | 57 | real4 CalcTriTessFactorsFromEdgeTessFactors(real3 triVertexFactors) 58 | { 59 | real4 tess; 60 | tess.x = triVertexFactors.x; 61 | tess.y = triVertexFactors.y; 62 | tess.z = triVertexFactors.z; 63 | tess.w = (triVertexFactors.x + triVertexFactors.y + triVertexFactors.z) / 3.0; 64 | 65 | return tess; 66 | } 67 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Tessellation.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86ef8a10e3e100c41b7d228b5dccb393 3 | timeCreated: 1483692743 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Texture.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87ed7142dd4a813488697dc0d8fa2622 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/TextureStack.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 472dadfd9f2f7be4b80df849cb79aa30 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/UnityDOTSInstancing.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7bf4b53e2f8c18b48b797bb8ce7ab547 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/UnityInstancing.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ff55611122048e43b0790a9561378d4 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Version.hlsl: -------------------------------------------------------------------------------- 1 | // The old version number system below is deprecated whith Graphic Packages that have move as core package of Unity. 2 | // User should rely on the Macro UNITY_VERSION now to detect which version of Unity is coupled to the current set of pipeline shader 3 | // Example of usage #if UNITY_VERSION >= 202120 to check if the version is above or equal 2021.2 4 | #define SHADER_LIBRARY_VERSION_MAJOR 12 5 | #define SHADER_LIBRARY_VERSION_MINOR 1 6 | 7 | #define VERSION_GREATER_EQUAL(major, minor) ((SHADER_LIBRARY_VERSION_MAJOR > major) || ((SHADER_LIBRARY_VERSION_MAJOR == major) && (SHADER_LIBRARY_VERSION_MINOR >= minor))) 8 | #define VERSION_LOWER(major, minor) ((SHADER_LIBRARY_VERSION_MAJOR < major) || ((SHADER_LIBRARY_VERSION_MAJOR == major) && (SHADER_LIBRARY_VERSION_MINOR < minor))) 9 | #define VERSION_EQUAL(major, minor) ((SHADER_LIBRARY_VERSION_MAJOR == major) && (SHADER_LIBRARY_VERSION_MINOR == minor)) 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/Version.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4890e86789bded14295c5a2728cfd406 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/VirtualTexturing.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04a132857bb0a974ab137ac76dd6896c 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CoreRP/ShaderLibrary/VolumeRendering.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b575495d94769e942b2d0e1180940bd4 3 | timeCreated: 1503651539 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /CoreRP/Unity LICENSE.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32f055d4fecb8ba4d9afd3dff1a8ab0d 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /CustomLighting.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35f32438d82d8fb45b4a714b9fd87518 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /CustomLighting/Bakery.cginc: -------------------------------------------------------------------------------- 1 | #ifndef BAKERY_INCLUDED 2 | #define BAKERY_INCLUDED 3 | 4 | Texture2D _RNM0, _RNM1, _RNM2; 5 | float4 _RNM0_TexelSize; 6 | 7 | #if defined(SHADER_API_MOBILE) 8 | #define BAKERY_SHNONLINEAR_OFF 9 | #endif 10 | 11 | void BakerySHLightmapAndSpecular(inout half3 lightMap, float2 lightmapUV, inout half3 directSpecular, float3 normalWS, float3 viewDir, half roughness, half3 f0) 12 | { 13 | #ifdef BAKERY_SH 14 | 15 | half3 L0 = lightMap; 16 | float3 nL1x = _RNM0.Sample(custom_bilinear_clamp_sampler, lightmapUV).rgb * 2.0 - 1.0; 17 | float3 nL1y = _RNM1.Sample(custom_bilinear_clamp_sampler, lightmapUV).rgb * 2.0 - 1.0; 18 | float3 nL1z = _RNM2.Sample(custom_bilinear_clamp_sampler, lightmapUV).rgb * 2.0 - 1.0; 19 | float3 L1x = nL1x * L0 * 2.0; 20 | float3 L1y = nL1y * L0 * 2.0; 21 | float3 L1z = nL1z * L0 * 2.0; 22 | 23 | #ifndef BAKERY_SHNONLINEAR_OFF 24 | float lumaL0 = dot(L0, float(1)); 25 | float lumaL1x = dot(L1x, float(1)); 26 | float lumaL1y = dot(L1y, float(1)); 27 | float lumaL1z = dot(L1z, float(1)); 28 | float lumaSH = shEvaluateDiffuseL1Geomerics(lumaL0, float3(lumaL1x, lumaL1y, lumaL1z), normalWS); 29 | 30 | lightMap = L0 + normalWS.x * L1x + normalWS.y * L1y + normalWS.z * L1z; 31 | float regularLumaSH = dot(lightMap, 1.0); 32 | lightMap *= lerp(1.0, lumaSH / regularLumaSH, saturate(regularLumaSH * 16.0)); 33 | #else 34 | lightMap = L0 + normalWS.x * L1x + normalWS.y * L1y + normalWS.z * L1z; 35 | #endif 36 | 37 | #ifdef _LIGHTMAPPED_SPECULAR 38 | float3 dominantDir = float3(dot(nL1x, GRAYSCALE), dot(nL1y, GRAYSCALE), dot(nL1z, GRAYSCALE)); 39 | float3 halfDir = Unity_SafeNormalize(normalize(dominantDir) + viewDir); 40 | half NoH = saturate(dot(normalWS, halfDir)); 41 | half spec = D_GGX(NoH, roughness); 42 | half3 sh = L0 + dominantDir.x * L1x + dominantDir.y * L1y + dominantDir.z * L1z; 43 | dominantDir = normalize(dominantDir); 44 | 45 | directSpecular += max(spec * sh, 0.0); 46 | #endif 47 | 48 | #endif 49 | } 50 | 51 | #ifdef BAKERY_MONOSH 52 | void BakeryMonoSH(inout float3 diffuseColor, inout float3 specularColor, float2 lmUV, float3 normalWorld, float3 viewDir, half roughness) 53 | { 54 | float3 L0 = diffuseColor; 55 | 56 | #if UNITY_VERSION >= 201740 57 | float3 dominantDir = unity_LightmapInd.Sample(custom_bilinear_clamp_sampler, lmUV).xyz; 58 | #else 59 | float3 dominantDir = UNITY_SAMPLE_TEX2D_SAMPLER(unity_LightmapInd, unity_Lightmap, lmUV).xyz; 60 | #endif 61 | 62 | float3 nL1 = dominantDir * 2 - 1; 63 | float3 L1x = nL1.x * L0 * 2; 64 | float3 L1y = nL1.y * L0 * 2; 65 | float3 L1z = nL1.z * L0 * 2; 66 | float3 sh; 67 | #ifndef BAKERY_SHNONLINEAR_OFF 68 | float lumaL0 = dot(L0, 1); 69 | float lumaL1x = dot(L1x, 1); 70 | float lumaL1y = dot(L1y, 1); 71 | float lumaL1z = dot(L1z, 1); 72 | float lumaSH = shEvaluateDiffuseL1Geomerics(lumaL0, float3(lumaL1x, lumaL1y, lumaL1z), normalWorld); 73 | 74 | sh = L0 + normalWorld.x * L1x + normalWorld.y * L1y + normalWorld.z * L1z; 75 | float regularLumaSH = dot(sh, 1); 76 | //sh *= regularLumaSH < 0.001 ? 1 : (lumaSH / regularLumaSH); 77 | sh *= lerp(1, lumaSH / regularLumaSH, saturate(regularLumaSH*16)); 78 | 79 | //sh.r = shEvaluateDiffuseL1Geomerics(L0.r, float3(L1x.r, L1y.r, L1z.r), normalWorld); 80 | //sh.g = shEvaluateDiffuseL1Geomerics(L0.g, float3(L1x.g, L1y.g, L1z.g), normalWorld); 81 | //sh.b = shEvaluateDiffuseL1Geomerics(L0.b, float3(L1x.b, L1y.b, L1z.b), normalWorld); 82 | 83 | #else 84 | sh = L0 + normalWorld.x * L1x + normalWorld.y * L1y + normalWorld.z * L1z; 85 | #endif 86 | 87 | diffuseColor = max(sh, 0.0); 88 | 89 | specularColor = 0; 90 | #ifdef _LIGHTMAPPED_SPECULAR 91 | dominantDir = nL1; 92 | float focus = saturate(length(dominantDir)); 93 | half3 halfDir = Unity_SafeNormalize(normalize(dominantDir) + viewDir); 94 | half nh = saturate(dot(normalWorld, halfDir)); 95 | half spec = D_GGX(nh, roughness); 96 | 97 | sh = L0 + dominantDir.x * L1x + dominantDir.y * L1y + dominantDir.z * L1z; 98 | 99 | specularColor = max(spec * sh, 0.0); 100 | #endif 101 | } 102 | #endif 103 | 104 | 105 | #endif -------------------------------------------------------------------------------- /CustomLighting/Bakery.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd4857fd031cfcf4f816ffacbd1decfb 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CustomLighting/BicubicSampling.cginc: -------------------------------------------------------------------------------- 1 | #ifndef BICUBIC_SAMPLING_INCLUDED 2 | #define BICUBIC_SAMPLING_INCLUDED 3 | #if defined(SHADER_API_MOBILE) 4 | #undef BICUBIC_LIGHTMAP 5 | #endif 6 | 7 | // https://ndotl.wordpress.com/2018/08/29/baking-artifact-free-lightmaps 8 | // bicubicw0, bicubicw1, bicubicw2, and bicubicw3 are the four cubic B-spline basis functions 9 | float bicubicw0(float a) 10 | { 11 | // return (1.0f/6.0f)*(-a*a*a + 3.0f*a*a - 3.0f*a + 1.0f); 12 | return (1.0f/6.0f)*(a*(a*(-a + 3.0f) - 3.0f) + 1.0f); // optimized 13 | } 14 | 15 | float bicubicw1(float a) 16 | { 17 | // return (1.0f/6.0f)*(3.0f*a*a*a - 6.0f*a*a + 4.0f); 18 | return (1.0f/6.0f)*(a*a*(3.0f*a - 6.0f) + 4.0f); 19 | } 20 | 21 | float bicubicw2(float a) 22 | { 23 | // return (1.0f/6.0f)*(-3.0f*a*a*a + 3.0f*a*a + 3.0f*a + 1.0f); 24 | return (1.0f/6.0f)*(a*(a*(-3.0f*a + 3.0f) + 3.0f) + 1.0f); 25 | } 26 | 27 | float bicubicw3(float a) 28 | { 29 | return (1.0f/6.0f)*(a*a*a); 30 | } 31 | 32 | // bicubicg0 and bicubicg1 are the two amplitude functions 33 | float bicubicg0(float a) 34 | { 35 | return bicubicw0(a) + bicubicw1(a); 36 | } 37 | 38 | float bicubicg1(float a) 39 | { 40 | return bicubicw2(a) + bicubicw3(a); 41 | } 42 | 43 | // bicubich0 and bicubich1 are the two offset functions 44 | float bicubich0(float a) 45 | { 46 | // note +0.5 offset to compensate for CUDA linear filtering convention 47 | return -1.0f + bicubicw1(a) / (bicubicw0(a) + bicubicw1(a)) + 0.5f; 48 | } 49 | 50 | float bicubich1(float a) 51 | { 52 | return 1.0f + bicubicw3(a) / (bicubicw2(a) + bicubicw3(a)) + 0.5f; 53 | } 54 | 55 | half4 SampleBicubic(Texture2D t, SamplerState s, float2 uv, float2 widthHeight, float2 texelSize) 56 | { 57 | #if defined(SHADER_API_MOBILE) || !defined(_BICUBICLIGHTMAP) 58 | return t.Sample(s, uv); 59 | #else 60 | 61 | float2 xy = uv * widthHeight - 0.5; 62 | float2 pxy = floor(xy); 63 | float2 fxy = xy - pxy; 64 | 65 | // note: we could store these functions in a lookup table texture, but maths is cheap 66 | float bicubicg0x = bicubicg0(fxy.x); 67 | float bicubicg1x = bicubicg1(fxy.x); 68 | float bicubich0x = bicubich0(fxy.x); 69 | float bicubich1x = bicubich1(fxy.x); 70 | float bicubich0y = bicubich0(fxy.y); 71 | float bicubich1y = bicubich1(fxy.y); 72 | 73 | //float lod = ComputeTextureLOD(uv); 74 | 75 | float4 t0 = bicubicg0x * t.SampleLevel(s, float2(pxy.x + bicubich0x, pxy.y + bicubich0y) * texelSize, 0); 76 | float4 t1 = bicubicg1x * t.SampleLevel(s, float2(pxy.x + bicubich1x, pxy.y + bicubich0y) * texelSize, 0); 77 | float4 t2 = bicubicg0x * t.SampleLevel(s, float2(pxy.x + bicubich0x, pxy.y + bicubich1y) * texelSize, 0); 78 | float4 t3 = bicubicg1x * t.SampleLevel(s, float2(pxy.x + bicubich1x, pxy.y + bicubich1y) * texelSize, 0); 79 | 80 | return bicubicg0(fxy.y) * (t0 + t1) + bicubicg1(fxy.y) * (t2 + t3); 81 | #endif 82 | } 83 | 84 | half4 SampleBicubic(Texture2D t, SamplerState s, float2 uv, float4 texelSize) 85 | { 86 | return SampleBicubic(t, s, uv, texelSize.zw, texelSize.xy); 87 | } 88 | 89 | half4 SampleBicubic(Texture2D t, SamplerState s, float2 uv) 90 | { 91 | float2 widthHeight; 92 | t.GetDimensions(widthHeight.x, widthHeight.y); 93 | float2 texelSize = 1.0 / widthHeight; 94 | return SampleBicubic(t, s, uv, widthHeight, texelSize); 95 | } 96 | #endif -------------------------------------------------------------------------------- /CustomLighting/BicubicSampling.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 476aa59936ac07d4cbfc9f4ebf6f26ca 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CustomLighting/CommonFunctions.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a83b314c52c1b854e8aaa47dfae131d7 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CustomLighting/Core.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53028feb31953aa4498bdd790baf73a8 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CustomLighting/EnvironmentBRDF.cginc: -------------------------------------------------------------------------------- 1 | #ifndef ENVIRONMENTBRDF_INCLUDED 2 | #define ENVIRONMENTBRDF_INCLUDED 3 | Texture2D _DFG; 4 | SamplerState sampler_DFG; 5 | 6 | static float2 DFGLut; 7 | static half3 DFGEnergyCompensation; 8 | 9 | half4 SampleDFG(half NoV, half perceptualRoughness) 10 | { 11 | return _DFG.SampleLevel(sampler_DFG, float2(NoV, perceptualRoughness), 0); 12 | } 13 | 14 | half3 EnvBRDF(half2 dfg, half3 f0) 15 | { 16 | return f0 * dfg.x + dfg.y; 17 | } 18 | 19 | half3 EnvBRDFMultiscatter(half2 dfg, half3 f0) 20 | { 21 | return lerp(dfg.xxx, dfg.yyy, f0); 22 | } 23 | 24 | half3 EnvBRDFEnergyCompensation(half2 dfg, half3 f0) 25 | { 26 | return 1.0 + f0 * (1.0 / dfg.y - 1.0); 27 | } 28 | 29 | half3 EnvBRDFApprox(half perceptualRoughness, half NoV, half3 f0) 30 | { 31 | // original code from https://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf 32 | half g = 1 - perceptualRoughness; 33 | half4 t = half4(1 / 0.96, 0.475, (0.0275 - 0.25 * 0.04) / 0.96, 0.25); 34 | t *= half4(g, g, g, g); 35 | t += half4(0.0, 0.0, (0.015 - 0.75 * 0.04) / 0.96, 0.75); 36 | half a0 = t.x * min(t.y, exp2(-9.28 * NoV)) + t.z; 37 | half a1 = t.w; 38 | return saturate(lerp(a0, a1, f0)); 39 | } 40 | #endif -------------------------------------------------------------------------------- /CustomLighting/EnvironmentBRDF.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7fabd884f4de72741bc1892af0f383d2 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CustomLighting/FlatLit.cginc: -------------------------------------------------------------------------------- 1 | 2 | half3 BetterSH9(half4 normal) 3 | { 4 | half3 indirect; 5 | half3 L0 = half3(unity_SHAr.w, unity_SHAg.w, unity_SHAb.w) + half3(unity_SHBr.z, unity_SHBg.z, unity_SHBb.z) / 3.0; 6 | indirect.r = shEvaluateDiffuseL1Geomerics(L0.r, unity_SHAr.xyz, normal.xyz); 7 | indirect.g = shEvaluateDiffuseL1Geomerics(L0.g, unity_SHAg.xyz, normal.xyz); 8 | indirect.b = shEvaluateDiffuseL1Geomerics(L0.b, unity_SHAb.xyz, normal.xyz); 9 | indirect = max(0, indirect); 10 | indirect += SHEvalLinearL2(normal); 11 | return indirect; 12 | } 13 | 14 | float calculateluminance(float3 color) 15 | { 16 | return color.r * 0.299 + color.g * 0.587 + color.b * 0.114; 17 | } 18 | 19 | // MIT License 20 | 21 | // Copyright (c) 2018 King Arthur 22 | 23 | // Permission is hereby granted, free of charge, to any person obtaining a copy 24 | // of this software and associated documentation files (the "Software"), to deal 25 | // in the Software without restriction, including without limitation the rights 26 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 27 | // copies of the Software, and to permit persons to whom the Software is 28 | // furnished to do so, subject to the following conditions: 29 | 30 | // The above copyright notice and this permission notice shall be included in all 31 | // copies or substantial portions of the Software. 32 | 33 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 34 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 35 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 36 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 37 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 38 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 39 | // SOFTWARE. 40 | -------------------------------------------------------------------------------- /CustomLighting/FlatLit.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 074e2b70e7226d34f82787928a2ba0c2 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CustomLighting/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 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. -------------------------------------------------------------------------------- /CustomLighting/LICENSE.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fdabc71471122c341aab2429bca092fb 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /CustomLighting/NonImportantLights.cginc: -------------------------------------------------------------------------------- 1 | #ifndef NONIMPORTANTLIGHTS_PERPIXEL_INCLUDED 2 | #define NONIMPORTANTLIGHTS_PERPIXEL_INCLUDED 3 | #if defined(VERTEXLIGHT_ON) && defined(UNITY_PASS_FORWARDBASE) 4 | 5 | void NonImportantLightsPerPixel(inout half3 lightColor, inout half3 directSpecular, float3 positionWS, float3 normalWS, float3 viewDir, half NoV, half3 f0, half clampedRoughness) 6 | { 7 | float4 toLightX = unity_4LightPosX0 - positionWS.x; 8 | float4 toLightY = unity_4LightPosY0 - positionWS.y; 9 | float4 toLightZ = unity_4LightPosZ0 - positionWS.z; 10 | 11 | float4 lengthSq = 0.0; 12 | lengthSq += toLightX * toLightX; 13 | lengthSq += toLightY * toLightY; 14 | lengthSq += toLightZ * toLightZ; 15 | 16 | float4 attenuation = 1.0 / (1.0 + lengthSq * unity_4LightAtten0); 17 | float4 atten2 = saturate(1 - (lengthSq * unity_4LightAtten0 / 25.0)); 18 | attenuation = min(attenuation, atten2 * atten2); 19 | 20 | [unroll(4)] 21 | for(uint i = 0; i < 4; i++) 22 | { 23 | UNITY_BRANCH 24 | if (attenuation[i] > 0.0) 25 | { 26 | float3 direction = normalize(float3(unity_4LightPosX0[i], unity_4LightPosY0[i], unity_4LightPosZ0[i]) - positionWS); 27 | half NoL = saturate(dot(normalWS, direction)); 28 | half3 color = NoL * attenuation[i] * unity_LightColor[i]; 29 | 30 | #ifdef SHADINGMODEL_FLATLIT 31 | lightColor += attenuation[i] * unity_LightColor[i]; 32 | #else 33 | lightColor += color; 34 | #endif 35 | 36 | #ifndef _SPECULARHIGHLIGHTS_OFF 37 | float3 halfVector = Unity_SafeNormalize(direction + viewDir); 38 | half vNoH = saturate(dot(normalWS, halfVector)); 39 | half vLoH = saturate(dot(direction, halfVector)); 40 | 41 | half3 Fv = F_Schlick(vLoH, f0); 42 | half Dv = D_GGX(vNoH, clampedRoughness); 43 | half Vv = V_SmithGGXCorrelatedFast(NoV, NoL, clampedRoughness); 44 | directSpecular += max(0.0, (Dv * Vv) * Fv) * color; 45 | #endif 46 | } 47 | } 48 | } 49 | 50 | 51 | 52 | // Original code by Xiexe 53 | // https://github.com/Xiexe/Xiexes-Unity-Shaders 54 | 55 | // MIT License 56 | 57 | // Copyright (c) 2019 Xiexe 58 | 59 | // Permission is hereby granted, free of charge, to any person obtaining a copy 60 | // of this software and associated documentation files (the "Software"), to deal 61 | // in the Software without restriction, including without limitation the rights 62 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 63 | // copies of the Software, and to permit persons to whom the Software is 64 | // furnished to do so, subject to the following conditions: 65 | 66 | // The above copyright notice and this permission notice shall be included in all 67 | // copies or substantial portions of the Software. 68 | 69 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 70 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 71 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 72 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 73 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 74 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 75 | // SOFTWARE. 76 | #endif 77 | #endif -------------------------------------------------------------------------------- /CustomLighting/NonImportantLights.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f1b42504b77a5a4da42da9636aaf028 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /CustomLighting/SurfaceData.cginc: -------------------------------------------------------------------------------- 1 | struct SurfaceDataCustom 2 | { 3 | half3 albedo; 4 | half3 tangentNormal; 5 | half3 emission; 6 | half metallic; 7 | half perceptualRoughness; 8 | half occlusion; 9 | half reflectance; 10 | half alpha; 11 | half alphaClipThreshold; 12 | }; 13 | 14 | void InitializeDefaultSurfaceData(inout SurfaceDataCustom surf) 15 | { 16 | surf.albedo = 1.0; 17 | surf.tangentNormal = half3(0,0,1); 18 | surf.emission = 0.0; 19 | surf.metallic = 0.0; 20 | surf.perceptualRoughness = 0.0; 21 | surf.occlusion = 1.0; 22 | surf.reflectance = 0.5; 23 | surf.alpha = 1.0; 24 | surf.alphaClipThreshold = 0.5; 25 | } 26 | 27 | 28 | void CopyStandardToCustomSurfaceData(inout SurfaceDataCustom surf, SurfaceOutputStandard standardSurf) 29 | { 30 | surf.albedo = standardSurf.Albedo; 31 | surf.tangentNormal = standardSurf.Normal; 32 | surf.emission = standardSurf.Emission; 33 | surf.metallic = standardSurf.Metallic; 34 | surf.perceptualRoughness = 1.0f - standardSurf.Smoothness; 35 | surf.occlusion = standardSurf.Occlusion; 36 | surf.reflectance = static_Reflectance; 37 | surf.alpha = standardSurf.Alpha; 38 | } -------------------------------------------------------------------------------- /CustomLighting/SurfaceData.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 100f40b227b1f1e49ac326fb7d35597c 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f67ea4b212ec8e54ea6c3fa9790bf32e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Importer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a5bd2b5732cfed4e99fb608bee64983 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ImporterEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e151e9b89c2b0a34d821279895ffbe8e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/ImporterSettings.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace ShaderGraphImporter 4 | { 5 | [CreateAssetMenu(fileName = "new Importer", menuName = "Shader/Shader Graph Importer")] 6 | public class ImporterSettings : ScriptableObject 7 | { 8 | public string shaderCode; 9 | public string shaderPath; 10 | public bool alphaToCoverage = true; 11 | public bool grabPass = false; 12 | public bool allowVertexLights = true; 13 | public bool lodFadeCrossfade = false; 14 | public bool bicubicLightmap = true; 15 | public bool bakeryFeatures = true; 16 | public bool specularOcclusion = false; 17 | public bool ltcgi = false; 18 | public bool dps = false; 19 | public bool stencil = false; 20 | public bool includeAudioLink = false; 21 | public string CustomEditor = "ShaderGraphImporter.DefaultInspector"; 22 | public string fallback; 23 | public string[] cgInclude; 24 | public ShadingModel shadingModel = ShadingModel.Lit; 25 | public VRCFallbackTags fallbackTags = VRCFallbackTags.defaultTag; 26 | public string VRCFallback = string.Empty; 27 | public bool thirdPartyFoldout = false; 28 | public Shader additionalPass; 29 | } 30 | 31 | public enum ShadingModel { Lit, FlatLit }; 32 | 33 | 34 | 35 | } -------------------------------------------------------------------------------- /Editor/ImporterSettings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 807326c6ef764e21a19cd0fc0d940c8d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {fileID: 2800000, guid: ba83742ac2b2a1a4f85a14386a9b9ac1, type: 3} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 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. -------------------------------------------------------------------------------- /Editor/LICENSE.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 08d87a02af103ae4fadf55acfc6c68f4 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dd73f9d8e1895384fbc0f9851d7e8041 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Resources/ShaderGraphImporterIcon0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z3y/ShaderGraph-BuiltIn-Importer/28605f39f5f004a2a1461b57f9ae0d42105ad20b/Editor/Resources/ShaderGraphImporterIcon0.png -------------------------------------------------------------------------------- /Editor/Resources/ShaderGraphImporterIcon0.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ba83742ac2b2a1a4f85a14386a9b9ac1 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 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 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: 1 35 | aniso: 1 36 | mipBias: 0 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: 1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 256 65 | resizeAlgorithm: 1 66 | textureFormat: -1 67 | textureCompression: 2 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 256 77 | resizeAlgorithm: 1 78 | textureFormat: -1 79 | textureCompression: 2 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | - serializedVersion: 3 87 | buildTarget: Android 88 | maxTextureSize: 256 89 | resizeAlgorithm: 1 90 | textureFormat: -1 91 | textureCompression: 2 92 | compressionQuality: 50 93 | crunchedCompression: 0 94 | allowsAlphaSplitting: 0 95 | overridden: 0 96 | androidETC2FallbackOverride: 0 97 | forceMaximumCompressionQuality_BC6H_BC7: 0 98 | spriteSheet: 99 | serializedVersion: 2 100 | sprites: [] 101 | outline: [] 102 | physicsShape: [] 103 | bones: [] 104 | spriteID: 105 | internalID: 0 106 | vertices: [] 107 | indices: 108 | edges: [] 109 | weights: [] 110 | secondaryTextures: [] 111 | spritePackingTag: 112 | pSDRemoveMatte: 0 113 | pSDShowRemoveMatteOption: 0 114 | userData: 115 | assetBundleName: 116 | assetBundleVariant: 117 | -------------------------------------------------------------------------------- /Editor/Resources/ShaderGraphImporterIcon1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z3y/ShaderGraph-BuiltIn-Importer/28605f39f5f004a2a1461b57f9ae0d42105ad20b/Editor/Resources/ShaderGraphImporterIcon1.png -------------------------------------------------------------------------------- /Editor/Resources/ShaderGraphImporterIcon1.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 806321d39154052449cbc87e5afe2543 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 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 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: 1 35 | aniso: 1 36 | mipBias: 0 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: 1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 256 65 | resizeAlgorithm: 1 66 | textureFormat: -1 67 | textureCompression: 2 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 256 77 | resizeAlgorithm: 1 78 | textureFormat: -1 79 | textureCompression: 2 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | - serializedVersion: 3 87 | buildTarget: Android 88 | maxTextureSize: 256 89 | resizeAlgorithm: 1 90 | textureFormat: -1 91 | textureCompression: 2 92 | compressionQuality: 50 93 | crunchedCompression: 0 94 | allowsAlphaSplitting: 0 95 | overridden: 0 96 | androidETC2FallbackOverride: 0 97 | forceMaximumCompressionQuality_BC6H_BC7: 0 98 | spriteSheet: 99 | serializedVersion: 2 100 | sprites: [] 101 | outline: [] 102 | physicsShape: [] 103 | bones: [] 104 | spriteID: 105 | internalID: 0 106 | vertices: [] 107 | indices: 108 | edges: [] 109 | weights: [] 110 | secondaryTextures: [] 111 | spritePackingTag: 112 | pSDRemoveMatte: 0 113 | pSDShowRemoveMatteOption: 0 114 | userData: 115 | assetBundleName: 116 | assetBundleVariant: 117 | -------------------------------------------------------------------------------- /Editor/ShaderGraphInspector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 39bb85d5a52b9d64eb43e82cc2076f8a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/VRCFallbackTags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ShaderGraphImporter 4 | { 5 | [Serializable] 6 | public class VRCFallbackTags 7 | { 8 | public enum ShaderType 9 | { 10 | Standard, 11 | Unlit, 12 | VertexLit, 13 | Toon, 14 | Particle, 15 | Sprite, 16 | Matcap, 17 | MobileToon, 18 | Hidden 19 | }; 20 | 21 | public enum ShaderMode 22 | { 23 | Opaque, 24 | Cutout, 25 | Transparent, 26 | Fade 27 | }; 28 | 29 | public ShaderType type; 30 | public ShaderMode mode; 31 | public bool doubleSided; 32 | 33 | public static string GetTag(VRCFallbackTags tags) 34 | { 35 | string result = string.Empty; 36 | result += Enum.GetName(typeof(ShaderType), tags.type); 37 | result += Enum.GetName(typeof(ShaderMode), tags.mode); 38 | if (tags.doubleSided) result += "DoubleSided"; 39 | 40 | result = result.Replace("Standard", string.Empty); 41 | result = result.Replace("Opaque", string.Empty); 42 | 43 | return result; 44 | } 45 | 46 | public static VRCFallbackTags defaultTag = new VRCFallbackTags() 47 | { 48 | type = VRCFallbackTags.ShaderType.Standard, 49 | mode = VRCFallbackTags.ShaderMode.Opaque, 50 | doubleSided = false 51 | }; 52 | } 53 | } -------------------------------------------------------------------------------- /Editor/VRCFallbackTags.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc1b525878174507a44a8342a0ca2533 3 | timeCreated: 1654100795 -------------------------------------------------------------------------------- /Editor/com.z3y.shadergraph-builtin.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.z3y.shadergraph-builtin", 3 | "references": [], 4 | "includePlatforms": [ 5 | "Editor" 6 | ], 7 | "excludePlatforms": [], 8 | "allowUnsafeCode": false, 9 | "overrideReferences": false, 10 | "precompiledReferences": [], 11 | "autoReferenced": true, 12 | "defineConstraints": [], 13 | "versionDefines": [], 14 | "noEngineReferences": false 15 | } -------------------------------------------------------------------------------- /Editor/com.z3y.shadergraph-builtin.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e0b098483a6c8e4589b251e84c0cef6 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/dfg-multiscatter.exr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z3y/ShaderGraph-BuiltIn-Importer/28605f39f5f004a2a1461b57f9ae0d42105ad20b/Editor/dfg-multiscatter.exr -------------------------------------------------------------------------------- /Editor/dfg-multiscatter.exr.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: af17e78d30db7cc438ee36132e35d43e 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 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 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: 1 35 | aniso: 0 36 | mipBias: 0 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: 1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 0 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 256 65 | resizeAlgorithm: 1 66 | textureFormat: -1 67 | textureCompression: 0 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 256 77 | resizeAlgorithm: 1 78 | textureFormat: -1 79 | textureCompression: 0 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | - serializedVersion: 3 87 | buildTarget: Android 88 | maxTextureSize: 128 89 | resizeAlgorithm: 1 90 | textureFormat: 4 91 | textureCompression: 0 92 | compressionQuality: 50 93 | crunchedCompression: 0 94 | allowsAlphaSplitting: 0 95 | overridden: 1 96 | androidETC2FallbackOverride: 0 97 | forceMaximumCompressionQuality_BC6H_BC7: 0 98 | spriteSheet: 99 | serializedVersion: 2 100 | sprites: [] 101 | outline: [] 102 | physicsShape: [] 103 | bones: [] 104 | spriteID: 105 | internalID: 0 106 | vertices: [] 107 | indices: 108 | edges: [] 109 | weights: [] 110 | secondaryTextures: [] 111 | spritePackingTag: 112 | pSDRemoveMatte: 0 113 | pSDShowRemoveMatteOption: 0 114 | userData: 115 | assetBundleName: 116 | assetBundleVariant: 117 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Replaced with https://github.com/z3y/ShaderGraph 2 | 3 | 4 | 5 | ShaderGraph built-in importer with custom shading and bug fixes. Target version is 2019.4 (VRChat). Shader Graph supports built-in pipeline natively in 2021+, this package only aims to fix bugs, make it usable in VRChat with both lit and unlit modes and provide some improvements. Experimental, might have breaking changes in the future. 6 | 7 | 8 | ### Installation: 9 | - Download and install Unity 2021 LTS and import Shader Graph (12.1.6) from the package manager 10 | - Import this package using git URL `https://github.com/z3y/ShaderGraph-BuiltIn-Importer.git` (install [Git](https://git-scm.com/) if you haven't already and restart Unity) 11 | OR download source and import the package.json 12 | with the Package Manager in Unity 2019 13 | 14 | ### How to use: 15 | - Create a Shader using Shader Graph with built-in target in 2021 16 | - Save Asset, Show In Project and Copy Shader 17 | - Create a new shader graph importer `Create > Shader > Shader Graph Importer` in 2019 18 | - Paste and Import 19 | 20 | 21 | ### Features: 22 | - Bakery features 23 | - Bicubic lightmap 24 | - Alpha to coverage 25 | - LTCGI 26 | - Audio Link 27 | - Flat Lit 28 | 29 | Notable bug fixes: GPU Instancing, Single Pass, Single Pass Instanced 30 | 31 | - Unity has a shader graph variant limit but its too low. Increase it in `Preferences > Shader Graph > Shader Variant Limit` 32 | - Stage keywords dont work on Quest, use only All stages 33 | - Make sure to follow standard property naming convetions so your shaders can fallback properly 34 | 35 | 36 | Shader Graph and Built-In shader code owned by Unity, Licensed under Unity Companion License: 37 | https://unity3d.com/legal/licenses/Unity_Companion_License 38 | 39 | For other files licenses are included in folders or files 40 | 41 | # 42 | If you want to ask something join https://discord.gg/bw46tKgRFT 43 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f8f232a8adb08747a125d6ddfa4d7ce 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69199b45e487b724caf178f442db796a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples/.shader: -------------------------------------------------------------------------------- 1 | Shader "Imported Shader Graphs/" 2 | -------------------------------------------------------------------------------- /Samples/Flat Lit.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7357731e38db5ea4e9dc6dd39050bc53 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples/Flat Lit.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17c7e8c9fb3447244b9482fd1c261ce0 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: 7 | - _DFG: {fileID: 2800000, guid: af17e78d30db7cc438ee36132e35d43e, type: 3} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Samples/Standard.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0548ab082354b7849b0ead41c83daf9e 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples/Standard.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9936a41fde0ab464f8606addc81be591 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: 7 | - _DFG: {fileID: 2800000, guid: af17e78d30db7cc438ee36132e35d43e, type: 3} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /ShaderGraph.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 741da9feb2e2fab44a60da892dac59d9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ShaderGraph/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 226e154f0c57b874ebec975d6f6285b3 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc1f3aefdce0c9c488ffa931bb6b8283 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc050569712ff15428f17eb64b3d6a94 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 013f9f05bf6b3014e914e3d4b94829fb 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 90225db7e5e0f2244a1f61058c7df76c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b1b65539d3a8c64982bdacc35dd4833 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1488c0e9361af5f4dab00b14d2ae0057 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/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 | 25 | // not needed 26 | // inputData.viewDirectionWS = SafeNormalize(input.viewDirectionWS); 27 | 28 | #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) 29 | inputData.shadowCoord = input.shadowCoord; 30 | #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS) 31 | inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS); 32 | #else 33 | inputData.shadowCoord = float4(0, 0, 0, 0); 34 | #endif 35 | 36 | inputData.fogCoord = input.fogFactorAndVertexLight.x; 37 | inputData.vertexLighting = input.fogFactorAndVertexLight.yzw; 38 | #if defined(LIGHTMAP_ON) 39 | inputData.bakedGI = SAMPLE_GI(input.lightmapUV, input.sh, inputData.normalWS); 40 | inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV); 41 | #endif 42 | inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS); 43 | } 44 | 45 | 46 | 47 | #endif // UNITY_BUILD_INTPUT_DATA_INCLUDED 48 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/BuildInputData.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f637b3efb6ea74246972537a6093d19e 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/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 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/DepthOnlyPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ed77c58e33c9e94caf637109850d649 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/LegacyBuilding.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_LEGACY_BUILDING_INCLUDED 2 | #define UNITY_LEGACY_BUILDING_INCLUDED 3 | 4 | #include "Packages/com.z3y.shadergraph-builtin/CustomLighting/Core.cginc" 5 | #include "Packages/com.z3y.shadergraph-builtin/ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/SurfaceData.hlsl" 6 | 7 | 8 | SurfaceData SurfaceDescriptionToSurfaceData(SurfaceDescription surfaceDescription) 9 | { 10 | #if _AlphaClip 11 | half alpha = surfaceDescription.Alpha; 12 | #if defined(UNITY_PASS_SHADOWCASTER) || !defined(PREDEFINED_A2C) 13 | // clip(alpha - surfaceDescription.AlphaClipThreshold); 14 | #else 15 | // alpha = (alpha - surfaceDescription.AlphaClipThreshold) / max(fwidth(alpha), 0.0001) + 0.5; 16 | #endif 17 | #elif _SURFACE_TYPE_TRANSPARENT 18 | half alpha = surfaceDescription.Alpha; 19 | #else 20 | half alpha = 1; 21 | #endif 22 | 23 | #ifdef _SPECULAR_SETUP 24 | float3 specular = surfaceDescription.Specular; 25 | float metallic = 1; 26 | #else 27 | float3 specular = 0; 28 | float metallic = surfaceDescription.Metallic; 29 | #endif 30 | 31 | SurfaceData surface = (SurfaceData)0; 32 | surface.albedo = surfaceDescription.BaseColor; 33 | surface.metallic = saturate(metallic); 34 | surface.specular = specular; 35 | surface.smoothness = saturate(surfaceDescription.Smoothness), 36 | surface.occlusion = surfaceDescription.Occlusion, 37 | surface.emission = surfaceDescription.Emission, 38 | surface.alpha = saturate(alpha); 39 | surface.clearCoatMask = 0; 40 | surface.clearCoatSmoothness = 1; 41 | return surface; 42 | } 43 | 44 | SurfaceOutputStandard BuildStandardSurfaceOutput(SurfaceDescription surfaceDescription, InputData inputData) 45 | { 46 | SurfaceData surface = SurfaceDescriptionToSurfaceData(surfaceDescription); 47 | 48 | SurfaceOutputStandard o = (SurfaceOutputStandard)0; 49 | o.Albedo = surface.albedo; 50 | o.Normal = inputData.normalWS; 51 | o.Metallic = surface.metallic; 52 | o.Smoothness = surface.smoothness; 53 | o.Occlusion = surface.occlusion; 54 | o.Emission = surface.emission; 55 | o.Alpha = surface.alpha; 56 | return o; 57 | } 58 | 59 | 60 | #endif // UNITY_LEGACY_BUILDING_INCLUDED 61 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/LegacyBuilding.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 383033b21e4cf0447a6901d3ffea9a18 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/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 defined(VERTEXLIGHT_ON) && !defined(LIGHTMAP_ON) && !defined(VERTEXLIGHT_PS) 11 | half3 sh;// vertex light 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 | #ifdef UNITY_PASS_META 18 | float4 tSpace0 : TEXCOORD6; 19 | float4 tSpace1 : TEXCOORD7; 20 | float4 tSpace2 : TEXCOORD8; 21 | #endif 22 | UNITY_VERTEX_INPUT_INSTANCE_ID 23 | UNITY_VERTEX_OUTPUT_STEREO 24 | }; 25 | 26 | #endif // UNITY_LEGACY_SURFACE_VERTEX 27 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/LegacySurfaceVertex.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4694b29d830896840bc60a50440ab941 3 | ShaderIncludeImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/LightingMetaPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 960d0ab5d107b75479fd1e7d606c506e 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/PBRDeferredPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 45e01e79ea258bb47b49afa57b4647ba 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/PBRForwardAddPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7126de643fe157c4f8d288a5a4f78431 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/PBRForwardPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 93e91967365c4ab47aa9b62e6ed92189 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/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 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/PBRGBufferPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 258218da82599ee4b94a6a4cab84c16c 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/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 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/ShaderPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 393c5a9e7110e7b4a8e265f7a82afef2 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/ShadowCasterPass.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef SG_SHADOW_PASS_INCLUDED 2 | #define SG_SHADOW_PASS_INCLUDED 3 | 4 | #include "Packages/com.z3y.shadergraph-builtin/CustomLighting/Core.cginc" 5 | 6 | v2f_surf ShadowCasterVertex(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 | 14 | #ifdef RALIV_PENETRATOR 15 | PenetratorReshape(v.vertex, v.normal); 16 | #endif 17 | #ifdef RALIV_ORIFICE 18 | OrificeReshape(v.vertex, v.normal, v.tangent, v.vertexId); 19 | #endif 20 | 21 | float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; 22 | float3 worldNormal = UnityObjectToWorldNormal(v.normal); 23 | o.worldPos.xyz = worldPos; 24 | TRANSFER_SHADOW_CASTER_NORMALOFFSET(o) 25 | return o; 26 | } 27 | 28 | void ShadowCasterVertex(Attributes input, VertexDescription vertexDescription, inout Varyings varyings) 29 | { 30 | appdata_full v; 31 | ZERO_INITIALIZE(appdata_full, v); 32 | BuildAppDataFull(input, vertexDescription, v); 33 | 34 | #if UNITY_ANY_INSTANCING_ENABLED 35 | v.instanceID = input.instanceID; 36 | #endif 37 | 38 | v2f_surf o = ShadowCasterVertex(v); 39 | 40 | #if UNITY_ANY_INSTANCING_ENABLED 41 | varyings.instanceID = o.instanceID; 42 | #endif 43 | SurfaceVertexToVaryings(o, varyings); 44 | } 45 | 46 | half4 ShadowCasterFragment(v2f_surf IN) 47 | { 48 | UNITY_SETUP_INSTANCE_ID(IN); 49 | #ifdef FOG_COMBINED_WITH_TSPACE 50 | UNITY_EXTRACT_FOG_FROM_TSPACE(IN); 51 | #elif defined FOG_COMBINED_WITH_WORLD_POS 52 | UNITY_EXTRACT_FOG_FROM_WORLD_POS(IN); 53 | #else 54 | UNITY_EXTRACT_FOG(IN); 55 | #endif 56 | float3 worldPos = IN.worldPos.xyz; 57 | #ifndef USING_DIRECTIONAL_LIGHT 58 | fixed3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos)); 59 | #else 60 | fixed3 lightDir = _WorldSpaceLightPos0.xyz; 61 | #endif 62 | fixed3 normalWorldVertex = fixed3(0,0,1); 63 | 64 | SHADOW_CASTER_FRAGMENT(IN) 65 | } 66 | 67 | half4 ShadowCasterFragment(SurfaceDescription surfaceDescription, Varyings varyings) 68 | { 69 | v2f_surf vertexSurf; 70 | ZERO_INITIALIZE(v2f_surf, vertexSurf); 71 | #if UNITY_ANY_INSTANCING_ENABLED 72 | vertexSurf.instanceID = varyings.instanceID; 73 | #endif 74 | VaryingsToSurfaceVertex(varyings, vertexSurf); 75 | 76 | //return ShadowCasterFragment(vertexSurf); 77 | SurfaceDataCustom surf; 78 | InitializeDefaultSurfaceData(surf); 79 | // CopyStandardToCustomSurfaceData(surf, o); 80 | #ifdef _BUILTIN_AlphaClip 81 | surf.alphaClipThreshold = surfaceDescription.AlphaClipThreshold; 82 | #endif 83 | #if defined(_BUILTIN_SURFACE_TYPE_TRANSPARENT) || defined(_BUILTIN_AlphaClip) 84 | surf.alpha = surfaceDescription.Alpha; 85 | #endif 86 | 87 | return CustomLightingFrag(vertexSurf, surf); 88 | } 89 | 90 | PackedVaryings vert(Attributes input) 91 | { 92 | Varyings output; 93 | ZERO_INITIALIZE(Varyings, output); 94 | output = BuildVaryings(input); 95 | 96 | VertexDescriptionInputs vertexDescriptionInputs = BuildVertexDescriptionInputs(input); 97 | VertexDescription vertexDescription = VertexDescriptionFunction(vertexDescriptionInputs); 98 | ShadowCasterVertex(input, vertexDescription, output); 99 | 100 | PackedVaryings packedOutput = (PackedVaryings)0; 101 | packedOutput = PackVaryings(output); 102 | return packedOutput; 103 | } 104 | 105 | half4 frag(PackedVaryings packedInput) : SV_TARGET 106 | { 107 | Varyings unpacked = UnpackVaryings(packedInput); 108 | UNITY_SETUP_INSTANCE_ID(unpacked); 109 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 110 | 111 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 112 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 113 | 114 | // #if _AlphaClip 115 | // half alpha = surfaceDescription.Alpha; 116 | // clip(alpha - surfaceDescription.AlphaClipThreshold); 117 | // #endif 118 | 119 | half4 color = ShadowCasterFragment(surfaceDescription, unpacked); 120 | return color; 121 | } 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/ShadowCasterPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c138016131157e42968660ab769ce21 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/SpriteForwardPass.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 | #ifdef BUILTIN_USELEGACYSPRITEBLOCKS 19 | half4 color = surfaceDescription.SpriteColor; 20 | #else 21 | half4 color = half4(surfaceDescription.BaseColor, surfaceDescription.Alpha); 22 | #endif 23 | 24 | color *= unpacked.color; 25 | return color; 26 | } 27 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/SpriteForwardPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d443fe02e8f1be498306b0910a84c8a 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/SpriteLitPass.hlsl: -------------------------------------------------------------------------------- 1 | #if USE_SHAPE_LIGHT_TYPE_0 2 | SHAPE_LIGHT(0) 3 | #endif 4 | 5 | #if USE_SHAPE_LIGHT_TYPE_1 6 | SHAPE_LIGHT(1) 7 | #endif 8 | 9 | #if USE_SHAPE_LIGHT_TYPE_2 10 | SHAPE_LIGHT(2) 11 | #endif 12 | 13 | #if USE_SHAPE_LIGHT_TYPE_3 14 | SHAPE_LIGHT(3) 15 | #endif 16 | 17 | #include "Packages/com.z3y.shadergraph-builtin/ShaderGraph/Editor/Generation/Targets/BuiltIn/Shaders/2D/Include/CombinedShapeLightShared.hlsl" 18 | 19 | PackedVaryings vert(Attributes input) 20 | { 21 | Varyings output = (Varyings)0; 22 | output = BuildVaryings(input); 23 | PackedVaryings packedOutput = PackVaryings(output); 24 | return packedOutput; 25 | } 26 | 27 | half4 frag(PackedVaryings packedInput) : SV_TARGET 28 | { 29 | Varyings unpacked = UnpackVaryings(packedInput); 30 | UNITY_SETUP_INSTANCE_ID(unpacked); 31 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 32 | 33 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 34 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 35 | 36 | #ifdef BUILTIN_USELEGACYSPRITEBLOCKS 37 | half4 color = surfaceDescription.SpriteColor; 38 | #else 39 | half4 color = half4(surfaceDescription.BaseColor, surfaceDescription.Alpha); 40 | #endif 41 | 42 | color *= unpacked.color; 43 | return CombinedShapeLightShared(color, surfaceDescription.SpriteMask, unpacked.screenPosition.xy / unpacked.screenPosition.w); 44 | } 45 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/SpriteLitPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5225925f8f164da419959081ec47ebb1 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/SpriteNormalPass.hlsl: -------------------------------------------------------------------------------- 1 | PackedVaryings vert(Attributes input) 2 | { 3 | Varyings output = (Varyings)0; 4 | output = BuildVaryings(input); 5 | output.normalWS = -GetViewForwardDir(); 6 | PackedVaryings packedOutput = PackVaryings(output); 7 | return packedOutput; 8 | } 9 | 10 | half4 frag(PackedVaryings packedInput) : SV_TARGET 11 | { 12 | Varyings unpacked = UnpackVaryings(packedInput); 13 | UNITY_SETUP_INSTANCE_ID(unpacked); 14 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 15 | 16 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 17 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 18 | 19 | half crossSign = (unpacked.tangentWS.w > 0.0 ? 1.0 : -1.0) * GetOddNegativeScale(); 20 | half3 bitangent = crossSign * cross(unpacked.normalWS.xyz, unpacked.tangentWS.xyz); 21 | 22 | #ifdef BUILTIN_USELEGACYSPRITEBLOCKS 23 | half4 color = surfaceDescription.SpriteColor; 24 | #else 25 | half4 color = half4(surfaceDescription.BaseColor, surfaceDescription.Alpha); 26 | #endif 27 | 28 | return NormalsRenderingShared(color, surfaceDescription.NormalTS, unpacked.tangentWS.xyz, bitangent, unpacked.normalWS); 29 | } 30 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/SpriteNormalPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 741621c95d92c754faf0d042e9b69068 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/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 | PackedVaryings packedOutput = PackVaryings(output); 8 | return packedOutput; 9 | } 10 | 11 | half4 frag(PackedVaryings packedInput) : SV_TARGET 12 | { 13 | Varyings unpacked = UnpackVaryings(packedInput); 14 | UNITY_SETUP_INSTANCE_ID(unpacked); 15 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked); 16 | 17 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 18 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 19 | 20 | #ifdef BUILTIN_USELEGACYSPRITEBLOCKS 21 | half4 color = surfaceDescription.SpriteColor; 22 | #else 23 | half4 color = half4(surfaceDescription.BaseColor, surfaceDescription.Alpha); 24 | #endif 25 | 26 | color *= unpacked.color * _RendererColor; 27 | return color; 28 | } 29 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/SpriteUnlitPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f50524540fd4c99498d1297fbe7a65b2 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/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 _BUILTIN_AlphaClip 19 | half alpha = surfaceDescription.Alpha; 20 | 21 | #if defined(UNITY_PASS_SHADOWCASTER) || !defined(PREDEFINED_A2C) 22 | clip(alpha - surfaceDescription.AlphaClipThreshold); 23 | #else 24 | alpha = (alpha - surfaceDescription.AlphaClipThreshold) / max(fwidth(alpha), 0.0001) + 0.5; 25 | #endif 26 | 27 | #elif _SURFACE_TYPE_TRANSPARENT 28 | half alpha = surfaceDescription.Alpha; 29 | #else 30 | half alpha = 1; 31 | #endif 32 | 33 | #ifdef _ALPHAPREMULTIPLY_ON 34 | surfaceDescription.BaseColor *= alpha; 35 | #endif 36 | 37 | return half4(surfaceDescription.BaseColor, alpha); 38 | } 39 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/UnlitPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 26726bc0bb91d46409a5e192c330c05a 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/Varyings.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: af819230fb757ff48982e9f4c1b5a049 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc2fd86f35a5f0943af68dc217c54485 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/AdditionalFunctions.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef ADDITIONALFUNCTIONS_INCLUDED 2 | #define ADDITIONALFUNCTIONS_INCLUDED 3 | 4 | 5 | half3 GetF0(half metallic, half3 albedo) 6 | { 7 | half reflectance = 0.5; 8 | return 0.16 * reflectance * reflectance * (1.0 - metallic) + albedo * metallic; 9 | } 10 | 11 | float3 getBoxProjection (float3 direction, float3 position, float4 cubemapPosition, float3 boxMin, float3 boxMax) 12 | { 13 | #if defined(UNITY_SPECCUBE_BOX_PROJECTION) || defined(FORCE_SPECCUBE_BOX_PROJECTION) 14 | UNITY_FLATTEN 15 | if (cubemapPosition.w > 0.0) 16 | { 17 | float3 factors = ((direction > 0.0 ? boxMax : boxMin) - position) / direction; 18 | float scalar = min(min(factors.x, factors.y), factors.z); 19 | direction = direction * scalar + (position - cubemapPosition.xyz); 20 | } 21 | #endif 22 | 23 | return direction; 24 | } 25 | 26 | half computeSpecularAO(half NoV, half ao, half roughness) 27 | { 28 | return clamp(pow(NoV + ao, exp2(-16.0 * roughness - 1.0)) - 1.0 + ao, 0.0, 1.0); 29 | } 30 | 31 | Texture2D _DFG; 32 | SamplerState sampler_DFG; 33 | 34 | half4 SampleDFG(half NoV, half perceptualRoughness) 35 | { 36 | return _DFG.Sample(sampler_DFG, float3(NoV, perceptualRoughness, 0)); 37 | } 38 | half3 EnvBRDF(half2 dfg, half3 f0) 39 | { 40 | return f0 * dfg.x + dfg.y; 41 | } 42 | half3 EnvBRDFMultiscatter(half2 dfg, half3 f0) 43 | { 44 | return lerp(dfg.xxx, dfg.yyy, f0); 45 | } 46 | half3 EnvBRDFEnergyCompensation(half2 dfg, half3 f0) 47 | { 48 | return 1.0 + f0 * (1.0 / dfg.y - 1.0); 49 | } 50 | 51 | half3 EnvBRDFApprox(half perceptualRoughness, half NoV, half3 f0) 52 | { 53 | // original code from https://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf 54 | half g = 1 - perceptualRoughness; 55 | half4 t = half4(1 / 0.96, 0.475, (0.0275 - 0.25 * 0.04) / 0.96, 0.25); 56 | t *= half4(g, g, g, g); 57 | t += half4(0.0, 0.0, (0.015 - 0.75 * 0.04) / 0.96, 0.75); 58 | half a0 = t.x * min(t.y, exp2(-9.28 * NoV)) + t.z; 59 | half a1 = t.w; 60 | return saturate(lerp(a0, a1, f0)); 61 | } 62 | 63 | half3 GetReflections(float3 normalWS, float3 positionWS, float3 viewDir, half3 f0, half roughness, half NoV, half3 indirectDiffuse, half occlusion) 64 | { 65 | half3 indirectSpecular = 0; 66 | #if defined(UNITY_PASS_FORWARDBASE) 67 | 68 | float3 reflDir = reflect(-viewDir, normalWS); 69 | #ifndef SHADER_API_MOBILE 70 | reflDir = lerp(reflDir, normalWS, roughness * roughness); 71 | #endif 72 | 73 | half perceptualRoughness = sqrt(roughness); 74 | Unity_GlossyEnvironmentData envData; 75 | envData.roughness = perceptualRoughness; 76 | envData.reflUVW = getBoxProjection(reflDir, positionWS, unity_SpecCube0_ProbePosition, unity_SpecCube0_BoxMin.xyz, unity_SpecCube0_BoxMax.xyz); 77 | 78 | half3 probe0 = Unity_GlossyEnvironment(UNITY_PASS_TEXCUBE(unity_SpecCube0), unity_SpecCube0_HDR, envData); 79 | indirectSpecular = probe0; 80 | 81 | #if defined(UNITY_SPECCUBE_BLENDING) && !defined(SHADER_API_MOBILE) 82 | UNITY_BRANCH 83 | if (unity_SpecCube0_BoxMin.w < 0.99999) 84 | { 85 | envData.reflUVW = getBoxProjection(reflDir, positionWS, unity_SpecCube1_ProbePosition, unity_SpecCube1_BoxMin.xyz, unity_SpecCube1_BoxMax.xyz); 86 | float3 probe1 = Unity_GlossyEnvironment(UNITY_PASS_TEXCUBE_SAMPLER(unity_SpecCube1, unity_SpecCube0), unity_SpecCube1_HDR, envData); 87 | indirectSpecular = lerp(probe1, probe0, unity_SpecCube0_BoxMin.w); 88 | } 89 | #endif 90 | 91 | float horizon = min(1.0 + dot(reflDir, normalWS), 1.0); 92 | indirectSpecular *= horizon * horizon; 93 | 94 | #ifdef USE_SPECULAR_OCCLUSION 95 | half lightmapOcclusion = lerp(1.0, saturate(dot(indirectDiffuse, 1.0)), _SpecularOcclusion); 96 | 97 | #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON) 98 | occlusion *= lightmapOcclusion; 99 | #endif 100 | #endif 101 | 102 | 103 | indirectSpecular *= computeSpecularAO(NoV, occlusion, perceptualRoughness * perceptualRoughness); 104 | 105 | #endif 106 | 107 | return indirectSpecular; 108 | } 109 | 110 | 111 | #endif -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/AdditionalFunctions.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b1d0ff940eadc54b91ecd797299a511 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Bakery.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef BAKERY_INCLUDED 2 | #define BAKERY_INCLUDED 3 | 4 | Texture2D _RNM0, _RNM1, _RNM2; 5 | float4 _RNM0_TexelSize; 6 | 7 | SamplerState bakery_bilinear_clamp_sampler; 8 | 9 | #if !defined(SHADER_API_MOBILE) 10 | #define BAKERY_SHNONLINEAR 11 | #endif 12 | 13 | #ifdef BAKERY_SHNONLINEAR_OFF 14 | #undef BAKERY_SHNONLINEAR 15 | #endif 16 | 17 | float shEvaluateDiffuseL1Geomerics(float L0, float3 L1, float3 n) 18 | { 19 | // average energy 20 | float R0 = L0; 21 | 22 | // avg direction of incoming light 23 | float3 R1 = 0.5f * L1; 24 | 25 | // directional brightness 26 | float lenR1 = length(R1); 27 | 28 | // linear angle between normal and direction 0-1 29 | //float q = 0.5f * (1.0f + dot(R1 / lenR1, n)); 30 | //float q = dot(R1 / lenR1, n) * 0.5 + 0.5; 31 | float q = dot(normalize(R1), n) * 0.5 + 0.5; 32 | q = saturate(q); // Thanks to ScruffyRuffles for the bug identity. 33 | 34 | // power for q 35 | // lerps from 1 (linear) to 3 (cubic) based on directionality 36 | float p = 1.0f + 2.0f * lenR1 / R0; 37 | 38 | // dynamic range constant 39 | // should vary between 4 (highly directional) and 0 (ambient) 40 | float a = (1.0f - lenR1 / R0) / (1.0f + lenR1 / R0); 41 | 42 | return R0 * (a + (1.0f - a) * (p + 1.0f) * pow(q, p)); 43 | } 44 | 45 | 46 | void BakerySHLightmapAndSpecular(inout half3 lightMap, float2 lightmapUV, inout half3 directSpecular, float3 normalWS, float3 viewDir, half roughness) 47 | { 48 | #ifdef BAKERY_SH 49 | 50 | half3 L0 = lightMap; 51 | float3 nL1x = _RNM0.Sample(bakery_bilinear_clamp_sampler, lightmapUV).rgb * 2.0 - 1.0; 52 | float3 nL1y = _RNM1.Sample(bakery_bilinear_clamp_sampler, lightmapUV).rgb * 2.0 - 1.0; 53 | float3 nL1z = _RNM2.Sample(bakery_bilinear_clamp_sampler, lightmapUV).rgb * 2.0 - 1.0; 54 | float3 L1x = nL1x * L0 * 2.0; 55 | float3 L1y = nL1y * L0 * 2.0; 56 | float3 L1z = nL1z * L0 * 2.0; 57 | 58 | #ifdef BAKERY_SHNONLINEAR 59 | float lumaL0 = dot(L0, float(1)); 60 | float lumaL1x = dot(L1x, float(1)); 61 | float lumaL1y = dot(L1y, float(1)); 62 | float lumaL1z = dot(L1z, float(1)); 63 | float lumaSH = shEvaluateDiffuseL1Geomerics(lumaL0, float3(lumaL1x, lumaL1y, lumaL1z), normalWS); 64 | 65 | lightMap = L0 + normalWS.x * L1x + normalWS.y * L1y + normalWS.z * L1z; 66 | float regularLumaSH = dot(lightMap, 1.0); 67 | lightMap *= lerp(1.0, lumaSH / regularLumaSH, saturate(regularLumaSH * 16.0)); 68 | #else 69 | lightMap = L0 + normalWS.x * L1x + normalWS.y * L1y + normalWS.z * L1z; 70 | #endif 71 | 72 | #ifdef _LIGHTMAPPED_SPECULAR 73 | float3 grayScaleVec = float3(0.2125, 0.7154, 0.0721); 74 | float3 dominantDir = float3(dot(nL1x, grayScaleVec), dot(nL1y, grayScaleVec), dot(nL1z, grayScaleVec)); 75 | float3 halfDir = Unity_SafeNormalize(normalize(dominantDir) + viewDir); 76 | half NoH = saturate(dot(normalWS, halfDir)); 77 | half spec = D_GGX(NoH, roughness); 78 | half3 sh = L0 + dominantDir.x * L1x + dominantDir.y * L1y + dominantDir.z * L1z; 79 | dominantDir = normalize(dominantDir); 80 | 81 | directSpecular += max(spec * sh, 0.0); 82 | #endif 83 | 84 | #endif 85 | } 86 | 87 | 88 | #endif -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Bakery.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6596685d57a9e9645adb749877cbbe83 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/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 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/BuiltInDOTSInstancing.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1590b42a6c38a6d4a907fe3eba8b01fc 3 | timeCreated: 1580903876 -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Core.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bca629ff9b2ec5a4d90a499bb7be3ebf 3 | timeCreated: 1488965025 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/DeclareDepthTexture.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_DECLARE_DEPTH_TEXTURE_INCLUDED 2 | #define UNITY_DECLARE_DEPTH_TEXTURE_INCLUDED 3 | #include "Packages/com.z3y.shadergraph-builtin/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 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/DeclareDepthTexture.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc35a2179bd3983409710ae52492b554 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/DeclareNormalsTexture.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_DECLARE_NORMALS_TEXTURE_INCLUDED 2 | #define UNITY_DECLARE_NORMALS_TEXTURE_INCLUDED 3 | #include "Packages/com.z3y.shadergraph-builtin/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 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/DeclareNormalsTexture.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 110369e5049ace54dbdb9afa3b53f144 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/DeclareOpaqueTexture.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_DECLARE_OPAQUE_TEXTURE_INCLUDED 2 | #define UNITY_DECLARE_OPAQUE_TEXTURE_INCLUDED 3 | #include "Packages/com.z3y.shadergraph-builtin/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 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/DeclareOpaqueTexture.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37dd556fb2ca759468fdddbd02550aed 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Deprecated.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef BUILTIN_DEPRECATED_INCLUDED 2 | #define BUILTIN_DEPRECATED_INCLUDED 3 | 4 | // Stereo-related bits 5 | #define SCREENSPACE_TEXTURE TEXTURE2D_X 6 | #define SCREENSPACE_TEXTURE_FLOAT TEXTURE2D_X_FLOAT 7 | #define SCREENSPACE_TEXTURE_HALF TEXTURE2D_X_HALF 8 | 9 | // Typo-fixes, re-route to new name for backwards compatiblity (if there are external dependencies). 10 | #define kDieletricSpec kDielectricSpec 11 | #define DirectBDRF DirectBRDF 12 | 13 | // Deprecated: not using consistent naming convention 14 | #if defined(USING_STEREO_MATRICES) 15 | #define unity_StereoMatrixIP unity_StereoMatrixInvP 16 | #define unity_StereoMatrixIVP unity_StereoMatrixInvVP 17 | #endif 18 | 19 | // Previously used when rendering with DrawObjectsPass. 20 | // Global object render pass data containing various settings. 21 | // x,y,z are currently unused 22 | // w is used for knowing whether the object is opaque(1) or alpha blended(0) 23 | half4 _DrawObjectPassData; 24 | 25 | #if USE_STRUCTURED_BUFFER_FOR_LIGHT_DATA 26 | // _AdditionalShadowsIndices was deprecated - To get the first shadow slice index for a light, use GetAdditionalLightShadowParams(lightIndex).w [see Shadows.hlsl] 27 | #define _AdditionalShadowsIndices _AdditionalShadowParams_SSBO 28 | // _AdditionalShadowsBuffer was deprecated - To access a shadow slice's matrix, use _AdditionalLightsWorldToShadow_SSBO[shadowSliceIndex] - To access other shadow parameters, use GetAdditionalLightShadowParams(int lightIndex) [see Shadows.hlsl] 29 | #define _AdditionalShadowsBuffer _AdditionalLightsWorldToShadow_SSBO 30 | #endif 31 | 32 | // Deprecated: even when USE_STRUCTURED_BUFFER_FOR_LIGHT_DATA is defined we do not this structure anymore, because worldToShadowMatrix and shadowParams must be stored in arrays of different sizes 33 | // To get the first shadow slice index for a light, use GetAdditionalLightShadowParams(lightIndex).w [see Shadows.hlsl] 34 | // To access other shadow parameters, use GetAdditionalLightShadowParams(int lightIndex)[see Shadows.hlsl] 35 | struct ShadowData 36 | { 37 | float4x4 worldToShadowMatrix; // per-shadow-slice 38 | float4 shadowParams; // per-casting-light 39 | }; 40 | 41 | #endif // BUILTIN_DEPRECATED_INCLUDED 42 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Deprecated.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a31a4c75e259a4c43956047799b896be 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Input.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef BUILTIN_INPUT_INCLUDED 2 | #define BUILTIN_INPUT_INCLUDED 3 | 4 | #define MAX_VISIBLE_LIGHTS_UBO 32 5 | #define MAX_VISIBLE_LIGHTS_SSBO 256 6 | 7 | // Keep in sync with RenderingUtils.useStructuredBuffer 8 | #define USE_STRUCTURED_BUFFER_FOR_LIGHT_DATA 0 9 | 10 | #include "Packages/com.z3y.shadergraph-builtin/ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/ShaderTypes.cs.hlsl" 11 | #include "Packages/com.z3y.shadergraph-builtin/ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Deprecated.hlsl" 12 | 13 | #if defined(SHADER_API_MOBILE) && (defined(SHADER_API_GLES) || defined(SHADER_API_GLES30)) 14 | #define MAX_VISIBLE_LIGHTS 16 15 | #elif defined(SHADER_API_MOBILE) || (defined(SHADER_API_GLCORE) && !defined(SHADER_API_SWITCH)) || defined(SHADER_API_GLES) || defined(SHADER_API_GLES3) // Workaround because SHADER_API_GLCORE is also defined when SHADER_API_SWITCH is 16 | #define MAX_VISIBLE_LIGHTS 32 17 | #else 18 | #define MAX_VISIBLE_LIGHTS 256 19 | #endif 20 | 21 | struct InputData 22 | { 23 | float3 positionWS; 24 | half3 normalWS; 25 | half3 viewDirectionWS; 26 | float4 shadowCoord; 27 | half fogCoord; 28 | half3 vertexLighting; 29 | half3 bakedGI; 30 | float2 normalizedScreenSpaceUV; 31 | half4 shadowMask; 32 | }; 33 | 34 | /////////////////////////////////////////////////////////////////////////////// 35 | // Constant Buffers // 36 | /////////////////////////////////////////////////////////////////////////////// 37 | 38 | half4 _GlossyEnvironmentColor; 39 | half4 _SubtractiveShadowColor; 40 | 41 | #define _InvCameraViewProj unity_MatrixInvVP 42 | float4 _ScaledScreenParams; 43 | 44 | float4 _MainLightPosition; 45 | half4 _MainLightColor; 46 | half4 _MainLightOcclusionProbes; 47 | 48 | // xyz are currently unused 49 | // w: directLightStrength 50 | half4 _AmbientOcclusionParam; 51 | 52 | half4 _AdditionalLightsCount; 53 | 54 | #if USE_STRUCTURED_BUFFER_FOR_LIGHT_DATA 55 | StructuredBuffer _AdditionalLightsBuffer; 56 | StructuredBuffer _AdditionalLightsIndices; 57 | #else 58 | // GLES3 causes a performance regression in some devices when using CBUFFER. 59 | #ifndef SHADER_API_GLES3 60 | CBUFFER_START(AdditionalLights) 61 | #endif 62 | float4 _AdditionalLightsPosition[MAX_VISIBLE_LIGHTS]; 63 | half4 _AdditionalLightsColor[MAX_VISIBLE_LIGHTS]; 64 | half4 _AdditionalLightsAttenuation[MAX_VISIBLE_LIGHTS]; 65 | half4 _AdditionalLightsSpotDir[MAX_VISIBLE_LIGHTS]; 66 | half4 _AdditionalLightsOcclusionProbes[MAX_VISIBLE_LIGHTS]; 67 | #ifndef SHADER_API_GLES3 68 | CBUFFER_END 69 | #endif 70 | #endif 71 | 72 | // Duplicate defined symbols in built-in target 73 | #ifndef BUILTIN_TARGET_API 74 | #define UNITY_MATRIX_M unity_ObjectToWorld 75 | #define UNITY_MATRIX_I_M unity_WorldToObject 76 | #define UNITY_MATRIX_V unity_MatrixV 77 | #define UNITY_MATRIX_I_V unity_MatrixInvV 78 | #define UNITY_MATRIX_P OptimizeProjectionMatrix(glstate_matrix_projection) 79 | #define UNITY_MATRIX_I_P (float4x4)0 80 | #define UNITY_MATRIX_VP unity_MatrixVP 81 | #define UNITY_MATRIX_I_VP (float4x4)0 82 | #define UNITY_MATRIX_MV mul(UNITY_MATRIX_V, UNITY_MATRIX_M) 83 | #define UNITY_MATRIX_T_MV transpose(UNITY_MATRIX_MV) 84 | #define UNITY_MATRIX_IT_MV transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V)) 85 | #define UNITY_MATRIX_MVP mul(UNITY_MATRIX_VP, UNITY_MATRIX_M) 86 | #define UNITY_PREV_MATRIX_M unity_MatrixPreviousM 87 | #define UNITY_PREV_MATRIX_I_M unity_MatrixPreviousMI 88 | #else 89 | // Not defined already by built-in 90 | #define UNITY_MATRIX_I_M unity_WorldToObject 91 | #define UNITY_MATRIX_I_P (float4x4)0 92 | #define UNITY_MATRIX_I_VP (float4x4)0 93 | #define UNITY_PREV_MATRIX_M (float4x4)0 94 | #define UNITY_PREV_MATRIX_I_M (float4x4)0 95 | #endif 96 | 97 | 98 | 99 | // Note: #include order is important here. 100 | // UnityInput.hlsl must be included before UnityInstancing.hlsl, so constant buffer 101 | // declarations don't fail because of instancing macros. 102 | // BuiltInDOTSInstancing.hlsl must be included after UnityInstancing.hlsl 103 | #include "Packages/com.z3y.shadergraph-builtin/ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/UnityInput.hlsl" 104 | #include "Packages/com.z3y.shadergraph-builtin/CoreRP/ShaderLibrary/UnityInstancing.hlsl" 105 | #include "Packages/com.z3y.shadergraph-builtin/ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/BuiltInDOTSInstancing.hlsl" 106 | #include "Packages/com.z3y.shadergraph-builtin/CoreRP/ShaderLibrary/SpaceTransforms.hlsl" 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Input.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d5634f9e4d0cb9f42a75246e38dcdccb 3 | timeCreated: 1488965025 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Lighting.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b79c76fdd7c489242bb3fe68f217c2b4 3 | timeCreated: 1488965025 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/MetaInput.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef BUILTIN_META_PASS_INCLUDED 2 | #define BUILTIN_META_PASS_INCLUDED 3 | 4 | #include "Packages/com.z3y.shadergraph-builtin/ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Lighting.hlsl" 5 | #include "Packages/com.z3y.shadergraph-builtin/CoreRP/ShaderLibrary/Color.hlsl" 6 | 7 | CBUFFER_START(UnityMetaPass) 8 | // x = use uv1 as raster position 9 | // y = use uv2 as raster position 10 | bool4 unity_MetaVertexControl; 11 | 12 | // x = return albedo 13 | // y = return normal 14 | bool4 unity_MetaFragmentControl; 15 | CBUFFER_END 16 | 17 | float unity_OneOverOutputBoost; 18 | float unity_MaxOutputValue; 19 | float unity_UseLinearSpace; 20 | 21 | struct MetaInput 22 | { 23 | half3 Albedo; 24 | half3 Emission; 25 | half3 SpecularColor; 26 | }; 27 | 28 | float4 MetaVertexPosition(float4 positionOS, float2 uv1, float2 uv2, float4 uv1ST, float4 uv2ST) 29 | { 30 | if (unity_MetaVertexControl.x) 31 | { 32 | positionOS.xy = uv1 * uv1ST.xy + uv1ST.zw; 33 | // OpenGL right now needs to actually use incoming vertex position, 34 | // so use it in a very dummy way 35 | positionOS.z = positionOS.z > 0 ? REAL_MIN : 0.0f; 36 | } 37 | if (unity_MetaVertexControl.y) 38 | { 39 | positionOS.xy = uv2 * uv2ST.xy + uv2ST.zw; 40 | // OpenGL right now needs to actually use incoming vertex position, 41 | // so use it in a very dummy way 42 | positionOS.z = positionOS.z > 0 ? REAL_MIN : 0.0f; 43 | } 44 | return TransformWorldToHClip(positionOS.xyz); 45 | } 46 | 47 | half4 MetaFragment(MetaInput input) 48 | { 49 | half4 res = 0; 50 | if (unity_MetaFragmentControl.x) 51 | { 52 | res = half4(input.Albedo, 1.0); 53 | 54 | // Apply Albedo Boost from LightmapSettings. 55 | res.rgb = clamp(PositivePow(res.rgb, saturate(unity_OneOverOutputBoost)), 0, unity_MaxOutputValue); 56 | } 57 | if (unity_MetaFragmentControl.y) 58 | { 59 | half3 emission; 60 | if (unity_UseLinearSpace) 61 | emission = input.Emission; 62 | else 63 | emission = LinearToSRGB(input.Emission); 64 | 65 | res = half4(emission, 1.0); 66 | } 67 | return res; 68 | } 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/MetaInput.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 13df0e1b4a6da1f49aab4b1c5144b5f9 3 | timeCreated: 1488965025 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Particles.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 60a299efbdf80274198d7d2cfce2e115 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/ParticlesInstancing.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef BUILTIN_PARTICLESINSTANCING_INCLUDED 2 | #define BUILTIN_PARTICLESINSTANCING_INCLUDED 3 | 4 | #if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED) && !defined(SHADER_TARGET_SURFACE_ANALYSIS) 5 | #define UNITY_PARTICLE_INSTANCING_ENABLED 6 | #endif 7 | 8 | #if defined(UNITY_PARTICLE_INSTANCING_ENABLED) 9 | 10 | #ifndef UNITY_PARTICLE_INSTANCE_DATA 11 | #define UNITY_PARTICLE_INSTANCE_DATA DefaultParticleInstanceData 12 | #endif 13 | 14 | struct DefaultParticleInstanceData 15 | { 16 | float3x4 transform; 17 | uint color; 18 | float animFrame; 19 | }; 20 | 21 | StructuredBuffer unity_ParticleInstanceData; 22 | float4 unity_ParticleUVShiftData; 23 | float unity_ParticleUseMeshColors; 24 | 25 | void ParticleInstancingMatrices(out float4x4 objectToWorld, out float4x4 worldToObject) 26 | { 27 | UNITY_PARTICLE_INSTANCE_DATA data = unity_ParticleInstanceData[unity_InstanceID]; 28 | 29 | // transform matrix 30 | objectToWorld._11_21_31_41 = float4(data.transform._11_21_31, 0.0f); 31 | objectToWorld._12_22_32_42 = float4(data.transform._12_22_32, 0.0f); 32 | objectToWorld._13_23_33_43 = float4(data.transform._13_23_33, 0.0f); 33 | objectToWorld._14_24_34_44 = float4(data.transform._14_24_34, 1.0f); 34 | 35 | // inverse transform matrix (TODO: replace with a library implementation if/when available) 36 | float3x3 worldToObject3x3; 37 | worldToObject3x3[0] = objectToWorld[1].yzx * objectToWorld[2].zxy - objectToWorld[1].zxy * objectToWorld[2].yzx; 38 | worldToObject3x3[1] = objectToWorld[0].zxy * objectToWorld[2].yzx - objectToWorld[0].yzx * objectToWorld[2].zxy; 39 | worldToObject3x3[2] = objectToWorld[0].yzx * objectToWorld[1].zxy - objectToWorld[0].zxy * objectToWorld[1].yzx; 40 | 41 | float det = dot(objectToWorld[0].xyz, worldToObject3x3[0]); 42 | 43 | worldToObject3x3 = transpose(worldToObject3x3); 44 | 45 | worldToObject3x3 *= rcp(det); 46 | 47 | float3 worldToObjectPosition = mul(worldToObject3x3, -objectToWorld._14_24_34); 48 | 49 | worldToObject._11_21_31_41 = float4(worldToObject3x3._11_21_31, 0.0f); 50 | worldToObject._12_22_32_42 = float4(worldToObject3x3._12_22_32, 0.0f); 51 | worldToObject._13_23_33_43 = float4(worldToObject3x3._13_23_33, 0.0f); 52 | worldToObject._14_24_34_44 = float4(worldToObjectPosition, 1.0f); 53 | } 54 | 55 | void ParticleInstancingSetup() 56 | { 57 | ParticleInstancingMatrices(unity_ObjectToWorld, unity_WorldToObject); 58 | } 59 | 60 | #else 61 | 62 | void ParticleInstancingSetup() {} 63 | 64 | #endif 65 | 66 | #endif // BUILTIN_PARTICLESINSTANCING_INCLUDED 67 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/ParticlesInstancing.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7969237c9e946bf4c9a468fa86bc2a6e 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/SSAO.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 77e514e255ff87744a7ce9ac35531c6d 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/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_LWSampleSceneColor(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 | #if defined(REQUIRE_DEPTH_TEXTURE) 14 | #include "Packages/com.z3y.shadergraph-builtin/ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/DeclareDepthTexture.hlsl" 15 | #endif 16 | 17 | #if defined(REQUIRE_OPAQUE_TEXTURE) 18 | #include "Packages/com.z3y.shadergraph-builtin/ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/DeclareOpaqueTexture.hlsl" 19 | #endif 20 | 21 | float shadergraph_LWSampleSceneDepth(float2 uv) 22 | { 23 | #if defined(REQUIRE_DEPTH_TEXTURE) 24 | return SampleSceneDepth(uv); 25 | #else 26 | return 0; 27 | #endif 28 | } 29 | 30 | float3 shadergraph_LWSampleSceneColor(float2 uv) 31 | { 32 | #if defined(REQUIRE_OPAQUE_TEXTURE) 33 | return SampleSceneColor(uv); 34 | #else 35 | return 0; 36 | #endif 37 | } 38 | 39 | float3 shadergraph_LWBakedGI(float3 positionWS, float3 normalWS, float2 uvStaticLightmap, float2 uvDynamicLightmap, bool applyScaling) 40 | { 41 | #ifdef LIGHTMAP_ON 42 | if (applyScaling) 43 | uvStaticLightmap = uvStaticLightmap * unity_LightmapST.xy + unity_LightmapST.zw; 44 | 45 | return SampleLightmap(uvStaticLightmap, normalWS); 46 | #else 47 | return SampleSH(normalWS); 48 | #endif 49 | } 50 | 51 | float3 shadergraph_LWReflectionProbe(float3 viewDir, float3 normalOS, float lod) 52 | { 53 | float3 reflectVec = reflect(-viewDir, normalOS); 54 | return DecodeHDREnvironment(SAMPLE_TEXTURECUBE_LOD(unity_SpecCube0, samplerunity_SpecCube0, reflectVec, lod), unity_SpecCube0_HDR); 55 | } 56 | 57 | void shadergraph_LWFog(float3 position, out float4 color, out float density) 58 | { 59 | color = unity_FogColor; 60 | #if defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2) 61 | // ComputeFogFactor returns the fog density (0 for no fog and 1 for full fog). 62 | density = ComputeFogFactor(TransformObjectToHClip(position).z); 63 | #else 64 | density = 0.0f; 65 | #endif 66 | } 67 | 68 | // This function assumes the bitangent flip is encoded in tangentWS.w 69 | float3x3 BuildTangentToWorld(float4 tangentWS, float3 normalWS) 70 | { 71 | // tangentWS must not be normalized (mikkts requirement) 72 | 73 | // Normalize normalWS vector but keep the renormFactor to apply it to bitangent and tangent 74 | float3 unnormalizedNormalWS = normalWS; 75 | float renormFactor = 1.0 / length(unnormalizedNormalWS); 76 | 77 | // bitangent on the fly option in xnormal to reduce vertex shader outputs. 78 | // this is the mikktspace transformation (must use unnormalized attributes) 79 | float3x3 tangentToWorld = CreateTangentToWorld(unnormalizedNormalWS, tangentWS.xyz, tangentWS.w > 0.0 ? 1.0 : -1.0); 80 | 81 | // surface gradient based formulation requires a unit length initial normal. We can maintain compliance with mikkts 82 | // by uniformly scaling all 3 vectors since normalization of the perturbed normal will cancel it. 83 | tangentToWorld[0] = tangentToWorld[0] * renormFactor; 84 | tangentToWorld[1] = tangentToWorld[1] * renormFactor; 85 | tangentToWorld[2] = tangentToWorld[2] * renormFactor; // normalizes the interpolated vertex normal 86 | 87 | return tangentToWorld; 88 | } 89 | 90 | // Always include Shader Graph version 91 | // Always include last to avoid double macros 92 | #include "Packages/com.z3y.shadergraph-builtin/ShaderGraph/ShaderGraphLibrary/Functions.hlsl" 93 | 94 | #endif // UNITY_GRAPHFUNCTIONS_LW_INCLUDED 95 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/ShaderGraphFunctions.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: acf235e786283f24eae2409d9d67d0c2 3 | timeCreated: 1488965025 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/ShaderTypes.cs.hlsl: -------------------------------------------------------------------------------- 1 | // 2 | // This file was automatically generated. Please don't edit by hand. Execute Editor command [ Edit > Rendering > Generate Shader Includes ] instead 3 | // 4 | 5 | #ifndef SHADERTYPES_CS_HLSL 6 | #define SHADERTYPES_CS_HLSL 7 | // Generated from UnityEngine.Rendering.BuiltIn.ShaderInput+LightData 8 | // PackingRules = Exact 9 | struct LightData 10 | { 11 | float4 position; 12 | float4 color; 13 | float4 attenuation; 14 | float4 spotDirection; 15 | float4 occlusionProbeChannels; 16 | }; 17 | 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/ShaderTypes.cs.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a84ec0ebe72c58e408851cdc86cec239 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/ShaderVariablesFunctions.deprecated.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_SHADER_VARIABLES_FUNCTIONS_DEPRECATED_INCLUDED 2 | #define UNITY_SHADER_VARIABLES_FUNCTIONS_DEPRECATED_INCLUDED 3 | 4 | #include "Packages/com.z3y.shadergraph-builtin/ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Input.hlsl" 5 | 6 | // Deprecated: A confusingly named and duplicate function that scales clipspace to unity NDC range. (-w < x(-y) < w --> 0 < xy < w) 7 | // Use GetVertexPositionInputs().positionNDC instead for vertex shader 8 | // Or a similar function in Common.hlsl, ComputeNormalizedDeviceCoordinatesWithZ() 9 | 10 | #ifndef BUILTIN_TARGET_API 11 | float4 ComputeScreenPos(float4 positionCS) 12 | { 13 | float4 o = positionCS * 0.5f; 14 | o.xy = float2(o.x, o.y * _ProjectionParams.x) + o.w; 15 | o.zw = positionCS.zw; 16 | return o; 17 | } 18 | #endif 19 | 20 | #endif // UNITY_SHADER_VARIABLES_FUNCTIONS_DEPRECATED_INCLUDED 21 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/ShaderVariablesFunctions.deprecated.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 576f715a228534346bbccf0ad60ed770 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/ShaderVariablesFunctions.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ddcf5b451596144688a41ee8ea75551 3 | timeCreated: 1488965025 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Shadows.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4cf4bda56061f2c4aa3275288c31e0b6 3 | timeCreated: 1488965025 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Shim.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e55fabdc7dd5ca448f3326d6fbc85ad 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Shim/HLSLSupportShim.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ecd8b1ffbc43f8e4f88add2b4102eaf7 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Shim/InputsShim.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_INPUTS_SHIM_INCLUDED 2 | #define UNITY_INPUTS_SHIM_INCLUDED 3 | 4 | // The built-in pipeline is not able to include UnityInput.hlsl due to it defining a bunch of 5 | // inputs/constants/variables that are also defined in built-in. This file defines the few extra 6 | // functions missing from there that are also needed. 7 | 8 | // Use the include guard to force UnityInput.hlsl to not get included 9 | #define BUILTIN_SHADER_VARIABLES_INCLUDED 10 | 11 | #include "UnityShaderVariables.cginc" 12 | 13 | // scaleBias.x = flipSign 14 | // scaleBias.y = scale 15 | // scaleBias.z = bias 16 | // scaleBias.w = unused 17 | //uniform float4 _ScaleBias; 18 | uniform float4 _ScaleBiasRt; 19 | 20 | // _TimeParameters is not defined in built-in, but is expected to be defined as [t, sin(t), cos(t), 0]. 21 | // This can be dynamically constructed from other variables knowing that: 22 | // float4 _Time; // (t/20, t, t*2, t*3) 23 | // float4 _SinTime; // sin(t/8), sin(t/4), sin(t/2), sin(t) 24 | // float4 _CosTime; // cos(t/8), cos(t/4), cos(t/2), cos(t) 25 | float4 GetTimeParameters() 26 | { 27 | return float4(_Time.y, _SinTime.w, _CosTime.w, 0); 28 | } 29 | #define _TimeParameters GetTimeParameters() 30 | 31 | float4x4 OptimizeProjectionMatrix(float4x4 M) 32 | { 33 | // Matrix format (x = non-constant value). 34 | // Orthographic Perspective Combined(OR) 35 | // | x 0 0 x | | x 0 x 0 | | x 0 x x | 36 | // | 0 x 0 x | | 0 x x 0 | | 0 x x x | 37 | // | x x x x | | x x x x | | x x x x | <- oblique projection row 38 | // | 0 0 0 1 | | 0 0 x 0 | | 0 0 x x | 39 | // Notice that some values are always 0. 40 | // We can avoid loading and doing math with constants. 41 | M._21_41 = 0; 42 | M._12_42 = 0; 43 | return M; 44 | } 45 | 46 | #include "Packages/com.z3y.shadergraph-builtin/CoreRP/ShaderLibrary/UnityInstancing.hlsl" 47 | #include "Packages/com.z3y.shadergraph-builtin/ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/BuiltInDOTSInstancing.hlsl" 48 | //#include "Packages/com.z3y.shadergraph-builtin/CoreRP/ShaderLibrary/SpaceTransforms.hlsl" 49 | 50 | #endif // UNITY_INPUTS_SHIM_INCLUDED 51 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Shim/InputsShim.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5cb1f637602dde44d9643f94d8ff1984 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Shim/Shims.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_SHIMS_INCLUDED 2 | #define UNITY_SHIMS_INCLUDED 3 | 4 | // This file serves as the shim between the legacy cginc files that required for the built-in pipeline and the core srp library. 5 | // For the built-in RP to work correctly, all the lighting in the cginc files is necessary, but there's a lot of utility 6 | // required (especially for shader graph) in the core SRP library. There are also some duplicate symbols and other complications. 7 | // This set of files helps to bridge the gap by hiding and redefining some symbols and other helpful declarations. 8 | 9 | 10 | // built-in uses a different keyword, fix for SPI 11 | #if defined(STEREO_INSTANCING_ON) 12 | #define UNITY_STEREO_INSTANCING_ENABLED 13 | #endif 14 | 15 | #include "Packages/com.z3y.shadergraph-builtin/CoreRP/ShaderLibrary/Common.hlsl" 16 | 17 | // Duplicate define in Macros.hlsl 18 | #if defined (TRANSFORM_TEX) 19 | #undef TRANSFORM_TEX 20 | #endif 21 | 22 | #include "HLSLSupportShim.hlsl" 23 | #include "InputsShim.hlsl" 24 | #include "SurfaceShaderProxy.hlsl" 25 | 26 | #include "UnityShaderVariables.cginc" 27 | #include "UnityShaderUtilities.cginc" 28 | #include "UnityCG.cginc" 29 | #include "Lighting.cginc" 30 | #include "UnityPBSLighting.cginc" 31 | #include "AutoLight.cginc" 32 | 33 | 34 | struct appdata_full_custom { 35 | float4 vertex : POSITION; 36 | float4 tangent : TANGENT; 37 | float3 normal : NORMAL; 38 | float4 texcoord : TEXCOORD0; 39 | float4 texcoord1 : TEXCOORD1; 40 | float4 texcoord2 : TEXCOORD2; 41 | float4 texcoord3 : TEXCOORD3; 42 | fixed4 color : COLOR; 43 | UNITY_VERTEX_INPUT_INSTANCE_ID 44 | uint vertexId : SV_VertexID; 45 | }; 46 | 47 | // need vertexId for dps 48 | #define appdata_full appdata_full_custom 49 | 50 | #if defined(RALIV_PENETRATOR) || defined(RALIV_ORIFICE) 51 | #include "Assets/RalivDynamicPenetrationSystem/Plugins/RalivDPS_Defines.cginc" 52 | #include "Assets/RalivDynamicPenetrationSystem/Plugins/RalivDPS_Functions.cginc" 53 | #endif 54 | 55 | static float static_Reflectance = 0.5; 56 | 57 | 58 | 59 | struct LightDataCustom 60 | { 61 | half3 Color; 62 | float3 Direction; 63 | half NoL; 64 | half LoH; 65 | half NoH; 66 | float3 HalfVector; 67 | half3 FinalColor; 68 | half3 Specular; 69 | half Attenuation; 70 | }; 71 | 72 | 73 | #ifdef POINT 74 | # define COPY_FROM_LIGHT_COORDS(dest, src) dest = src._LightCoord 75 | # define COPY_TO_LIGHT_COORDS(dest, src) dest._LightCoord.xyz = src.xyz 76 | #endif 77 | 78 | #ifdef SPOT 79 | # define COPY_FROM_LIGHT_COORDS(dest, src) dest = src._LightCoord.xyz 80 | # define COPY_TO_LIGHT_COORDS(dest, src) dest._LightCoord.xyz = src.xyz 81 | #endif 82 | 83 | #ifdef DIRECTIONAL 84 | # define COPY_FROM_LIGHT_COORDS(dest, src) 85 | # define COPY_TO_LIGHT_COORDS(dest, src) 86 | #endif 87 | 88 | #ifdef POINT_COOKIE 89 | # define COPY_FROM_LIGHT_COORDS(dest, src) dest = src._LightCoord.xyz 90 | # define COPY_TO_LIGHT_COORDS(dest, src) dest._LightCoord.xyz = src.xyz 91 | #endif 92 | 93 | #ifdef DIRECTIONAL_COOKIE 94 | # define COPY_FROM_LIGHT_COORDS(dest, src) dest = float3(src._LightCoord.xy, 1) 95 | # define COPY_TO_LIGHT_COORDS(dest, src) dest._LightCoord.xy = src.xy 96 | #endif 97 | 98 | #endif // UNITY_SHIMS_INCLUDED 99 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Shim/Shims.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cc71c6614ca564b4ebac808ccb55bb3c 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Shim/SurfaceShaderProxy.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_SURFACE_SHADER_PROXY_INCLUDED 2 | #define UNITY_SURFACE_SHADER_PROXY_INCLUDED 3 | 4 | #define UNITY_MATRIX_I_M unity_WorldToObject 5 | 6 | #endif // UNITY_SURFACE_SHADER_PROXY_INCLUDED 7 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Shim/SurfaceShaderProxy.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: efd92de5eb1e71549aa8533ffdc688c2 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | preprocessorOverride: 0 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/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 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/SurfaceData.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a5c7663a58665f549ba33673ecb6bb7b 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/SurfaceInput.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | #ifndef BUILTIN_INPUT_SURFACE_INCLUDED 3 | #define BUILTIN_INPUT_SURFACE_INCLUDED 4 | 5 | #include "Packages/com.z3y.shadergraph-builtin/ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/Core.hlsl" 6 | #include "Packages/com.z3y.shadergraph-builtin/ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/SurfaceData.hlsl" 7 | #include "Packages/com.z3y.shadergraph-builtin/CoreRP/ShaderLibrary/Packing.hlsl" 8 | #include "Packages/com.z3y.shadergraph-builtin/CoreRP/ShaderLibrary/CommonMaterial.hlsl" 9 | 10 | TEXTURE2D(_BaseMap); SAMPLER(sampler_BaseMap); 11 | TEXTURE2D(_BumpMap); SAMPLER(sampler_BumpMap); 12 | TEXTURE2D(_EmissionMap); SAMPLER(sampler_EmissionMap); 13 | 14 | /////////////////////////////////////////////////////////////////////////////// 15 | // Material Property Helpers // 16 | /////////////////////////////////////////////////////////////////////////////// 17 | half Alpha(half albedoAlpha, half4 color, half cutoff) 18 | { 19 | #if !defined(_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A) && !defined(_GLOSSINESS_FROM_BASE_ALPHA) 20 | half alpha = albedoAlpha * color.a; 21 | #else 22 | half alpha = color.a; 23 | #endif 24 | 25 | #if defined(_ALPHATEST_ON) 26 | clip(alpha - cutoff); 27 | #endif 28 | 29 | return alpha; 30 | } 31 | 32 | half4 SampleAlbedoAlpha(float2 uv, TEXTURE2D_PARAM(albedoAlphaMap, sampler_albedoAlphaMap)) 33 | { 34 | return SAMPLE_TEXTURE2D(albedoAlphaMap, sampler_albedoAlphaMap, uv); 35 | } 36 | 37 | half3 SampleNormal(float2 uv, TEXTURE2D_PARAM(bumpMap, sampler_bumpMap), half scale = 1.0h) 38 | { 39 | #ifdef _NORMALMAP 40 | half4 n = SAMPLE_TEXTURE2D(bumpMap, sampler_bumpMap, uv); 41 | #if BUMP_SCALE_NOT_SUPPORTED 42 | return UnpackNormal(n); 43 | #else 44 | return UnpackNormalScale(n, scale); 45 | #endif 46 | #else 47 | return half3(0.0h, 0.0h, 1.0h); 48 | #endif 49 | } 50 | 51 | half3 SampleEmission(float2 uv, half3 emissionColor, TEXTURE2D_PARAM(emissionMap, sampler_emissionMap)) 52 | { 53 | #ifndef _EMISSION 54 | return 0; 55 | #else 56 | return SAMPLE_TEXTURE2D(emissionMap, sampler_emissionMap, uv).rgb * emissionColor; 57 | #endif 58 | } 59 | 60 | #endif 61 | */ -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/SurfaceInput.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d803f5b22d6efe74e847edeaa8133ce5 3 | timeCreated: 1488965025 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/UnityGBuffer.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b09efb39ebb28434396eb01846d26011 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Editor/Generation/Targets/BuiltIn/ShaderLibrary/UnityInput.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a0b88ebb689241e498a536497232b8d2 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6422be51653e166478180da3a6bf1f7f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/Functions.hlsl: -------------------------------------------------------------------------------- 1 | // UNITY_SHADER_NO_UPGRADE 2 | #ifndef UNITY_GRAPHFUNCTIONS_INCLUDED 3 | #define UNITY_GRAPHFUNCTIONS_INCLUDED 4 | 5 | // ---------------------------------------------------------------------------- 6 | // Included in generated graph shaders 7 | // ---------------------------------------------------------------------------- 8 | 9 | #ifndef BUILTIN_TARGET_API 10 | bool IsGammaSpace() 11 | { 12 | #ifdef UNITY_COLORSPACE_GAMMA 13 | return true; 14 | #else 15 | return false; 16 | #endif 17 | } 18 | #endif 19 | 20 | float4 ComputeScreenPos (float4 pos, float projectionSign) 21 | { 22 | float4 o = pos * 0.5f; 23 | o.xy = float2(o.x, o.y * projectionSign) + o.w; 24 | o.zw = pos.zw; 25 | return o; 26 | } 27 | 28 | struct Gradient 29 | { 30 | int type; 31 | int colorsLength; 32 | int alphasLength; 33 | float4 colors[8]; 34 | float2 alphas[8]; 35 | }; 36 | 37 | Gradient NewGradient(int type, int colorsLength, int alphasLength, 38 | float4 colors0, float4 colors1, float4 colors2, float4 colors3, float4 colors4, float4 colors5, float4 colors6, float4 colors7, 39 | float2 alphas0, float2 alphas1, float2 alphas2, float2 alphas3, float2 alphas4, float2 alphas5, float2 alphas6, float2 alphas7) 40 | { 41 | Gradient output = 42 | { 43 | type, colorsLength, alphasLength, 44 | {colors0, colors1, colors2, colors3, colors4, colors5, colors6, colors7}, 45 | {alphas0, alphas1, alphas2, alphas3, alphas4, alphas5, alphas6, alphas7} 46 | }; 47 | return output; 48 | } 49 | 50 | #ifndef SHADERGRAPH_SAMPLE_SCENE_DEPTH 51 | #define SHADERGRAPH_SAMPLE_SCENE_DEPTH(uv) shadergraph_SampleSceneDepth(uv) 52 | #endif 53 | 54 | #ifndef SHADERGRAPH_SAMPLE_SCENE_COLOR 55 | #define SHADERGRAPH_SAMPLE_SCENE_COLOR(uv) shadergraph_SampleSceneColor(uv) 56 | #endif 57 | 58 | #ifndef SHADERGRAPH_BAKED_GI 59 | #define SHADERGRAPH_BAKED_GI(positionWS, normalWS, uvStaticLightmap, uvDynamicLightmap, applyScaling) shadergraph_BakedGI(positionWS, normalWS, uvStaticLightmap, uvDynamicLightmap, applyScaling) 60 | #endif 61 | 62 | #ifndef SHADERGRAPH_REFLECTION_PROBE 63 | #define SHADERGRAPH_REFLECTION_PROBE(viewDir, normalOS, lod) shadergraph_ReflectionProbe(viewDir, normalOS, lod) 64 | #endif 65 | 66 | #ifndef SHADERGRAPH_FOG 67 | #define SHADERGRAPH_FOG(position, color, density) shadergraph_Fog(position, color, density) 68 | #endif 69 | 70 | #ifndef SHADERGRAPH_AMBIENT_SKY 71 | #define SHADERGRAPH_AMBIENT_SKY float3(0,0,0) 72 | #endif 73 | 74 | #ifndef SHADERGRAPH_AMBIENT_EQUATOR 75 | #define SHADERGRAPH_AMBIENT_EQUATOR float3(0,0,0) 76 | #endif 77 | 78 | #ifndef SHADERGRAPH_AMBIENT_GROUND 79 | #define SHADERGRAPH_AMBIENT_GROUND float3(0,0,0) 80 | #endif 81 | 82 | #ifndef SHADERGRAPH_OBJECT_POSITION 83 | #define SHADERGRAPH_OBJECT_POSITION UNITY_MATRIX_M._m03_m13_m23 84 | #endif 85 | 86 | float shadergraph_SampleSceneDepth(float2 uv) 87 | { 88 | return 1; 89 | } 90 | 91 | float3 shadergraph_SampleSceneColor(float2 uv) 92 | { 93 | return 0; 94 | } 95 | 96 | float3 shadergraph_BakedGI(float3 positionWS, float3 normalWS, float2 uvStaticLightmap, float2 uvDynamicLightmap, bool applyScaling) 97 | { 98 | return 0; 99 | } 100 | 101 | float3 shadergraph_ReflectionProbe(float3 viewDir, float3 normalOS, float lod) 102 | { 103 | return 0; 104 | } 105 | 106 | void shadergraph_Fog(float3 position, out float4 color, out float density) 107 | { 108 | color = 0; 109 | density = 0; 110 | } 111 | 112 | #endif // UNITY_GRAPHFUNCTIONS_INCLUDED 113 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/Functions.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a352ada646046774db81f16e4cdac0a8 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/GeometricTools.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f9159db814bf6b4b9d6ee7242d1816c 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/LODDitheringTransition.hlsl: -------------------------------------------------------------------------------- 1 | // Shadergraph-friendly implementation of LODDitheringTransition. 2 | // The function as defined in Common.hlsl terminates on clip(f). 3 | // However, since it does not return or output anything, shadergraph 4 | // doesn't recognize it as code that gets used. This file can be removed 5 | // and replaced with a string custom function if Shader Graph ever adds 6 | // support for flagging custom function nodes as used, even if not 7 | // connected to anything. 8 | #ifndef SHADERGRAPH_CROSSFADE_INCLUDED 9 | #define SHADERGRAPH_CROSSFADE_INCLUDED 10 | #ifndef UNITY_MATERIAL_INCLUDED 11 | uint2 ComputeFadeMaskSeed(float3 V, uint2 positionSS) 12 | { 13 | uint2 fadeMaskSeed; 14 | 15 | // Is this a reasonable quality gate? 16 | #if defined(SHADER_QUALITY_HIGH) 17 | if (IsPerspectiveProjection()) 18 | { 19 | // Start with the world-space direction V. It is independent from the orientation of the camera, 20 | // and only depends on the position of the camera and the position of the fragment. 21 | // Now, project and transform it into [-1, 1]. 22 | float2 pv = PackNormalOctQuadEncode(V); 23 | // Rescale it to account for the resolution of the screen. 24 | pv *= _ScreenParams.xy; 25 | // The camera only sees a small portion of the sphere, limited by hFoV and vFoV. 26 | // Therefore, we must rescale again (before quantization), roughly, by 1/tan(FoV/2). 27 | pv *= UNITY_MATRIX_P._m00_m11; 28 | // Truncate and quantize. 29 | fadeMaskSeed = asuint((int2)pv); 30 | } 31 | else 32 | #endif 33 | { 34 | // Can't use the view direction, it is the same across the entire screen. 35 | fadeMaskSeed = positionSS; 36 | } 37 | 38 | return fadeMaskSeed; 39 | } 40 | #endif 41 | void LODDitheringTransitionSG_float(float3 viewDirWS, float4 screenPos, out float multiplyAlpha) 42 | { 43 | #if !defined (SHADER_API_GLES) && !defined(SHADER_STAGE_RAY_TRACING) 44 | float p = GenerateHashedRandomFloat(ComputeFadeMaskSeed(viewDirWS, screenPos.xy)); 45 | float f = unity_LODFade.x - CopySign(p, unity_LODFade.x); 46 | multiplyAlpha = f < 0 ? 0.0f : 1.0f; 47 | #endif 48 | } 49 | void DoLODCrossFade_half(float3 viewDirWS, float4 screenPos, out half halfAlpha) 50 | { 51 | #if !defined (SHADER_API_GLES) && !defined(SHADER_STAGE_RAY_TRACING) 52 | float p = GenerateHashedRandomFloat(ComputeFadeMaskSeed(viewDirWS, screenPos.xy)); 53 | float f = unity_LODFade.x - CopySign(p, unity_LODFade.x); 54 | float multiplyAlpha = f < 0 ? 0.0f : 1.0f; 55 | halfAlpha = (half)multiplyAlpha; 56 | #endif 57 | } 58 | #endif 59 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/LODDitheringTransition.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1337f3134fa53fd4ca0eca8c2f95c98d 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/Nature.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 061c0979672898547a7f65f3de5246a0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/Nature/SpeedTree8Billboard.shadersubgraph.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 498d2de04b78e7046b1f43b1aef87faf 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3} 11 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/Nature/SpeedTree8ColorAlpha.shadersubgraph.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ca3aca4c61870547a9fa74144fd9b68 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3} 11 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/Nature/SpeedTree8InterpolatedNormals.shadersubgraph.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf2c93cf8a2ba9a46b18b6e80bffd87c 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3} 11 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/Nature/SpeedTree8Wind.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d0737624af1dba44810f9b9cd97fc6c 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/Nature/SpeedTree8Wind.shadersubgraph.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2f069188ae738349ad28cd2bdbec14d 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3} 11 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/PreviewPass.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 | 13 | SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked); 14 | SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); 15 | 16 | return surfaceDescription.Out; 17 | } 18 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/PreviewPass.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2e3e748fad9a104988df2d832b8eb27 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/PreviewVaryings.hlsl: -------------------------------------------------------------------------------- 1 | Varyings BuildVaryings(Attributes input) 2 | { 3 | Varyings output = (Varyings)0; 4 | 5 | // Returns the camera relative position (if enabled) 6 | float3 positionWS = TransformObjectToWorld(input.positionOS); 7 | 8 | #ifdef ATTRIBUTES_NEED_NORMAL 9 | float3 normalWS = TransformObjectToWorldNormal(input.normalOS); 10 | #else 11 | // Required to compile ApplyVertexModification that doesn't use normal. 12 | float3 normalWS = float3(0.0, 0.0, 0.0); 13 | #endif 14 | 15 | #ifdef ATTRIBUTES_NEED_TANGENT 16 | float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w); 17 | #endif 18 | 19 | #ifdef VARYINGS_NEED_POSITION_WS 20 | output.positionWS = positionWS; 21 | #endif 22 | 23 | #ifdef VARYINGS_NEED_POSITIONPREDISPLACEMENT_WS 24 | output.positionPredisplacementWS = positionWS; 25 | #endif 26 | 27 | #ifdef VARYINGS_NEED_NORMAL_WS 28 | output.normalWS = normalize(normalWS); 29 | #endif 30 | 31 | #ifdef VARYINGS_NEED_TANGENT_WS 32 | output.tangentWS = normalize(tangentWS); 33 | #endif 34 | 35 | output.positionCS = TransformWorldToHClip(positionWS); 36 | 37 | #if defined(VARYINGS_NEED_TEXCOORD0) || defined(VARYINGS_DS_NEED_TEXCOORD0) 38 | output.texCoord0 = input.uv0; 39 | #endif 40 | #if defined(VARYINGS_NEED_TEXCOORD1) || defined(VARYINGS_DS_NEED_TEXCOORD1) 41 | output.texCoord1 = input.uv1; 42 | #endif 43 | #if defined(VARYINGS_NEED_TEXCOORD2) || defined(VARYINGS_DS_NEED_TEXCOORD2) 44 | output.texCoord2 = input.uv2; 45 | #endif 46 | #if defined(VARYINGS_NEED_TEXCOORD3) || defined(VARYINGS_DS_NEED_TEXCOORD3) 47 | output.texCoord3 = input.uv3; 48 | #endif 49 | 50 | #if defined(VARYINGS_NEED_COLOR) || defined(VARYINGS_DS_NEED_COLOR) 51 | output.color = input.color; 52 | #endif 53 | 54 | #if defined(VARYINGS_NEED_VERTEXID) 55 | output.vertexID = input.vertexID; 56 | #endif 57 | 58 | #ifdef VARYINGS_NEED_VIEWDIRECTION_WS 59 | output.viewDirectionWS = _WorldSpaceCameraPos.xyz - positionWS; 60 | #endif 61 | 62 | #ifdef VARYINGS_NEED_BITANGENT_WS 63 | output.bitangentWS = cross(normalWS, tangentWS.xyz) * tangentWS.w; 64 | #endif 65 | 66 | #ifdef VARYINGS_NEED_SCREENPOSITION 67 | output.screenPosition = ComputeScreenPos(output.positionCS, _ProjectionParams.x); 68 | #endif 69 | 70 | return output; 71 | } 72 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/PreviewVaryings.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dcc746d5857c50c41ab8ba8f0717c7ed 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/ShaderConfig.cs.hlsl: -------------------------------------------------------------------------------- 1 | // 2 | // This file was automatically generated. Please don't edit by hand. 3 | // 4 | 5 | #ifndef SHADERCONFIG_CS_HLSL 6 | #define SHADERCONFIG_CS_HLSL 7 | // 8 | // UnityEngine.Rendering.HighDefinition.ShaderOptions: static fields 9 | // 10 | #define SHADEROPTIONS_VELOCITY_IN_GBUFFER (0) 11 | #define SHADEROPTIONS_PACK_GBUFFER_IN_U16 (0) 12 | #define SHADEROPTIONS_CAMERA_RELATIVE_RENDERING (1) 13 | 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/ShaderConfig.cs.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3acb93da5b299464cb99a4d0892e21be 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/ShaderVariables.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0bac0356da685464e818d1213cfb822b 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/ShaderVariablesFunctions.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_SHADER_VARIABLES_FUNCTIONS_INCLUDED 2 | #define UNITY_SHADER_VARIABLES_FUNCTIONS_INCLUDED 3 | 4 | #include "Packages/com.z3y.shadergraph-builtin/CoreRP/ShaderLibrary/SpaceTransforms.hlsl" 5 | 6 | // Note: '_WorldSpaceCameraPos' is set by the legacy Unity code. 7 | float3 GetPrimaryCameraPosition() 8 | { 9 | #if (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0) 10 | return float3(0, 0, 0); 11 | #else 12 | return _WorldSpaceCameraPos; 13 | #endif 14 | } 15 | 16 | // Could be e.g. the position of a primary camera or a shadow-casting light. 17 | float3 GetCurrentViewPosition() 18 | { 19 | #if defined(SHADERPASS) && (SHADERPASS != SHADERPASS_SHADOWS) 20 | return GetPrimaryCameraPosition(); 21 | #else 22 | // This is a generic solution. 23 | // However, for the primary camera, using '_WorldSpaceCameraPos' is better for cache locality, 24 | // and in case we enable camera-relative rendering, we can statically set the position is 0. 25 | return UNITY_MATRIX_I_V._14_24_34; 26 | #endif 27 | } 28 | 29 | // Returns the forward (central) direction of the current view in the world space. 30 | float3 GetViewForwardDir() 31 | { 32 | float4x4 viewMat = GetWorldToViewMatrix(); 33 | return -viewMat[2].xyz; 34 | } 35 | 36 | // Returns 'true' if the current view performs a perspective projection. 37 | bool IsPerspectiveProjection() 38 | { 39 | #if defined(SHADERPASS) && (SHADERPASS != SHADERPASS_SHADOWS) 40 | return (unity_OrthoParams.w == 0); 41 | #else 42 | // TODO: set 'unity_OrthoParams' during the shadow pass. 43 | return UNITY_MATRIX_P[3][3] == 0; 44 | #endif 45 | } 46 | 47 | // Computes the world space view direction (pointing towards the viewer). 48 | float3 GetWorldSpaceNormalizeViewDir(float3 positionWS) 49 | { 50 | if (IsPerspectiveProjection()) 51 | { 52 | // Perspective 53 | float3 V = GetCurrentViewPosition() - positionWS; 54 | return normalize(V); 55 | } 56 | else 57 | { 58 | // Orthographic 59 | return -GetViewForwardDir(); 60 | } 61 | } 62 | 63 | // UNITY_MATRIX_V defines a right-handed view space with the Z axis pointing towards the viewer. 64 | // This function reverses the direction of the Z axis (so that it points forward), 65 | // making the view space coordinate system left-handed. 66 | void GetLeftHandedViewSpaceMatrices(out float4x4 viewMatrix, out float4x4 projMatrix) 67 | { 68 | viewMatrix = UNITY_MATRIX_V; 69 | viewMatrix._31_32_33_34 = -viewMatrix._31_32_33_34; 70 | 71 | projMatrix = UNITY_MATRIX_P; 72 | projMatrix._13_23_33_43 = -projMatrix._13_23_33_43; 73 | } 74 | 75 | #if UNITY_REVERSED_Z 76 | #if (defined(SHADER_API_GLCORE) && !defined(SHADER_API_SWITCH)) || defined(SHADER_API_GLES) || defined(SHADER_API_GLES3) 77 | //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) 78 | #define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) max(-(coord), 0) 79 | #else 80 | //D3d with reversed Z => z clip range is [near, 0] -> remapping to [0, far] 81 | //max is required to protect ourselves from near plane not being correct/meaningfull in case of oblique matrices. 82 | #define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) max(((1.0-(coord)/_ProjectionParams.y)*_ProjectionParams.z),0) 83 | #endif 84 | #elif UNITY_UV_STARTS_AT_TOP 85 | //D3d without reversed z => z clip range is [0, far] -> nothing to do 86 | #define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) (coord) 87 | #else 88 | //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) 89 | #define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) (coord) 90 | #endif 91 | 92 | #endif // UNITY_SHADER_VARIABLES_FUNCTIONS_INCLUDED 93 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/ShaderVariablesFunctions.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7889fc3387069e48abb2bec84bf3a22 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/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 _InvProjMatrix 14 | #define UNITY_MATRIX_VP unity_MatrixVP 15 | #define UNITY_MATRIX_I_VP _InvViewProjMatrix 16 | #define UNITY_MATRIX_MV mul(UNITY_MATRIX_V, UNITY_MATRIX_M) 17 | #define UNITY_MATRIX_T_MV transpose(UNITY_MATRIX_MV) 18 | #define UNITY_MATRIX_IT_MV transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V)) 19 | #define UNITY_MATRIX_MVP mul(UNITY_MATRIX_VP, UNITY_MATRIX_M) 20 | #define UNITY_PREV_MATRIX_M unity_MatrixPreviousM 21 | #define UNITY_PREV_MATRIX_I_M unity_MatrixPreviousMI 22 | 23 | 24 | #endif // UNITY_SHADER_VARIABLES_MATRIX_DEFS_LEGACY_UNITY_INCLUDED 25 | -------------------------------------------------------------------------------- /ShaderGraph/ShaderGraphLibrary/ShaderVariablesMatrixDefsLegacyUnity.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cce3f1a860f9a824092f4c13fb4ea044 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ShaderGraph/Unity LICENSE.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9121065e89fedda4093ffe2f64867e43 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.z3y.shadergraph-builtin", 3 | "description": "Unity built-in Shader Graphs in 2019.4. Only .hlsl files and fixes for built-in\n\nSupported Shader Graph version: 12.1.6", 4 | "version": "0.1.1", 5 | "unity": "2019.4", 6 | "displayName": "Shader Graph Built-In", 7 | "hideInEditor": false 8 | } -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 16356bac25ab83c4c9a0d1aae02ecc97 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------