diff --git a/BJH/.gitignore b/BJH/.gitignore new file mode 100644 index 0000000..ee7c00e --- /dev/null +++ b/BJH/.gitignore @@ -0,0 +1,74 @@ +# ---> Unity +# This .gitignore file should be placed at the root of your Unity project directory +# +# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore +# +/[Ll]ibrary/ +/[Tt]emp/ +/[Oo]bj/ +/[Bb]uild/ +/[Bb]uilds/ +/[Ll]ogs/ +/[Uu]ser[Ss]ettings/ + +# MemoryCaptures can get excessive in size. +# They also could contain extremely sensitive data +/[Mm]emoryCaptures/ + +# Recordings can get excessive in size +/[Rr]ecordings/ + +# Uncomment this line if you wish to ignore the asset store tools plugin +# /[Aa]ssets/AssetStoreTools* + +# Autogenerated Jetbrains Rider plugin +/[Aa]ssets/Plugins/Editor/JetBrains* + +# Visual Studio cache directory +.vs/ + +# Gradle cache directory +.gradle/ + +# Autogenerated VS/MD/Consulo solution and project files +ExportedObj/ +.consulo/ +*.csproj +*.unityproj +*.sln +*.suo +*.tmp +*.user +*.userprefs +*.pidb +*.booproj +*.svd +*.pdb +*.mdb +*.opendb +*.VC.db + +# Unity3D generated meta files +*.pidb.meta +*.pdb.meta +*.mdb.meta + +# Unity3D generated file on crash reports +sysinfo.txt + +# Builds +*.apk +*.aab +*.unitypackage +*.app + +# Crashlytics generated file +crashlytics-build.properties + +# Packed Addressables +/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* + +# Temporary auto-generated Android Assets +/[Aa]ssets/[Ss]treamingAssets/aa.meta +/[Aa]ssets/[Ss]treamingAssets/aa/* + diff --git a/BJH/.vsconfig b/BJH/.vsconfig new file mode 100644 index 0000000..f019fd0 --- /dev/null +++ b/BJH/.vsconfig @@ -0,0 +1,6 @@ +{ + "version": "1.0", + "components": [ + "Microsoft.VisualStudio.Workload.ManagedGame" + ] +} diff --git a/BJH/Assets/BJH.meta b/BJH/Assets/BJH.meta new file mode 100644 index 0000000..6c575cd --- /dev/null +++ b/BJH/Assets/BJH.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c90e99fa3f9ea9c4f8441887d5f0478c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest.meta b/BJH/Assets/BJH/3dtest.meta new file mode 100644 index 0000000..cfa9503 --- /dev/null +++ b/BJH/Assets/BJH/3dtest.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3c376e8ea335c7a429fde4d52503ce52 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/CHANGELOG.md b/BJH/Assets/BJH/3dtest/CHANGELOG.md new file mode 100644 index 0000000..d10bc37 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/CHANGELOG.md @@ -0,0 +1,456 @@ +# Changelog + +## [0.13.1-preview] - 2025-12-22 + +* fix: shader compile error when screen space shadow is enabled in URP +* fix: check property existence before when converting materials + +## [0.13.0-preview] - 2025-12-04 + +## Added +* feat: add Toon 3D as 2D shader +* feat: assign material props when switching a material to Toon3Das2D +* license: add explicit reference to the Unity-chan license +* doc: add rendering paths section in the feature model doc + +## Changed +* package: raise minimum Unity version requirement to 6.0 +* deps: use com.unity.film-internal-utilities@0.20.0-preview +* sample: replace Unity-chan assets package-wide +* sample: mention Unity-chan license inside sample description +* sample: rename "Sample" scene to KageBall +* sample: move UVCheckGrid texture into the common folder +* sample: rename ToonShader scenes to UnityChan +* sample: rename sample description and displayName strings +* sample: update Built-in RP / URP / HDRP scenes +* sample: disable CameraController while running tests +* sample: reorganize floor materials grouping +* sample: stop auto-generating materials for the Unity-chan model +* doc: clean up Getting Started guide +* doc: clean up Highlight documentation +* doc: clean up Outline documentation +* doc: clean up AngelRing documentation +* doc: clean up Matcap documentation +* doc: tidy the Samples documentation +* doc: clean up Feature Difference documentation +* doc: move MaterialConverter lower in the TOC +* doc: put Render Pipeline Compatibility on the index page +* doc: use "With Additional Control Maps" term in Modes page +* doc: drop the word "Settings" from TOC entries +* doc: lower Outline doc heading levels +* doc: use emoji markers for feature availability +* doc: improve grammar and clarity +* doc: relocate HDRP box light entry under HDRP features + +## Fixed +* fix: share the same cbuffer for the Universal2D pass +* fix: workaround to prevent Built-in RP code from being executed in URP/HDRP +* fix: correct inspector documentation URLs +* fix: drop duplicate/unused Toon and Toon(Tessellation) shader properties +* fix: resolve deprecated UxmlFactory warnings +* fix: warnings - FindFirstObjectByType(), GetScriptingDefineSymbols(), SetScriptingDefineSymbols() + +## Removed +* sample: delete unused materials +* sample: remove unnecessary meta files +* sample: delete unused Unity-chan materials for URP +* doc: remove unused images +* doc: remove the “What’s New” documentation pages +* remove: strip all Raytraced Hard Shadow references + +## [0.12.0-preview] - 2025-07-28 + +### Added +* feat: make toon URP work show basic colors/texture and outline in 2D light environment + +### Changed +* doc: improve documentation accessibility + +### Fixed +* fix: errors when unlit mode is selected in the SceneView +* fix: undefined punctual shadow keywords for HDRP in Unity 6000.0 or later +* fix: dark areas instead of outlines in WebGL and OpenGL + + +## [0.11.1-preview] - 2025-06-12 + +### Added +* sample: add metaverse materials and prefabs of Unity-chan in the HDRP sample + +### Fixed +* fix: calling InitializeBakedGIData() is necessary for Unity newer than 6000.0.12 +* doc: fix incorrect table layout documentation in sections under Inspector Window Settings + +## [0.11.0-preview] - 2024-12-11 + +### Changed: +* api: change the accessor of internal test classes to internal +* api: change the accessor of UTS3MaterialHeaderScope to internal +* api: change the accessor of UTS3MaterialHeaderScopeList to internal +* api: change the accessor of UTS3MaterialEditorExtension and MaterialEditorExtension to internal +* docs: update Unity Editor Compatibility +* deps: use com.unity.film-internal-utilities@0.19.2-preview + +### Removed: +* api: remove unused empty UniversalToonShaderInfo class + +## [0.10.2-preview] - 2024-08-20 +### Fixed: +* Plane objects can not be chosen from their front face in SceneViews. +* Wrong include path for Linux systems. + +## [0.10.1-preview] - 2024-07-08 +### Fixed: +* URP Shader Eroors on newer then Unity 6000.0.9. +* HDRP Shder Erorrs on Unity 6. (Thanks to riina) +* SceneView Flickers when Light probe on HDRP shaders. + + +## [0.10.0-preview] - 2024-04-14 +### Updated: +* URP shader is compatible with DOTS instancing. (Thanks to Hum9183) +### Fixed: +* Base Map/1st Shade Map/2nd Shade Map missing Tiling & Offset values are applied to Clipping Masks. +* Undoing/Redoing Tiling & Offset won't be reflected on the screen until slection is changed.(Thanks to Hum9183) + +## [0.9.7-preview] - 2024-03-20 +### Updated +* URP Shader is comaptible with Light Layer. (Thanks to Hum9183) +* Fixed:Base Map/1st Shade Map/2nd Shade Map missing Tiling & Offset controls for all the render pipelines. (Thanks to Hum9183) + +## [0.9.6-preview] - 2023-09-24 +### Updated +* URP Shader is comaptible with DECAL. (Thanks to Hum9183Hum9183) +* Installation manual is suitable for new than Unity 2021. +### Fixed: +* A invalid reqnder queue when when Clipping is "On" or "Clip Transparency". (Thanks to TakeshiMiyakawaCR) + +## [0.9.5-preview] - 2023-08-25 +### Fixed +* A URP Shader error when using newer than 2023.1.3. +* A Null Reference Exception error with HDRP tesslation shader. + +## [0.9.4-preview] - 2023-05-01 +* Added a exlanation for URP line issue into Kown Issues. + +## [0.9.3-preview] - 2023-04-18 +* Deleted warnings when creating materials with URP and Built-in shaders. + +## [0.9.2-preview] - 2023-04-12 +### Fixed +* URP shader doesn't recieve shadows in player builds. + +## [0.9.1-preview] - 2023-03-30 +### Fixed +* Some wrong information for shader path in docs. +* Errors caused by mishandling for analytics. + +## [0.9.0-preview] - 2023-03-16 +### Updated +* Minimum Unity version is 2020.3.45, 2021.3.19,2022.2.11. +* Compatiblity with Universal RP Forward+. + +## [0.8.5-preview] - 2023-02-13 +### Fixed: +* Some wrong information in docs. + + +## [0.8.4-preview] - 2023-01-19 +### Updated: +* Shaders are compatible with some console platforms. + +## [0.8.3-preview] - 2023-01-11 +### Fixed: +* URP Shader doesn't work with Unity 2022.2.2f1. +* Warrnings in HDRP shaders. + +## [0.8.2-preview] - 2022-09-09 +### Updated: +* Updated some documents. + +### Fixed: +* Deleted some warinings. +* The converter ignores custom render queue in Unitychan Toon Shader ver 2 materials. +* The converter sometimes misidentified materials older than 0.7.x in Built-in UTS3 as older materials in Unitychan Toon Shader Ver 2.0.7. +* URP shader was not working for WebGL/GLES 3.0. + + +## [0.8.1-preview] - 2022-08-24 +### Updated: +* Updated some docs. + +### Fixed: +* TOC didn't include the link to Material Converter page. +* A image in index.md wasn't displayed in doc web site. + +## [0.8.0-preview] - 2022-08-02 +### Updated: +* All the render pipeline shaders are integrated. +* Added material converter to above which is capable of Unity-Chan Toon Shader V2, Universal Toon and UTS3 older than 0.7.x. +* The package is compatible with 2020.3, 2021.3, 2022.1 and 2022.2. 2019.4 is no longer supported. + + +## [0.7.5-preview] - 2022-06-27 +* Improved the logic for blending outlines into a scene when there are no directional lights in the scene. + +## [0.7.4-preview] - 2022-06-25 +### Fixed: +* HDRP:Metaverse light was not working properly. + +### Updated: +* Added `Getting Started` to the documentation. +* Added more description to Outline doc. +* Added more description to RimLight doc. +* Mended Meteverse doc to use property, insted of indented menus. +* Mended SceneLightSetting doc to use property instead of indented menus. +* Re-wrote the doc to install samples. +* Updated some images in docs. +* Improved some wording in documentation. + +## [0.7.3-preview] - 2022-06-15 +### Updated: +* HDRP shader is compatible with 2022.2.0 a16. +* Attribute class for Mono-behaviors for UTS3. +* Mac Graphics Tests use rsync instead of scp. +* New retry count to several commands in Mac graphics tests. +* 3 basic color is now Three basic colors. +* `NormalMap Settings` is now an independent block. +* Updated docs. + +## [0.7.2-preview] - 2022-05-30 +### Fixed: +* Dead links for Toon EV adjustment HELP URL Buttons. +* Some classes are accessible from outside. + +## [0.7.1-preview] - 2022-05-26 +### Updated: +* Polished docs. + +## [0.7.0-preview] - 2022-05-23 +### Updated: +* Shader version properties in all the render pipeline shaders. +* Updated installation.md. +* The inspector window is significantly reorganized. +* Renamed `Double Shade with Feather` to `Standard`. +* Renamed `Shading Grade map` to `With Additional Control Maps`. +* Replaced toggle buttons Off/Active UI to Unity standard toggles. +* Renamed `Basic Shader Settings` to `Shader Setting`. +* Replaced some toggle buttons, such as `Emissive UV Coord`, `Specular Mode`, to dropdown menus +* Specular mode name are not just `Off`/`On` but `Soft`/`Hard`. +* Made everything in the inspector hidden when disabled to be shown but grayed out. +* Folder headers use Unity standard style in the inspector window when SRP core newer than 12 is not installed. +* Folder headers use SRP style in the inspector window when SRP core newer than 12 is installed. +* Renamed `【DX11 Phong Tessellation Settings】` to `Legacy Pipeline: Phong Tessellation Settings` as it works on Mac too. +* Renamed term, `Technique`, to `Mode`. +* Renamed term, `Contribution`, to `Effectiveness`. +* Renamed foldout name `Light Color Contribution` to `Scene Light Effectiveness Settings` +* Moved `Gi Intensity` and `Scene Light hi cut filter` to bellow it. +* Renamed `Scene Hi-cut filter` to `Limit Light Intensity` . +* Renamed term, `High Color`, to `Highlight`. +* Renamed `Settings for PointLights in ForwardAdd Pass` to `Point Light Settings`. +* Renamed `Point Light High Cut Filter` to `Filter Point Light Hight Light`. +* Re-organized Stencil and Clipping settings in the inspector window. +* Renamed `Stencil Out` to `Draw If Not Equal to`. +* Renamed `Stencil Mask` to `Replace Stencil Buffer with`. +* Renamed `Stencil No.` to `Stencil Value`. +* The above used to be a number field. Now it is editable with IntSlider. +* Renamed `Inverse MatCap Mask` to `Invert MatCap Mask`. +* Renamed `Trans Clipping Mode` to `Clip Transparency`. +* Renamed `Unlit Intensity` to `Metaverse Light Intensity` and `Buiilt-in light settings` are moved into `Metaverse Settings` foldout header in the inspector so that users can understand setting them is not necessary for usual uses.The setting works only when no directional lights are on the scenes like some VRChat ones. +* _Unlit_Intensity ranges defined in all the shaders are from 0 to 4. originally they were from 0.001 to 4. +* Changed built-in light default brightness from 1 to 0. +* Renamed `Basic Look Dev` to `Shading Step and Feather Settings`. +* `Advanced settings` in Outline foldout header are always shown. +* Renamed `Outline Sampler` in Ontline foldout header to `Outline Width Map`. +* Renamed `Outline-tex` in Ontline foldout header to `Outline Color Map`. +* Renamed Culling mode itemes from `CullingOff`, `FrontCulling` and `BackCulling` to `Off`, `Frontface` and `Backface`. +* Renamed `Receive System Shadows` to `Receive Shadows`. +* Renamed `Shadow Mask on High Color` to `Highlight Blending on Shadows`. +* Renamed `Highlight Power on Shadows` to `Blending Level`. +* Renamed `Camera Rolling Stabilizer` to `Stabilize Camera Rolling`. +* Renamed `ViewShift of Color` to `Color Shifting with View Angle`. +* Renamed `ViewShift` to `Shifting Target Color`. +* Renamed `Use Outline Texture` to `Outline Color Map`. +* Renamed `Use Baked Normal for Outline` to `Baked Normalmap`. +* Renamed `HighColor Power on Shadow` to `Brightness on Shadows`. +* Renamed `MatCap Power on Shadow` to `MatCap Blending on Shadows`. +* Renamed `Color Shift Speed` to `Color Shifting Speed`. +* Renamed `Blur Level of ShadingGradeMap` to `ShadingGradeMap Blur Level`. +* Renamed `MatCap Sampler` to `MatCap Map`. +* Renamed `Blur Level of MatCap Sampler` to `MatCap Blur Level`. +* Renamed `Rim Light Power` to `Rim Light Level`. +* Renamed `RimLight Inside Mask` to `Adjust Rim Light Area`. +* Renamed `Light Direction Mask` under Rim Light Settings to `Light Dreiction Mode`. +* Renamed `Light Direction Mask Level` to `Light Direction Rim Light Level`. +* Renamed `Antipodean(Ap)_RimLight` to `Inversed Direciton Rim Light`. +* Renamed `AP_RimLgiht Power` to `Inversed Rim Light Level`. +* Renamed `Color Blend Mode` to `Color Bleinding Mode`. +* Renamed `GI Intesity` to `Light Probe Intensity` +. +### Added: +* Legacy: Compatibility with Single Pass Stereo Rendering. +* Legacy: Graphics Test 2022.2. +* Universal RP: Graphics Test 2022.2. +* HDRP: Graphics Test 2022.2. +* Project Settings, but quite simple yet. +* Help buttons to foldout headers in the inspector window, which work newer than Unity 2021.1. +* Unity-Chan Toon Shader 2 Converter window opens when old shaders are in projects on start up or right after the package is installed. +* Dependency to srp core take advantege of its help system. +* Added Tips to Culling Mode popup menu in the inspector window. +* Added Tips to GUI Toggles in the inspector window. +* Added Tips to Range Properties in the inspector window. + +### Removed: +* Removed `● Additional Settings` in the Inspector window. +* Removed Simple UI. +* Removed Japanese and English manual link buttons. +* Removed Game Recommendation window and changed the default values of shader variables. +* Removed 【】in the Inspector window. +* Removed ● in the Inspector window. +* Removed unnecessary labels in the inspector such as `System Shadows:` +* `RTHS(Realtime Hard Shadow` is deprecated now as it will not be Unity official package. +* RTHS is not shown unless `Show deprecated features in the inspector` is checked in the `Project Settings Window`. + +### Fixed: +* Undo/Redo was not working on some items in the inspector window. +* Fixed Indent in NoramMap Settings in the inspector window. +* `Point Light High Cut Filter` Side Effects. It just shows or hides the point lights' highlight. +* Unify the notation in the converter with Unity-Chan Toon Shader 2. +* Fixed some popups in the inspector window not to use connected names without spaces. Each name is separated by a space. +* `Rimlight Mask` on URP and HDRP version were not working well. +* Single pass stereo rendering was not working with legacy(built-in) tessellation shaders. +* URP shader errors when used with Unity 2022.2. + +## [0.6.1-preview] - 2022-02-24 +### Fixed: +* typo in inspector. +* removed .sample.json under Samples~ folder +* Some unnecessary classes were public. +* Unnatural expression `Multiply or Additive` to `Multiply or Add`. + +## [0.6.0-preview] - 2022-02-22 +### Updated: +* Replaced test VM to use gtx1080 +* Updated README.md +* Added LICENSE.md under the project folder. +* Shader version properties in all the render pipeline shaders. + +### Fixed: +* Some unnecessary classes were public. +* URP: a depth output issue later then 10.0.x. (Thanks to riina) +* Typos in README.md +* promotion test issues. +* no .sample.json files under each render-pileline sample folder. + +## [0.5.0-preview] - 2022-01-20 +### Updated: +* Updated documentation and folder structure in order to make the package structure friendly to Unity official package. +* Tentatively deleted Japanese documentation before making the package ready for Unity standard translation system. +* HDRP: made UTS compatible with HDRP AOV. Capable of outputting Albedo, Normal and so on using AOV Image Sequence Recorder newer than 3.0. +* More effective and strict internal tests. + +### Fixed: +* HDRP:reduced shader variants by disabling some debug pragmas. +* URP:UTS materials don't receive shadows when using newer than Unity 2021.1. +* Legacy:Unable to disable Outline. +* AutoRenderQueue is disabled when material inspector is unfocused. + + +### Known Issues: +* HDRP: When outputting AOV images, UTS Outline is also put into the images. In such cases, please disable OUTLINE in Material Inspectors. + +## [0.4.1-preview] - 2021-10-20 +### Added +* HDRP:Something similar to HDRP exposure compensation. + +### Fixed: +* typo in documents. +* missing mono behaviors in sample scenes. +* HDRP:BoxLightAdjustment script. some flags are not updated properly when some checkboxes are clicked. +* HDRP:Shader compile errors when used with HDRP 12.1 + +## [0.4.0-preview] - 2021-10-13 +### Added +* HDRP: Compatibility with Box Light, a spot light variation, as main lights. +* HDRP: BoxLightAdjustment mono-behavior + +### Fixed: +* URP: Unstable SRP Compatibility. Thanks to tangx246. +* URP: Outline pass is not compatible with VR when Single Pass Instanced rendering is chosen. Thanks to tangx246 again. +* URP: Some warnings. + +### Updated: +* Documentation~/en/FeatureModel_en.md. Thanks to riina. +* Platforms in documentation. + +## [0.3.2-preview] - 2021-09-28 +### Added +* doc: HDRP: description for ray-trace shadow. + +### Fixed +* HDRP: fix Gaps between self-shadow and ray-trace shadow. + +## [0.3.1-preview] - 2021-09-27 +* description is above. + +## [0.3.0-preview] - 2021-09-16 +* HDRP: Fixed weird steps when more than 3 point lights are in a scene. +* HDRP: Added Toon EV Adjustment per Model. +* HDRP: Compatible with Raytraced Hardshadow when DX12 is chosen as API. +* Legacy: Applied a fix for outline flicker in VR chat. + +## [0.2.2-preview] - 2021-08-24 +* Modified Toon EV Adjustment Curve inspector. +* Excluded unnecessary files from release zip. +* Improved folder structure in order not to cause long file name errors when included in other packages. +* Added documentation for Toon EV Adjustment Curve. + +## [0.2.1-preview] - 2021-08-18 +* HDRP: Fixed: Multiple instances of Toon EV adjustment curve can exist in one scene. + +## [0.2.0-preview] - 2021-08-17 +* HDRP: Toon EV adjustment curve as a Mono-behavior. +* Legacy, Universal and HDRP: Some texture samplers,such as _MainTex, _NormalMap, _1st_ShadeMap and _2nd_ShadeMap, are shared by 1 sampler, sampler_MainTex, in order to avoid sampler number exceeding errors. +* Integrated Textures feature is removed from all the render pipeline versions instead of above. +* HDRP and URP are compatible with SRP Batcher. +* Legacy, Universal and HDRP: Added image comparison tests for Windows Vulkan API. +* HDRP: Added light probe compatibility. +* Added a material converter from Unity-chan Toon Shader newer than 2.0.7 to Unity Toon Shader. (Experimental) + +## [0.1.0-preview] - 2021-07-07 +* HDRP: Emission started to work. +* HDRP: Improved exposure. +* HDRP: Implemented tessellation to the outline pass. +* deleted ValidationConfig.json. + +## [0.0.7-preview] - 2021-06-14 +* Made samples installable. + +## [0.0.6-preview] - 2021-06-04 +* Modified documents + +## [0.0.5-preview] - 2021-05-12 +* Channel Mask rendering feature put the results into alpha channel. + +## [0.0.4-preview] - 2021-05-09 +* Universal RP shaders are compatible with SRP 12. + +## [0.0.3-preview] - 2021-05-05 +* Universal RP and HDRP shaders are compatible with SRP 10. +* HDRP shaders' DepthOnly path is replaced to DepthForwardOnly path. +* Internal tests are compatible with not only 2019.4 but also 2020.x now. + +## [0.0.2-preview] - 2021-03-30 +* Legacy shaders are integrated into two shaders. +* The number of textures is reduced experimental +* Added Clipping Matte feature for HDRP. +* Removed almost all the warnings when compiling shaders. +* Grafted graphics tests from Scriptable Render Pipelines. +* Reorganized documents. +* Reorganized repository folder structure. +* Added feature model list FeatureModel_en.md + +## [0.0.1-preview] - 2021-03-11 + +* Reorganized Unity-chan/Universal Toon Shader as Unity Toon shader. + diff --git a/BJH/Assets/BJH/3dtest/CHANGELOG.md.meta b/BJH/Assets/BJH/3dtest/CHANGELOG.md.meta new file mode 100644 index 0000000..fa0d85e --- /dev/null +++ b/BJH/Assets/BJH/3dtest/CHANGELOG.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2c2487b337be842428cd282ca300a522 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/CONTRIBUTING.md b/BJH/Assets/BJH/3dtest/CONTRIBUTING.md new file mode 100644 index 0000000..9f299b1 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/CONTRIBUTING.md @@ -0,0 +1,9 @@ +# Contributing + +## If you are interested in contributing, here are some ground rules: +* ... Define guidelines & rules for what contributors need to know to successfully make Pull requests against your repo ... + +## All contributions are subject to the [Unity Contribution Agreement(UCA)](https://unity3d.com/legal/licenses/Unity_Contribution_Agreement) +By making a pull request, you are confirming agreement to the terms and conditions of the UCA, including that your Contributions are your original creation and that you have complete right and authority to make your Contributions. + +## Once you have a change ready following these ground rules. Simply make a pull request diff --git a/BJH/Assets/BJH/3dtest/CONTRIBUTING.md.meta b/BJH/Assets/BJH/3dtest/CONTRIBUTING.md.meta new file mode 100644 index 0000000..12bcf26 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/CONTRIBUTING.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d6964b21905e5cf4c9bad823e15bc7a6 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Documentation~/AngelRing.md b/BJH/Assets/BJH/3dtest/Documentation~/AngelRing.md new file mode 100644 index 0000000..e771fb7 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/AngelRing.md @@ -0,0 +1,44 @@ +# Angel Ring Projection Settings + +The Angel Ring effect for UTS expresses shine or luster in hair. +This effect always appears in a fixed position as seen from the camera. + +Angel Ring requires: +1. [Unity Toon Shader mode](Modes.md) set to **With Additional Control Maps**. +2. 2nd UV in the model. + + +![The head of a chibi-style character with feathered hair and cat ears. The head is oriented from three angles: side, front, and back. In each angle, two bright highlights appear in the same place on the left and right.](images/AR_Image.png) + +- [Angel Ring Projection](#angel-ring-projection) + - [Angel Ring](#angel-ring) + - [Offset U and V](#offset-u-and-v) + - [Alpha Channel as Clipping Mask](#alpha-channel-as-clipping-mask) + +## Angel Ring Projection +Enable the Angel Ring effect for UTS, which expresses shine or luster in hair. + +### Angel Ring +Angel Ring: Texture(sRGB) × Color(RGB). Default: Black. + +**Unity Toon Shader** adds the color to the lighting results, and +you can also clip the effect using the alpha of the texture. +See [Alpha Channel as Clipping Mask](#alpha-channel-as-clipping-mask) for details. + + +![A dark square texture, with lighter v-shaped areas at the left and right edges.](images/para_height2.png)
+Angel Ring Texture Example + +### Offset U and V + +* Offset U: Adjusts the Angel Ring's shape in the horizontal direction. +* Offset V: Adjusts the Angel Ring’s shape in the vertical direction. + + + +### Alpha Channel as Clipping Mask + +The texture's alpha channel acts as a clipping mask. When disabled, alpha has no effect. + +![The head of a chibi-style character, with the v-shaped highlights on the left and right of their hair. This uses a 1024 x 1024 RGBA Compressed DXT5|BC3 Norm transparent square texture with white v-shaped areas at the left and right edges.](images/AngelRingWithAlpha_Output.png)
+Left: The alpha of the Angel Ring texture. Right: Output with **Alpha Channel as Clipping Mask** enabled. \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Documentation~/Basic.md b/BJH/Assets/BJH/3dtest/Documentation~/Basic.md new file mode 100644 index 0000000..7f44f79 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/Basic.md @@ -0,0 +1,81 @@ +# Three Color Map and Control Map Settings + +**Three Color Map and Control Map Settings** provide basic cel-shading settings in the **Unity Toon Shader**. These settings allow you to control the rendering of light and shadow areas independently from the actual light color. UTS provides detailed control over whether the directional light color affects materials. Please refer to [Scene Light Effectiveness Settings](SceneLight.md) for more information. + +* [Three Basic Color Maps](#Three-basic-color-maps) + * [Base Map](#base-map) + * [Apply to 1st Shading Map](#apply-to-1st-shading-map) + * [1st Shading map](#1st-shading-map) + * [Apply to 2nd Shading Map](#apply-to-2nd-shading-map) + * [2nd Shading Map](#2nd-shading-map) + * [Example of Three Color Map Operation](#example-of-Three-color-map-operation) +

+ + +* [Shadow Control Maps](#shadow-control-maps) + * [1st Shading Position Map](#1st-shading-map) + * [2nd Shading Position Map](#2nd-shading-map) + * [Example of Shadow Control Map Application](#example-of-shadow-control-map-application) +

+ +## Three Basic Color Maps + +## Base Map +Base Color: Texture(sRGB) × Color(RGB). The default color is white. The base color represents the color of the unshaded areas of objects or characters. + +| Base Color Map (Face) | (Hair) | Result | +| ---- | ---- |---- | +| A yellow texture map with different-colored areas for skin, ears, eyes, cheeks, and other parts of a face. | A grey texture map with two brown areas for cat-like ears, and lighter grey brushstrokes for parts of the hair. |A chibi-style face with yellow skin, grey hair, brown cat ears, large eyes, and rosy cheeks. | + + +### Apply to 1st Shading Map +Apply **Base Map** to the **1st Shading Map**. When you check **Apply to 1st Shading Map**, the texture map in **1st Shading Map** is not applied for rendering and the Inspector window disables its texture UI. + + +## 1st Shading Map +The map used for the brighter portions of the shadow. Texture(sRGB) × Color(RGB). The default color is white. + +| **1st Shading Map** (Face) | (Hair) | Result | +| ---- | ---- | ---- | +| A similar texture map to the base map, but the background is now tan. | A similar hair map to the base map, but the background is darker, and the brushstrokes have a blue gradient. |The chibi-style face, now with shadows at the bottom of the hair and face, and over the eyes. | + + +### Apply to 2nd Shading Map +Apply **Base Map** or the **1st Shading Map** to the **2nd Shading Map**. When you check **Apply to 2nd Shading Map**, the texture map in **2nd Shading Map** is not applied for rendering and the Inspector window disables its texture UI. + + +### 2nd Shading Map +The map used for the darker portions of the shadow. Texture(sRGB) × Color(RGB). The default color is white. + +| **2nd Shading Map** (Face) | (Hair) | Result | +| ---- | ---- | ---- | +| A similar texture map to the base map, but the background is now a dark orange. | A similar hair map to the base map, but the background is even darker. |The chibi-style face, now with darker shadows at the edges of the hair. | + + +## Shadow Control Maps +Textures that dictate the fixed shadows of the material. + +### 1st Shading Position Map +Specifies the position of fixed shadows that fall in 1st shade color areas in UV coordinates. **1st Position Map**: Texture(linear). + +### 2nd Shading Position Map +Specifies the position of fixed shadows that fall in 2nd shade color areas in UV coordinates. **2nd Position Map**: Texture(linear). + + +

+## Example of Shadow Control Map Application +| Base Map | 1st Shading Map | Shading Position Map | +| ---- | ---- | ---- | +| A UV map texture that contains all the parts of a chibi-style character model. |The same UV map but some areas have a darker color. |A mostly white texture, with 3 black hair shapes. | + +No Shadow Control Maps: +![A chibi-style character model with rabbit ears. In the Inspector window, the 1st Shading Position Map and 2nd Shading Position Map properties are empty.](images/ShadowControlMap0.png) + +1st Shading Position Map: +![The same model. In the Inspector window, the 1st Shading Position Map property is set to the shading position map texture.](images/ShadowControlMap1.png) + +2nd Shading Position Map: +![The same model. In the Inspector window, the 2nd Shading Position Map property is set to the shading position map texture.](images/ShadowControlMap2.png) + +Both: +![The same model. In the Inspector window, both the 1st Shading Position Map and 2nd Shading Position Map properties are set to the shading position map texture. ](images/ShadowControlMap3.png) diff --git a/BJH/Assets/BJH/3dtest/Documentation~/Emission.md b/BJH/Assets/BJH/3dtest/Documentation~/Emission.md new file mode 100644 index 0000000..17d0028 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/Emission.md @@ -0,0 +1,91 @@ +# Emission Settings + +Emission controls the color and intensity of light emitted from the surface. When you use an emissive material in your scene, it appears as a visible source of light. The meshes appear to be self-illuminated. + +[A chibi-style model standing between two red cubes, which light the model with emissive light.](images/EmissiveAnimation.png) + +* [Emission Map](#emission-map) +* [Emission Map Animation](#emission-map-animation) + * [Base Speed (Time)](#base-speed-time) + * [Animation Mode](#animation-mode) + * [Scroll U/X direction](#scroll-ux-direction) + * [Scroll V/Y direction](#scroll-vy-direction) + * [Rotate around UV center](#rotate-around-uv-center) + * [Ping-pong moves for base](#ping-pong-moves-for-base) + + * [Color Shifting with Time](#color-shifting-speed-time) + * [Destination Color](#destination-color) + * [Color Shifting Speed (Time)](#color-shifting-speed-time) + + * [Color Shifting with View Angle](#color-shifting-with-view-angle) + * [Shifting Target Color](#shifting-target-color) + + +## Emission Map +Primarily used with the Bloom Post Effect and represents luminous objects. + +![The Unity logo against a transparent background. The color fades from bright white at the center to black at the edges. The texture dimensions are 1024 x 1024, the texture size is 1.3MB, and the texture type is RBGA Compressed DXT5|BC3 UNorm.](images/EmissionMapSample.png) + +## Emission Map Animation +When enabled, the UV and color of the **Emission Map** animate. + + + + +### Base Speed (Time) +Specifies the base update speed of scroll animation. If the value is 1, it will scroll in 1 second. Specifying a value of 2 results in twice the speed of a value of 1, so it will scroll in 0.5 seconds. + +Base Speed = 0.5: + + + +Base Speed = 1.5: + + + +### Animation Mode +Controls the animated scrolling of the emissive texture. + +UV Coordinate Scroll: + + + +View Coordinate Scroll: + + + +### Scroll U/X direction +Specifies how much the Emissive texture should scroll in the U-direction (x-axis direction) when updating the animation. Base Speed (Time) x Scroll U Direction x Scroll V Direction determine the animation speed. + +### Scroll V/Y direction +Specifies how much the Emissive texture should scroll in the V-direction (y-axis direction) when updating the animation. Base Speed (Time) x Scroll U Direction x Scroll V Direction determine the animation speed. + +### Rotate around UV center +When Base Speed=1, the Emissive texture will rotate clockwise by 1. When combined with scrolling, rotation will occur after scrolling. + + + +### Ping-pong moves for base +When enabled, you can set PingPong (back and forth) in the direction of the animation. + + + +### Color Shifting with Time +The color multiplied by the Emissive texture changes by linear interpolation (Lerp) toward the Destination Color. + +#### Destination Color +Target color for [Color Shifting with Time](#color-shifting-with-time), must be in HDR. + +#### Color Shifting Speed (Time) +Sets the reference speed for color shift. When the value is 1, one cycle should take around 6 seconds. + + + +### Color Shifting with View Angle +Emissive color shifts consistent with view angle. The further out from the front of the camera, the more it changes to [Shifting Target Color](#shifting-target-color). + +#### Shifting Target Color +Target color for [Color Shifting with View Angle](#color-shifting-with-view-angle) which must be in HDR. + + + diff --git a/BJH/Assets/BJH/3dtest/Documentation~/FeatureModel_en.md b/BJH/Assets/BJH/3dtest/Documentation~/FeatureModel_en.md new file mode 100644 index 0000000..9192ed4 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/FeatureModel_en.md @@ -0,0 +1,101 @@ +## Feature Differences in Each Render Pipeline + +| Function | Built-In | URP | HDRP | +|--------------------------------------------------------------------------------------------|------------------------|--------------------|------------------------| +| ***1. Modes*** | | | | +|   Standard | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   With Advanced Control Map | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +| ***2. Shader Settings*** | | | | +|   Culling | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Stencil | :heavy_check_mark: | :heavy_check_mark: | :x: | +|   Stencil Value | :heavy_check_mark: | :heavy_check_mark: | :x: | +|   Clipping | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Clipping Mask | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Invert Clipping Mask | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Use Base Map Alpha as Clipping Mask | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +| ***3. Three Color Map and Control Map Settings*** | | | | +|   Base Map | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   1st Shading Map | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   2nd Shading Map | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Normal Map | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Shadow Control Maps | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +| ***4. Shading Steps and Feather Settings*** | | | | +|   Base Color Step | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Base Shading Feather | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Shading Color Step | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Point Light Step Offset | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Filter Point Light Highlights | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +| ***5. Highlight Settings*** | | | | +|   Highlight Power | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Specular Mode | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Color Blending Mode | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Highlight Blending on Shadows | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Highlight Mask | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Highlight Mask Level | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +| ***6. Rim Light Settings*** | | | | +|   Rim Light Color | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Rim Light Level | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Adjust Rim Light Area | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Inverted Light Direction Rim Light | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Rim Light Mask | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +| ***7. Material Capture(MatCap) Settings*** | | | | +|   MatCap Map | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   MatCap Blur Level | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Color Blending Mode | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Scale MatCap UV | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Rotate MatCap UV | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Stabilize Camera Rolling | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Normal Map | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Rotate Normal Map UV | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   MatCap Blending on Shadows | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   MatCap Camera Mode | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   MatCap Mask | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   MatCap Mask Level | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Invert MatCap Mask | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +| ***8. Emission Settings*** | | | | +|   Emission Map | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Use the alpha channel of Emissive Map as a Clipping mask | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Emission Map Animation | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Base Speed (Time) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Animation Mode | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Scroll U/X direction | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Scroll V/Y direction | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Rotate around UV center | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Ping-pong moves for base | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Color Shifting with Time | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Color Shifting with View Angle | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +| ***9. Angel Ring Projection Settings*** | | | | +|   Angel Ring | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Offset U/V | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Alpha Channel as Clipping Mask | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +| ***10. [Scene Light Effectiveness Settings](SceneLight.md) for all UTS color properties*** | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +| ***11. Metaverse Settings*** | | | | +|   Metaverse Light | :heavy_check_mark: | :heavy_check_mark: | :x: | +|   Metaverse Light Intensity | :heavy_check_mark: | :heavy_check_mark: | :x: | +|   Metaverse Light Direction | :heavy_check_mark: | :heavy_check_mark: | :x: | +| ***12. Outline Settings*** | | | | +|   Outline Mode | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Outline Width | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Outline Color | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Blend Base Color to Outline | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Offset Outline with Camera Z-axis | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Camera Distance for Outline Width | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Outline Color Map | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Rotate around UV center | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Ping-pong moves for base | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Color Shifting with Time | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Color Shifting with View Angle | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +| ***13.Tessellation Settings*** | DX11/DX12/Vulkan/Metal | :no_entry_sign: | DX11/DX12/Vulkan/Metal | +| ***14. EV Adjustment in high intensity light scenes*** | :no_entry_sign: | :no_entry_sign: | :heavy_check_mark: | +| ***15. DXR (ray-traced) shadows*** | :no_entry_sign: | :no_entry_sign: | :heavy_check_mark: | +| ***16. [Box Light](HDRPBoxLight.md)*** | :no_entry_sign: | :no_entry_sign: | :heavy_check_mark: | +| ***17. Rendering Paths*** | | | | +|   Forward | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +|   Forward+ | :no_entry_sign: | :heavy_check_mark: | :no_entry_sign: | +|   Deferred | :x: | :x: | :heavy_check_mark: | +|   Deferred+ | :no_entry_sign: | :x: | :no_entry_sign: | + +Notes: +* :heavy_check_mark: : Supported +* :no_entry_sign: : Not supported (e.g. limitations in the render pipeline, etc) +* :x: : Currently not available diff --git a/BJH/Assets/BJH/3dtest/Documentation~/GettingStarted.md b/BJH/Assets/BJH/3dtest/Documentation~/GettingStarted.md new file mode 100644 index 0000000..76b57bd --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/GettingStarted.md @@ -0,0 +1,115 @@ +# Getting Started with Unity Toon Shader + +The **Unity Toon Shader (UTS)** provides extensive controls +for professional cel-shading across the Built-in Render Pipeline, URP, and HDRP. +This page walks through the key concepts of cel-shading step by step. + +Follow these steps for simple cel-shading: +1. [Put a directional light in the scene](#put-a-directional-light-in-the-scene). +2. [Create materials for cel-shading and set the appropriate shader](#creating-a-new-material-and-applying-unity-toon-shader). +3. [Set up three basic colors](#setting-up-three-basic-colors). +4. [Determine the character's visual style](#adjusting-the-edges-of-the-three-basic-color-regions). +5. [Set up the outline](#set-up-the-outline). + +After mastering the basics, explore: + +- [Advanced techniques](#advanced-techniques) such as: + * [Eliminating outlines around eyes](#eliminating-outlines-around-eyes). + * [Adding luster to hair](#adding-luster-to-hair). +- [More options for stunning professional cel-shading](#more-options-for-stunning-professional-cel-shading) to push the look further. + +## Put a directional light in the scene + +To make cel-shading work, you need to place at least one [directional light](https://docs.unity3d.com/2022.2/Documentation/Manual/Lighting.html) in the scene. +Start with a neutral white light so you can see how UTS-specific settings influence the shading +without additional color shifts. + +## Creating a new material and applying Unity Toon Shader + +Start by [creating a material](https://docs.unity3d.com/6000.0/Documentation/Manual/materials-introduction.html) for your mesh and then assign the UTS shader: + +1. Create a new material and assign it to the mesh you plan to shade. +2. In the Inspector, choose **Toon > Toon** or **Toon > Toon (Tessellation)** from the Shader drop-down. + These shaders work on all supported render pipelines: Built-in Render Pipeline, URP, and HDRP. +3. Once assigned, the model will render as a flat silhouette until + you provide the texture maps that define the cel-shaded look. + +![The same character model with the Toon shader selected in the Inspector window. The model is now a flat white silhouette.](images/AppliedUTS.png) + +The directional light will no longer control shading in the usual way because UTS overrides the lighting response according to artist-driven parameters. UTS also allows you to decide whether and how the directional light color influences materials. See [Scene Light Effectiveness Settings](SceneLight.md) for guidance. + +## Setting up three basic colors + +UTS renders meshes in three conceptual regions: +1. **Base Map** for lit areas +2. **1st Shading Map** for lighter shadows, and +3. **2nd Shading Map** for the darkest tones. + +For basic cel-shading you can focus on the Base Map and 1st Shading Map. +The [Three Color Map and Control Map Settings](Basic.md) page explains the controls in depth. + +![The same character model with the same shader selected. The Base Map property and the 1st Shading Map properties in the Inspector window are set to UV texture maps that have the shapes and colors for the model. The character is now fully textured.](images/AppliedTextures.png) + +Follow these steps: +1. Author or import textures for the Base Map and 1st Shading Map. They can be separate textures or the same texture colored differently. +2. Assign the Base Map to define the fully lit colors. +3. Assign the 1st Shading Map to introduce a darker tone that UTS will show based on your shading step settings. + + +![UV map textures of a chibi-style model for lit and lighter shadows areas](images/UnityChanTextures.png)
+Left: an example Base Map. Right: an example 1st Shading Map. + + +## Adjusting the edges of the three basic color regions + +The borders between your color regions drive the perceived style of the character. +[Shading Steps and Feather Settings](ShadingStepAndFeather.md) let you adjust the position of those borders +and whether they are sharp or blended. + +Follow these steps: +1. Increase **Base Color Step** so the **1st Shading Map** becomes visible and the contrast between lit and shadowed regions matches your intent. +2. Use **Base Shading Feather** to control how crisply the regions transition. Lower values create graphic, posterized shading, while higher values blend the regions. + +![The same character model. In the Inspector window of the Toon shader, the Base Color Step property is set to 0.609. The shadows on the model are more prominent.](images/WithoutOutline.png) + +![The same character model. In the Inspector window of the Toon shader, the Base Shading Feather property is set to 0.279. The shadows on the model are more blended.](images/AdjustingFeather.png) + +## Set up the outline + +Outline is another important factor that determines the animation style. +Consider the outline color relative to your background and adjust the thickness to reinforce the style. +The [Outline Settings](Outline.md) page details every property. + + + + + +
Drag the slider to compare the images. + +## Advanced techniques + +Now that you've learned basic cel-shading, you can refine specific features of the character. +The following examples illustrate how UTS helps solve common cel-shading challenges. + +### Eliminating outlines around eyes + +Outlines around delicate facial features can be distracting. +Apply an [Outline Width Map](Outline.md#outline-width-map) to control outline thickness per texel so you can taper or remove the stroke where needed. + +![The same character model. In the Inspector window of the Toon shader, the Outline Width Map property is set to a texture. There's no longer an outline around the eyes of the character.](images/OutlineWidthMap3.png) + +### Adding luster to hair + +Flat lighting can make hair feel lifeless. +Combine the [Highlight](Highlight.md), [Angel Ring](AngelRing.md), and [Material Capture (MatCap)](MatCap.md) features to add dimensionality. +In this example, we'll apply a [MatCap map](MatCap.md#matcap-map) onto the hair. + +![The same character model. In the Inspector window of the Toon shader, the MatCap Map property is set to a texture. The shadows and outlines on the hair look more three-dimensional.](images/Luster3.png) + +## More options for stunning professional cel-shading + +Once you're comfortable with the steps above, experiment with these additional features to push the look even further: + +- [Emission](Emission.md) for glowing elements such as eyes, screens, or weapons. +- [Normal Map](NormalMap.md) to control the bumpiness of the material. +- [Rim Light](Rimlight.md) to highlight the edges of meshes. diff --git a/BJH/Assets/BJH/3dtest/Documentation~/HDRPBoxLight.md b/BJH/Assets/BJH/3dtest/Documentation~/HDRPBoxLight.md new file mode 100644 index 0000000..ab96b67 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/HDRPBoxLight.md @@ -0,0 +1,17 @@ + +## HDRP Box Light + +In HDRP, [only one directional light can cast shadow at a time](https://docs.unity3d.com/Manual/render-pipelines-feature-comparison.html). +This can be undesirable when we need lighting that differs from the scene's main directional light, +such as brightening a character's face or adding idealized shadows. + +The [Box Light](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@14.0/manual/Light-Component.html#Shape) +offers a practical workaround, and Unity Toon Shader supports it. + + + + +
+Drag the slider to compare the images. + +Box light applied to a character's face. Note that editing the angle of the box changes the shadows falling on the face, but not on the body and the ground. diff --git a/BJH/Assets/BJH/3dtest/Documentation~/Highlight.md b/BJH/Assets/BJH/3dtest/Documentation~/Highlight.md new file mode 100644 index 0000000..b6170aa --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/Highlight.md @@ -0,0 +1,81 @@ +# Highlight Settings + +The ability to display specular highlights in a cel-animation-like manner is essential for toon shaders. The **Unity Toon Shader** provides a wide variety of expressions with controllable illumination that works independently of light color and intensity for impressive cel-shading. + +Settings: +* [Highlight](#highlight) +* [Highlight Power](#highlight-power) +* [Specular Mode](#specular-mode) + * [Color Blending Mode](#color-blending-mode) +* [Highlight Blending on Shadows](#highlight-blending-on-shadows) + * [Blending Level](#blending-level) +* [Highlight Mask](#highlight-mask) +* [Highlight Mask Level](#highlight-mask-level) + + +## Highlight +Highlight: Texture(sRGB) × Color(RGB). Defines the pattern and tint of the specular highlight. + +Default: white. + + + + + +
Drag the slider to compare the images. + +## Highlight Power + +The highlight size is controlled by the **Highlight Power** slider. + + + + +## Specular Mode + +UTS provides two modes for the highlight for different occasions and effect. The hard mode provides a crisp and solid edge to the highlight while the soft mode provides a blended blurred effect. + + + + + +
Drag the slider to compare the images. + +

+ +### Color Blending Mode +Specular color blending mode allows the user to control the hardness of the colour applied to the highlight. +Users have two options: Multiply or Add. + +Note that **Color Blending Mode** is disabled when **Specular** Mode is set to **Soft**. + + + + + +
Drag the slider to compare the images. + +## Highlight Blending on Shadows +Control the blending for the highlights in shadows. Please refer to the image at [Blending Level](#blending-level). + +### Blending Level +Adjusts the intensity of highlight applied to shadow areas. + + + +## Highlight Mask +A gray scale texture which utilises its brightness to control highlight intensity. Applying the highlight mask allows to fine-tune the reflectivity on the material. + +![A square texture with a black and grey checkerboard pattern. Each square has a small plus symbol in its center.](images/UVCheckGrid.png)
+An example of a grayscale texture highlight mask. + + + + + +
Drag the slider to compare the images. + +## Highlight Mask Level +Highlight mask texture blending level to highlights. + + \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Documentation~/Known-issue.md b/BJH/Assets/BJH/3dtest/Documentation~/Known-issue.md new file mode 100644 index 0000000..68af8d2 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/Known-issue.md @@ -0,0 +1,14 @@ +# Known Issues +## When using AOV Image Sequence Recorder + +The **Unity Toon Shader** [Outline](Outline.md) is not automatically disabled when recording with the [AOV Image Sequence Recorder](https://docs.unity3d.com/Packages/com.unity.recorder@4.0/manual/RecorderAOV.html). Please disable [Outline](Outline.md#outline) in the Material Inspector when outputting AOV images. + +## When using Universal Render Pipeline + +When using the [Universal Render Pipeline](https://docs.unity3d.com/Manual/com.unity.render-pipelines.universal.html), you need to set [Depth Priming Mode](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@16.0/manual/urp-universal-renderer.html#rendering) to **Disabled** to show the [outline](Outline.md). + + + + + +
Drag the slider to compare the images. diff --git a/BJH/Assets/BJH/3dtest/Documentation~/MatCap.md b/BJH/Assets/BJH/3dtest/Documentation~/MatCap.md new file mode 100644 index 0000000..79ce5f1 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/MatCap.md @@ -0,0 +1,137 @@ +# Material Capture (MatCap) Settings + +MatCap is a method of light expression using pre-rendered images. +This technique uses a image of a sphere that represents the material and light to simulate lighting. + + + +* [MatCap Map](#matcap-map) +* [MatCap Blur Level](#matcap-blur-level) +* [Color Blending Mode](#color-blending-mode) +* [Scale MatCap UV](#scale-matcap-uv) +* [Rotate MatCap UV](#rotate-matcap-uv) +* [Stabilize Camera rolling](#stabilize-camera-rolling) +* [Normal Map Specular Mask for MatCap](#normal-map-specular-mask-for-matcap) + * [Normal Map](#normal-map) + * [Rotate Normal Map UV](#rotate-normal-map-uv) +* [MatCap Blending on Shadows](#matcap-blending-on-shadows) + * [Blending Level](#blending-level) +* [MatCap Camera Mode](#matcap-camera-mode) +* [MatCap Mask](#matcap-mask) + * [MatCap Mask Level](#matcap-mask-level) + * [Invert MatCap Mask](#invert-matcap-mask) + +## MatCap Map +MatCap Color: Texture(sRGB) × Color(RGB). + +Default: White + +![A square black texture, with an upwards-curving yellow shape with soft edges.](images/HiLight_Matcap.png)
+An example of a MatCap Map texture. + +
+MatCap Map disabled. + +
+MatCap Map enabled. + +## MatCap Blur Level +Blur MatCap Map using the Mip Map feature. + +To enable Mip Map, activate Advanced > Generate Mip Maps in the [Texture Import Settings](https://docs.unity3d.com/Manual/class-TextureImporter.html). + + + +## Color Blending Mode +MatCap color blending mode. Multiply or Add. + + + +## Scale MatCap UV +Scaling UV of MatCap Map. + + + + +## Rotate MatCap UV +Rotating UV of MatCap Map. + + + + +## Stabilize Camera Rolling +Stabilize Camera rolling when capturing materials with camera. + +
+Stabilize Camera Rolling disabled. + +
+Stabilize Camera Rolling enabled. + + +## Normal Map Specular Mask for MatCap + +When enabled, uses a dedicated normal map for MatCap. +If MatCap is used as specular lighting, this normal map can serve as a specular mask. + + + + + +
Drag the slider to compare the images. + +### Normal Map +A texture that dictates the bumpiness of the material. + + +![A grayscale texture of fine hair.](images/HairNormalMask.png)
+An example of a Normal Map texture. + + +### Rotate Normal Map UV +Rotates the MatCap normal map UV based on its center. + + + + +## MatCap Blending on Shadows +Enables the blending rate of the MatCap range in shadows. + + + + + +
Drag the slider to compare the images. + + +## Blending Level +Adjusts the intensity of MatCap applied to shadow areas. + +
+ + +## MatCap Camera Mode +Control how the MatCap Map is rendered based on the camera type. + +## MatCap Mask + +The MatCap mask aligns with the mesh’s UVs used for the MatCap projection. +Pixels in black (0) regions of the mask are fully hidden. + +![A view from above a chibi-style character model with blonde hair. Her hair has yellow highlights in the shape of the Unity logo.](images/MatCapMaskSample.png) + + +## MatCap Mask Level +Adjusts the level of the MatCap Mask. When the value is: +* 1: MatCap represents 100% irrespective of mask. +* -1: MatCap won't be displayed at all and MatCap will be the same as in the off state. + + + + +## Invert MatCap Mask +When enabled, inverts **MatCap Mask** Texture colors. + +![A view from above a chibi-style character model with blonde hair. Her hair has a bow-shaped brighter yellow specular highlight, with Unity logos cut out in the unlit hair color.](images/InvertMatCapMask.png) + + diff --git a/BJH/Assets/BJH/3dtest/Documentation~/MaterialConverter.md b/BJH/Assets/BJH/3dtest/Documentation~/MaterialConverter.md new file mode 100644 index 0000000..6977444 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/MaterialConverter.md @@ -0,0 +1,46 @@ +# Material Converter + +## Capability + +**Unity Toon Shader Material Converter** handles not only the **Unity Toon Shader** materials, but also [Unity-chan Toon Shader materials](https://github.com/unity3d-jp/UnityChanToonShaderVer2_Project) and [Univeral Toon Shader materials](https://github.com/unity3d-jp/UnityChanToonShaderVer2_Project/tree/release/urp/2.5.1). + + +Note: Unity-Chan Toon Shader materials saved with older than 2.0.6 have to be re-saved using 2.0.7 or newer. + +## How to convert +All you have to do to convert toon shader materials to the **Unity Toon Shader materials** are: +* [Launch converter](#launching-converter) +* [Select render pipeline and shaders in your project](#selecting-the-converter) +* [Press **Scan** button](#pressing-scan-button). +* [Press **Convert** button](#pressing-convert-button). + +Please make sure to back up the project since this converting process is irreversible. + +## Launching Converter +Launch the converter from menu. +Window -> Rendering -> Unity Toon Shader Converter + + ![MaterialConverterMenu](images/MaterialConverterMenu.png) + +Here is the converter screen. + + ![ConverterScreen](images/ConverterScreen.png) + +## Selecting the converter +You see five options to convert materials in the project. Choose the shader used in the project. + + ![MaterialConverterMenu](images/ConverterWindowOption.png) + + +## Pressing Scan Button + + ![MaterialConverterScanButton](images/ConverterScanButton.png) + +If you choose **Unity-chan Toon Shader 2** and the materials are saved with older than 2.0.6. The converter shows errors. In such case, you should save the materials using **Unity-chan Toon Shader** 2.0.7 or later. + + ![MaterialConverterScanButton](images/ConverterError.png) + +## Pressing Convert Button + +If there is no error, just press convert button. + diff --git a/BJH/Assets/BJH/3dtest/Documentation~/Metaverse.md b/BJH/Assets/BJH/3dtest/Documentation~/Metaverse.md new file mode 100644 index 0000000..70fc89b --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/Metaverse.md @@ -0,0 +1,24 @@ +# Metaverse Settings (Experimental) + +The **Unity Toon Shader** requires one directional light to work, though, often there are no directional lights in Metaverse scenes. In such cases, Metaverse light works as virtual directional light for cel-shading. + +* [Metaverse Light](#metaverse-light) + * [Metaverse Light Intensity](#metaverse-light-intensity) + * [Metaverse Light Direction](#metaverse-light-direction) +

+ + +## Metaverse Light +A checkbox to enable Metaverse light, which enables the use of UTS to work appropriately without any directional lights in the scene. +

+### Metaverse Light Intensity +Control the intensity of the supplementary lighting for UTS in the scene. +

+### Metaverse Light Direction +A checkbox to enable Metaverse Light direction, which Controls the direction of the supplementary lighting for UTS in the scene. + +| Property | Description | +| -- | -- | +| Offset X-Axis Direction | Moves Metaverse light horizontally. | +| Offset Y-Axis Direction | Moves Metaverse light vertically. | +| Invert Z-Axis Direction | Invert Metaverse light Z-Axis Direction.| diff --git a/BJH/Assets/BJH/3dtest/Documentation~/Modes.md b/BJH/Assets/BJH/3dtest/Documentation~/Modes.md new file mode 100644 index 0000000..2fbc052 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/Modes.md @@ -0,0 +1,10 @@ +# Mode + +The **Unity Toon Shader** mode that controls which workflow to apply in the shader. + +The Mode dropdown with Standard and With Advanced Control Map options. + +| Mode | Description | Image | +| ---- | ---- | ---- | +| **Standard** | Standard provides basic cel-shading techniques. | A toon-shaded sphere with three blue color bands and a light blue specular highlight. | +| **With Additional Control Maps** | **With Additional Control Maps** provides more complex cel-shading techniques with several additional control maps. | A toon-shaded sphere with a jagged repeating pattern of three blue color bands. | \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Documentation~/NormalMap.md b/BJH/Assets/BJH/3dtest/Documentation~/NormalMap.md new file mode 100644 index 0000000..2e95d8b --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/NormalMap.md @@ -0,0 +1,41 @@ +# Normal Map Settings + +A Normal Map is a texture that dictates the bumpiness of the material. The **Unity Toon Shader** allows control over **Normal Map** strength and which areas it applies to. + +* [Normal Map](#normal-map) +* [Normal Map Effectiveness](#normal-map-effectiveness) +* [Example of Normal Map Effectiveness Operation](#example-of-normal-map-effectiveness-operation) +

+ +## Normal Map +A Normal Map texture and its strength. + +![An example of a normal map. A square surface with 16 small raised squares in a regular layout. The edges of the raised squares use a different color for each normal direction.](images/DecoPlane_Nromal.png) + +Examples of a normal map with a strength of 1.0, 0.3, and 0.0: + +![The example normal map applied to a plane using the URP/Lit shader on the left side and the UTS shader on the right side, with a strength of 1.0. The raised squares are clearly visible on both halves.](images/NormalMapStrength1.png)
+Strength: 1.0. + +![The same example with a strength of 0.3. The raised squares are less visible on the UTS side.](images/NormalMapStrength03.png)
+Strength: 0.3. + +![The same example with a strength of 0.0. The raised squares are not visible on the UTS side.](images/NormalMapStrength00.png)
+Strength: 0.0. + +## Normal Map Effectiveness + + +|Properties| Description | +| ---- | ---- | +| Three Basic Colors | The effectiveness of the Normal Map on Three Basic color areas, lit, the 1st shading and the 2nd. | +| Highlight | Normal map effectiveness to high lit areas. | +| Rim Light | Normal map effectiveness to rim lit areas. | + +

+ +## Example of Normal Map Effectiveness Operation + + + + diff --git a/BJH/Assets/BJH/3dtest/Documentation~/Outline.md b/BJH/Assets/BJH/3dtest/Documentation~/Outline.md new file mode 100644 index 0000000..59e765c --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/Outline.md @@ -0,0 +1,98 @@ +# Outline Settings + +Outlines are one of the most important elements that affect the impression of cel-animated images. +You can control the outline thickness numerically, and refine it in more detail using an Outline Width Map. +Outline color can be set directly or blended with the character's base colors. + + + + + +
Drag the slider to compare the images.
+ +UTS provides two methods to generate outlines: +1. Extrude polygons along the mesh normals. +2. Scale the mesh uniformly to create an outline. + +Settings: +* [Outline Mode](#outline-mode) +* [Outline Width](#outline-width) +* [Outline Color](#outline-color) +* [Blend Base Color to Outline](#blend-base-color-to-outline) +* [Outline Width Map](#outline-width-map) +* [Offset Outline with Camera Z-axis](#offset-outline-with-camera-z-axis) +* [Camera Distance for Outline Width](#camera-distance-for-outline-width) + * [Farthest Distance to vanish](#farthest-distance-to-vanish) + * [Nearest Distance to draw with Outline Width](#nearest-distance-to-draw-with-outline-width) +* [Outline Color Map](#outline-color-map) +* [Baked Normal Map](#baked-normal-map) + +## Outline Mode +Specifies how the inverted-outline objects spawn. + +| Outline Mode | Description | +| -- | -- | +| Normal Direction | Stretches polygons in the normal direction. | +| Position Scaling | Applies a scale value to the mesh. | + + + +## Outline Width +Specifies the width of the outline. This value depends on the scale when importing the model to Unity. + +## Outline Color +Specifies the color of the outline. + +## Blend Base Color to Outline +Blends **Base Color** into the outline color. + + + + + +
+Drag the slider to compare the images. + +## Outline Width Map +Outline Width Map as grayscale texture: Texture(linear). + +UTS provides a detailed control solution for outline thickness using a texture map. +Let's take a look at an example. + +![The UV map that contains all the parts of the model, and a square grayscale texture as the Outline Width Map. Most of the Outline Width Map uses a uniform light gray, while the face, legs, and hands are in a darker gray.](images/OutlineWidthMapSources.png)
+Left: a Base Map example. Right: an Outline Width Map example. + +With the above maps applied, regions that are white in the Outline Width Map produce thicker outlines. +This is especially noticeable around the character's eyes and face. + + + + + +
+Drag the slider to compare the images. + + +## Offset Outline with Camera Z-axis +Offsets the outline in the depth (Z) direction of the camera. UTS outline is implemented by either extending polygons in the normal direction or applying a scale value. Sometimes, offsetting the position of the generated polygons in the Z (depth) direction can improve their appearance. + + + + + +
+Drag the slider to compare the images. + +## Camera Distance for Outline Width + +### Farthest Distance to vanish +Specifies the furthest distance where the outline width changes with the distance between the camera and the object. The outline will be zero at this distance. + +### Nearest Distance to draw with Outline Width +Specifies the closest distance where the outline width changes with the distance between the camera and the object. At this distance, the outline will be the maximum width set by Outline_Width. + +## Outline Color Map +Apply a texture as the outline color map. + +## Baked Normal Map +Normal maps with vertex normals baked in from other models can be loaded as an addition when setting up normal inversion outlines. \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Documentation~/Parameter-Settings.md b/BJH/Assets/BJH/3dtest/Documentation~/Parameter-Settings.md new file mode 100644 index 0000000..1b51f87 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/Parameter-Settings.md @@ -0,0 +1,19 @@ +# Shader Settings in the Inspector Window + +The following are all the **Unity Toon Shader** settings in the Inspector window. + + * [Modes](Modes.md) + * [Shader Settings](Shader.md) + * [Three Color Map and Control Map Settings](Basic.md) + * [Shading Step and Feather Settings](ShadingStepAndFeather.md) + * [Normal Map Settings](NormalMap.md) + * [Highlight Settings](Highlight.md) + * [Rim Light Settings](Rimlight.md) + * [Material Capture (MatCap) Settings](MatCap.md) + * [Emission Settings](Emission.md) + * [Angel Ring Projection Settings](AngelRing.md) + * [Scene Light Effectiveness Settings](SceneLight.md) + * [Metaverse Settings(Experimental)](Metaverse.md) + * [Outline Settings](Outline.md) + * [Tessellation Settings(the Built-in Render Pipeline)](TessellationLegacy.md) + * [Tessellation Settings(HDRP)](TessellationHDRP.md) \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Documentation~/Rimlight.md b/BJH/Assets/BJH/3dtest/Documentation~/Rimlight.md new file mode 100644 index 0000000..8677a44 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/Rimlight.md @@ -0,0 +1,115 @@ +# Rim Light Settings + +Rim Light highlights the edges of meshes. Rim Light is based on the angle between the surface normal and view direction. The **Unity Toon Shader** provides a variety of options for Rim Light. + +* [Rim Light](#rim-light) + * [Rim Light Color](#rim-light-color) + * [Rim Light Level](#rim-light-level) + * [Adjust Rim Light Area](#adjust-rim-light-area) + * [Rim Light Feather Off](#rim-light-feather-off) + * [Light Direction](#light-direction) + * [Light Direction Rim Light Level](#light-direction-rim-light-level) + * [Inverted Light Direction Rim Light](#inverted-light-direction-rim-light) + * [Inverted Rim Light Color](#inverted-light-direction-rim-light) + * [Inverted Rim Light Level](#inverted-rim-light-level) + * [Inverted Rim Light Feather Off](#inverted-rim-light-level) + + * [Rim Light Mask](#rim-light-mask) + * [Rim Light Mask Level](#rim-light-mask-level) + +## Rim Light +A checkbox to enable **Rim Light** that hits the 3D model from behind and emphasizes the contours of the model from the front. + + + + + +
+Drag the slider to compare the images. + +### Rim Light Color +Specifies the color of **Rim Light**. + +### Rim Light Level +Specifies **Rim Light** intensity. + + +
+ +### Adjust Rim Light Area +Increasing this value narrows the area of influence of **Rim Light**. + + +
+ +### Rim Light Feather Off +A check box to disable **Rim Light** feather. + + + + + +
+Drag the slider to compare the images. + +### Light Direction +A Checkbox to enable light direction. When Enabled, generates **Rim Light** in the direction of the light source. + + + + + +
+Drag the slider to compare the images. + +### Light Direction Rim Light Level +Specifies intensity of **Rim Light** in the light source direction. + +### Inverted Light Direction Rim Light +Light color effectiveness to inverted direction rim lit areas. + + + + + +
+Drag the slider to compare the images. + + +#### Inverted Rim Light Color +Specifies the color of inverted/antipodean **Rim Light**. + + +#### Inverted Rim Light Level +Specifies Inverted/Antipodean **Rim Light** Level. + + +#### Inverted Rim Light Feather Off +Disable Inverted **Rim Light** feather. + + + + + +
+Drag the slider to compare the images. + +### Rim Light Mask +Rim Light Mask : a gray scale texture(linear). The white part of the texture represents **Rim Light**, and the black part masks. + +![A square checkerboard pattern of black and gray squares. Each square has a plus symbol at its center.](images/UVCheckGrid.png)
+Grayscale texture example. + + + + + + +
+Drag the slider to compare the images. + + +### Rim Light Mask Level +-1 gives 0% for the Rim Light effect, 0 gives 100% for the Rim Light and Mask effect, 1 gives 100% for the Rim Light and 0% for the Mask effect. + + diff --git a/BJH/Assets/BJH/3dtest/Documentation~/SampleInstallation.md b/BJH/Assets/BJH/3dtest/Documentation~/SampleInstallation.md new file mode 100644 index 0000000..bac7f10 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/SampleInstallation.md @@ -0,0 +1,54 @@ +# Installing the sample scenes + +The **Unity Toon Shader (UTS)** package provides +sample scenes for every supported render pipeline. +Import the sample set that matches the render pipeline currently assigned to your project. + +## Before you import + +- Confirm that the [render pipeline](https://docs.unity3d.com/6000.0/Documentation/Manual/render-pipelines.html) you intend to use is installed and active. + +## Import samples through Package Manager + +1. Open the [Package Manager](https://docs.unity3d.com/6000.0/Documentation/Manual/Packages.html). +2. Select **Unity Toon Shader** from the package list. +3. In the **Samples** section, choose the collection that matches your render pipeline. +4. Click **Import**. Unity creates an `Assets/Samples/Unity Toon Shader//...` folder containing the selected samples. + +> Tip: You can re-import the samples at any time. Unity prompts you before overwriting existing files. + +## Sample scene overview + +### Universal Render Pipeline + +`Assets/Samples/Unity Toon Shader//URP` + +- `AngelRing/AngelRing.unity` — Setup for the [Angel Ring](AngelRing.md) feature. +- `Cube_HardEdge/Cube_HardEdge.unity` — Reference for baked normals. +- `BoxProjection/BoxProjection.unity` — Dark room lighting with box projection probes. +- `EmissiveAnimation/EmissiveAnimation.unity` — Animated [Emission](Emission.md) sequences. +- `LightAndShadows/LightAndShadows.unity` — Comparison between the PBR shader and UTS. +- `MatCapMask/MatCapMask.unity` — Using [MatCap](MatCap.md) masks. +- `Mirror/MirrorTest.unity` — Mirror material setup and testing. +- `NormalMap/NormalMap.unity` — Normal map techniques tuned with UTS. +- `PointLightTest/PointLightTest.unity` — Cel-shading examples using point lights. +- `KageBall/KageBall.unity` — The basics. +- `UnityChan/UnityChan.unity` — SD Unity-chan model showcasing illustration-style shading. +- `UnityChan_CelLook/UnityChan_CelLook.unity` — SD Unity-chan model with classic cel-look settings for characters. +- `UnityChan_Emissive/UnityChan_Emissive.unity` — SD Unity-chan model showing the [Emission](Emission.md) feature. +- `UnityChan_Firefly/UnityChan_Firefly.unity` — SD Unity-chan model with multiple point lights. + +> Unity-chan assets are licensed under the [Unity-Chan License](http://unity-chan.com/contents/guideline_en/) + +### Built-in Render Pipeline + +`Assets/Samples/Unity Toon Shader//Built-In RP` + +- Mirrors the URP scenes but configured for built-in render pipeline. + +### High Definition Render Pipeline + +`Assets/Samples/Unity Toon Shader//HDRP` + +- Mirrors the URP scenes but configured for HDRP. + diff --git a/BJH/Assets/BJH/3dtest/Documentation~/SceneLight.md b/BJH/Assets/BJH/3dtest/Documentation~/SceneLight.md new file mode 100644 index 0000000..395d039 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/SceneLight.md @@ -0,0 +1,51 @@ +# Scene Light Effectiveness Settings + +The **Unity Toon Shader** provides a way to control the effectiveness of lights in the scene per material. There are times when you want to eliminate or limit the effect of lighting on a material type. +UTS allows you to control each area color regardless of the actual light color. While this feature is fundamental to professional cel-shading, sometimes it's necessary to apply actual light colors. +UTS provides a way to determine whether the actual light color affects the material or not. + +* [Light Color Effectiveness Settings](#light-color-effectiveness) +* [Light Probe Intensity](#light-probe-intensity) +* [Limit Light Intensity](#limit-light-intensity) + +

+ +## Light Color Effectiveness + +If the setting for each color is off, the color is always illuminated with a light intensity of 1 and a light color of white regardless of the intensity of the lights in the scene. + +| Property | Description | +| --| --| +| Base Color | Light color effect in the base color areas. | +| 1st Shading Color | Light color effect in the 1st shading color areas. | +| 2nd Shading Color | Light color effect in the 2nd shading color areas. | +| Highlight | Light color effect in high lit areas. | +| Rim Light | Light color effect in rim lit areas. | +| Inverted Light Direction Rim Light | Light color effect in inverted direction rim lit areas. | +| Angel Ring | Light color effect in angel ring areas. Angel Ring is exclusive to **With Additional Control Maps** mode.| +| MatCap | Light color effect in MatCap areas. | +| Outline | Light color effect in outlines. | + +Light Color Effectiveness example: A red light on the face. Unchecked areas on the face material are not affected by the light color. + + + + + +
Drag the slider to compare the images. + +## Light Probe Intensity + +Adds the light probe color to the material color according to the **Light Probe Intensity** value. + +## Limit Light Intensity + +Limit the brightness of the light to 1 to avoid white-out. + +Example: When a intensive directional light is on the character. + + + + + +
Drag the slider to compare the images. diff --git a/BJH/Assets/BJH/3dtest/Documentation~/Shader.md b/BJH/Assets/BJH/3dtest/Documentation~/Shader.md new file mode 100644 index 0000000..3e95dcc --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/Shader.md @@ -0,0 +1,69 @@ +# Shader Settings + +The Shader Settings provide basic settings that aren't specific to cel-shading but are necessary for general computer graphics. + +* [Culling Mode](#culling-Mode) +* [Auto Render Queue](#auto-render-queue) + * [Render Queue](#render-queue) +* [Transparency](#transparency) +* [Stencil](#stencil) + * [Stencil Value](#stencil-value) +* [Clipping](#clipping) + * [Clipping Mask](#clipping-mask) + * [Invert Clipping Mask](#invert-clipping-mask) + * [Clipping Level](#clipping-level) + * [Transparency Level](#transparency-level) + * [Use Base Map Alpha as Clipping Mask](#use-base-map-alpha-as-clipping-mask) + +## Culling Mode + +| Culling Mode | Description | +| ---- | ---- | +| Back | Don't render polygons that are facing away from the viewer (default), i.e., back-facing polygons are culled. | +| Front | Don't render polygons that are facing towards the viewer. Used for turning objects inside-out. | +| Off | Disables culling—all faces are drawn. Used for special effects. | + +## Auto Render Queue +When enabled, the system automatically determines rendering order. + +### Render Queue +Rendering order in the scene. + +## Transparency +Enables different modes that allow the simulation of a variety of transparent objects. + +## Stencil +Control the stencil buffer which manipulates pixel drawing. + +| Stencil | Description | +| ---- | ---- | +| Replace Stencil Buffer with | Replaces a pixel value in stencil buffer with [Stencil Value](#stencil-value) when drawing.| +| Draw If Not Equal to | Draw a pixel when the number in stencil buffer isn't equal to [Stencil Value](#stencil-value).| +| Off | Nothing is written to stencil buffer and [Stencil Value](#stencil-value) doesn't affect at all when drawing.| + +### Stencil Value +Stencil value that's submitted to the stencil buffer for controlling the per-pixel drawing. Min is 0. Max is 255. The default is 0. + +## Clipping +Allow for the use of a texture to control the transparency of the shader. + +| Clipping | Description | +| ---- | ---- | +| Off | Disable clipping. | +| On | Enable clipping. | +| Clip Transparency | [Enable clipping with Transparency Level](#transparency-level). | + +### Clipping Mask +A gray scale texture which utilises its brightness to control transparency. + +### Invert Clipping Mask +Invert clipping mask results. + +### Clipping Level +Specifies the strength of the clipping mask. + +### Transparency Level +Adjusts the transparency by considering the gray scale level of the clipping mask as an alpha value. + +### Use Base Map Alpha as Clipping Mask +Use Base Map Alpha as Clipping Mask instead of Clipping mask texture. diff --git a/BJH/Assets/BJH/3dtest/Documentation~/ShadingStepAndFeather.md b/BJH/Assets/BJH/3dtest/Documentation~/ShadingStepAndFeather.md new file mode 100644 index 0000000..a134c14 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/ShadingStepAndFeather.md @@ -0,0 +1,64 @@ +# Shading Steps and Feather Settings + +The **Unity Toon Shader** allows you to control the position of area boundaries, to clearly demarcate the boundaries, or to blur or blend them. + +* [Base Color Step](#base-color-step) +* [Base Shading Feather](#base-shading-feather) +* [Shading Color Step](#shading-color-step) +* [1st/2nd Shading Feather](#1st2nd-shading-feather) +* [Receive Shadows](#receive-shadows) + * [System Shadow Level](#system-shadow-level) +* [Point Light Settings](#point-light-settings) + * [Step Offset](#step-offset) + * [Filter Point Light Highlights](#filter-point-light-highlights) + + +### Base Color Step +Sets the boundary between the Base Color and the Shade Colors. + + + +## Base Shading Feather +Feathers the boundary between the Base Color and the Shade Colors. + + + +## Shading Color Step +Sets the boundary between the 1st and 2nd Shade Colors. Set this to 0 if the 2nd Shade Color is unnecessary. + + + + +### 1st/2nd Shading Feather +Feathers the boundary between the 1st and 2nd Shade Colors. + + + +### Receive Shadows +Determine if the material reflects shadows. + + + + +#### System Shadow Level +Define the appearance of self-shadows and other received shadows that blend with the Too Shader. + + + + +## Point Light Settings + +### Step Offset +Fine tunes light steps (boundaries) added in the ForwardAdd pass, such as real-time point lights. + + + + + + + +### Filter Point Light Highlights +Show or hide highlight of point lights. + + + diff --git a/BJH/Assets/BJH/3dtest/Documentation~/TableOfContents.md b/BJH/Assets/BJH/3dtest/Documentation~/TableOfContents.md new file mode 100644 index 0000000..a6f16c4 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/TableOfContents.md @@ -0,0 +1,29 @@ +* [Unity Toon Shader](index.md) +* [Installation](installation.md) +* [Getting started](GettingStarted.md) +* [Inspector Window Settings](Parameter-Settings.md) + * [Modes](Modes.md) + * [Shader](Shader.md) + * [Three Color Map and Control Map](Basic.md) + * [Shading Step and Feather](ShadingStepAndFeather.md) + * [Normal Map](NormalMap.md) + * [Highlight](Highlight.md) + * [Rim Light](Rimlight.md) + * [Material Capture (MatCap)](MatCap.md) + * [Angel Ring Projection](AngelRing.md) + * [Emission](Emission.md) + * [Outline](Outline.md) + * Tessellation + * [HDRP](TessellationHDRP.md) + * [Built-in Render Pipeline](TessellationLegacy.md) + * [Tessellation (HDRP)](TessellationHDRP.md) + * [Scene Light Effectiveness](SceneLight.md) + * [Metaverse (Experimental)](Metaverse.md) +* Additional features for HDRP + * [Box Light](HDRPBoxLight.md) + * [Toon EV Adjustment](ToonEVAdjustment.md) +* [Material Converter](MaterialConverter.md) +* [Samples](SampleInstallation.md) +* [Feature Difference](FeatureModel_en.md) +* [Known Issues](Known-issue.md) + diff --git a/BJH/Assets/BJH/3dtest/Documentation~/TessellationHDRP.md b/BJH/Assets/BJH/3dtest/Documentation~/TessellationHDRP.md new file mode 100644 index 0000000..bf30d41 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/TessellationHDRP.md @@ -0,0 +1,14 @@ +# Tessellation Settings (HDRP) + + +## Properties + +| Property| Description | +|-------------------|-------------------| +|Tessellation Mode| Controls the Phong tessellation. It smooths the result of displacement.| +|Tessellation Factor| Controls the strength of the tessellation effect. Higher values result in more tessellation. Max tessellation factor is 15 on the Xbox One and PS4.| +|Start Fade Distance| Sets the distance (in meter) at which tessellation begins to fade out.| +|End Fade Distance| Sets the maximum distance (in meter) to the Camera where HDRP tessellates triangle.| +|Triangle Size| Sets the desired screen space size of triangles (in pixels). Smaller values result in smaller triangle.| +|Shape Factor| Controls the strength of Phong tessellation shape (lerp factor).| +|Triangle Culling Epsilon| Controls triangle culling. A value of -1.0 disables back face culling for tessellation, higher values produce more aggressive culling and better performance.| diff --git a/BJH/Assets/BJH/3dtest/Documentation~/TessellationLegacy.md b/BJH/Assets/BJH/3dtest/Documentation~/TessellationLegacy.md new file mode 100644 index 0000000..2db019e --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/TessellationLegacy.md @@ -0,0 +1,12 @@ +# Tessellation Settings (the Built-in Render Pipeline) + +## Properties + +| Property| Description | +|-------------------|-------------------| +| Edge Length| Divides the tessellation according to the camera's distance. The smaller the value, the smaller the tiles become. | +| Phong Strength| Adjusts the pulling strength of the surfaces divided by tessellation. | +| Extrusion Amount| Scales the expanded parts due to tessellation. | + + + diff --git a/BJH/Assets/BJH/3dtest/Documentation~/ToonEVAdjustment.md b/BJH/Assets/BJH/3dtest/Documentation~/ToonEVAdjustment.md new file mode 100644 index 0000000..b52f805 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/ToonEVAdjustment.md @@ -0,0 +1,28 @@ +# Toon EV Adjustment + +![Three examples of a chibi-style character model in front of a golden globe with the Unity logo. In the first, the model is under a very bright light. In the second, the model is under more natural light. In the third, the model is under a moderately bright light.](images/TooEvAdjustmenEfficiency2.png) + +**Toon EV Adjustment** is only available for HDRP. When combined with post-effects, such as the Exposure Volume Profile, is designed to render optically correct images without collapsing even in bright environments as intense as 130,000 lux. But, because the **Unity Toon Shader** uses a totally different logic to render toons, the automatic correction built in HDRP isn't enough to get the picture the artist wants. **Toon EV Adjustment** supports artists' corrections in two ways. + +## Scene Toon EV Adjustment + +Over the scene, **Scene Toon EV Adjustment** can control exposure level by applying EV curve for **Unity Toon Shader**. + +### The way to enable **Scene Toon EV Adjustment** +1. `GameObject/Toon Shader/Scene Toon EV Adjustment` from the Unity Editor menu to create **Scene Toon EV Adjustment Component** component. +2. Put models you want to control exposure to its inspector. + +Just one **Scene Toon EV Adjustment Component** can be placed in a scene. + + +## Model Toon EV Adjustment +**Toon EV Adjustment** can works to a certain model by choosing `GameObject/Toon Shader/Attatch Model Toon EV Adjustment` when the model is selected. + + +## Properties + +| Property| Description | +|:-------------------|:-------------------| +| Ignore Volume Exposure | Ignore the automatic corrections built into HDRP. If this checkbox is On, lights brighter than 1 will result in more blown whites and a much more exaggerated Bloom. But, this method is suitable if you are using Light Culling or similar to shine independent lights of 1 lux or less on your character.| +| Light High Cut Filter | Clips up to 1 lux of light hitting objects with Toon Shader materials.| +| Toon EV adjustment curve | The correction applied with an editable curve; since it would be impossible for an artist to draw a curve that controls from 0 lux to 130000 lux, **Toon EV Adjustment** adopted EV to express the brightness unit in this screen. The default curve ranges from –10 EV to –1.32 EV.| diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/1st2ndShadeFeather.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/1st2ndShadeFeather.mp4 new file mode 100644 index 0000000..f77eb25 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/1st2ndShadeFeather.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/AR_Image.png b/BJH/Assets/BJH/3dtest/Documentation~/images/AR_Image.png new file mode 100644 index 0000000..e4309b3 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/AR_Image.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/AdjustRimLightArea.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/AdjustRimLightArea.mp4 new file mode 100644 index 0000000..d81b9b9 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/AdjustRimLightArea.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/AdjustingFeather.png b/BJH/Assets/BJH/3dtest/Documentation~/images/AdjustingFeather.png new file mode 100644 index 0000000..4c25ae9 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/AdjustingFeather.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/AngelRingOffsetUV_1.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/AngelRingOffsetUV_1.mp4 new file mode 100644 index 0000000..9a6736f Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/AngelRingOffsetUV_1.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/AngelRingWithAlpha_Output.png b/BJH/Assets/BJH/3dtest/Documentation~/images/AngelRingWithAlpha_Output.png new file mode 100644 index 0000000..c97462c Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/AngelRingWithAlpha_Output.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/AppliedTextures.png b/BJH/Assets/BJH/3dtest/Documentation~/images/AppliedTextures.png new file mode 100644 index 0000000..53dbcb7 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/AppliedTextures.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/AppliedUTS.png b/BJH/Assets/BJH/3dtest/Documentation~/images/AppliedUTS.png new file mode 100644 index 0000000..78bdfbb Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/AppliedUTS.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/BaseShadingFeather.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/BaseShadingFeather.mp4 new file mode 100644 index 0000000..4568e82 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/BaseShadingFeather.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/BlendBaseColorToOutlineOff.png b/BJH/Assets/BJH/3dtest/Documentation~/images/BlendBaseColorToOutlineOff.png new file mode 100644 index 0000000..1396b2b Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/BlendBaseColorToOutlineOff.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/BlendBaseColorToOutlineOn.png b/BJH/Assets/BJH/3dtest/Documentation~/images/BlendBaseColorToOutlineOn.png new file mode 100644 index 0000000..4f89571 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/BlendBaseColorToOutlineOn.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/BoldOutline2.png b/BJH/Assets/BJH/3dtest/Documentation~/images/BoldOutline2.png new file mode 100644 index 0000000..795dc85 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/BoldOutline2.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/BoxLight0.png b/BJH/Assets/BJH/3dtest/Documentation~/images/BoxLight0.png new file mode 100644 index 0000000..89c636d Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/BoxLight0.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/BoxLight1.png b/BJH/Assets/BJH/3dtest/Documentation~/images/BoxLight1.png new file mode 100644 index 0000000..df64f36 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/BoxLight1.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/ColorShiftingWithTime.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/ColorShiftingWithTime.mp4 new file mode 100644 index 0000000..11d06f1 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/ColorShiftingWithTime.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/ColorShiftingWithView.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/ColorShiftingWithView.mp4 new file mode 100644 index 0000000..3a1e232 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/ColorShiftingWithView.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/ColorStep.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/ColorStep.mp4 new file mode 100644 index 0000000..3dbbb9a Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/ColorStep.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/ConverterError.png b/BJH/Assets/BJH/3dtest/Documentation~/images/ConverterError.png new file mode 100644 index 0000000..6cd0e0c Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/ConverterError.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/ConverterScanButton.png b/BJH/Assets/BJH/3dtest/Documentation~/images/ConverterScanButton.png new file mode 100644 index 0000000..227f132 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/ConverterScanButton.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/ConverterScreen.png b/BJH/Assets/BJH/3dtest/Documentation~/images/ConverterScreen.png new file mode 100644 index 0000000..cf73202 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/ConverterScreen.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/ConverterWindowOption.png b/BJH/Assets/BJH/3dtest/Documentation~/images/ConverterWindowOption.png new file mode 100644 index 0000000..7129311 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/ConverterWindowOption.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/DecoPlane_Nromal.png b/BJH/Assets/BJH/3dtest/Documentation~/images/DecoPlane_Nromal.png new file mode 100644 index 0000000..5d0bd52 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/DecoPlane_Nromal.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/DepthPrimingModeAuto.png b/BJH/Assets/BJH/3dtest/Documentation~/images/DepthPrimingModeAuto.png new file mode 100644 index 0000000..a2fc7f5 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/DepthPrimingModeAuto.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/DepthPrimingModeDisabled.png b/BJH/Assets/BJH/3dtest/Documentation~/images/DepthPrimingModeDisabled.png new file mode 100644 index 0000000..bccfdbe Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/DepthPrimingModeDisabled.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/EmissionAnimation.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/EmissionAnimation.mp4 new file mode 100644 index 0000000..e45fd79 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/EmissionAnimation.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/EmissionMapBaseSpeedHalf.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/EmissionMapBaseSpeedHalf.mp4 new file mode 100644 index 0000000..82e2dbc Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/EmissionMapBaseSpeedHalf.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/EmissionMapBaseSpeedOneAndHalf.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/EmissionMapBaseSpeedOneAndHalf.mp4 new file mode 100644 index 0000000..3446cbe Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/EmissionMapBaseSpeedOneAndHalf.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/EmissionMapSample.png b/BJH/Assets/BJH/3dtest/Documentation~/images/EmissionMapSample.png new file mode 100644 index 0000000..87df496 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/EmissionMapSample.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/EmissionMapViewCoordinateScroll.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/EmissionMapViewCoordinateScroll.mp4 new file mode 100644 index 0000000..4aab062 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/EmissionMapViewCoordinateScroll.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/EmissiveAnimation.png b/BJH/Assets/BJH/3dtest/Documentation~/images/EmissiveAnimation.png new file mode 100644 index 0000000..5387ae5 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/EmissiveAnimation.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/FilterHilightOnPointLight-2.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/FilterHilightOnPointLight-2.mp4 new file mode 100644 index 0000000..a7167ff Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/FilterHilightOnPointLight-2.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/FilterPointLightHighlight-Ball.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/FilterPointLightHighlight-Ball.mp4 new file mode 100644 index 0000000..1f72067 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/FilterPointLightHighlight-Ball.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/HairNormalMask.png b/BJH/Assets/BJH/3dtest/Documentation~/images/HairNormalMask.png new file mode 100644 index 0000000..6b2f9cf Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/HairNormalMask.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/HiLight_Matcap.png b/BJH/Assets/BJH/3dtest/Documentation~/images/HiLight_Matcap.png new file mode 100644 index 0000000..b985791 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/HiLight_Matcap.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/Highlight0.png b/BJH/Assets/BJH/3dtest/Documentation~/images/Highlight0.png new file mode 100644 index 0000000..615ed5f Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/Highlight0.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/Highlight1.png b/BJH/Assets/BJH/3dtest/Documentation~/images/Highlight1.png new file mode 100644 index 0000000..00c586a Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/Highlight1.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/HighlightBlendingLevel.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/HighlightBlendingLevel.mp4 new file mode 100644 index 0000000..13bc2af Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/HighlightBlendingLevel.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/HighlightMaskLevel.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/HighlightMaskLevel.mp4 new file mode 100644 index 0000000..2a44e9f Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/HighlightMaskLevel.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/HighlightMaskOff.png b/BJH/Assets/BJH/3dtest/Documentation~/images/HighlightMaskOff.png new file mode 100644 index 0000000..a3868b6 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/HighlightMaskOff.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/HighlightMaskOn.png b/BJH/Assets/BJH/3dtest/Documentation~/images/HighlightMaskOn.png new file mode 100644 index 0000000..116b61d Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/HighlightMaskOn.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/InspectorMode.png b/BJH/Assets/BJH/3dtest/Documentation~/images/InspectorMode.png new file mode 100644 index 0000000..d63915a Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/InspectorMode.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/InversedLightDirectionRimLightOff.png b/BJH/Assets/BJH/3dtest/Documentation~/images/InversedLightDirectionRimLightOff.png new file mode 100644 index 0000000..4c2eb8e Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/InversedLightDirectionRimLightOff.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/InversedLightDirectionRimLightOn.png b/BJH/Assets/BJH/3dtest/Documentation~/images/InversedLightDirectionRimLightOn.png new file mode 100644 index 0000000..392740a Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/InversedLightDirectionRimLightOn.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/InversedRimLightFeathterOff.png b/BJH/Assets/BJH/3dtest/Documentation~/images/InversedRimLightFeathterOff.png new file mode 100644 index 0000000..eacbd98 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/InversedRimLightFeathterOff.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/InversedRimLightFeathterOn.png b/BJH/Assets/BJH/3dtest/Documentation~/images/InversedRimLightFeathterOn.png new file mode 100644 index 0000000..5f4b38b Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/InversedRimLightFeathterOn.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/InvertMatCapMask.png b/BJH/Assets/BJH/3dtest/Documentation~/images/InvertMatCapMask.png new file mode 100644 index 0000000..f64db77 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/InvertMatCapMask.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/LimitLightIntensityOff.png b/BJH/Assets/BJH/3dtest/Documentation~/images/LimitLightIntensityOff.png new file mode 100644 index 0000000..f19dbcd Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/LimitLightIntensityOff.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/LimitLightIntensityOn.png b/BJH/Assets/BJH/3dtest/Documentation~/images/LimitLightIntensityOn.png new file mode 100644 index 0000000..3efb586 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/LimitLightIntensityOn.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/Luster3.png b/BJH/Assets/BJH/3dtest/Documentation~/images/Luster3.png new file mode 100644 index 0000000..0f75106 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/Luster3.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/MatCap.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCap.mp4 new file mode 100644 index 0000000..84dc4b6 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCap.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/MatCap.png b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCap.png new file mode 100644 index 0000000..56aae08 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCap.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapBlendingOnShadowOff.png b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapBlendingOnShadowOff.png new file mode 100644 index 0000000..b8d5569 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapBlendingOnShadowOff.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapBlendingOnShadowOn.png b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapBlendingOnShadowOn.png new file mode 100644 index 0000000..41b6f2c Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapBlendingOnShadowOn.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapBlurLebel.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapBlurLebel.mp4 new file mode 100644 index 0000000..5fcef7b Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapBlurLebel.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapMaskLevel.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapMaskLevel.mp4 new file mode 100644 index 0000000..f2a53f4 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapMaskLevel.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapMaskSample.png b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapMaskSample.png new file mode 100644 index 0000000..ac26263 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapMaskSample.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapNormalMapOff.png b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapNormalMapOff.png new file mode 100644 index 0000000..86e6673 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapNormalMapOff.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapNormalMapOn.png b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapNormalMapOn.png new file mode 100644 index 0000000..d835dc9 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapNormalMapOn.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapOnShadowLevel.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapOnShadowLevel.mp4 new file mode 100644 index 0000000..c9af6e4 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/MatCapOnShadowLevel.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/MaterialConverterMenu.png b/BJH/Assets/BJH/3dtest/Documentation~/images/MaterialConverterMenu.png new file mode 100644 index 0000000..b5aff08 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/MaterialConverterMenu.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/NormalMapStrength00.png b/BJH/Assets/BJH/3dtest/Documentation~/images/NormalMapStrength00.png new file mode 100644 index 0000000..113866f Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/NormalMapStrength00.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/NormalMapStrength03.png b/BJH/Assets/BJH/3dtest/Documentation~/images/NormalMapStrength03.png new file mode 100644 index 0000000..c709d6e Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/NormalMapStrength03.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/NormalMapStrength1.png b/BJH/Assets/BJH/3dtest/Documentation~/images/NormalMapStrength1.png new file mode 100644 index 0000000..3cb3bfd Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/NormalMapStrength1.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/Normalmapeffectiveness.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/Normalmapeffectiveness.mp4 new file mode 100644 index 0000000..13432d5 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/Normalmapeffectiveness.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/OffsetZ02.png b/BJH/Assets/BJH/3dtest/Documentation~/images/OffsetZ02.png new file mode 100644 index 0000000..445b914 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/OffsetZ02.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/OffsetZ03.png b/BJH/Assets/BJH/3dtest/Documentation~/images/OffsetZ03.png new file mode 100644 index 0000000..f2ceffc Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/OffsetZ03.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineOff.png b/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineOff.png new file mode 100644 index 0000000..4f14ba5 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineOff.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineOn.png b/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineOn.png new file mode 100644 index 0000000..dde6d7e Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineOn.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineWidthMap3.png b/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineWidthMap3.png new file mode 100644 index 0000000..a0ce059 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineWidthMap3.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineWidthMapOff.png b/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineWidthMapOff.png new file mode 100644 index 0000000..b1e7891 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineWidthMapOff.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineWidthMapOn.png b/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineWidthMapOn.png new file mode 100644 index 0000000..27d9965 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineWidthMapOn.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineWidthMapSources.png b/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineWidthMapSources.png new file mode 100644 index 0000000..ee5f1cb Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/OutlineWidthMapSources.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/PingPongMove.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/PingPongMove.mp4 new file mode 100644 index 0000000..f874122 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/PingPongMove.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/PointLightStepOffset-Ball3.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/PointLightStepOffset-Ball3.mp4 new file mode 100644 index 0000000..a2f6b68 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/PointLightStepOffset-Ball3.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/PointLightStepOffset.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/PointLightStepOffset.mp4 new file mode 100644 index 0000000..a02fd7e Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/PointLightStepOffset.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/RecieveSystemShadow.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/RecieveSystemShadow.mp4 new file mode 100644 index 0000000..2f9828c Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/RecieveSystemShadow.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightDirectionOff.png b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightDirectionOff.png new file mode 100644 index 0000000..85edd94 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightDirectionOff.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightDirectionOn.png b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightDirectionOn.png new file mode 100644 index 0000000..59a19c6 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightDirectionOn.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightFeatherOff.png b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightFeatherOff.png new file mode 100644 index 0000000..6a8ef04 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightFeatherOff.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightFeatherOn.png b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightFeatherOn.png new file mode 100644 index 0000000..bf3943c Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightFeatherOn.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightLevel.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightLevel.mp4 new file mode 100644 index 0000000..375033c Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightLevel.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightMaskLevel.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightMaskLevel.mp4 new file mode 100644 index 0000000..dd4bd53 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightMaskLevel.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightMaskOff.png b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightMaskOff.png new file mode 100644 index 0000000..d526743 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightMaskOff.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightMaskOn.png b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightMaskOn.png new file mode 100644 index 0000000..54e8b7d Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightMaskOn.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightOff.png b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightOff.png new file mode 100644 index 0000000..7ca927e Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightOff.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightOn.png b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightOn.png new file mode 100644 index 0000000..cbe8911 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/RimLightOn.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/RotateAroundUVCenter3.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/RotateAroundUVCenter3.mp4 new file mode 100644 index 0000000..47f8e94 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/RotateAroundUVCenter3.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/RotateMatCapNormalMapUV.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/RotateMatCapNormalMapUV.mp4 new file mode 100644 index 0000000..16b4039 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/RotateMatCapNormalMapUV.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/RotateMatCapUV.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/RotateMatCapUV.mp4 new file mode 100644 index 0000000..b4fd015 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/RotateMatCapUV.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/ScaleMatCapUV.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/ScaleMatCapUV.mp4 new file mode 100644 index 0000000..bc1aac7 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/ScaleMatCapUV.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/SceneLightColorEffectivenessOff.png b/BJH/Assets/BJH/3dtest/Documentation~/images/SceneLightColorEffectivenessOff.png new file mode 100644 index 0000000..86109ba Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/SceneLightColorEffectivenessOff.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/SceneLightColorEffectivenessOn.png b/BJH/Assets/BJH/3dtest/Documentation~/images/SceneLightColorEffectivenessOn.png new file mode 100644 index 0000000..4d57732 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/SceneLightColorEffectivenessOn.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/ShadingColorStep.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/ShadingColorStep.mp4 new file mode 100644 index 0000000..4fbf781 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/ShadingColorStep.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/ShadowControlMap0.png b/BJH/Assets/BJH/3dtest/Documentation~/images/ShadowControlMap0.png new file mode 100644 index 0000000..49ee81d Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/ShadowControlMap0.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/ShadowControlMap1.png b/BJH/Assets/BJH/3dtest/Documentation~/images/ShadowControlMap1.png new file mode 100644 index 0000000..82dd17e Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/ShadowControlMap1.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/ShadowControlMap2.png b/BJH/Assets/BJH/3dtest/Documentation~/images/ShadowControlMap2.png new file mode 100644 index 0000000..5a17bf6 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/ShadowControlMap2.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/ShadowControlMap3.png b/BJH/Assets/BJH/3dtest/Documentation~/images/ShadowControlMap3.png new file mode 100644 index 0000000..823690f Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/ShadowControlMap3.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/SpecularAdd.png b/BJH/Assets/BJH/3dtest/Documentation~/images/SpecularAdd.png new file mode 100644 index 0000000..8d58a5c Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/SpecularAdd.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/SpecularHard.png b/BJH/Assets/BJH/3dtest/Documentation~/images/SpecularHard.png new file mode 100644 index 0000000..460e9f6 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/SpecularHard.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/SpecularMultiply.png b/BJH/Assets/BJH/3dtest/Documentation~/images/SpecularMultiply.png new file mode 100644 index 0000000..985a3ff Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/SpecularMultiply.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/SpecularPower.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/SpecularPower.mp4 new file mode 100644 index 0000000..1e491c6 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/SpecularPower.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/SpecularSoft.png b/BJH/Assets/BJH/3dtest/Documentation~/images/SpecularSoft.png new file mode 100644 index 0000000..ebaea42 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/SpecularSoft.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/SphereStandard.png b/BJH/Assets/BJH/3dtest/Documentation~/images/SphereStandard.png new file mode 100644 index 0000000..b109d99 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/SphereStandard.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/SphereWithAdvanced.png b/BJH/Assets/BJH/3dtest/Documentation~/images/SphereWithAdvanced.png new file mode 100644 index 0000000..0a482f2 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/SphereWithAdvanced.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/StabilizerOff.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/StabilizerOff.mp4 new file mode 100644 index 0000000..9c2be7c Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/StabilizerOff.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/StabilizerOn.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/StabilizerOn.mp4 new file mode 100644 index 0000000..fc57f95 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/StabilizerOn.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/SystemShadowLevel.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/SystemShadowLevel.mp4 new file mode 100644 index 0000000..16c6a22 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/SystemShadowLevel.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/TPK_04.png b/BJH/Assets/BJH/3dtest/Documentation~/images/TPK_04.png new file mode 100644 index 0000000..6ef9a34 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/TPK_04.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/ThinOutline2.png b/BJH/Assets/BJH/3dtest/Documentation~/images/ThinOutline2.png new file mode 100644 index 0000000..711a38f Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/ThinOutline2.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/TooEvAdjustmenEfficiency2.png b/BJH/Assets/BJH/3dtest/Documentation~/images/TooEvAdjustmenEfficiency2.png new file mode 100644 index 0000000..0dd6314 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/TooEvAdjustmenEfficiency2.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/UTS4Color2.png b/BJH/Assets/BJH/3dtest/Documentation~/images/UTS4Color2.png new file mode 100644 index 0000000..b7e37da Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/UTS4Color2.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/UVCheckGrid.png b/BJH/Assets/BJH/3dtest/Documentation~/images/UVCheckGrid.png new file mode 100644 index 0000000..c99e3ff Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/UVCheckGrid.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/UnityChanTextures.png b/BJH/Assets/BJH/3dtest/Documentation~/images/UnityChanTextures.png new file mode 100644 index 0000000..f1e8868 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/UnityChanTextures.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/WithMatCap.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/WithMatCap.mp4 new file mode 100644 index 0000000..7b20997 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/WithMatCap.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/WithOutMatCap.mp4 b/BJH/Assets/BJH/3dtest/Documentation~/images/WithOutMatCap.mp4 new file mode 100644 index 0000000..291df9f Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/WithOutMatCap.mp4 differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/WithoutOutline.png b/BJH/Assets/BJH/3dtest/Documentation~/images/WithoutOutline.png new file mode 100644 index 0000000..bd11da8 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/WithoutOutline.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/YukoFace.png b/BJH/Assets/BJH/3dtest/Documentation~/images/YukoFace.png new file mode 100644 index 0000000..03fb0c4 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/YukoFace.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/YukoFace1stShadingMap.png b/BJH/Assets/BJH/3dtest/Documentation~/images/YukoFace1stShadingMap.png new file mode 100644 index 0000000..19433b9 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/YukoFace1stShadingMap.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/YukoFace2ndShadingMap.png b/BJH/Assets/BJH/3dtest/Documentation~/images/YukoFace2ndShadingMap.png new file mode 100644 index 0000000..dde6351 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/YukoFace2ndShadingMap.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/para_height2.png b/BJH/Assets/BJH/3dtest/Documentation~/images/para_height2.png new file mode 100644 index 0000000..d048687 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/para_height2.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/utc_all2_dark.png b/BJH/Assets/BJH/3dtest/Documentation~/images/utc_all2_dark.png new file mode 100644 index 0000000..4ac9fc5 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/utc_all2_dark.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/utc_all2_light.png b/BJH/Assets/BJH/3dtest/Documentation~/images/utc_all2_light.png new file mode 100644 index 0000000..3b19b23 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/utc_all2_light.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/utc_all2_offsetdark.png b/BJH/Assets/BJH/3dtest/Documentation~/images/utc_all2_offsetdark.png new file mode 100644 index 0000000..8df5075 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/utc_all2_offsetdark.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_face3_B.png b/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_face3_B.png new file mode 100644 index 0000000..83377ff Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_face3_B.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_face3_C.png b/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_face3_C.png new file mode 100644 index 0000000..524fbd2 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_face3_C.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_face3_main.png b/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_face3_main.png new file mode 100644 index 0000000..49937a5 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_face3_main.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_hair.png b/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_hair.png new file mode 100644 index 0000000..a30cbc6 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_hair.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_hairB.png b/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_hairB.png new file mode 100644 index 0000000..ff03c7c Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_hairB.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_hairC.png b/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_hairC.png new file mode 100644 index 0000000..e3348a4 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Documentation~/images/yuko_hairC.png differ diff --git a/BJH/Assets/BJH/3dtest/Documentation~/index.md b/BJH/Assets/BJH/3dtest/Documentation~/index.md new file mode 100644 index 0000000..d2d824c --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/index.md @@ -0,0 +1,39 @@ +# Unity Toon Shader overview + +![An image from the toon-shaded film The Phantom Knowledge in the Scene view of the Unity Editor. A close-up of a girl raising a weapon with a ruined cityscape in the background.](images/TPK_04.png) + +The **Unity Toon Shader** (UTS3) is a set of toon shaders designed to meet the needs of creators working on cel-shaded 3D-CG animations. + +The **Unity Toon Shader** is compatible with all render pipelines: the **Built-in Render Pipeline**, the **Universal Render Pipeline (URP)**, and the **High Definition Render Pipeline (HDRP)**. However, there are some differences in the features supported by different render pipelines. Please refer to [Feature Difference](FeatureModel_en.md) for details about each render pipeline. + +**Unity Toon Shader** is the successor to **Unity-chan Toon Shader ver 2.0 (UTS2)**, which was popular for years in games and animations. However, UTS2 was designed solely for the **Built-in Render Pipeline**, consisted of many different shaders, could not be installed through the [Package Manager window](https://docs.unity3d.com/Manual/upm-ui.html), and had a different license from other Unity software. + +## Features of Unity Toon Shader + +In animation production, color specialists specify detailed color designs for every scene. UTS can apply these color specifications as written in the design instructions. UTS allows users to apply specific colors for light and shadow areas regardless of the actual light colors in the scene. This feature is essential for cel-shaded character designs. UTS provides detailed control over whether the directional light color affects materials. + +Typical color design instruction example: + +![A stylized girl in a sailor uniform. A: White highlights on the hair. B: The main blonde hair color. C: Hair in shadow, with a tan color. D: Hair in darker shadow, with a darker tan color.](images/UTS4Color2.png) + +- A: Highlight Color +- B: Base Color +- C: 1st Shading Color +- D: 2nd Shading Color + +Three basic colors—**base color**, **1st shading color**, and **2nd shading color**—play key roles in character design with the **Unity Toon Shader**. Please refer to [Three Color Map and Control Map Settings](Basic.md) for more information. + +Besides the three basic colors, the **Unity Toon Shader** provides a wide variety of features such as [Highlight](Highlight.md), [Rim Light](Rimlight.md), [Emission](Emission.md), [Angel Ring](AngelRing.md), [Material Capture (MatCap)](MatCap.md), and some special maps. + +To get started with cel-shading, see [Getting Started](GettingStarted.md). + +## Render Pipeline Compatibility +The **Unity Toon Shader** works across the **Built-in Render Pipeline**, +**Universal Render Pipeline (URP)**, and **High Definition Render Pipeline (HDRP)**. + +Feature availability can vary slightly between pipelines, +so review the [feature differences](FeatureModel_en.md) document to confirm +which features are supported in your target pipeline. + +> The use of linear color space is strongly recommended. + diff --git a/BJH/Assets/BJH/3dtest/Documentation~/installation.md b/BJH/Assets/BJH/3dtest/Documentation~/installation.md new file mode 100644 index 0000000..76829e8 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Documentation~/installation.md @@ -0,0 +1,11 @@ +# Installation + +The **Unity Toon Shader** is a preview/experimental package. +Installing the package requires the following steps: + +1. Make sure Git is installed on your system. +1. Open the [Package Manager window](https://docs.unity3d.com/Manual/upm-ui.html). +1. Click the **+** button and choose **Add package by name**. +1. Type `com.unity.toonshader` and click the **Add** button. + +You can also specify a particular version, for example: `com.unity.toonshader@0.9.4-preview` diff --git a/BJH/Assets/BJH/3dtest/LICENSE.md b/BJH/Assets/BJH/3dtest/LICENSE.md new file mode 100644 index 0000000..3fc5c8a --- /dev/null +++ b/BJH/Assets/BJH/3dtest/LICENSE.md @@ -0,0 +1,5 @@ +Unity Toon Shader copyright © 2021 Unity Technologies. + +Licensed under the Unity Companion License for Unity-dependent projects--see [Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License). + +Unless expressly provided otherwise, the Software under this license is made available strictly on an “AS IS” BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. Please review the license for details on these and other terms and conditions. diff --git a/BJH/Assets/BJH/3dtest/LICENSE.md.meta b/BJH/Assets/BJH/3dtest/LICENSE.md.meta new file mode 100644 index 0000000..7444215 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/LICENSE.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: b009ebcc6ae97f145bcead5d67654d18 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/NewBlitScriptableRenderPipelineShader.shader b/BJH/Assets/BJH/3dtest/NewBlitScriptableRenderPipelineShader.shader new file mode 100644 index 0000000..cfc9ca8 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/NewBlitScriptableRenderPipelineShader.shader @@ -0,0 +1,31 @@ +Shader "Custom/NewBlitScriptableRenderPipelineShader" +{ + SubShader + { + HLSLINCLUDE + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl" + ENDHLSL + + Tags { "RenderType"="Opaque" } + LOD 100 + ZWrite Off Cull Off + Pass + { + Name "NewBlitScriptableRenderPipelineShader" + + HLSLPROGRAM + + #pragma vertex Vert + #pragma fragment Frag + + float4 Frag (Varyings input) : SV_Target + { + float4 color = SAMPLE_TEXTURE2D(_BlitTexture, sampler_LinearClamp, input.texcoord).rgba; + return color; + } + + ENDHLSL + } + } +} diff --git a/BJH/Assets/BJH/3dtest/NewBlitScriptableRenderPipelineShader.shader.meta b/BJH/Assets/BJH/3dtest/NewBlitScriptableRenderPipelineShader.shader.meta new file mode 100644 index 0000000..8a366bf --- /dev/null +++ b/BJH/Assets/BJH/3dtest/NewBlitScriptableRenderPipelineShader.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c1f0366b8629ef741ba071218dc2497d +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/NewUnlitUniversalRenderPipelineShader.shader b/BJH/Assets/BJH/3dtest/NewUnlitUniversalRenderPipelineShader.shader new file mode 100644 index 0000000..cc818fa --- /dev/null +++ b/BJH/Assets/BJH/3dtest/NewUnlitUniversalRenderPipelineShader.shader @@ -0,0 +1,58 @@ +Shader "Custom/NewUnlitUniversalRenderPipelineShader" +{ + Properties + { + [MainColor] _BaseColor("Base Color", Color) = (1, 1, 1, 1) + [MainTexture] _BaseMap("Base Map", 2D) = "white" {} + } + + SubShader + { + Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" } + + Pass + { + HLSLPROGRAM + + #pragma vertex vert + #pragma fragment frag + + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + + struct Attributes + { + float4 positionOS : POSITION; + float2 uv : TEXCOORD0; + }; + + struct Varyings + { + float4 positionHCS : SV_POSITION; + float2 uv : TEXCOORD0; + }; + + TEXTURE2D(_BaseMap); + SAMPLER(sampler_BaseMap); + + CBUFFER_START(UnityPerMaterial) + half4 _BaseColor; + float4 _BaseMap_ST; + CBUFFER_END + + Varyings vert(Attributes IN) + { + Varyings OUT; + OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz); + OUT.uv = TRANSFORM_TEX(IN.uv, _BaseMap); + return OUT; + } + + half4 frag(Varyings IN) : SV_Target + { + half4 color = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, IN.uv) * _BaseColor; + return color; + } + ENDHLSL + } + } +} diff --git a/BJH/Assets/BJH/3dtest/NewUnlitUniversalRenderPipelineShader.shader.meta b/BJH/Assets/BJH/3dtest/NewUnlitUniversalRenderPipelineShader.shader.meta new file mode 100644 index 0000000..42263ac --- /dev/null +++ b/BJH/Assets/BJH/3dtest/NewUnlitUniversalRenderPipelineShader.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: fa954d381c7327947a896c1d447c6be2 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime.meta b/BJH/Assets/BJH/3dtest/Runtime.meta new file mode 100644 index 0000000..cb30e58 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 41a2dcf1ba3220e4da1fa240a1309952 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/AssemblyInfo.cs b/BJH/Assets/BJH/3dtest/Runtime/AssemblyInfo.cs new file mode 100644 index 0000000..f2e0b18 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/AssemblyInfo.cs @@ -0,0 +1,12 @@ +using System.Runtime.CompilerServices; +[assembly: InternalsVisibleTo("Unity.ToonShader.Tests")] +[assembly: InternalsVisibleTo("Unity.ToonShader.Editor")] +[assembly: InternalsVisibleTo("Unity.ToonShader.EditorTests")] + + +[assembly: InternalsVisibleTo("Unity.VisualCompositor")] +[assembly: InternalsVisibleTo("Unity.VisualCompositor.Tests")] +[assembly: InternalsVisibleTo("Unity.VisualCompositor.Editor")] +[assembly: InternalsVisibleTo("Unity.VisualCompositor.EditorTests")] + + diff --git a/BJH/Assets/BJH/3dtest/Runtime/AssemblyInfo.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/AssemblyInfo.cs.meta new file mode 100644 index 0000000..ecc58ae --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/AssemblyInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e1163a616bae574499d69d7acb21967c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/ClippingMatteMode.cs b/BJH/Assets/BJH/3dtest/Runtime/ClippingMatteMode.cs new file mode 100644 index 0000000..cae0b73 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/ClippingMatteMode.cs @@ -0,0 +1,14 @@ + +namespace Unity.Rendering.Toon { + +internal enum ClippingMatteMode { + None = 0, + Base, + FirstShade, + SecondShade, + Highlight, + AngelRing, +} + + +} \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/ClippingMatteMode.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/ClippingMatteMode.cs.meta new file mode 100644 index 0000000..a138b67 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/ClippingMatteMode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5bafd34f910dcde4887bc821a981c432 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/DebugShadowmap.cs b/BJH/Assets/BJH/3dtest/Runtime/DebugShadowmap.cs new file mode 100644 index 0000000..c11c673 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/DebugShadowmap.cs @@ -0,0 +1,239 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif +using UnityEngine.Rendering; +using UnityEngine.Experimental.Rendering; +using UnityObject = UnityEngine.Object; +namespace Unity.Rendering.Toon +{ + [ExecuteAlways] + [DisallowMultipleComponent] + [RequireComponent(typeof(Camera))] + internal class DebugShadowmap : MonoBehaviour + { + // flags + bool m_initialized = false; + bool m_srpCallbackInitialized = false; + [SerializeField] + internal bool m_enableShadowmapDebugging = false; + [SerializeField] + internal bool m_enableSelfShadowDebugging = false; + [SerializeField] + internal bool m_enableBinalization = false; + [SerializeField] + internal bool m_enableOutlineDebugging = false; + + + + const string kDebugShadowmapDefine = "UTS_DEBUG_SHADOWMAP"; + const string kDebugSelfShadowDefine = "UTS_DEBUG_SELFSHADOW"; + const string kDebugDefineNoOutline = "UTS_DEBUG_SHADOWMAP_NO_OUTLINE"; + const string kDebugDefineBinalization = "UTS_DEBUG_SHADOWMAP_BINALIZATION"; + private static DebugShadowmap instance; +#if UNITY_EDITOR +#pragma warning restore CS0414 + bool m_isCompiling = false; +#endif + + + void Awake() + { + if (instance == null) + { + instance = this as DebugShadowmap; + return; + } + else if (instance == this) + { + return ; + } + Debug.LogError("There is DebugShadowmap instance in hierarchy."); +#if UNITY_EDITOR + DestroyImmediate(this); + Selection.activeGameObject = instance.gameObject; +#else + Destroy(this); +#endif + } + + void Reset() + { + OnDisable(); + OnEnable(); + } + + + void Update() + { + + Initialize(); + +#if UNITY_EDITOR + // handle script recompile + if (EditorApplication.isCompiling && !m_isCompiling) + { + // on compile begin + m_isCompiling = true; + // Release(); no need + return; // + } + else if (!EditorApplication.isCompiling && m_isCompiling) + { + // on compile end + m_isCompiling = false; + } +#endif + ApplyDebuggingFlag(); + } + + void EnableSelfShadowKeyword() + { + Shader.EnableKeyword(kDebugSelfShadowDefine); + } + + void DisableSelfShadowKeyword() + { + Shader.DisableKeyword(kDebugSelfShadowDefine); + } + + + void EnableShadowmapKeyword() + { + Shader.EnableKeyword(kDebugShadowmapDefine); + } + void DisableShadowmapKeyword() + { + Shader.DisableKeyword(kDebugShadowmapDefine); + } + + void EnableOutlineKeyword() + { + Shader.EnableKeyword(kDebugDefineNoOutline); + } + void DisableOutlineKeyword() + { + Shader.DisableKeyword(kDebugDefineNoOutline); + } + + void EnableBinalizationKeyword() + { + Shader.EnableKeyword(kDebugDefineBinalization); + } + void DisableBinalizationKeyword() + { + Shader.DisableKeyword(kDebugDefineBinalization); + } + + void EnableSrpCallbacks() + { + + if (!m_srpCallbackInitialized) + { + m_srpCallbackInitialized = true; + } + } + void DisableSrpCallbacks() + { + if (m_srpCallbackInitialized) + { + m_srpCallbackInitialized = false; + } + } + + void OnEnable() + { + + Initialize(); + + EnableSrpCallbacks(); + + } + + void OnDisable() + { + DisableSrpCallbacks(); + + Release(); + } + + void OnValidate() + { + ApplyDebuggingFlag(); + } + + void ApplyDebuggingFlag() + { + if (! this.enabled) + { + return; + } + if (m_enableShadowmapDebugging) + { + EnableShadowmapKeyword(); + } + else + { + DisableShadowmapKeyword(); + } + if (m_enableSelfShadowDebugging) + { + EnableSelfShadowKeyword(); + } + else + { + DisableSelfShadowKeyword(); + } + + + if (m_enableOutlineDebugging) + { + EnableOutlineKeyword(); + } + else + { + DisableOutlineKeyword(); + } + if (m_enableBinalization) + { + EnableBinalizationKeyword(); + } + else + { + DisableBinalizationKeyword(); + } + } + void Initialize() + { + if (m_initialized) + { + return; + } +#if UNITY_EDITOR + // initializing renderer can interfere GI baking. so wait until it is completed. + + if (EditorApplication.isCompiling) + return; +#endif + + m_initialized = true; + } + + + void Release() + { + if (m_initialized) + { + DisableShadowmapKeyword(); + } + + m_initialized = false; + + } + + } + + +} diff --git a/BJH/Assets/BJH/3dtest/Runtime/DebugShadowmap.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/DebugShadowmap.cs.meta new file mode 100644 index 0000000..a23477f --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/DebugShadowmap.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a7bbfa63eb3f4054f9140fb0c238aba4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP.meta new file mode 100644 index 0000000..561f7b2 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 29660dd543a3ad04ea860b6366d28b54 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/BoxLightAdjustment.cs b/BJH/Assets/BJH/3dtest/Runtime/HDRP/BoxLightAdjustment.cs new file mode 100644 index 0000000..2eb3647 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/BoxLightAdjustment.cs @@ -0,0 +1,304 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif +using UnityEngine.Rendering; +using UnityEngine.Experimental.Rendering; +using UnityObject = UnityEngine.Object; +using System.Linq; + +#if HDRP_IS_INSTALLED_FOR_UTS +using UnityEngine.Rendering.HighDefinition; + +namespace Unity.Rendering.HighDefinition.Toon +{ + [ExecuteAlways] + [DisallowMultipleComponent] + [RequireComponent(typeof(Light))] + internal class BoxLightAdjustment : MonoBehaviour + { + + + // flags + bool m_initialized = false; + bool m_srpCallbackInitialized = false; + + [SerializeField] + GameObject[] m_GameObjects; + + [SerializeField] + Renderer[] m_Renderers; + + + [SerializeField] + internal HDAdditionalLightData m_targetBoxLight; + + [SerializeField] + internal bool m_FollowGameObjectPosition = false; + + [SerializeField] + internal bool m_FollowGameObjectRotation = false; + [SerializeField] + internal Vector3 m_PositionOffset; + [SerializeField] + internal Quaternion m_RotationOffset; +#if UNITY_EDITOR +#pragma warning restore CS0414 + bool m_isCompiling = false; +#endif + + void Reset() + { + OnDisable(); + OnEnable(); + + } + + internal void OnValidate() + { + Release(); + Initialize(); + } + + private void Awake() + { + Initialize(); + + } + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + + Initialize(); + + + +#if UNITY_EDITOR + // handle script recompile + if (EditorApplication.isCompiling && !m_isCompiling) + { + // on compile begin + m_isCompiling = true; + // Release(); no need + return; // + } + else if (!EditorApplication.isCompiling && m_isCompiling) + { + // on compile end + m_isCompiling = false; + } +#endif + if (m_Renderers == null) + { + return; + } + if (m_targetBoxLight == null) + { + return; + } + + for (int ii = 0; ii < m_Renderers.Length; ii++) + { + m_Renderers[ii].renderingLayerMask &= 0xffffff00; + m_Renderers[ii].renderingLayerMask |= (uint)m_targetBoxLight.lightlayersMask; + } + if ( /* m_targetBoxLight != null && */ m_GameObjects != null && m_GameObjects.Length > 0 && m_GameObjects[0] != null ) + { + if (m_FollowGameObjectPosition ) + { + m_targetBoxLight.transform.position = m_GameObjects[0].transform.position + m_PositionOffset; + } + if (m_FollowGameObjectRotation ) + { + m_targetBoxLight.transform.rotation = m_GameObjects[0].transform.rotation * m_RotationOffset; + } + } + } + + void EnableSrpCallbacks() + { + + if (!m_srpCallbackInitialized) + { + m_srpCallbackInitialized = true; + } + } + void DisableSrpCallbacks() + { + if (m_srpCallbackInitialized) + { + m_srpCallbackInitialized = false; + } + } + + void OnEnable() + { + + Initialize(); + + EnableSrpCallbacks(); + + } + + + void OnDisable() + { + DisableSrpCallbacks(); + + Release(); + } + + void UpdateObjectLightLayers() + { + Initialize(); + + } + + internal static GameObject CreateBoxLight(GameObject[] gameObjects) + { + if (gameObjects == null || gameObjects[0] == null ) + { + Debug.LogError("Please, select a GameObject you want a Box Light to follow."); + return null; + } + var gameObjectName = "Box Light for " + gameObjects[0].name; + GameObject lightGameObject = new GameObject(gameObjectName); +#if UNITY_EDITOR + Undo.RegisterCreatedObjectUndo(lightGameObject, "Created Boxlight adjustment"); +#endif + HDAdditionalLightData hdLightData = lightGameObject.AddHDLight(HDLightTypeAndShape.BoxSpot); + // light size + hdLightData.SetBoxSpotSize(new Vector2(10.0f, 10.0f)); // Size should be culculated with more acculacy? + BoxLightAdjustment boxLightAdjustment = lightGameObject.GetComponent(); + if (boxLightAdjustment == null) + { +#if UNITY_EDITOR + boxLightAdjustment = Undo.AddComponent(lightGameObject); +#else + boxLightAdjustment = lightGameObject.AddComponent(); +#endif + } + + + +#if UNITY_EDITOR + Undo.RecordObject(boxLightAdjustment, "target " + boxLightAdjustment.name); +#endif + boxLightAdjustment.m_targetBoxLight = hdLightData; +#if UNITY_EDITOR + Undo.RecordObject(lightGameObject.transform, "Position " + lightGameObject.transform.name); +#endif + // position and rotation + var goPos = lightGameObject.transform.position; + goPos.y += 10.0f; + lightGameObject.transform.position = goPos; + + var goRot = lightGameObject.transform.rotation; + goRot.eulerAngles = new Vector3(90.0f, 0.0f, 0.0f); +#if UNITY_EDITOR + Undo.RecordObject(lightGameObject.transform, "Rotation " + lightGameObject.transform.name); +#endif + hdLightData.gameObject.transform.rotation = goRot; + + // must be put to gameObject model chain. + boxLightAdjustment.m_GameObjects = gameObjects; + + + return lightGameObject; + } + + + void Initialize() + { + if (m_initialized) + { + return; + } +#if UNITY_EDITOR + // initializing renderer can interfere GI baking. so wait until it is completed. + + if (EditorApplication.isCompiling) + return; +#endif + if (m_GameObjects == null ) + { + return; + } + int objCount = m_GameObjects.Length; + int rendererCount = 0; + + List rendererList = new List(); + for (int ii = 0; ii < objCount; ii++) + { + if (m_GameObjects[ii] == null ) + { + continue; + } + + + var renderer = m_GameObjects[ii].GetComponent(); + if (renderer != null) + { + rendererCount++; + rendererList.Add(renderer); + } + GameObject[] childGameObjects = m_GameObjects[ii].GetComponentsInChildren().Select(t => t.gameObject).ToArray(); + int childCount = childGameObjects.Length; + for (int jj = 0; jj < childCount; jj++) + { + if (m_GameObjects[ii] == childGameObjects[jj]) + continue; + var modelToonEvAdjustment = childGameObjects[jj].GetComponent(); + if ( modelToonEvAdjustment != null ) + { + + break; + } + renderer = childGameObjects[jj].GetComponent(); + if ( renderer != null ) + { + rendererList.Add(renderer); + rendererCount++; + } + } + if (rendererCount != 0) + { + + + m_Renderers = rendererList.ToArray(); + + } + } + if (m_targetBoxLight != null && objCount > 0 ) + { + m_PositionOffset = m_targetBoxLight.transform.position - m_GameObjects[0].transform.position; + m_RotationOffset = Quaternion.Inverse(m_GameObjects[0].transform.rotation) * m_targetBoxLight.transform.rotation; + } + + m_initialized = true; + } + + + void Release() + { + if (m_initialized) + { + m_Renderers = null; + } + + m_initialized = false; + + } + + } +} +#endif // HDRP_IS_INSTALLED_FOR_UTS \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/BoxLightAdjustment.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/BoxLightAdjustment.cs.meta new file mode 100644 index 0000000..db4a863 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/BoxLightAdjustment.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1257ea4f6b97f2e44a49fe6ddad1c29a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders.meta new file mode 100644 index 0000000..3974070 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f540b3d0947249b4fb0a16fc4db4dfa1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DebugDisplay.hlsl b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DebugDisplay.hlsl new file mode 100644 index 0000000..6de36b9 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DebugDisplay.hlsl @@ -0,0 +1,263 @@ +#ifdef DEBUG_DISPLAY // Guard define here to be compliant with how shader graph generate code for include + +#ifndef UNITY_DEBUG_DISPLAY_INCLUDED +#define UNITY_DEBUG_DISPLAY_INCLUDED + +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Debug.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/MaterialDebug.cs.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/MipMapDebug.cs.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/ColorPickerDebug.cs.hlsl" + + +// Local shader variables +static SHADOW_TYPE g_DebugShadowAttenuation = 0; + +StructuredBuffer _DebugDepthPyramidOffsets; + +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/PBRValidator.hlsl" + +// When displaying lux meter we compress the light in order to be able to display value higher than 65504 +// The sun is between 100 000 and 150 000, so we use 4 to be able to cover such a range (4 * 65504) +#define LUXMETER_COMPRESSION_RATIO 4 + +TEXTURE2D(_DebugFont); // Debug font to write string in shader +TEXTURE2D(_DebugMatCapTexture); + +void GetPropertiesDataDebug(uint paramId, inout float3 result, inout bool needLinearToSRGB) +{ + switch (paramId) + { + case DEBUGVIEWPROPERTIES_TESSELLATION: +#ifdef TESSELLATION_ON + result = float3(1.0, 0.0, 0.0); +#else + result = float3(0.0, 0.0, 0.0); +#endif + break; + + case DEBUGVIEWPROPERTIES_PIXEL_DISPLACEMENT: +#ifdef _PIXEL_DISPLACEMENT // Caution: This define is related to a shader features (But it may become a standard features for HD) + result = float3(1.0, 0.0, 0.0); +#else + result = float3(0.0, 0.0, 0.0); +#endif + break; + + case DEBUGVIEWPROPERTIES_VERTEX_DISPLACEMENT: +#ifdef _VERTEX_DISPLACEMENT // Caution: This define is related to a shader features (But it may become a standard features for HD) + result = float3(1.0, 0.0, 0.0); +#else + result = float3(0.0, 0.0, 0.0); +#endif + break; + + case DEBUGVIEWPROPERTIES_TESSELLATION_DISPLACEMENT: +#ifdef _TESSELLATION_DISPLACEMENT // Caution: This define is related to a shader features (But it may become a standard features for HD) + result = float3(1.0, 0.0, 0.0); +#else + result = float3(0.0, 0.0, 0.0); +#endif + break; + + case DEBUGVIEWPROPERTIES_DEPTH_OFFSET: +#ifdef _DEPTHOFFSET_ON // Caution: This define is related to a shader features (But it may become a standard features for HD) + result = float3(1.0, 0.0, 0.0); +#else + result = float3(0.0, 0.0, 0.0); +#endif + break; + + case DEBUGVIEWPROPERTIES_LIGHTMAP: +#if defined(LIGHTMAP_ON) || defined (DIRLIGHTMAP_COMBINED) || defined(DYNAMICLIGHTMAP_ON) + result = float3(1.0, 0.0, 0.0); +#else + result = float3(0.0, 0.0, 0.0); +#endif + break; + + case DEBUGVIEWPROPERTIES_INSTANCING: +#if defined(UNITY_INSTANCING_ENABLED) + result = float3(1.0, 0.0, 0.0); +#else + result = float3(0.0, 0.0, 0.0); +#endif + break; + } +} + +float3 GetTextureDataDebug(uint paramId, float2 uv, Texture2D tex, float4 texelSize, float4 mipInfo, float3 originalColor) +{ + float3 outColor = originalColor; + + switch (paramId) + { + case DEBUGMIPMAPMODE_MIP_RATIO: + outColor = GetDebugMipColorIncludingMipReduction(originalColor, tex, texelSize, uv, mipInfo); + break; + case DEBUGMIPMAPMODE_MIP_COUNT: + outColor = GetDebugMipCountColor(originalColor, tex); + break; + case DEBUGMIPMAPMODE_MIP_COUNT_REDUCTION: + outColor = GetDebugMipReductionColor(tex, mipInfo); + break; + case DEBUGMIPMAPMODE_STREAMING_MIP_BUDGET: + outColor = GetDebugStreamingMipColor(tex, mipInfo); + break; + case DEBUGMIPMAPMODE_STREAMING_MIP: + outColor = GetDebugStreamingMipColorBlended(originalColor, tex, mipInfo); + break; + } + + return outColor; +} + +// DebugFont code assume black and white font with texture size 256x128 with bloc of 16x16 +#define DEBUG_FONT_TEXT_WIDTH 16 +#define DEBUG_FONT_TEXT_HEIGHT 16 +#define DEBUG_FONT_TEXT_COUNT_X 16 +#define DEBUG_FONT_TEXT_COUNT_Y 8 +#define DEBUG_FONT_TEXT_ASCII_START 32 + +#define DEBUG_FONT_TEXT_SCALE_WIDTH 10 // This control the spacing between characters (if a character fill the text block it will overlap). + +// Only support ASCII symbol from DEBUG_FONT_TEXT_ASCII_START to 126 +// return black or white depends if we hit font character or not +// currentUnormCoord is current unormalized screen position +// fixedUnormCoord is the position where we want to draw something, this will be incremented by block font size in provided direction +// color is current screen color +// color of the font to use +// direction is 1 or -1 and indicate fixedUnormCoord block shift +void DrawCharacter(uint asciiValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, inout float3 color, int direction, int fontTextScaleWidth) +{ + // Are we inside a font display block on the screen ? + uint2 localCharCoord = currentUnormCoord - fixedUnormCoord; + if (localCharCoord.x >= 0 && localCharCoord.x < DEBUG_FONT_TEXT_WIDTH && localCharCoord.y >= 0 && localCharCoord.y < DEBUG_FONT_TEXT_HEIGHT) + { + localCharCoord.y = DEBUG_FONT_TEXT_HEIGHT - localCharCoord.y; + + asciiValue -= DEBUG_FONT_TEXT_ASCII_START; // Our font start at ASCII table 32; + uint2 asciiCoord = uint2(asciiValue % DEBUG_FONT_TEXT_COUNT_X, asciiValue / DEBUG_FONT_TEXT_COUNT_X); + // Unorm coordinate inside the font texture + uint2 unormTexCoord = asciiCoord * uint2(DEBUG_FONT_TEXT_WIDTH, DEBUG_FONT_TEXT_HEIGHT) + localCharCoord; + // normalized coordinate + float2 normTexCoord = float2(unormTexCoord) / float2(DEBUG_FONT_TEXT_WIDTH * DEBUG_FONT_TEXT_COUNT_X, DEBUG_FONT_TEXT_HEIGHT * DEBUG_FONT_TEXT_COUNT_Y); + +#if UNITY_UV_STARTS_AT_TOP + normTexCoord.y = 1.0 - normTexCoord.y; +#endif + + float charColor = SAMPLE_TEXTURE2D_LOD(_DebugFont, s_point_clamp_sampler, normTexCoord, 0).r; + color = color * (1.0 - charColor) + charColor * fontColor; + } + + fixedUnormCoord.x += fontTextScaleWidth * direction; +} + +void DrawCharacter(uint asciiValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, inout float3 color, int direction) +{ + DrawCharacter(asciiValue, fontColor, currentUnormCoord, fixedUnormCoord, color, direction, DEBUG_FONT_TEXT_SCALE_WIDTH); +} + +// Shortcut to not have to file direction +void DrawCharacter(uint asciiValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, inout float3 color) +{ + DrawCharacter(asciiValue, fontColor, currentUnormCoord, fixedUnormCoord, color, 1); +} + +// Draw a signed integer +// Can't display more than 16 digit +// The two following parameter are for float representation +// leading0 is used when drawing frac part of a float to draw the leading 0 (call is in charge of it) +// forceNegativeSign is used to force to display a negative sign as -0 is not recognize +void DrawInteger(int intValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, inout float3 color, int leading0, bool forceNegativeSign) +{ + const uint maxStringSize = 16; + + uint absIntValue = abs(intValue); + + // 1. Get size of the number of display + int numEntries = min((intValue == 0 ? 0 : log10(absIntValue)) + ((intValue < 0 || forceNegativeSign) ? 1 : 0) + leading0, maxStringSize); + + // 2. Shift curseur to last location as we will go reverse + fixedUnormCoord.x += numEntries * DEBUG_FONT_TEXT_SCALE_WIDTH; + + // 3. Display the number + bool drawCharacter = true; // bit weird, but it is to appease the compiler. + for (uint j = 0; j < maxStringSize; ++j) + { + // Numeric value incurrent font start on the second row at 0 + if(drawCharacter) + DrawCharacter((absIntValue % 10) + '0', fontColor, currentUnormCoord, fixedUnormCoord, color, -1); + + if (absIntValue < 10) + drawCharacter = false; + + absIntValue /= 10; + } + + // 4. Display leading 0 + if (leading0 > 0) + { + for (int i = 0; i < leading0; ++i) + { + DrawCharacter('0', fontColor, currentUnormCoord, fixedUnormCoord, color, -1); + } + } + + // 5. Display sign + if (intValue < 0 || forceNegativeSign) + { + DrawCharacter('-', fontColor, currentUnormCoord, fixedUnormCoord, color, -1); + } + + // 6. Reset cursor at end location + fixedUnormCoord.x += (numEntries + 2) * DEBUG_FONT_TEXT_SCALE_WIDTH; +} + +void DrawInteger(int intValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, inout float3 color) +{ + DrawInteger(intValue, fontColor, currentUnormCoord, fixedUnormCoord, color, 0, false); +} + +void DrawFloatExplicitPrecision(float floatValue, float3 fontColor, uint2 currentUnormCoord, uint digitCount, inout uint2 fixedUnormCoord, inout float3 color) +{ + if (IsNaN(floatValue)) + { + DrawCharacter('N', fontColor, currentUnormCoord, fixedUnormCoord, color); + DrawCharacter('a', fontColor, currentUnormCoord, fixedUnormCoord, color); + DrawCharacter('N', fontColor, currentUnormCoord, fixedUnormCoord, color); + } + else + { + int intValue = int(floatValue); + bool forceNegativeSign = floatValue >= 0.0f ? false : true; + DrawInteger(intValue, fontColor, currentUnormCoord, fixedUnormCoord, color, 0, forceNegativeSign); + DrawCharacter('.', fontColor, currentUnormCoord, fixedUnormCoord, color); + int fracValue = int(frac(abs(floatValue)) * pow(10, digitCount)); + int leading0 = digitCount - (int(log10(fracValue)) + 1); // Counting leading0 to add in front of the float + DrawInteger(fracValue, fontColor, currentUnormCoord, fixedUnormCoord, color, leading0, false); + } +} + +void DrawFloat(float floatValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, inout float3 color) +{ + DrawFloatExplicitPrecision(floatValue, fontColor, currentUnormCoord, 6, fixedUnormCoord, color); +} + +// Debug rendering is performed at the end of the frame (after post-processing). +// Debug textures are never flipped upside-down automatically. Therefore, we must always flip manually. +bool ShouldFlipDebugTexture() +{ + #if UNITY_UV_STARTS_AT_TOP + return (_ProjectionParams.x > 0); + #else + return (_ProjectionParams.x < 0); + #endif +} + +#endif + +#endif // DEBUG_DISPLAY diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DebugDisplay.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DebugDisplay.hlsl.meta new file mode 100644 index 0000000..3298318 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DebugDisplay.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8ab1498776c236c4da0411cc76a11bf6 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DoubleShadeWithFeatherMainLight.hlsl b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DoubleShadeWithFeatherMainLight.hlsl new file mode 100644 index 0000000..7665bdd --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DoubleShadeWithFeatherMainLight.hlsl @@ -0,0 +1,301 @@ +//Unity Toon Shader/HDRP +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Universal RP/HDRP) + +float3 UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, float3 mainLihgtDirection, float3 mainLightColor, out float inverseClipping, out float channelOutAlpha, out UTSData utsData) +{ + channelOutAlpha = 1.0f; + uint2 tileIndex = uint2(input.positionSS.xy) / GetTileSize(); + inverseClipping = 0; + // input.positionSS is SV_Position + PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, tileIndex); + + +#ifdef VARYINGS_NEED_POSITION_WS + float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS); +#else + // Unused + float3 V = float3(1.0, 1.0, 1.0); // Avoid the division by 0 +#endif + + SurfaceData surfaceData; + BuiltinData builtinData; + GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData); + + BSDFData bsdfData = ConvertSurfaceDataToBSDFData(input.positionSS.xy, surfaceData); + + PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); + /* todo. these should be put int a struct */ + float4 Set_UV0 = input.texCoord0; + float3x3 tangentTransform = input.tangentToWorld; + //UnpackNormalmapRGorAG(SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, texCoords)) + float4 n = SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, Set_UV0.xy); +// float3 _NormalMap_var = UnpackNormalScale(tex2D(_NormalMap, TRANSFORM_TEX(Set_UV0, _NormalMap)), _BumpScale); + float3 _NormalMap_var = UnpackNormalScale(n, _BumpScale); + float3 normalLocal = _NormalMap_var.rgb; + utsData.normalDirection = normalize(mul(normalLocal, tangentTransform)); // Perturbed normals + + float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)); + float3 i_normalDir = surfaceData.normalWS; + utsData.viewDirection = V; + /* to here todo. these should be put int a struct */ + + //v.2.0.4 +#if defined(_IS_CLIPPING_MODE) +//DoubleShadeWithFeather_Clipping + float4 _ClippingMask_var = SAMPLE_TEXTURE2D(_ClippingMask, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)); + float Set_Clipping = saturate((lerp(_ClippingMask_var.r, (1.0 - _ClippingMask_var.r), _Inverse_Clipping) + _Clipping_Level)); + clip(Set_Clipping - 0.5); +#elif defined(_IS_CLIPPING_TRANSMODE) || defined(_IS_TRANSCLIPPING_ON) +//DoubleShadeWithFeather_TransClipping + float4 _ClippingMask_var = SAMPLE_TEXTURE2D(_ClippingMask, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)); + float Set_MainTexAlpha = _MainTex_var.a; + float _IsBaseMapAlphaAsClippingMask_var = lerp(_ClippingMask_var.r, Set_MainTexAlpha, _IsBaseMapAlphaAsClippingMask); + float _Inverse_Clipping_var = lerp(_IsBaseMapAlphaAsClippingMask_var, (1.0 - _IsBaseMapAlphaAsClippingMask_var), _Inverse_Clipping); + float Set_Clipping = saturate((_Inverse_Clipping_var + _Clipping_Level)); + clip(Set_Clipping - 0.5); + inverseClipping = _Inverse_Clipping_var; +#elif defined(_IS_CLIPPING_OFF) || defined(_IS_TRANSCLIPPING_OFF) +//DoubleShadeWithFeather +#endif + + float shadowAttenuation = (float)lightLoopContext.shadowValue; + + + +// float4 tmpColor = EvaluateLight_Directional(context, posInput, _DirectionalLightDatas[mainLightIndex]); +// float3 mainLightColor = tmpColor.xyz; + float3 defaultLightDirection = normalize(UNITY_MATRIX_V[2].xyz + UNITY_MATRIX_V[1].xyz); + float3 defaultLightColor = saturate(max(float3(0.05, 0.05, 0.05) * _Unlit_Intensity, max( + SampleBakedGI_UTS(posInput.positionWS, float3(0.0, 0.0, 0.0), input.texCoord1.xy, input.texCoord2.xy, true), + SampleBakedGI_UTS(posInput.positionWS, float3(0.0, -1.0, 0.0), input.texCoord1.xy, input.texCoord2.xy, true) + ) * _Unlit_Intensity)); + float3 customLightDirection = normalize(mul(UNITY_MATRIX_M, float4(((float3(1.0, 0.0, 0.0) * _Offset_X_Axis_BLD * 10) + (float3(0.0, 1.0, 0.0) * _Offset_Y_Axis_BLD * 10) + (float3(0.0, 0.0, -1.0) * lerp(-1.0, 1.0, _Inverse_Z_Axis_BLD))), 0)).xyz); + float3 lightDirection = normalize(lerp(defaultLightDirection, mainLihgtDirection.xyz, any(mainLihgtDirection.xyz))); + lightDirection = lerp(lightDirection, customLightDirection, _Is_BLD); + float3 originalLightColor = mainLightColor; + + originalLightColor = lerp(originalLightColor, clamp(originalLightColor, ConvertFromEV100(_ToonEvAdjustmentValueMin ), ConvertFromEV100(_ToonEvAdjustmentValueMax)), _ToonEvAdjustmentCurve); + float3 lightColor = lerp(max(defaultLightColor, originalLightColor), max(defaultLightColor, saturate(originalLightColor)), max(_Is_Filter_LightColor, _ToonLightHiCutFilter)); + + + ////// Lighting: + float3 halfDirection = normalize(utsData.viewDirection + lightDirection); + //v.2.0.5 + _Color = _BaseColor; + float3 Set_LightColor = lightColor.rgb; + float3 Set_BaseColor = lerp((_MainTex_var.rgb * _BaseColor.rgb), ((_MainTex_var.rgb * _BaseColor.rgb) * Set_LightColor), _Is_LightColor_Base); + float3 clippingColor = float3(1.0f, 1.0f, 1.0f); +#ifdef _IS_CLIPPING_MATTE + if (_ClippingMatteMode == 5) + { + clippingColor = float3(0.0f, 0.0f, 0.0f); + return clippingColor; + } +#endif // _IS_CLIPPING_MATTE +#ifdef _IS_CLIPPING_MATTE + if (_ClippingMatteMode == 1) + { + clippingColor = Set_BaseColor; + return clippingColor; + } +#endif // _IS_CLIPPING_MATTE + +#ifdef UTS_LAYER_VISIBILITY + float3 overridingColor = lerp(_BaseColorMaskColor, float4(_BaseColorMaskColor.w, _BaseColorMaskColor.w, _BaseColorMaskColor.w, 1.0f), _ComposerMaskMode).xyz; + float maskEnabled = max(_BaseColorOverridden, _ComposerMaskMode); + Set_BaseColor = lerp(Set_BaseColor, overridingColor, maskEnabled); + Set_BaseColor *= _BaseColorVisible; + float Set_BaseColorAlpha = _BaseColorVisible; +#endif //#ifdef UTS_LAYER_VISIBILITY + //v.2.0.5 + float4 _1st_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_1st_ShadeMap, sampler_MainTex,TRANSFORM_TEX(Set_UV0, _MainTex)), _MainTex_var, _Use_BaseAs1st); + float3 Set_1st_ShadeColor = lerp((_1st_ShadeColor.rgb * _1st_ShadeMap_var.rgb), ((_1st_ShadeColor.rgb * _1st_ShadeMap_var.rgb) * Set_LightColor), _Is_LightColor_1st_Shade); +#ifdef _IS_CLIPPING_MATTE + if (_ClippingMatteMode == 2) + { + clippingColor = Set_1st_ShadeColor; + return clippingColor; + } +#endif // _IS_CLIPPING_MATTE +#ifdef UTS_LAYER_VISIBILITY + { + float4 overridingColor = lerp(_FirstShadeMaskColor, float4(_FirstShadeMaskColor.w, _FirstShadeMaskColor.w, _FirstShadeMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_FirstShadeOverridden, _ComposerMaskMode); + Set_1st_ShadeColor = lerp(Set_1st_ShadeColor, overridingColor.xyz, maskEnabled); + Set_1st_ShadeColor = lerp(Set_1st_ShadeColor, Set_BaseColor, 1.0f - _FirstShadeVisible); + } + float Set_1st_ShadeAlpha = _FirstShadeVisible; +#endif //#ifdef UTS_LAYER_VISIBILITY + //v.2.0.5 + float4 _2nd_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_2nd_ShadeMap, sampler_MainTex,TRANSFORM_TEX(Set_UV0, _MainTex)), _1st_ShadeMap_var, _Use_1stAs2nd); + float3 Set_2nd_ShadeColor = lerp((_2nd_ShadeColor.rgb * _2nd_ShadeMap_var.rgb), ((_2nd_ShadeColor.rgb * _2nd_ShadeMap_var.rgb) * Set_LightColor), _Is_LightColor_2nd_Shade); + float _HalfLambert_var = 0.5 * dot(lerp(i_normalDir, utsData.normalDirection, _Is_NormalMapToBase), lightDirection) + 0.5; + float4 _Set_2nd_ShadePosition_var = tex2D(_Set_2nd_ShadePosition, TRANSFORM_TEX(Set_UV0, _Set_2nd_ShadePosition)); + float4 _Set_1st_ShadePosition_var = tex2D(_Set_1st_ShadePosition, TRANSFORM_TEX(Set_UV0, _Set_1st_ShadePosition)); + + float _1stColorFeatherForMask = lerp(_BaseShade_Feather, 0.0f, max(_FirstShadeOverridden, _ComposerMaskMode)); + float _2ndColorFeatherForMask = lerp(_1st2nd_Shades_Feather, 0.0f, max(_SecondShadeOverridden, _ComposerMaskMode)); + + + //v.2.0.6 + //Minmimum value is same as the Minimum Feather's value with the Minimum Step's value as threshold. + float _SystemShadowsLevel_var = (shadowAttenuation * 0.5) + 0.5 + _Tweak_SystemShadowsLevel > 0.001 ? (shadowAttenuation * 0.5) + 0.5 + _Tweak_SystemShadowsLevel : 0.0001; + float Set_FinalShadowMask = saturate((1.0 + ((lerp(_HalfLambert_var, _HalfLambert_var * saturate(_SystemShadowsLevel_var), _Set_SystemShadowsToBase) - (_BaseColor_Step - _1stColorFeatherForMask)) * ((1.0 - _Set_1st_ShadePosition_var.rgb).r - 1.0)) / (_BaseColor_Step - (_BaseColor_Step - _1stColorFeatherForMask)))); + // + //Composition: 3 Basic Colors as Set_FinalBaseColor +#ifdef _IS_CLIPPING_MATTE + if (_ClippingMatteMode == 3) + { + clippingColor = Set_2nd_ShadeColor; + return clippingColor; + } +#endif // _IS_CLIPPING_MATTE +#ifdef UTS_LAYER_VISIBILITY + { + float4 overridingColor = lerp(_SecondShadeMaskColor, float4(_SecondShadeMaskColor.w, _SecondShadeMaskColor.w, _SecondShadeMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_SecondShadeOverridden, _ComposerMaskMode); + Set_2nd_ShadeColor = lerp(Set_2nd_ShadeColor, overridingColor.xyz, maskEnabled); + Set_2nd_ShadeColor = lerp(Set_2nd_ShadeColor, Set_BaseColor, 1.0f - _SecondShadeVisible); + } + float Set_2nd_ShadeAlpha = _SecondShadeVisible; +#endif //#ifdef UTS_LAYER_VISIBILITY + float3 Set_FinalBaseColor = lerp(Set_BaseColor, lerp(Set_1st_ShadeColor, Set_2nd_ShadeColor, saturate((1.0 + ((_HalfLambert_var - (_ShadeColor_Step - _2ndColorFeatherForMask)) * ((1.0 - _Set_2nd_ShadePosition_var.rgb).r - 1.0)) / (_ShadeColor_Step - (_ShadeColor_Step - _2ndColorFeatherForMask))))), Set_FinalShadowMask); // Final Color + channelOutAlpha = lerp(Set_BaseColorAlpha, lerp(Set_1st_ShadeAlpha, Set_2nd_ShadeAlpha, saturate((1.0 + ((_HalfLambert_var - (_ShadeColor_Step - _2ndColorFeatherForMask)) * ((1.0 - _Set_2nd_ShadePosition_var.rgb).r - 1.0)) / (_ShadeColor_Step - (_ShadeColor_Step - _2ndColorFeatherForMask))))), Set_FinalShadowMask); + float4 _Set_HighColorMask_var = tex2D(_Set_HighColorMask, TRANSFORM_TEX(Set_UV0, _Set_HighColorMask)); + float _Specular_var = 0.5 * dot(halfDirection, lerp(i_normalDir, utsData.normalDirection, _Is_NormalMapToHighColor)) + 0.5; // Specular + float _TweakHighColorMask_var = (saturate((_Set_HighColorMask_var.g + _Tweak_HighColorMaskLevel)) * lerp((1.0 - step(_Specular_var, (1.0 - pow(_HighColor_Power, 5)))), pow(abs(_Specular_var), exp2(lerp(11, 1, _HighColor_Power))), _Is_SpecularToHighColor)); + float4 _HighColor_Tex_var = tex2D(_HighColor_Tex, TRANSFORM_TEX(Set_UV0, _HighColor_Tex)); + float3 _HighColorWithOutTweak_var = lerp((_HighColor_Tex_var.rgb * _HighColor.rgb), ((_HighColor_Tex_var.rgb * _HighColor.rgb) * Set_LightColor), _Is_LightColor_HighColor); + float3 _HighColor_var = _HighColorWithOutTweak_var * _TweakHighColorMask_var; + +#ifdef _IS_CLIPPING_MATTE + if (_ClippingMatteMode == 4) + { + clippingColor = _HighColorWithOutTweak_var; + return clippingColor; + } +#endif // _IS_CLIPPING_MATTE + //Composition: 3 Basic Colors and HighColor as Set_HighColor +#ifdef UTS_LAYER_VISIBILITY + float3 Set_HighColor; + { + float4 overridingColor = lerp(_HighlightMaskColor, float4(_HighlightMaskColor.w, _HighlightMaskColor.w, _HighlightMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_HighlightOverridden, _ComposerMaskMode); + + _HighColor_var *= _HighlightVisible; + Set_HighColor = + lerp(SATURATE_IF_SDR(Set_FinalBaseColor - _TweakHighColorMask_var), Set_FinalBaseColor, + lerp(_Is_BlendAddToHiColor, 1.0 + , _Is_SpecularToHighColor)); + float3 addColor = + lerp(_HighColor_var, (_HighColor_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakHighColorOnShadow))) + , _Is_UseTweakHighColorOnShadow); + Set_HighColor += addColor; + if (any(addColor)) + { + Set_HighColor = lerp(Set_HighColor, overridingColor.xyz, maskEnabled); + channelOutAlpha = _HighlightVisible; + } + } + +#else + float3 Set_HighColor = (lerp(SATURATE_IF_SDR((Set_FinalBaseColor - _TweakHighColorMask_var)), Set_FinalBaseColor, lerp(_Is_BlendAddToHiColor, 1.0, _Is_SpecularToHighColor)) + lerp(_HighColor_var, (_HighColor_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakHighColorOnShadow))), _Is_UseTweakHighColorOnShadow)); +#endif + float4 _Set_RimLightMask_var = tex2D(_Set_RimLightMask, TRANSFORM_TEX(Set_UV0, _Set_RimLightMask)); + float3 _Is_LightColor_RimLight_var = lerp(_RimLightColor.rgb, (_RimLightColor.rgb * Set_LightColor), _Is_LightColor_RimLight); + float _RimArea_var = abs((1.0 - dot(lerp(i_normalDir, utsData.normalDirection, _Is_NormalMapToRimLight), utsData.viewDirection))); + float _RimLightPower_var = pow(_RimArea_var, exp2(lerp(3, 0, _RimLight_Power))); + float _Rimlight_InsideMask_var = saturate(lerp((0.0 + ((_RimLightPower_var - _RimLight_InsideMask) * (1.0 - 0.0)) / (1.0 - _RimLight_InsideMask)), step(_RimLight_InsideMask, _RimLightPower_var), _RimLight_FeatherOff)); + float _VertHalfLambert_var = 0.5 * dot(i_normalDir, lightDirection) + 0.5; + float3 _LightDirection_MaskOn_var = lerp((_Is_LightColor_RimLight_var * _Rimlight_InsideMask_var), (_Is_LightColor_RimLight_var * saturate((_Rimlight_InsideMask_var - ((1.0 - _VertHalfLambert_var) + _Tweak_LightDirection_MaskLevel)))), _LightDirection_MaskOn); + float _ApRimLightPower_var = pow(_RimArea_var, exp2(lerp(3, 0, _Ap_RimLight_Power))); +#ifdef UTS_LAYER_VISIBILITY + float4 overridingRimColor = lerp(_RimLightMaskColor, float4(_RimLightMaskColor.w, _RimLightMaskColor.w, _RimLightMaskColor.w, 1.0f), _ComposerMaskMode); + float maskRimEnabled = max(_RimLightOverridden, _ComposerMaskMode); + float Set_RimLightAlpha = _RimLightVisible; + float3 Set_RimLight = (saturate((_Set_RimLightMask_var.g + _Tweak_RimLightMaskLevel)) * lerp(_LightDirection_MaskOn_var, (_LightDirection_MaskOn_var + (lerp(_Ap_RimLightColor.rgb, (_Ap_RimLightColor.rgb * Set_LightColor), _Is_LightColor_Ap_RimLight) * saturate((lerp((0.0 + ((_ApRimLightPower_var - _RimLight_InsideMask) * (1.0 - 0.0)) / (1.0 - _RimLight_InsideMask)), step(_RimLight_InsideMask, _ApRimLightPower_var), _Ap_RimLight_FeatherOff) - (saturate(_VertHalfLambert_var) + _Tweak_LightDirection_MaskLevel))))), _Add_Antipodean_RimLight)); + Set_RimLight *= _RimLightVisible; + float3 _RimLight_var = lerp(Set_HighColor, (Set_HighColor + Set_RimLight), _RimLight); + if (any(Set_RimLight) * maskRimEnabled) + { + _RimLight_var = overridingRimColor.xyz; + channelOutAlpha = Set_RimLightAlpha; + } +#else + float3 Set_RimLight = (saturate((_Set_RimLightMask_var.g + _Tweak_RimLightMaskLevel)) * lerp(_LightDirection_MaskOn_var, (_LightDirection_MaskOn_var + (lerp(_Ap_RimLightColor.rgb, (_Ap_RimLightColor.rgb * Set_LightColor), _Is_LightColor_Ap_RimLight) * saturate((lerp((0.0 + ((_ApRimLightPower_var - _RimLight_InsideMask) * (1.0 - 0.0)) / (1.0 - _RimLight_InsideMask)), step(_RimLight_InsideMask, _ApRimLightPower_var), _Ap_RimLight_FeatherOff) - (saturate(_VertHalfLambert_var) + _Tweak_LightDirection_MaskLevel))))), _Add_Antipodean_RimLight)); + //Composition: HighColor and RimLight as _RimLight_var + float3 _RimLight_var = lerp(Set_HighColor, (Set_HighColor + Set_RimLight), _RimLight); +#endif + //Matcap + //v.2.0.6 : CameraRolling Stabilizer + //Mirror Script Determination: if sign_Mirror = -1, determine "Inside the mirror". + //v.2.0.7 + utsData.signMirror = 0.0; // i.mirrorFlag; todo. + float3 _Camera_Right = UNITY_MATRIX_V[0].xyz; + float3 _Camera_Front = UNITY_MATRIX_V[2].xyz; + float3 _Up_Unit = float3(0, 1, 0); + float3 _Right_Axis = cross(_Camera_Front, _Up_Unit); + + //Invert if it's "inside the mirror". + if (utsData.signMirror < 0) { + _Right_Axis = -1 * _Right_Axis; + _Rotate_MatCapUV = -1 * _Rotate_MatCapUV; + } + else { + _Right_Axis = _Right_Axis; + } + float _Camera_Right_Magnitude = sqrt(_Camera_Right.x * _Camera_Right.x + _Camera_Right.y * _Camera_Right.y + _Camera_Right.z * _Camera_Right.z); + float _Right_Axis_Magnitude = sqrt(_Right_Axis.x * _Right_Axis.x + _Right_Axis.y * _Right_Axis.y + _Right_Axis.z * _Right_Axis.z); + float _Camera_Roll_Cos = dot(_Right_Axis, _Camera_Right) / (_Right_Axis_Magnitude * _Camera_Right_Magnitude); + utsData.cameraRoll = acos(clamp(_Camera_Roll_Cos, -1, 1)); + utsData.cameraDir = _Camera_Right.y < 0 ? -1 : 1; + float _Rot_MatCapUV_var_ang = (_Rotate_MatCapUV * 3.141592654) - utsData.cameraDir * utsData.cameraRoll * _CameraRolling_Stabilizer; + //v.2.0.7 + float2 _Rot_MatCapNmUV_var = RotateUV(Set_UV0.xy, (_Rotate_NormalMapForMatCapUV * 3.141592654f), float2(0.5, 0.5), 1.0); + //V.2.0.6 + float3 _NormalMapForMatCap_var = UnpackNormalScale(tex2D(_NormalMapForMatCap, TRANSFORM_TEX(_Rot_MatCapNmUV_var, _NormalMapForMatCap)), _BumpScaleMatcap); + //v.2.0.5: MatCap with camera skew correction + float3 viewNormal = (mul(UNITY_MATRIX_V, float4(lerp(i_normalDir, mul(_NormalMapForMatCap_var.rgb, tangentTransform).rgb, _Is_NormalMapForMatCap), 0))).rgb; + float3 NormalBlend_MatcapUV_Detail = viewNormal.rgb * float3(-1, -1, 1); + float3 NormalBlend_MatcapUV_Base = (mul(UNITY_MATRIX_V, float4(utsData.viewDirection, 0)).rgb * float3(-1, -1, 1)) + float3(0, 0, 1); + float3 noSknewViewNormal = NormalBlend_MatcapUV_Base * dot(NormalBlend_MatcapUV_Base, NormalBlend_MatcapUV_Detail) / NormalBlend_MatcapUV_Base.b - NormalBlend_MatcapUV_Detail; + float2 _ViewNormalAsMatCapUV = (lerp(noSknewViewNormal, viewNormal, _Is_Ortho).rg * 0.5) + 0.5; + //v.2.0.7 + float2 _Rot_MatCapUV_var = RotateUV((0.0 + ((_ViewNormalAsMatCapUV - (0.0 + _Tweak_MatCapUV)) * (1.0 - 0.0)) / ((1.0 - _Tweak_MatCapUV) - (0.0 + _Tweak_MatCapUV))), _Rot_MatCapUV_var_ang, float2(0.5, 0.5), 1.0); + //Invert if it's "inside the mirror". + if (utsData.signMirror < 0) { + _Rot_MatCapUV_var.x = 1 - _Rot_MatCapUV_var.x; + } + else { + _Rot_MatCapUV_var = _Rot_MatCapUV_var; + } + //v.2.0.6 : LOD of Matcap + // + //MatcapMask + float4 _MatCap_Sampler_var = tex2Dlod(_MatCap_Sampler, float4(TRANSFORM_TEX(_Rot_MatCapUV_var, _MatCap_Sampler), 0.0, _BlurLevelMatcap)); + float4 _Set_MatcapMask_var = tex2D(_Set_MatcapMask, TRANSFORM_TEX(Set_UV0, _Set_MatcapMask)); + float _Tweak_MatcapMaskLevel_var = saturate(lerp(_Set_MatcapMask_var.g, (1.0 - _Set_MatcapMask_var.g), _Inverse_MatcapMask) + _Tweak_MatcapMaskLevel); + // + float3 _Is_LightColor_MatCap_var = lerp((_MatCap_Sampler_var.rgb * _MatCapColor.rgb), ((_MatCap_Sampler_var.rgb * _MatCapColor.rgb) * Set_LightColor), _Is_LightColor_MatCap); + //v.2.0.6 : ShadowMask on Matcap in Blend mode : multiply + float3 Set_MatCap = lerp(_Is_LightColor_MatCap_var, (_Is_LightColor_MatCap_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakMatCapOnShadow)) + lerp(Set_HighColor * Set_FinalShadowMask * (1.0 - _TweakMatCapOnShadow), float3(0.0, 0.0, 0.0), _Is_BlendAddToMatCap)), _Is_UseTweakMatCapOnShadow); + + // + //Composition: RimLight and MatCap as finalColor + //Broke down finalColor composition + float3 matCapColorOnAddMode = _RimLight_var + Set_MatCap * _Tweak_MatcapMaskLevel_var; + float _Tweak_MatcapMaskLevel_var_MultiplyMode = _Tweak_MatcapMaskLevel_var * lerp(1.0, (1.0 - (Set_FinalShadowMask) * (1.0 - _TweakMatCapOnShadow)), _Is_UseTweakMatCapOnShadow); + float3 matCapColorOnMultiplyMode = Set_HighColor * (1 - _Tweak_MatcapMaskLevel_var_MultiplyMode) + Set_HighColor * Set_MatCap * _Tweak_MatcapMaskLevel_var_MultiplyMode + lerp(float3(0, 0, 0), Set_RimLight, _RimLight); + float3 matCapColorFinal = lerp(matCapColorOnMultiplyMode, matCapColorOnAddMode, _Is_BlendAddToMatCap); + float3 finalColor = lerp(_RimLight_var, matCapColorFinal, _MatCap);// Final Composition before Emissive + // + //v.2.0.6: GI_Intensity with Intensity Multiplier Filter + float3 envLightColor = saturate(SampleBakedGI_UTS(posInput.positionWS, utsData.normalDirection, input.texCoord1.xy, input.texCoord2.xy, true)); + float envLightIntensity = saturate(0.299 * envLightColor.r + 0.587 * envLightColor.g + 0.114 * envLightColor.b); + + finalColor = SATURATE_IF_SDR(finalColor) + (envLightColor * envLightIntensity * _GI_Intensity * smoothstep(1, 0, envLightIntensity / 2)) + emissive; + + + return finalColor; +} diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DoubleShadeWithFeatherMainLight.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DoubleShadeWithFeatherMainLight.hlsl.meta new file mode 100644 index 0000000..ba3e48f --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DoubleShadeWithFeatherMainLight.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8f3d7136d29e4e94694ab0df05f6a94c +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DoubleShadeWithFeatherOtherLight.hlsl b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DoubleShadeWithFeatherOtherLight.hlsl new file mode 100644 index 0000000..f4d29d8 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DoubleShadeWithFeatherOtherLight.hlsl @@ -0,0 +1,143 @@ +//Unity Toon Shader/HDRP +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Universal RP/HDRP) + +float3 UTS_OtherLights(FragInputs input, float3 i_normalDir, + float3 additionalLightColor, float3 lightDirection, float notDirectional, out float channelOutAlpha) +{ + channelOutAlpha = 1.0f; +#ifdef _IS_CLIPPING_MATTE + if (_ClippingMatteMode != 0) + { + + return float3(0.0f, 0.0f, 0.0f); + } +#endif // _IS_CLIPPING_MATTE + + /* todo. these should be put into struct */ +#ifdef VARYINGS_NEED_POSITION_WS + float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS); +#else + // Unused + float3 V = float3(1.0, 1.0, 1.0); // Avoid the division by 0 +#endif + + float4 Set_UV0 = input.texCoord0; + float3x3 tangentTransform = input.tangentToWorld; + //UnpackNormalmapRGorAG(SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, texCoords)) + float4 n = SAMPLE_TEXTURE2D_LOD(_NormalMap, sampler_NormalMap, Set_UV0.xy, 0); +// float3 _NormalMap_var = UnpackNormalScale(tex2D(_NormalMap, TRANSFORM_TEX(Set_UV0, _NormalMap)), _BumpScale); + float3 _NormalMap_var = UnpackNormalScale(n, _BumpScale); + float3 normalLocal = _NormalMap_var.rgb; + float3 normalDirection = normalize(mul(normalLocal, tangentTransform)); // Perturbed normals + // float3 i_normalDir = surfaceData.normalWS; + float3 viewDirection = V; + float4 _MainTex_var = SAMPLE_TEXTURE2D_LOD(_MainTex, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex), 0.0f); + /* end of todo.*/ + + + + //v.2.0.5: + float3 addPassLightColor = (0.5 * dot(lerp(i_normalDir, normalDirection, _Is_NormalMapToBase), lightDirection) + 0.5) * additionalLightColor.rgb; + float pureIntencity = max(0.001, (0.299 * additionalLightColor.r + 0.587 * additionalLightColor.g + 0.114 * additionalLightColor.b)); + float3 lightColor = max(float3(0.0,0.0,0.0), lerp(addPassLightColor, lerp(float3(0.0,0.0,0.0), min(addPassLightColor, addPassLightColor / pureIntencity), notDirectional), _Is_Filter_LightColor)); + float3 halfDirection = normalize(viewDirection + lightDirection); // has to be recalced here. + //v.2.0.5: + _BaseColor_Step = saturate(_BaseColor_Step + _StepOffset); + _ShadeColor_Step = saturate(_ShadeColor_Step + _StepOffset); + // + //v.2.0.5: If Added lights is directional, set 0 as _LightIntensity + float _LightIntensity = lerp(0, (0.299 * additionalLightColor.r + 0.587 * additionalLightColor.g + 0.114 * additionalLightColor.b), notDirectional); + //v.2.0.5: Filtering the high intensity zone of PointLights + float3 Set_LightColor = lightColor; + // + float3 Set_BaseColor = lerp((_BaseColor.rgb * _MainTex_var.rgb * _LightIntensity), ((_BaseColor.rgb * _MainTex_var.rgb) * Set_LightColor), _Is_LightColor_Base); + +#ifdef UTS_LAYER_VISIBILITY + float4 overridingColor = lerp(_BaseColorMaskColor, float4(_BaseColorMaskColor.w, _BaseColorMaskColor.w, _BaseColorMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_BaseColorOverridden, _ComposerMaskMode); + Set_BaseColor = lerp(Set_BaseColor, overridingColor.xyz, maskEnabled); + Set_BaseColor *= _BaseColorVisible; + float Set_BaseColorAlpha = _BaseColorVisible; +#endif //#ifdef UTS_LAYER_VISIBILITY //v.2.0.5 + float4 _1st_ShadeMap_var = lerp(SAMPLE_TEXTURE2D_LOD(_1st_ShadeMap, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex),0.0f), _MainTex_var, _Use_BaseAs1st); + float3 Set_1st_ShadeColor = lerp((_1st_ShadeColor.rgb * _1st_ShadeMap_var.rgb * _LightIntensity), ((_1st_ShadeColor.rgb * _1st_ShadeMap_var.rgb) * Set_LightColor), _Is_LightColor_1st_Shade); +#ifdef UTS_LAYER_VISIBILITY + { + float4 overridingColor = lerp(_FirstShadeMaskColor, float4(_FirstShadeMaskColor.w, _FirstShadeMaskColor.w, _FirstShadeMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_FirstShadeOverridden, _ComposerMaskMode); + Set_1st_ShadeColor = lerp(Set_1st_ShadeColor, overridingColor.xyz, maskEnabled); + Set_1st_ShadeColor = lerp(Set_1st_ShadeColor, Set_BaseColor, 1.0f - _FirstShadeVisible); + } + float Set_1st_ShadeAlpha = _FirstShadeVisible; +#endif //#ifdef UTS_LAYER_VISIBILITY //v.2.0.5 + float4 _2nd_ShadeMap_var = lerp(SAMPLE_TEXTURE2D_LOD(_2nd_ShadeMap, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex), 0.0), _1st_ShadeMap_var, _Use_1stAs2nd); + float3 Set_2nd_ShadeColor = lerp((_2nd_ShadeColor.rgb * _2nd_ShadeMap_var.rgb * _LightIntensity), ((_2nd_ShadeColor.rgb * _2nd_ShadeMap_var.rgb) * Set_LightColor), _Is_LightColor_2nd_Shade); + float _HalfLambert_var = 0.5 * dot(lerp(i_normalDir, normalDirection, _Is_NormalMapToBase), lightDirection) + 0.5; + float4 _Set_2nd_ShadePosition_var = tex2Dlod(_Set_2nd_ShadePosition, float4(TRANSFORM_TEX(Set_UV0, _Set_2nd_ShadePosition),0.0f,0.0f)); + float4 _Set_1st_ShadePosition_var = tex2Dlod(_Set_1st_ShadePosition, float4(TRANSFORM_TEX(Set_UV0, _Set_1st_ShadePosition),0.0f, 0.0f)); + //v.2.0.5: + float _1stColorFeatherForMask = lerp(_BaseShade_Feather, 0.0f, max(_FirstShadeOverridden, _ComposerMaskMode)); + float _2ndColorFeatherForMask = lerp(_1st2nd_Shades_Feather, 0.0f, max(_SecondShadeOverridden, _ComposerMaskMode)); + float Set_FinalShadowMask = saturate((1.0 + ((lerp(_HalfLambert_var, (_HalfLambert_var * saturate(1.0 + _Tweak_SystemShadowsLevel)), _Set_SystemShadowsToBase) - (_BaseColor_Step - _1stColorFeatherForMask)) * ((1.0 - _Set_1st_ShadePosition_var.rgb).r - 1.0)) / (_BaseColor_Step - (_BaseColor_Step - _1stColorFeatherForMask)))); + + + + + //Composition: 3 Basic Colors as finalColor +#ifdef UTS_LAYER_VISIBILITY + { + float4 overridingColor = lerp(_SecondShadeMaskColor, float4(_SecondShadeMaskColor.w, _SecondShadeMaskColor.w, _SecondShadeMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_SecondShadeOverridden, _ComposerMaskMode); + Set_2nd_ShadeColor = lerp(Set_2nd_ShadeColor, overridingColor.xyz, maskEnabled); + Set_2nd_ShadeColor = lerp(Set_2nd_ShadeColor, Set_BaseColor, 1.0f - _SecondShadeVisible); + } +#endif //#ifdef UTS_LAYER_VISIBILITY + float3 finalColor = lerp(Set_BaseColor, lerp(Set_1st_ShadeColor, Set_2nd_ShadeColor, saturate((1.0 + ((_HalfLambert_var - (_ShadeColor_Step - _2ndColorFeatherForMask)) * ((1.0 - _Set_2nd_ShadePosition_var.rgb).r - 1.0)) / (_ShadeColor_Step - (_ShadeColor_Step - _2ndColorFeatherForMask))))), Set_FinalShadowMask); // Final Color +#ifdef UTS_LAYER_VISIBILITY + float Set_2nd_ShadeAlpha = _SecondShadeVisible; + channelOutAlpha = lerp(Set_BaseColorAlpha, lerp(Set_1st_ShadeAlpha, Set_2nd_ShadeAlpha, saturate((1.0 + ((_HalfLambert_var - (_ShadeColor_Step - _2ndColorFeatherForMask)) * ((1.0 - _Set_2nd_ShadePosition_var.rgb).r - 1.0)) / (_ShadeColor_Step - (_ShadeColor_Step - _2ndColorFeatherForMask))))), Set_FinalShadowMask); +#endif + //v.2.0.6: Add HighColor if _Is_Filter_HiCutPointLightColor is False + + float4 _Set_HighColorMask_var = tex2Dlod(_Set_HighColorMask, float4(TRANSFORM_TEX(Set_UV0, _Set_HighColorMask),0.0f,0.0f)); + float _Specular_var = 0.5 * dot(halfDirection, lerp(i_normalDir, normalDirection, _Is_NormalMapToHighColor)) + 0.5; // Specular + float _TweakHighColorMask_var = (saturate((_Set_HighColorMask_var.g + _Tweak_HighColorMaskLevel)) * lerp((1.0 - step(_Specular_var, (1.0 - pow(abs(_HighColor_Power), 5)))), pow(abs(_Specular_var), exp2(lerp(11, 1, _HighColor_Power))), _Is_SpecularToHighColor)); + float4 _HighColor_Tex_var = tex2Dlod(_HighColor_Tex, float4( TRANSFORM_TEX(Set_UV0, _HighColor_Tex),0.0f,0.0f)); + + float3 _HighColor_var = lerp((_HighColor_Tex_var.rgb * _HighColor.rgb), ((_HighColor_Tex_var.rgb * _HighColor.rgb) * Set_LightColor), _Is_LightColor_HighColor); +#ifdef UTS_LAYER_VISIBILITY + { + float4 overridingColor = lerp(_HighlightMaskColor, float4(_HighlightMaskColor.w, _HighlightMaskColor.w, _HighlightMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_HighlightOverridden, _ComposerMaskMode); + _HighColor_var *= _TweakHighColorMask_var; + _HighColor_var *= _HighlightVisible; + finalColor = + lerp(saturate(finalColor - _TweakHighColorMask_var), finalColor, + lerp(_Is_BlendAddToHiColor, 1.0 + , _Is_SpecularToHighColor)); + float3 addColor = + lerp(_HighColor_var, (_HighColor_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakHighColorOnShadow))) + , _Is_UseTweakHighColorOnShadow); + finalColor += addColor; + if (any(addColor)) + { + finalColor = lerp(finalColor, overridingColor.xyz, maskEnabled); + channelOutAlpha = _HighlightVisible; + } + + } +#else + _HighColor_var *= _TweakHighColorMask_var; + finalColor = finalColor + lerp(lerp(_HighColor_var, (_HighColor_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakHighColorOnShadow))), _Is_UseTweakHighColorOnShadow), float3(0, 0, 0), _Is_Filter_HiCutPointLightColor); +#endif //#ifdef UTS_LAYER_VISIBILITY + // + + finalColor = SATURATE_IF_SDR(finalColor); + + // pointLightColor += finalColor; + + + + return finalColor; +} diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DoubleShadeWithFeatherOtherLight.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DoubleShadeWithFeatherOtherLight.hlsl.meta new file mode 100644 index 0000000..5b22131 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/DoubleShadeWithFeatherOtherLight.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 840a356bfe23a2d47830da601e134150 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonHead.hlsl b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonHead.hlsl new file mode 100644 index 0000000..e138ac3 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonHead.hlsl @@ -0,0 +1,309 @@ +//Unity Toon Shader/HDRP +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Universal RP/HDRP) + +#ifndef UCTS_HDRP_INCLUDED +#define UCTS_HDRP_INCLUDED + +#define UCTS_HDRP 1 + +#define UTS_LAYER_VISIBILITY + + + +#ifndef DIRECTIONAL +# define DIRECTIONAL +#endif + +#define FP_BUFFER 1 +#if FP_BUFFER + #define SATURATE_IF_SDR(x) (x) + #define SATURATE_BASE_COLOR_IF_SDR(x) (x) +#else + #define SATURATE_IF_SDR(x) saturate(x) + #define SATURATE_BASE_COLOR_IF_SDR(x) saturate(x) +#endif + +struct UTSData +{ + float3 viewDirection; + float3 normalDirection; + fixed cameraDir; + float cameraRoll; + fixed signMirror; +}; + + + + + +#if defined(UNITY_PASS_PREPASSBASE) || defined(UNITY_PASS_DEFERRED) || defined(UNITY_PASS_SHADOWCASTER) +#undef FOG_LINEAR +#undef FOG_EXP +#undef FOG_EXP2 +#endif + + +#if 1 + +// Legacy for compatibility with existing shaders +inline bool IsGammaSpace() +{ +#ifdef UNITY_COLORSPACE_GAMMA + return true; +#else + return false; +#endif +} + + +// normal should be normalized, w=1.0 +half3 SHEvalLinearL0L1(half4 normal) +{ + half3 x; + + // Linear (L1) + constant (L0) polynomial terms + x.r = dot(unity_SHAr, normal); + x.g = dot(unity_SHAg, normal); + x.b = dot(unity_SHAb, normal); + + return x; +} + +// normal should be normalized, w=1.0 +half3 SHEvalLinearL2(half4 normal) +{ + half3 x1, x2; + // 4 of the quadratic (L2) polynomials + half4 vB = normal.xyzz * normal.yzzx; + x1.r = dot(unity_SHBr, vB); + x1.g = dot(unity_SHBg, vB); + x1.b = dot(unity_SHBb, vB); + + // Final (5th) quadratic (L2) polynomial + half vC = normal.x * normal.x - normal.y * normal.y; + x2 = unity_SHC.rgb * vC; + + return x1 + x2; +} + +// normal should be normalized, w=1.0 +// output in active color space +half3 ShadeSH9(half4 normal) +{ + // Linear + constant polynomial terms + half3 res = SHEvalLinearL0L1(normal); + + // Quadratic polynomials + res += SHEvalLinearL2(normal); + +# ifdef UNITY_COLORSPACE_GAMMA + res = LinearToGammaSpace(res); +# endif + + return res; +} + +float3 DecodeLightProbe(float3 N) { + return ShadeSH9(float4(N, 1)); +} + + +inline float GammaToLinearSpaceExact(float value) +{ + if (value <= 0.04045F) + return value / 12.92F; + else if (value < 1.0F) + return pow((value + 0.055F) / 1.055F, 2.4F); + else + return pow(value, 2.2F); +} + +inline float3 GammaToLinearSpace(float3 sRGB) +{ + // Approximate version from http://chilliant.blogspot.com.au/2012/08/srgb-approximations-for-hlsl.html?m=1 + return sRGB * (sRGB * (sRGB * 0.305306011h + 0.682171111h) + 0.012522878h); + + // Precise version, useful for debugging. + //return half3(GammaToLinearSpaceExact(sRGB.r), GammaToLinearSpaceExact(sRGB.g), GammaToLinearSpaceExact(sRGB.b)); +} + +inline float LinearToGammaSpaceExact(float value) +{ + if (value <= 0.0F) + return 0.0F; + else if (value <= 0.0031308F) + return 12.92F * value; + else if (value < 1.0F) + return 1.055F * pow(value, 0.4166667F) - 0.055F; + else + return pow(value, 0.45454545F); +} + +inline float3 LinearToGammaSpace(float3 linRGB) +{ + linRGB = max(linRGB, float3(0.h, 0.h, 0.h)); + // An almost-perfect approximation from http://chilliant.blogspot.com.au/2012/08/srgb-approximations-for-hlsl.html?m=1 + return max(1.055h * pow(linRGB, 0.416666667h) - 0.055h, 0.h); + + // Exact version, useful for debugging. + //return half3(LinearToGammaSpaceExact(linRGB.r), LinearToGammaSpaceExact(linRGB.g), LinearToGammaSpaceExact(linRGB.b)); +} + + +#if defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2) + #define UNITY_FOG_COORDS(idx) UNITY_FOG_COORDS_PACKED(idx, float1) + + #if (SHADER_TARGET < 30) || defined(SHADER_API_MOBILE) + // mobile or SM2.0: calculate fog factor per-vertex + #define UNITY_TRANSFER_FOG(o,outpos) UNITY_CALC_FOG_FACTOR((outpos).z); o.fogCoord.x = unityFogFactor + #else + // SM3.0 and PC/console: calculate fog distance per-vertex, and fog factor per-pixel + #define UNITY_TRANSFER_FOG(o,outpos) o.fogCoord.x = (outpos).z + #endif +#else + #define UNITY_FOG_COORDS(idx) + #define UNITY_TRANSFER_FOG(o,outpos) +#endif + +#define UNITY_FOG_LERP_COLOR(col,fogCol,fogFac) col.rgb = lerp((fogCol).rgb, (col).rgb, saturate(fogFac)) + + +#if defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2) + #if (SHADER_TARGET < 30) || defined(SHADER_API_MOBILE) + // mobile or SM2.0: fog factor was already calculated per-vertex, so just lerp the color + #define UNITY_APPLY_FOG_COLOR(coord,col,fogCol) UNITY_FOG_LERP_COLOR(col,fogCol,(coord).x) + #else + // SM3.0 and PC/console: calculate fog factor and lerp fog color + #define UNITY_APPLY_FOG_COLOR(coord,col,fogCol) UNITY_CALC_FOG_FACTOR((coord).x); UNITY_FOG_LERP_COLOR(col,fogCol,unityFogFactor) + #endif +#else + #define UNITY_APPLY_FOG_COLOR(coord,col,fogCol) +#endif + +#ifdef UNITY_PASS_FORWARDADD + #define UNITY_APPLY_FOG(coord,col) UNITY_APPLY_FOG_COLOR(coord,col,fixed4(0,0,0,0)) +#else + #define UNITY_APPLY_FOG(coord,col) UNITY_APPLY_FOG_COLOR(coord,col,unity_FogColor) +#endif + +#endif //#if false + +#ifdef DIRECTIONAL + #define LIGHTING_COORDS(idx1,idx2) SHADOW_COORDS(idx1) + #define TRANSFER_VERTEX_TO_FRAGMENT(a) TRANSFER_SHADOW(a) + #define LIGHT_ATTENUATION(a) SHADOW_ATTENUATION(a) +#endif + +// Transforms 2D UV by scale/bias property +#define UCTS_TEXTURE2D(tex,name) SAMPLE_TEXTURE2D(tex,sampler##tex,TRANSFORM_TEX(name, tex)); + + +inline float4 UnityObjectToClipPosInstanced(in float3 pos) +{ +// return mul(UNITY_MATRIX_VP, mul(unity_ObjectToWorldArray[unity_InstanceID], float4(pos, 1.0))); + // todo. right? + return mul(UNITY_MATRIX_VP, mul(UNITY_MATRIX_M, float4(pos, 1.0))); +} +inline float4 UnityObjectToClipPosInstanced(float4 pos) +{ + return UnityObjectToClipPosInstanced(pos.xyz); +} +#define UnityObjectToClipPos UnityObjectToClipPosInstanced + +inline float3 UnityObjectToWorldNormal( in float3 norm ) +{ +#ifdef UNITY_ASSUME_UNIFORM_SCALING + return UnityObjectToWorldDir(norm); +#else + // mul(IT_M, norm) => mul(norm, I_M) => {dot(norm, I_M.col0), dot(norm, I_M.col1), dot(norm, I_M.col2)} + return normalize(mul(norm, (float3x3)UNITY_MATRIX_M)); +#endif +} +// normal should be normalized, w=1.0 +float3 SHEvalLinearL0L1 (float4 normal) +{ + float3 x; + + // Linear (L1) + constant (L0) polynomial terms + x.r = dot(unity_SHAr,normal); + x.g = dot(unity_SHAg,normal); + x.b = dot(unity_SHAb,normal); + + return x; +} + +// normal should be normalized, w=1.0 +float3 SHEvalLinearL2 (float4 normal) +{ + float3 x1, x2; + // 4 of the quadratic (L2) polynomials + float4 vB = normal.xyzz * normal.yzzx; + x1.r = dot(unity_SHBr,vB); + x1.g = dot(unity_SHBg,vB); + x1.b = dot(unity_SHBb,vB); + + // Final (5th) quadratic (L2) polynomial + half vC = normal.x*normal.x - normal.y*normal.y; + x2 = unity_SHC.rgb * vC; + + return x1 + x2; +} + +// normal should be normalized, w=1.0 +// output in active color space +float3 ShadeSH9 (float4 normal) +{ + // Linear + constant polynomial terms + float3 res = SHEvalLinearL0L1 (normal); + + // Quadratic polynomials + res += SHEvalLinearL2 (normal); + +# ifdef UNITY_COLORSPACE_GAMMA + res = LinearToGammaSpace (res); +# endif + + return res; +} + +float rateR = 0.299; +float rateG = 0.587; +float rateB = 0.114; + + +float3 SampleBakedGI_UTS(float3 positionRWS, float3 normalWS, float2 uvStaticLightmap, float2 uvDynamicLightmap, bool needToIncludeAPV = false) +{ + float3 bakeDiffuseLighting = float3(0, 0, 0); + float3 backBakeDiffuseLighting = float3(0, 0, 0); + float3 backNormalWS = float3(0, 0, 0); + +#if !defined(_SURFACE_TYPE_TRANSPARENT) && (SHADERPASS != SHADERPASS_RAYTRACING_INDIRECT) && (SHADERPASS != SHADERPASS_RAYTRACING_GBUFFER) + if (_IndirectDiffuseMode != INDIRECTDIFFUSEMODE_OFF +#if (SHADERPASS == SHADERPASS_GBUFER) + && _IndirectDiffuseMode != INDIRECTDIFFUSEMODE_MIXED && _ReflectionsMode != REFLECTIONSMODE_MIXED +#endif + ) + return bakeDiffuseLighting; +#endif + +#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON) + EvaluateLightmap(positionRWS, normalWS, backNormalWS, uvStaticLightmap, uvDynamicLightmap, bakeDiffuseLighting, backBakeDiffuseLighting); +#elif (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)) + if (needToIncludeAPV) + { + EvaluateAdaptiveProbeVolume(GetAbsolutePositionWS(positionRWS), normalWS, backNormalWS, GetWorldSpaceNormalizeViewDir(positionRWS), 0.0, bakeDiffuseLighting, backBakeDiffuseLighting); + } +#else + EvaluateLightProbeBuiltin(positionRWS, normalWS, backNormalWS, bakeDiffuseLighting, backBakeDiffuseLighting); + +#if defined(SHADER_STAGE_RAY_TRACING) + bakeDiffuseLighting *= _RayTracingAmbientProbeDimmer; + backBakeDiffuseLighting *= _RayTracingAmbientProbeDimmer; +#endif +#endif + + return bakeDiffuseLighting; +} + +#endif //#ifndef UCTS_HDRP_INCLUDED \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonHead.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonHead.hlsl.meta new file mode 100644 index 0000000..c56c206 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonHead.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e2fc592d7e0eb2d47b07a315b3ec3ea8 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonOutline.hlsl b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonOutline.hlsl new file mode 100644 index 0000000..a3ab322 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonOutline.hlsl @@ -0,0 +1,210 @@ +//Unity Toon Shader/HDRP +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Universal RP/HDRP) + + +#undef unity_ObjectToWorld +#undef unity_WorldToObject + +float4 _LightColor0; // not referenced in c# code ?? + +#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/MotionVectorVertexShaderCommon.hlsl" + + // PackedVaryingsType + // https://github.com/Unity-Technologies/Graphics/blob/e4117c07b479adafed38237f3407a363eefb4590/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl#L120 + + PackedVaryingsType Vert(AttributesMesh inputMesh, AttributesPass inputPass) + { + // VaryingsType + // https://github.com/Unity-Technologies/Graphics/blob/e4117c07b479adafed38237f3407a363eefb4590/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl#L118 + + VaryingsType varyingsType; + varyingsType.vmesh = VertMesh(inputMesh); + #include "HDRPToonOutlineVertMain.hlsl" + + return MotionVectorVS(varyingsType, inputMesh, inputPass); + } + +#ifdef TESSELLATION_ON + + PackedVaryingsToPS VertTesselation(VaryingsToDS input) + { + VaryingsToPS output; + output.vmesh = VertMeshTesselation(input.vmesh); + MotionVectorPositionZBias(output); + + output.vpass.positionCS = input.vpass.positionCS; + output.vpass.previousPositionCS = input.vpass.previousPositionCS; + + return PackVaryingsToPS(output); + } + +#endif // TESSELLATION_ON + +#else // _WRITE_TRANSPARENT_MOTION_VECTOR + +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl" + + PackedVaryingsType Vert(AttributesMesh inputMesh) + { + VaryingsType varyingsType; + varyingsType.vmesh = VertMesh(inputMesh); + #include "HDRPToonOutlineVertMain.hlsl" + + return PackVaryingsType(varyingsType); + } + +#ifdef TESSELLATION_ON + + PackedVaryingsToPS VertTesselation(VaryingsToDS input) + { + VaryingsToPS output; + output.vmesh = VertMeshTesselation(input.vmesh); + + return PackVaryingsToPS(output); + } + + +#endif // TESSELLATION_ON + +#endif // _WRITE_TRANSPARENT_MOTION_VECTOR + + +#ifdef TESSELLATION_ON +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/TessellationShare.hlsl" +#endif + + + + + +#ifdef UNITY_VIRTUAL_TEXTURING +#define VT_BUFFER_TARGET SV_Target1 +#define EXTRA_BUFFER_TARGET SV_Target2 +#else +#define EXTRA_BUFFER_TARGET SV_Target1 +#endif + + + +void Frag(PackedVaryingsToPS packedInput, +#ifdef OUTPUT_SPLIT_LIGHTING + out float4 outColor : SV_Target0, // outSpecularLighting +#ifdef UNITY_VIRTUAL_TEXTURING + out float4 outVTFeedback : VT_BUFFER_TARGET, +#endif + out float4 outDiffuseLighting : EXTRA_BUFFER_TARGET, + OUTPUT_SSSBUFFER(outSSSBuffer) +#else + out float4 outColor : SV_Target0 +#ifdef UNITY_VIRTUAL_TEXTURING + , out float4 outVTFeedback : VT_BUFFER_TARGET +#endif +#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR + , out float4 outMotionVec : EXTRA_BUFFER_TARGET +#endif // _WRITE_TRANSPARENT_MOTION_VECTOR +#endif // OUTPUT_SPLIT_LIGHTING +#ifdef _DEPTHOFFSET_ON + , out float outputDepth : SV_Depth +#endif + ) + +{ + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput); + FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh); +#ifdef _IS_CLIPPING_MASK + if (_ClippingMaskMode != 0) + { + discard; + } +#endif +#ifdef _IS_CLIPPING_MATTE + if (_ClippingMatteMode != 0) + { + discard; + } +#endif // _IS_CLIPPING_MATTE +#if defined(UTS_DEBUG_SHADOWMAP_NO_OUTLINE) + discard; +#endif + + + + //v.2.0.5 + if (_ZOverDrawMode > 0.99f) + { +#ifdef _DEPTHOFFSET_ON + outputDepth = posInput.deviceDepth; +#endif +#ifdef UNITY_VIRTUAL_TEXTURING + + outVTFeedback = builtinData.vtPackedFeedback; +#endif + outColor = float4(1.0f, 1.0f, 1.0f, 1.0f); // but nothing should be drawn except Z value as colormask is set to 0 + return; + } + _Color = _BaseColor; + float4 objPos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1)); + // The following temporary definition of unity_AmbientEquator is for HDRP only. + float4 unity_AmbientEquator = float4(0.05, 0.05, 0.05, 1.0); //Todo. + //v.2.0.9 + float3 envLightSource_GradientEquator = unity_AmbientEquator.rgb >0.05 ? unity_AmbientEquator.rgb : half3(0.05,0.05,0.05); + float3 envLightSource_SkyboxIntensity = max( + SampleBakedGI_UTS(objPos, float3(0.0, 0.0, 0.0), input.texCoord1.xy, input.texCoord2.xy, true), + SampleBakedGI_UTS(objPos, float3(0.0, -1.0, 0.0), input.texCoord1.xy, input.texCoord2.xy, true) + ).rgb; + float3 ambientSkyColor = envLightSource_SkyboxIntensity.rgb>0.0 ? envLightSource_SkyboxIntensity*_Unlit_Intensity : envLightSource_GradientEquator*_Unlit_Intensity; + // + float3 lightColor = _LightColor0.rgb >0.05 ? _LightColor0.rgb : ambientSkyColor.rgb; + float lightColorIntensity = (0.299*lightColor.r + 0.587*lightColor.g + 0.114*lightColor.b); + lightColor = lightColorIntensity<1 ? lightColor : lightColor/lightColorIntensity; + lightColor = lerp(half3(1.0,1.0,1.0), lightColor, _Is_LightColor_Outline); + + float2 Set_UV0 = input.texCoord0.xy; + + float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,TRANSFORM_TEX(Set_UV0, _MainTex)); + float3 Set_BaseColor = _BaseColor.rgb*_MainTex_var.rgb; + float3 _Is_BlendBaseColor_var = lerp( _Outline_Color.rgb*lightColor, (_Outline_Color.rgb*Set_BaseColor*Set_BaseColor*lightColor), _Is_BlendBaseColor ); + // + float3 _OutlineTex_var = tex2D(_OutlineTex,TRANSFORM_TEX(Set_UV0, _OutlineTex)).xyz; + + float4 overridingColor = lerp(_OutlineMaskColor, float4(_OutlineMaskColor.w, _OutlineMaskColor.w, _OutlineMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_OutlineOverridden, _ComposerMaskMode); + +//v.2.0.7.5 +#ifdef _IS_OUTLINE_CLIPPING_NO + float3 Set_Outline_Color = lerp(_Is_BlendBaseColor_var, _OutlineTex_var.rgb*_Outline_Color.rgb*lightColor, _Is_OutlineTex ); + if (_OutlineVisible < 0.1) + { + // Todo. + // without this, something is drawn even if _OutlineVisible = 0, in AngelRing(HDRP) + discard; + } + Set_Outline_Color = lerp(Set_Outline_Color, overridingColor.xyz, maskEnabled); + outColor =float4(Set_Outline_Color, _OutlineVisible ); + + +#elif _IS_OUTLINE_CLIPPING_YES + float4 _ClippingMask_var = SAMPLE_TEXTURE2D(_ClippingMask, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)); + float Set_MainTexAlpha = _MainTex_var.a; + float _IsBaseMapAlphaAsClippingMask_var = lerp( _ClippingMask_var.r, Set_MainTexAlpha, _IsBaseMapAlphaAsClippingMask ); + float _Inverse_Clipping_var = lerp( _IsBaseMapAlphaAsClippingMask_var, (1.0 - _IsBaseMapAlphaAsClippingMask_var), _Inverse_Clipping ); + float Set_Clipping = saturate((_Inverse_Clipping_var+_Clipping_Level)); + clip(Set_Clipping - 0.5); + float4 Set_Outline_Color = lerp( float4(_Is_BlendBaseColor_var,Set_Clipping), float4((_OutlineTex_var.rgb*_Outline_Color.rgb*lightColor),Set_Clipping), _Is_OutlineTex ); + Set_Outline_Color = lerp(Set_Outline_Color, overridingColor, maskEnabled); + Set_Outline_Color.w *= _OutlineVisible; + outColor = Set_Outline_Color; +#endif + + +#ifdef _DEPTHOFFSET_ON + outputDepth = posInput.deviceDepth; +#endif +#ifdef UNITY_VIRTUAL_TEXTURING + outVTFeedback = builtinData.vtPackedFeedback; +#endif +} +// End of File + diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonOutline.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonOutline.hlsl.meta new file mode 100644 index 0000000..72df5de --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonOutline.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: da01533aa573e30428720fa587ddbe94 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonOutlineVertMain.hlsl b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonOutlineVertMain.hlsl new file mode 100644 index 0000000..45a2e10 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonOutlineVertMain.hlsl @@ -0,0 +1,50 @@ +//Unity Toon Shader/HDRP +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Universal RP/HDRP) + + +#if 1 + float4 objPos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1)); + float2 Set_UV0 = inputMesh.uv0; + float4 _Outline_Sampler_var = tex2Dlod(_Outline_Sampler, float4(TRANSFORM_TEX(Set_UV0, _Outline_Sampler), 0.0, 0)); + //v.2.0.4.3 baked Normal Texture for Outline + float3 normalDir = UnityObjectToWorldNormal(inputMesh.normalOS); + float3 tangentDir = normalize(mul(unity_ObjectToWorld, float4(inputMesh.tangentOS.xyz, 0.0)).xyz); + float3 bitangentDir = normalize(cross(normalDir, tangentDir) * inputMesh.tangentOS.w); + float3x3 tangentTransform = float3x3(tangentDir, bitangentDir, normalDir); + //UnpackNormal() can't be used, and so as follows. Do not specify a bump for the texture to be used. + float4 _BakedNormal_var = (tex2Dlod(_BakedNormal, float4(TRANSFORM_TEX(Set_UV0, _BakedNormal), 0.0, 0)) * 2 - 1); + float3 _BakedNormalDir = normalize(mul(_BakedNormal_var.rgb, tangentTransform)); + //end + float Set_Outline_Width = (_Outline_Width*0.001*smoothstep(_Farthest_Distance, _Nearest_Distance, distance(objPos.rgb, _WorldSpaceCameraPos))*_Outline_Sampler_var.rgb).r; + Set_Outline_Width *= (1.0f - _ZOverDrawMode); + //v.2.0.7.5 + float4 _ClipCameraPos = mul(UNITY_MATRIX_VP, float4(_WorldSpaceCameraPos.xyz, 1)); + //v.2.0.7 +#if defined(UNITY_REVERSED_Z) || (UNITY_VERSION >= 202230) + //v.2.0.4.2 (DX) + _Offset_Z = _Offset_Z * -0.01; +#else + //OpenGL + _Offset_Z = _Offset_Z * 0.01; +#endif + //v2.0.4 +#ifdef _OUTLINE_NML + //v.2.0.4.3 baked Normal Texture for Outline + float4 clipPos= UnityObjectToClipPos(lerp(float4(inputMesh.positionOS + inputMesh.normalOS*Set_Outline_Width, 1), float4(inputMesh.positionOS.xyz + _BakedNormalDir * Set_Outline_Width, 1), _Is_BakedNormal)); +#elif _OUTLINE_POS + Set_Outline_Width = Set_Outline_Width * 2; + float signVar = dot(normalize(inputMesh.positionOS), normalize(inputMesh.normalOS)) < 0 ? -1 : 1; + float4 clipPos = UnityObjectToClipPos(float4(inputMesh.positionOS + signVar * normalize(inputMesh.positionOS)*Set_Outline_Width, 1)); +#endif + //v.2.0.7.5 + clipPos.z = clipPos.z + _Offset_Z * _ClipCameraPos.z; + + float4 rws = mul(UNITY_MATRIX_I_P, clipPos); // use UNITY_MATRIX_I_P instead of unity_CameraInvProjection. + rws = mul(UNITY_MATRIX_I_V, rws); // use UNITY_MATRIX_I_V instead of unity_cameraToWorld. +#ifndef TESSELLATION_ON + varyingsType.vmesh.positionCS = clipPos; +#endif // TESSELLATION_ON + varyingsType.vmesh.positionRWS = rws.xyz; + +#endif // #if 1 diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonOutlineVertMain.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonOutlineVertMain.hlsl.meta new file mode 100644 index 0000000..1afbe5d --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/HDRPToonOutlineVertMain.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 317af98a1c897dd46b2d3839bc92aaa5 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShaderPassForward.hlsl b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShaderPassForward.hlsl new file mode 100644 index 0000000..0f7e6ba --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShaderPassForward.hlsl @@ -0,0 +1,268 @@ +#if SHADERPASS != SHADERPASS_FORWARD +#error SHADERPASS_is_not_correctly_define +#endif + +#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/MotionVectorVertexShaderCommon.hlsl" + +PackedVaryingsType Vert(AttributesMesh inputMesh, AttributesPass inputPass) +{ + VaryingsType varyingsType; + varyingsType.vmesh = VertMesh(inputMesh); + return MotionVectorVS(varyingsType, inputMesh, inputPass); +} + +#ifdef TESSELLATION_ON + +PackedVaryingsToPS VertTesselation(VaryingsToDS input) +{ + VaryingsToPS output; + output.vmesh = VertMeshTesselation(input.vmesh); + MotionVectorPositionZBias(output); + + output.vpass.positionCS = input.vpass.positionCS; + output.vpass.previousPositionCS = input.vpass.previousPositionCS; + + return PackVaryingsToPS(output); +} + +#endif // TESSELLATION_ON + +#else // _WRITE_TRANSPARENT_MOTION_VECTOR + +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl" + +PackedVaryingsType Vert(AttributesMesh inputMesh) +{ + VaryingsType varyingsType; + +#if defined(HAVE_RECURSIVE_RENDERING) + // If we have a recursive raytrace object, we will not render it. + // As we don't want to rely on renderqueue to exclude the object from the list, + // we cull it by settings position to NaN value. + // TODO: provide a solution to filter dyanmically recursive raytrace object in the DrawRenderer + if (_EnableRecursiveRayTracing && _RayTracing > 0.0) + { + ZERO_INITIALIZE(VaryingsType, varyingsType); // Divide by 0 should produce a NaN and thus cull the primitive. + } + else +#endif + { + varyingsType.vmesh = VertMesh(inputMesh); + } + + return PackVaryingsType(varyingsType); +} + +#ifdef TESSELLATION_ON + +PackedVaryingsToPS VertTesselation(VaryingsToDS input) +{ + VaryingsToPS output; + output.vmesh = VertMeshTesselation(input.vmesh); + + return PackVaryingsToPS(output); +} + + +#endif // TESSELLATION_ON + +#endif // _WRITE_TRANSPARENT_MOTION_VECTOR + + +#ifdef TESSELLATION_ON +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/TessellationShare.hlsl" +#endif + +#ifdef UNITY_VIRTUAL_TEXTURING +#define VT_BUFFER_TARGET SV_Target1 +#define EXTRA_BUFFER_TARGET SV_Target2 +#else +#define EXTRA_BUFFER_TARGET SV_Target1 +#endif + +void Frag(PackedVaryingsToPS packedInput, + #ifdef OUTPUT_SPLIT_LIGHTING + out float4 outColor : SV_Target0, // outSpecularLighting + #ifdef UNITY_VIRTUAL_TEXTURING + out float4 outVTFeedback : VT_BUFFER_TARGET, + #endif + out float4 outDiffuseLighting : EXTRA_BUFFER_TARGET, + OUTPUT_SSSBUFFER(outSSSBuffer) + #else + out float4 outColor : SV_Target0 + #ifdef UNITY_VIRTUAL_TEXTURING + ,out float4 outVTFeedback : VT_BUFFER_TARGET + #endif + #ifdef _WRITE_TRANSPARENT_MOTION_VECTOR + , out float4 outMotionVec : EXTRA_BUFFER_TARGET + #endif // _WRITE_TRANSPARENT_MOTION_VECTOR + #endif // OUTPUT_SPLIT_LIGHTING + #ifdef _DEPTHOFFSET_ON + , out float outputDepth : SV_Depth + #endif +) +{ +#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR + // Init outMotionVector here to solve compiler warning (potentially unitialized variable) + // It is init to the value of forceNoMotion (with 2.0) + outMotionVec = float4(2.0, 0.0, 0.0, 0.0); +#endif + + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput); + FragInputs input = UnpackVaryingsToFragInputs(packedInput); + + // We need to readapt the SS position as our screen space positions are for a low res buffer, but we try to access a full res buffer. + input.positionSS.xy = _OffScreenRendering > 0 ? (input.positionSS.xy * _OffScreenDownsampleFactor) : input.positionSS.xy; + + uint2 tileIndex = uint2(input.positionSS.xy) / GetTileSize(); + + // input.positionSS is SV_Position + PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, tileIndex); + +#ifdef VARYINGS_NEED_POSITION_WS + float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS); +#else + // Unused + float3 V = float3(1.0, 1.0, 1.0); // Avoid the division by 0 +#endif + + SurfaceData surfaceData; + BuiltinData builtinData; + GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData); + + BSDFData bsdfData = ConvertSurfaceDataToBSDFData(input.positionSS.xy, surfaceData); + + PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); + + outColor = float4(0.0, 0.0, 0.0, 0.0); + + // We need to skip lighting when doing debug pass because the debug pass is done before lighting so some buffers may not be properly initialized potentially causing crashes on PS4. + +#ifdef DEBUG_DISPLAY + // Init in debug display mode to quiet warning +#ifdef OUTPUT_SPLIT_LIGHTING + outDiffuseLighting = 0; + ENCODE_INTO_SSSBUFFER(surfaceData, posInput.positionSS, outSSSBuffer); +#endif + float4 Set_UV0 = input.texCoord0; + float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)); + + surfaceData.baseColor = _MainTex_var.xyz; + // Same code in ShaderPassForwardUnlit.shader + // Reminder: _DebugViewMaterialArray[i] + // i==0 -> the size used in the buffer + // i>0 -> the index used (0 value means nothing) + // The index stored in this buffer could either be + // - a gBufferIndex (always stored in _DebugViewMaterialArray[1] as only one supported) + // - a property index which is different for each kind of material even if reflecting the same thing (see MaterialSharedProperty) + bool viewMaterial = false; + int bufferSize = _DebugViewMaterialArray[0].x; + if (bufferSize != 0) + { + bool needLinearToSRGB = false; + float3 result = float3(1.0, 0.0, 1.0); + + // Loop through the whole buffer + // Works because GetSurfaceDataDebug will do nothing if the index is not a known one + for (int index = 1; index <= bufferSize; index++) + { + int indexMaterialProperty = _DebugViewMaterialArray[index].x; + + // skip if not really in use + if (indexMaterialProperty != 0) + { + viewMaterial = true; + + GetPropertiesDataDebug(indexMaterialProperty, result, needLinearToSRGB); + GetVaryingsDataDebug(indexMaterialProperty, input, result, needLinearToSRGB); + GetBuiltinDataDebug(indexMaterialProperty, builtinData, posInput, result, needLinearToSRGB); + GetSurfaceDataDebug(indexMaterialProperty, surfaceData, result, needLinearToSRGB); + GetBSDFDataDebug(indexMaterialProperty, bsdfData, result, needLinearToSRGB); + } + } + + // TEMP! + // For now, the final blit in the backbuffer performs an sRGB write + // So in the meantime we apply the inverse transform to linear data to compensate, unless we output to AOVs. + if (!needLinearToSRGB && _DebugAOVOutput == 0) + result = SRGBToLinear(max(0, result)); + + outColor = float4(result, 1.0); + } + + if (!viewMaterial) + { + if (_DebugFullScreenMode == FULLSCREENDEBUGMODE_VALIDATE_DIFFUSE_COLOR || _DebugFullScreenMode == FULLSCREENDEBUGMODE_VALIDATE_SPECULAR_COLOR) + { + float3 result = float3(0.0, 0.0, 0.0); + + GetPBRValidatorDebug(surfaceData, result); + + outColor = float4(result, 1.0f); + } + else if (_DebugFullScreenMode == FULLSCREENDEBUGMODE_TRANSPARENCY_OVERDRAW) + { + float4 result = _DebugTransparencyOverdrawWeight * float4(TRANSPARENCY_OVERDRAW_COST, TRANSPARENCY_OVERDRAW_COST, TRANSPARENCY_OVERDRAW_COST, TRANSPARENCY_OVERDRAW_A); + outColor = result; + } + else +#endif + { +#ifdef _SURFACE_TYPE_TRANSPARENT + uint featureFlags = LIGHT_FEATURE_MASK_FLAGS_TRANSPARENT; +#else + uint featureFlags = LIGHT_FEATURE_MASK_FLAGS_OPAQUE; +#endif + LightLoopOutput lightLoopOutput; + LightLoop(V, posInput, preLightData, bsdfData, builtinData, featureFlags, lightLoopOutput); + + // Alias + float3 diffuseLighting = lightLoopOutput.diffuseLighting; + float3 specularLighting = lightLoopOutput.specularLighting; + + diffuseLighting *= GetCurrentExposureMultiplier(); + specularLighting *= GetCurrentExposureMultiplier(); + +#ifdef OUTPUT_SPLIT_LIGHTING + if (_EnableSubsurfaceScattering != 0 && ShouldOutputSplitLighting(bsdfData)) + { + outColor = float4(specularLighting, 1.0); + outDiffuseLighting = float4(TagLightingForSSS(diffuseLighting), 1.0); + } + else + { + outColor = float4(diffuseLighting + specularLighting, 1.0); + outDiffuseLighting = 0; + } + ENCODE_INTO_SSSBUFFER(surfaceData, posInput.positionSS, outSSSBuffer); +#else + outColor = ApplyBlendMode(diffuseLighting, specularLighting, builtinData.opacity); + outColor = EvaluateAtmosphericScattering(posInput, V, outColor); +#endif + +#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR + VaryingsPassToPS inputPass = UnpackVaryingsPassToPS(packedInput.vpass); + bool forceNoMotion = any(unity_MotionVectorsParams.yw == 0.0); + // outMotionVec is already initialize at the value of forceNoMotion (see above) + if (!forceNoMotion) + { + float2 motionVec = CalculateMotionVector(inputPass.positionCS, inputPass.previousPositionCS); + EncodeMotionVector(motionVec * 0.5, outMotionVec); + outMotionVec.zw = 1.0; + } +#endif + } + +#ifdef DEBUG_DISPLAY + } +#endif + +#ifdef _DEPTHOFFSET_ON + outputDepth = posInput.deviceDepth; +#endif + +#ifdef UNITY_VIRTUAL_TEXTURING + outVTFeedback = builtinData.vtPackedFeedback; +#endif +} diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShaderPassForward.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShaderPassForward.hlsl.meta new file mode 100644 index 0000000..b1fbd5d --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShaderPassForward.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7e90380c2b26b694b99ad3d90989105b +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShaderPassForwardUTS.hlsl b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShaderPassForwardUTS.hlsl new file mode 100644 index 0000000..ea85884 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShaderPassForwardUTS.hlsl @@ -0,0 +1,561 @@ +//Unity Toon Shader/HDRP +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Universal RP/HDRP) + +#if SHADERPASS != SHADERPASS_FORWARD +#error SHADERPASS_is_not_correctly_define +#endif + + +#ifndef SCALARIZE_LIGHT_LOOP +// We perform scalarization only for forward rendering as for deferred loads will already be scalar since tiles will match waves and therefore all threads will read from the same tile. +// More info on scalarization: https://flashypixels.wordpress.com/2018/11/10/intro-to-gpu-scalarization-part-2-scalarize-all-the-lights/ . +// Note that it is currently disabled on gamecore platforms for issues with wave intrinsics and the new compiler, it will be soon investigated, but we disable it in the meantime. +#define SCALARIZE_LIGHT_LOOP (defined(PLATFORM_SUPPORTS_WAVE_INTRINSICS) && !defined(LIGHTLOOP_DISABLE_TILE_AND_CLUSTER) && !defined(SHADER_API_GAMECORE) && SHADERPASS == SHADERPASS_FORWARD) +#endif + +#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/MotionVectorVertexShaderCommon.hlsl" + +PackedVaryingsType Vert(AttributesMesh inputMesh, AttributesPass inputPass) +{ + VaryingsType varyingsType; + varyingsType.vmesh = VertMesh(inputMesh); + return MotionVectorVS(varyingsType, inputMesh, inputPass); +} + +#ifdef TESSELLATION_ON + +PackedVaryingsToPS VertTesselation(VaryingsToDS input) +{ + VaryingsToPS output; + output.vmesh = VertMeshTesselation(input.vmesh); + MotionVectorPositionZBias(output); + + output.vpass.positionCS = input.vpass.positionCS; + output.vpass.previousPositionCS = input.vpass.previousPositionCS; + + return PackVaryingsToPS(output); +} + +#endif // TESSELLATION_ON + +#else // _WRITE_TRANSPARENT_MOTION_VECTOR + +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl" + +PackedVaryingsType Vert(AttributesMesh inputMesh) +{ + VaryingsType varyingsType; + varyingsType.vmesh = VertMesh(inputMesh); + + return PackVaryingsType(varyingsType); +} + +#ifdef TESSELLATION_ON + +PackedVaryingsToPS VertTesselation(VaryingsToDS input) +{ + VaryingsToPS output; + output.vmesh = VertMeshTesselation(input.vmesh); + + return PackVaryingsToPS(output); +} + + +#endif // TESSELLATION_ON + +#endif // _WRITE_TRANSPARENT_MOTION_VECTOR + + +#ifdef TESSELLATION_ON +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/TessellationShare.hlsl" +#endif + +/////////////////////////////////////////////////////////////////////////////// +// Attenuation Functions / +/////////////////////////////////////////////////////////////////////////////// +// Grafted from URP +// Matches Unity Vanila attenuation +// Attenuation smoothly decreases to light range. +float DistanceAttenuation(float distanceSqr, half2 distanceAttenuation) +{ + // We use a shared distance attenuation for additional directional and puctual lights + // for directional lights attenuation will be 1 + float lightAtten = rcp(distanceSqr); + +#if SHADER_HINT_NICE_QUALITY + // Use the smoothing factor also used in the Unity lightmapper. + half factor = distanceSqr * distanceAttenuation.x; + half smoothFactor = saturate(1.0h - factor * factor); + smoothFactor = smoothFactor * smoothFactor; +#else + // We need to smoothly fade attenuation to light range. We start fading linearly at 80% of light range + // Therefore: + // fadeDistance = (0.8 * 0.8 * lightRangeSq) + // smoothFactor = (lightRangeSqr - distanceSqr) / (lightRangeSqr - fadeDistance) + // We can rewrite that to fit a MAD by doing + // distanceSqr * (1.0 / (fadeDistanceSqr - lightRangeSqr)) + (-lightRangeSqr / (fadeDistanceSqr - lightRangeSqr) + // distanceSqr * distanceAttenuation.y + distanceAttenuation.z + half smoothFactor = saturate(distanceSqr * distanceAttenuation.x + distanceAttenuation.y); +#endif + + return lightAtten * smoothFactor; +} + +float ApplyChannelAlpha( float alpha) +{ + return lerp(1.0, alpha, _ComposerMaskMode); +} + + +bool UtsUseScreenSpaceShadow(DirectionalLightData light, float3 normalWS) +{ +#if defined(RAY_TRACED_SCREEN_SPACE_SHADOW_FLAG) + // Two different options are possible here + // - We have a ray trace shadow in which case we have no valid signal for a transmission and we need to fallback on the rasterized shadow + // - We have a screen space shadow and it already contains the transmission shadow and we can use it straight away + bool visibleLight = 0.5 * dot(normalWS, -light.forward) + 0.5 > 0.0; + bool validScreenSpaceShadow = (light.screenSpaceShadowIndex & SCREEN_SPACE_SHADOW_INDEX_MASK) != INVALID_SCREEN_SPACE_SHADOW; + bool rayTracedShadow = (light.screenSpaceShadowIndex & RAY_TRACED_SCREEN_SPACE_SHADOW_FLAG) != 0; + return (validScreenSpaceShadow && ((rayTracedShadow && visibleLight) || !rayTracedShadow)); +#else + return ( (light.screenSpaceShadowIndex & SCREEN_SPACE_SHADOW_INDEX_MASK) != INVALID_SCREEN_SPACE_SHADOW); +#endif +} + +#ifdef UNITY_VIRTUAL_TEXTURING +#define VT_BUFFER_TARGET SV_Target1 +#define EXTRA_BUFFER_TARGET SV_Target2 +#else +#define EXTRA_BUFFER_TARGET SV_Target1 +#endif + +uniform sampler2D _RaytracedHardShadow; +float4 _RaytracedHardShadow_TexelSize; + + + +void Frag(PackedVaryingsToPS packedInput, +#ifdef OUTPUT_SPLIT_LIGHTING + out float4 outColor : SV_Target0, // outSpecularLighting + #ifdef UNITY_VIRTUAL_TEXTURING + out float4 outVTFeedback : VT_BUFFER_TARGET, + #endif + out float4 outDiffuseLighting : EXTRA_BUFFER_TARGET, + OUTPUT_SSSBUFFER(outSSSBuffer) +#else + out float4 outColor : SV_Target0 + #ifdef UNITY_VIRTUAL_TEXTURING + ,out float4 outVTFeedback : VT_BUFFER_TARGET + #endif +#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR + , out float4 outMotionVec : EXTRA_BUFFER_TARGET +#endif // _WRITE_TRANSPARENT_MOTION_VECTOR +#endif // OUTPUT_SPLIT_LIGHTING +#ifdef _DEPTHOFFSET_ON + , out float outputDepth : SV_Depth +#endif +) +{ +#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR + // Init outMotionVector here to solve compiler warning (potentially unitialized variable) + // It is init to the value of forceNoMotion (with 2.0) + outMotionVec = float4(2.0, 0.0, 0.0, 0.0); +#endif + + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput); + + FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh); +#if defined(PLATFORM_SUPPORTS_PRIMITIVE_ID_IN_PIXEL_SHADER) && SHADER_STAGE_FRAGMENT +#if (defined(VARYINGS_NEED_PRIMITIVEID) || (SHADERPASS == SHADERPASS_FULL_SCREEN_DEBUG)) + input.primitiveID = packedInput.primitiveID; +#endif +#endif + +#if defined(VARYINGS_NEED_CULLFACE) && SHADER_STAGE_FRAGMENT + input.isFrontFace = IS_FRONT_VFACE(packedInput.cullFace, true, false); +#endif + + float4 Set_UV0 = input.texCoord0; + UTSData utsData; + + // We need to readapt the SS position as our screen space positions are for a low res buffer, but we try to access a full res buffer. + input.positionSS.xy = _OffScreenRendering > 0 ? (input.positionSS.xy * _OffScreenDownsampleFactor) : input.positionSS.xy; + + uint2 tileIndex = uint2(input.positionSS.xy) / GetTileSize(); + + // input.positionSS is SV_Position + PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, tileIndex); + +#ifdef VARYINGS_NEED_POSITION_WS + float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS); +#else + // Unused + float3 V = float3(1.0, 1.0, 1.0); // Avoid the division by 0 +#endif +#ifdef _SURFACE_TYPE_TRANSPARENT + uint featureFlags = LIGHT_FEATURE_MASK_FLAGS_TRANSPARENT; +#else + uint featureFlags = LIGHT_FEATURE_MASK_FLAGS_OPAQUE; +#endif + SurfaceData surfaceData; // used to get normalWS; + BuiltinData builtinData; // used to get lightlayersAndSoOn + GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData); + + + + BSDFData bsdfData = ConvertSurfaceDataToBSDFData(input.positionSS.xy, surfaceData); // used to calc shadow + PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); // used to calc shadow + + outColor = float4(0.0, 0.0, 0.0, 0.0); + + + + +#define UNITY_PROJ_COORD(a) a +#define UNITY_SAMPLE_SCREEN_SHADOW(tex, uv) tex2Dproj( tex, UNITY_PROJ_COORD(uv) ).r + float inverseClipping = 0; + LightLoopContext context; + context.shadowContext = InitShadowContext(); + context.shadowValue = 1; + context.sampleReflection = 0; +#if UNITY_VERSION >= 202120 && UNITY_VERSION < 202320 + context.splineVisibility = -1; +#endif +#ifdef APPLY_FOG_ON_SKY_REFLECTIONS + context.positionWS = posInput.positionWS; +#endif + +#if defined(DEBUG_DISPLAY) && !defined(UTS_DEBUG_SHADOWMAP) && !defined(UTS_DEBUG_SELFSHADOW) + // In Unity's SceneView, the Unlit mode is internally handled using the DEBUG_DISPLAY define. + // In official HDRP shaders, this macro is often combined with other debug macros to display various kinds of debug information, + // However, UTS currently does not implement these advanced debug visualizations. + // Therefore, if no other debug macros (e.g., UTS_DEBUG_SHADOWMAP, UTS_DEBUG_SELFSHADOW) are defined, we treat this as SceneView's Unlit mode and simply output the main texture color. + + float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, TRANSFORM_TEX(input.texCoord0, _MainTex)); + outColor = float4(_MainTex_var.rgb, 1.0f); + #ifdef _DEPTHOFFSET_ON + outputDepth = posInput.deviceDepth; + #endif + #ifdef UNITY_VIRTUAL_TEXTURING + + outVTFeedback = builtinData.vtPackedFeedback; + #endif + return; +#endif + + // With XR single-pass and camera-relative: offset position to do lighting computations from the combined center view (original camera matrix). + // This is required because there is only one list of lights generated on the CPU. Shadows are also generated once and shared between the instanced views. + ApplyCameraRelativeXR(posInput.positionWS); + + // Initialize the contactShadow and contactShadowFade fields + InitContactShadow(posInput, context); + + float3 i_normalDir = surfaceData.normalWS; + + int mainLightIndex = -1; + float channelAlpha = 0.0f; + float3 finalColor = float3(0.0f, 0.0f, 0.0f); + if (featureFlags & LIGHTFEATUREFLAGS_DIRECTIONAL) + { + // Evaluate sun shadows. + if (_DirectionalShadowIndex >= 0) + { + DirectionalLightData light = _DirectionalLightDatas[_DirectionalShadowIndex]; +#if defined(SCREEN_SPACE_SHADOWS_ON) && !defined(_SURFACE_TYPE_TRANSPARENT) + if (UtsUseScreenSpaceShadow(light, bsdfData.normalWS)) + { + // HDRP Contact Shadow + context.shadowValue = GetScreenSpaceColorShadow(posInput, light.screenSpaceShadowIndex).SHADOW_TYPE_SWIZZLE; + } + else +#endif + { + // TODO: this will cause us to load from the normal buffer first. Does this cause a performance problem? + float3 L = -light.forward; + + // Is it worth sampling the shadow map? + if ((light.lightDimmer > 0) && (light.shadowDimmer > 0) && // Note: Volumetric can have different dimmer, thus why we test it here + IsNonZeroBSDF(V, L, preLightData, bsdfData) && + !ShouldEvaluateThickObjectTransmission(V, L, preLightData, bsdfData, light.shadowIndex)) + { + + { + context.shadowValue = GetDirectionalShadowAttenuation(context.shadowContext, + posInput.positionSS, posInput.positionWS, GetNormalForShadowBias(bsdfData), + light.shadowIndex, L); + + } + + + } + } + + } + + + // because of light culling or light layer, we can not adopt this + // https://unity.slack.com/archives/C06V7HDDW/p1580959470180800 + // int mainLightIndex = _DirectionalShadowIndex; + mainLightIndex = GetUtsMainLightIndex(builtinData); + DirectionalLightData lightData; + ZERO_INITIALIZE(DirectionalLightData, lightData); + if (mainLightIndex >= 0) + { + lightData = _DirectionalLightDatas[mainLightIndex]; + } + + float3 lightColor = ApplyCurrentExposureMultiplier(lightData.color); + float3 lightDirection = -lightData.forward; + + +#if defined(UTS_DEBUG_SELFSHADOW) + if (_DirectionalShadowIndex >= 0) + finalColor = UTS_SelfShdowMainLight(context, input, _DirectionalShadowIndex); +#elif defined(_SHADINGGRADEMAP)|| defined(UTS_DEBUG_SHADOWMAP) + finalColor = UTS_MainLightShadingGrademap(context, input, lightDirection, lightColor, inverseClipping, channelAlpha, utsData); +#else + finalColor = UTS_MainLight(context, input, lightDirection, lightColor, inverseClipping, channelAlpha, utsData); +#endif + + + + + int i = 0; // Declare once to avoid the D3D11 compiler warning. + for (i = 0; i < (int)_DirectionalLightCount; ++i) + { + if (IsMatchingLightLayer(_DirectionalLightDatas[i].lightLayers, builtinData.renderingLayers)) + { + if (mainLightIndex != i) + { + + float3 lightColor = ApplyCurrentExposureMultiplier(_DirectionalLightDatas[i].color); + float3 lightDirection = -_DirectionalLightDatas[i].forward; + float notDirectional = 0.0f; +#if defined(UTS_DEBUG_SELFSHADOW) + +#elif defined(_SHADINGGRADEMAP)|| defined(UTS_DEBUG_SHADOWMAP) + + finalColor += UTS_OtherLightsShadingGrademap(input, i_normalDir, lightColor, lightDirection, notDirectional, channelAlpha); +#else + finalColor += UTS_OtherLights(input, i_normalDir, lightColor, lightDirection, notDirectional, channelAlpha); +#endif + + } + } + } + + } + + +#undef EVALUATE_BSDF_ENV +#undef EVALUATE_BSDF_ENV_SKY + + if (featureFlags & LIGHTFEATUREFLAGS_PUNCTUAL) + { + uint lightCount, lightStart; + +#ifndef LIGHTLOOP_DISABLE_TILE_AND_CLUSTER + GetCountAndStart(posInput, LIGHTCATEGORY_PUNCTUAL, lightStart, lightCount); +#else // LIGHTLOOP_DISABLE_TILE_AND_CLUSTER + lightCount = _PunctualLightCount; + lightStart = 0; +#endif + bool fastPath = false; + #if SCALARIZE_LIGHT_LOOP + uint lightStartLane0; + fastPath = IsFastPath(lightStart, lightStartLane0); + + if (fastPath) + { + lightStart = lightStartLane0; + } + #endif + + + + // Scalarized loop. All lights that are in a tile/cluster touched by any pixel in the wave are loaded (scalar load), only the one relevant to current thread/pixel are processed. + // For clarity, the following code will follow the convention: variables starting with s_ are meant to be wave uniform (meant for scalar register), + // v_ are variables that might have different value for each thread in the wave (meant for vector registers). + // This will perform more loads than it is supposed to, however, the benefits should offset the downside, especially given that light data accessed should be largely coherent. + // Note that the above is valid only if wave intriniscs are supported. + + uint v_lightListOffset = 0; + uint v_lightIdx = lightStart; + float channelAlpha = 0.0f; + [loop] // vulkan shader compiler can not unroll. + while (v_lightListOffset < lightCount) + { + v_lightIdx = FetchIndex(lightStart, v_lightListOffset); +#if SCALARIZE_LIGHT_LOOP + uint s_lightIdx = ScalarizeElementIndex(v_lightIdx, fastPath); +#else + uint s_lightIdx = v_lightIdx; +#endif + if (s_lightIdx == -1) + break; + + LightData s_lightData = FetchLight(s_lightIdx); + + + // If current scalar and vector light index match, we process the light. The v_lightListOffset for current thread is increased. + // Note that the following should really be ==, however, since helper lanes are not considered by WaveActiveMin, such helper lanes could + // end up with a unique v_lightIdx value that is smaller than s_lightIdx hence being stuck in a loop. All the active lanes will not have this problem. + if (s_lightIdx >= v_lightIdx) + { + v_lightListOffset++; + if (IsMatchingLightLayer(s_lightData.lightLayers, builtinData.renderingLayers)) + { + float3 L; + float4 distances; // {d, d^2, 1/d, d_proj} + GetPunctualLightVectors(posInput.positionWS, s_lightData, L, distances); + real attenuation = PunctualLightAttenuation(distances, s_lightData.rangeAttenuationScale, s_lightData.rangeAttenuationBias, + s_lightData.angleScale, s_lightData.angleOffset); + float3 additionalLightColor = ApplyCurrentExposureMultiplier(s_lightData.color) * attenuation; + const float notDirectional = 1.0f; + + float3 lightColor = ApplyCurrentExposureMultiplier(s_lightData.color); + float3 lightDirection = -s_lightData.forward; + +#if defined(UTS_DEBUG_SELFSHADOW) + +#elif defined(_SHADINGGRADEMAP) || defined(UTS_DEBUG_SHADOWMAP) + if (mainLightIndex == -1 && s_lightData.lightType == GPULIGHTTYPE_PROJECTOR_BOX) + { + float shadow = (float)EvaluateShadow_Punctual(context, posInput, s_lightData, builtinData, GetNormalForShadowBias(bsdfData), L, distances); + context.shadowValue = shadow; // min(context.shadowValue, shadow); // ComputeShadowColor(shadow, s_lightData.shadowTint, s_lightData.penumbraTint); + + finalColor += UTS_MainLightShadingGrademap(context, input, lightDirection, lightColor, inverseClipping, channelAlpha, utsData); + } + else + { + finalColor += UTS_OtherLightsShadingGrademap(input, i_normalDir, additionalLightColor, L, notDirectional, channelAlpha); + } + + +#else + if (mainLightIndex == -1 && s_lightData.lightType == GPULIGHTTYPE_PROJECTOR_BOX) + { + float shadow = (float)EvaluateShadow_Punctual(context, posInput, s_lightData, builtinData, GetNormalForShadowBias(bsdfData), L, distances); + context.shadowValue = shadow; // min(context.shadowValue, shadow); // ComputeShadowColor(shadow, s_lightData.shadowTint, s_lightData.penumbraTint); + finalColor += UTS_MainLight(context, input, lightDirection, lightColor, inverseClipping, channelAlpha, utsData); + } + else + { + finalColor += UTS_OtherLights(input, i_normalDir, additionalLightColor, L, notDirectional, channelAlpha); + } +#endif + } + + } + } + } + //v.2.0.7 + +#ifdef _EMISSIVE_SIMPLE + float4 _Emissive_Tex_var = tex2D(_Emissive_Tex, TRANSFORM_TEX(Set_UV0, _Emissive_Tex)); + float emissiveMask = _Emissive_Tex_var.a; + emissive = _Emissive_Tex_var.rgb * _Emissive_Color.rgb * emissiveMask; +#elif _EMISSIVE_ANIMATION + //v.2.0.7 Calculation View Coord UV for Scroll + float3 viewNormal_Emissive = (mul(UNITY_MATRIX_V, float4(i_normalDir, 0))).xyz; + float3 NormalBlend_Emissive_Detail = viewNormal_Emissive * float3(-1, -1, 1); + float3 NormalBlend_Emissive_Base = (mul(UNITY_MATRIX_V, float4(utsData.viewDirection, 0)).xyz * float3(-1, -1, 1)) + float3(0, 0, 1); + float3 noSknewViewNormal_Emissive = NormalBlend_Emissive_Base * dot(NormalBlend_Emissive_Base, NormalBlend_Emissive_Detail) / NormalBlend_Emissive_Base.z - NormalBlend_Emissive_Detail; + float2 _ViewNormalAsEmissiveUV = noSknewViewNormal_Emissive.xy * 0.5 + 0.5; + float2 _ViewCoord_UV = RotateUV(_ViewNormalAsEmissiveUV, -(utsData.cameraDir * utsData.cameraRoll), float2(0.5, 0.5), 1.0); + //Invert if it's "inside the mirror". + if (utsData.signMirror < 0) { + _ViewCoord_UV.x = 1 - _ViewCoord_UV.x; + } + else { + _ViewCoord_UV = _ViewCoord_UV; + } + float2 emissive_uv = lerp(Set_UV0, _ViewCoord_UV, _Is_ViewCoord_Scroll); + // + float4 _time_var = _Time; + float _base_Speed_var = (_time_var.g * _Base_Speed); + float _Is_PingPong_Base_var = lerp(_base_Speed_var, sin(_base_Speed_var), _Is_PingPong_Base); + float2 scrolledUV = emissive_uv + float2(_Scroll_EmissiveU, _Scroll_EmissiveV) * _Is_PingPong_Base_var; + float rotateVelocity = _Rotate_EmissiveUV * 3.141592654; + float2 _rotate_EmissiveUV_var = RotateUV(scrolledUV, rotateVelocity, float2(0.5, 0.5), _Is_PingPong_Base_var); + float4 _Emissive_Tex_var = tex2D(_Emissive_Tex, TRANSFORM_TEX(Set_UV0, _Emissive_Tex)); + float emissiveMask = _Emissive_Tex_var.a; + _Emissive_Tex_var = tex2D(_Emissive_Tex, TRANSFORM_TEX(_rotate_EmissiveUV_var, _Emissive_Tex)); + float _colorShift_Speed_var = 1.0 - cos(_time_var.g * _ColorShift_Speed); + float viewShift_var = smoothstep(0.0, 1.0, max(0, dot(utsData.normalDirection, utsData.viewDirection))); + float4 colorShift_Color = lerp(_Emissive_Color, lerp(_Emissive_Color, _ColorShift, _colorShift_Speed_var), _Is_ColorShift); + float4 viewShift_Color = lerp(_ViewShift, colorShift_Color, viewShift_var); + float4 emissive_Color = lerp(colorShift_Color, viewShift_Color, _Is_ViewShift); + emissive = emissive_Color.rgb * _Emissive_Tex_var.rgb * emissiveMask; + + // + //v.2.0.6: GI_Intensity with Intensity Multiplier Filter +#endif + // float3 envColor = aggregateLighting.direct.diffuse; // ??? + float3 envColor = float3(0.2f, 0.2f, 0.2f); + float3 envLightColor = envColor; + float3 envLightIntensity = GetLightAttenuation(envLightColor) < 1 ? GetLightAttenuation(envLightColor) : 1; + float3 finalColorWoEmissive = SATURATE_IF_SDR(finalColor) + (envLightColor * envLightIntensity * _GI_Intensity * smoothstep(1, 0, envLightIntensity / 2)); + + finalColorWoEmissive = GetExposureAdjustedColor(finalColorWoEmissive ); + finalColorWoEmissive = ApplyCompensation(finalColorWoEmissive); + finalColor = finalColorWoEmissive + emissive; + + +#if defined(_SHADINGGRADEMAP) || defined(UTS_DEBUG_SHADOWMAP) || defined(UTS_DEBUG_SELFSHADOW) + //v.2.0.4 + #ifdef _IS_TRANSCLIPPING_OFF + + outColor = float4(finalColor, 1 * ApplyChannelAlpha(channelAlpha)); + + #elif _IS_TRANSCLIPPING_ON + float Set_Opacity = SATURATE_IF_SDR((inverseClipping + _Tweak_transparency)); + + outColor = float4(finalColor, Set_Opacity * ApplyChannelAlpha(channelAlpha)); + + #endif + +#else //#if defined(_SHADINGGRADEMAP) + + #ifdef _IS_CLIPPING_OFF + //DoubleShadeWithFeather + + outColor = float4(finalColor, 1 * ApplyChannelAlpha(channelAlpha)); + + #elif _IS_CLIPPING_MODE + //DoubleShadeWithFeather_Clipping + + outColor = float4(finalColor, 1 * ApplyChannelAlpha(channelAlpha)); + + #elif _IS_CLIPPING_TRANSMODE + //DoubleShadeWithFeather_TransClipping + float Set_Opacity = SATURATE_IF_SDR((inverseClipping + _Tweak_transparency)); + outColor = float4(finalColor, Set_Opacity * ApplyChannelAlpha(channelAlpha)); + #endif +#endif //#if defined(_SHADINGGRADEMAP) + +#if defined(UTS_DEBUG_SHADOWMAP) || defined(UTS_DEBUG_SELFSHADOW) + outColor.rgb = 1; + #ifdef UTS_DEBUG_SELFSHADOW + outColor.rgb = min(finalColor, outColor.rgb); + #endif + + #ifdef UTS_DEBUG_SHADOWMAP + #ifdef UTS_DEBUG_SHADOWMAP_BINALIZATION + outColor.rgb = min(context.shadowValue < 0.9f ? clamp(context.shadowValue - 0.2, 0.0, 0.9) : 1.0f, outColor.rgb); + #else + outColor.rgb = min(context.shadowValue, outColor.rgb); + #endif + #endif // ifdef UTS_DEBUG_SHADOWMAP +#endif // defined(UTS_DEBUG_SHADOWMAP) || defined(UTS_DEBUG_SELFSHADOW) + +#ifdef _DEPTHOFFSET_ON + outputDepth = posInput.deviceDepth; +#endif +#ifdef UNITY_VIRTUAL_TEXTURING + + outVTFeedback = builtinData.vtPackedFeedback; +#endif +} diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShaderPassForwardUTS.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShaderPassForwardUTS.hlsl.meta new file mode 100644 index 0000000..5b7c417 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShaderPassForwardUTS.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d797988f43f630944b3b0de4c7cfab37 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShadingGrademapMainLight.hlsl b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShadingGrademapMainLight.hlsl new file mode 100644 index 0000000..f9c25f9 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShadingGrademapMainLight.hlsl @@ -0,0 +1,399 @@ +//Unity Toon Shader/HDRP +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Universal RP/HDRP) + + +#ifndef DirectionalShadowType +# if (SHADEROPTIONS_RAYTRACING && (defined(SHADER_API_D3D11) || defined(SHADER_API_D3D12)) && !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)) +# define DirectionalShadowType float3 +# else +# define DirectionalShadowType float +# endif +#endif + +float3 UTS_MainLightShadingGrademap(LightLoopContext lightLoopContext, FragInputs input, float3 mainLihgtDirection, float3 mainLightColor, out float inverseClipping, out float channelOutAlpha, out UTSData utsData) +{ + channelOutAlpha = 1.0f; + + uint2 tileIndex = uint2(input.positionSS.xy) / GetTileSize(); + inverseClipping = 0; + // input.positionSS is SV_Position + PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, tileIndex); + + +#ifdef VARYINGS_NEED_POSITION_WS + float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS); +#else + // Unused + float3 V = float3(1.0, 1.0, 1.0); // Avoid the division by 0 +#endif + SurfaceData surfaceData; + BuiltinData builtinData; + GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData); + + BSDFData bsdfData = ConvertSurfaceDataToBSDFData(input.positionSS.xy, surfaceData); + + PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); + /* todo. these should be put int a struct */ + float4 Set_UV0 = input.texCoord0; + float3x3 tangentTransform = input.tangentToWorld; + //UnpackNormalmapRGorAG(SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, texCoords)) + float4 n = SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, Set_UV0.xy); // todo. TRANSFORM_TEX +// float3 _NormalMap_var = UnpackNormalScale(tex2D(_NormalMap, TRANSFORM_TEX(Set_UV0, _NormalMap)), _BumpScale); + float3 _NormalMap_var = UnpackNormalScale(n, _BumpScale); + float3 normalLocal = _NormalMap_var.rgb; + utsData.normalDirection = normalize(mul(normalLocal, tangentTransform)); // Perturbed normals + + float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)); + float3 i_normalDir = surfaceData.normalWS; + utsData.viewDirection = V; + + + /* to here todo. these should be put int a struct */ + //v.2.0.4 +#ifdef _IS_TRANSCLIPPING_OFF +// +#elif _IS_TRANSCLIPPING_ON + float4 _ClippingMask_var = SAMPLE_TEXTURE2D(_ClippingMask, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)); + float Set_MainTexAlpha = _MainTex_var.a; + float _IsBaseMapAlphaAsClippingMask_var = lerp(_ClippingMask_var.r, Set_MainTexAlpha, _IsBaseMapAlphaAsClippingMask); + float _Inverse_Clipping_var = lerp(_IsBaseMapAlphaAsClippingMask_var, (1.0 - _IsBaseMapAlphaAsClippingMask_var), _Inverse_Clipping); + float Set_Clipping = saturate((_Inverse_Clipping_var + _Clipping_Level)); + clip(Set_Clipping - 0.5); + inverseClipping = _Inverse_Clipping_var; +#endif + + + + DirectionalShadowType shadowAttenuation = (DirectionalShadowType)lightLoopContext.shadowValue; + + + + //v.2.0.4 + + float3 defaultLightDirection = normalize(UNITY_MATRIX_V[2].xyz + UNITY_MATRIX_V[1].xyz); + //v.2.0.5 + float3 defaultLightColor = saturate(max(float3(0.05, 0.05, 0.05) * _Unlit_Intensity, max( + SampleBakedGI_UTS(posInput.positionWS, float3(0.0, 0.0, 0.0), input.texCoord1.xy, input.texCoord2.xy, true), + SampleBakedGI_UTS(posInput.positionWS, float3(0.0, -1.0, 0.0), input.texCoord1.xy, input.texCoord2.xy, true) + ) * _Unlit_Intensity)); + float3 customLightDirection = normalize(mul(UNITY_MATRIX_M, float4(((float3(1.0, 0.0, 0.0) * _Offset_X_Axis_BLD * 10) + (float3(0.0, 1.0, 0.0) * _Offset_Y_Axis_BLD * 10) + (float3(0.0, 0.0, -1.0) * lerp(-1.0, 1.0, _Inverse_Z_Axis_BLD))), 0)).xyz); + float3 lightDirection = normalize(lerp(defaultLightDirection, mainLihgtDirection.xyz, any(mainLihgtDirection.xyz))); + lightDirection = lerp(lightDirection, customLightDirection, _Is_BLD); + float3 originalLightColor = mainLightColor.rgb; + + originalLightColor = lerp(originalLightColor, clamp(originalLightColor, ConvertFromEV100(_ToonEvAdjustmentValueMin ), ConvertFromEV100(_ToonEvAdjustmentValueMax)), _ToonEvAdjustmentCurve); + float3 lightColor = lerp(max(defaultLightColor, originalLightColor), max(defaultLightColor, saturate(originalLightColor)), max(_Is_Filter_LightColor, _ToonLightHiCutFilter)); + + + ////// Lighting: + float3 halfDirection = normalize(utsData.viewDirection + lightDirection); + //v.2.0.5 + _Color = _BaseColor; + + + float3 Set_LightColor = lightColor.rgb; + + float3 Set_BaseColor = lerp((_BaseColor.rgb * _MainTex_var.rgb), ((_BaseColor.rgb * _MainTex_var.rgb) * Set_LightColor), _Is_LightColor_Base); + float Set_BaseColorAlpha = _BaseColorVisible; + float3 clippingColor = float3(1.0f, 1.0f, 1.0f); +#ifdef _IS_CLIPPING_MATTE + if (_ClippingMatteMode == 1) + { + clippingColor = Set_BaseColor; + return clippingColor; + } +#endif // _IS_CLIPPING_MATTE + +#ifdef UTS_LAYER_VISIBILITY + + float4 overridingColor = lerp(_BaseColorMaskColor, float4(_BaseColorMaskColor.w, _BaseColorMaskColor.w, _BaseColorMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_BaseColorOverridden, _ComposerMaskMode); + Set_BaseColor = lerp(Set_BaseColor, overridingColor.rgb, maskEnabled); + Set_BaseColor *= _BaseColorVisible; + +#endif //#ifdef UTS_LAYER_VISIBILITY + //v.2.0.5 + float4 _1st_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_1st_ShadeMap, sampler_MainTex,TRANSFORM_TEX(Set_UV0, _MainTex)), _MainTex_var, _Use_BaseAs1st); + float3 _Is_LightColor_1st_Shade_var = lerp((_1st_ShadeMap_var.rgb * _1st_ShadeColor.rgb), ((_1st_ShadeMap_var.rgb * _1st_ShadeColor.rgb) * Set_LightColor), _Is_LightColor_1st_Shade); + float _HalfLambert_var = 0.5 * dot(lerp(i_normalDir, utsData.normalDirection, _Is_NormalMapToBase), lightDirection) + 0.5; // Half Lambert + //v.2.0.6 + float4 _ShadingGradeMap_var = tex2Dlod(_ShadingGradeMap, float4(TRANSFORM_TEX(Set_UV0, _ShadingGradeMap), 0.0, _BlurLevelSGM)); + //v.2.0.6 + //Minimum value is same as the Minimum Feather's value with the Minimum Step's value as threshold. + shadowAttenuation *= 2.0f; + shadowAttenuation = saturate(shadowAttenuation); + + float _SystemShadowsLevel_var = (shadowAttenuation *0.5)+0.5+_Tweak_SystemShadowsLevel > 0.001 ? (shadowAttenuation*0.5)+0.5+_Tweak_SystemShadowsLevel : 0.0001; + + float _ShadingGradeMapLevel_var = _ShadingGradeMap_var.r < 0.95 ? _ShadingGradeMap_var.r + _Tweak_ShadingGradeMapLevel : 1; + + float Set_ShadingGrade = saturate(_ShadingGradeMapLevel_var) * lerp(_HalfLambert_var, (_HalfLambert_var * saturate(_SystemShadowsLevel_var)), _Set_SystemShadowsToBase ); + +// float Set_ShadingGrade = saturate(_ShadingGradeMapLevel_var) * lerp(_HalfLambert_var, (_HalfLambert_var * saturate(1.0 + _Tweak_SystemShadowsLevel)), _Set_SystemShadowsToBase); + + float _1stColorFeatherForMask = lerp(_1st_ShadeColor_Feather, 0.0f, max(_ComposerMaskMode, _FirstShadeOverridden)); + // + float Set_FinalShadowMask = saturate((1.0 + ((Set_ShadingGrade - (_1st_ShadeColor_Step - _1stColorFeatherForMask)) * (0.0 - 1.0)) / (_1st_ShadeColor_Step - (_1st_ShadeColor_Step - _1stColorFeatherForMask)))); // Base and 1st Shade Mask +#ifdef _IS_CLIPPING_MATTE + if (_ClippingMatteMode == 2) + { + clippingColor = _Is_LightColor_1st_Shade_var; + return clippingColor; + } +#endif // _IS_CLIPPING_MATTE + +#ifdef UTS_LAYER_VISIBILITY + { + float4 overridingColor = lerp(_FirstShadeMaskColor, float4(_FirstShadeMaskColor.w, _FirstShadeMaskColor.w, _FirstShadeMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_FirstShadeOverridden, _ComposerMaskMode); + _Is_LightColor_1st_Shade_var = lerp(_Is_LightColor_1st_Shade_var, overridingColor.rgb, maskEnabled); + _Is_LightColor_1st_Shade_var = lerp(_Is_LightColor_1st_Shade_var, Set_BaseColor, 1.0f - _FirstShadeVisible); + } + float Set_1st_ShadeAlpha = _FirstShadeVisible; +#endif //#ifdef UTS_LAYER_VISIBILITY + float3 _BaseColor_var = lerp(Set_BaseColor, _Is_LightColor_1st_Shade_var, Set_FinalShadowMask); + //v.2.0.5 + float4 _2nd_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_2nd_ShadeMap, sampler_MainTex,TRANSFORM_TEX(Set_UV0, _MainTex)), _1st_ShadeMap_var, _Use_1stAs2nd); + float _2ndColorFeatherForMask = lerp(_2nd_ShadeColor_Feather, 0.0f, max(_SecondShadeOverridden, _ComposerMaskMode)); + float Set_ShadeShadowMask = saturate((1.0 + ((Set_ShadingGrade - (_2nd_ShadeColor_Step - _2ndColorFeatherForMask)) * (0.0 - 1.0)) / (_2nd_ShadeColor_Step - (_2nd_ShadeColor_Step - _2ndColorFeatherForMask)))); // 1st and 2nd Shades Mask + //Composition: 3 Basic Colors as Set_FinalBaseColor + +#ifdef UTS_LAYER_VISIBILITY + float3 Set_FinalBaseColor; + { + float4 overridingColor = lerp(_SecondShadeMaskColor, float4(_SecondShadeMaskColor.w, _SecondShadeMaskColor.w, _SecondShadeMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_SecondShadeOverridden, _ComposerMaskMode); + + float3 _Is_LightColor_2nd_Shade_var = lerp((_2nd_ShadeMap_var.rgb * _2nd_ShadeColor.rgb), ((_2nd_ShadeMap_var.rgb * _2nd_ShadeColor.rgb) * Set_LightColor), _Is_LightColor_2nd_Shade); + _Is_LightColor_2nd_Shade_var = lerp(_Is_LightColor_2nd_Shade_var, overridingColor.rgb, maskEnabled); + _Is_LightColor_2nd_Shade_var = lerp(_Is_LightColor_2nd_Shade_var, Set_BaseColor, 1.0f - _SecondShadeVisible); + float Set_2nd_ShadeAlpha = _SecondShadeVisible; + Set_FinalBaseColor = + lerp(_BaseColor_var, + lerp(_Is_LightColor_1st_Shade_var, _Is_LightColor_2nd_Shade_var + , Set_ShadeShadowMask) + , Set_FinalShadowMask); + channelOutAlpha = + lerp(Set_BaseColorAlpha, lerp(Set_1st_ShadeAlpha, Set_2nd_ShadeAlpha, Set_ShadeShadowMask),Set_FinalShadowMask); + + } + +#else + float3 Set_FinalBaseColor = + lerp(_BaseColor_var, + lerp(_Is_LightColor_1st_Shade_var, + lerp((_2nd_ShadeMap_var.rgb * _2nd_ShadeColor.rgb), ((_2nd_ShadeMap_var.rgb * _2nd_ShadeColor.rgb) * Set_LightColor) + , _Is_LightColor_2nd_Shade) + , Set_ShadeShadowMask) + , Set_FinalShadowMask); +#endif //#ifdef UTS_LAYER_VISIBILITY + +#ifdef _IS_CLIPPING_MATTE + if (_ClippingMatteMode == 3) + { + clippingColor = lerp((_2nd_ShadeMap_var.rgb * _2nd_ShadeColor.rgb), ((_2nd_ShadeMap_var.rgb * _2nd_ShadeColor.rgb) * Set_LightColor) + , _Is_LightColor_2nd_Shade); + return clippingColor; + } +#endif // _IS_CLIPPING_MATTE + + float4 _Set_HighColorMask_var = tex2D(_Set_HighColorMask, TRANSFORM_TEX(Set_UV0, _Set_HighColorMask)); + + float _Specular_var = 0.5 * dot(halfDirection, lerp(i_normalDir, utsData.normalDirection, _Is_NormalMapToHighColor)) + 0.5; // Specular + float _TweakHighColorMask_var = (saturate((_Set_HighColorMask_var.g + _Tweak_HighColorMaskLevel)) * lerp((1.0 - step(_Specular_var, (1.0 - pow(abs(_HighColor_Power), 5)))), pow(abs(_Specular_var), exp2(lerp(11, 1, _HighColor_Power))), _Is_SpecularToHighColor)); + + float4 _HighColor_Tex_var = tex2D(_HighColor_Tex, TRANSFORM_TEX(Set_UV0, _HighColor_Tex)); + + //Composition: 3 Basic Colors and HighColor as Set_HighColor + float3 _HighColorWithOutTweak_var = lerp((_HighColor_Tex_var.rgb * _HighColor.rgb), ((_HighColor_Tex_var.rgb * _HighColor.rgb) * Set_LightColor), _Is_LightColor_HighColor); + float3 _HighColor_var = _HighColorWithOutTweak_var * _TweakHighColorMask_var; +#ifdef _IS_CLIPPING_MATTE + if (_ClippingMatteMode == 4) + { + clippingColor = _HighColorWithOutTweak_var; + return clippingColor; + } +#endif // _IS_CLIPPING_MATTE + #ifdef UTS_LAYER_VISIBILITY + float3 Set_HighColor; + { + float4 overridingColor = lerp(_HighlightMaskColor, float4(_HighlightMaskColor.w, _HighlightMaskColor.w, _HighlightMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_HighlightOverridden, _ComposerMaskMode); + + _HighColor_var *= _HighlightVisible; + Set_HighColor = + lerp(SATURATE_IF_SDR(Set_FinalBaseColor - _TweakHighColorMask_var), Set_FinalBaseColor, + lerp(_Is_BlendAddToHiColor, 1.0 + , _Is_SpecularToHighColor)); + float3 addColor = + lerp(_HighColor_var, (_HighColor_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakHighColorOnShadow))) + , _Is_UseTweakHighColorOnShadow); + Set_HighColor += addColor; + if (any(addColor)) + { + Set_HighColor = lerp(Set_HighColor, overridingColor.rgb, maskEnabled); + channelOutAlpha = _HighlightVisible; + } + } +#else + float3 Set_HighColor = (lerp(SATURATE_IF_SDR((Set_FinalBaseColor - _TweakHighColorMask_var)), Set_FinalBaseColor, lerp(_Is_BlendAddToHiColor, 1.0, _Is_SpecularToHighColor)) + lerp(_HighColor_var, (_HighColor_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakHighColorOnShadow))), _Is_UseTweakHighColorOnShadow)); +#endif + + + float4 _Set_RimLightMask_var = tex2D(_Set_RimLightMask, TRANSFORM_TEX(Set_UV0, _Set_RimLightMask)); + float3 _Is_LightColor_RimLight_var = lerp(_RimLightColor.rgb, (_RimLightColor.rgb * Set_LightColor), _Is_LightColor_RimLight); + float _RimArea_var = (1.0 - dot(lerp(i_normalDir, utsData.normalDirection, _Is_NormalMapToRimLight), utsData.viewDirection)); + float _RimLightPower_var = pow(abs(_RimArea_var), exp2(lerp(3, 0, _RimLight_Power))); + float _Rimlight_InsideMask_var = saturate(lerp((0.0 + ((_RimLightPower_var - _RimLight_InsideMask) * (1.0 - 0.0)) / (1.0 - _RimLight_InsideMask)), step(_RimLight_InsideMask, _RimLightPower_var), _RimLight_FeatherOff)); + float _VertHalfLambert_var = 0.5 * dot(i_normalDir, lightDirection) + 0.5; + float3 _LightDirection_MaskOn_var = lerp((_Is_LightColor_RimLight_var * _Rimlight_InsideMask_var), (_Is_LightColor_RimLight_var * saturate((_Rimlight_InsideMask_var - ((1.0 - _VertHalfLambert_var) + _Tweak_LightDirection_MaskLevel)))), _LightDirection_MaskOn); + float _ApRimLightPower_var = pow(abs(_RimArea_var), exp2(lerp(3, 0, _Ap_RimLight_Power))); + //Composition: HighColor and RimLight as _RimLight_var + +#ifdef UTS_LAYER_VISIBILITY + + float4 overridingRimColor = lerp(_RimLightMaskColor, float4(_RimLightMaskColor.w, _RimLightMaskColor.w, _RimLightMaskColor.w, 1.0f), _ComposerMaskMode); + float maskRimEnabled = max(_RimLightOverridden, _ComposerMaskMode); + float Set_RimLightAlpha = _RimLightVisible; + float3 Set_RimLight = (saturate((_Set_RimLightMask_var.g + _Tweak_RimLightMaskLevel)) * lerp(_LightDirection_MaskOn_var, (_LightDirection_MaskOn_var + (lerp(_Ap_RimLightColor.rgb, (_Ap_RimLightColor.rgb * Set_LightColor), _Is_LightColor_Ap_RimLight) * saturate((lerp((0.0 + ((_ApRimLightPower_var - _RimLight_InsideMask) * (1.0 - 0.0)) / (1.0 - _RimLight_InsideMask)), step(_RimLight_InsideMask, _ApRimLightPower_var), _Ap_RimLight_FeatherOff) - (saturate(_VertHalfLambert_var) + _Tweak_LightDirection_MaskLevel))))), _Add_Antipodean_RimLight)); + Set_RimLight *= _RimLightVisible; + float3 _RimLight_var = lerp(Set_HighColor, (Set_HighColor + Set_RimLight), _RimLight); + if (any(Set_RimLight) * maskRimEnabled) + { + _RimLight_var = overridingRimColor.rgb; + channelOutAlpha = Set_RimLightAlpha; + } + +#else + float3 Set_RimLight = (saturate((_Set_RimLightMask_var.g + _Tweak_RimLightMaskLevel)) * lerp(_LightDirection_MaskOn_var, (_LightDirection_MaskOn_var + (lerp(_Ap_RimLightColor.rgb, (_Ap_RimLightColor.rgb * Set_LightColor), _Is_LightColor_Ap_RimLight) * saturate((lerp((0.0 + ((_ApRimLightPower_var - _RimLight_InsideMask) * (1.0 - 0.0)) / (1.0 - _RimLight_InsideMask)), step(_RimLight_InsideMask, _ApRimLightPower_var), _Ap_RimLight_FeatherOff) - (saturate(_VertHalfLambert_var) + _Tweak_LightDirection_MaskLevel))))), _Add_Antipodean_RimLight)); + float3 _RimLight_var = lerp(Set_HighColor, (Set_HighColor + Set_RimLight), _RimLight); +#endif + + //Matcap + //v.2.0.6 : CameraRolling Stabilizer + //Mirror Script Determination: if sign_Mirror = -1, determine "Inside the mirror". + //v.2.0.7 + utsData.signMirror= 0.0; // i.mirrorFlag; todo. + + // + float3 _Camera_Right = UNITY_MATRIX_V[0].xyz; + float3 _Camera_Front = UNITY_MATRIX_V[2].xyz; + float3 _Up_Unit = float3(0, 1, 0); + float3 _Right_Axis = cross(_Camera_Front, _Up_Unit); + //Invert if it's "inside the mirror". + if (utsData.signMirror < 0) { + _Right_Axis = -1 * _Right_Axis; + _Rotate_MatCapUV = -1 * _Rotate_MatCapUV; + } + else { + _Right_Axis = _Right_Axis; + } + float _Camera_Right_Magnitude = sqrt(_Camera_Right.x * _Camera_Right.x + _Camera_Right.y * _Camera_Right.y + _Camera_Right.z * _Camera_Right.z); + float _Right_Axis_Magnitude = sqrt(_Right_Axis.x * _Right_Axis.x + _Right_Axis.y * _Right_Axis.y + _Right_Axis.z * _Right_Axis.z); + float _Camera_Roll_Cos = dot(_Right_Axis, _Camera_Right) / (_Right_Axis_Magnitude * _Camera_Right_Magnitude); + utsData.cameraRoll = acos(clamp(_Camera_Roll_Cos, -1, 1)); + utsData.cameraDir = _Camera_Right.y < 0 ? -1 : 1; + float _Rot_MatCapUV_var_ang = (_Rotate_MatCapUV * 3.141592654) - utsData.cameraDir * utsData.cameraRoll * _CameraRolling_Stabilizer; + //v.2.0.7 + float2 _Rot_MatCapNmUV_var = RotateUV(Set_UV0.xy, (_Rotate_NormalMapForMatCapUV * 3.141592654), float2(0.5, 0.5), 1.0); + //V.2.0.6 + + float3 _NormalMapForMatCap_var = UnpackNormalScale(tex2D(_NormalMapForMatCap, TRANSFORM_TEX(_Rot_MatCapNmUV_var, _NormalMapForMatCap)), _BumpScaleMatcap); + + //v.2.0.5: MatCap with camera skew correction + float3 viewNormal = (mul(UNITY_MATRIX_V, float4(lerp(i_normalDir, mul(_NormalMapForMatCap_var.rgb, tangentTransform).rgb, _Is_NormalMapForMatCap), 0))).rgb; + float3 NormalBlend_MatcapUV_Detail = viewNormal.rgb * float3(-1, -1, 1); + float3 NormalBlend_MatcapUV_Base = (mul(UNITY_MATRIX_V, float4(utsData.viewDirection, 0)).rgb * float3(-1, -1, 1)) + float3(0, 0, 1); + float3 noSknewViewNormal = NormalBlend_MatcapUV_Base * dot(NormalBlend_MatcapUV_Base, NormalBlend_MatcapUV_Detail) / NormalBlend_MatcapUV_Base.b - NormalBlend_MatcapUV_Detail; + float2 _ViewNormalAsMatCapUV = (lerp(noSknewViewNormal, viewNormal, _Is_Ortho).rg * 0.5) + 0.5; + // + //v.2.0.7 + float2 _Rot_MatCapUV_var = RotateUV((0.0 + ((_ViewNormalAsMatCapUV - (0.0 + _Tweak_MatCapUV)) * (1.0 - 0.0)) / ((1.0 - _Tweak_MatCapUV) - (0.0 + _Tweak_MatCapUV))), _Rot_MatCapUV_var_ang, float2(0.5, 0.5), 1.0); + //Invert if it's "inside the mirror". + if (utsData.signMirror < 0) { + _Rot_MatCapUV_var.x = 1 - _Rot_MatCapUV_var.x; + } + else { + _Rot_MatCapUV_var = _Rot_MatCapUV_var; + } + + //v.2.0.6 : LOD of Matcap + float4 _MatCap_Sampler_var = tex2Dlod(_MatCap_Sampler, float4(TRANSFORM_TEX(_Rot_MatCapUV_var, _MatCap_Sampler), 0.0, _BlurLevelMatcap)); + float4 _Set_MatcapMask_var = tex2D(_Set_MatcapMask, TRANSFORM_TEX(Set_UV0, _Set_MatcapMask)); + // + //MatcapMask + float _Tweak_MatcapMaskLevel_var = saturate(lerp(_Set_MatcapMask_var.g, (1.0 - _Set_MatcapMask_var.g), _Inverse_MatcapMask) + _Tweak_MatcapMaskLevel); + float3 _Is_LightColor_MatCap_var = lerp((_MatCap_Sampler_var.rgb * _MatCapColor.rgb), ((_MatCap_Sampler_var.rgb * _MatCapColor.rgb) * Set_LightColor), _Is_LightColor_MatCap); + //v.2.0.6 : ShadowMask on Matcap in Blend mode : multiply + float3 Set_MatCap = lerp(_Is_LightColor_MatCap_var, (_Is_LightColor_MatCap_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakMatCapOnShadow)) + lerp(Set_HighColor * Set_FinalShadowMask * (1.0 - _TweakMatCapOnShadow), float3(0.0, 0.0, 0.0), _Is_BlendAddToMatCap)), _Is_UseTweakMatCapOnShadow); + + + // + //v.2.0.6 + //Composition: RimLight and MatCap as finalColor + //Broke down finalColor composition + float3 matCapColorOnAddMode = _RimLight_var + Set_MatCap * _Tweak_MatcapMaskLevel_var; + float _Tweak_MatcapMaskLevel_var_MultiplyMode = _Tweak_MatcapMaskLevel_var * lerp(1, (1 - (Set_FinalShadowMask) * (1 - _TweakMatCapOnShadow)), _Is_UseTweakMatCapOnShadow); + float3 matCapColorOnMultiplyMode = Set_HighColor * (1 - _Tweak_MatcapMaskLevel_var_MultiplyMode) + Set_HighColor * Set_MatCap * _Tweak_MatcapMaskLevel_var_MultiplyMode + lerp(float3(0, 0, 0), Set_RimLight, _RimLight); + float3 matCapColorFinal = lerp(matCapColorOnMultiplyMode, matCapColorOnAddMode, _Is_BlendAddToMatCap); + +#if defined(_IS_ANGELRING_ON) + float3 finalColor = lerp(_RimLight_var, matCapColorFinal, _MatCap);// Final Composition before AR + //v.2.0.7 AR Camera Rolling Stabilizer + float3 _AR_OffsetU_var = lerp(mul(UNITY_MATRIX_V, float4(i_normalDir, 0)).xyz, float3(0, 0, 1), _AR_OffsetU); + float2 AR_VN = _AR_OffsetU_var.xy * 0.5 + float2(0.5, 0.5); + float2 AR_VN_Rotate = RotateUV(AR_VN, -(utsData.cameraDir * utsData.cameraRoll), float2(0.5, 0.5), 1.0); + float2 _AR_OffsetV_var = float2(AR_VN_Rotate.x, lerp(input.texCoord1.y, AR_VN_Rotate.y, _AR_OffsetV)); + float4 _AngelRing_Sampler_var = tex2D(_AngelRing_Sampler, TRANSFORM_TEX(_AR_OffsetV_var, _AngelRing_Sampler)); + float3 _Is_LightColor_AR_var = lerp((_AngelRing_Sampler_var.rgb * _AngelRing_Color.rgb), ((_AngelRing_Sampler_var.rgb * _AngelRing_Color.rgb) * Set_LightColor), _Is_LightColor_AR); + float3 Set_AngelRing = _Is_LightColor_AR_var; + float Set_ARtexAlpha = _AngelRing_Sampler_var.a; + float3 Set_AngelRingWithAlpha = (_Is_LightColor_AR_var * _AngelRing_Sampler_var.a); + //Composition: MatCap and AngelRing as finalColor +# ifdef UTS_LAYER_VISIBILITY + { + float4 overridingColor = lerp(_AngelRingMaskColor, float4(_AngelRingMaskColor.w, _AngelRingMaskColor.w, _AngelRingMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_AngelRingOverridden, _ComposerMaskMode); + + _AngelRing *= _AngelRingVisible; + finalColor = lerp(finalColor, lerp((finalColor + Set_AngelRing), ((finalColor * (1.0 - Set_ARtexAlpha)) + Set_AngelRingWithAlpha), _ARSampler_AlphaOn), _AngelRing);// Final Composition before Emissive + if (any(Set_AngelRing) * maskEnabled) + { + finalColor = lerp(finalColor, lerp(overridingColor.xyz, ((finalColor * (1.0 - Set_ARtexAlpha)) + Set_AngelRingWithAlpha), _ARSampler_AlphaOn), _AngelRing);// Final Composition before Emissive + channelOutAlpha = _AngelRingVisible; + } + } +# else + finalColor = lerp(finalColor, lerp((finalColor + Set_AngelRing), ((finalColor * (1.0 - Set_ARtexAlpha)) + Set_AngelRingWithAlpha), _ARSampler_AlphaOn), _AngelRing);// Final Composition before Emissive +# endif //#ifdef UTS_LAYER_VISIBILITY +#ifdef _IS_CLIPPING_MATTE + if (_ClippingMatteMode == 5) + { + clippingColor = _Is_LightColor_AR_var; + return clippingColor; + } +#endif // _IS_CLIPPING_MATTE + +#else +#ifdef _IS_CLIPPING_MATTE + if (_ClippingMatteMode == 5) + { + clippingColor = float3(0.0f,0.0f,0.0f); + return clippingColor; + } +#endif // _IS_CLIPPING_MATTE + float3 finalColor = lerp(_RimLight_var, matCapColorFinal, _MatCap);// Final Composition before Emissive + +#endif //#if defined(_IS_ANGELRING_ON) + + + + //v.2.0.6: GI_Intensity with Intensity Multiplier Filter + float3 envLightColor = saturate(SampleBakedGI_UTS(posInput.positionWS, utsData.normalDirection, input.texCoord1.xy, input.texCoord2.xy, true)); + float envLightIntensity = saturate(0.299 * envLightColor.r + 0.587 * envLightColor.g + 0.114 * envLightColor.b); + + finalColor = SATURATE_IF_SDR(finalColor) + (envLightColor * envLightIntensity * _GI_Intensity * smoothstep(1, 0, envLightIntensity / 2)) + emissive; + + return finalColor; +} diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShadingGrademapMainLight.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShadingGrademapMainLight.hlsl.meta new file mode 100644 index 0000000..915fca0 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShadingGrademapMainLight.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b18b203f15b921a47a7cf30e26007d1a +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShadingGrademapOtherLight.hlsl b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShadingGrademapOtherLight.hlsl new file mode 100644 index 0000000..938f2e1 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShadingGrademapOtherLight.hlsl @@ -0,0 +1,175 @@ +//Unity Toon Shader/HDRP +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Universal RP/HDRP) + +float3 UTS_OtherLightsShadingGrademap(FragInputs input, float3 i_normalDir, + float3 additionalLightColor, float3 lightDirection, float notDirectional, out float channelOutAlpha) +{ + channelOutAlpha = 1.0f; +#ifdef _IS_CLIPPING_MATTE + if (_ClippingMatteMode != 0) + { + + return float3(0.0f, 0.0f, 0.0f); + } +#endif // _IS_CLIPPING_MATTE + + /* todo. these should be put into struct */ +#ifdef VARYINGS_NEED_POSITION_WS + float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS); +#else + // Unused + float3 V = float3(1.0, 1.0, 1.0); // Avoid the division by 0 +#endif + + + + float4 Set_UV0 = input.texCoord0; + float3x3 tangentTransform = input.tangentToWorld; + //UnpackNormalmapRGorAG(SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, texCoords)) + float4 n = SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, Set_UV0.xy); +// float3 _NormalMap_var = UnpackNormalScale(tex2D(_NormalMap, TRANSFORM_TEX(Set_UV0, _NormalMap)), _BumpScale); + float3 _NormalMap_var = UnpackNormalScale(n, _BumpScale); + float3 normalLocal = _NormalMap_var.rgb; + float3 normalDirection = normalize(mul(normalLocal, tangentTransform)); // Perturbed normals + // float3 i_normalDir = surfaceData.normalWS; + float3 viewDirection = V; + float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex,TRANSFORM_TEX(Set_UV0, _MainTex)); + /* end of todo.*/ + + + + //v.2.0.5: + float3 addPassLightColor = (0.5 * dot(lerp(i_normalDir, normalDirection, _Is_NormalMapToBase), lightDirection) + 0.5) * additionalLightColor.rgb; + float pureIntencity = max(0.001, (0.299 * additionalLightColor.r + 0.587 * additionalLightColor.g + 0.114 * additionalLightColor.b)); + float3 lightColor = max(float3(0.0,0.0,0.0), lerp(addPassLightColor, lerp(float3(0.0,0.0,0.0), min(addPassLightColor, addPassLightColor / pureIntencity), notDirectional), _Is_Filter_LightColor)); + float3 halfDirection = normalize(viewDirection + lightDirection); // has to be recalced here. + //v.2.0.5: + //v.2.0.5: + _1st_ShadeColor_Step = saturate(_1st_ShadeColor_Step + _StepOffset); + _2nd_ShadeColor_Step = saturate(_2nd_ShadeColor_Step + _StepOffset); + // + //v.2.0.5: If Added lights is directional, set 0 as _LightIntensity + float _LightIntensity = lerp(0, (0.299 * additionalLightColor.r + 0.587 * additionalLightColor.g + 0.114 * additionalLightColor.b), notDirectional); + //v.2.0.5: Filtering the high intensity zone of PointLights + float3 Set_LightColor = lightColor; + // + float3 Set_BaseColor = lerp((_BaseColor.rgb * _MainTex_var.rgb * _LightIntensity), ((_BaseColor.rgb * _MainTex_var.rgb) * Set_LightColor), _Is_LightColor_Base); +#ifdef UTS_LAYER_VISIBILITY + float Set_BaseColorAlpha = _BaseColorVisible; + float4 overridingColor = lerp(_BaseColorMaskColor, float4(_BaseColorMaskColor.w, _BaseColorMaskColor.w, _BaseColorMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_BaseColorOverridden, _ComposerMaskMode); + Set_BaseColor = lerp(Set_BaseColor, overridingColor.rgb, maskEnabled); + Set_BaseColor *= _BaseColorVisible; + +#endif //#ifdef UTS_LAYER_VISIBILITY + //v.2.0.5 + float4 _1st_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_1st_ShadeMap, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)), _MainTex_var, _Use_BaseAs1st); + float3 Set_1st_ShadeColor = lerp((_1st_ShadeColor.rgb * _1st_ShadeMap_var.rgb * _LightIntensity), ((_1st_ShadeColor.rgb * _1st_ShadeMap_var.rgb) * Set_LightColor), _Is_LightColor_1st_Shade); +#ifdef UTS_LAYER_VISIBILITY + { + float4 overridingColor = lerp(_FirstShadeMaskColor, float4(_FirstShadeMaskColor.w, _FirstShadeMaskColor.w, _FirstShadeMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_FirstShadeOverridden, _ComposerMaskMode); + Set_1st_ShadeColor = lerp(Set_1st_ShadeColor, overridingColor.rgb, maskEnabled); + Set_1st_ShadeColor = lerp(Set_1st_ShadeColor, Set_BaseColor, 1.0f - _FirstShadeVisible); + } + float Set_1st_ShadeAlpha = _FirstShadeVisible; +#endif //#ifdef UTS_LAYER_VISIBILITY //v.2.0.5 + //v.2.0.5 + float4 _2nd_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_2nd_ShadeMap, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)), _1st_ShadeMap_var, _Use_1stAs2nd); + float3 Set_2nd_ShadeColor = lerp((_2nd_ShadeColor.rgb * _2nd_ShadeMap_var.rgb * _LightIntensity), ((_2nd_ShadeColor.rgb * _2nd_ShadeMap_var.rgb) * Set_LightColor), _Is_LightColor_2nd_Shade); +#ifdef UTS_LAYER_VISIBILITY + { + float4 overridingColor = lerp(_SecondShadeMaskColor, float4(_SecondShadeMaskColor.w, _SecondShadeMaskColor.w, _SecondShadeMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_SecondShadeOverridden, _ComposerMaskMode); + Set_2nd_ShadeColor = lerp(Set_2nd_ShadeColor, overridingColor.rgb, maskEnabled); + Set_2nd_ShadeColor = lerp(Set_2nd_ShadeColor, Set_BaseColor, 1.0f - _SecondShadeVisible); + + } +#endif //#ifdef UTS_LAYER_VISIBILITY + + float _HalfLambert_var = 0.5 * dot(lerp(i_normalDir, normalDirection, _Is_NormalMapToBase), lightDirection) + 0.5; + + // //v.2.0.5: +//SGM + //v.2.0.6 + float4 _ShadingGradeMap_var = tex2Dlod(_ShadingGradeMap, float4(TRANSFORM_TEX(Set_UV0, _ShadingGradeMap), 0.0, _BlurLevelSGM)); + + //v.2.0.6 + //Minmimum value is same as the Minimum Feather's value with the Minimum Step's value as threshold. + //float _SystemShadowsLevel_var = (attenuation*0.5)+0.5+_Tweak_SystemShadowsLevel > 0.001 ? (attenuation*0.5)+0.5+_Tweak_SystemShadowsLevel : 0.0001; + float _ShadingGradeMapLevel_var = _ShadingGradeMap_var.r < 0.95 ? _ShadingGradeMap_var.r + _Tweak_ShadingGradeMapLevel : 1; + + //float Set_ShadingGrade = saturate(_ShadingGradeMapLevel_var)*lerp( _HalfLambert_var, (_HalfLambert_var*saturate(_SystemShadowsLevel_var)), _Set_SystemShadowsToBase ); + + float Set_ShadingGrade = saturate(_ShadingGradeMapLevel_var) * lerp(_HalfLambert_var, (_HalfLambert_var * saturate(1.0 + _Tweak_SystemShadowsLevel)), _Set_SystemShadowsToBase); + + + float _1stColorFeatherForMask = lerp(_1st_ShadeColor_Feather, 0.0f, max(_FirstShadeOverridden, _ComposerMaskMode)); + float _2ndColorFeatherForMask = lerp(_2nd_ShadeColor_Feather, 0.0f, max(_SecondShadeOverridden, _ComposerMaskMode)); + + // + float Set_FinalShadowMask = saturate((1.0 + ((Set_ShadingGrade - (_1st_ShadeColor_Step - _1stColorFeatherForMask)) * (0.0 - 1.0)) / (_1st_ShadeColor_Step - (_1st_ShadeColor_Step - _1stColorFeatherForMask)))); + float Set_ShadeShadowMask = saturate((1.0 + ((Set_ShadingGrade - (_2nd_ShadeColor_Step - _2ndColorFeatherForMask)) * (0.0 - 1.0)) / (_2nd_ShadeColor_Step - (_2nd_ShadeColor_Step - _2ndColorFeatherForMask)))); // 1st and 2nd Shades Mask + +//SGM + + + + + + //Composition: 3 Basic Colors as finalColor + + float3 finalColor = + lerp( + Set_BaseColor, + lerp( + Set_1st_ShadeColor, + Set_2nd_ShadeColor, + Set_ShadeShadowMask + ), + Set_FinalShadowMask); +#ifdef UTS_LAYER_VISIBILITY + float Set_2nd_ShadeAlpha = _SecondShadeVisible; + channelOutAlpha = + lerp(Set_BaseColorAlpha, lerp(Set_1st_ShadeAlpha, Set_2nd_ShadeAlpha, Set_ShadeShadowMask), Set_FinalShadowMask); +#endif + //v.2.0.6: Add HighColor if _Is_Filter_HiCutPointLightColor is False + + float4 _Set_HighColorMask_var = tex2D(_Set_HighColorMask, TRANSFORM_TEX(Set_UV0, _Set_HighColorMask)); + float _Specular_var = 0.5 * dot(halfDirection, lerp(i_normalDir, normalDirection, _Is_NormalMapToHighColor)) + 0.5; // Specular + float _TweakHighColorMask_var = (saturate((_Set_HighColorMask_var.g + _Tweak_HighColorMaskLevel)) * lerp((1.0 - step(_Specular_var, (1.0 - pow(abs(_HighColor_Power), 5)))), pow(abs(_Specular_var), exp2(lerp(11, 1, _HighColor_Power))), _Is_SpecularToHighColor)); + float4 _HighColor_Tex_var = tex2D(_HighColor_Tex, TRANSFORM_TEX(Set_UV0, _HighColor_Tex)); + float3 _HighColor_var = lerp((_HighColor_Tex_var.rgb * _HighColor.rgb), ((_HighColor_Tex_var.rgb * _HighColor.rgb) * Set_LightColor), _Is_LightColor_HighColor); +#ifdef UTS_LAYER_VISIBILITY + { + float4 overridingColor = lerp(_HighlightMaskColor, float4(_HighlightMaskColor.w, _HighlightMaskColor.w, _HighlightMaskColor.w, 1.0f), _ComposerMaskMode); + float maskEnabled = max(_HighlightOverridden, _ComposerMaskMode); + _HighColor_var *= _TweakHighColorMask_var; + _HighColor_var *= _HighlightVisible; + finalColor = + lerp(saturate(finalColor - _TweakHighColorMask_var), finalColor, + lerp(_Is_BlendAddToHiColor, 1.0 + , _Is_SpecularToHighColor)); + float3 addColor = + lerp(_HighColor_var, (_HighColor_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakHighColorOnShadow))) + , _Is_UseTweakHighColorOnShadow); + finalColor += addColor; + if (any(addColor)) + { + finalColor = lerp(finalColor, overridingColor.rgb, maskEnabled); + channelOutAlpha = _HighlightVisible; + } + } + +#else + _HighColor_var *= _TweakHighColorMask_var; + finalColor = finalColor + lerp(lerp(_HighColor_var, (_HighColor_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakHighColorOnShadow))), _Is_UseTweakHighColorOnShadow), float3(0, 0, 0), _Is_Filter_HiCutPointLightColor); +#endif //#ifdef UTS_LAYER_VISIBILITY + + + finalColor = SATURATE_IF_SDR(finalColor); + + // pointLightColor += finalColor; + return finalColor; +} diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShadingGrademapOtherLight.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShadingGrademapOtherLight.hlsl.meta new file mode 100644 index 0000000..70682c8 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/ShadingGrademapOtherLight.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e0d6ddf3fb34bef48b91a2fb9cae8cb1 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsHDRP.hlsl b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsHDRP.hlsl new file mode 100644 index 0000000..aaa55cf --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsHDRP.hlsl @@ -0,0 +1,36 @@ + + + //------------------------------------------------------------------------------------- + // Define + //------------------------------------------------------------------------------------- + + // This shader support vertex modification + #define HAVE_VERTEX_MODIFICATION + + // If we use subsurface scattering, enable output split lighting (for forward pass) + #if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) && !defined(_SURFACE_TYPE_TRANSPARENT) + #define OUTPUT_SPLIT_LIGHTING + #endif + + #if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT) + #define _WRITE_TRANSPARENT_MOTION_VECTOR + #endif + //------------------------------------------------------------------------------------- + // Include + //------------------------------------------------------------------------------------- + + #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" +#ifdef TESSELLATION_ON + #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/GeometricTools.hlsl" + #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Tessellation.hlsl" +#endif //TESSELLATION_ON + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + //------------------------------------------------------------------------------------- + // variable declaration + //------------------------------------------------------------------------------------- + + #include "UtsHdrpProperties.hlsl" + #include "UtsTextures.hlsl" diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsHDRP.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsHDRP.hlsl.meta new file mode 100644 index 0000000..2d0ac67 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsHDRP.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: abef26bf2a832ee4d85bb4845b53f617 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsHdrpProperties.hlsl b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsHdrpProperties.hlsl new file mode 100644 index 0000000..69e4682 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsHdrpProperties.hlsl @@ -0,0 +1,310 @@ +// =========================================================================== +// WARNING: +// On PS4, texture/sampler declarations need to be outside of CBuffers +// Otherwise those parameters are not bound correctly at runtime. +// =========================================================================== +#if DEBUG_DISPLAY +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl" +#endif + +#ifndef fixed +#define fixed half +#endif + +// Unity Toon Shader +//#include "UtsTextures.hlsl" + +// Lit +TEXTURE2D(_DistortionVectorMap); +SAMPLER(sampler_DistortionVectorMap); + +TEXTURE2D(_EmissiveColorMap); +SAMPLER(sampler_EmissiveColorMap); + +#ifndef LAYERED_LIT_SHADER + +TEXTURE2D(_DiffuseLightingMap); +SAMPLER(sampler_DiffuseLightingMap); + +TEXTURE2D(_BaseColorMap); +SAMPLER(sampler_BaseColorMap); + +TEXTURE2D(_MaskMap); +SAMPLER(sampler_MaskMap); +TEXTURE2D(_BentNormalMap); // Reuse sampler from normal map +SAMPLER(sampler_BentNormalMap); + +TEXTURE2D(_NormalMap); +SAMPLER(sampler_NormalMap); +TEXTURE2D(_NormalMapOS); +SAMPLER(sampler_NormalMapOS); + +TEXTURE2D(_DetailMap); +SAMPLER(sampler_DetailMap); + +TEXTURE2D(_HeightMap); +SAMPLER(sampler_HeightMap); + +TEXTURE2D(_TangentMap); +SAMPLER(sampler_TangentMap); +TEXTURE2D(_TangentMapOS); +SAMPLER(sampler_TangentMapOS); + +TEXTURE2D(_AnisotropyMap); +SAMPLER(sampler_AnisotropyMap); + +TEXTURE2D(_SubsurfaceMaskMap); +SAMPLER(sampler_SubsurfaceMaskMap); +TEXTURE2D(_ThicknessMap); +SAMPLER(sampler_ThicknessMap); + +TEXTURE2D(_IridescenceThicknessMap); +SAMPLER(sampler_IridescenceThicknessMap); + +TEXTURE2D(_IridescenceMaskMap); +SAMPLER(sampler_IridescenceMaskMap); + +TEXTURE2D(_SpecularColorMap); +SAMPLER(sampler_SpecularColorMap); + +TEXTURE2D(_TransmittanceColorMap); +SAMPLER(sampler_TransmittanceColorMap); + +TEXTURE2D(_CoatMaskMap); +SAMPLER(sampler_CoatMaskMap); + +#else + +// Set of users variables +#define PROP_DECL(type, name) type name##0, name##1, name##2, name##3 +// sampler are share by texture type inside a layered material but we need to support that a particualr layer have no texture, so we take the first sampler of available texture as the share one +// mean we must declare all sampler +#define PROP_DECL_TEX2D(name)\ + TEXTURE2D(CALL_MERGE_NAME(name, 0)); \ + SAMPLER(CALL_MERGE_NAME(CALL_MERGE_NAME(sampler, name), 0)); \ + TEXTURE2D(CALL_MERGE_NAME(name, 1)); \ + SAMPLER(CALL_MERGE_NAME(CALL_MERGE_NAME(sampler, name), 1)); \ + TEXTURE2D(CALL_MERGE_NAME(name, 2)); \ + SAMPLER(CALL_MERGE_NAME(CALL_MERGE_NAME(sampler, name), 2)); \ + TEXTURE2D(CALL_MERGE_NAME(name, 3)); \ + SAMPLER(CALL_MERGE_NAME(CALL_MERGE_NAME(sampler, name), 3)) + + +PROP_DECL_TEX2D(_BaseColorMap); +PROP_DECL_TEX2D(_MaskMap); +PROP_DECL_TEX2D(_BentNormalMap); +PROP_DECL_TEX2D(_NormalMap); +PROP_DECL_TEX2D(_NormalMapOS); +PROP_DECL_TEX2D(_DetailMap); +PROP_DECL_TEX2D(_HeightMap); + +PROP_DECL_TEX2D(_SubsurfaceMaskMap); +PROP_DECL_TEX2D(_ThicknessMap); + +TEXTURE2D(_LayerMaskMap); +SAMPLER(sampler_LayerMaskMap); +TEXTURE2D(_LayerInfluenceMaskMap); +SAMPLER(sampler_LayerInfluenceMaskMap); + +#endif + +CBUFFER_START(UnityPerMaterial) + + +#include "UtsUnityPerMaterial.hlsl" + +// shared constant between lit and layered lit +float _AlphaCutoff; +float _UseShadowThreshold; +float _AlphaCutoffShadow; +float _AlphaCutoffPrepass; +float _AlphaCutoffPostpass; +float4 _DoubleSidedConstants; +float _DistortionScale; +float _DistortionVectorScale; +float _DistortionVectorBias; +float _DistortionBlurScale; +float _DistortionBlurRemapMin; +float _DistortionBlurRemapMax; + +float _PPDMaxSamples; +float _PPDMinSamples; +float _PPDLodThreshold; + +float3 _EmissiveColor; +float _AlbedoAffectEmissive; +float _EmissiveExposureWeight; + +int _SpecularOcclusionMode; + +// Transparency +float3 _TransmittanceColor; +float _Ior; +float _ATDistance; + +// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" +// value that exist to identify if the GI emission need to be enabled. +// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. +// TODO: Fix the code in legacy unity so we can customize the beahvior for GI +float3 _EmissionColor; +float4 _EmissiveColorMap_ST; +float _TexWorldScaleEmissive; +float4 _UVMappingMaskEmissive; + +float4 _InvPrimScale; // Only XY are used + +// Wind +float _InitialBend; +float _Stiffness; +float _Drag; +float _ShiverDrag; +float _ShiverDirectionality; + +// Specular AA +float _EnableGeometricSpecularAA; +float _SpecularAAScreenSpaceVariance; +float _SpecularAAThreshold; + +#ifndef LAYERED_LIT_SHADER + +// Set of users variables +float4 _BaseColor; +float4 _BaseColorMap_ST; +float4 _BaseColorMap_TexelSize; +float4 _BaseColorMap_MipInfo; + +float _Metallic; +float _Smoothness; +float _SmoothnessRemapMin; +float _SmoothnessRemapMax; +float _AlphaRemapMin; +float _AlphaRemapMax; +float _AORemapMin; +float _AORemapMax; + +float _NormalScale; + +float4 _DetailMap_ST; +float _DetailAlbedoScale; +float _DetailNormalScale; +float _DetailSmoothnessScale; + +float4 _HeightMap_TexelSize; // Unity facility. This will provide the size of the heightmap to the shader + +float _HeightAmplitude; +float _HeightCenter; + +float _Anisotropy; + +float _DiffusionProfileHash; +float _SubsurfaceMask; +float _TransmissionMask; +float _Thickness; +float4 _ThicknessRemap; + + +float _IridescenceThickness; +float4 _IridescenceThicknessRemap; +float _IridescenceMask; + +float _CoatMask; + +float4 _SpecularColor; +float _EnergyConservingSpecularColor; + +float _TexWorldScale; +float _InvTilingScale; +float4 _UVMappingMask; +float4 _UVDetailsMappingMask; +float _LinkDetailsWithBase; +float _ObjectSpaceUVMapping; +#else // LAYERED_LIT_SHADER + +// Set of users variables +PROP_DECL(float4, _BaseColor); +float4 _BaseColorMap0_ST; +float4 _BaseColorMap1_ST; +float4 _BaseColorMap2_ST; +float4 _BaseColorMap3_ST; + +float4 _BaseColorMap0_TexelSize; +float4 _BaseColorMap0_MipInfo; + +PROP_DECL(float, _Metallic); +PROP_DECL(float, _Smoothness); +PROP_DECL(float, _SmoothnessRemapMin); +PROP_DECL(float, _SmoothnessRemapMax); +PROP_DECL(float, _AORemapMin); +PROP_DECL(float, _AORemapMax); + +PROP_DECL(float, _NormalScale); +float4 _NormalMap0_TexelSize; // Unity facility. This will provide the size of the base normal to the shader + +float4 _HeightMap0_TexelSize; +float4 _HeightMap1_TexelSize; +float4 _HeightMap2_TexelSize; +float4 _HeightMap3_TexelSize; + +float4 _DetailMap0_ST; +float4 _DetailMap1_ST; +float4 _DetailMap2_ST; +float4 _DetailMap3_ST; +PROP_DECL(float, _UVDetail); +PROP_DECL(float, _DetailAlbedoScale); +PROP_DECL(float, _DetailNormalScale); +PROP_DECL(float, _DetailSmoothnessScale); + +PROP_DECL(float, _HeightAmplitude); +PROP_DECL(float, _HeightCenter); + +PROP_DECL(float, _DiffusionProfileHash); +PROP_DECL(float, _SubsurfaceMask); +PROP_DECL(float, _Thickness); +PROP_DECL(float4, _ThicknessRemap); + +PROP_DECL(float, _OpacityAsDensity); +float _InheritBaseNormal1; +float _InheritBaseNormal2; +float _InheritBaseNormal3; +float _InheritBaseHeight1; +float _InheritBaseHeight2; +float _InheritBaseHeight3; +float _InheritBaseColor1; +float _InheritBaseColor2; +float _InheritBaseColor3; +PROP_DECL(float, _HeightOffset); +float _HeightTransition; + +float4 _LayerMaskMap_ST; +float _TexWorldScaleBlendMask; +PROP_DECL(float, _TexWorldScale); +PROP_DECL(float, _InvTilingScale); +float4 _UVMappingMaskBlendMask; +PROP_DECL(float4, _UVMappingMask); +PROP_DECL(float4, _UVDetailsMappingMask); +PROP_DECL(float, _LinkDetailsWithBase); + +#endif // LAYERED_LIT_SHADER + +#if DEBUG_DISPLAY +UNITY_TEXTURE_STREAMING_DEBUG_VARS +#endif + +// Tessellation specific + +#ifdef TESSELLATION_ON +float _TessellationFactor; +float _TessellationFactorMinDistance; +float _TessellationFactorMaxDistance; +float _TessellationFactorTriangleSize; +float _TessellationShapeFactor; +float _TessellationBackFaceCullEpsilon; +float _TessellationObjectScale; +float _TessellationTilingScale; +#endif + +// Following two variables are feeded by the C++ Editor for Scene selection +int _ObjectId; +int _PassValue; + +CBUFFER_END diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsHdrpProperties.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsHdrpProperties.hlsl.meta new file mode 100644 index 0000000..e5f2901 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsHdrpProperties.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f766a049b2bd4cd4bac4693fe41e62b2 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsLightLoop.hlsl b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsLightLoop.hlsl new file mode 100644 index 0000000..01e2850 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsLightLoop.hlsl @@ -0,0 +1,188 @@ +//Unity Toon Shader/HDRP +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Universal RP/HDRP) + +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Macros.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/PhysicalCamera.hlsl" +#include "HDRPToonHead.hlsl" + +// Channel mask enum. +// this must be same to UI cs code +// HDRPToonGUI._ChannelEnum +int eBaseColor = 0; +int eFirstShade = 1; +int eSecondShade = 2; +int eHighlight = 3; +int eAngelRing = 4; +int eRimLight = 5; +int eOutline = 6; + + + + + + + + +// not in materials +int _ToonLightHiCutFilter; +int _ToonEvAdjustmentCurve; +float _ToonEvAdjustmentValueArray[128]; +float _ToonEvAdjustmentValueMin; +float _ToonEvAdjustmentValueMax; +float _ToonEvAdjustmentCompensation; +float _ToonIgnoreExposureMultiplier; + + +// function to rotate the UV: RotateUV() +//float2 rotatedUV = RotateUV(i.uv0, (_angular_Verocity*3.141592654), float2(0.5, 0.5), _Time.g); +float2 RotateUV(float2 _uv, float _radian, float2 _piv, float _time) +{ + float RotateUV_ang = _radian; + float RotateUV_cos = cos(_time*RotateUV_ang); + float RotateUV_sin = sin(_time*RotateUV_ang); + return (mul(_uv - _piv, float2x2(RotateUV_cos, -RotateUV_sin, RotateUV_sin, RotateUV_cos)) + _piv); +} + +float3 ConvertFromEV100(float3 EV100) +{ +#if 1 + float3 value = pow(2, EV100) * 2.5f; + return value; +#else + float3 maxLuminance = 1.2f * pow(2.0f, EV100); + return 1.0f / maxLuminance; +#endif +} + +float3 ConvertToEV100(float3 value) +{ +#if 1 + return log2(value*0.4f); +#else + return log2(1.0f / (1.2f * value)); +#endif +} + + + +float WeightSample(PositionInputs positionInput) +{ + // Center-weighted + const float2 kCenter = _ScreenParams.xy * 0.5; + const float weight = pow(length((kCenter.xy - positionInput.positionSS.xy) / _ScreenParams.xy),1.0) ; + return 1.0 - saturate(weight); +} + +float3 ApplyCompensation(float3 originalColor) +{ + float3 ev100_Color = ConvertToEV100(originalColor) +_ToonEvAdjustmentCompensation * 0.5f; + + + float3 resultColor = max(0, ConvertFromEV100(ev100_Color)); + return resultColor; +} + +float3 ApplyCurrentExposureMultiplier(float3 color) +{ + return color * lerp(GetCurrentExposureMultiplier(), 1, _ToonIgnoreExposureMultiplier); +} + + +float3 GetExposureAdjustedColor(float3 originalColor) +{ + if (_ToonEvAdjustmentCurve != 0) + { + + float3 ev100_Color = ConvertToEV100(originalColor); + ev100_Color = clamp(ev100_Color, _ToonEvAdjustmentValueMin, _ToonEvAdjustmentValueMax); + float3 ev100_remap = (ev100_Color - _ToonEvAdjustmentValueMin) * (128-1) / (_ToonEvAdjustmentValueMax - _ToonEvAdjustmentValueMin); + ev100_remap = clamp(ev100_remap, 0.0, 127.0); + int3 ev100_idx = (int3)ev100_remap; + float3 ev100_lerp = ev100_remap - ev100_idx; + float3 ev100_remapped; + + ev100_remapped.r = _ToonEvAdjustmentValueArray[ev100_idx.r] +(_ToonEvAdjustmentValueArray[ev100_idx.r + 1] - _ToonEvAdjustmentValueArray[ev100_idx.r]) * ev100_lerp.r; + ev100_remapped.g = _ToonEvAdjustmentValueArray[ev100_idx.g] +(_ToonEvAdjustmentValueArray[ev100_idx.g + 1] - _ToonEvAdjustmentValueArray[ev100_idx.g]) * ev100_lerp.g; + ev100_remapped.b = _ToonEvAdjustmentValueArray[ev100_idx.b] +(_ToonEvAdjustmentValueArray[ev100_idx.b + 1] - _ToonEvAdjustmentValueArray[ev100_idx.b]) * ev100_lerp.b; + + + float3 resultColor = ConvertFromEV100(ev100_remapped); + + + return resultColor; + } + else // else is neccessary to avoid warrnings. + { + return originalColor; + } +} + + +float GetLightAttenuation(float3 lightColor) +{ + float lightAttenuation = rateR *lightColor.r + rateG *lightColor.g + rateB *lightColor.b; + return lightAttenuation; +} + + +int GetNextDirectionalLightIndex(BuiltinData builtinData, int currentIndex, int mainLightIndex) +{ + int i = 0; // Declare once to avoid the D3D11 compiler warning. + for (i = 0; i < (int)_DirectionalLightCount; ++i) + { + if (IsMatchingLightLayer(_DirectionalLightDatas[i].lightLayers, builtinData.renderingLayers)) + { + if (mainLightIndex != i) + { + if (currentIndex < i) + { + return i; + } + } + } + } + return -1; // not found +} +int GetUtsMainLightIndex(BuiltinData builtinData) +{ + int mainLightIndex = -1; + float3 lightColor = float3(0.0f, 0.0f, 0.0f); + float lightAttenuation = 0.0f; + uint i = 0; // Declare once to avoid the D3D11 compiler warning. + for (i = 0; i < _DirectionalLightCount; ++i) + { + if (IsMatchingLightLayer(_DirectionalLightDatas[i].lightLayers, builtinData.renderingLayers)) + { + float3 currentLightColor = _DirectionalLightDatas[i].color; + float currentLightAttenuation = GetLightAttenuation(currentLightColor); + + if (mainLightIndex == -1 || (currentLightAttenuation > lightAttenuation)) + { + mainLightIndex = i; + lightAttenuation = currentLightAttenuation; + lightColor = currentLightColor; + } + } + } + + return mainLightIndex; +} + + +#if defined(_SHADINGGRADEMAP)|| defined(UTS_DEBUG_SHADOWMAP) || defined(UTS_DEBUG_SELFSHADOW) +# include "ShadingGrademapOtherLight.hlsl" +#else //#if defined(_SHADINGGRADEMAP) +# include "DoubleShadeWithFeatherOtherLight.hlsl" +#endif //#if defined(_SHADINGGRADEMAP) + +# include "UtsSelfShadowMainLight.hlsl" + + + +#if defined(_SHADINGGRADEMAP)|| defined(UTS_DEBUG_SHADOWMAP) +# include "ShadingGrademapMainLight.hlsl" +#else +# include "DoubleShadeWithFeatherMainLight.hlsl" +#endif + diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsLightLoop.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsLightLoop.hlsl.meta new file mode 100644 index 0000000..b676ae4 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsLightLoop.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9ed2a3a7c9a17104c9792d8ec79bf631 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsSelfShadowMainLight.hlsl b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsSelfShadowMainLight.hlsl new file mode 100644 index 0000000..aed698b --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsSelfShadowMainLight.hlsl @@ -0,0 +1,86 @@ +//Unity Toon Shader/HDRP +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Universal RP/HDRP) + + +#ifndef DirectionalShadowType +# if (SHADEROPTIONS_RAYTRACING && (defined(SHADER_API_D3D11) || defined(SHADER_API_D3D12)) && !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)) +# define DirectionalShadowType float3 +# else +# define DirectionalShadowType float +# endif +#endif + +float3 UTS_SelfShdowMainLight(LightLoopContext lightLoopContext, FragInputs input, int mainLightIndex) +{ + + uint2 tileIndex = uint2(input.positionSS.xy) / GetTileSize(); + + // input.positionSS is SV_Position + PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, tileIndex); + + +#ifdef VARYINGS_NEED_POSITION_WS + float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS); +#else + // Unused + float3 V = float3(1.0, 1.0, 1.0); // Avoid the division by 0 +#endif + + SurfaceData surfaceData; + BuiltinData builtinData; + GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData); + + BSDFData bsdfData = ConvertSurfaceDataToBSDFData(input.positionSS.xy, surfaceData); + + PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); + /* todo. these should be put int a struct */ + float4 Set_UV0 = input.texCoord0; + float3x3 tangentTransform = input.tangentToWorld; + //UnpackNormalmapRGorAG(SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, texCoords)) + float4 n = SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, Set_UV0.xy); + // float3 _NormalMap_var = UnpackNormalScale(tex2D(_NormalMap, TRANSFORM_TEX(Set_UV0, _NormalMap)), _BumpScale); + float3 _NormalMap_var = UnpackNormalScale(n, _BumpScale); + float3 normalLocal = _NormalMap_var.rgb; + + + float3 i_normalDir = surfaceData.normalWS; + + /* to here todo. these should be put int a struct */ + + + float shadowAttenuation = (float)lightLoopContext.shadowValue; + + + float3 mainLihgtDirection = -_DirectionalLightDatas[mainLightIndex].forward; + float3 mainLightColor = ApplyCurrentExposureMultiplier(_DirectionalLightDatas[mainLightIndex].color); + // float4 tmpColor = EvaluateLight_Directional(context, posInput, _DirectionalLightDatas[mainLightIndex]); + // float3 mainLightColor = tmpColor.xyz; + float3 defaultLightDirection = normalize(UNITY_MATRIX_V[2].xyz + UNITY_MATRIX_V[1].xyz); + float3 defaultLightColor = saturate(max(float3(0.05, 0.05, 0.05) * _Unlit_Intensity, max( + SampleBakedGI_UTS(posInput.positionWS, float3(0.0, 0.0, 0.0), input.texCoord1.xy, input.texCoord2.xy, true), + SampleBakedGI_UTS(posInput.positionWS, float3(0.0, -1.0, 0.0), input.texCoord1.xy, input.texCoord2.xy, true) + ) * _Unlit_Intensity)); + float3 customLightDirection = normalize(mul(UNITY_MATRIX_M, float4(((float3(1.0, 0.0, 0.0) * _Offset_X_Axis_BLD * 10) + (float3(0.0, 1.0, 0.0) * _Offset_Y_Axis_BLD * 10) + (float3(0.0, 0.0, -1.0) * lerp(-1.0, 1.0, _Inverse_Z_Axis_BLD))), 0)).xyz); + float3 lightDirection = normalize(lerp(defaultLightDirection, mainLihgtDirection.xyz, any(mainLihgtDirection.xyz))); + lightDirection = lerp(lightDirection, customLightDirection, _Is_BLD); + + ////// Lighting: + + + + float _HalfLambert_var = 0.5 * dot(i_normalDir, lightDirection) + 0.5; + float lambert = dot(i_normalDir, lightDirection); + _HalfLambert_var = lambert; + + float baseColorStep = 0.00001; + float Set_FinalShadowMask = saturate(1.0 + (-_HalfLambert_var) / (baseColorStep)); + + float3 Set_FinalBaseColor = 1 - Set_FinalShadowMask; + + + + return Set_FinalBaseColor; + + +} diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsSelfShadowMainLight.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsSelfShadowMainLight.hlsl.meta new file mode 100644 index 0000000..0e69552 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsSelfShadowMainLight.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d53a3bfa05741064d9b4d15154890a04 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsTextures.hlsl b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsTextures.hlsl new file mode 100644 index 0000000..7eb5632 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsTextures.hlsl @@ -0,0 +1,27 @@ + +// Unity Toon Shader +// sampler2D _MainTex; +// sampler2D _1st_ShadeMap; +// sampler2D _2nd_ShadeMap; + +TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex); +TEXTURE2D(_1st_ShadeMap); +TEXTURE2D(_2nd_ShadeMap); + + +sampler2D _Set_1st_ShadePosition; +sampler2D _Set_2nd_ShadePosition; +sampler2D _ShadingGradeMap; +sampler2D _HighColor_Tex; +sampler2D _Set_HighColorMask; +sampler2D _Set_RimLightMask; +sampler2D _MatCap_Sampler; +sampler2D _NormalMapForMatCap; +sampler2D _Set_MatcapMask; +sampler2D _Emissive_Tex; +// sampler2D _ClippingMask); +TEXTURE2D(_ClippingMask); +sampler2D _AngelRing_Sampler; +sampler2D _Outline_Sampler; +sampler2D _OutlineTex; +sampler2D _BakedNormal; diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsTextures.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsTextures.hlsl.meta new file mode 100644 index 0000000..ca67d19 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsTextures.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5b757fd47d2cd7d4e8b2e32ece1f6f8d +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsUnityPerMaterial.hlsl b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsUnityPerMaterial.hlsl new file mode 100644 index 0000000..7a90b75 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsUnityPerMaterial.hlsl @@ -0,0 +1,188 @@ + +// cosntant in Unity Toon Shader +float _utsTechnique; +float4 _Color; +fixed _Use_BaseAs1st; +fixed _Use_1stAs2nd; +fixed _Is_LightColor_Base; +float4 _MainTex_ST; +float4 _1st_ShadeMap_ST; +float4 _1st_ShadeColor; +fixed _Is_LightColor_1st_Shade; +float4 _2nd_ShadeMap_ST; +float4 _2nd_ShadeColor; +fixed _Is_LightColor_2nd_Shade; +fixed _Is_NormalMapToBase; +fixed _Set_SystemShadowsToBase; + +float _Tweak_SystemShadowsLevel; +float _BaseColor_Step; +float _BaseShade_Feather; +float4 _Set_1st_ShadePosition_ST; + +float _ShadeColor_Step; +float _1st2nd_Shades_Feather; +float4 _Set_2nd_ShadePosition_ST; +float4 _ShadingGradeMap_ST; + +float _Tweak_ShadingGradeMapLevel; +fixed _BlurLevelSGM; +// +float _1st_ShadeColor_Step; +float _1st_ShadeColor_Feather; +float _2nd_ShadeColor_Step; +float _2nd_ShadeColor_Feather; + +float4 _HighColor; +float4 _HighColor_Tex_ST; +fixed _Is_LightColor_HighColor; + +fixed _Is_NormalMapToHighColor; +float _HighColor_Power; +fixed _Is_SpecularToHighColor; +fixed _Is_BlendAddToHiColor; +fixed _Is_UseTweakHighColorOnShadow; +float _TweakHighColorOnShadow; +float4 _Set_HighColorMask_ST; +float _Tweak_HighColorMaskLevel; +fixed _RimLight; +float4 _RimLightColor; +fixed _Is_LightColor_RimLight; +fixed _Is_NormalMapToRimLight; +float _RimLight_Power; +float _RimLight_InsideMask; +fixed _RimLight_FeatherOff; +fixed _LightDirection_MaskOn; +float _Tweak_LightDirection_MaskLevel; +fixed _Add_Antipodean_RimLight; +float4 _Ap_RimLightColor; +fixed _Is_LightColor_Ap_RimLight; +float _Ap_RimLight_Power; +fixed _Ap_RimLight_FeatherOff; +float4 _Set_RimLightMask_ST; +float _Tweak_RimLightMaskLevel; +fixed _MatCap; +float4 _MatCap_Sampler_ST; +float4 _MatCapColor; +fixed _Is_LightColor_MatCap; +fixed _Is_BlendAddToMatCap; +float _Tweak_MatCapUV; +float _Rotate_MatCapUV; +fixed _Is_NormalMapForMatCap; +float4 _NormalMapForMatCap_ST; +float _Rotate_NormalMapForMatCapUV; +fixed _Is_UseTweakMatCapOnShadow; +float _TweakMatCapOnShadow; +float4 _Set_MatcapMask_ST; +float _Tweak_MatcapMaskLevel; +fixed _Is_Ortho; +float _CameraRolling_Stabilizer; +fixed _BlurLevelMatcap; +fixed _Inverse_MatcapMask; +float _BumpScale; +float _BumpScaleMatcap; +float4 _Emissive_Tex_ST; +float4 _Emissive_Color; + +fixed _Is_ViewCoord_Scroll; +float _Rotate_EmissiveUV; +float _Base_Speed; +float _Scroll_EmissiveU; +float _Scroll_EmissiveV; +fixed _Is_PingPong_Base; +float4 _ColorShift; +float4 _ViewShift; +float _ColorShift_Speed; +fixed _Is_ColorShift; +fixed _Is_ViewShift; +float3 emissive; +// +float _Unlit_Intensity; + +fixed _Is_Filter_HiCutPointLightColor; +fixed _Is_Filter_LightColor; + +float _StepOffset; +fixed _Is_BLD; +float _Offset_X_Axis_BLD; +float _Offset_Y_Axis_BLD; +fixed _Inverse_Z_Axis_BLD; + +float4 _ClippingMask_ST; + +fixed _IsBaseMapAlphaAsClippingMask; +float _Clipping_Level; +fixed _Inverse_Clipping; +float _Tweak_transparency; +fixed _AngelRing; +float4 _AngelRing_Sampler_ST; + +float _BaseColorVisible; +float _BaseColorOverridden; +float4 _BaseColorMaskColor; + +float _FirstShadeVisible; +float _FirstShadeOverridden; +float4 _FirstShadeMaskColor; + +float _SecondShadeVisible; +float _SecondShadeOverridden; +float4 _SecondShadeMaskColor; + +float _HighlightVisible; +float _HighlightOverridden; +float4 _HighlightMaskColor; + +float _AngelRingVisible; +float _AngelRingOverridden; +float4 _AngelRingMaskColor; + +float _RimLightVisible; +float _RimLightOverridden; +float4 _RimLightMaskColor; + +float _OutlineVisible; +float _OutlineOverridden; +float4 _OutlineMaskColor; + +float _ComposerMaskMode; +int _ClippingMatteMode; + +float _GI_Intensity; + + +float4 _AngelRing_Color; +fixed _Is_LightColor_AR; +float _AR_OffsetU; +float _AR_OffsetV; +fixed _ARSampler_AlphaOn; + +// Unity Toon Shader Outline + +fixed _Is_LightColor_Outline; +float _Outline_Width; +float _Farthest_Distance; +float _Nearest_Distance; +float4 _Outline_Sampler_ST; +float4 _Outline_Color; +fixed _Is_BlendBaseColor; +float _Offset_Z; +float4 _OutlineTex_ST; +fixed _Is_OutlineTex; +float4 _BakedNormal_ST; +fixed _Is_BakedNormal; + +float _ZOverDrawMode; + // + +#if defined(_UTS_TOON_EV_PER_MODEL) +// not in materials +int _ToonLightHiCutFilter; +int _ToonEvAdjustmentCurve; +float _ToonEvAdjustmentValueArray[128]; +float _ToonEvAdjustmentValueMin; +float _ToonEvAdjustmentValueMax; +float _ToonEvAdjustmentCompensation; +#endif //#if !defined(_UTS_TOON_EV_PER_MODEL) + + diff --git a/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsUnityPerMaterial.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsUnityPerMaterial.hlsl.meta new file mode 100644 index 0000000..29369b3 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/HDRP/Shaders/UtsUnityPerMaterial.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7efa59ca140c8c1448f8198e85ed27ec +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Integrated.meta b/BJH/Assets/BJH/3dtest/Runtime/Integrated.meta new file mode 100644 index 0000000..ba0d852 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Integrated.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 597ad9a8fd13994418511dbf5b99ee4b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Integrated/Shaders.meta b/BJH/Assets/BJH/3dtest/Runtime/Integrated/Shaders.meta new file mode 100644 index 0000000..8c2e41e --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Integrated/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7ef86aec2d0a7ed41b1e9aac674c4175 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Integrated/Shaders/UnityToon.shader b/BJH/Assets/BJH/3dtest/Runtime/Integrated/Shaders/UnityToon.shader new file mode 100644 index 0000000..f380d9a --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Integrated/Shaders/UnityToon.shader @@ -0,0 +1,1651 @@ +//Auto-generated on Fri Dec 19 07:08:10 UTC 2025 +Shader "Toon/Toon" { + Properties + { + // Common Properties for Unity Toon Shader + // This file contains all shared properties between UnityToon.shader and UnityToonTessellation.shader + // with comments preserved from the original files + + // Basic UI and Version Properties + [HideInInspector] _simpleUI ("SimpleUI", Int ) = 0 + [HideInInspector] _utsTechnique ("Technique", int ) = 0 //DWF + _AutoRenderQueue("Automatic Render Queue ", int) = 1 + + // Stencil Properties + [Enum(OFF, 0, StencilOut, 1, StencilMask, 2)] _StencilMode("StencilMode", int) = 0 + // these are set in UniversalToonGUI.cs in accordance with _StencilMode + _StencilComp("Stencil Comparison", Float) = 8 + _StencilNo("Stencil No", Float) = 1 + _StencilOpPass("Stencil Operation", Float) = 0 + _StencilOpFail("Stencil Operation", Float) = 0 + [Enum(OFF, 0, ON, 1,] _TransparentEnabled("Transparent Mode", int) = 0 + + // Clipping Properties + // DoubleShadeWithFeather + // 0:_IS_CLIPPING_OFF 1:_IS_CLIPPING_MODE 2:_IS_CLIPPING_TRANSMODE + // ShadingGradeMap + // 0:_IS_TRANSCLIPPING_OFF 1:_IS_TRANSCLIPPING_ON + [Enum(OFF, 0, ON, 1, TRANSMODE, 2)] _ClippingMode("CliippingMode", int) = 0 + + // Cull and ZWrite Properties + [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK + [Enum(OFF, 0, ONT, 1)] _ZWriteMode("ZWrite Mode", int) = 1 //OFF/ON + [Enum(OFF, 0, ONT, 1)] _ZOverDrawMode("ZOver Draw Mode", Float) = 0 //OFF/ON + _SPRDefaultUnlitColorMask("SPRDefaultUnlit Path Color Mask", int) = 15 + [Enum(OFF, 0, FRONT, 1, BACK, 2)] _SRPDefaultUnlitColMode("SPRDefaultUnlit Cull Mode", int) = 1 //OFF/FRONT/BACK + + // ClippingMask parameters + // ClippingMask paramaters from Here. + _ClippingMask("ClippingMask", 2D) = "white" {} + _IsBaseMapAlphaAsClippingMask("IsBaseMapAlphaAsClippingMask", Float) = 0 + // + [Toggle(_)] _Inverse_Clipping("Inverse_Clipping", Float) = 0 + _Clipping_Level("Clipping_Level", Range(0, 1)) = 0 + _Tweak_transparency("Tweak_transparency", Range(-1, 1)) = 0 + // ClippingMask paramaters to Here. + + // Base Color Properties + _MainTex ("BaseMap", 2D) = "white" {} + _BaseMap ("BaseMap", 2D) = "white" {} + _BaseColor ("BaseColor", Color) = (1,1,1,1) + //v.2.0.5 : Clipping/TransClipping for SSAO Problems in PostProcessing Stack. + //If you want to go back the former SSAO results, comment out the below line. + _Color("Color", Color) = (1,1,1,1) + // + [Toggle(_)] _Is_LightColor_Base ("Is_LightColor_Base", Float ) = 1 + + // 1st Shade Properties + _1st_ShadeMap ("1st_ShadeMap", 2D) = "white" {} + //v.2.0.5 + [Toggle(_)] _Use_BaseAs1st ("Use BaseMap as 1st_ShadeMap", Float ) = 0 + _1st_ShadeColor ("1st_ShadeColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_1st_Shade ("Is_LightColor_1st_Shade", Float ) = 1 + + // 2nd Shade Properties + _2nd_ShadeMap ("2nd_ShadeMap", 2D) = "white" {} + //v.2.0.5 + [Toggle(_)] _Use_1stAs2nd ("Use 1st_ShadeMap as 2nd_ShadeMap", Float ) = 0 + _2nd_ShadeColor ("2nd_ShadeColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_2nd_Shade ("Is_LightColor_2nd_Shade", Float ) = 1 + + // Normal Map Properties + _NormalMap ("NormalMap", 2D) = "bump" {} + _BumpScale ("Normal Scale", Range(0, 1)) = 1 + [Toggle(_)] _Is_NormalMapToBase ("Is_NormalMapToBase", Float ) = 0 + //v.2.0.4.4 + [Toggle(_)] _Set_SystemShadowsToBase ("Set_SystemShadowsToBase", Float ) = 1 + _Tweak_SystemShadowsLevel ("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0 + + // Shading Properties + //v.2.0.6 + _BaseColor_Step ("BaseColor_Step", Range(0, 1)) = 0.5 + _BaseShade_Feather ("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001 + _ShadeColor_Step ("ShadeColor_Step", Range(0, 1)) = 0 + _1st2nd_Shades_Feather ("1st/2nd_Shades_Feather", Range(0.0001, 1)) = 0.0001 + _1st_ShadeColor_Step ("1st_ShadeColor_Step", Range(0, 1)) = 0.5 + _1st_ShadeColor_Feather ("1st_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 + _2nd_ShadeColor_Step ("2nd_ShadeColor_Step", Range(0, 1)) = 0 + _2nd_ShadeColor_Feather ("2nd_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 + //v.2.0.5 + _StepOffset ("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0 + [Toggle(_)] _Is_Filter_HiCutPointLightColor ("PointLights HiCut_Filter (ForwardAdd Only)", Float ) = 1 + + // Shading Grade Map Properties + _Set_1st_ShadePosition ("Set_1st_ShadePosition", 2D) = "white" {} + _Set_2nd_ShadePosition ("Set_2nd_ShadePosition", 2D) = "white" {} + _ShadingGradeMap("ShadingGradeMap", 2D) = "white" {} + //v.2.0.6 + _Tweak_ShadingGradeMapLevel("Tweak_ShadingGradeMapLevel", Range(-0.5, 0.5)) = 0 + _BlurLevelSGM("Blur Level of ShadingGradeMap", Range(0, 10)) = 0 + + // High Color Properties + _HighColor ("HighColor", Color) = (0,0,0,1) + //v.2.0.4 HighColor_Tex + _HighColor_Tex ("HighColor_Tex", 2D) = "white" {} + [Toggle(_)] _Is_LightColor_HighColor ("Is_LightColor_HighColor", Float ) = 1 + [Toggle(_)] _Is_NormalMapToHighColor ("Is_NormalMapToHighColor", Float ) = 0 + _HighColor_Power ("HighColor_Power", Range(0, 1)) = 0 + [Toggle(_)] _Is_SpecularToHighColor ("Is_SpecularToHighColor", Float ) = 0 + [Toggle(_)] _Is_BlendAddToHiColor ("Is_BlendAddToHiColor", Float ) = 0 + [Toggle(_)] _Is_UseTweakHighColorOnShadow ("Is_UseTweakHighColorOnShadow", Float ) = 0 + _TweakHighColorOnShadow ("TweakHighColorOnShadow", Range(0, 1)) = 0 + //HiColorMask + _Set_HighColorMask ("Set_HighColorMask", 2D) = "white" {} + _Tweak_HighColorMaskLevel ("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0 + + // Rim Light Properties + [Toggle(_)] _RimLight ("RimLight", Float ) = 0 + _RimLightColor ("RimLightColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_RimLight ("Is_LightColor_RimLight", Float ) = 1 + [Toggle(_)] _Is_NormalMapToRimLight ("Is_NormalMapToRimLight", Float ) = 0 + _RimLight_Power ("RimLight_Power", Range(0, 1)) = 0.1 + _RimLight_InsideMask ("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001 + [Toggle(_)] _RimLight_FeatherOff ("RimLight_FeatherOff", Float ) = 0 + //RimLight + [Toggle(_)] _LightDirection_MaskOn ("LightDirection_MaskOn", Float ) = 0 + _Tweak_LightDirection_MaskLevel ("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0 + [Toggle(_)] _Add_Antipodean_RimLight ("Add_Antipodean_RimLight", Float ) = 0 + _Ap_RimLightColor ("Ap_RimLightColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_Ap_RimLight ("Is_LightColor_Ap_RimLight", Float ) = 1 + _Ap_RimLight_Power ("Ap_RimLight_Power", Range(0, 1)) = 0.1 + [Toggle(_)] _Ap_RimLight_FeatherOff ("Ap_RimLight_FeatherOff", Float ) = 0 + //RimLightMask + _Set_RimLightMask ("Set_RimLightMask", 2D) = "white" {} + _Tweak_RimLightMaskLevel ("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0 + + // MatCap Properties + [Toggle(_)] _MatCap ("MatCap", Float ) = 0 + _MatCap_Sampler ("MatCap_Sampler", 2D) = "black" {} + //v.2.0.6 + _BlurLevelMatcap ("Blur Level of MatCap_Sampler", Range(0, 10)) = 0 + _MatCapColor ("MatCapColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_MatCap ("Is_LightColor_MatCap", Float ) = 1 + [Toggle(_)] _Is_BlendAddToMatCap ("Is_BlendAddToMatCap", Float ) = 1 + _Tweak_MatCapUV ("Tweak_MatCapUV", Range(-0.5, 0.5)) = 0 + _Rotate_MatCapUV ("Rotate_MatCapUV", Range(-1, 1)) = 0 + //v.2.0.6 + [Toggle(_)] _CameraRolling_Stabilizer ("Activate CameraRolling_Stabilizer", Float ) = 0 + [Toggle(_)] _Is_NormalMapForMatCap ("Is_NormalMapForMatCap", Float ) = 0 + _NormalMapForMatCap ("NormalMapForMatCap", 2D) = "bump" {} + _BumpScaleMatcap ("Scale for NormalMapforMatCap", Range(0, 1)) = 1 + _Rotate_NormalMapForMatCapUV ("Rotate_NormalMapForMatCapUV", Range(-1, 1)) = 0 + [Toggle(_)] _Is_UseTweakMatCapOnShadow ("Is_UseTweakMatCapOnShadow", Float ) = 0 + _TweakMatCapOnShadow ("TweakMatCapOnShadow", Range(0, 1)) = 0 + //MatcapMask + _Set_MatcapMask ("Set_MatcapMask", 2D) = "white" {} + _Tweak_MatcapMaskLevel ("Tweak_MatcapMaskLevel", Range(-1, 1)) = 0 + [Toggle(_)] _Inverse_MatcapMask ("Inverse_MatcapMask", Float ) = 0 + //v.2.0.5 + [Toggle(_)] _Is_Ortho ("Orthographic Projection for MatCap", Float ) = 0 + + // Angel Rings Properties + //// Angel Rings + [Toggle(_)] _AngelRing("AngelRing", Float) = 0 + _AngelRing_Sampler("AngelRing_Sampler", 2D) = "black" {} + _AngelRing_Color("AngelRing_Color", Color) = (1, 1, 1, 1) + [Toggle(_)] _Is_LightColor_AR("Is_LightColor_AR", Float) = 1 + _AR_OffsetU("AR_OffsetU", Range(0, 0.5)) = 0 + _AR_OffsetV("AR_OffsetV", Range(0, 1)) = 0.3 + [Toggle(_)] _ARSampler_AlphaOn("ARSampler_AlphaOn", Float) = 0 + + // Emissive Properties + //v.2.0.7 Emissive + [KeywordEnum(SIMPLE,ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0 + _Emissive_Tex ("Emissive_Tex", 2D) = "white" {} + [HDR]_Emissive_Color ("Emissive_Color", Color) = (0,0,0,1) + _Base_Speed ("Base_Speed", Float ) = 0 + _Scroll_EmissiveU ("Scroll_EmissiveU", Range(-1, 1)) = 0 + _Scroll_EmissiveV ("Scroll_EmissiveV", Range(-1, 1)) = 0 + _Rotate_EmissiveUV ("Rotate_EmissiveUV", Float ) = 0 + [Toggle(_)] _Is_PingPong_Base ("Is_PingPong_Base", Float ) = 0 + [Toggle(_)] _Is_ColorShift ("Activate ColorShift", Float ) = 0 + [HDR]_ColorShift ("ColorSift", Color) = (0,0,0,1) + _ColorShift_Speed ("ColorShift_Speed", Float ) = 0 + [Toggle(_)] _Is_ViewShift ("Activate ViewShift", Float ) = 0 + [HDR]_ViewShift ("ViewSift", Color) = (0,0,0,1) + [Toggle(_)] _Is_ViewCoord_Scroll ("Is_ViewCoord_Scroll", Float ) = 0 + + // Outline Properties + //Outline + [KeywordEnum(NML,POS)] _OUTLINE("OUTLINE MODE", Float) = 0 + _Outline_Width ("Outline_Width", Float ) = 0 + _Farthest_Distance ("Farthest_Distance", Float ) = 100 + _Nearest_Distance ("Nearest_Distance", Float ) = 0.5 + _Outline_Sampler ("Outline_Sampler", 2D) = "white" {} + _Outline_Color ("Outline_Color", Color) = (0.5,0.5,0.5,1) + [Toggle(_)] _Is_BlendBaseColor ("Is_BlendBaseColor", Float ) = 0 + [Toggle(_)] _Is_LightColor_Outline ("Is_LightColor_Outline", Float ) = 1 + //v.2.0.4 + [Toggle(_)] _Is_OutlineTex ("Is_OutlineTex", Float ) = 0 + _OutlineTex ("OutlineTex", 2D) = "white" {} + //Offset parameter + _Offset_Z ("Offset_Camera_Z", Float) = 0 + //v.2.0.4.3 Baked Normal Texture for Outline + [Toggle(_)] _Is_BakedNormal ("Is_BakedNormal", Float ) = 0 + _BakedNormal ("Baked Normal for Outline", 2D) = "white" {} + //GI Intensity + _GI_Intensity ("GI_Intensity", Range(0, 1)) = 0 + //For VR Chat under No effective light objects + _Unlit_Intensity ("Unlit_Intensity", Range(0, 4)) = 0 + //v.2.0.5 + [Toggle(_)] _Is_Filter_LightColor ("VRChat : SceneLights HiCut_Filter", Float ) = 1 + //Built-in Light Direction + [Toggle(_)] _Is_BLD ("Advanced : Activate Built-in Light Direction", Float ) = 0 + _Offset_X_Axis_BLD (" Offset X-Axis (Built-in Light Direction)", Range(-1, 1)) = -0.05 + _Offset_Y_Axis_BLD (" Offset Y-Axis (Built-in Light Direction)", Range(-1, 1)) = 0.09 + [Toggle(_)] _Inverse_Z_Axis_BLD (" Inverse Z-Axis (Built-in Light Direction)", Float ) = 1 + + // HDRP Matte Properties + ////////////////////////////////////////////////////////////////////////////// + ////////////////// Beginning of HDRP Matte. ////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// + [Toggle(_)] _BaseColorVisible("Channel mask", Float) = 1 + [Toggle(_)] _BaseColorOverridden("Channel mask", Float) = 0 + _BaseColorMaskColor("chennel mask color", Color) = (1, 1, 1, 1) + + [Toggle(_)] _FirstShadeVisible("Channel mask", Float) = 1 + [Toggle(_)] _FirstShadeOverridden("Channel mask", Float) = 0 + _FirstShadeMaskColor("chennel mask color", Color) = (0, 1, 1, 1) + + [Toggle(_)] _SecondShadeVisible("Channel mask", Float) = 1 + [Toggle(_)] _SecondShadeOverridden("Channel mask", Float) = 0 + _SecondShadeMaskColor("chennel mask color", Color) = (0, 0, 1, 1) + + [Toggle(_)] _HighlightVisible("Channel mask", Float) = 1 + [Toggle(_)] _HighlightOverridden("Channel mask", Float) = 0 + _HighlightMaskColor("Channel mask color", Color) = (1, 1, 0, 1) + + [Toggle(_)] _AngelRingVisible("Channel mask", Float) = 1 + [Toggle(_)] _AngelRingOverridden("Channel mask", Float) = 0 + _AngelRingMaskColor("Channel mask color", Color) = (0, 1, 0, 1) + + [Toggle(_)] _RimLightVisible("Channel mask", Float) = 1 + [Toggle(_)] _RimLightOverridden("Channel mask", Float) = 0 + _RimLightMaskColor("Channel mask color", Color) = (1, 0, 1, 1) + + [Toggle(_)] _OutlineVisible("Channel mask", Float) = 1 + [Toggle(_)] _OutlineOverridden("Channel mask", Float) = 0 + _OutlineMaskColor("Channel mask color", Color) = (0, 0, 0, 1) + + [Toggle(_)] _ComposerMaskMode("", Float) = 0 + [Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0 + + ////////////////////////////////////////////////////////////////////////////// + ////////////////// End of HDRP Matte. ////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// + + // Avoid HDRP srp batcher error + ////////////////// Avoid HDRP srp batcher error /////////////////////////////// + [HideInInspector] emissive("to avoid srp batcher error", Color)= (0, 0, 0, 1) // + ////////////////// Avoid HDRP srp batcher error /////////////////////////////// + + // HDRP material default values + ////////////////////////////////////////////////////////////////////////////// + ////////////////// Beginning of HDRP material default values. //////////////// + ////////////////////////////////////////////////////////////////////////////// + _BaseColorMap("BaseColorMap", 2D) = "white" {} + [HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0) + + _Metallic("_Metallic", Range(0.0, 1.0)) = 0 + _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 + _MaskMap("MaskMap", 2D) = "white" {} + _SmoothnessRemapMin("SmoothnessRemapMin", Float) = 0.0 + _SmoothnessRemapMax("SmoothnessRemapMax", Float) = 1.0 + _AlphaRemapMin("AlphaRemapMin", Float) = 0.0 // HDRP 14 + _AlphaRemapMax("AlphaRemapMax", Float) = 1.0 // HDRP 14 + _AORemapMin("AORemapMin", Float) = 0.0 + _AORemapMax("AORemapMax", Float) = 1.0 + + // Normal Maps + ////////////// _NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map + _NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value + _NormalScale("_NormalScale", Range(0.0, 8.0)) = 1 + + _BentNormalMap("_BentNormalMap", 2D) = "bump" {} + _BentNormalMapOS("_BentNormalMapOS", 2D) = "white" {} + + // Height Maps + _HeightMap("HeightMap", 2D) = "black" {} + // Caution: Default value of _HeightAmplitude must be (_HeightMax - _HeightMin) * 0.01 + // Those two properties are computed from the ones exposed in the UI and depends on the displaement mode so they are separate because we don't want to lose information upon displacement mode change. + [HideInInspector] _HeightAmplitude("Height Amplitude", Float) = 0.02 // In world units. This will be computed in the UI. + [HideInInspector] _HeightCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + + [Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization("Heightmap Parametrization", Int) = 0 + // These parameters are for vertex displacement/Tessellation + _HeightOffset("Height Offset", Float) = 0 + // MinMax mode + _HeightMin("Heightmap Min", Float) = -1 + _HeightMax("Heightmap Max", Float) = 1 + // Amplitude mode + _HeightTessAmplitude("Amplitude", Float) = 2.0 // in Centimeters + _HeightTessCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + + // These parameters are for pixel displacement + _HeightPoMAmplitude("Height Amplitude", Float) = 2.0 // In centimeters + + // Detail Maps + _DetailMap("DetailMap", 2D) = "linearGrey" {} + _DetailAlbedoScale("_DetailAlbedoScale", Range(0.0, 2.0)) = 1 + _DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1 + _DetailSmoothnessScale("_DetailSmoothnessScale", Range(0.0, 2.0)) = 1 + + // Tangent Maps + _TangentMap("TangentMap", 2D) = "bump" {} + _TangentMapOS("TangentMapOS", 2D) = "white" {} + _Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0 + _AnisotropyMap("AnisotropyMap", 2D) = "white" {} + + // Diffusion Profile + [HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0 + [HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0) + [HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0 + _SubsurfaceMask("Subsurface Radius", Range(0.0, 1.0)) = 1.0 + _SubsurfaceMaskMap("Subsurface Radius Map", 2D) = "white" {} + _TransmissionMask("Transmission Mask", Range(0.0, 1.0)) = 1.0 + _Thickness("Thickness", Range(0.0, 1.0)) = 1.0 + _ThicknessMap("Thickness Map", 2D) = "white" {} + _ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0) + + // Iridescence + _IridescenceThickness("Iridescence Thickness", Range(0.0, 1.0)) = 1.0 + _IridescenceThicknessMap("Iridescence Thickness Map", 2D) = "white" {} + _IridescenceThicknessRemap("Iridescence Thickness Remap", Vector) = (0, 1, 0, 0) + _IridescenceMask("Iridescence Mask", Range(0.0, 1.0)) = 1.0 + _IridescenceMaskMap("Iridescence Mask Map", 2D) = "white" {} + + // Coat + _CoatMask("Coat Mask", Range(0.0, 1.0)) = 0.0 + _CoatMaskMap("CoatMaskMap", 2D) = "white" {} + + // Specular + [ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0 + _SpecularColor("SpecularColor", Color) = (1, 1, 1, 1) + _SpecularColorMap("SpecularColorMap", 2D) = "white" {} + + // Following options are for the GUI inspector and different from the input parameters above + // These option below will cause different compilation flag. + [Enum(Off, 0, From Ambient Occlusion, 1, From Bent Normals, 2)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1 + + // Emissive + [HDR] _EmissiveColor("EmissiveColor", Color) = (0, 0, 0) + // Used only to serialize the LDR and HDR emissive color in the material UI, + // in the shader only the _EmissiveColor should be used + [HideInInspector] _EmissiveColorLDR("EmissiveColor LDR", Color) = (0, 0, 0) + _EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} + [ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0 + [HideInInspector] _EmissiveIntensityUnit("Emissive Mode", Int) = 0 + [ToggleUI] _UseEmissiveIntensity("Use Emissive Intensity", Int) = 0 + _EmissiveIntensity("Emissive Intensity", Float) = 1 + _EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0 + + // Distortion + _DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} + [ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0 + [ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0 + [Enum(Add, 0, Multiply, 1, Replace, 2)] _DistortionBlendMode("Distortion Blend Mode", Int) = 0 + [HideInInspector] _DistortionSrcBlend("Distortion Blend Src", Int) = 0 + [HideInInspector] _DistortionDstBlend("Distortion Blend Dst", Int) = 0 + [HideInInspector] _DistortionBlurSrcBlend("Distortion Blur Blend Src", Int) = 0 + [HideInInspector] _DistortionBlurDstBlend("Distortion Blur Blend Dst", Int) = 0 + [HideInInspector] _DistortionBlurBlendMode("Distortion Blur Blend Mode", Int) = 0 + _DistortionScale("Distortion Scale", Float) = 1 + _DistortionVectorScale("Distortion Vector Scale", Float) = 2 + _DistortionVectorBias("Distortion Vector Bias", Float) = -1 + _DistortionBlurScale("Distortion Blur Scale", Float) = 1 + _DistortionBlurRemapMin("DistortionBlurRemapMin", Float) = 0.0 + _DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0 + + // Alpha and Transparency + [ToggleUI] _UseShadowThreshold("_UseShadowThreshold", Float) = 0.0 + [ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 + _AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + _AlphaCutoffShadow("_AlphaCutoffShadow", Range(0.0, 1.0)) = 0.5 + _AlphaCutoffPrepass("_AlphaCutoffPrepass", Range(0.0, 1.0)) = 0.5 + _AlphaCutoffPostpass("_AlphaCutoffPostpass", Range(0.0, 1.0)) = 0.5 + [ToggleUI] _TransparentDepthPrepassEnable("_TransparentDepthPrepassEnable", Float) = 0.0 + [ToggleUI] _TransparentBackfaceEnable("_TransparentBackfaceEnable", Float) = 0.0 + [ToggleUI] _TransparentDepthPostpassEnable("_TransparentDepthPostpassEnable", Float) = 0.0 + _TransparentSortPriority("_TransparentSortPriority", Float) = 0 + + // Transparency + [Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0 + [Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0 + _Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.0 + _ThicknessMultiplier("Thickness Multiplier", Float) = 1.0 + _TransmittanceColor("Transmittance Color", Color) = (1.0, 1.0, 1.0) + _TransmittanceColorMap("TransmittanceColorMap", 2D) = "white" {} + _ATDistance("Transmittance Absorption Distance", Float) = 1.0 + [ToggleUI] _TransparentWritingMotionVec("_TransparentWritingMotionVec", Float) = 0.0 + + // Stencil state + // Forward + [HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting + [HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 3 // StencilMask.Lighting + // GBuffer + [HideInInspector] _StencilRefGBuffer("_StencilRefGBuffer", Int) = 2 // StencilLightingUsage.RegularLighting + [HideInInspector] _StencilWriteMaskGBuffer("_StencilWriteMaskGBuffer", Int) = 3 // StencilMask.Lighting + // Depth prepass + [HideInInspector] _StencilRefDepth("_StencilRefDepth", Int) = 0 // Nothing + [HideInInspector] _StencilWriteMaskDepth("_StencilWriteMaskDepth", Int) = 32 // DoesntReceiveSSR + // Motion vector pass + [HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilBitMask.ObjectMotionVectors + [HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilBitMask.ObjectMotionVectors + // Distortion vector pass + [HideInInspector] _StencilRefDistortionVec("_StencilRefDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors + [HideInInspector] _StencilWriteMaskDistortionVec("_StencilWriteMaskDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors + + // Blending state + [HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 + [HideInInspector] _BlendMode("__blendmode", Float) = 0.0 + [HideInInspector] _SrcBlend("__src", Float) = 1.0 + [HideInInspector] _DstBlend("__dst", Float) = 0.0 + [HideInInspector] _AlphaSrcBlend("__alphaSrc", Float) = 1.0 + [HideInInspector] _AlphaDstBlend("__alphaDst", Float) = 0.0 + [HideInInspector][ToggleUI] _ZWrite("__zw", Float) = 1.0 + [HideInInspector][ToggleUI] _TransparentZWrite("_TransparentZWrite", Float) = 0.0 + [HideInInspector] _CullModeForward("__cullmodeForward", Float) = 2.0 // This mode is dedicated to Forward to correctly handle backface then front face rendering thin transparent + [HideInInspector] _TransparentCullMode("_TransparentCullMode", Int) = 2 // Back culling by default + [HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal + [HideInInspector] _ZTestModeDistortion("_ZTestModeDistortion", Int) = 8 + [HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4 + [Enum(UnityEngine.Rendering.CompareFunction)] _ZTestTransparent("Transparent ZTest", Int) = 4 // Less equal + + [ToggleUI] _EnableFogOnTransparent("Enable Fog", Float) = 1.0 + [ToggleUI] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1.0 + + [ToggleUI] _DoubleSidedEnable("Double sided enable", Float) = 0.0 + [Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1 + [HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0) + + [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase("UV Set for base", Float) = 0 + [Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMapping("Mapping space", Float) = 0.0 + _TexWorldScale("Scale to apply on world coordinate", Float) = 1.0 + [HideInInspector] _InvTilingScale("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 + [HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0) + [Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 + + // Following enum should be material feature flags (i.e bitfield), however due to Gbuffer encoding constrain many combination exclude each other + // so we use this enum as "material ID" which can be interpreted as preset of bitfield of material feature + // The only material feature flag that can be added in all cases is clear coat + [Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, Iridescence, 3, Specular Color, 4, Translucent, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.Standard + + [ToggleUI] _EnableGeometricSpecularAA("EnableGeometricSpecularAA", Float) = 0.0 + _SpecularAAScreenSpaceVariance("SpecularAAScreenSpaceVariance", Range(0.0, 1.0)) = 0.1 + _SpecularAAThreshold("SpecularAAThreshold", Range(0.0, 1.0)) = 0.2 + + _PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5 + _PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15 + _PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5 + _PPDPrimitiveLength("Primitive length for POM", Float) = 1 + _PPDPrimitiveWidth("Primitive width for POM", Float) = 1 + [HideInInspector] _InvPrimScale("Inverse primitive scale for non-planar POM", Vector) = (1, 1, 0, 0) + + [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0 + [HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0) + [ToggleUI] _LinkDetailsWithBase("LinkDetailsWithBase", Float) = 1.0 + + [Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 + [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVEmissive("UV Set for emissive", Float) = 0 + _TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0 + [HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0) + + // Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" + // value that exist to identify if the GI emission need to be enabled. + // In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. + // TODO: Fix the code in legacy unity so we can customize the beahvior for GI + _EmissionColor("Color", Color) = (1, 1, 1) + + // HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes. + ////////// _MainTex("BaseMap", 2D) = "white" {} + _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + + [ToggleUI] _SupportDecals("Support Decals", Float) = 1.0 + [ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0 + [ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0 + ////////////////////////////////////////////////////////////////////////////// + //////////////////// End of HDRP material default values. //////////////////// + ////////////////////////////////////////////////////////////////////////////// + + [HideInInspector] _ToonMaterialVersion ("Toon Material Version", Integer ) = 0 + } + + + HLSLINCLUDE + + #define DISABLE_RP_SHADERS + //------------------------------------------------------------------------------------- + // Variant + //------------------------------------------------------------------------------------- +#ifndef DISABLE_RP_SHADERS +// HDRP Variant + #pragma shader_feature_local _ALPHATEST_ON + #pragma shader_feature_local _DEPTHOFFSET_ON + #pragma shader_feature_local _DOUBLESIDED_ON + #pragma shader_feature_local _ _VERTEX_DISPLACEMENT _PIXEL_DISPLACEMENT + #pragma shader_feature_local _VERTEX_DISPLACEMENT_LOCK_OBJECT_SCALE + #pragma shader_feature_local _DISPLACEMENT_LOCK_TILING_SCALE + #pragma shader_feature_local _PIXEL_DISPLACEMENT_LOCK_OBJECT_SCALE + #pragma shader_feature_local _TESSELLATION_PHONG + #pragma shader_feature_local _ _REFRACTION_PLANE _REFRACTION_SPHERE _REFRACTION_THIN + + #pragma shader_feature_local _ _EMISSIVE_MAPPING_PLANAR _EMISSIVE_MAPPING_TRIPLANAR + #pragma shader_feature_local _ _MAPPING_PLANAR _MAPPING_TRIPLANAR + #pragma shader_feature_local _NORMALMAP_TANGENT_SPACE + #pragma shader_feature_local _ _REQUIRE_UV2 _REQUIRE_UV3 + + #pragma shader_feature_local _NORMALMAP + #pragma shader_feature_local _MASKMAP + #pragma shader_feature_local _BENTNORMALMAP + #pragma shader_feature_local _EMISSIVE_COLOR_MAP + + // _ENABLESPECULAROCCLUSION keyword is obsolete but keep here for compatibility. Do not used + // _ENABLESPECULAROCCLUSION and _SPECULAR_OCCLUSION_X can't exist at the same time (the new _SPECULAR_OCCLUSION replace it) + // When _ENABLESPECULAROCCLUSION is found we define _SPECULAR_OCCLUSION_X so new code to work + #pragma shader_feature_local _ENABLESPECULAROCCLUSION + #pragma shader_feature_local _ _SPECULAR_OCCLUSION_NONE _SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP + #ifdef _ENABLESPECULAROCCLUSION + #define _SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP + #endif + + #pragma shader_feature_local _HEIGHTMAP + #pragma shader_feature_local _TANGENTMAP + #pragma shader_feature_local _ANISOTROPYMAP + #pragma shader_feature_local _DETAIL_MAP + #pragma shader_feature_local _SUBSURFACE_MASK_MAP + #pragma shader_feature_local _THICKNESSMAP + #pragma shader_feature_local _IRIDESCENCE_THICKNESSMAP + #pragma shader_feature_local _SPECULARCOLORMAP + #pragma shader_feature_local _TRANSMITTANCECOLORMAP + + #pragma shader_feature_local _DISABLE_DECALS + #pragma shader_feature_local _DISABLE_SSR + #pragma shader_feature_local _ADD_PRECOMPUTED_VELOCITY + #pragma shader_feature_local _ENABLE_GEOMETRIC_SPECULAR_AA + + // Keyword for transparent + #pragma shader_feature _SURFACE_TYPE_TRANSPARENT + #pragma shader_feature_local _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY + #pragma shader_feature_local _BLENDMODE_PRESERVE_SPECULAR_LIGHTING + #pragma shader_feature_local _ENABLE_FOG_ON_TRANSPARENT + #pragma shader_feature_local _TRANSPARENT_WRITES_MOTION_VEC + + // MaterialFeature are used as shader feature to allow compiler to optimize properly + #pragma shader_feature_local _MATERIAL_FEATURE_SUBSURFACE_SCATTERING + #pragma shader_feature_local _MATERIAL_FEATURE_TRANSMISSION + #pragma shader_feature_local _MATERIAL_FEATURE_ANISOTROPY + #pragma shader_feature_local _MATERIAL_FEATURE_CLEAR_COAT + #pragma shader_feature_local _MATERIAL_FEATURE_IRIDESCENCE + #pragma shader_feature_local _MATERIAL_FEATURE_SPECULAR_COLOR + + + + + // enable dithering LOD crossfade + #pragma multi_compile _ LOD_FADE_CROSSFADE + + //enable GPU instancing support + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + // enable debug shado + // #pragma multi_compile _ UTS_DEBUG_SELFSHADOW + // #pragma multi_compile _ UTS_DEBUG_SHADOWMAP + // #pragma multi_compile _ UTS_DEBUG_SHADOWMAP_NO_OUTLINE + // end of HDRP Variants +#endif //#ifndef DISABLE_RP_SHADERS + + ENDHLSL + + + // *************************** // + // ****** HDRP Subshader ***** // + // *************************** // + SubShader + { + PackageRequirements + { + "com.unity.render-pipelines.high-definition": "10.5.0" + } + // This tags allow to use the shader replacement features + Tags{ "RenderPipeline"="HDRenderPipeline" } + + Pass + { + Name "SceneSelectionPass" + Tags { "LightMode" = "SceneSelectionPass" } + + Cull Off + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // Note: Require _ObjectId and _PassValue variables + + // We reuse depth prepass for the scene selection, allow to handle alpha correctly as well as tessellation and vertex animation + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define SCENESELECTIONPASS // This will drive the output of the scene selection shader + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + #pragma editor_sync_compilation + + ENDHLSL + } + + // Caution: The outline selection in the editor use the vertex shader/hull/domain shader of the first pass declare. So it should not bethe meta pass. + Pass + { + Name "GBuffer" + Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index + + Cull[_CullMode] + ZTest[_ZTestGBuffer] + + Stencil + { + WriteMask[_StencilWriteMaskGBuffer] + Ref[_StencilRefGBuffer] + Comp Always + Pass Replace + } + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma multi_compile _ DOTS_INSTANCING_ON + + + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + #pragma multi_compile _ LIGHT_LAYERS + + #ifndef DEBUG_DISPLAY + // When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer + // Don't do it with debug display mode as it is possible there is no depth prepass in this case + #define SHADERPASS_GBUFFER_BYPASS_ALPHA_TEST + #endif + + #define SHADERPASS SHADERPASS_GBUFFER + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + // #include "MaterialGBufferMacrosUTS.hlsl" // must be above lit.hlsl + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + // #include "EncodeIntoGBufferUTS.hlsl" // must be bellow lit.hlsl + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl" + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + + // Extracts information for lightmapping, GI (emission, albedo, ...) + // This pass it not used during regular rendering. + Pass + { + Name "META" + Tags{ "LightMode" = "META" } + + Cull Off + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // Lightmap memo + // DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light, + // both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON. + + #define SHADERPASS SHADERPASS_LIGHT_TRANSPORT + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "ShadowCaster" + Tags{ "LightMode" = "ShadowCaster" } + + Cull[_CullMode] + + ZClip [_ZClip] + ZWrite On + ZTest LEqual + + ColorMask 0 + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + + #define SHADERPASS SHADERPASS_SHADOWS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "DepthForwardOnly" + Tags{ "LightMode" = "DepthForwardOnly" } + + Cull[_CullMode] + + // To be able to tag stencil with disableSSR information for forward + Stencil + { + WriteMask [_StencilWriteMaskDepth] + Ref [_StencilRefDepth] + Comp Always + Pass Replace + } + + ZWrite On + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // In deferred, depth only pass don't output anything. + // In forward it output the normal buffer + #pragma multi_compile _ WRITE_NORMAL_BUFFER + #pragma multi_compile _ WRITE_MSAA_DEPTH + + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #else + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #endif + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "MotionVectors" + Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity) + + // If velocity pass (motion vectors) is enabled we tag the stencil so it don't perform CameraMotionVelocity + Stencil + { + WriteMask [_StencilWriteMaskMV] + Ref [_StencilRefMV] + Comp Always + Pass Replace + } + + Cull[_CullMode] + + ZWrite On + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #pragma multi_compile _ WRITE_NORMAL_BUFFER + #pragma multi_compile _ WRITE_MSAA_DEPTH + + #define SHADERPASS SHADERPASS_MOTION_VECTORS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #else + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitMotionVectorPass.hlsl" + #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassMotionVectors.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "DistortionVectors" + Tags { "LightMode" = "DistortionVectors" } // This will be only for transparent object based on the RenderQueue index + + Stencil + { + WriteMask [_StencilRefDistortionVec] + Ref [_StencilRefDistortionVec] + Comp Always + Pass Replace + } + + Blend [_DistortionSrcBlend] [_DistortionDstBlend], [_DistortionBlurSrcBlend] [_DistortionBlurDstBlend] + BlendOp Add, [_DistortionBlurBlendOp] + ZTest [_ZTestModeDistortion] + ZWrite off + Cull [_CullMode] + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DISTORTION + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDistortionPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDistortion.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "TransparentDepthPrepass" + Tags{ "LightMode" = "TransparentDepthPrepass" } + + Cull[_CullMode] + ZWrite On + ColorMask 0 + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define CUTOFF_TRANSPARENT_DEPTH_PREPASS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + // Caution: Order is important: TransparentBackface, then Forward/ForwardOnly + Pass + { + Name "TransparentBackface" + Tags { "LightMode" = "TransparentBackface" } + + Blend [_SrcBlend] [_DstBlend], [_AlphaSrcBlend] [_AlphaDstBlend] + ZWrite [_ZWrite] + Cull Front + ColorMask [_ColorMaskTransparentVel] 1 + ZTest [_ZTestTransparent] + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + + // Supported shadow modes per light type + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH + #if UNITY_VERSION >= 60000000 + // fix for https://github.com/Unity-Technologies/com.unity.toonshader/issues/391 + #ifdef SHADOW_MEDIUM + #ifndef PUNCTUAL_SHADOW_MEDIUM + #define PUNCTUAL_SHADOW_MEDIUM + #endif + #ifndef DIRECTIONAL_SHADOW_MEDIUM + #define DIRECTIONAL_SHADOW_MEDIUM + #endif + #endif + + #ifdef SHADOW_HIGH + #ifndef PUNCTUAL_SHADOW_HIGH + #define PUNCTUAL_SHADOW_HIGH + #endif + #ifndef DIRECTIONAL_SHADOW_HIGH + #define DIRECTIONAL_SHADOW_HIGH + #endif + #endif + #endif + #define USE_CLUSTERED_LIGHTLIST // There is not FPTL lighting when using transparent + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + + Name "ForwardOnly" + Tags { "LightMode" = "ForwardOnly" } + + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" +// #pragma multi_compile _ UTS_DEBUG_SHADOWMAP_BINALIZATION + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + // Ensure APV path is taken if available + #pragma multi_compile_fragment _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 + #pragma multi_compile _ SHADOWS_SHADOWMASK + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON + // Supported shadow modes per light type + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH + #if UNITY_VERSION >= 60000000 + // fix for https://github.com/Unity-Technologies/com.unity.toonshader/issues/391 + #ifdef SHADOW_MEDIUM + #ifndef PUNCTUAL_SHADOW_MEDIUM + #define PUNCTUAL_SHADOW_MEDIUM + #endif + #ifndef DIRECTIONAL_SHADOW_MEDIUM + #define DIRECTIONAL_SHADOW_MEDIUM + #endif + #endif + + #ifdef SHADOW_HIGH + #ifndef PUNCTUAL_SHADOW_HIGH + #define PUNCTUAL_SHADOW_HIGH + #endif + #ifndef DIRECTIONAL_SHADOW_HIGH + #define DIRECTIONAL_SHADOW_HIGH + #endif + #endif + #endif + #define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER +// #pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + // In case of opaque we don't want to perform the alpha test, it is done in depth prepass and we use depth equal for ztest (setup from UI) + // Don't do it with debug display mode as it is possible there is no depth prepass in this case + #if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(DEBUG_DISPLAY) + #define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST + #endif + #pragma shader_feature_local _ _SHADINGGRADEMAP + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_ON + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + // controlling mask rendering + #pragma shader_feature _ _IS_CLIPPING_MATTE + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" +#ifdef UNITY_SHADER_VARIABLES_INCLUDED + #include "../../HDRP/Shaders/UtsLightLoop.hlsl" + #include "../../HDRP/Shaders/ShaderPassForwardUTS.hlsl" +#endif + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "TransparentDepthPostpass" + Tags { "LightMode" = "TransparentDepthPostpass" } + + Cull[_CullMode] + ZWrite On + ColorMask 0 + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define CUTOFF_TRANSPARENT_DEPTH_POSTPASS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Tags{ + "RenderType" = "Opaque" + } + Pass{ + Name "Outline" + Tags { + "LightMode" = "SRPDefaultUnlit" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + #define SHADOW_LOW + #define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER + + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + // Ensure APV path is taken if available + #pragma multi_compile_fragment _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO _IS_OUTLINE_CLIPPING_YES + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + #pragma shader_feature _ _IS_CLIPPING_MATTE + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + +#ifdef UNITY_SHADER_VARIABLES_INCLUDED + #include "../../HDRP/Shaders/HDRPToonHead.hlsl" + #include "../../HDRP/Shaders/HDRPToonOutline.hlsl" +#endif + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + } + // *************************** // + // ****** URP Subshader ***** // + // *************************** // + SubShader + { + PackageRequirements + { + "com.unity.render-pipelines.universal": "10.5.0" + } + Tags { + "RenderType"="Opaque" + "RenderPipeline" = "UniversalPipeline" + } + +//ToonCoreStart + Pass { + Name "ForwardLit" + Tags{"LightMode" = "UniversalForward"} + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 2.0 + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex vert + #pragma fragment frag + +#ifndef DISABLE_RP_SHADERS + // ------------------------------------- + // urp Material Keywords + // ------------------------------------- + #pragma shader_feature_local _ALPHAPREMULTIPLY_ON + #pragma shader_feature_local _EMISSION + #pragma shader_feature_local _METALLICSPECGLOSSMAP + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A +// #pragma shader_feature _OCCLUSIONMAP + + #pragma shader_feature_local _SPECULARHIGHLIGHTS_OFF + #pragma shader_feature_local _ENVIRONMENTREFLECTIONS_OFF + #pragma shader_feature_local _SPECULAR_SETUP + #pragma shader_feature_local _RECEIVE_SHADOWS_OFF +#endif + // ------------------------------------- + // Lightweight Pipeline keywords + #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN + #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS + #pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS + #pragma multi_compile _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH + #pragma multi_compile _ _FORWARD_PLUS + #if (!defined(UNITY_COMPILER_DXC) && (defined(UNITY_PLATFORM_OSX) || defined(UNITY_PLATFORM_IOS))) || defined(SHADER_API_PS5) + + #if defined(SHADER_API_PS5) || defined(SHADER_API_METAL) + + #define SUPPORTS_FOVEATED_RENDERING_NON_UNIFORM_RASTER 1 + + // On Metal Foveated Rendering is currently not supported with DXC + #pragma warning (disable : 3568) // unknown pragma ignored + + #pragma never_use_dxc metal + #pragma dynamic_branch _ _FOVEATED_RENDERING_NON_UNIFORM_RASTER + + #pragma warning (default : 3568) // restore unknown pragma ignored + + #endif + + #endif + #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 + #pragma multi_compile_fragment _ _LIGHT_LAYERS + + #pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE + // ------------------------------------- + // Unity defined keywords + #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING + #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile_fog + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #define _IS_PASS_FWDBASE + // DoubleShadeWithFeather and ShadingGradeMap use different fragment shader. + #pragma shader_feature_local _ _SHADINGGRADEMAP + + + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_ON + + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" +#ifdef UNIVERSAL_PIPELINE_CORE_INCLUDED + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonHead.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonBody.hlsl" +#endif + ENDHLSL + + } + + Pass { + Name "Outline" + Tags { + "LightMode" = "SRPDefaultUnlit" + } + Cull [_SRPDefaultUnlitColMode] + ColorMask [_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 2.0 + #pragma vertex vert + #pragma fragment frag + + + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO _IS_OUTLINE_CLIPPING_YES + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Outline is implemented in UniversalToonOutline.hlsl. + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + +#ifdef UNIVERSAL_PIPELINE_CORE_INCLUDED + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonHead.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonOutline.hlsl" +#endif + ENDHLSL + } + + Pass + { + Name "Universal2D" + Tags + { + "LightMode" = "Universal2D" + } + + // ------------------------------------- + // Render State Commands + Blend[_SrcBlend][_DstBlend] + ZWrite[_ZWrite] + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 + + // ------------------------------------- + // Shader Stages + #pragma vertex vert + #pragma fragment frag + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON + + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + + // ------------------------------------- + // Includes + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "../../UniversalRP/Shaders/UniversalBasic2D.hlsl" + ENDHLSL + } + + + Pass + { + Name "ShadowCaster" + Tags{"LightMode" = "ShadowCaster"} + + ZWrite On + ZTest LEqual + Cull[_CullMode] + + HLSLPROGRAM + #pragma target 2.0 + + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + #pragma vertex ShadowPassVertex + #pragma fragment ShadowPassFragment + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl" + ENDHLSL + } + + Pass + { + Name "DepthOnly" + Tags{"LightMode" = "DepthOnly"} + + ZWrite On + ColorMask 0 + Cull[_CullMode] + + HLSLPROGRAM + #pragma target 2.0 + + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex DepthOnlyVertex + #pragma fragment DepthOnlyFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl" + ENDHLSL + } + // This pass is used when drawing to a _CameraNormalsTexture texture + Pass + { + Name "DepthNormals" + Tags{"LightMode" = "DepthNormals"} + + ZWrite On + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Version.hlsl" + + + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex DepthNormalsVertex + #pragma fragment DepthNormalsFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _PARALLAXMAP + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl" + + ENDHLSL + } + +//ToonCoreEnd + } + + // ***************************** // + // ****** Legacy Subshader ***** // + // ***************************** // + + SubShader { + Tags { + "RenderType"="Opaque" + } +//ToonCoreStart + Pass { + Name "FORWARD" + Tags { + "LightMode"="ForwardBase" + } + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + //#define UNITY_PASS_FORWARDBASE + #include "UnityCG.cginc" + #include "AutoLight.cginc" + #include "Lighting.cginc" + #pragma multi_compile_fwdbase_fullshadows + #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + #pragma multi_compile _IS_PASS_FWDBASE //[TODO-sin:2025-11-20] Check if this is used. + + #pragma shader_feature_local UTS_RP_BUILTIN + #include_with_pragmas "../../Shaders/BuiltIn/BuiltInToonMode.hlsl" + + ENDCG + } + Pass { + Name "Outline" + Tags { + "LightMode"="ForwardBase" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #include "UnityCG.cginc" + //#pragma fragmentoption ARB_precision_hint_fastest + //#pragma multi_compile_shadowcaster + //#pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Unity Toon Shader 0.5.0 + #pragma multi_compile _ _DISABLE_OUTLINE + //The outline process goes to UTS_Outline.cginc. + #include "../../Legacy/Shaders/UCTS_Outline.cginc" + ENDCG + } + Pass { + Name "FORWARD_DELTA" + Tags { + "LightMode"="ForwardAdd" + } + + Blend One One + Cull[_CullMode] + + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + //#define UNITY_PASS_FORWARDADD + #include "UnityCG.cginc" + #include "AutoLight.cginc" + #include "Lighting.cginc" + //for Unity2018.x + #pragma multi_compile_fwdadd_fullshadows + #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + + #pragma multi_compile _IS_PASS_FWDDELTA //[TODO-sin:2025-11-20] Check if this is used. + + #pragma shader_feature_local UTS_RP_BUILTIN + #include_with_pragmas "../../Shaders/BuiltIn/BuiltInToonMode.hlsl" + + ENDCG + } + Pass { + Name "ShadowCaster" + Tags { + "LightMode"="ShadowCaster" + } + Offset 1, 1 + Cull Off + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + //#define UNITY_PASS_SHADOWCASTER + #include "UnityCG.cginc" + #include "Lighting.cginc" + #pragma fragmentoption ARB_precision_hint_fastest + #pragma multi_compile_shadowcaster + #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + //v.2.0.4 + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + #include "../../Legacy/Shaders/UCTS_ShadowCaster.cginc" + ENDCG + } +//ToonCoreEnd + } + + CustomEditor "UnityEditor.Rendering.Toon.UTS3GUI" +} diff --git a/BJH/Assets/BJH/3dtest/Runtime/Integrated/Shaders/UnityToon.shader.meta b/BJH/Assets/BJH/3dtest/Runtime/Integrated/Shaders/UnityToon.shader.meta new file mode 100644 index 0000000..82ffc46 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Integrated/Shaders/UnityToon.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: be891319084e9d147b09d89e80ce60e0 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Integrated/Shaders/UnityToonTessellation.shader b/BJH/Assets/BJH/3dtest/Runtime/Integrated/Shaders/UnityToonTessellation.shader new file mode 100644 index 0000000..046e60f --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Integrated/Shaders/UnityToonTessellation.shader @@ -0,0 +1,1759 @@ +//Auto-generated on Fri Dec 19 07:08:10 UTC 2025 +Shader "Toon/Toon (Tessellation)" { + Properties + { + // Common Properties for Unity Toon Shader + // This file contains all shared properties between UnityToon.shader and UnityToonTessellation.shader + // with comments preserved from the original files + + // Basic UI and Version Properties + [HideInInspector] _simpleUI ("SimpleUI", Int ) = 0 + [HideInInspector] _utsTechnique ("Technique", int ) = 0 //DWF + _AutoRenderQueue("Automatic Render Queue ", int) = 1 + + // Stencil Properties + [Enum(OFF, 0, StencilOut, 1, StencilMask, 2)] _StencilMode("StencilMode", int) = 0 + // these are set in UniversalToonGUI.cs in accordance with _StencilMode + _StencilComp("Stencil Comparison", Float) = 8 + _StencilNo("Stencil No", Float) = 1 + _StencilOpPass("Stencil Operation", Float) = 0 + _StencilOpFail("Stencil Operation", Float) = 0 + [Enum(OFF, 0, ON, 1,] _TransparentEnabled("Transparent Mode", int) = 0 + + // Clipping Properties + // DoubleShadeWithFeather + // 0:_IS_CLIPPING_OFF 1:_IS_CLIPPING_MODE 2:_IS_CLIPPING_TRANSMODE + // ShadingGradeMap + // 0:_IS_TRANSCLIPPING_OFF 1:_IS_TRANSCLIPPING_ON + [Enum(OFF, 0, ON, 1, TRANSMODE, 2)] _ClippingMode("CliippingMode", int) = 0 + + // Cull and ZWrite Properties + [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK + [Enum(OFF, 0, ONT, 1)] _ZWriteMode("ZWrite Mode", int) = 1 //OFF/ON + [Enum(OFF, 0, ONT, 1)] _ZOverDrawMode("ZOver Draw Mode", Float) = 0 //OFF/ON + _SPRDefaultUnlitColorMask("SPRDefaultUnlit Path Color Mask", int) = 15 + [Enum(OFF, 0, FRONT, 1, BACK, 2)] _SRPDefaultUnlitColMode("SPRDefaultUnlit Cull Mode", int) = 1 //OFF/FRONT/BACK + + // ClippingMask parameters + // ClippingMask paramaters from Here. + _ClippingMask("ClippingMask", 2D) = "white" {} + _IsBaseMapAlphaAsClippingMask("IsBaseMapAlphaAsClippingMask", Float) = 0 + // + [Toggle(_)] _Inverse_Clipping("Inverse_Clipping", Float) = 0 + _Clipping_Level("Clipping_Level", Range(0, 1)) = 0 + _Tweak_transparency("Tweak_transparency", Range(-1, 1)) = 0 + // ClippingMask paramaters to Here. + + // Base Color Properties + _MainTex ("BaseMap", 2D) = "white" {} + _BaseMap ("BaseMap", 2D) = "white" {} + _BaseColor ("BaseColor", Color) = (1,1,1,1) + //v.2.0.5 : Clipping/TransClipping for SSAO Problems in PostProcessing Stack. + //If you want to go back the former SSAO results, comment out the below line. + _Color("Color", Color) = (1,1,1,1) + // + [Toggle(_)] _Is_LightColor_Base ("Is_LightColor_Base", Float ) = 1 + + // 1st Shade Properties + _1st_ShadeMap ("1st_ShadeMap", 2D) = "white" {} + //v.2.0.5 + [Toggle(_)] _Use_BaseAs1st ("Use BaseMap as 1st_ShadeMap", Float ) = 0 + _1st_ShadeColor ("1st_ShadeColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_1st_Shade ("Is_LightColor_1st_Shade", Float ) = 1 + + // 2nd Shade Properties + _2nd_ShadeMap ("2nd_ShadeMap", 2D) = "white" {} + //v.2.0.5 + [Toggle(_)] _Use_1stAs2nd ("Use 1st_ShadeMap as 2nd_ShadeMap", Float ) = 0 + _2nd_ShadeColor ("2nd_ShadeColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_2nd_Shade ("Is_LightColor_2nd_Shade", Float ) = 1 + + // Normal Map Properties + _NormalMap ("NormalMap", 2D) = "bump" {} + _BumpScale ("Normal Scale", Range(0, 1)) = 1 + [Toggle(_)] _Is_NormalMapToBase ("Is_NormalMapToBase", Float ) = 0 + //v.2.0.4.4 + [Toggle(_)] _Set_SystemShadowsToBase ("Set_SystemShadowsToBase", Float ) = 1 + _Tweak_SystemShadowsLevel ("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0 + + // Shading Properties + //v.2.0.6 + _BaseColor_Step ("BaseColor_Step", Range(0, 1)) = 0.5 + _BaseShade_Feather ("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001 + _ShadeColor_Step ("ShadeColor_Step", Range(0, 1)) = 0 + _1st2nd_Shades_Feather ("1st/2nd_Shades_Feather", Range(0.0001, 1)) = 0.0001 + _1st_ShadeColor_Step ("1st_ShadeColor_Step", Range(0, 1)) = 0.5 + _1st_ShadeColor_Feather ("1st_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 + _2nd_ShadeColor_Step ("2nd_ShadeColor_Step", Range(0, 1)) = 0 + _2nd_ShadeColor_Feather ("2nd_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 + //v.2.0.5 + _StepOffset ("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0 + [Toggle(_)] _Is_Filter_HiCutPointLightColor ("PointLights HiCut_Filter (ForwardAdd Only)", Float ) = 1 + + // Shading Grade Map Properties + _Set_1st_ShadePosition ("Set_1st_ShadePosition", 2D) = "white" {} + _Set_2nd_ShadePosition ("Set_2nd_ShadePosition", 2D) = "white" {} + _ShadingGradeMap("ShadingGradeMap", 2D) = "white" {} + //v.2.0.6 + _Tweak_ShadingGradeMapLevel("Tweak_ShadingGradeMapLevel", Range(-0.5, 0.5)) = 0 + _BlurLevelSGM("Blur Level of ShadingGradeMap", Range(0, 10)) = 0 + + // High Color Properties + _HighColor ("HighColor", Color) = (0,0,0,1) + //v.2.0.4 HighColor_Tex + _HighColor_Tex ("HighColor_Tex", 2D) = "white" {} + [Toggle(_)] _Is_LightColor_HighColor ("Is_LightColor_HighColor", Float ) = 1 + [Toggle(_)] _Is_NormalMapToHighColor ("Is_NormalMapToHighColor", Float ) = 0 + _HighColor_Power ("HighColor_Power", Range(0, 1)) = 0 + [Toggle(_)] _Is_SpecularToHighColor ("Is_SpecularToHighColor", Float ) = 0 + [Toggle(_)] _Is_BlendAddToHiColor ("Is_BlendAddToHiColor", Float ) = 0 + [Toggle(_)] _Is_UseTweakHighColorOnShadow ("Is_UseTweakHighColorOnShadow", Float ) = 0 + _TweakHighColorOnShadow ("TweakHighColorOnShadow", Range(0, 1)) = 0 + //HiColorMask + _Set_HighColorMask ("Set_HighColorMask", 2D) = "white" {} + _Tweak_HighColorMaskLevel ("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0 + + // Rim Light Properties + [Toggle(_)] _RimLight ("RimLight", Float ) = 0 + _RimLightColor ("RimLightColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_RimLight ("Is_LightColor_RimLight", Float ) = 1 + [Toggle(_)] _Is_NormalMapToRimLight ("Is_NormalMapToRimLight", Float ) = 0 + _RimLight_Power ("RimLight_Power", Range(0, 1)) = 0.1 + _RimLight_InsideMask ("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001 + [Toggle(_)] _RimLight_FeatherOff ("RimLight_FeatherOff", Float ) = 0 + //RimLight + [Toggle(_)] _LightDirection_MaskOn ("LightDirection_MaskOn", Float ) = 0 + _Tweak_LightDirection_MaskLevel ("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0 + [Toggle(_)] _Add_Antipodean_RimLight ("Add_Antipodean_RimLight", Float ) = 0 + _Ap_RimLightColor ("Ap_RimLightColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_Ap_RimLight ("Is_LightColor_Ap_RimLight", Float ) = 1 + _Ap_RimLight_Power ("Ap_RimLight_Power", Range(0, 1)) = 0.1 + [Toggle(_)] _Ap_RimLight_FeatherOff ("Ap_RimLight_FeatherOff", Float ) = 0 + //RimLightMask + _Set_RimLightMask ("Set_RimLightMask", 2D) = "white" {} + _Tweak_RimLightMaskLevel ("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0 + + // MatCap Properties + [Toggle(_)] _MatCap ("MatCap", Float ) = 0 + _MatCap_Sampler ("MatCap_Sampler", 2D) = "black" {} + //v.2.0.6 + _BlurLevelMatcap ("Blur Level of MatCap_Sampler", Range(0, 10)) = 0 + _MatCapColor ("MatCapColor", Color) = (1,1,1,1) + [Toggle(_)] _Is_LightColor_MatCap ("Is_LightColor_MatCap", Float ) = 1 + [Toggle(_)] _Is_BlendAddToMatCap ("Is_BlendAddToMatCap", Float ) = 1 + _Tweak_MatCapUV ("Tweak_MatCapUV", Range(-0.5, 0.5)) = 0 + _Rotate_MatCapUV ("Rotate_MatCapUV", Range(-1, 1)) = 0 + //v.2.0.6 + [Toggle(_)] _CameraRolling_Stabilizer ("Activate CameraRolling_Stabilizer", Float ) = 0 + [Toggle(_)] _Is_NormalMapForMatCap ("Is_NormalMapForMatCap", Float ) = 0 + _NormalMapForMatCap ("NormalMapForMatCap", 2D) = "bump" {} + _BumpScaleMatcap ("Scale for NormalMapforMatCap", Range(0, 1)) = 1 + _Rotate_NormalMapForMatCapUV ("Rotate_NormalMapForMatCapUV", Range(-1, 1)) = 0 + [Toggle(_)] _Is_UseTweakMatCapOnShadow ("Is_UseTweakMatCapOnShadow", Float ) = 0 + _TweakMatCapOnShadow ("TweakMatCapOnShadow", Range(0, 1)) = 0 + //MatcapMask + _Set_MatcapMask ("Set_MatcapMask", 2D) = "white" {} + _Tweak_MatcapMaskLevel ("Tweak_MatcapMaskLevel", Range(-1, 1)) = 0 + [Toggle(_)] _Inverse_MatcapMask ("Inverse_MatcapMask", Float ) = 0 + //v.2.0.5 + [Toggle(_)] _Is_Ortho ("Orthographic Projection for MatCap", Float ) = 0 + + // Angel Rings Properties + //// Angel Rings + [Toggle(_)] _AngelRing("AngelRing", Float) = 0 + _AngelRing_Sampler("AngelRing_Sampler", 2D) = "black" {} + _AngelRing_Color("AngelRing_Color", Color) = (1, 1, 1, 1) + [Toggle(_)] _Is_LightColor_AR("Is_LightColor_AR", Float) = 1 + _AR_OffsetU("AR_OffsetU", Range(0, 0.5)) = 0 + _AR_OffsetV("AR_OffsetV", Range(0, 1)) = 0.3 + [Toggle(_)] _ARSampler_AlphaOn("ARSampler_AlphaOn", Float) = 0 + + // Emissive Properties + //v.2.0.7 Emissive + [KeywordEnum(SIMPLE,ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0 + _Emissive_Tex ("Emissive_Tex", 2D) = "white" {} + [HDR]_Emissive_Color ("Emissive_Color", Color) = (0,0,0,1) + _Base_Speed ("Base_Speed", Float ) = 0 + _Scroll_EmissiveU ("Scroll_EmissiveU", Range(-1, 1)) = 0 + _Scroll_EmissiveV ("Scroll_EmissiveV", Range(-1, 1)) = 0 + _Rotate_EmissiveUV ("Rotate_EmissiveUV", Float ) = 0 + [Toggle(_)] _Is_PingPong_Base ("Is_PingPong_Base", Float ) = 0 + [Toggle(_)] _Is_ColorShift ("Activate ColorShift", Float ) = 0 + [HDR]_ColorShift ("ColorSift", Color) = (0,0,0,1) + _ColorShift_Speed ("ColorShift_Speed", Float ) = 0 + [Toggle(_)] _Is_ViewShift ("Activate ViewShift", Float ) = 0 + [HDR]_ViewShift ("ViewSift", Color) = (0,0,0,1) + [Toggle(_)] _Is_ViewCoord_Scroll ("Is_ViewCoord_Scroll", Float ) = 0 + + // Outline Properties + //Outline + [KeywordEnum(NML,POS)] _OUTLINE("OUTLINE MODE", Float) = 0 + _Outline_Width ("Outline_Width", Float ) = 0 + _Farthest_Distance ("Farthest_Distance", Float ) = 100 + _Nearest_Distance ("Nearest_Distance", Float ) = 0.5 + _Outline_Sampler ("Outline_Sampler", 2D) = "white" {} + _Outline_Color ("Outline_Color", Color) = (0.5,0.5,0.5,1) + [Toggle(_)] _Is_BlendBaseColor ("Is_BlendBaseColor", Float ) = 0 + [Toggle(_)] _Is_LightColor_Outline ("Is_LightColor_Outline", Float ) = 1 + //v.2.0.4 + [Toggle(_)] _Is_OutlineTex ("Is_OutlineTex", Float ) = 0 + _OutlineTex ("OutlineTex", 2D) = "white" {} + //Offset parameter + _Offset_Z ("Offset_Camera_Z", Float) = 0 + //v.2.0.4.3 Baked Normal Texture for Outline + [Toggle(_)] _Is_BakedNormal ("Is_BakedNormal", Float ) = 0 + _BakedNormal ("Baked Normal for Outline", 2D) = "white" {} + //GI Intensity + _GI_Intensity ("GI_Intensity", Range(0, 1)) = 0 + //For VR Chat under No effective light objects + _Unlit_Intensity ("Unlit_Intensity", Range(0, 4)) = 0 + //v.2.0.5 + [Toggle(_)] _Is_Filter_LightColor ("VRChat : SceneLights HiCut_Filter", Float ) = 1 + //Built-in Light Direction + [Toggle(_)] _Is_BLD ("Advanced : Activate Built-in Light Direction", Float ) = 0 + _Offset_X_Axis_BLD (" Offset X-Axis (Built-in Light Direction)", Range(-1, 1)) = -0.05 + _Offset_Y_Axis_BLD (" Offset Y-Axis (Built-in Light Direction)", Range(-1, 1)) = 0.09 + [Toggle(_)] _Inverse_Z_Axis_BLD (" Inverse Z-Axis (Built-in Light Direction)", Float ) = 1 + + // HDRP Matte Properties + ////////////////////////////////////////////////////////////////////////////// + ////////////////// Beginning of HDRP Matte. ////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// + [Toggle(_)] _BaseColorVisible("Channel mask", Float) = 1 + [Toggle(_)] _BaseColorOverridden("Channel mask", Float) = 0 + _BaseColorMaskColor("chennel mask color", Color) = (1, 1, 1, 1) + + [Toggle(_)] _FirstShadeVisible("Channel mask", Float) = 1 + [Toggle(_)] _FirstShadeOverridden("Channel mask", Float) = 0 + _FirstShadeMaskColor("chennel mask color", Color) = (0, 1, 1, 1) + + [Toggle(_)] _SecondShadeVisible("Channel mask", Float) = 1 + [Toggle(_)] _SecondShadeOverridden("Channel mask", Float) = 0 + _SecondShadeMaskColor("chennel mask color", Color) = (0, 0, 1, 1) + + [Toggle(_)] _HighlightVisible("Channel mask", Float) = 1 + [Toggle(_)] _HighlightOverridden("Channel mask", Float) = 0 + _HighlightMaskColor("Channel mask color", Color) = (1, 1, 0, 1) + + [Toggle(_)] _AngelRingVisible("Channel mask", Float) = 1 + [Toggle(_)] _AngelRingOverridden("Channel mask", Float) = 0 + _AngelRingMaskColor("Channel mask color", Color) = (0, 1, 0, 1) + + [Toggle(_)] _RimLightVisible("Channel mask", Float) = 1 + [Toggle(_)] _RimLightOverridden("Channel mask", Float) = 0 + _RimLightMaskColor("Channel mask color", Color) = (1, 0, 1, 1) + + [Toggle(_)] _OutlineVisible("Channel mask", Float) = 1 + [Toggle(_)] _OutlineOverridden("Channel mask", Float) = 0 + _OutlineMaskColor("Channel mask color", Color) = (0, 0, 0, 1) + + [Toggle(_)] _ComposerMaskMode("", Float) = 0 + [Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0 + + ////////////////////////////////////////////////////////////////////////////// + ////////////////// End of HDRP Matte. ////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// + + // Avoid HDRP srp batcher error + ////////////////// Avoid HDRP srp batcher error /////////////////////////////// + [HideInInspector] emissive("to avoid srp batcher error", Color)= (0, 0, 0, 1) // + ////////////////// Avoid HDRP srp batcher error /////////////////////////////// + + // HDRP material default values + ////////////////////////////////////////////////////////////////////////////// + ////////////////// Beginning of HDRP material default values. //////////////// + ////////////////////////////////////////////////////////////////////////////// + _BaseColorMap("BaseColorMap", 2D) = "white" {} + [HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0) + + _Metallic("_Metallic", Range(0.0, 1.0)) = 0 + _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 + _MaskMap("MaskMap", 2D) = "white" {} + _SmoothnessRemapMin("SmoothnessRemapMin", Float) = 0.0 + _SmoothnessRemapMax("SmoothnessRemapMax", Float) = 1.0 + _AlphaRemapMin("AlphaRemapMin", Float) = 0.0 // HDRP 14 + _AlphaRemapMax("AlphaRemapMax", Float) = 1.0 // HDRP 14 + _AORemapMin("AORemapMin", Float) = 0.0 + _AORemapMax("AORemapMax", Float) = 1.0 + + // Normal Maps + ////////////// _NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map + _NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value + _NormalScale("_NormalScale", Range(0.0, 8.0)) = 1 + + _BentNormalMap("_BentNormalMap", 2D) = "bump" {} + _BentNormalMapOS("_BentNormalMapOS", 2D) = "white" {} + + // Height Maps + _HeightMap("HeightMap", 2D) = "black" {} + // Caution: Default value of _HeightAmplitude must be (_HeightMax - _HeightMin) * 0.01 + // Those two properties are computed from the ones exposed in the UI and depends on the displaement mode so they are separate because we don't want to lose information upon displacement mode change. + [HideInInspector] _HeightAmplitude("Height Amplitude", Float) = 0.02 // In world units. This will be computed in the UI. + [HideInInspector] _HeightCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + + [Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization("Heightmap Parametrization", Int) = 0 + // These parameters are for vertex displacement/Tessellation + _HeightOffset("Height Offset", Float) = 0 + // MinMax mode + _HeightMin("Heightmap Min", Float) = -1 + _HeightMax("Heightmap Max", Float) = 1 + // Amplitude mode + _HeightTessAmplitude("Amplitude", Float) = 2.0 // in Centimeters + _HeightTessCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + + // These parameters are for pixel displacement + _HeightPoMAmplitude("Height Amplitude", Float) = 2.0 // In centimeters + + // Detail Maps + _DetailMap("DetailMap", 2D) = "linearGrey" {} + _DetailAlbedoScale("_DetailAlbedoScale", Range(0.0, 2.0)) = 1 + _DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1 + _DetailSmoothnessScale("_DetailSmoothnessScale", Range(0.0, 2.0)) = 1 + + // Tangent Maps + _TangentMap("TangentMap", 2D) = "bump" {} + _TangentMapOS("TangentMapOS", 2D) = "white" {} + _Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0 + _AnisotropyMap("AnisotropyMap", 2D) = "white" {} + + // Diffusion Profile + [HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0 + [HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0) + [HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0 + _SubsurfaceMask("Subsurface Radius", Range(0.0, 1.0)) = 1.0 + _SubsurfaceMaskMap("Subsurface Radius Map", 2D) = "white" {} + _TransmissionMask("Transmission Mask", Range(0.0, 1.0)) = 1.0 + _Thickness("Thickness", Range(0.0, 1.0)) = 1.0 + _ThicknessMap("Thickness Map", 2D) = "white" {} + _ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0) + + // Iridescence + _IridescenceThickness("Iridescence Thickness", Range(0.0, 1.0)) = 1.0 + _IridescenceThicknessMap("Iridescence Thickness Map", 2D) = "white" {} + _IridescenceThicknessRemap("Iridescence Thickness Remap", Vector) = (0, 1, 0, 0) + _IridescenceMask("Iridescence Mask", Range(0.0, 1.0)) = 1.0 + _IridescenceMaskMap("Iridescence Mask Map", 2D) = "white" {} + + // Coat + _CoatMask("Coat Mask", Range(0.0, 1.0)) = 0.0 + _CoatMaskMap("CoatMaskMap", 2D) = "white" {} + + // Specular + [ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0 + _SpecularColor("SpecularColor", Color) = (1, 1, 1, 1) + _SpecularColorMap("SpecularColorMap", 2D) = "white" {} + + // Following options are for the GUI inspector and different from the input parameters above + // These option below will cause different compilation flag. + [Enum(Off, 0, From Ambient Occlusion, 1, From Bent Normals, 2)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1 + + // Emissive + [HDR] _EmissiveColor("EmissiveColor", Color) = (0, 0, 0) + // Used only to serialize the LDR and HDR emissive color in the material UI, + // in the shader only the _EmissiveColor should be used + [HideInInspector] _EmissiveColorLDR("EmissiveColor LDR", Color) = (0, 0, 0) + _EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} + [ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0 + [HideInInspector] _EmissiveIntensityUnit("Emissive Mode", Int) = 0 + [ToggleUI] _UseEmissiveIntensity("Use Emissive Intensity", Int) = 0 + _EmissiveIntensity("Emissive Intensity", Float) = 1 + _EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0 + + // Distortion + _DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} + [ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0 + [ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0 + [Enum(Add, 0, Multiply, 1, Replace, 2)] _DistortionBlendMode("Distortion Blend Mode", Int) = 0 + [HideInInspector] _DistortionSrcBlend("Distortion Blend Src", Int) = 0 + [HideInInspector] _DistortionDstBlend("Distortion Blend Dst", Int) = 0 + [HideInInspector] _DistortionBlurSrcBlend("Distortion Blur Blend Src", Int) = 0 + [HideInInspector] _DistortionBlurDstBlend("Distortion Blur Blend Dst", Int) = 0 + [HideInInspector] _DistortionBlurBlendMode("Distortion Blur Blend Mode", Int) = 0 + _DistortionScale("Distortion Scale", Float) = 1 + _DistortionVectorScale("Distortion Vector Scale", Float) = 2 + _DistortionVectorBias("Distortion Vector Bias", Float) = -1 + _DistortionBlurScale("Distortion Blur Scale", Float) = 1 + _DistortionBlurRemapMin("DistortionBlurRemapMin", Float) = 0.0 + _DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0 + + // Alpha and Transparency + [ToggleUI] _UseShadowThreshold("_UseShadowThreshold", Float) = 0.0 + [ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 + _AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + _AlphaCutoffShadow("_AlphaCutoffShadow", Range(0.0, 1.0)) = 0.5 + _AlphaCutoffPrepass("_AlphaCutoffPrepass", Range(0.0, 1.0)) = 0.5 + _AlphaCutoffPostpass("_AlphaCutoffPostpass", Range(0.0, 1.0)) = 0.5 + [ToggleUI] _TransparentDepthPrepassEnable("_TransparentDepthPrepassEnable", Float) = 0.0 + [ToggleUI] _TransparentBackfaceEnable("_TransparentBackfaceEnable", Float) = 0.0 + [ToggleUI] _TransparentDepthPostpassEnable("_TransparentDepthPostpassEnable", Float) = 0.0 + _TransparentSortPriority("_TransparentSortPriority", Float) = 0 + + // Transparency + [Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0 + [Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0 + _Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.0 + _ThicknessMultiplier("Thickness Multiplier", Float) = 1.0 + _TransmittanceColor("Transmittance Color", Color) = (1.0, 1.0, 1.0) + _TransmittanceColorMap("TransmittanceColorMap", 2D) = "white" {} + _ATDistance("Transmittance Absorption Distance", Float) = 1.0 + [ToggleUI] _TransparentWritingMotionVec("_TransparentWritingMotionVec", Float) = 0.0 + + // Stencil state + // Forward + [HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting + [HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 3 // StencilMask.Lighting + // GBuffer + [HideInInspector] _StencilRefGBuffer("_StencilRefGBuffer", Int) = 2 // StencilLightingUsage.RegularLighting + [HideInInspector] _StencilWriteMaskGBuffer("_StencilWriteMaskGBuffer", Int) = 3 // StencilMask.Lighting + // Depth prepass + [HideInInspector] _StencilRefDepth("_StencilRefDepth", Int) = 0 // Nothing + [HideInInspector] _StencilWriteMaskDepth("_StencilWriteMaskDepth", Int) = 32 // DoesntReceiveSSR + // Motion vector pass + [HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilBitMask.ObjectMotionVectors + [HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilBitMask.ObjectMotionVectors + // Distortion vector pass + [HideInInspector] _StencilRefDistortionVec("_StencilRefDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors + [HideInInspector] _StencilWriteMaskDistortionVec("_StencilWriteMaskDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors + + // Blending state + [HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 + [HideInInspector] _BlendMode("__blendmode", Float) = 0.0 + [HideInInspector] _SrcBlend("__src", Float) = 1.0 + [HideInInspector] _DstBlend("__dst", Float) = 0.0 + [HideInInspector] _AlphaSrcBlend("__alphaSrc", Float) = 1.0 + [HideInInspector] _AlphaDstBlend("__alphaDst", Float) = 0.0 + [HideInInspector][ToggleUI] _ZWrite("__zw", Float) = 1.0 + [HideInInspector][ToggleUI] _TransparentZWrite("_TransparentZWrite", Float) = 0.0 + [HideInInspector] _CullModeForward("__cullmodeForward", Float) = 2.0 // This mode is dedicated to Forward to correctly handle backface then front face rendering thin transparent + [HideInInspector] _TransparentCullMode("_TransparentCullMode", Int) = 2 // Back culling by default + [HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal + [HideInInspector] _ZTestModeDistortion("_ZTestModeDistortion", Int) = 8 + [HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4 + [Enum(UnityEngine.Rendering.CompareFunction)] _ZTestTransparent("Transparent ZTest", Int) = 4 // Less equal + + [ToggleUI] _EnableFogOnTransparent("Enable Fog", Float) = 1.0 + [ToggleUI] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1.0 + + [ToggleUI] _DoubleSidedEnable("Double sided enable", Float) = 0.0 + [Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1 + [HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0) + + [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase("UV Set for base", Float) = 0 + [Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMapping("Mapping space", Float) = 0.0 + _TexWorldScale("Scale to apply on world coordinate", Float) = 1.0 + [HideInInspector] _InvTilingScale("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 + [HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0) + [Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 + + // Following enum should be material feature flags (i.e bitfield), however due to Gbuffer encoding constrain many combination exclude each other + // so we use this enum as "material ID" which can be interpreted as preset of bitfield of material feature + // The only material feature flag that can be added in all cases is clear coat + [Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, Iridescence, 3, Specular Color, 4, Translucent, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.Standard + + [ToggleUI] _EnableGeometricSpecularAA("EnableGeometricSpecularAA", Float) = 0.0 + _SpecularAAScreenSpaceVariance("SpecularAAScreenSpaceVariance", Range(0.0, 1.0)) = 0.1 + _SpecularAAThreshold("SpecularAAThreshold", Range(0.0, 1.0)) = 0.2 + + _PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5 + _PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15 + _PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5 + _PPDPrimitiveLength("Primitive length for POM", Float) = 1 + _PPDPrimitiveWidth("Primitive width for POM", Float) = 1 + [HideInInspector] _InvPrimScale("Inverse primitive scale for non-planar POM", Vector) = (1, 1, 0, 0) + + [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0 + [HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0) + [ToggleUI] _LinkDetailsWithBase("LinkDetailsWithBase", Float) = 1.0 + + [Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 + [Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVEmissive("UV Set for emissive", Float) = 0 + _TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0 + [HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0) + + // Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" + // value that exist to identify if the GI emission need to be enabled. + // In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. + // TODO: Fix the code in legacy unity so we can customize the beahvior for GI + _EmissionColor("Color", Color) = (1, 1, 1) + + // HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes. + ////////// _MainTex("BaseMap", 2D) = "white" {} + _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + + [ToggleUI] _SupportDecals("Support Decals", Float) = 1.0 + [ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0 + [ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0 + ////////////////////////////////////////////////////////////////////////////// + //////////////////// End of HDRP material default values. //////////////////// + ////////////////////////////////////////////////////////////////////////////// + + [HideInInspector] _ToonMaterialVersion ("Toon Material Version", Integer ) = 0 + + // Tessellation-specific properties + // Tessellation-specific Properties for Unity Toon Shader Tessellation + // These properties are only present in the tessellation shader + + // Tessellation specific + [Enum(None, 0, Phong, 1)] _TessellationMode("Tessellation mode", Float) = 0 + _TessellationFactor("Tessellation Factor", Range(0.0, 64.0)) = 4.0 + _TessellationFactorMinDistance("Tessellation start fading distance", Float) = 20.0 + _TessellationFactorMaxDistance("Tessellation end fading distance", Float) = 50.0 + _TessellationFactorTriangleSize("Tessellation triangle size", Float) = 100.0 + _TessellationShapeFactor("Tessellation shape factor", Range(0.0, 1.0)) = 0.75 // Only use with Phong + _TessellationBackFaceCullEpsilon("Tessellation back face epsilon", Range(-1.0, 0.0)) = -0.25 + + // Legacy material tessellation values + //Tessellation + _TessEdgeLength("DX11 Tess : Edge length", Range(2, 50)) = 5 + _TessPhongStrength("DX11 Tess : Phong Strength", Range(0, 1)) = 0.5 + _TessExtrusionAmount("DX11 Tess : Extrusion Amount", Range(-0.005, 0.005)) = 0.0 + } + + + HLSLINCLUDE + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #define DISABLE_RP_SHADERS + //------------------------------------------------------------------------------------- + // Variant + //------------------------------------------------------------------------------------- +#ifndef DISABLE_RP_SHADERS + // HDRP Variant + #pragma shader_feature_local _ALPHATEST_ON + #pragma shader_feature_local _DEPTHOFFSET_ON + #pragma shader_feature_local _DOUBLESIDED_ON + #pragma shader_feature_local _ _TESSELLATION_DISPLACEMENT _PIXEL_DISPLACEMENT + #pragma shader_feature_local _VERTEX_DISPLACEMENT_LOCK_OBJECT_SCALE + #pragma shader_feature_local _DISPLACEMENT_LOCK_TILING_SCALE + #pragma shader_feature_local _PIXEL_DISPLACEMENT_LOCK_OBJECT_SCALE + #pragma shader_feature_local _TESSELLATION_PHONG + #pragma shader_feature_local _ _REFRACTION_PLANE _REFRACTION_SPHERE _REFRACTION_THIN + + #pragma shader_feature_local _ _EMISSIVE_MAPPING_PLANAR _EMISSIVE_MAPPING_TRIPLANAR + #pragma shader_feature_local _ _MAPPING_PLANAR _MAPPING_TRIPLANAR + #pragma shader_feature_local _NORMALMAP_TANGENT_SPACE + #pragma shader_feature_local _ _REQUIRE_UV2 _REQUIRE_UV3 + + #pragma shader_feature_local _NORMALMAP + #pragma shader_feature_local _MASKMAP + #pragma shader_feature_local _BENTNORMALMAP + #pragma shader_feature_local _EMISSIVE_COLOR_MAP + + // _ENABLESPECULAROCCLUSION keyword is obsolete but keep here for compatibility. Do not used + // _ENABLESPECULAROCCLUSION and _SPECULAR_OCCLUSION_X can't exist at the same time (the new _SPECULAR_OCCLUSION replace it) + // When _ENABLESPECULAROCCLUSION is found we define _SPECULAR_OCCLUSION_X so new code to work + #pragma shader_feature_local _ENABLESPECULAROCCLUSION + #pragma shader_feature_local _ _SPECULAR_OCCLUSION_NONE _SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP + #ifdef _ENABLESPECULAROCCLUSION + #define _SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP + #endif + + #pragma shader_feature_local _HEIGHTMAP + #pragma shader_feature_local _TANGENTMAP + #pragma shader_feature_local _ANISOTROPYMAP + #pragma shader_feature_local _DETAIL_MAP + #pragma shader_feature_local _SUBSURFACE_MASK_MAP + #pragma shader_feature_local _THICKNESSMAP + #pragma shader_feature_local _IRIDESCENCE_THICKNESSMAP + #pragma shader_feature_local _SPECULARCOLORMAP + #pragma shader_feature_local _TRANSMITTANCECOLORMAP + + #pragma shader_feature_local _DISABLE_DECALS + #pragma shader_feature_local _DISABLE_SSR + #pragma shader_feature_local _ADD_PRECOMPUTED_VELOCITY + #pragma shader_feature_local _ENABLE_GEOMETRIC_SPECULAR_AA + + // Keyword for transparent + #pragma shader_feature _SURFACE_TYPE_TRANSPARENT + #pragma shader_feature_local _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY + #pragma shader_feature_local _BLENDMODE_PRESERVE_SPECULAR_LIGHTING + #pragma shader_feature_local _ENABLE_FOG_ON_TRANSPARENT + #pragma shader_feature_local _TRANSPARENT_WRITES_MOTION_VEC + + // MaterialFeature are used as shader feature to allow compiler to optimize properly + #pragma shader_feature_local _MATERIAL_FEATURE_SUBSURFACE_SCATTERING + #pragma shader_feature_local _MATERIAL_FEATURE_TRANSMISSION + #pragma shader_feature_local _MATERIAL_FEATURE_ANISOTROPY + #pragma shader_feature_local _MATERIAL_FEATURE_CLEAR_COAT + #pragma shader_feature_local _MATERIAL_FEATURE_IRIDESCENCE + #pragma shader_feature_local _MATERIAL_FEATURE_SPECULAR_COLOR + + + // enable dithering LOD crossfade + #pragma multi_compile _ LOD_FADE_CROSSFADE + + //enable GPU instancing support + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + // enable debug shado + // #pragma multi_compile _ UTS_DEBUG_SELFSHADOW + // #pragma multi_compile _ UTS_DEBUG_SHADOWMAP + // #pragma multi_compile _ UTS_DEBUG_SHADOWMAP_NO_OUTLINE + // end of HDRP Variants +#endif //#ifndef DISABLE_RP_SHADERS + + + //------------------------------------------------------------------------------------- + // Define + //------------------------------------------------------------------------------------- + #define TESSELLATION_ON + // This shader support vertex modification + #define HAVE_VERTEX_MODIFICATION + #define HAVE_TESSELLATION_MODIFICATION + + // If we use subsurface scattering, enable output split lighting (for forward pass) + #if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) && !defined(_SURFACE_TYPE_TRANSPARENT) + #define OUTPUT_SPLIT_LIGHTING + #endif + + #if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT) + #define _WRITE_TRANSPARENT_MOTION_VECTOR + #endif + + ENDHLSL + + // *************************** // + // ****** HDRP Subshader ***** // + // *************************** // + SubShader + { + PackageRequirements + { + "com.unity.render-pipelines.high-definition": "10.5.0" + } + // This tags allow to use the shader replacement features + Tags{ "RenderPipeline"="HDRenderPipeline" } + + Pass + { + Name "SceneSelectionPass" + Tags { "LightMode" = "SceneSelectionPass" } + + Cull Off + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // Note: Require _ObjectId and _PassValue variables + + // We reuse depth prepass for the scene selection, allow to handle alpha correctly as well as tessellation and vertex animation + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define SCENESELECTIONPASS // This will drive the output of the scene selection shader + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + #pragma editor_sync_compilation + + ENDHLSL + } + + // Caution: The outline selection in the editor use the vertex shader/hull/domain shader of the first pass declare. So it should not bethe meta pass. + Pass + { + Name "GBuffer" + Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index + + Cull[_CullMode] + ZTest[_ZTestGBuffer] + + Stencil + { + WriteMask[_StencilWriteMaskGBuffer] + Ref[_StencilRefGBuffer] + Comp Always + Pass Replace + } + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma multi_compile _ DOTS_INSTANCING_ON + + + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + #pragma multi_compile _ LIGHT_LAYERS + + #ifndef DEBUG_DISPLAY + // When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer + // Don't do it with debug display mode as it is possible there is no depth prepass in this case + #define SHADERPASS_GBUFFER_BYPASS_ALPHA_TEST + #endif + + #define SHADERPASS SHADERPASS_GBUFFER + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + // #include "MaterialGBufferMacrosUTS.hlsl" // must be above lit.hlsl + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + // #include "EncodeIntoGBufferUTS.hlsl" // must be bellow lit.hlsl + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl" + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + + // Extracts information for lightmapping, GI (emission, albedo, ...) + // This pass it not used during regular rendering. + Pass + { + Name "META" + Tags{ "LightMode" = "META" } + + Cull Off + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // Lightmap memo + // DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light, + // both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON. + + #define SHADERPASS SHADERPASS_LIGHT_TRANSPORT + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "ShadowCaster" + Tags{ "LightMode" = "ShadowCaster" } + + Cull[_CullMode] + + ZClip [_ZClip] + ZWrite On + ZTest LEqual + + ColorMask 0 + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + + #define SHADERPASS SHADERPASS_SHADOWS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + Name "DepthForwardOnly" + Tags{ "LightMode" = "DepthForwardOnly" } + + Cull[_CullMode] + + // To be able to tag stencil with disableSSR information for forward + Stencil + { + WriteMask [_StencilWriteMaskDepth] + Ref [_StencilRefDepth] + Comp Always + Pass Replace + } + + ZWrite On + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // In deferred, depth only pass don't output anything. + // In forward it output the normal buffer + #pragma multi_compile _ WRITE_NORMAL_BUFFER + #pragma multi_compile _ WRITE_MSAA_DEPTH + + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #else + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #endif + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + Name "MotionVectors" + Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity) + + // If velocity pass (motion vectors) is enabled we tag the stencil so it don't perform CameraMotionVelocity + Stencil + { + WriteMask [_StencilWriteMaskMV] + Ref [_StencilRefMV] + Comp Always + Pass Replace + } + + Cull[_CullMode] + + ZWrite On + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #pragma multi_compile _ WRITE_NORMAL_BUFFER + #pragma multi_compile _ WRITE_MSAA_DEPTH + + #define SHADERPASS SHADERPASS_MOTION_VECTORS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #else + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitMotionVectorPass.hlsl" + #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassMotionVectors.hlsl" + + // TODO: Tesselation can't work with velocity for now... + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + Name "DistortionVectors" + Tags { "LightMode" = "DistortionVectors" } // This will be only for transparent object based on the RenderQueue index + + Stencil + { + WriteMask [_StencilRefDistortionVec] + Ref [_StencilRefDistortionVec] + Comp Always + Pass Replace + } + + Blend [_DistortionSrcBlend] [_DistortionDstBlend], [_DistortionBlurSrcBlend] [_DistortionBlurDstBlend] + BlendOp Add, [_DistortionBlurBlendOp] + ZTest [_ZTestModeDistortion] + ZWrite off + Cull [_CullMode] + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DISTORTION + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDistortionPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDistortion.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + Name "TransparentDepthPrepass" + Tags{ "LightMode" = "TransparentDepthPrepass" } + + Cull[_CullMode] + ZWrite On + ColorMask 0 + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define CUTOFF_TRANSPARENT_DEPTH_PREPASS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + // Caution: Order is important: TransparentBackface, then Forward/ForwardOnly + Pass + { + Name "TransparentBackface" + Tags { "LightMode" = "TransparentBackface" } + + Blend [_SrcBlend] [_DstBlend], [_AlphaSrcBlend] [_AlphaDstBlend] + ZWrite [_ZWrite] + Cull Front + ColorMask [_ColorMaskTransparentVel] 1 + ZTest [_ZTestTransparent] + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + + // Supported shadow modes per light type + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH + #if UNITY_VERSION >= 60000000 + // fix for https://github.com/Unity-Technologies/com.unity.toonshader/issues/391 + #ifdef SHADOW_MEDIUM + #ifndef PUNCTUAL_SHADOW_MEDIUM + #define PUNCTUAL_SHADOW_MEDIUM + #endif + #ifndef DIRECTIONAL_SHADOW_MEDIUM + #define DIRECTIONAL_SHADOW_MEDIUM + #endif + #endif + + #ifdef SHADOW_HIGH + #ifndef PUNCTUAL_SHADOW_HIGH + #define PUNCTUAL_SHADOW_HIGH + #endif + #ifndef DIRECTIONAL_SHADOW_HIGH + #define DIRECTIONAL_SHADOW_HIGH + #endif + #endif + #endif + #define USE_CLUSTERED_LIGHTLIST // There is not FPTL lighting when using transparent + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + + Name "ForwardOnly" + Tags { "LightMode" = "ForwardOnly" } + + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" +// #pragma multi_compile _ UTS_DEBUG_SHADOWMAP_BINALIZATION + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON + // Supported shadow modes per light type + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH + #if UNITY_VERSION >= 60000000 + // fix for https://github.com/Unity-Technologies/com.unity.toonshader/issues/391 + #ifdef SHADOW_MEDIUM + #ifndef PUNCTUAL_SHADOW_MEDIUM + #define PUNCTUAL_SHADOW_MEDIUM + #endif + #ifndef DIRECTIONAL_SHADOW_MEDIUM + #define DIRECTIONAL_SHADOW_MEDIUM + #endif + #endif + + #ifdef SHADOW_HIGH + #ifndef PUNCTUAL_SHADOW_HIGH + #define PUNCTUAL_SHADOW_HIGH + #endif + #ifndef DIRECTIONAL_SHADOW_HIGH + #define DIRECTIONAL_SHADOW_HIGH + #endif + #endif + #endif + #define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER +// #pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + // In case of opaque we don't want to perform the alpha test, it is done in depth prepass and we use depth equal for ztest (setup from UI) + // Don't do it with debug display mode as it is possible there is no depth prepass in this case + #if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(DEBUG_DISPLAY) + #define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST + #endif + #pragma shader_feature_local _ _SHADINGGRADEMAP + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_ON + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + // controlling mask rendering + #pragma shader_feature _ _IS_CLIPPING_MATTE + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" +#ifdef UNITY_SHADER_VARIABLES_INCLUDED + #include "../../HDRP/Shaders/UtsLightLoop.hlsl" + #include "../../HDRP/Shaders/ShaderPassForwardUTS.hlsl" +#endif + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + Name "TransparentDepthPostpass" + Tags { "LightMode" = "TransparentDepthPostpass" } + + Cull[_CullMode] + ZWrite On + ColorMask 0 + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define CUTOFF_TRANSPARENT_DEPTH_POSTPASS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Tags{ + "RenderType" = "Opaque" + } + Pass{ + Name "Outline" + Tags { + "LightMode" = "SRPDefaultUnlit" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + #define SHADOW_LOW + #define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER + + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO _IS_OUTLINE_CLIPPING_YES + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + #pragma shader_feature _ _IS_CLIPPING_MATTE + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + +#ifdef UNITY_SHADER_VARIABLES_INCLUDED + #include "../../HDRP/Shaders/HDRPToonHead.hlsl" + #include "../../HDRP/Shaders/HDRPToonOutline.hlsl" +#endif + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + } + // *************************** // + // ****** URP Subshader ***** // + // *************************** // + SubShader + { + PackageRequirements + { + "com.unity.render-pipelines.universal": "10.5.0" + } + Tags { + "RenderType"="Opaque" + "RenderPipeline" = "UniversalPipeline" + } + +//ToonCoreStart + Pass { + Name "ForwardLit" + Tags{"LightMode" = "UniversalForward"} + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 2.0 + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex vert + #pragma fragment frag + +#ifndef DISABLE_RP_SHADERS + // ------------------------------------- + // urp Material Keywords + // ------------------------------------- + #pragma shader_feature_local _ALPHAPREMULTIPLY_ON + #pragma shader_feature_local _EMISSION + #pragma shader_feature_local _METALLICSPECGLOSSMAP + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A +// #pragma shader_feature _OCCLUSIONMAP + + #pragma shader_feature_local _SPECULARHIGHLIGHTS_OFF + #pragma shader_feature_local _ENVIRONMENTREFLECTIONS_OFF + #pragma shader_feature_local _SPECULAR_SETUP + #pragma shader_feature_local _RECEIVE_SHADOWS_OFF +#endif + // ------------------------------------- + // Lightweight Pipeline keywords + #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN + #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS + #pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS + #pragma multi_compile _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH + #pragma multi_compile _ _FORWARD_PLUS + #if (!defined(UNITY_COMPILER_DXC) && (defined(UNITY_PLATFORM_OSX) || defined(UNITY_PLATFORM_IOS))) || defined(SHADER_API_PS5) + + #if defined(SHADER_API_PS5) || defined(SHADER_API_METAL) + + #define SUPPORTS_FOVEATED_RENDERING_NON_UNIFORM_RASTER 1 + + // On Metal Foveated Rendering is currently not supported with DXC + #pragma warning (disable : 3568) // unknown pragma ignored + + #pragma never_use_dxc metal + #pragma dynamic_branch _ _FOVEATED_RENDERING_NON_UNIFORM_RASTER + + #pragma warning (default : 3568) // restore unknown pragma ignored + + #endif + + #endif + #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 + #pragma multi_compile_fragment _ _LIGHT_LAYERS + + #pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE + // ------------------------------------- + // Unity defined keywords + #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING + #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile_fog + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #define _IS_PASS_FWDBASE + // DoubleShadeWithFeather and ShadingGradeMap use different fragment shader. + #pragma shader_feature_local _ _SHADINGGRADEMAP + + + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_ON + + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" +#ifdef UNIVERSAL_PIPELINE_CORE_INCLUDED + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonHead.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonBody.hlsl" +#endif + ENDHLSL + + } + + Pass { + Name "Outline" + Tags { + "LightMode" = "SRPDefaultUnlit" + } + Cull [_SRPDefaultUnlitColMode] + ColorMask [_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 2.0 + #pragma vertex vert + #pragma fragment frag + + + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO _IS_OUTLINE_CLIPPING_YES + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Outline is implemented in UniversalToonOutline.hlsl. + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + +#ifdef UNIVERSAL_PIPELINE_CORE_INCLUDED + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonHead.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonOutline.hlsl" +#endif + ENDHLSL + } + + Pass + { + Name "Universal2D" + Tags + { + "LightMode" = "Universal2D" + } + + // ------------------------------------- + // Render State Commands + Blend[_SrcBlend][_DstBlend] + ZWrite[_ZWrite] + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 + + // ------------------------------------- + // Shader Stages + #pragma vertex vert + #pragma fragment frag + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON + + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + + // ------------------------------------- + // Includes + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "../../UniversalRP/Shaders/UniversalBasic2D.hlsl" + ENDHLSL + } + + Pass + { + Name "ShadowCaster" + Tags{"LightMode" = "ShadowCaster"} + + ZWrite On + ZTest LEqual + Cull[_CullMode] + + HLSLPROGRAM + #pragma target 2.0 + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + // ------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + #pragma vertex ShadowPassVertex + #pragma fragment ShadowPassFragment + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl" + ENDHLSL + } + + Pass + { + Name "DepthOnly" + Tags{"LightMode" = "DepthOnly"} + + ZWrite On + ColorMask 0 + Cull[_CullMode] + + HLSLPROGRAM + #pragma target 2.0 + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex DepthOnlyVertex + #pragma fragment DepthOnlyFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl" + ENDHLSL + } + // This pass is used when drawing to a _CameraNormalsTexture texture + Pass + { + Name "DepthNormals" + Tags{"LightMode" = "DepthNormals"} + + ZWrite On + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 + +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Version.hlsl" +#ifndef VERSION_GREATER_EQUAL +#define VERSION_GREATER_EQUAL(x, y) 1 +#endif +#if (VERSION_GREATER_EQUAL(10, 0)) + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex DepthNormalsVertex + #pragma fragment DepthNormalsFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _PARALLAXMAP + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl" +#endif + ENDHLSL + } + +//ToonCoreEnd + } + + // ***************************** // + // ****** Legacy Subshader ***** // + // ***************************** // + + SubShader { + Tags { + "RenderType"="Opaque" + } + Pass { + Name "Outline" + Tags { + "LightMode"="ForwardBase" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #include "UnityCG.cginc" + //#pragma fragmentoption ARB_precision_hint_fastest + //#pragma multi_compile_shadowcaster + //#pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Unity Toon Shader 0.5.0 + #pragma multi_compile _ _DISABLE_OUTLINE + //The outline process goes to UTS_Outline.cginc. + #include "../../Legacy/Shaders/UCTS_Outline.cginc" + ENDCG + } +//ToonCoreStart + Pass { + Name "FORWARD" + Tags { + "LightMode"="ForwardBase" + } + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #define TESSELLATION_ON + #pragma target 5.0 + #pragma vertex tess_VertexInput + #pragma hull hs_VertexInput + #pragma domain ds_surf + #pragma fragment frag + + #ifdef TESSELLATION_ON + #include "../../Legacy/Shaders/UCTS_Tess.cginc" + #endif + //#define UNITY_PASS_FORWARDBASE + #include "UnityCG.cginc" + #include "AutoLight.cginc" + #include "Lighting.cginc" + #pragma multi_compile_fwdbase_fullshadows +// #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + #pragma target 5.0 + + #pragma multi_compile _IS_PASS_FWDBASE //[TODO-sin:2025-11-20] Check if this is used. + + #pragma shader_feature_local UTS_RP_BUILTIN + #include_with_pragmas "../../Shaders/BuiltIn/BuiltInToonMode.hlsl" + + ENDCG + } + Pass { + Name "Outline" + Tags { + "LightMode"="ForwardBase" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #define TESSELLATION_ON + #pragma target 5.0 + #pragma vertex tess_VertexInput + #pragma hull hs_VertexInput + #pragma domain ds_surf + #pragma fragment frag + #ifdef TESSELLATION_ON + #include "../../Legacy/Shaders/UCTS_Tess.cginc" + #endif + #include "UnityCG.cginc" + //#pragma fragmentoption ARB_precision_hint_fastest + //#pragma multi_compile_shadowcaster + //#pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Unity Toon Shader 0.5.0 + #pragma multi_compile _ _DISABLE_OUTLINE + //The outline process goes to UTS_Outline.cginc. + #include "../../Legacy/Shaders/UCTS_Outline_Tess.cginc" + ENDCG + } + Pass { + Name "FORWARD_DELTA" + Tags { + "LightMode"="ForwardAdd" + } + + Blend One One + Cull[_CullMode] + + + CGPROGRAM + #define TESSELLATION_ON + #pragma target 5.0 + #pragma vertex tess_VertexInput + #pragma hull hs_VertexInput + #pragma domain ds_surf + #pragma fragment frag + + #ifdef TESSELLATION_ON + #include "../../Legacy/Shaders/UCTS_Tess.cginc" + #endif + //#define UNITY_PASS_FORWARDADD + #include "UnityCG.cginc" + #include "AutoLight.cginc" + #include "Lighting.cginc" + //for Unity2018.x + #pragma multi_compile_fwdadd_fullshadows +// #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + // DoubleShadeWithFeather and ShadingGradeMap use different fragment shader. + #pragma shader_feature_local _ _SHADINGGRADEMAP + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_ON + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + //v.2.0.4 + + #pragma multi_compile _IS_PASS_FWDDELTA //[TODO-sin:2025-11-20] Check if this is used. + + #pragma shader_feature_local UTS_RP_BUILTIN + #include_with_pragmas "../../Shaders/BuiltIn/BuiltInToonMode.hlsl" + + ENDCG + } + Pass { + Name "ShadowCaster" + Tags { + "LightMode"="ShadowCaster" + } + Offset 1, 1 + Cull Off + + CGPROGRAM + #define TESSELLATION_ON + #pragma target 5.0 + #pragma vertex tess_VertexInput + #pragma hull hs_VertexInput + #pragma domain ds_surf + #pragma fragment frag + #ifdef TESSELLATION_ON + #include "../../Legacy/Shaders/UCTS_Tess.cginc" + #endif + //#define UNITY_PASS_SHADOWCASTER + #include "UnityCG.cginc" + #include "Lighting.cginc" + #pragma fragmentoption ARB_precision_hint_fastest + #pragma multi_compile_shadowcaster +// #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + //v.2.0.4 + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + // Unity Toon Shader 0.5.0 + #pragma multi_compile _ _DISABLE_OUTLINE + #include "../../Legacy/Shaders/UCTS_ShadowCaster_Tess.cginc" + ENDCG + + } +//ToonCoreEnd + } + + CustomEditor "UnityEditor.Rendering.Toon.UTS3GUI" +} diff --git a/BJH/Assets/BJH/3dtest/Runtime/Integrated/Shaders/UnityToonTessellation.shader.meta b/BJH/Assets/BJH/3dtest/Runtime/Integrated/Shaders/UnityToonTessellation.shader.meta new file mode 100644 index 0000000..0f9e931 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Integrated/Shaders/UnityToonTessellation.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e4468eb8a8320f7488ddbb0e591f9fbc +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy.meta b/BJH/Assets/BJH/3dtest/Runtime/Legacy.meta new file mode 100644 index 0000000..2a56d11 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 21182f02cedb2c14eb0429bcfdfb3658 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders.meta b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders.meta new file mode 100644 index 0000000..91142b5 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3c4b433ce164b3945a1d418aeb3ff82b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_DoubleShadeWithFeather.cginc b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_DoubleShadeWithFeather.cginc new file mode 100644 index 0000000..6a5c93d --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_DoubleShadeWithFeather.cginc @@ -0,0 +1,364 @@ +//Unity Toon Shader/Legacy +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Intengrated) +// ※Tessellation support +// The corresponding code was adapted from Nora's https://github.com/Stereoarts/UnityChanToonShaderVer2_Tess. +// + +#ifndef TESSELLATION_ON +struct VertexInput { + float4 vertex : POSITION; + float3 normal : NORMAL; + float4 tangent : TANGENT; + float2 texcoord0 : TEXCOORD0; + + UNITY_VERTEX_INPUT_INSTANCE_ID +}; +#endif +struct VertexOutput { + float4 pos : SV_POSITION; + float2 uv0 : TEXCOORD0; + float4 posWorld : TEXCOORD1; + float3 normalDir : TEXCOORD2; + float3 tangentDir : TEXCOORD3; + float3 bitangentDir : TEXCOORD4; + //v.2.0.7 + float mirrorFlag : TEXCOORD5; + LIGHTING_COORDS(6,7) + UNITY_FOG_COORDS(8) + // + UNITY_VERTEX_INPUT_INSTANCE_ID + UNITY_VERTEX_OUTPUT_STEREO +}; + +//--------------------------------------------------------------------------------------------------------------------- + +#include "UCTS_Light.cginc" +#include "UCTS_Input.cginc" + + //function to rotate the UV: RotateUV() + //float2 rotatedUV = RotateUV(i.uv0, (_angular_Verocity*3.141592654), float2(0.5, 0.5), _Time.g); + float2 RotateUV(float2 _uv, float _radian, float2 _piv, float _time) + { + float RotateUV_ang = _radian; + float RotateUV_cos = cos(_time*RotateUV_ang); + float RotateUV_sin = sin(_time*RotateUV_ang); + return (mul(_uv - _piv, float2x2( RotateUV_cos, -RotateUV_sin, RotateUV_sin, RotateUV_cos)) + _piv); + } + // + fixed3 DecodeLightProbe( fixed3 N ){ + return ShadeSH9(float4(N,1)); + } + + + VertexOutput vert (VertexInput v) { + VertexOutput o = (VertexOutput)0; + UNITY_SETUP_INSTANCE_ID(v); + UNITY_TRANSFER_INSTANCE_ID(v, o); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); + + o.uv0 = v.texcoord0; + o.normalDir = UnityObjectToWorldNormal(v.normal); + o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz ); + o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w); + o.posWorld = mul(unity_ObjectToWorld, v.vertex); + float3 lightColor = _LightColor0.rgb; + o.pos = UnityObjectToClipPos( v.vertex ); + //v.2.0.7 Detection of the inside the mirror (right or left-handed) o.mirrorFlag = -1 then "inside the mirror". + float3 crossFwd = cross(UNITY_MATRIX_V[0], UNITY_MATRIX_V[1]); + o.mirrorFlag = dot(crossFwd, UNITY_MATRIX_V[2].xyz) < 0 ? 1 : -1; + // + UNITY_TRANSFER_FOG(o,o.pos); + TRANSFER_VERTEX_TO_FRAGMENT(o) + return o; + } + +//Tessellation ON +#ifdef TESSELLATION_ON +#ifdef UNITY_CAN_COMPILE_TESSELLATION + // tessellation domain shader + [UNITY_domain("tri")] + VertexOutput ds_surf(UnityTessellationFactors tessFactors, const OutputPatch vi, float3 bary : SV_DomainLocation) + { + VertexInput v = _ds_VertexInput(tessFactors, vi, bary); + return vert(v); + } +#endif // UNITY_CAN_COMPILE_TESSELLATION +#endif // TESSELLATION_ON + float4 frag(VertexOutput i, fixed facing : VFACE) : SV_TARGET { + UNITY_SETUP_INSTANCE_ID(i); + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i); + + i.normalDir = normalize(i.normalDir); + float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir); + float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz); + float2 Set_UV0 = i.uv0; + + //v.2.0.6 + float3 _NormalMap_var = UnpackScaleNormal(SAMPLE_TEXTURE2D(_NormalMap,sampler_MainTex, TRANSFORM_TEX(Set_UV0, _NormalMap)), _BumpScale); + float3 normalLocal = _NormalMap_var.rgb; + float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals + float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)); + + +//v.2.0.4 +#ifdef _IS_CLIPPING_MODE +//DoubleShadeWithFeather_Clipping + float4 _ClippingMask_var = tex2D(_ClippingMask, TRANSFORM_TEX(Set_UV0, _MainTex)); + float Set_Clipping = saturate((lerp( _ClippingMask_var.r, (1.0 - _ClippingMask_var.r), _Inverse_Clipping )+_Clipping_Level)); + clip(Set_Clipping - 0.5); +#elif _IS_CLIPPING_TRANSMODE +//DoubleShadeWithFeather_TransClipping + + float4 _ClippingMask_var = tex2D(_ClippingMask, TRANSFORM_TEX(Set_UV0, _MainTex)); + float Set_MainTexAlpha = _MainTex_var.a; + float _IsBaseMapAlphaAsClippingMask_var = lerp( _ClippingMask_var.r, Set_MainTexAlpha, _IsBaseMapAlphaAsClippingMask ); + float _Inverse_Clipping_var = lerp( _IsBaseMapAlphaAsClippingMask_var, (1.0 - _IsBaseMapAlphaAsClippingMask_var), _Inverse_Clipping ); + float Set_Clipping = saturate((_Inverse_Clipping_var+_Clipping_Level)); + clip(Set_Clipping - 0.5); + +#elif _IS_CLIPPING_OFF +//DoubleShadeWithFeather +#endif + + UTS_LIGHT_ATTENUATION(attenuation, i, i.posWorld.xyz); + +//v.2.0.4 +#ifdef _IS_PASS_FWDBASE + + float3 defaultLightDirection = normalize(UNITY_MATRIX_V[2].xyz + UNITY_MATRIX_V[1].xyz); + //v.2.0.5 + float3 defaultLightColor = saturate(max(half3(0.05,0.05,0.05)*_Unlit_Intensity,max(ShadeSH9(half4(0.0, 0.0, 0.0, 1.0)),ShadeSH9(half4(0.0, -1.0, 0.0, 1.0)).rgb)*_Unlit_Intensity)); + float3 customLightDirection = normalize(mul( unity_ObjectToWorld, float4(((float3(1.0,0.0,0.0)*_Offset_X_Axis_BLD*10)+(float3(0.0,1.0,0.0)*_Offset_Y_Axis_BLD*10)+(float3(0.0,0.0,-1.0)*lerp(-1.0,1.0,_Inverse_Z_Axis_BLD))),0)).xyz); + float3 lightDirection = normalize(lerp(defaultLightDirection,_WorldSpaceLightPos0.xyz,any(_WorldSpaceLightPos0.xyz))); + lightDirection = lerp(lightDirection, customLightDirection, _Is_BLD); + //v.2.0.5: + float3 lightColor = lerp(max(defaultLightColor,_LightColor0.rgb),max(defaultLightColor,saturate(_LightColor0.rgb)),_Is_Filter_LightColor); +#elif _IS_PASS_FWDDELTA + float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w)); + //v.2.0.5: + float3 addPassLightColor = (0.5*dot(lerp( i.normalDir, normalDirection, _Is_NormalMapToBase ), lightDirection)+0.5) * _LightColor0.rgb * attenuation; + float pureIntencity = max(0.001,(0.299*_LightColor0.r + 0.587*_LightColor0.g + 0.114*_LightColor0.b)); + float3 lightColor = max(float3(0,0,0), lerp(addPassLightColor, lerp(float3(0,0,0),min(addPassLightColor,addPassLightColor/pureIntencity),_WorldSpaceLightPos0.w),_Is_Filter_LightColor)); +#endif +////// Lighting: + float3 halfDirection = normalize(viewDirection+lightDirection); + //v.2.0.5 + _Color = _BaseColor; + +#ifdef _IS_PASS_FWDBASE + float3 Set_LightColor = lightColor.rgb; + float3 Set_BaseColor = lerp( (_BaseColor.rgb*_MainTex_var.rgb), ((_BaseColor.rgb*_MainTex_var.rgb)*Set_LightColor), _Is_LightColor_Base ); + //v.2.0.5 + float4 _1st_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_1st_ShadeMap,sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)),_MainTex_var,_Use_BaseAs1st); + float3 Set_1st_ShadeColor = lerp( (_1st_ShadeColor.rgb*_1st_ShadeMap_var.rgb), ((_1st_ShadeColor.rgb*_1st_ShadeMap_var.rgb)*Set_LightColor), _Is_LightColor_1st_Shade ); + //v.2.0.5 + float4 _2nd_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_2nd_ShadeMap,sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)),_1st_ShadeMap_var,_Use_1stAs2nd); + float3 Set_2nd_ShadeColor = lerp( (_2nd_ShadeColor.rgb*_2nd_ShadeMap_var.rgb), ((_2nd_ShadeColor.rgb*_2nd_ShadeMap_var.rgb)*Set_LightColor), _Is_LightColor_2nd_Shade ); + float _HalfLambert_var = 0.5*dot(lerp( i.normalDir, normalDirection, _Is_NormalMapToBase ),lightDirection)+0.5; + + float4 _Set_2nd_ShadePosition_var = tex2D(_Set_2nd_ShadePosition,TRANSFORM_TEX(Set_UV0, _Set_2nd_ShadePosition)); + float4 _Set_1st_ShadePosition_var = tex2D(_Set_1st_ShadePosition,TRANSFORM_TEX(Set_UV0, _Set_1st_ShadePosition)); + + //v.2.0.6 + //Minmimum value is same as the Minimum Feather's value with the Minimum Step's value as threshold. + float _SystemShadowsLevel_var = (attenuation*0.5)+0.5+_Tweak_SystemShadowsLevel > 0.001 ? (attenuation*0.5)+0.5+_Tweak_SystemShadowsLevel : 0.0001; + float Set_FinalShadowMask = saturate((1.0 + ( (lerp( _HalfLambert_var, _HalfLambert_var*saturate(_SystemShadowsLevel_var), _Set_SystemShadowsToBase ) - (_BaseColor_Step-_BaseShade_Feather)) * ((1.0 - _Set_1st_ShadePosition_var.rgb).r - 1.0) ) / (_BaseColor_Step - (_BaseColor_Step-_BaseShade_Feather)))); + // + //Composition: 3 Basic Colors as Set_FinalBaseColor + float3 Set_FinalBaseColor = lerp(Set_BaseColor,lerp(Set_1st_ShadeColor,Set_2nd_ShadeColor,saturate((1.0 + ( (_HalfLambert_var - (_ShadeColor_Step-_1st2nd_Shades_Feather)) * ((1.0 - _Set_2nd_ShadePosition_var.rgb).r - 1.0) ) / (_ShadeColor_Step - (_ShadeColor_Step-_1st2nd_Shades_Feather))))),Set_FinalShadowMask); // Final Color + float4 _Set_HighColorMask_var = tex2D(_Set_HighColorMask, TRANSFORM_TEX(Set_UV0, _Set_HighColorMask)); + float _Specular_var = 0.5*dot(halfDirection,lerp( i.normalDir, normalDirection, _Is_NormalMapToHighColor ))+0.5; // Specular + float _TweakHighColorMask_var = (saturate((_Set_HighColorMask_var.g+_Tweak_HighColorMaskLevel))*lerp( (1.0 - step(_Specular_var,(1.0 - pow(_HighColor_Power,5)))), pow(_Specular_var,exp2(lerp(11,1,_HighColor_Power))), _Is_SpecularToHighColor )); + + float4 _HighColor_Tex_var = tex2D(_HighColor_Tex, TRANSFORM_TEX(Set_UV0, _HighColor_Tex)); + float3 _HighColor_var = (lerp( (_HighColor_Tex_var.rgb*_HighColor.rgb), ((_HighColor_Tex_var.rgb*_HighColor.rgb)*Set_LightColor), _Is_LightColor_HighColor )*_TweakHighColorMask_var); + //Composition: 3 Basic Colors and HighColor as Set_HighColor + float3 Set_HighColor = (lerp( saturate((Set_FinalBaseColor-_TweakHighColorMask_var)), Set_FinalBaseColor, lerp(_Is_BlendAddToHiColor,1.0,_Is_SpecularToHighColor) )+lerp( _HighColor_var, (_HighColor_var*((1.0 - Set_FinalShadowMask)+(Set_FinalShadowMask*_TweakHighColorOnShadow))), _Is_UseTweakHighColorOnShadow )); + + float4 _Set_RimLightMask_var = tex2D(_Set_RimLightMask, TRANSFORM_TEX(Set_UV0, _Set_RimLightMask)); + float3 _Is_LightColor_RimLight_var = lerp( _RimLightColor.rgb, (_RimLightColor.rgb*Set_LightColor), _Is_LightColor_RimLight ); + float _RimArea_var = (1.0 - dot(lerp( i.normalDir, normalDirection, _Is_NormalMapToRimLight ),viewDirection)); + float _RimLightPower_var = pow(_RimArea_var,exp2(lerp(3,0,_RimLight_Power))); + float _Rimlight_InsideMask_var = saturate(lerp( (0.0 + ( (_RimLightPower_var - _RimLight_InsideMask) * (1.0 - 0.0) ) / (1.0 - _RimLight_InsideMask)), step(_RimLight_InsideMask,_RimLightPower_var), _RimLight_FeatherOff )); + float _VertHalfLambert_var = 0.5*dot(i.normalDir,lightDirection)+0.5; + float3 _LightDirection_MaskOn_var = lerp( (_Is_LightColor_RimLight_var*_Rimlight_InsideMask_var), (_Is_LightColor_RimLight_var*saturate((_Rimlight_InsideMask_var-((1.0 - _VertHalfLambert_var)+_Tweak_LightDirection_MaskLevel)))), _LightDirection_MaskOn ); + float _ApRimLightPower_var = pow(_RimArea_var,exp2(lerp(3,0,_Ap_RimLight_Power))); + float3 Set_RimLight = (saturate((_Set_RimLightMask_var.g+_Tweak_RimLightMaskLevel))*lerp( _LightDirection_MaskOn_var, (_LightDirection_MaskOn_var+(lerp( _Ap_RimLightColor.rgb, (_Ap_RimLightColor.rgb*Set_LightColor), _Is_LightColor_Ap_RimLight )*saturate((lerp( (0.0 + ( (_ApRimLightPower_var - _RimLight_InsideMask) * (1.0 - 0.0) ) / (1.0 - _RimLight_InsideMask)), step(_RimLight_InsideMask,_ApRimLightPower_var), _Ap_RimLight_FeatherOff )-(saturate(_VertHalfLambert_var)+_Tweak_LightDirection_MaskLevel))))), _Add_Antipodean_RimLight )); + //Composition: HighColor and RimLight as _RimLight_var + float3 _RimLight_var = lerp( Set_HighColor, (Set_HighColor+Set_RimLight), _RimLight ); + //Matcap + //v.2.0.6 : CameraRolling Stabilizer + //Mirror Script Determination: if sign_Mirror = -1, determine "Inside the mirror". + //v.2.0.7 + fixed _sign_Mirror = i.mirrorFlag; + // + float3 _Camera_Right = UNITY_MATRIX_V[0].xyz; + float3 _Camera_Front = UNITY_MATRIX_V[2].xyz; + float3 _Up_Unit = float3(0, 1, 0); + float3 _Right_Axis = cross(_Camera_Front, _Up_Unit); + //Invert if it's "inside the mirror". + if(_sign_Mirror < 0){ + _Right_Axis = -1 * _Right_Axis; + _Rotate_MatCapUV = -1 * _Rotate_MatCapUV; + }else{ + _Right_Axis = _Right_Axis; + } + float _Camera_Right_Magnitude = sqrt(_Camera_Right.x*_Camera_Right.x + _Camera_Right.y*_Camera_Right.y + _Camera_Right.z*_Camera_Right.z); + float _Right_Axis_Magnitude = sqrt(_Right_Axis.x*_Right_Axis.x + _Right_Axis.y*_Right_Axis.y + _Right_Axis.z*_Right_Axis.z); + float _Camera_Roll_Cos = dot(_Right_Axis, _Camera_Right) / (_Right_Axis_Magnitude * _Camera_Right_Magnitude); + float _Camera_Roll = acos(clamp(_Camera_Roll_Cos, -1, 1)); + fixed _Camera_Dir = _Camera_Right.y < 0 ? -1 : 1; + float _Rot_MatCapUV_var_ang = (_Rotate_MatCapUV*3.141592654) - _Camera_Dir*_Camera_Roll*_CameraRolling_Stabilizer; + //v.2.0.7 + float2 _Rot_MatCapNmUV_var = RotateUV(Set_UV0, (_Rotate_NormalMapForMatCapUV*3.141592654), float2(0.5, 0.5), 1.0); + //V.2.0.6 + float3 _NormalMapForMatCap_var = UnpackScaleNormal(tex2D(_NormalMapForMatCap,TRANSFORM_TEX(_Rot_MatCapNmUV_var, _NormalMapForMatCap)),_BumpScaleMatcap); + //v.2.0.5: MatCap with camera skew correction + float3 viewNormal = (mul(UNITY_MATRIX_V, float4(lerp( i.normalDir, mul( _NormalMapForMatCap_var.rgb, tangentTransform ).rgb, _Is_NormalMapForMatCap ),0))).rgb; + float3 NormalBlend_MatcapUV_Detail = viewNormal.rgb * float3(-1,-1,1); + float3 NormalBlend_MatcapUV_Base = (mul( UNITY_MATRIX_V, float4(viewDirection,0) ).rgb*float3(-1,-1,1)) + float3(0,0,1); + float3 noSknewViewNormal = NormalBlend_MatcapUV_Base*dot(NormalBlend_MatcapUV_Base, NormalBlend_MatcapUV_Detail)/NormalBlend_MatcapUV_Base.b - NormalBlend_MatcapUV_Detail; + float2 _ViewNormalAsMatCapUV = (lerp(noSknewViewNormal,viewNormal,_Is_Ortho).rg*0.5)+0.5; + //v.2.0.7 + float2 _Rot_MatCapUV_var = RotateUV((0.0 + ((_ViewNormalAsMatCapUV - (0.0+_Tweak_MatCapUV)) * (1.0 - 0.0) ) / ((1.0-_Tweak_MatCapUV) - (0.0+_Tweak_MatCapUV))), _Rot_MatCapUV_var_ang, float2(0.5, 0.5), 1.0); + //If it is "inside the mirror", flip the UV left and right. + if(_sign_Mirror < 0){ + _Rot_MatCapUV_var.x = 1-_Rot_MatCapUV_var.x; + }else{ + _Rot_MatCapUV_var = _Rot_MatCapUV_var; + } + //v.2.0.6 : LOD of Matcap + + float4 _MatCap_Sampler_var = tex2Dlod(_MatCap_Sampler, float4(TRANSFORM_TEX(_Rot_MatCapUV_var, _MatCap_Sampler), 0.0, _BlurLevelMatcap)); + float4 _Set_MatcapMask_var = tex2D(_Set_MatcapMask, TRANSFORM_TEX(Set_UV0, _Set_MatcapMask)); + + float _Tweak_MatcapMaskLevel_var = saturate(lerp(_Set_MatcapMask_var.g, (1.0 - _Set_MatcapMask_var.g), _Inverse_MatcapMask) + _Tweak_MatcapMaskLevel); + // + float3 _Is_LightColor_MatCap_var = lerp( (_MatCap_Sampler_var.rgb*_MatCapColor.rgb), ((_MatCap_Sampler_var.rgb*_MatCapColor.rgb)*Set_LightColor), _Is_LightColor_MatCap ); + //v.2.0.6 : ShadowMask on Matcap in Blend mode : multiply + float3 Set_MatCap = lerp( _Is_LightColor_MatCap_var, (_Is_LightColor_MatCap_var*((1.0 - Set_FinalShadowMask)+(Set_FinalShadowMask*_TweakMatCapOnShadow)) + lerp(Set_HighColor*Set_FinalShadowMask*(1.0-_TweakMatCapOnShadow), float3(0.0, 0.0, 0.0), _Is_BlendAddToMatCap)), _Is_UseTweakMatCapOnShadow ); + // + //Composition: RimLight and MatCap as finalColor + //Broke down finalColor composition + float3 matCapColorOnAddMode = _RimLight_var+Set_MatCap*_Tweak_MatcapMaskLevel_var; + float _Tweak_MatcapMaskLevel_var_MultiplyMode = _Tweak_MatcapMaskLevel_var * lerp (1.0, (1.0 - (Set_FinalShadowMask)*(1.0 - _TweakMatCapOnShadow)), _Is_UseTweakMatCapOnShadow); + float3 matCapColorOnMultiplyMode = Set_HighColor*(1-_Tweak_MatcapMaskLevel_var_MultiplyMode) + Set_HighColor*Set_MatCap*_Tweak_MatcapMaskLevel_var_MultiplyMode + lerp(float3(0,0,0),Set_RimLight,_RimLight); + float3 matCapColorFinal = lerp(matCapColorOnMultiplyMode, matCapColorOnAddMode, _Is_BlendAddToMatCap); + float3 finalColor = lerp(_RimLight_var, matCapColorFinal, _MatCap);// Final Composition before Emissive + // + //v.2.0.6: GI_Intensity with Intensity Multiplier Filter + float3 envLightColor = DecodeLightProbe(normalDirection) < float3(1,1,1) ? DecodeLightProbe(normalDirection) : float3(1,1,1); + float envLightIntensity = 0.299*envLightColor.r + 0.587*envLightColor.g + 0.114*envLightColor.b <1 ? (0.299*envLightColor.r + 0.587*envLightColor.g + 0.114*envLightColor.b) : 1; +//v.2.0.7 +#ifdef _EMISSIVE_SIMPLE + float4 _Emissive_Tex_var = tex2D(_Emissive_Tex,TRANSFORM_TEX(Set_UV0, _Emissive_Tex)); + float emissiveMask = _Emissive_Tex_var.a; + emissive = _Emissive_Tex_var.rgb * _Emissive_Color.rgb * emissiveMask; +#elif _EMISSIVE_ANIMATION + //v.2.0.7 Calculation View Coord UV for Scroll + float3 viewNormal_Emissive = (mul(UNITY_MATRIX_V, float4(i.normalDir,0))).xyz; + float3 NormalBlend_Emissive_Detail = viewNormal_Emissive * float3(-1,-1,1); + float3 NormalBlend_Emissive_Base = (mul( UNITY_MATRIX_V, float4(viewDirection,0)).xyz*float3(-1,-1,1)) + float3(0,0,1); + float3 noSknewViewNormal_Emissive = NormalBlend_Emissive_Base*dot(NormalBlend_Emissive_Base, NormalBlend_Emissive_Detail)/NormalBlend_Emissive_Base.z - NormalBlend_Emissive_Detail; + float2 _ViewNormalAsEmissiveUV = noSknewViewNormal_Emissive.xy*0.5+0.5; + float2 _ViewCoord_UV = RotateUV(_ViewNormalAsEmissiveUV, -(_Camera_Dir*_Camera_Roll), float2(0.5,0.5), 1.0); + //If it is "inside the mirror", flip the UV left and right. + if(_sign_Mirror < 0){ + _ViewCoord_UV.x = 1-_ViewCoord_UV.x; + }else{ + _ViewCoord_UV = _ViewCoord_UV; + } + float2 emissive_uv = lerp(i.uv0, _ViewCoord_UV, _Is_ViewCoord_Scroll); + // + float4 _time_var = _Time; + float _base_Speed_var = (_time_var.g*_Base_Speed); + float _Is_PingPong_Base_var = lerp(_base_Speed_var, sin(_base_Speed_var), _Is_PingPong_Base ); + float2 scrolledUV = emissive_uv - float2(_Scroll_EmissiveU, _Scroll_EmissiveV)*_Is_PingPong_Base_var; + float rotateVelocity = _Rotate_EmissiveUV*3.141592654; + float2 _rotate_EmissiveUV_var = RotateUV(scrolledUV, rotateVelocity, float2(0.5, 0.5), _Is_PingPong_Base_var); + float4 _Emissive_Tex_var = tex2D(_Emissive_Tex,TRANSFORM_TEX(Set_UV0, _Emissive_Tex)); + float emissiveMask = _Emissive_Tex_var.a; + _Emissive_Tex_var = tex2D(_Emissive_Tex,TRANSFORM_TEX(_rotate_EmissiveUV_var, _Emissive_Tex)); + float _colorShift_Speed_var = 1.0 - cos(_time_var.g*_ColorShift_Speed); + float viewShift_var = smoothstep( 0.0, 1.0, max(0,dot(normalDirection,viewDirection))); + float4 colorShift_Color = lerp(_Emissive_Color, lerp(_Emissive_Color, _ColorShift, _colorShift_Speed_var), _Is_ColorShift); + float4 viewShift_Color = lerp(_ViewShift, colorShift_Color, viewShift_var); + float4 emissive_Color = lerp(colorShift_Color, viewShift_Color, _Is_ViewShift); + emissive = emissive_Color.rgb * _Emissive_Tex_var.rgb * emissiveMask; +#endif +// + //Final Composition + finalColor = saturate(finalColor) + (envLightColor*envLightIntensity*_GI_Intensity*smoothstep(1,0,envLightIntensity/2)) + emissive; + +#elif _IS_PASS_FWDDELTA + //v.2.0.5: + _BaseColor_Step = saturate(_BaseColor_Step + _StepOffset); + _ShadeColor_Step = saturate(_ShadeColor_Step + _StepOffset); + // + //v.2.0.5: If Added lights is directional, set 0 as _LightIntensity + float _LightIntensity = lerp(0,(0.299*_LightColor0.r + 0.587*_LightColor0.g + 0.114*_LightColor0.b)*attenuation,_WorldSpaceLightPos0.w) ; + //v.2.0.5: Filtering the high intensity zone of PointLights + float3 Set_LightColor = lightColor; + // + float3 Set_BaseColor = lerp( (_BaseColor.rgb*_MainTex_var.rgb*_LightIntensity), ((_BaseColor.rgb*_MainTex_var.rgb)*Set_LightColor), _Is_LightColor_Base ); + //v.2.0.5 + float4 _1st_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_1st_ShadeMap,sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)),_MainTex_var,_Use_BaseAs1st); + float3 Set_1st_ShadeColor = lerp( (_1st_ShadeColor.rgb*_1st_ShadeMap_var.rgb*_LightIntensity), ((_1st_ShadeColor.rgb*_1st_ShadeMap_var.rgb)*Set_LightColor), _Is_LightColor_1st_Shade ); + //v.2.0.5 + float4 _2nd_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_2nd_ShadeMap,sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)),_1st_ShadeMap_var,_Use_1stAs2nd); + float3 Set_2nd_ShadeColor = lerp( (_2nd_ShadeColor.rgb*_2nd_ShadeMap_var.rgb*_LightIntensity), ((_2nd_ShadeColor.rgb*_2nd_ShadeMap_var.rgb)*Set_LightColor), _Is_LightColor_2nd_Shade ); + float _HalfLambert_var = 0.5*dot(lerp( i.normalDir, normalDirection, _Is_NormalMapToBase ),lightDirection)+0.5; + + float4 _Set_2nd_ShadePosition_var = tex2D(_Set_2nd_ShadePosition, TRANSFORM_TEX(Set_UV0, _Set_2nd_ShadePosition)); + float4 _Set_1st_ShadePosition_var = tex2D(_Set_1st_ShadePosition, TRANSFORM_TEX(Set_UV0, _Set_1st_ShadePosition)); + + //v.2.0.5: + float Set_FinalShadowMask = saturate((1.0 + ( (lerp( _HalfLambert_var, (_HalfLambert_var*saturate(1.0+_Tweak_SystemShadowsLevel)), _Set_SystemShadowsToBase ) - (_BaseColor_Step-_BaseShade_Feather)) * ((1.0 - _Set_1st_ShadePosition_var.rgb).r - 1.0) ) / (_BaseColor_Step - (_BaseColor_Step-_BaseShade_Feather)))); + //Composition: 3 Basic Colors as finalColor + float3 finalColor = lerp(Set_BaseColor,lerp(Set_1st_ShadeColor,Set_2nd_ShadeColor,saturate((1.0 + ( (_HalfLambert_var - (_ShadeColor_Step-_1st2nd_Shades_Feather)) * ((1.0 - _Set_2nd_ShadePosition_var.rgb).r - 1.0) ) / (_ShadeColor_Step - (_ShadeColor_Step-_1st2nd_Shades_Feather))))),Set_FinalShadowMask); // Final Color + + //v.2.0.6: Add HighColor if _Is_Filter_HiCutPointLightColor is False + + float4 _Set_HighColorMask_var = tex2D(_Set_HighColorMask, TRANSFORM_TEX(Set_UV0, _Set_HighColorMask)); + + float _Specular_var = 0.5*dot(halfDirection,lerp( i.normalDir, normalDirection, _Is_NormalMapToHighColor ))+0.5; // Specular + float _TweakHighColorMask_var = (saturate((_Set_HighColorMask_var.g+_Tweak_HighColorMaskLevel))*lerp( (1.0 - step(_Specular_var,(1.0 - pow(_HighColor_Power,5)))), pow(_Specular_var,exp2(lerp(11,1,_HighColor_Power))), _Is_SpecularToHighColor )); + + float4 _HighColor_Tex_var = tex2D(_HighColor_Tex, TRANSFORM_TEX(Set_UV0, _HighColor_Tex)); + + float3 _HighColor_var = (lerp( (_HighColor_Tex_var.rgb*_HighColor.rgb), ((_HighColor_Tex_var.rgb*_HighColor.rgb)*Set_LightColor), _Is_LightColor_HighColor )*_TweakHighColorMask_var); + finalColor = finalColor + lerp(lerp( _HighColor_var, (_HighColor_var*((1.0 - Set_FinalShadowMask)+(Set_FinalShadowMask*_TweakHighColorOnShadow))), _Is_UseTweakHighColorOnShadow ),float3(0,0,0),_Is_Filter_HiCutPointLightColor); + // + + finalColor = saturate(finalColor); +#endif + + +//v.2.0.4 +#ifdef _IS_CLIPPING_OFF +//DoubleShadeWithFeather + #ifdef _IS_PASS_FWDBASE + fixed4 finalRGBA = fixed4(finalColor,1); + #elif _IS_PASS_FWDDELTA + fixed4 finalRGBA = fixed4(finalColor,0); + #endif +#elif _IS_CLIPPING_MODE +//DoubleShadeWithFeather_Clipping + #ifdef _IS_PASS_FWDBASE + fixed4 finalRGBA = fixed4(finalColor,1); + #elif _IS_PASS_FWDDELTA + fixed4 finalRGBA = fixed4(finalColor,0); + #endif +#elif _IS_CLIPPING_TRANSMODE +//DoubleShadeWithFeather_TransClipping + float Set_Opacity = saturate((_Inverse_Clipping_var+_Tweak_transparency)); + #ifdef _IS_PASS_FWDBASE + fixed4 finalRGBA = fixed4(finalColor,Set_Opacity); + #elif _IS_PASS_FWDDELTA + fixed4 finalRGBA = fixed4(finalColor * Set_Opacity,0); + #endif +#endif + UNITY_APPLY_FOG(i.fogCoord, finalRGBA); + return finalRGBA; + } diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_DoubleShadeWithFeather.cginc.meta b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_DoubleShadeWithFeather.cginc.meta new file mode 100644 index 0000000..e8ae549 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_DoubleShadeWithFeather.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f89105d64a395ea42931fae2703a2823 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Input.cginc b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Input.cginc new file mode 100644 index 0000000..8a58ee4 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Input.cginc @@ -0,0 +1,206 @@ + +#ifndef SAMPLE_TEXTURE2D +#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.SampleLevel(samplerName, coord2, 0) +#endif + +// CBUFFER_START(UnityPerMaterial) +float _utsTechnique; +float4 _MainTex_ST; + +float4 _Color; +fixed _Use_BaseAs1st; +fixed _Use_1stAs2nd; +fixed _Is_LightColor_Base; +// +float4 _1st_ShadeMap_ST; +float4 _1st_ShadeColor; +fixed _Is_LightColor_1st_Shade; +float4 _2nd_ShadeMap_ST; +float4 _2nd_ShadeColor; +fixed _Is_LightColor_2nd_Shade; +float4 _NormalMap_ST; + +fixed _Is_NormalMapToBase; +fixed _Set_SystemShadowsToBase; +float _Tweak_SystemShadowsLevel; +float _BaseColor_Step; +float _BaseShade_Feather; + +float4 _Set_1st_ShadePosition_ST; +float _ShadeColor_Step; +float _1st2nd_Shades_Feather; +float4 _Set_2nd_ShadePosition_ST; + +float4 _ShadingGradeMap_ST; + +float _Tweak_ShadingGradeMapLevel; +fixed _BlurLevelSGM; + +float _1st_ShadeColor_Step; +float _1st_ShadeColor_Feather; +float _2nd_ShadeColor_Step; +float _2nd_ShadeColor_Feather; + +float4 _HighColor; +float4 _HighColor_Tex_ST; +fixed _Is_LightColor_HighColor; +fixed _Is_NormalMapToHighColor; +float _HighColor_Power; + +fixed _Is_SpecularToHighColor; +fixed _Is_BlendAddToHiColor; +fixed _Is_UseTweakHighColorOnShadow; +float _TweakHighColorOnShadow; + +float4 _Set_HighColorMask_ST; + +float _Tweak_HighColorMaskLevel; +fixed _RimLight; +float4 _RimLightColor; +fixed _Is_LightColor_RimLight; +fixed _Is_NormalMapToRimLight; +float _RimLight_Power; +float _RimLight_InsideMask; +fixed _RimLight_FeatherOff; +fixed _LightDirection_MaskOn; +float _Tweak_LightDirection_MaskLevel; +fixed _Add_Antipodean_RimLight; +float4 _Ap_RimLightColor; +fixed _Is_LightColor_Ap_RimLight; +float _Ap_RimLight_Power; +fixed _Ap_RimLight_FeatherOff; +float4 _Set_RimLightMask_ST; +float _Tweak_RimLightMaskLevel; +fixed _MatCap; + +float4 _MatCap_Sampler_ST; + +float4 _MatCapColor; +fixed _Is_LightColor_MatCap; +fixed _Is_BlendAddToMatCap; +float _Tweak_MatCapUV; +float _Rotate_MatCapUV; +fixed _Is_NormalMapForMatCap; + +float4 _NormalMapForMatCap_ST; +float _Rotate_NormalMapForMatCapUV; +fixed _Is_UseTweakMatCapOnShadow; +float _TweakMatCapOnShadow; +//MatcapMask +// +float4 _Set_MatcapMask_ST; +float _Tweak_MatcapMaskLevel; + +fixed _Is_Ortho; + +float _CameraRolling_Stabilizer; +fixed _BlurLevelMatcap; +fixed _Inverse_MatcapMask; + +float _BumpScaleMatcap; + +float4 _Emissive_Tex_ST; +float4 _Emissive_Color; + +uniform fixed _Is_ViewCoord_Scroll; +float _Rotate_EmissiveUV; +float _Base_Speed; +float _Scroll_EmissiveU; +float _Scroll_EmissiveV; +fixed _Is_PingPong_Base; +float4 _ColorShift; +float4 _ViewShift; +float _ColorShift_Speed; +fixed _Is_ColorShift; +fixed _Is_ViewShift; +float3 emissive; +// + +float _Unlit_Intensity; + +fixed _Is_Filter_HiCutPointLightColor; +fixed _Is_Filter_LightColor; + +float _StepOffset; +fixed _Is_BLD; +float _Offset_X_Axis_BLD; +float _Offset_Y_Axis_BLD; +fixed _Inverse_Z_Axis_BLD; + +float4 _ClippingMask_ST; + +fixed _IsBaseMapAlphaAsClippingMask; +float _Clipping_Level; +fixed _Inverse_Clipping; +float _Tweak_transparency; + +float _GI_Intensity; +fixed _AngelRing; +float4 _AngelRing_Sampler_ST; +float4 _AngelRing_Color; +fixed _Is_LightColor_AR; +float _AR_OffsetU; +float _AR_OffsetV; +fixed _ARSampler_AlphaOn; + +// OUTLINE + + +fixed _Is_LightColor_Outline; + +float _Outline_Width; +float _Farthest_Distance; +float _Nearest_Distance; +float4 _Outline_Sampler_ST; +float4 _Outline_Color; +fixed _Is_BlendBaseColor; +float _Offset_Z; + +float4 _OutlineTex_ST; +fixed _Is_OutlineTex; + +float4 _BakedNormal_ST; +fixed _Is_BakedNormal; + +float _ZOverDrawMode; + +// +// +// +float4 _BaseMap_ST; +half4 _BaseColor; +//half4 _SpecColor; +half4 _EmissionColor; +half _Cutoff; +half _Smoothness; +half _Metallic; +half _BumpScale; +half _OcclusionStrength; +half _Surface; +// CBUFFER_END + +// sampler2D _MainTex; +// sampler2D _1st_ShadeMap; +// sampler2D _2nd_ShadeMap; +// sampler2D _NormalMap; + +Texture2D _MainTex; SamplerState sampler_MainTex; +Texture2D _1st_ShadeMap; +Texture2D _2nd_ShadeMap; +Texture2D _NormalMap; + +sampler2D _Set_1st_ShadePosition; +sampler2D _Set_2nd_ShadePosition; +sampler2D _ShadingGradeMap; +sampler2D _HighColor_Tex; +sampler2D _Set_HighColorMask; +sampler2D _Set_RimLightMask; +sampler2D _MatCap_Sampler; +sampler2D _NormalMapForMatCap; +sampler2D _Set_MatcapMask; +sampler2D _Emissive_Tex; +sampler2D _ClippingMask; +sampler2D _AngelRing_Sampler; +sampler2D _Outline_Sampler; +sampler2D _OutlineTex; +sampler2D _BakedNormal; \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Input.cginc.meta b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Input.cginc.meta new file mode 100644 index 0000000..7f8b776 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Input.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8546c9fb3eb4e994cb51739be7a92cba +timeCreated: 1486305225 +licenseType: Pro +ShaderImporter: + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Light.cginc b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Light.cginc new file mode 100644 index 0000000..39e0596 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Light.cginc @@ -0,0 +1,10 @@ +//Note: requires VertexOutput to be defined before including this file + +#ifndef __UCTS_LIGHT__ +#define __UCTS_LIGHT__ + +#include "AutoLight.cginc" +#define UTS_LIGHT_ATTENUATION(destName, input, worldPos) UNITY_LIGHT_ATTENUATION(destName, input, worldPos) + +#endif //__UCTS_LIGHT__ + diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Light.cginc.meta b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Light.cginc.meta new file mode 100644 index 0000000..0932f61 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Light.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8ea6d9641574dec4f89650891ca9dffc +timeCreated: 1518248457 +licenseType: Pro +ShaderImporter: + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Outline.cginc b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Outline.cginc new file mode 100644 index 0000000..1681a97 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Outline.cginc @@ -0,0 +1,108 @@ +//Unity Toon Shader/Legacy +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Intengrated) +// + +#include "UCTS_Input.cginc" + + uniform float4 _LightColor0; + + + struct VertexInput { + float4 vertex : POSITION; + float3 normal : NORMAL; + float4 tangent : TANGENT; + float2 texcoord0 : TEXCOORD0; + UNITY_VERTEX_INPUT_INSTANCE_ID // + }; + struct VertexOutput { + float4 pos : SV_POSITION; + float2 uv0 : TEXCOORD0; + float3 normalDir : TEXCOORD1; + float3 tangentDir : TEXCOORD2; + float3 bitangentDir : TEXCOORD3; + UNITY_VERTEX_INPUT_INSTANCE_ID + UNITY_VERTEX_OUTPUT_STEREO + }; + VertexOutput vert (VertexInput v) { + VertexOutput o = (VertexOutput)0; + UNITY_SETUP_INSTANCE_ID(v); + UNITY_TRANSFER_INSTANCE_ID(v, o); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); + o.uv0 = v.texcoord0; + float4 objPos = mul ( unity_ObjectToWorld, float4(0,0,0,1) ); + float2 Set_UV0 = o.uv0; + float4 _Outline_Sampler_var = tex2Dlod(_Outline_Sampler,float4(TRANSFORM_TEX(Set_UV0, _Outline_Sampler),0.0,0)); + //v.2.0.4.3 baked Normal Texture for Outline + o.normalDir = UnityObjectToWorldNormal(v.normal); + o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz ); + o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w); + float3x3 tangentTransform = float3x3( o.tangentDir, o.bitangentDir, o.normalDir); + //UnpackNormal() can't be used, and so as follows. Do not specify a bump for the texture to be used. + float4 _BakedNormal_var = (tex2Dlod(_BakedNormal,float4(TRANSFORM_TEX(Set_UV0, _BakedNormal),0.0,0)) * 2 - 1); + float3 _BakedNormalDir = normalize(mul(_BakedNormal_var.rgb, tangentTransform)); + //end + float Set_Outline_Width = (_Outline_Width*0.001*smoothstep( _Farthest_Distance, _Nearest_Distance, distance(objPos.rgb,_WorldSpaceCameraPos) )*_Outline_Sampler_var.rgb).r; + //v.2.0.7.5 + float4 _ClipCameraPos = mul(UNITY_MATRIX_VP, float4(_WorldSpaceCameraPos.xyz, 1)); + //v.2.0.7 + #if defined(UNITY_REVERSED_Z) || (UNITY_VERSION >= 202230) + //v.2.0.4.2 (DX) + _Offset_Z = _Offset_Z * -0.01; + #else + //OpenGL + _Offset_Z = _Offset_Z * 0.01; + #endif +//v2.0.4 +#ifdef _OUTLINE_NML + //v.2.0.4.3 baked Normal Texture for Outline + o.pos = UnityObjectToClipPos(lerp(float4(v.vertex.xyz + v.normal*Set_Outline_Width,1), float4(v.vertex.xyz + _BakedNormalDir*Set_Outline_Width,1),_Is_BakedNormal)); +#elif _OUTLINE_POS + Set_Outline_Width = Set_Outline_Width*2; + float signVar = dot(normalize(v.vertex.xyz),normalize(v.normal))<0 ? -1 : 1; + o.pos = UnityObjectToClipPos(float4(v.vertex.xyz + signVar*normalize(v.vertex)*Set_Outline_Width, 1)); +#endif + //v.2.0.7.5 + o.pos.z = o.pos.z + _Offset_Z * _ClipCameraPos.z; + return o; + } + float4 frag(VertexOutput i) : SV_Target{ +#if _DISABLE_OUTLINE + discard; +#endif + UNITY_SETUP_INSTANCE_ID(i); + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i); + //v.2.0.5 + _Color = _BaseColor; + float4 objPos = mul ( unity_ObjectToWorld, float4(0,0,0,1) ); + //v.2.0.9 + float3 envLightSource_GradientEquator = unity_AmbientEquator.rgb >0.05 ? unity_AmbientEquator.rgb : half3(0.05,0.05,0.05); + float3 envLightSource_SkyboxIntensity = max(ShadeSH9(half4(0.0,0.0,0.0,1.0)),ShadeSH9(half4(0.0,-1.0,0.0,1.0))).rgb; + float3 ambientSkyColor = envLightSource_SkyboxIntensity.rgb>0.0 ? envLightSource_SkyboxIntensity*_Unlit_Intensity : envLightSource_GradientEquator*_Unlit_Intensity; + // + float3 lightColor = _LightColor0.rgb >0.05 ? _LightColor0.rgb : ambientSkyColor.rgb; + float lightColorIntensity = (0.299*lightColor.r + 0.587*lightColor.g + 0.114*lightColor.b); + lightColor = lightColorIntensity<1 ? lightColor : lightColor/lightColorIntensity; + lightColor = lerp(half3(1.0,1.0,1.0), lightColor, _Is_LightColor_Outline); + float2 Set_UV0 = i.uv0; + float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)); + float3 Set_BaseColor = _BaseColor.rgb*_MainTex_var.rgb; + float3 _Is_BlendBaseColor_var = lerp( _Outline_Color.rgb*lightColor, (_Outline_Color.rgb*Set_BaseColor*Set_BaseColor*lightColor), _Is_BlendBaseColor ); + // + float3 _OutlineTex_var = tex2D(_OutlineTex,TRANSFORM_TEX(Set_UV0, _OutlineTex)); +//v.2.0.7.5 +#ifdef _IS_OUTLINE_CLIPPING_NO + float3 Set_Outline_Color = lerp(_Is_BlendBaseColor_var, _OutlineTex_var.rgb*_Outline_Color.rgb*lightColor, _Is_OutlineTex ); + return float4(Set_Outline_Color,1.0); +#elif _IS_OUTLINE_CLIPPING_YES + float4 _ClippingMask_var = tex2D(_ClippingMask,TRANSFORM_TEX(Set_UV0, _ClippingMask)); + float Set_MainTexAlpha = _MainTex_var.a; + float _IsBaseMapAlphaAsClippingMask_var = lerp( _ClippingMask_var.r, Set_MainTexAlpha, _IsBaseMapAlphaAsClippingMask ); + float _Inverse_Clipping_var = lerp( _IsBaseMapAlphaAsClippingMask_var, (1.0 - _IsBaseMapAlphaAsClippingMask_var), _Inverse_Clipping ); + float Set_Clipping = saturate((_Inverse_Clipping_var+_Clipping_Level)); + clip(Set_Clipping - 0.5); + float4 Set_Outline_Color = lerp( float4(_Is_BlendBaseColor_var,Set_Clipping), float4((_OutlineTex_var.rgb*_Outline_Color.rgb*lightColor),Set_Clipping), _Is_OutlineTex ); + return Set_Outline_Color; +#endif + } +// End of UCTS_Outline.cginc diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Outline.cginc.meta b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Outline.cginc.meta new file mode 100644 index 0000000..24bac14 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Outline.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: fd30dab7fe1aaa6429b563a96f6973fd +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Outline_Tess.cginc b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Outline_Tess.cginc new file mode 100644 index 0000000..1a461b6 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Outline_Tess.cginc @@ -0,0 +1,127 @@ +//Unity Toon Shader/Legacy +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Intengrated) +// ※Tessellation support +// The corresponding code was adapted from Nora's https://github.com/Stereoarts/UnityChanToonShaderVer2_Tess. +// +#ifndef TESSELLATION_ON +struct VertexInput { + float4 vertex : POSITION; + float3 normal : NORMAL; + float4 tangent : TANGENT; + float2 texcoord0 : TEXCOORD0; + UNITY_VERTEX_INPUT_INSTANCE_ID +}; + +#endif + +struct VertexOutput { + float4 pos : SV_POSITION; + float2 uv0 : TEXCOORD0; + float3 normalDir : TEXCOORD1; + float3 tangentDir : TEXCOORD2; + float3 bitangentDir : TEXCOORD3; + UNITY_VERTEX_INPUT_INSTANCE_ID + UNITY_VERTEX_OUTPUT_STEREO +}; + +//--------------------------------------------------------------------------------------------------------------------- +#include "UCTS_Input.cginc" +#ifdef TESSELLATION_ON + #include "UCTS_Tess.cginc" +#endif +#ifndef TESSELLATION_ON + uniform float4 _LightColor0; +#endif + + VertexOutput vert (VertexInput v) { + VertexOutput o = (VertexOutput)0; + UNITY_SETUP_INSTANCE_ID(v); + UNITY_TRANSFER_INSTANCE_ID(v, o); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); + o.uv0 = v.texcoord0; + float4 objPos = mul ( unity_ObjectToWorld, float4(0,0,0,1) ); + float2 Set_UV0 = o.uv0; + float4 _Outline_Sampler_var = tex2Dlod(_Outline_Sampler,float4(TRANSFORM_TEX(Set_UV0, _Outline_Sampler),0.0,0)); + //v.2.0.4.3 baked Normal Texture for Outline + o.normalDir = UnityObjectToWorldNormal(v.normal); + o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz ); + o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w); + float3x3 tangentTransform = float3x3( o.tangentDir, o.bitangentDir, o.normalDir); + //UnpackNormal() can't be used, and so as follows. Do not specify a bump for the texture to be used. + float4 _BakedNormal_var = (tex2Dlod(_BakedNormal,float4(TRANSFORM_TEX(Set_UV0, _BakedNormal),0.0,0)) * 2 - 1); + float3 _BakedNormalDir = normalize(mul(_BakedNormal_var.rgb, tangentTransform)); + //end + float Set_Outline_Width = (_Outline_Width*0.001*smoothstep( _Farthest_Distance, _Nearest_Distance, distance(objPos.rgb,_WorldSpaceCameraPos) )*_Outline_Sampler_var.rgb).r; + //v.2.0.7.5 + float4 _ClipCameraPos = mul(UNITY_MATRIX_VP, float4(_WorldSpaceCameraPos.xyz, 1)); + //v.2.0.7 + #if defined(UNITY_REVERSED_Z) || (UNITY_VERSION >= 202230) + //v.2.0.4.2 (DX) + _Offset_Z = _Offset_Z * -0.01; + #else + //OpenGL + _Offset_Z = _Offset_Z * 0.01; + #endif +//v2.0.4 +#ifdef _OUTLINE_NML + //v.2.0.4.3 baked Normal Texture for Outline + o.pos = UnityObjectToClipPos(lerp(float4(v.vertex.xyz + v.normal*Set_Outline_Width,1), float4(v.vertex.xyz + _BakedNormalDir*Set_Outline_Width,1),_Is_BakedNormal)); +#elif _OUTLINE_POS + Set_Outline_Width = Set_Outline_Width*2; + float signVar = dot(normalize(v.vertex),normalize(v.normal))<0 ? -1 : 1; + o.pos = UnityObjectToClipPos(float4(v.vertex.xyz + signVar*normalize(v.vertex)*Set_Outline_Width, 1)); +#endif + //v.2.0.7.5 + o.pos.z = o.pos.z + _Offset_Z * _ClipCameraPos.z; + return o; + } +#ifdef TESSELLATION_ON +#ifdef UNITY_CAN_COMPILE_TESSELLATION + // tessellation domain shader + [UNITY_domain("tri")] + VertexOutput ds_surf(UnityTessellationFactors tessFactors, const OutputPatch vi, float3 bary : SV_DomainLocation) + { + VertexInput v = _ds_VertexInput(tessFactors, vi, bary); + return vert(v); + } +#endif // UNITY_CAN_COMPILE_TESSELLATION +#endif // TESSELLATION_ON + float4 frag(VertexOutput i) : SV_Target{ +#if _DISABLE_OUTLINE + discard; +#endif + //v.2.0.5 + _Color = _BaseColor; + float4 objPos = mul ( unity_ObjectToWorld, float4(0,0,0,1) ); + //v.2.0.9 + float3 envLightSource_GradientEquator = unity_AmbientEquator.rgb >0.05 ? unity_AmbientEquator.rgb : half3(0.05,0.05,0.05); + float3 envLightSource_SkyboxIntensity = max(ShadeSH9(half4(0.0,0.0,0.0,1.0)),ShadeSH9(half4(0.0,-1.0,0.0,1.0))).rgb; + float3 ambientSkyColor = envLightSource_SkyboxIntensity.rgb>0.0 ? envLightSource_SkyboxIntensity*_Unlit_Intensity : envLightSource_GradientEquator*_Unlit_Intensity; + // + float3 lightColor = _LightColor0.rgb >0.05 ? _LightColor0.rgb : ambientSkyColor.rgb; + float lightColorIntensity = (0.299*lightColor.r + 0.587*lightColor.g + 0.114*lightColor.b); + lightColor = lightColorIntensity<1 ? lightColor : lightColor/lightColorIntensity; + lightColor = lerp(half3(1.0,1.0,1.0), lightColor, _Is_LightColor_Outline); + float2 Set_UV0 = i.uv0; + float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,TRANSFORM_TEX(Set_UV0, _MainTex)); + float3 Set_BaseColor = _BaseColor.rgb*_MainTex_var.rgb; + float3 _Is_BlendBaseColor_var = lerp( _Outline_Color.rgb*lightColor, (_Outline_Color.rgb*Set_BaseColor*Set_BaseColor*lightColor), _Is_BlendBaseColor ); + // + float3 _OutlineTex_var = tex2D(_OutlineTex,TRANSFORM_TEX(Set_UV0, _OutlineTex)); +//v.2.0.7.5 +#ifdef _IS_OUTLINE_CLIPPING_NO + float3 Set_Outline_Color = lerp(_Is_BlendBaseColor_var, _OutlineTex_var.rgb*_Outline_Color.rgb*lightColor, _Is_OutlineTex ); + return float4(Set_Outline_Color,1.0); +#elif _IS_OUTLINE_CLIPPING_YES + float4 _ClippingMask_var = tex2D(_ClippingMask,TRANSFORM_TEX(Set_UV0, _ClippingMask)); + float Set_MainTexAlpha = _MainTex_var.a; + float _IsBaseMapAlphaAsClippingMask_var = lerp( _ClippingMask_var.r, Set_MainTexAlpha, _IsBaseMapAlphaAsClippingMask ); + float _Inverse_Clipping_var = lerp( _IsBaseMapAlphaAsClippingMask_var, (1.0 - _IsBaseMapAlphaAsClippingMask_var), _Inverse_Clipping ); + float Set_Clipping = saturate((_Inverse_Clipping_var+_Clipping_Level)); + clip(Set_Clipping - 0.5); + float4 Set_Outline_Color = lerp( float4(_Is_BlendBaseColor_var,Set_Clipping), float4((_OutlineTex_var.rgb*_Outline_Color.rgb*lightColor),Set_Clipping), _Is_OutlineTex ); + return Set_Outline_Color; +#endif + } +// End of UCTS_Outline_Tess.cginc diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Outline_Tess.cginc.meta b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Outline_Tess.cginc.meta new file mode 100644 index 0000000..105d942 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Outline_Tess.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a902fff45376f1a48bbf2a98b9f649d6 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadingGradeMap.cginc b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadingGradeMap.cginc new file mode 100644 index 0000000..b433c19 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadingGradeMap.cginc @@ -0,0 +1,386 @@ +//Unity Toon Shader/Legacy +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Intengrated) + +// ※Tessellation support +// The corresponding code was adapted from Nora's https://github.com/Stereoarts/UnityChanToonShaderVer2_Tess. +// + + +//Tessellation OFF +#ifndef TESSELLATION_ON + +struct VertexInput { + float4 vertex : POSITION; + float3 normal : NORMAL; + float4 tangent : TANGENT; + float2 texcoord0 : TEXCOORD0; +#if defined(_IS_ANGELRING_ON) + float2 texcoord1 : TEXCOORD1; +#endif + UNITY_VERTEX_INPUT_INSTANCE_ID // +}; +#endif +struct VertexOutput { + float4 pos : SV_POSITION; + float2 uv0 : TEXCOORD0; + +#if _IS_ANGELRING_ON + float2 uv1 : TEXCOORD1; +#endif + + float4 posWorld : TEXCOORD2; + float3 normalDir : TEXCOORD3; + float3 tangentDir : TEXCOORD4; + float3 bitangentDir : TEXCOORD5; + float mirrorFlag : TEXCOORD6; + LIGHTING_COORDS(7,8) + UNITY_FOG_COORDS(9) + + UNITY_VERTEX_INPUT_INSTANCE_ID + UNITY_VERTEX_OUTPUT_STEREO +}; + +//--------------------------------------------------------------------------------------------------------------------- + +#include "UCTS_Light.cginc" +#include "UCTS_Input.cginc" + //function to rotate the UV: RotateUV() + //float2 rotatedUV = RotateUV(i.uv0, (_angular_Verocity*3.141592654), float2(0.5, 0.5), _Time.g); + float2 RotateUV(float2 _uv, float _radian, float2 _piv, float _time) + { + float RotateUV_ang = _radian; + float RotateUV_cos = cos(_time*RotateUV_ang); + float RotateUV_sin = sin(_time*RotateUV_ang); + return (mul(_uv - _piv, float2x2( RotateUV_cos, -RotateUV_sin, RotateUV_sin, RotateUV_cos)) + _piv); + } + // + fixed3 DecodeLightProbe( fixed3 N ){ + return ShadeSH9(float4(N,1)); + } + + // + VertexOutput vert (VertexInput v) { + VertexOutput o = (VertexOutput)0; + UNITY_SETUP_INSTANCE_ID(v); + UNITY_TRANSFER_INSTANCE_ID(v, o); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); + o.uv0 = v.texcoord0; + +#if defined(_IS_ANGELRING_ON) + o.uv1 = v.texcoord1; +#endif + o.normalDir = UnityObjectToWorldNormal(v.normal); + o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz ); + o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w); + o.posWorld = mul(unity_ObjectToWorld, v.vertex); + float3 lightColor = _LightColor0.rgb; + o.pos = UnityObjectToClipPos( v.vertex ); + //v.2.0.7 Detection of the inside the mirror (right or left-handed) o.mirrorFlag = -1 then "inside the mirror". + float3 crossFwd = cross(UNITY_MATRIX_V[0], UNITY_MATRIX_V[1]); + o.mirrorFlag = dot(crossFwd, UNITY_MATRIX_V[2].xyz) < 0 ? 1 : -1; + // + UNITY_TRANSFER_FOG(o,o.pos); + TRANSFER_VERTEX_TO_FRAGMENT(o) + return o; + } + +//Tessellation ON +#ifdef TESSELLATION_ON +#ifdef UNITY_CAN_COMPILE_TESSELLATION + // tessellation domain shader + [UNITY_domain("tri")] + VertexOutput ds_surf(UnityTessellationFactors tessFactors, const OutputPatch vi, float3 bary : SV_DomainLocation) + { + VertexInput v = _ds_VertexInput(tessFactors, vi, bary); + return vert(v); + } +#endif // UNITY_CAN_COMPILE_TESSELLATION +#endif // TESSELLATION_ON + float4 frag(VertexOutput i, fixed facing : VFACE) : SV_TARGET { + UNITY_SETUP_INSTANCE_ID(i); + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i); + + i.normalDir = normalize(i.normalDir); + float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir); + float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz); + float2 Set_UV0 = i.uv0; + //v.2.0.6 + float3 _NormalMap_var = UnpackScaleNormal(SAMPLE_TEXTURE2D(_NormalMap,sampler_MainTex, TRANSFORM_TEX(Set_UV0, _NormalMap)), _BumpScale); + float3 normalLocal = _NormalMap_var.rgb; + float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals + + float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)); + + +//v.2.0.4 +#ifdef _IS_TRANSCLIPPING_OFF +// +#elif _IS_TRANSCLIPPING_ON + + + float4 _ClippingMask_var = tex2D(_ClippingMask,TRANSFORM_TEX(Set_UV0, _MainTex)); + float Set_MainTexAlpha = _MainTex_var.a; + float _IsBaseMapAlphaAsClippingMask_var = lerp( _ClippingMask_var.r, Set_MainTexAlpha, _IsBaseMapAlphaAsClippingMask ); + float _Inverse_Clipping_var = lerp( _IsBaseMapAlphaAsClippingMask_var, (1.0 - _IsBaseMapAlphaAsClippingMask_var), _Inverse_Clipping ); + float Set_Clipping = saturate((_Inverse_Clipping_var+_Clipping_Level)); + clip(Set_Clipping - 0.5); +#endif + + UTS_LIGHT_ATTENUATION(attenuation, i, i.posWorld.xyz); +//v.2.0.4 +#ifdef _IS_PASS_FWDBASE + float3 defaultLightDirection = normalize(UNITY_MATRIX_V[2].xyz + UNITY_MATRIX_V[1].xyz); + //v.2.0.5 + float3 defaultLightColor = saturate(max(half3(0.05,0.05,0.05)*_Unlit_Intensity,max(ShadeSH9(half4(0.0, 0.0, 0.0, 1.0)),ShadeSH9(half4(0.0, -1.0, 0.0, 1.0)).rgb)*_Unlit_Intensity)); + float3 customLightDirection = normalize(mul( unity_ObjectToWorld, float4(((float3(1.0,0.0,0.0)*_Offset_X_Axis_BLD*10)+(float3(0.0,1.0,0.0)*_Offset_Y_Axis_BLD*10)+(float3(0.0,0.0,-1.0)*lerp(-1.0,1.0,_Inverse_Z_Axis_BLD))),0)).xyz); + float3 lightDirection = normalize(lerp(defaultLightDirection,_WorldSpaceLightPos0.xyz,any(_WorldSpaceLightPos0.xyz))); + lightDirection = lerp(lightDirection, customLightDirection, _Is_BLD); + //v.2.0.5: + float3 lightColor = lerp(max(defaultLightColor,_LightColor0.rgb),max(defaultLightColor,saturate(_LightColor0.rgb)),_Is_Filter_LightColor); +#elif _IS_PASS_FWDDELTA + float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w)); + //v.2.0.5: + float3 addPassLightColor = (0.5*dot(lerp( i.normalDir, normalDirection, _Is_NormalMapToBase ), lightDirection)+0.5) * _LightColor0.rgb * attenuation; + float pureIntencity = max(0.001,(0.299*_LightColor0.r + 0.587*_LightColor0.g + 0.114*_LightColor0.b)); + float3 lightColor = max(float3(0,0,0), lerp(addPassLightColor, lerp(float3(0,0,0),min(addPassLightColor,addPassLightColor/pureIntencity),_WorldSpaceLightPos0.w),_Is_Filter_LightColor)); +#endif +////// Lighting: + float3 halfDirection = normalize(viewDirection+lightDirection); + //v.2.0.5 + _Color = _BaseColor; + +#ifdef _IS_PASS_FWDBASE + float3 Set_LightColor = lightColor.rgb; + float3 Set_BaseColor = lerp( (_MainTex_var.rgb*_BaseColor.rgb), ((_MainTex_var.rgb*_BaseColor.rgb)*Set_LightColor), _Is_LightColor_Base ); + //v.2.0.5 + float4 _1st_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_1st_ShadeMap,sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)),_MainTex_var,_Use_BaseAs1st); + float3 _Is_LightColor_1st_Shade_var = lerp( (_1st_ShadeMap_var.rgb*_1st_ShadeColor.rgb), ((_1st_ShadeMap_var.rgb*_1st_ShadeColor.rgb)*Set_LightColor), _Is_LightColor_1st_Shade ); + float _HalfLambert_var = 0.5*dot(lerp( i.normalDir, normalDirection, _Is_NormalMapToBase ),lightDirection)+0.5; // Half Lambert + + //v.2.0.6 + float4 _ShadingGradeMap_var = tex2Dlod(_ShadingGradeMap,float4(TRANSFORM_TEX(Set_UV0, _ShadingGradeMap),0.0,_BlurLevelSGM)); + //v.2.0.6 + //Minmimum value is same as the Minimum Feather's value with the Minimum Step's value as threshold. + float _SystemShadowsLevel_var = (attenuation*0.5)+0.5+_Tweak_SystemShadowsLevel > 0.001 ? (attenuation*0.5)+0.5+_Tweak_SystemShadowsLevel : 0.0001; + float _ShadingGradeMapLevel_var = _ShadingGradeMap_var.r < 0.95 ? _ShadingGradeMap_var.r +_Tweak_ShadingGradeMapLevel : 1; + float Set_ShadingGrade = saturate(_ShadingGradeMapLevel_var)*lerp( _HalfLambert_var, (_HalfLambert_var*saturate(_SystemShadowsLevel_var)), _Set_SystemShadowsToBase ); + // + float Set_FinalShadowMask = saturate((1.0 + ( (Set_ShadingGrade - (_1st_ShadeColor_Step-_1st_ShadeColor_Feather)) * (0.0 - 1.0) ) / (_1st_ShadeColor_Step - (_1st_ShadeColor_Step-_1st_ShadeColor_Feather)))); // Base and 1st Shade Mask + float3 _BaseColor_var = lerp(Set_BaseColor,_Is_LightColor_1st_Shade_var,Set_FinalShadowMask); + //v.2.0.5 + float4 _2nd_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_2nd_ShadeMap,sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)),_1st_ShadeMap_var,_Use_1stAs2nd); + float Set_ShadeShadowMask = saturate((1.0 + ( (Set_ShadingGrade - (_2nd_ShadeColor_Step-_2nd_ShadeColor_Feather)) * (0.0 - 1.0) ) / (_2nd_ShadeColor_Step - (_2nd_ShadeColor_Step-_2nd_ShadeColor_Feather)))); // 1st and 2nd Shades Mask + //Composition: 3 Basic Colors as Set_FinalBaseColor + float3 Set_FinalBaseColor = lerp(_BaseColor_var,lerp(_Is_LightColor_1st_Shade_var,lerp( (_2nd_ShadeMap_var.rgb*_2nd_ShadeColor.rgb), ((_2nd_ShadeMap_var.rgb*_2nd_ShadeColor.rgb)*Set_LightColor), _Is_LightColor_2nd_Shade ),Set_ShadeShadowMask),Set_FinalShadowMask); + //v.2.0.6: Add HighColor if _Is_Filter_HiCutPointLightColor is False + + float4 _Set_HighColorMask_var = tex2D(_Set_HighColorMask, TRANSFORM_TEX(Set_UV0, _Set_HighColorMask)); + + float _Specular_var = 0.5*dot(halfDirection,lerp( i.normalDir, normalDirection, _Is_NormalMapToHighColor ))+0.5; // Specular + float _TweakHighColorMask_var = (saturate((_Set_HighColorMask_var.g+_Tweak_HighColorMaskLevel))*lerp( (1.0 - step(_Specular_var,(1.0 - pow(_HighColor_Power,5)))), pow(_Specular_var,exp2(lerp(11,1,_HighColor_Power))), _Is_SpecularToHighColor )); + + float4 _HighColor_Tex_var = tex2D(_HighColor_Tex, TRANSFORM_TEX(Set_UV0, _HighColor_Tex)); + float3 _HighColor_var = (lerp( (_HighColor_Tex_var.rgb*_HighColor.rgb), ((_HighColor_Tex_var.rgb*_HighColor.rgb)*Set_LightColor), _Is_LightColor_HighColor )*_TweakHighColorMask_var); + //Composition: 3 Basic Colors and HighColor as Set_HighColor + float3 Set_HighColor = (lerp( saturate((Set_FinalBaseColor-_TweakHighColorMask_var)), Set_FinalBaseColor, lerp(_Is_BlendAddToHiColor,1.0,_Is_SpecularToHighColor) )+lerp( _HighColor_var, (_HighColor_var*((1.0 - Set_FinalShadowMask)+(Set_FinalShadowMask*_TweakHighColorOnShadow))), _Is_UseTweakHighColorOnShadow )); + + float4 _Set_RimLightMask_var = tex2D(_Set_RimLightMask,TRANSFORM_TEX(Set_UV0, _Set_RimLightMask)); + float3 _Is_LightColor_RimLight_var = lerp( _RimLightColor.rgb, (_RimLightColor.rgb*Set_LightColor), _Is_LightColor_RimLight ); + float _RimArea_var = (1.0 - dot(lerp( i.normalDir, normalDirection, _Is_NormalMapToRimLight ),viewDirection)); + float _RimLightPower_var = pow(_RimArea_var,exp2(lerp(3,0,_RimLight_Power))); + float _Rimlight_InsideMask_var = saturate(lerp( (0.0 + ( (_RimLightPower_var - _RimLight_InsideMask) * (1.0 - 0.0) ) / (1.0 - _RimLight_InsideMask)), step(_RimLight_InsideMask,_RimLightPower_var), _RimLight_FeatherOff )); + float _VertHalfLambert_var = 0.5*dot(i.normalDir,lightDirection)+0.5; + float3 _LightDirection_MaskOn_var = lerp( (_Is_LightColor_RimLight_var*_Rimlight_InsideMask_var), (_Is_LightColor_RimLight_var*saturate((_Rimlight_InsideMask_var-((1.0 - _VertHalfLambert_var)+_Tweak_LightDirection_MaskLevel)))), _LightDirection_MaskOn ); + float _ApRimLightPower_var = pow(_RimArea_var,exp2(lerp(3,0,_Ap_RimLight_Power))); + float3 Set_RimLight = (saturate((_Set_RimLightMask_var.g+_Tweak_RimLightMaskLevel))*lerp( _LightDirection_MaskOn_var, (_LightDirection_MaskOn_var+(lerp( _Ap_RimLightColor.rgb, (_Ap_RimLightColor.rgb*Set_LightColor), _Is_LightColor_Ap_RimLight )*saturate((lerp( (0.0 + ( (_ApRimLightPower_var - _RimLight_InsideMask) * (1.0 - 0.0) ) / (1.0 - _RimLight_InsideMask)), step(_RimLight_InsideMask,_ApRimLightPower_var), _Ap_RimLight_FeatherOff )-(saturate(_VertHalfLambert_var)+_Tweak_LightDirection_MaskLevel))))), _Add_Antipodean_RimLight )); + //Composition: HighColor and RimLight as _RimLight_var + float3 _RimLight_var = lerp( Set_HighColor, (Set_HighColor+Set_RimLight), _RimLight ); + //Matcap + //v.2.0.6 : CameraRolling Stabilizer + //Mirror Script Determination: if sign_Mirror = -1, determine "Inside the mirror". + //v.2.0.7 + fixed _sign_Mirror = i.mirrorFlag; + // + float3 _Camera_Right = UNITY_MATRIX_V[0].xyz; + float3 _Camera_Front = UNITY_MATRIX_V[2].xyz; + float3 _Up_Unit = float3(0, 1, 0); + float3 _Right_Axis = cross(_Camera_Front, _Up_Unit); + //Invert if it's "inside the mirror". + if(_sign_Mirror < 0){ + _Right_Axis = -1 * _Right_Axis; + _Rotate_MatCapUV = -1 * _Rotate_MatCapUV; + }else{ + _Right_Axis = _Right_Axis; + } + float _Camera_Right_Magnitude = sqrt(_Camera_Right.x*_Camera_Right.x + _Camera_Right.y*_Camera_Right.y + _Camera_Right.z*_Camera_Right.z); + float _Right_Axis_Magnitude = sqrt(_Right_Axis.x*_Right_Axis.x + _Right_Axis.y*_Right_Axis.y + _Right_Axis.z*_Right_Axis.z); + float _Camera_Roll_Cos = dot(_Right_Axis, _Camera_Right) / (_Right_Axis_Magnitude * _Camera_Right_Magnitude); + float _Camera_Roll = acos(clamp(_Camera_Roll_Cos, -1, 1)); + fixed _Camera_Dir = _Camera_Right.y < 0 ? -1 : 1; + float _Rot_MatCapUV_var_ang = (_Rotate_MatCapUV*3.141592654) - _Camera_Dir*_Camera_Roll*_CameraRolling_Stabilizer; + //v.2.0.7 + float2 _Rot_MatCapNmUV_var = RotateUV(Set_UV0, (_Rotate_NormalMapForMatCapUV*3.141592654), float2(0.5, 0.5), 1.0); + //V.2.0.6 + float3 _NormalMapForMatCap_var = UnpackScaleNormal(tex2D(_NormalMapForMatCap,TRANSFORM_TEX(_Rot_MatCapNmUV_var, _NormalMapForMatCap)),_BumpScaleMatcap); + //v.2.0.5: MatCap with camera skew correction + float3 viewNormal = (mul(UNITY_MATRIX_V, float4(lerp( i.normalDir, mul( _NormalMapForMatCap_var.rgb, tangentTransform ).rgb, _Is_NormalMapForMatCap ),0))).rgb; + float3 NormalBlend_MatcapUV_Detail = viewNormal.rgb * float3(-1,-1,1); + float3 NormalBlend_MatcapUV_Base = (mul( UNITY_MATRIX_V, float4(viewDirection,0) ).rgb*float3(-1,-1,1)) + float3(0,0,1); + float3 noSknewViewNormal = NormalBlend_MatcapUV_Base*dot(NormalBlend_MatcapUV_Base, NormalBlend_MatcapUV_Detail)/NormalBlend_MatcapUV_Base.b - NormalBlend_MatcapUV_Detail; + float2 _ViewNormalAsMatCapUV = (lerp(noSknewViewNormal,viewNormal,_Is_Ortho).rg*0.5)+0.5; + // + //v.2.0.7 + float2 _Rot_MatCapUV_var = RotateUV((0.0 + ((_ViewNormalAsMatCapUV - (0.0+_Tweak_MatCapUV)) * (1.0 - 0.0) ) / ((1.0-_Tweak_MatCapUV) - (0.0+_Tweak_MatCapUV))), _Rot_MatCapUV_var_ang, float2(0.5, 0.5), 1.0); + //If it is "inside the mirror", flip the UV left and right. + if(_sign_Mirror < 0){ + _Rot_MatCapUV_var.x = 1-_Rot_MatCapUV_var.x; + }else{ + _Rot_MatCapUV_var = _Rot_MatCapUV_var; + } + //v.2.0.6 : LOD of Matcap + + float4 _MatCap_Sampler_var = tex2Dlod(_MatCap_Sampler,float4(TRANSFORM_TEX(_Rot_MatCapUV_var, _MatCap_Sampler),0.0,_BlurLevelMatcap)); + float4 _Set_MatcapMask_var = tex2D(_Set_MatcapMask, TRANSFORM_TEX(Set_UV0, _Set_MatcapMask)); + + float _Tweak_MatcapMaskLevel_var = saturate(lerp(_Set_MatcapMask_var.g, (1.0 - _Set_MatcapMask_var.g), _Inverse_MatcapMask) + _Tweak_MatcapMaskLevel); + float3 _Is_LightColor_MatCap_var = lerp( (_MatCap_Sampler_var.rgb*_MatCapColor.rgb), ((_MatCap_Sampler_var.rgb*_MatCapColor.rgb)*Set_LightColor), _Is_LightColor_MatCap ); + //v.2.0.6 : ShadowMask on Matcap in Blend mode : multiply + float3 Set_MatCap = lerp( _Is_LightColor_MatCap_var, (_Is_LightColor_MatCap_var*((1.0 - Set_FinalShadowMask)+(Set_FinalShadowMask*_TweakMatCapOnShadow)) + lerp(Set_HighColor*Set_FinalShadowMask*(1.0-_TweakMatCapOnShadow), float3(0.0, 0.0, 0.0), _Is_BlendAddToMatCap)), _Is_UseTweakMatCapOnShadow ); + // + //v.2.0.6 + //Composition: RimLight and MatCap as finalColor + //Broke down finalColor composition + float3 matCapColorOnAddMode = _RimLight_var+Set_MatCap*_Tweak_MatcapMaskLevel_var; + float _Tweak_MatcapMaskLevel_var_MultiplyMode = _Tweak_MatcapMaskLevel_var * lerp (1, (1 - (Set_FinalShadowMask)*(1 - _TweakMatCapOnShadow)), _Is_UseTweakMatCapOnShadow); + float3 matCapColorOnMultiplyMode = Set_HighColor*(1-_Tweak_MatcapMaskLevel_var_MultiplyMode) + Set_HighColor*Set_MatCap*_Tweak_MatcapMaskLevel_var_MultiplyMode + lerp(float3(0,0,0),Set_RimLight,_RimLight); + float3 matCapColorFinal = lerp(matCapColorOnMultiplyMode, matCapColorOnAddMode, _Is_BlendAddToMatCap); + +#if defined(_IS_ANGELRING_ON) + float3 finalColor = lerp(_RimLight_var, matCapColorFinal, _MatCap);// Final Composition before AR + //v.2.0.7 AR Camera Rolling Stabilizer + float3 _AR_OffsetU_var = lerp(mul(UNITY_MATRIX_V, float4(i.normalDir,0)).xyz,float3(0,0,1),_AR_OffsetU); + float2 AR_VN = _AR_OffsetU_var.xy*0.5 + float2(0.5,0.5); + float2 AR_VN_Rotate = RotateUV(AR_VN, -(_Camera_Dir*_Camera_Roll), float2(0.5,0.5), 1.0); + float2 _AR_OffsetV_var = float2(AR_VN_Rotate.x, lerp(i.uv1.y, AR_VN_Rotate.y, _AR_OffsetV)); + float4 _AngelRing_Sampler_var = tex2D(_AngelRing_Sampler,TRANSFORM_TEX(_AR_OffsetV_var, _AngelRing_Sampler)); + float3 _Is_LightColor_AR_var = lerp( (_AngelRing_Sampler_var.rgb*_AngelRing_Color.rgb), ((_AngelRing_Sampler_var.rgb*_AngelRing_Color.rgb)*Set_LightColor), _Is_LightColor_AR ); + float3 Set_AngelRing = _Is_LightColor_AR_var; + float Set_ARtexAlpha = _AngelRing_Sampler_var.a; + float3 Set_AngelRingWithAlpha = (_Is_LightColor_AR_var*_AngelRing_Sampler_var.a); + //Composition: MatCap and AngelRing as finalColor + finalColor = lerp(finalColor, lerp((finalColor + Set_AngelRing), ((finalColor*(1.0 - Set_ARtexAlpha))+Set_AngelRingWithAlpha), _ARSampler_AlphaOn ), _AngelRing );// Final Composition before Emissive +#else + float3 finalColor = lerp(_RimLight_var, matCapColorFinal, _MatCap);// Final Composition before Emissive + +#endif +//v.2.0.7 + +#ifdef _EMISSIVE_SIMPLE + float4 _Emissive_Tex_var = tex2D(_Emissive_Tex,TRANSFORM_TEX(Set_UV0, _Emissive_Tex)); + float emissiveMask = _Emissive_Tex_var.a; + emissive = _Emissive_Tex_var.rgb * _Emissive_Color.rgb * emissiveMask; +#elif _EMISSIVE_ANIMATION + //v.2.0.7 Calculation View Coord UV for Scroll + float3 viewNormal_Emissive = (mul(UNITY_MATRIX_V, float4(i.normalDir,0))).xyz; + float3 NormalBlend_Emissive_Detail = viewNormal_Emissive * float3(-1,-1,1); + float3 NormalBlend_Emissive_Base = (mul( UNITY_MATRIX_V, float4(viewDirection,0)).xyz*float3(-1,-1,1)) + float3(0,0,1); + float3 noSknewViewNormal_Emissive = NormalBlend_Emissive_Base*dot(NormalBlend_Emissive_Base, NormalBlend_Emissive_Detail)/NormalBlend_Emissive_Base.z - NormalBlend_Emissive_Detail; + float2 _ViewNormalAsEmissiveUV = noSknewViewNormal_Emissive.xy*0.5+0.5; + float2 _ViewCoord_UV = RotateUV(_ViewNormalAsEmissiveUV, -(_Camera_Dir*_Camera_Roll), float2(0.5,0.5), 1.0); + //If it is "inside the mirror", flip the UV left and right. + if(_sign_Mirror < 0){ + _ViewCoord_UV.x = 1-_ViewCoord_UV.x; + }else{ + _ViewCoord_UV = _ViewCoord_UV; + } + float2 emissive_uv = lerp(i.uv0, _ViewCoord_UV, _Is_ViewCoord_Scroll); + // + float4 _time_var = _Time; + float _base_Speed_var = (_time_var.g*_Base_Speed); + float _Is_PingPong_Base_var = lerp(_base_Speed_var, sin(_base_Speed_var), _Is_PingPong_Base ); + float2 scrolledUV = emissive_uv + float2(_Scroll_EmissiveU, _Scroll_EmissiveV)*_Is_PingPong_Base_var; + float rotateVelocity = _Rotate_EmissiveUV*3.141592654; + float2 _rotate_EmissiveUV_var = RotateUV(scrolledUV, rotateVelocity, float2(0.5, 0.5), _Is_PingPong_Base_var); + float4 _Emissive_Tex_var = tex2D(_Emissive_Tex,TRANSFORM_TEX(Set_UV0, _Emissive_Tex)); + float emissiveMask = _Emissive_Tex_var.a; + _Emissive_Tex_var = tex2D(_Emissive_Tex,TRANSFORM_TEX(_rotate_EmissiveUV_var, _Emissive_Tex)); + float _colorShift_Speed_var = 1.0 - cos(_time_var.g*_ColorShift_Speed); + float viewShift_var = smoothstep( 0.0, 1.0, max(0,dot(normalDirection,viewDirection))); + float4 colorShift_Color = lerp(_Emissive_Color, lerp(_Emissive_Color, _ColorShift, _colorShift_Speed_var), _Is_ColorShift); + float4 viewShift_Color = lerp(_ViewShift, colorShift_Color, viewShift_var); + float4 emissive_Color = lerp(colorShift_Color, viewShift_Color, _Is_ViewShift); + emissive = emissive_Color.rgb * _Emissive_Tex_var.rgb * emissiveMask; +#endif +// + //v.2.0.6: GI_Intensity with Intensity Multiplier Filter + float3 envLightColor = DecodeLightProbe(normalDirection) < float3(1,1,1) ? DecodeLightProbe(normalDirection) : float3(1,1,1); + float envLightIntensity = 0.299*envLightColor.r + 0.587*envLightColor.g + 0.114*envLightColor.b <1 ? (0.299*envLightColor.r + 0.587*envLightColor.g + 0.114*envLightColor.b) : 1; + //Final Composition + finalColor = saturate(finalColor) + (envLightColor*envLightIntensity*_GI_Intensity*smoothstep(1,0,envLightIntensity/2)) + emissive; + + +#elif _IS_PASS_FWDDELTA + //v.2.0.4.4 + _1st_ShadeColor_Step = saturate(_1st_ShadeColor_Step + _StepOffset); + _2nd_ShadeColor_Step = saturate(_2nd_ShadeColor_Step + _StepOffset); + // + //v.2.0.5: If Added lights is directional, set 0 as _LightIntensity + float _LightIntensity = lerp(0,(0.299*_LightColor0.r + 0.587*_LightColor0.g + 0.114*_LightColor0.b)*attenuation,_WorldSpaceLightPos0.w) ; + //v.2.0.5: Filtering the high intensity zone of PointLights + float3 Set_LightColor = lightColor; + // + float3 Set_BaseColor = lerp( (_MainTex_var.rgb*_BaseColor.rgb*_LightIntensity), ((_MainTex_var.rgb*_BaseColor.rgb)*Set_LightColor), _Is_LightColor_Base ); + //v.2.0.5 + float4 _1st_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_1st_ShadeMap,sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)),_MainTex_var,_Use_BaseAs1st); + float3 _Is_LightColor_1st_Shade_var = lerp( (_1st_ShadeMap_var.rgb*_1st_ShadeColor.rgb*_LightIntensity), ((_1st_ShadeMap_var.rgb*_1st_ShadeColor.rgb)*Set_LightColor), _Is_LightColor_1st_Shade ); + float _HalfLambert_var = 0.5*dot(lerp( i.normalDir, normalDirection, _Is_NormalMapToBase ),lightDirection)+0.5; // Half Lambert + //v.2.0.6 + float4 _ShadingGradeMap_var = tex2Dlod(_ShadingGradeMap,float4(TRANSFORM_TEX(Set_UV0, _ShadingGradeMap),0.0,_BlurLevelSGM)); + //v.2.0.6 + float _ShadingGradeMapLevel_var = _ShadingGradeMap_var.r < 0.95 ? _ShadingGradeMap_var.r+_Tweak_ShadingGradeMapLevel : 1; + float Set_ShadingGrade = saturate(_ShadingGradeMapLevel_var)*lerp( _HalfLambert_var, (_HalfLambert_var*saturate(1.0+_Tweak_SystemShadowsLevel)), _Set_SystemShadowsToBase ); + // + float Set_FinalShadowMask = saturate((1.0 + ( (Set_ShadingGrade - (_1st_ShadeColor_Step-_1st_ShadeColor_Feather)) * (0.0 - 1.0) ) / (_1st_ShadeColor_Step - (_1st_ShadeColor_Step-_1st_ShadeColor_Feather)))); // Base and 1st Shade Mask + float3 _BaseColor_var = lerp(Set_BaseColor,_Is_LightColor_1st_Shade_var,Set_FinalShadowMask); + //v.2.0.5 + float4 _2nd_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_2nd_ShadeMap,sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)),_1st_ShadeMap_var,_Use_1stAs2nd); + float Set_ShadeShadowMask = saturate((1.0 + ( (Set_ShadingGrade - (_2nd_ShadeColor_Step-_2nd_ShadeColor_Feather)) * (0.0 - 1.0) ) / (_2nd_ShadeColor_Step - (_2nd_ShadeColor_Step-_2nd_ShadeColor_Feather)))); // 1st and 2nd Shades Mask + //Composition: 3 Basic Colors as finalColor + float3 finalColor = lerp(_BaseColor_var,lerp(_Is_LightColor_1st_Shade_var,lerp( (_2nd_ShadeMap_var.rgb*_2nd_ShadeColor.rgb*_LightIntensity), ((_2nd_ShadeMap_var.rgb*_2nd_ShadeColor.rgb)*Set_LightColor), _Is_LightColor_2nd_Shade ),Set_ShadeShadowMask),Set_FinalShadowMask); + + //v.2.0.6: Add HighColor if _Is_Filter_HiCutPointLightColor is False + + float4 _Set_HighColorMask_var = tex2D(_Set_HighColorMask, TRANSFORM_TEX(Set_UV0, _Set_HighColorMask)); + + float _Specular_var = 0.5*dot(halfDirection,lerp( i.normalDir, normalDirection, _Is_NormalMapToHighColor ))+0.5; // Specular + float _TweakHighColorMask_var = (saturate((_Set_HighColorMask_var.g+_Tweak_HighColorMaskLevel))*lerp( (1.0 - step(_Specular_var,(1.0 - pow(_HighColor_Power,5)))), pow(_Specular_var,exp2(lerp(11,1,_HighColor_Power))), _Is_SpecularToHighColor )); + + float4 _HighColor_Tex_var = tex2D(_HighColor_Tex, TRANSFORM_TEX(Set_UV0, _HighColor_Tex)); + float3 _HighColor_var = (lerp( (_HighColor_Tex_var.rgb*_HighColor.rgb), ((_HighColor_Tex_var.rgb*_HighColor.rgb)*Set_LightColor), _Is_LightColor_HighColor )*_TweakHighColorMask_var); + finalColor = finalColor + lerp(lerp( _HighColor_var, (_HighColor_var*((1.0 - Set_FinalShadowMask)+(Set_FinalShadowMask*_TweakHighColorOnShadow))), _Is_UseTweakHighColorOnShadow ),float3(0,0,0),_Is_Filter_HiCutPointLightColor); + // + + finalColor = saturate(finalColor); +#endif + + +//v.2.0.4 +#ifdef _IS_TRANSCLIPPING_OFF +# ifdef _IS_PASS_FWDBASE + fixed4 finalRGBA = fixed4(finalColor,1); +# elif _IS_PASS_FWDDELTA + fixed4 finalRGBA = fixed4(finalColor,0); +# endif +#elif _IS_TRANSCLIPPING_ON + float Set_Opacity = saturate((_Inverse_Clipping_var+_Tweak_transparency)); +# ifdef _IS_PASS_FWDBASE + fixed4 finalRGBA = fixed4(finalColor,Set_Opacity); +# elif _IS_PASS_FWDDELTA + fixed4 finalRGBA = fixed4(finalColor * Set_Opacity,0); +# endif +#endif + + UNITY_APPLY_FOG(i.fogCoord, finalRGBA); + return finalRGBA; + } diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadingGradeMap.cginc.meta b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadingGradeMap.cginc.meta new file mode 100644 index 0000000..b37f069 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadingGradeMap.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 82894163e0dee9f49ab2a2441257c986 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadowCaster.cginc b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadowCaster.cginc new file mode 100644 index 0000000..837b80c --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadowCaster.cginc @@ -0,0 +1,79 @@ +//Unity Toon Shader/Legacy +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Intengrated) + + +#include "UCTS_Input.cginc" + + + struct VertexInput { + float4 vertex : POSITION; +#ifdef _IS_CLIPPING_MODE +//_Clipping + float2 texcoord0 : TEXCOORD0; +#elif _IS_CLIPPING_TRANSMODE +//_TransClipping + float2 texcoord0 : TEXCOORD0; +#elif _IS_CLIPPING_OFF +//Default +#endif + UNITY_VERTEX_INPUT_INSTANCE_ID + }; + struct VertexOutput { + V2F_SHADOW_CASTER; +#ifdef _IS_CLIPPING_MODE +//_Clipping + float2 uv0 : TEXCOORD1; +#elif _IS_CLIPPING_TRANSMODE +//_TransClipping + float2 uv0 : TEXCOORD1; +#elif _IS_CLIPPING_OFF +//Default +#endif + UNITY_VERTEX_INPUT_INSTANCE_ID + UNITY_VERTEX_OUTPUT_STEREO + }; + VertexOutput vert (VertexInput v) { + VertexOutput o = (VertexOutput)0; + UNITY_SETUP_INSTANCE_ID(v); + UNITY_TRANSFER_INSTANCE_ID(v, o); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); + +#ifdef _IS_CLIPPING_MODE +//_Clipping + o.uv0 = v.texcoord0; +#elif _IS_CLIPPING_TRANSMODE +//_TransClipping + o.uv0 = v.texcoord0; +#elif _IS_CLIPPING_OFF +//Default +#endif + o.pos = UnityObjectToClipPos( v.vertex ); + TRANSFER_SHADOW_CASTER(o) + return o; + } + float4 frag(VertexOutput i) : SV_TARGET { + UNITY_SETUP_INSTANCE_ID(i); +#ifdef _IS_CLIPPING_MODE +//_Clipping + float2 Set_UV0 = i.uv0; + float4 _ClippingMask_var = tex2D(_ClippingMask,TRANSFORM_TEX(Set_UV0, _MainTex)); + float Set_Clipping = saturate((lerp( _ClippingMask_var.r, (1.0 - _ClippingMask_var.r), _Inverse_Clipping )+_Clipping_Level)); + clip(Set_Clipping - 0.5); +#elif _IS_CLIPPING_TRANSMODE +//_TransClipping + float2 Set_UV0 = i.uv0; + + float4 _ClippingMask_var = tex2D(_ClippingMask, TRANSFORM_TEX(Set_UV0, _MainTex)); + float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)); + + float Set_MainTexAlpha = _MainTex_var.a; + float _IsBaseMapAlphaAsClippingMask_var = lerp( _ClippingMask_var.r, Set_MainTexAlpha, _IsBaseMapAlphaAsClippingMask ); + float _Inverse_Clipping_var = lerp( _IsBaseMapAlphaAsClippingMask_var, (1.0 - _IsBaseMapAlphaAsClippingMask_var), _Inverse_Clipping ); + float Set_Clipping = saturate((_Inverse_Clipping_var+_Clipping_Level)); + clip(Set_Clipping - 0.5); +#elif _IS_CLIPPING_OFF +//Default +#endif + SHADOW_CASTER_FRAGMENT(i) + } diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadowCaster.cginc.meta b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadowCaster.cginc.meta new file mode 100644 index 0000000..b3d69f8 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadowCaster.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6c5f6cfebe74fe74e9474b543a15bc99 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadowCaster_Tess.cginc b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadowCaster_Tess.cginc new file mode 100644 index 0000000..0be7ee8 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadowCaster_Tess.cginc @@ -0,0 +1,98 @@ +//Unity Toon Shader/Legacy +//nobuyuki@unity3d.com +//toshiyuki@unity3d.com (Intengrated) +//https://github.com/unity3d-jp/UnityChanToonShaderVer2_Project +// ※Tessellation support +// The corresponding code was adapted from Nora's https://github.com/Stereoarts/UnityChanToonShaderVer2_Tess. +// + +#include "UCTS_Input.cginc" + + +//Tessellation OFF +#ifndef TESSELLATION_ON + struct VertexInput { + float4 vertex : POSITION; +#ifdef _IS_CLIPPING_MODE +//_Clipping + float2 texcoord0 : TEXCOORD0; +#elif _IS_CLIPPING_TRANSMODE +//_TransClipping + float2 texcoord0 : TEXCOORD0; +#elif _IS_CLIPPING_OFF +//Default +#endif + UNITY_VERTEX_INPUT_INSTANCE_ID + }; +#endif + + struct VertexOutput { + V2F_SHADOW_CASTER; +#ifdef _IS_CLIPPING_MODE +//_Clipping + float2 uv0 : TEXCOORD1; +#elif _IS_CLIPPING_TRANSMODE +//_TransClipping + float2 uv0 : TEXCOORD1; +#elif _IS_CLIPPING_OFF +//Default +#endif + UNITY_VERTEX_INPUT_INSTANCE_ID + UNITY_VERTEX_OUTPUT_STEREO + }; + VertexOutput vert (VertexInput v) { + VertexOutput o = (VertexOutput)0; + UNITY_SETUP_INSTANCE_ID(v); + UNITY_TRANSFER_INSTANCE_ID(v, o); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); + +#ifdef _IS_CLIPPING_MODE +//_Clipping + o.uv0 = v.texcoord0; +#elif _IS_CLIPPING_TRANSMODE +//_TransClipping + o.uv0 = v.texcoord0; +#elif _IS_CLIPPING_OFF +//Default +#endif + o.pos = UnityObjectToClipPos(v.vertex ); + TRANSFER_SHADOW_CASTER(o) + return o; + } + +//Tessellation ON +#ifdef TESSELLATION_ON +#ifdef UNITY_CAN_COMPILE_TESSELLATION + // tessellation domain shader + [UNITY_domain("tri")] + VertexOutput ds_surf(UnityTessellationFactors tessFactors, const OutputPatch vi, float3 bary : SV_DomainLocation) + { + VertexInput v = _ds_VertexInput(tessFactors, vi, bary); + return vert(v); + } +#endif // UNITY_CAN_COMPILE_TESSELLATION +#endif // TESSELLATION_ON + + float4 frag(VertexOutput i) : SV_TARGET { + UNITY_SETUP_INSTANCE_ID(i); +#ifdef _IS_CLIPPING_MODE +//_Clipping + float2 Set_UV0 = i.uv0; + float4 _ClippingMask_var = tex2D(_ClippingMask,TRANSFORM_TEX(Set_UV0, _MainTex)); + float Set_Clipping = saturate((lerp( _ClippingMask_var.r, (1.0 - _ClippingMask_var.r), _Inverse_Clipping )+_Clipping_Level)); + clip(Set_Clipping - 0.5); +#elif _IS_CLIPPING_TRANSMODE +//_TransClipping + float2 Set_UV0 = i.uv0; + float4 _ClippingMask_var = tex2D(_ClippingMask,TRANSFORM_TEX(Set_UV0, _MainTex)); + float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,TRANSFORM_TEX(Set_UV0, _MainTex)); + float Set_MainTexAlpha = _MainTex_var.a; + float _IsBaseMapAlphaAsClippingMask_var = lerp( _ClippingMask_var.r, Set_MainTexAlpha, _IsBaseMapAlphaAsClippingMask ); + float _Inverse_Clipping_var = lerp( _IsBaseMapAlphaAsClippingMask_var, (1.0 - _IsBaseMapAlphaAsClippingMask_var), _Inverse_Clipping ); + float Set_Clipping = saturate((_Inverse_Clipping_var+_Clipping_Level)); + clip(Set_Clipping - 0.5); +#elif _IS_CLIPPING_OFF +//Default +#endif + SHADOW_CASTER_FRAGMENT(i) + } diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadowCaster_Tess.cginc.meta b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadowCaster_Tess.cginc.meta new file mode 100644 index 0000000..177c9a3 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_ShadowCaster_Tess.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ad5a3340a7fb20141afd70a94bbdddac +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Tess.cginc b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Tess.cginc new file mode 100644 index 0000000..3cd9bfe --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Tess.cginc @@ -0,0 +1,95 @@ +//UCTS_Tess.cginc +//nobuyuki@unity3d.com +//https://github.com/unity3d-jp/UnityChanToonShaderVer2_Project +//(C)Unity Technologies Japan/UCL + +#ifndef UCTS_TESS +#define UCTS_TESS + +#ifdef TESSELLATION_ON +#include "HLSLSupport.cginc" // UNITY_CAN_COMPILE_TESSELLATION +#include "Lighting.cginc" // UnityTessellationFactors +#include "Tessellation.cginc" + +#ifdef UNITY_CAN_COMPILE_TESSELLATION + +float _TessPhongStrength; +float _TessEdgeLength; +float _TessExtrusionAmount; + +struct VertexInput +{ + float4 vertex : POSITION; + float4 tangent : TANGENT; + float3 normal : NORMAL; + float4 texcoord0 : TEXCOORD0; + float4 texcoord1 : TEXCOORD1; + UNITY_VERTEX_INPUT_INSTANCE_ID // +}; + +struct InternalTessInterp_VertexInput +{ + float4 vertex : INTERNALTESSPOS; + float4 tangent : TANGENT; + float3 normal : NORMAL; + float4 texcoord0 : TEXCOORD0; + float4 texcoord1 : TEXCOORD1; + UNITY_VERTEX_INPUT_INSTANCE_ID // +}; + +InternalTessInterp_VertexInput tess_VertexInput(VertexInput v) +{ + InternalTessInterp_VertexInput o; + o.vertex = v.vertex; + o.tangent = v.tangent; + o.normal = v.normal; + o.texcoord0 = v.texcoord0; + o.texcoord1 = v.texcoord1; + UNITY_TRANSFER_INSTANCE_ID(v,o); + return o; +} + +// tessellation hull constant shader +UnityTessellationFactors hsconst_VertexInput(InputPatch v) +{ + float4 tf = UnityEdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, _TessEdgeLength); + UnityTessellationFactors o; + o.edge[0] = tf.x; + o.edge[1] = tf.y; + o.edge[2] = tf.z; + o.inside = tf.w; + return o; +} + +// tessellation hull shader +[UNITY_domain("tri")] +[UNITY_partitioning("fractional_odd")] +[UNITY_outputtopology("triangle_cw")] +[UNITY_patchconstantfunc("hsconst_VertexInput")] +[UNITY_outputcontrolpoints(3)] +InternalTessInterp_VertexInput hs_VertexInput(InputPatch v, uint id : SV_OutputControlPointID) +{ + return v[id]; +} + +inline VertexInput _ds_VertexInput(UnityTessellationFactors tessFactors, const OutputPatch vi, float3 bary : SV_DomainLocation) +{ + VertexInput v; + v.vertex = vi[0].vertex*bary.x + vi[1].vertex*bary.y + vi[2].vertex*bary.z; + float3 pp[3]; + for (int i = 0; i < 3; ++i) + pp[i] = v.vertex.xyz - vi[i].normal * (dot(v.vertex.xyz, vi[i].normal) - dot(vi[i].vertex.xyz, vi[i].normal)); + v.vertex.xyz = _TessPhongStrength * (pp[0] * bary.x + pp[1] * bary.y + pp[2] * bary.z) + (1.0f - _TessPhongStrength) * v.vertex.xyz; + v.tangent = vi[0].tangent*bary.x + vi[1].tangent*bary.y + vi[2].tangent*bary.z; + v.normal = vi[0].normal*bary.x + vi[1].normal*bary.y + vi[2].normal*bary.z; + v.vertex.xyz += v.normal.xyz * _TessExtrusionAmount; + v.texcoord0 = vi[0].texcoord0*bary.x + vi[1].texcoord0*bary.y + vi[2].texcoord0*bary.z; + v.texcoord1 = vi[0].texcoord1*bary.x + vi[1].texcoord1*bary.y + vi[2].texcoord1*bary.z; + UNITY_TRANSFER_INSTANCE_ID(vi[0], v); + return v; +} + +#endif // UNITY_CAN_COMPILE_TESSELLATION +#endif // TESSELLATION_ON + +#endif // UCTS_TESS diff --git a/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Tess.cginc.meta b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Tess.cginc.meta new file mode 100644 index 0000000..ccb185b --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Legacy/Shaders/UCTS_Tess.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9d8eecfad09d5ad42be63601b8a1a468 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/ModelToonEvAdjustment.cs b/BJH/Assets/BJH/3dtest/Runtime/ModelToonEvAdjustment.cs new file mode 100644 index 0000000..5cd0fa8 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/ModelToonEvAdjustment.cs @@ -0,0 +1,292 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif +using UnityEngine.Rendering; +using UnityEngine.Experimental.Rendering; +using UnityObject = UnityEngine.Object; +using System.Linq; + +namespace Unity.Rendering.Toon +{ + [ExecuteAlways] + [DisallowMultipleComponent] + [UTSHelpURL("ToonEVAdjustment")] + + + internal class ModelToonEvAdjustment : MonoBehaviour + { + const string kCompensationPorpName = "_ToonEvAdjustmentCompensation"; + const string kExposureAdjustmentPropName = "_ToonEvAdjustmentCurve"; + const string kExposureArrayPropName = "_ToonEvAdjustmentValueArray"; + const string kExposureMinPropName = "_ToonEvAdjustmentValueMin"; + const string kExposureMaxPropName = "_ToonEvAdjustmentValueMax"; + const string kToonLightFilterPropName = "_ToonLightHiCutFilter"; + + // flags + bool m_initialized = false; + bool m_srpCallbackInitialized = false; + + const int kAdjustmentCurvePrecision = 128; + + + + + [SerializeField] + internal bool m_ToonLightHiCutFilter = false; + [SerializeField] + internal bool m_ExposureAdjustmnt = false; + [SerializeField] + internal bool m_IgnorVolumeExposure = false; + [SerializeField] + internal AnimationCurve m_AnimationCurve = DefaultAnimationCurve(); + [SerializeField] + internal float[] m_ExposureArray; + [SerializeField] + internal float m_Max, m_Min; + [SerializeField] + internal float m_Compensation; + + internal GameObject[] m_Objs; + [SerializeField] +// [HideInInspector] + Renderer[] m_Renderers; + [SerializeField] +// [HideInInspector] + MaterialPropertyBlock[] m_MaterialPropertyBlocks; + +#if UNITY_EDITOR +#pragma warning restore CS0414 + bool m_isCompiling = false; +#endif + + void Reset() + { + OnDisable(); + OnEnable(); + DefaultAnimationCurve(); + } + + void OnValidate() + { + Release(); + Initialize(); + } + static AnimationCurve DefaultAnimationCurve() + { + return AnimationCurve.Linear(-10f, -10f, -1.32f, -1.32f); + } + + private void Awake() + { + Initialize(); + + } + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + if (m_Renderers == null || m_Renderers.Length == 0) + { + return; + } + + Initialize(); + + + + // Fail safe in case the curve is deleted / has 0 point + var curve = m_AnimationCurve; + + + if (curve == null || curve.length == 0) + { + m_Min = 0f; + m_Max = 0f; + + for (int i = 0; i < kAdjustmentCurvePrecision; i++) + m_ExposureArray[i] = 0.0f; + } + else + { + m_Min = curve[0].time; + m_Max = curve[curve.length - 1].time; + float step = (m_Max - m_Min) / (kAdjustmentCurvePrecision - 1f); + + for (int i = 0; i < kAdjustmentCurvePrecision; i++) + m_ExposureArray[i] = curve.Evaluate(m_Min + step * i); + } + + +#if UNITY_EDITOR + // handle script recompile + if (EditorApplication.isCompiling && !m_isCompiling) + { + // on compile begin + m_isCompiling = true; + // Release(); no need + return; // + } + else if (!EditorApplication.isCompiling && m_isCompiling) + { + // on compile end + m_isCompiling = false; + } +#endif + + + + int length = m_Renderers.Length; + for (int ii = 0; ii < length; ii++) + { + m_Renderers[ii].GetPropertyBlock(m_MaterialPropertyBlocks[ii]); + + m_MaterialPropertyBlocks[ii].SetFloatArray(kExposureArrayPropName, m_ExposureArray); + m_MaterialPropertyBlocks[ii].SetFloat(kExposureMinPropName, m_Min); + m_MaterialPropertyBlocks[ii].SetFloat(kExposureMaxPropName, m_Max); + m_MaterialPropertyBlocks[ii].SetInt(kExposureAdjustmentPropName, m_ExposureAdjustmnt ? 1 : 0); + m_MaterialPropertyBlocks[ii].SetInt(kToonLightFilterPropName, m_ToonLightHiCutFilter ? 1 : 0); + m_MaterialPropertyBlocks[ii].SetFloat(kCompensationPorpName, m_Compensation); + + m_Renderers[ii].SetPropertyBlock(m_MaterialPropertyBlocks[ii]); + } + + } + void EnableSrpCallbacks() + { + + if (!m_srpCallbackInitialized) + { + m_srpCallbackInitialized = true; + } + } + void DisableSrpCallbacks() + { + if (m_srpCallbackInitialized) + { + m_srpCallbackInitialized = false; + } + } + + void OnEnable() + { + + Initialize(); + + EnableSrpCallbacks(); + + } + + void OnDisable() + { + DisableSrpCallbacks(); + + Release(); + } + + void Initialize() + { + if (m_initialized) + { + return; + } +#if UNITY_EDITOR + // initializing renderer can interfere GI baking. so wait until it is completed. + + if (EditorApplication.isCompiling) + return; +#endif + // must be put to gameObject model chain. + if (m_Objs == null || m_Objs.Length == 0) + { + m_Objs = new GameObject[1]; + m_Objs[0] = this.gameObject; + } + int objCount = m_Objs.Length; + int rendererCount = 0; + + List rendererList = new List(); + for (int ii = 0; ii < objCount; ii++) + { + if (m_Objs[ii] == null ) + { + continue; + } + + + var renderer = m_Objs[ii].GetComponent(); + if (renderer != null) + { + rendererCount++; + rendererList.Add(renderer); + } + GameObject[] childGameObjects = m_Objs[ii].GetComponentsInChildren().Select(t => t.gameObject).ToArray(); + int childCount = childGameObjects.Length; + for (int jj = 0; jj < childCount; jj++) + { + if (m_Objs[ii] == childGameObjects[jj]) + continue; + var modelToonEvAdjustment = childGameObjects[jj].GetComponent(); + if ( modelToonEvAdjustment != null ) + { + + break; + } + renderer = childGameObjects[jj].GetComponent(); + if ( renderer != null ) + { + rendererList.Add(renderer); + rendererCount++; + } + } + } + if (rendererCount != 0) + { + + m_MaterialPropertyBlocks = new MaterialPropertyBlock[rendererCount]; + m_Renderers = rendererList.ToArray(); + + + for (int ii = 0; ii < rendererCount; ii++) + { + m_MaterialPropertyBlocks[ii] = new MaterialPropertyBlock(); + } + } + if (m_ExposureArray == null || m_ExposureArray.Length != kAdjustmentCurvePrecision) + { + m_ExposureArray = new float[kAdjustmentCurvePrecision]; + } + m_initialized = true; + } + + + void Release() + { + if (m_initialized) + { + m_ExposureArray = null; + if (m_Renderers != null ) + { + int length = m_Renderers.Length; + for (int ii = 0; ii < length; ii++) + { + m_Renderers[ii].SetPropertyBlock(null); + } + } + m_Renderers = null; + m_MaterialPropertyBlocks = null; + } + + m_initialized = false; + + } + + } +} \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/ModelToonEvAdjustment.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/ModelToonEvAdjustment.cs.meta new file mode 100644 index 0000000..3f64cb4 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/ModelToonEvAdjustment.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cd255a2dd4fd0764d86c685787b0762c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/SceneToonEvAdjustment.cs b/BJH/Assets/BJH/3dtest/Runtime/SceneToonEvAdjustment.cs new file mode 100644 index 0000000..dac90ed --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/SceneToonEvAdjustment.cs @@ -0,0 +1,211 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif +using UnityEngine.Rendering; +using UnityEngine.Experimental.Rendering; +using UnityObject = UnityEngine.Object; +namespace Unity.Rendering.Toon +{ + + + [ExecuteAlways] + [DisallowMultipleComponent] + [UTSHelpURL("ToonEVAdjustment")] + + internal class SceneToonEvAdjustment : MonoBehaviour + { + // flags + bool m_initialized = false; + bool m_srpCallbackInitialized = false; + + const int kAdjustmentCurvePrecision = 128; + + const string kCompensationPorpName = "_ToonEvAdjustmentCompensation"; + const string kExposureAdjustmentPropName = "_ToonEvAdjustmentCurve"; + const string kExposureArrayPropName = "_ToonEvAdjustmentValueArray"; + const string kExposureMinPropName = "_ToonEvAdjustmentValueMin"; + const string kExposureMaxPropName = "_ToonEvAdjustmentValueMax"; + const string kToonLightFilterPropName = "_ToonLightHiCutFilter"; + const string kIgonoreVolumeExposurePropName = "_ToonIgnoreExposureMultiplier"; + + [SerializeField] + internal bool m_ToonLightHiCutFilter= false; + [SerializeField] + internal bool m_ExposureAdjustmnt = false; + [SerializeField] + internal bool m_IgnorVolumeExposure= false; + [SerializeField] + internal AnimationCurve m_AnimationCurve = DefaultAnimationCurve(); + [SerializeField] + internal float[] m_ExposureArray; + [SerializeField] + internal float m_Max, m_Min; + [SerializeField] + internal float m_Compensation; + + + private static SceneToonEvAdjustment instance; +#if UNITY_EDITOR +#pragma warning restore CS0414 + bool m_isCompiling = false; +#endif + + + void Awake() + { + if (instance == null) + { + instance = this as SceneToonEvAdjustment; + return; + } + else if (instance == this) + { + return ; + } + Debug.LogError("There is ToonEvAdjustmentCurve instance in hierarchy."); +#if UNITY_EDITOR + DestroyImmediate(this); + Selection.activeGameObject = instance.gameObject; +#else + Destroy(this); +#endif + } + + void Reset() + { + OnDisable(); + OnEnable(); + DefaultAnimationCurve(); + } + + internal static AnimationCurve DefaultAnimationCurve() + { + return AnimationCurve.Linear(-10f, -10f, -1.32f, -1.32f); + } + void Update() + { + + Initialize(); + + + + // Fail safe in case the curve is deleted / has 0 point + var curve = m_AnimationCurve; + + + if (curve == null || curve.length == 0) + { + m_Min = 0f; + m_Max = 0f; + + for (int i = 0; i < kAdjustmentCurvePrecision; i++) + m_ExposureArray[i] = 0.0f; + } + else + { + m_Min = curve[0].time; + m_Max = curve[curve.length - 1].time; + float step = (m_Max - m_Min) / (kAdjustmentCurvePrecision - 1f); + + for (int i = 0; i < kAdjustmentCurvePrecision; i++) + m_ExposureArray[i] = curve.Evaluate(m_Min + step * i); + } + + +#if UNITY_EDITOR + // handle script recompile + if (EditorApplication.isCompiling && !m_isCompiling) + { + // on compile begin + m_isCompiling = true; + // Release(); no need + return; // + } + else if (!EditorApplication.isCompiling && m_isCompiling) + { + // on compile end + m_isCompiling = false; + } +#endif + Shader.SetGlobalFloatArray(kExposureArrayPropName, m_ExposureArray); + Shader.SetGlobalFloat(kExposureMinPropName, m_Min); + Shader.SetGlobalFloat(kExposureMaxPropName, m_Max); + Shader.SetGlobalInt(kExposureAdjustmentPropName, m_ExposureAdjustmnt ? 1 : 0); + Shader.SetGlobalInt(kToonLightFilterPropName, m_ToonLightHiCutFilter ? 1 : 0); + Shader.SetGlobalInt(kIgonoreVolumeExposurePropName, m_IgnorVolumeExposure ? 1: 0); + Shader.SetGlobalFloat(kCompensationPorpName, m_Compensation); + } + + void EnableSrpCallbacks() + { + + if (!m_srpCallbackInitialized) + { + m_srpCallbackInitialized = true; + } + } + void DisableSrpCallbacks() + { + if (m_srpCallbackInitialized) + { + m_srpCallbackInitialized = false; + } + } + + void OnEnable() + { + + Initialize(); + + EnableSrpCallbacks(); + + } + + void OnDisable() + { + DisableSrpCallbacks(); + + Release(); + } + + void Initialize() + { + if (m_initialized) + { + return; + } +#if UNITY_EDITOR + // initializing renderer can interfere GI baking. so wait until it is completed. + + if (EditorApplication.isCompiling) + return; +#endif + + if (m_ExposureArray == null || m_ExposureArray.Length != kAdjustmentCurvePrecision ) + { + m_ExposureArray = new float[kAdjustmentCurvePrecision]; + } + m_initialized = true; + } + + + void Release() + { + if (m_initialized) + { + m_ExposureArray = null; + Shader.SetGlobalInt(kExposureAdjustmentPropName, 0); + Shader.SetGlobalInt(kToonLightFilterPropName, 0); + } + + m_initialized = false; + + } + + } + + +} diff --git a/BJH/Assets/BJH/3dtest/Runtime/SceneToonEvAdjustment.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/SceneToonEvAdjustment.cs.meta new file mode 100644 index 0000000..bd81308 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/SceneToonEvAdjustment.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: db8edd5c572b6e648974dac4815d5619 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts.meta b/BJH/Assets/BJH/3dtest/Runtime/Scripts.meta new file mode 100644 index 0000000..bbd69dc --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9c029c2c043c4774eb2dd9158a1e30c7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/MaterialPropertyValue.cs b/BJH/Assets/BJH/3dtest/Runtime/Scripts/MaterialPropertyValue.cs new file mode 100644 index 0000000..6a315e8 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/MaterialPropertyValue.cs @@ -0,0 +1,74 @@ +using UnityEngine; +using UnityEngine.Rendering; + +namespace Unity.Rendering.Toon { + +[System.Serializable] +internal class MaterialPropertyValue { + internal static MaterialPropertyValue FromMaterial(Material mat, int propIndex) { + MaterialPropertyValue value = new MaterialPropertyValue(); + Shader shader = mat.shader; + string name = shader.GetPropertyName(propIndex); + ShaderPropertyType type = shader.GetPropertyType(propIndex); + value.type = type; + + switch (type) { + case ShaderPropertyType.Color: + value.color = mat.GetColor(name); + break; + case ShaderPropertyType.Vector: + value.vector = mat.GetVector(name); + break; + case ShaderPropertyType.Float: + case ShaderPropertyType.Range: + value.floatValue = mat.GetFloat(name); + break; + case ShaderPropertyType.Texture: + value.texture = mat.GetTexture(name); + value.texOffset = mat.GetTextureOffset(name); + value.texScale = mat.GetTextureScale(name); + break; + } + + return value; + } + + internal void ApplyToMaterial(Material mat, string targetName) { + if (!mat.HasProperty(targetName)) { + Debug.LogWarning($"[UTS] material {mat.name} does not have property: {targetName}"); + return; + } + + switch (type) { + case ShaderPropertyType.Color: + mat.SetColor(targetName, color); + break; + case ShaderPropertyType.Vector: + mat.SetVector(targetName, vector); + break; + case ShaderPropertyType.Float: + case ShaderPropertyType.Range: + mat.SetFloat(targetName, floatValue); + break; + case ShaderPropertyType.Texture: + mat.SetTexture(targetName, texture); + mat.SetTextureOffset(targetName, texOffset); + mat.SetTextureScale(targetName, texScale); + break; + } + } + +//---------------------------------------------------------------------------------------------------------------------- + + internal ShaderPropertyType type; + internal Color color; + internal Vector4 vector; + internal float floatValue; + internal Texture texture; + internal Vector2 texOffset; + internal Vector2 texScale; + + +} + +} //end namespace \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/MaterialPropertyValue.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/Scripts/MaterialPropertyValue.cs.meta new file mode 100644 index 0000000..93e1839 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/MaterialPropertyValue.cs.meta @@ -0,0 +1,20 @@ +fileFormatVersion: 2 +guid: 7e6477a593c3822458f6dfb35bfa9675 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: + - m_ViewDataDictionary: {instanceID: 0} + - converterEditorAsset: {fileID: 9197481963319205126, guid: aa3c5f92dd380f54e9fe27e4da1648bd, + type: 3} + - converterItem: {fileID: 9197481963319205126, guid: 3ae32bee832b0a0499b14ad8646ba6af, + type: 3} + - converterWidgetMainAsset: {fileID: 9197481963319205126, guid: 7142661a783b06f42a6130280bed87a3, + type: 3} + - converterItemMaterial: {fileID: 9197481963319205126, guid: 136a2f7bdc5291a47b8c54e9e3ef0d37, + type: 3} + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonCameraViewController.cs b/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonCameraViewController.cs new file mode 100644 index 0000000..12eb566 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonCameraViewController.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace Unity.Rendering.Toon { + +[ExecuteAlways] +internal class ToonCameraViewController : MonoBehaviour { + private void OnEnable() { + m_transform = transform; + } + + void Update() { + Vector3 pos = m_transform.position; + foreach (Material mat in m_materials) { + if (mat == null) continue; + mat.SetVector(ToonConstants.SHADER_PROP_DIRECTIONAL_LIGHT_VIEW_POSITION, pos); + } + } + + +//---------------------------------------------------------------------------------------------------------------------- + [SerializeField] private List m_materials = new List(); + + private Transform m_transform; +} + +} \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonCameraViewController.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonCameraViewController.cs.meta new file mode 100644 index 0000000..c6f5c36 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonCameraViewController.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 76eb1733b1eefbe4fb94e0398915fc49 diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonConstants.cs b/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonConstants.cs new file mode 100644 index 0000000..806db06 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonConstants.cs @@ -0,0 +1,103 @@ + +using UnityEngine; + +namespace Unity.Rendering.Toon { + +internal static class ToonConstants { + + internal const string PACKAGE_NAME = "com.unity.toonshader"; + internal const string PACKAGE_VERSION_MAJOR_MINOR = "0.13"; + + internal const string SHADER_KEYWORD_IS_CLIPPING_MATTE = "_IS_CLIPPING_MATTE"; + + internal static readonly int SHADER_PROPERTY_CLIPPING_MATTE_MODE = Shader.PropertyToID("_ClippingMatteMode"); + + internal static readonly int SHADER_PROPERTY_BASE_COLOR_VISIBLE = Shader.PropertyToID("_BaseColorVisible"); + internal static readonly int SHADER_PROPERTY_FIRST_SHADE_VISIBLE = Shader.PropertyToID("_FirstShadeVisible"); + internal static readonly int SHADER_PROPERTY_SECOND_SHADE_VISIBLE = Shader.PropertyToID("_SecondShadeVisible"); + internal static readonly int SHADER_PROPERTY_HIGHLIGHT_VISIBLE = Shader.PropertyToID("_HighlightVisible"); + internal static readonly int SHADER_PROPERTY_ANGEL_RING_VISIBLE = Shader.PropertyToID("_AngelRingVisible"); + internal static readonly int SHADER_PROPERTY_RIM_LIGHT_VISIBLE = Shader.PropertyToID("_RimLightVisible"); + internal static readonly int SHADER_PROPERTY_OUTLINE_VISIBLE = Shader.PropertyToID("_OutlineVisible"); + + internal static readonly int SHADER_PROPERTY_COMPOSER_MASK_MODE = Shader.PropertyToID("_ComposerMaskMode"); + + internal static readonly int SHADER_PROPERTY_BASE_COLOR_MASK_COLOR = Shader.PropertyToID("_BaseColorMaskColor"); + internal static readonly int SHADER_PROPERTY_FIRST_SHADE_MASK_COLOR = Shader.PropertyToID("_FirstShadeMaskColor"); + internal static readonly int SHADER_PROPERTY_SECOND_SHADE_MASK_COLOR = Shader.PropertyToID("_SecondShadeMaskColor"); + internal static readonly int SHADER_PROPERTY_HIGHLIGHT_MASK_COLOR = Shader.PropertyToID("_HighlightMaskColor"); + internal static readonly int SHADER_PROPERTY_ANGEL_RING_MASK_COLOR = Shader.PropertyToID("_AngelRingMaskColor"); + internal static readonly int SHADER_PROPERTY_RIM_LIGHT_MASK_COLOR = Shader.PropertyToID("_RimLightMaskColor"); + internal static readonly int SHADER_PROPERTY_OUTLINE_MASK_COLOR = Shader.PropertyToID("_OutlineMaskColor"); + + //Common constants + //Colors + internal const string SHADER_PROP_BASE_COLOR = "_BaseColor"; + internal const string SHADER_PROP_MAIN_TEX = "_MainTex"; + + internal const string SHADER_PROP_NORMAL_MAP = "_NormalMap"; + internal const string SHADER_PROP_BUMP_SCALE = "_BumpScale"; + + internal const string SHADER_PROP_1_ST_SHADE_COLOR = "_1st_ShadeColor"; + internal const string SHADER_PROP_1_ST_SHADE_MAP = "_1st_ShadeMap"; + internal const string SHADER_PROP_USE_BASE_AS_1ST = "_Use_BaseAs1st"; + + internal const string SHADER_PROP_2ND_SHADE_COLOR = "_2nd_ShadeColor"; + internal const string SHADER_PROP_2ND_SHADE_MAP = "_2nd_ShadeMap"; + internal const string SHADER_PROP_USE_1ST_AS_2ND = "_Use_1stAs2nd"; + + //Shading + internal const string SHADER_PROP_BASE_TO_1ST_SHADE_START = "_BaseTo1st_ShadeStart"; + internal const string SHADER_PROP_BASE_TO_1ST_SHADE_FEATHER = "_BaseTo1st_ShadeFeather"; + internal const string SHADER_PROP_1ST_TO_2ND_SHADE_START = "_1stTo2nd_ShadeStart"; + internal const string SHADER_PROP_1ST_TO_2ND_SHADE_FEATHER = "_1stTo2nd_ShadeFeather"; + + + //Lighting + internal const string SHADER_PROP_2D_LIGHT_STRENGTH = "_2DLightStrength"; + internal const string SHADER_PROP_DIRECTIONAL_LIGHT_USE = "_DirectionalLight_Use"; + internal const string SHADER_PROP_DIRECTIONAL_LIGHT_DIFFUSE_STRENGTH = "_DirectionalLight_DiffuseStrength"; + internal const string SHADER_PROP_DIRECTIONAL_LIGHT_HIGHLIGHT_MODE = "_DirectionalLight_HighlightMode"; + internal const string SHADER_PROP_DIRECTIONAL_LIGHT_HIGHLIGHT_STRENGTH = "_DirectionalLight_HighlightStrength"; + internal const string SHADER_PROP_DIRECTIONAL_LIGHT_HIGHLIGHT_SIZE = "_DirectionalLight_HighlightSize"; + + //Highlight + internal const string SHADER_PROP_HIGHLIGHT_COLOR = "_HighlightColor"; + internal const string SHADER_PROP_HIGHLIGHT_TEX = "_HighlightTex"; + + //Outline + internal const string SHADER_PROP_OUTLINE_MODE = "_OutlineMode"; + internal static readonly int SHADER_PROP_OUTLINE_MODE_ID = Shader.PropertyToID(SHADER_PROP_OUTLINE_MODE); + internal const string SHADER_PROP_OUTLINE_WIDTH = "_OutlineWidth"; + internal const string SHADER_PROP_OUTLINE_WIDTH_MAP = "_OutlineWidthMap"; + internal const string SHADER_PROP_OUTLINE_TEX = "_OutlineTex"; + internal const string SHADER_PROP_OUTLINE_COLOR = "_OutlineColor"; + internal const string SHADER_PROP_OUTLINE_BASE_COLOR_BLEND = "_Outline_BaseColorBlend"; + internal const string SHADER_PROP_OUTLINE_LIGHT_COLOR_BLEND = "_Outline_LightColorBlend"; + internal const string SHADER_PROP_OUTLINE_OFFSET_Z = "_OutlineOffsetZ"; + internal const string SHADER_PROP_OUTLINE_NEAR = "_OutlineNear"; + internal const string SHADER_PROP_OUTLINE_FAR = "_OutlineFar"; + internal const string SHADER_PROP_OUTLINE_USE_NORMAL_MAP = "_Outline_UseNormalMap"; + internal const string SHADER_PROP_OUTLINE_NORMAL_MAP = "_Outline_NormalMap"; + + internal static readonly int SHADER_PROPERTY_MATERIAL_VERSION = Shader.PropertyToID("_ToonMaterialVersion"); + + internal const string SHADER_PROP_DIRECTIONAL_LIGHT_DIRECTION = "_DirectionalLight_Direction"; + internal const string SHADER_PROP_DIRECTIONAL_LIGHT_COLOR = "_DirectionalLight_Color"; + internal const string SHADER_PROP_DIRECTIONAL_LIGHT_INTENSITY = "_DirectionalLight_Intensity"; + + internal const string SHADER_PROP_DIRECTIONAL_LIGHT_VIEW_POSITION = "_DirectionalLight_ViewPosition"; + + //Doc: Use this LightMode tag value to draw an extra Pass when rendering objects. + internal const string SHADER_LIGHT_MODE_NAME_FOR_OUTLINE = "SRPDefaultUnlit"; + + + internal const string GBUFFER_PASS_NAME = "GBuffer"; + + internal const string SHADER_KEYWORD_RP_BUILTIN = "UTS_RP_BUILTIN"; + +} + + + +} //end namespace \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonConstants.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonConstants.cs.meta new file mode 100644 index 0000000..9e26def --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonConstants.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 478afbf544da4da4294c03288e83da4c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonDirectionalLightController.cs b/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonDirectionalLightController.cs new file mode 100644 index 0000000..a3c3710 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonDirectionalLightController.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace Unity.Rendering.Toon { + +[ExecuteAlways] +[RequireComponent(typeof(Light))] +internal class ToonDirectionalLightController : MonoBehaviour { + void OnEnable() { + m_light = GetComponent(); + } + + + void Update() { + if (m_light.type != LightType.Directional) { + return; + } + + Vector3 lightDir = m_light.transform.forward; + Color lightColor = m_light.color; + float lightIntensity = m_light.intensity; + + foreach (Material mat in m_materials) { + if (mat == null) continue; + mat.SetVector(ToonConstants.SHADER_PROP_DIRECTIONAL_LIGHT_DIRECTION, lightDir); + mat.SetColor(ToonConstants.SHADER_PROP_DIRECTIONAL_LIGHT_COLOR, lightColor); + mat.SetFloat(ToonConstants.SHADER_PROP_DIRECTIONAL_LIGHT_INTENSITY, lightIntensity); + } + } + + +//---------------------------------------------------------------------------------------------------------------------- + [SerializeField] private List m_materials = new List(); + +//---------------------------------------------------------------------------------------------------------------------- + Light m_light; +} + +} \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonDirectionalLightController.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonDirectionalLightController.cs.meta new file mode 100644 index 0000000..801eab1 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonDirectionalLightController.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 95eb0866ac8fd424c8dfba8d023d36df \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonOutlineMode.cs b/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonOutlineMode.cs new file mode 100644 index 0000000..8be3817 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonOutlineMode.cs @@ -0,0 +1,11 @@ + + +namespace Unity.Rendering.Toon { + +internal enum ToonOutlineMode { + NormalDirection, + PositionScaling +} + + +} //end namespace \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonOutlineMode.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonOutlineMode.cs.meta new file mode 100644 index 0000000..a50c0dd --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/ToonOutlineMode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e237949f5a98d084d9c1f129d19ccfc4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities.meta b/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities.meta new file mode 100644 index 0000000..086e5a2 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bcd11e5e1846e854f98c349104ae4134 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/Toon3Das2DMaterialUtility.cs b/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/Toon3Das2DMaterialUtility.cs new file mode 100644 index 0000000..eebda20 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/Toon3Das2DMaterialUtility.cs @@ -0,0 +1,46 @@ + +using UnityEngine; + +namespace Unity.Rendering.Toon { + +internal static class Toon3Das2DMaterialUtility { + + internal static bool IsOutlineEnabled(Material m) { + return m.GetShaderPassEnabled(ToonConstants.SHADER_LIGHT_MODE_NAME_FOR_OUTLINE); + } + + internal static void EnableOutline(Material m, bool enabled) { + m.SetShaderPassEnabled(ToonConstants.SHADER_LIGHT_MODE_NAME_FOR_OUTLINE, enabled); + } + + internal static void SetOutlineMode(Material[] mats, ToonOutlineMode outlineMode) { + + foreach (Material m in mats) { + m.SetInteger(ToonConstants.SHADER_PROP_OUTLINE_MODE_ID, (int) outlineMode); + } + + const string OUTLINE_NORMAL_KEYWORD = "TOON_OUTLINE_NORMAL"; + const string OUTLINE_POSITION_KEYWORD = "TOON_OUTLINE_POS"; + + switch (outlineMode) { + case ToonOutlineMode.NormalDirection: + foreach (Material m in mats) { + m.EnableKeyword(OUTLINE_NORMAL_KEYWORD); + m.DisableKeyword(OUTLINE_POSITION_KEYWORD); + } + + break; + case ToonOutlineMode.PositionScaling: + foreach (Material m in mats) { + m.DisableKeyword(OUTLINE_NORMAL_KEYWORD); + m.EnableKeyword(OUTLINE_POSITION_KEYWORD); + } + + break; + } + + } + +} + +} \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/Toon3Das2DMaterialUtility.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/Toon3Das2DMaterialUtility.cs.meta new file mode 100644 index 0000000..6d61ea0 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/Toon3Das2DMaterialUtility.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 1f6f8d2fae7ab014fa7390f1242434db diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/ToonEnumUtility.cs b/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/ToonEnumUtility.cs new file mode 100644 index 0000000..3377296 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/ToonEnumUtility.cs @@ -0,0 +1,43 @@ + +using System; +using System.Collections.Generic; +using System.Reflection; +using UnityEngine; + +namespace Unity.Rendering.Toon { + +internal static class ToonEnumUtility { + internal static GUIContent[] ToInspectorNamesAsGUIContent(Type t) { + MemberInfo[] members = t.GetMembers(BindingFlags.Static | BindingFlags.Public); + + int numMembers = members.Length; + GUIContent[] ret = new GUIContent[numMembers]; + for (int i = 0; i < numMembers; i++) { + InspectorNameAttribute inspectorNameAttribute = (InspectorNameAttribute)Attribute.GetCustomAttribute( + members[i], typeof(InspectorNameAttribute)); + if (inspectorNameAttribute == null) { + ret[i] = new GUIContent(members[i].Name); + } else { + ret[i] = new GUIContent(inspectorNameAttribute.displayName); + } + } + + return ret; + } + + internal static int[] ToIndices(Type t) { + + MemberInfo[] members = t.GetMembers(BindingFlags.Static | BindingFlags.Public); + int numMembers = members.Length; + int[] indices = new int[numMembers]; + for (int i = 0; i < numMembers; ++i) { + indices[i] = i; + } + + return indices; + + } + +} + +} \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/ToonEnumUtility.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/ToonEnumUtility.cs.meta new file mode 100644 index 0000000..cb73a5c --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/ToonEnumUtility.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 05528202f03325348a70db7be3aa1271 diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/ToonMaterialUtility.cs b/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/ToonMaterialUtility.cs new file mode 100644 index 0000000..1e9d700 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/ToonMaterialUtility.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace Unity.Rendering.Toon { + +internal static class ToonMaterialUtility { + internal static Dictionary CaptureMaterialValues(Material mat) { + + Dictionary store = new Dictionary(); + Shader shader = mat.shader; + int count = shader.GetPropertyCount(); + for (int i = 0; i < count; i++) { + string name = shader.GetPropertyName(i); + + if (!mat.HasProperty(name)) + continue; + MaterialPropertyValue value = MaterialPropertyValue.FromMaterial(mat, i); + store[name] = value; + } + return store; + } + +} + +} \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/ToonMaterialUtility.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/ToonMaterialUtility.cs.meta new file mode 100644 index 0000000..b79fe37 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Scripts/Utilities/ToonMaterialUtility.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 6318da48f4f2b5c49b573ba5bf276399 diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders.meta b/BJH/Assets/BJH/3dtest/Runtime/Shaders.meta new file mode 100644 index 0000000..f232e43 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ac15e4c7900bb024b867ecb47e72df54 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/BuiltIn.meta b/BJH/Assets/BJH/3dtest/Runtime/Shaders/BuiltIn.meta new file mode 100644 index 0000000..4a579f0 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/BuiltIn.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8025904cbdaf5d248a95aba1f5b45b35 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/BuiltIn/BuiltInToonMode.hlsl b/BJH/Assets/BJH/3dtest/Runtime/Shaders/BuiltIn/BuiltInToonMode.hlsl new file mode 100644 index 0000000..7c68081 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/BuiltIn/BuiltInToonMode.hlsl @@ -0,0 +1,28 @@ +// DoubleShadeWithFeather and ShadingGradeMap use different fragment shader. +#pragma shader_feature_local _ _SHADINGGRADEMAP +// used in ShadingGradeMap +#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON +#pragma shader_feature _IS_ANGELRING_ON +// used in DoubleShadeWithFeather +#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE +#pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + +#if defined(UTS_RP_BUILTIN) + +#if defined(_SHADINGGRADEMAP) + +#include "../../Legacy/Shaders/UCTS_ShadingGradeMap.cginc" + + +#else //#if defined(_SHADINGGRADEMAP) + +#include "../../Legacy/Shaders/UCTS_DoubleShadeWithFeather.cginc" + + +#endif //#if defined(_SHADINGGRADEMAP) + +#else +#include "../Common/Error.hlsl" + + +#endif \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/BuiltIn/BuiltInToonMode.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/Shaders/BuiltIn/BuiltInToonMode.hlsl.meta new file mode 100644 index 0000000..49b242b --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/BuiltIn/BuiltInToonMode.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: f63021986cc9542468e7b5d9c1f4bb7e +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common.meta b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common.meta new file mode 100644 index 0000000..26ec813 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 11c7ba989f6d79c4b856b7e953b921b4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Error.hlsl b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Error.hlsl new file mode 100644 index 0000000..5e0dda3 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Error.hlsl @@ -0,0 +1,43 @@ +#include + + +struct appdata { + float4 vertex : POSITION; +}; + +struct v2f { + float4 vertex : SV_POSITION; +}; + +//---------------------------------------------------------------------------------------------------------------------- +struct DummyTessellationFactors +{ + float edge[3] : SV_TessFactor; + float inside : SV_InsideTessFactor; +}; + +[UNITY_domain("tri")] +v2f ds_surf(DummyTessellationFactors factors, const OutputPatch patch, float3 bary : SV_DomainLocation) { + + v2f o; + // Interpolate position using barycentric coordinates + o.vertex = patch[0].vertex * bary.x + + patch[1].vertex * bary.y + + patch[2].vertex * bary.z; + return o; +} + +//---------------------------------------------------------------------------------------------------------------------- + +sampler2D _MainTex; +float4 _MainTex_ST; + +v2f vert(appdata v) { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + return o; +} + +fixed4 frag(v2f i) : SV_Target { + return fixed4(1,0,1,1); +} diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Error.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Error.hlsl.meta new file mode 100644 index 0000000..21e0963 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Error.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9960caebaaf49c54a95b6495689939e8 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts.meta b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts.meta new file mode 100644 index 0000000..30ae644 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 97613359723ff8742b9c17fdf6cebbff +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/CommonProperties.shaderblock b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/CommonProperties.shaderblock new file mode 100644 index 0000000..c8dd3e3 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/CommonProperties.shaderblock @@ -0,0 +1,488 @@ +// Common Properties for Unity Toon Shader +// This file contains all shared properties between UnityToon.shader and UnityToonTessellation.shader +// with comments preserved from the original files + +// Basic UI and Version Properties +[HideInInspector] _simpleUI ("SimpleUI", Int ) = 0 +[HideInInspector] _utsTechnique ("Technique", int ) = 0 //DWF +_AutoRenderQueue("Automatic Render Queue ", int) = 1 + +// Stencil Properties +[Enum(OFF, 0, StencilOut, 1, StencilMask, 2)] _StencilMode("StencilMode", int) = 0 +// these are set in UniversalToonGUI.cs in accordance with _StencilMode +_StencilComp("Stencil Comparison", Float) = 8 +_StencilNo("Stencil No", Float) = 1 +_StencilOpPass("Stencil Operation", Float) = 0 +_StencilOpFail("Stencil Operation", Float) = 0 +[Enum(OFF, 0, ON, 1,] _TransparentEnabled("Transparent Mode", int) = 0 + +// Clipping Properties +// DoubleShadeWithFeather +// 0:_IS_CLIPPING_OFF 1:_IS_CLIPPING_MODE 2:_IS_CLIPPING_TRANSMODE +// ShadingGradeMap +// 0:_IS_TRANSCLIPPING_OFF 1:_IS_TRANSCLIPPING_ON +[Enum(OFF, 0, ON, 1, TRANSMODE, 2)] _ClippingMode("CliippingMode", int) = 0 + +// Cull and ZWrite Properties +[Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode("Cull Mode", int) = 2 //OFF/FRONT/BACK +[Enum(OFF, 0, ONT, 1)] _ZWriteMode("ZWrite Mode", int) = 1 //OFF/ON +[Enum(OFF, 0, ONT, 1)] _ZOverDrawMode("ZOver Draw Mode", Float) = 0 //OFF/ON +_SPRDefaultUnlitColorMask("SPRDefaultUnlit Path Color Mask", int) = 15 +[Enum(OFF, 0, FRONT, 1, BACK, 2)] _SRPDefaultUnlitColMode("SPRDefaultUnlit Cull Mode", int) = 1 //OFF/FRONT/BACK + +// ClippingMask parameters +// ClippingMask paramaters from Here. +_ClippingMask("ClippingMask", 2D) = "white" {} +_IsBaseMapAlphaAsClippingMask("IsBaseMapAlphaAsClippingMask", Float) = 0 +// +[Toggle(_)] _Inverse_Clipping("Inverse_Clipping", Float) = 0 +_Clipping_Level("Clipping_Level", Range(0, 1)) = 0 +_Tweak_transparency("Tweak_transparency", Range(-1, 1)) = 0 +// ClippingMask paramaters to Here. + +// Base Color Properties +_MainTex ("BaseMap", 2D) = "white" {} +_BaseMap ("BaseMap", 2D) = "white" {} +_BaseColor ("BaseColor", Color) = (1,1,1,1) +//v.2.0.5 : Clipping/TransClipping for SSAO Problems in PostProcessing Stack. +//If you want to go back the former SSAO results, comment out the below line. +_Color ("Color", Color) = (1,1,1,1) +// +[Toggle(_)] _Is_LightColor_Base ("Is_LightColor_Base", Float ) = 1 + +// 1st Shade Properties +_1st_ShadeMap ("1st_ShadeMap", 2D) = "white" {} +//v.2.0.5 +[Toggle(_)] _Use_BaseAs1st ("Use BaseMap as 1st_ShadeMap", Float ) = 0 +_1st_ShadeColor ("1st_ShadeColor", Color) = (1,1,1,1) +[Toggle(_)] _Is_LightColor_1st_Shade ("Is_LightColor_1st_Shade", Float ) = 1 + +// 2nd Shade Properties +_2nd_ShadeMap ("2nd_ShadeMap", 2D) = "white" {} +//v.2.0.5 +[Toggle(_)] _Use_1stAs2nd ("Use 1st_ShadeMap as 2nd_ShadeMap", Float ) = 0 +_2nd_ShadeColor ("2nd_ShadeColor", Color) = (1,1,1,1) +[Toggle(_)] _Is_LightColor_2nd_Shade ("Is_LightColor_2nd_Shade", Float ) = 1 + +// Normal Map Properties +_NormalMap ("NormalMap", 2D) = "bump" {} +_BumpScale ("Normal Scale", Range(0, 1)) = 1 +[Toggle(_)] _Is_NormalMapToBase ("Is_NormalMapToBase", Float ) = 0 +//v.2.0.4.4 +[Toggle(_)] _Set_SystemShadowsToBase ("Set_SystemShadowsToBase", Float ) = 1 +_Tweak_SystemShadowsLevel ("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0 + +// Shading Properties +//v.2.0.6 +_BaseColor_Step ("BaseColor_Step", Range(0, 1)) = 0.5 +_BaseShade_Feather ("Base/Shade_Feather", Range(0.0001, 1)) = 0.0001 +_ShadeColor_Step ("ShadeColor_Step", Range(0, 1)) = 0 +_1st2nd_Shades_Feather ("1st/2nd_Shades_Feather", Range(0.0001, 1)) = 0.0001 +_1st_ShadeColor_Step ("1st_ShadeColor_Step", Range(0, 1)) = 0.5 +_1st_ShadeColor_Feather ("1st_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 +_2nd_ShadeColor_Step ("2nd_ShadeColor_Step", Range(0, 1)) = 0 +_2nd_ShadeColor_Feather ("2nd_ShadeColor_Feather", Range(0.0001, 1)) = 0.0001 +//v.2.0.5 +_StepOffset ("Step_Offset (ForwardAdd Only)", Range(-0.5, 0.5)) = 0 +[Toggle(_)] _Is_Filter_HiCutPointLightColor ("PointLights HiCut_Filter (ForwardAdd Only)", Float ) = 1 + +// Shading Grade Map Properties +_Set_1st_ShadePosition ("Set_1st_ShadePosition", 2D) = "white" {} +_Set_2nd_ShadePosition ("Set_2nd_ShadePosition", 2D) = "white" {} +_ShadingGradeMap("ShadingGradeMap", 2D) = "white" {} +//v.2.0.6 +_Tweak_ShadingGradeMapLevel("Tweak_ShadingGradeMapLevel", Range(-0.5, 0.5)) = 0 +_BlurLevelSGM("Blur Level of ShadingGradeMap", Range(0, 10)) = 0 + +// High Color Properties +_HighColor ("HighColor", Color) = (0,0,0,1) +//v.2.0.4 HighColor_Tex +_HighColor_Tex ("HighColor_Tex", 2D) = "white" {} +[Toggle(_)] _Is_LightColor_HighColor ("Is_LightColor_HighColor", Float ) = 1 +[Toggle(_)] _Is_NormalMapToHighColor ("Is_NormalMapToHighColor", Float ) = 0 +_HighColor_Power ("HighColor_Power", Range(0, 1)) = 0 +[Toggle(_)] _Is_SpecularToHighColor ("Is_SpecularToHighColor", Float ) = 0 +[Toggle(_)] _Is_BlendAddToHiColor ("Is_BlendAddToHiColor", Float ) = 0 +[Toggle(_)] _Is_UseTweakHighColorOnShadow ("Is_UseTweakHighColorOnShadow", Float ) = 0 +_TweakHighColorOnShadow ("TweakHighColorOnShadow", Range(0, 1)) = 0 +//HiColorMask +_Set_HighColorMask ("Set_HighColorMask", 2D) = "white" {} +_Tweak_HighColorMaskLevel ("Tweak_HighColorMaskLevel", Range(-1, 1)) = 0 + +// Rim Light Properties +[Toggle(_)] _RimLight ("RimLight", Float ) = 0 +_RimLightColor ("RimLightColor", Color) = (1,1,1,1) +[Toggle(_)] _Is_LightColor_RimLight ("Is_LightColor_RimLight", Float ) = 1 +[Toggle(_)] _Is_NormalMapToRimLight ("Is_NormalMapToRimLight", Float ) = 0 +_RimLight_Power ("RimLight_Power", Range(0, 1)) = 0.1 +_RimLight_InsideMask ("RimLight_InsideMask", Range(0.0001, 1)) = 0.0001 +[Toggle(_)] _RimLight_FeatherOff ("RimLight_FeatherOff", Float ) = 0 +//RimLight +[Toggle(_)] _LightDirection_MaskOn ("LightDirection_MaskOn", Float ) = 0 +_Tweak_LightDirection_MaskLevel ("Tweak_LightDirection_MaskLevel", Range(0, 0.5)) = 0 +[Toggle(_)] _Add_Antipodean_RimLight ("Add_Antipodean_RimLight", Float ) = 0 +_Ap_RimLightColor ("Ap_RimLightColor", Color) = (1,1,1,1) +[Toggle(_)] _Is_LightColor_Ap_RimLight ("Is_LightColor_Ap_RimLight", Float ) = 1 +_Ap_RimLight_Power ("Ap_RimLight_Power", Range(0, 1)) = 0.1 +[Toggle(_)] _Ap_RimLight_FeatherOff ("Ap_RimLight_FeatherOff", Float ) = 0 +//RimLightMask +_Set_RimLightMask ("Set_RimLightMask", 2D) = "white" {} +_Tweak_RimLightMaskLevel ("Tweak_RimLightMaskLevel", Range(-1, 1)) = 0 + +// MatCap Properties +[Toggle(_)] _MatCap ("MatCap", Float ) = 0 +_MatCap_Sampler ("MatCap_Sampler", 2D) = "black" {} +//v.2.0.6 +_BlurLevelMatcap ("Blur Level of MatCap_Sampler", Range(0, 10)) = 0 +_MatCapColor ("MatCapColor", Color) = (1,1,1,1) +[Toggle(_)] _Is_LightColor_MatCap ("Is_LightColor_MatCap", Float ) = 1 +[Toggle(_)] _Is_BlendAddToMatCap ("Is_BlendAddToMatCap", Float ) = 1 +_Tweak_MatCapUV ("Tweak_MatCapUV", Range(-0.5, 0.5)) = 0 +_Rotate_MatCapUV ("Rotate_MatCapUV", Range(-1, 1)) = 0 +//v.2.0.6 +[Toggle(_)] _CameraRolling_Stabilizer ("Activate CameraRolling_Stabilizer", Float ) = 0 +[Toggle(_)] _Is_NormalMapForMatCap ("Is_NormalMapForMatCap", Float ) = 0 +_NormalMapForMatCap ("NormalMapForMatCap", 2D) = "bump" {} +_BumpScaleMatcap ("Scale for NormalMapforMatCap", Range(0, 1)) = 1 +_Rotate_NormalMapForMatCapUV ("Rotate_NormalMapForMatCapUV", Range(-1, 1)) = 0 +[Toggle(_)] _Is_UseTweakMatCapOnShadow ("Is_UseTweakMatCapOnShadow", Float ) = 0 +_TweakMatCapOnShadow ("TweakMatCapOnShadow", Range(0, 1)) = 0 +//MatcapMask +_Set_MatcapMask ("Set_MatcapMask", 2D) = "white" {} +_Tweak_MatcapMaskLevel ("Tweak_MatcapMaskLevel", Range(-1, 1)) = 0 +[Toggle(_)] _Inverse_MatcapMask ("Inverse_MatcapMask", Float ) = 0 +//v.2.0.5 +[Toggle(_)] _Is_Ortho ("Orthographic Projection for MatCap", Float ) = 0 + +// Angel Rings Properties +//// Angel Rings +[Toggle(_)] _AngelRing("AngelRing", Float) = 0 +_AngelRing_Sampler("AngelRing_Sampler", 2D) = "black" {} +_AngelRing_Color("AngelRing_Color", Color) = (1, 1, 1, 1) +[Toggle(_)] _Is_LightColor_AR("Is_LightColor_AR", Float) = 1 +_AR_OffsetU("AR_OffsetU", Range(0, 0.5)) = 0 +_AR_OffsetV("AR_OffsetV", Range(0, 1)) = 0.3 +[Toggle(_)] _ARSampler_AlphaOn("ARSampler_AlphaOn", Float) = 0 + +// Emissive Properties +//v.2.0.7 Emissive +[KeywordEnum(SIMPLE,ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0 +_Emissive_Tex ("Emissive_Tex", 2D) = "white" {} +[HDR]_Emissive_Color ("Emissive_Color", Color) = (0,0,0,1) +_Base_Speed ("Base_Speed", Float ) = 0 +_Scroll_EmissiveU ("Scroll_EmissiveU", Range(-1, 1)) = 0 +_Scroll_EmissiveV ("Scroll_EmissiveV", Range(-1, 1)) = 0 +_Rotate_EmissiveUV ("Rotate_EmissiveUV", Float ) = 0 +[Toggle(_)] _Is_PingPong_Base ("Is_PingPong_Base", Float ) = 0 +[Toggle(_)] _Is_ColorShift ("Activate ColorShift", Float ) = 0 +[HDR]_ColorShift ("ColorSift", Color) = (0,0,0,1) +_ColorShift_Speed ("ColorShift_Speed", Float ) = 0 +[Toggle(_)] _Is_ViewShift ("Activate ViewShift", Float ) = 0 +[HDR]_ViewShift ("ViewSift", Color) = (0,0,0,1) +[Toggle(_)] _Is_ViewCoord_Scroll ("Is_ViewCoord_Scroll", Float ) = 0 + +// Outline Properties +//Outline +[KeywordEnum(NML,POS)] _OUTLINE("OUTLINE MODE", Float) = 0 +_Outline_Width ("Outline_Width", Float ) = 0 +_Farthest_Distance ("Farthest_Distance", Float ) = 100 +_Nearest_Distance ("Nearest_Distance", Float ) = 0.5 +_Outline_Sampler ("Outline_Sampler", 2D) = "white" {} +_Outline_Color ("Outline_Color", Color) = (0.5,0.5,0.5,1) +[Toggle(_)] _Is_BlendBaseColor ("Is_BlendBaseColor", Float ) = 0 +[Toggle(_)] _Is_LightColor_Outline ("Is_LightColor_Outline", Float ) = 1 +//v.2.0.4 +[Toggle(_)] _Is_OutlineTex ("Is_OutlineTex", Float ) = 0 +_OutlineTex ("OutlineTex", 2D) = "white" {} +//Offset parameter +_Offset_Z ("Offset_Camera_Z", Float) = 0 +//v.2.0.4.3 Baked Normal Texture for Outline +[Toggle(_)] _Is_BakedNormal ("Is_BakedNormal", Float ) = 0 +_BakedNormal ("Baked Normal for Outline", 2D) = "white" {} +//GI Intensity +_GI_Intensity ("GI_Intensity", Range(0, 1)) = 0 +//For VR Chat under No effective light objects +_Unlit_Intensity ("Unlit_Intensity", Range(0, 4)) = 0 +//v.2.0.5 +[Toggle(_)] _Is_Filter_LightColor ("VRChat : SceneLights HiCut_Filter", Float ) = 1 +//Built-in Light Direction +[Toggle(_)] _Is_BLD ("Advanced : Activate Built-in Light Direction", Float ) = 0 +_Offset_X_Axis_BLD (" Offset X-Axis (Built-in Light Direction)", Range(-1, 1)) = -0.05 +_Offset_Y_Axis_BLD (" Offset Y-Axis (Built-in Light Direction)", Range(-1, 1)) = 0.09 +[Toggle(_)] _Inverse_Z_Axis_BLD (" Inverse Z-Axis (Built-in Light Direction)", Float ) = 1 + +// HDRP Matte Properties +////////////////////////////////////////////////////////////////////////////// +////////////////// Beginning of HDRP Matte. ////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +[Toggle(_)] _BaseColorVisible("Channel mask", Float) = 1 +[Toggle(_)] _BaseColorOverridden("Channel mask", Float) = 0 +_BaseColorMaskColor("chennel mask color", Color) = (1, 1, 1, 1) + +[Toggle(_)] _FirstShadeVisible("Channel mask", Float) = 1 +[Toggle(_)] _FirstShadeOverridden("Channel mask", Float) = 0 +_FirstShadeMaskColor("chennel mask color", Color) = (0, 1, 1, 1) + +[Toggle(_)] _SecondShadeVisible("Channel mask", Float) = 1 +[Toggle(_)] _SecondShadeOverridden("Channel mask", Float) = 0 +_SecondShadeMaskColor("chennel mask color", Color) = (0, 0, 1, 1) + +[Toggle(_)] _HighlightVisible("Channel mask", Float) = 1 +[Toggle(_)] _HighlightOverridden("Channel mask", Float) = 0 +_HighlightMaskColor("Channel mask color", Color) = (1, 1, 0, 1) + +[Toggle(_)] _AngelRingVisible("Channel mask", Float) = 1 +[Toggle(_)] _AngelRingOverridden("Channel mask", Float) = 0 +_AngelRingMaskColor("Channel mask color", Color) = (0, 1, 0, 1) + +[Toggle(_)] _RimLightVisible("Channel mask", Float) = 1 +[Toggle(_)] _RimLightOverridden("Channel mask", Float) = 0 +_RimLightMaskColor("Channel mask color", Color) = (1, 0, 1, 1) + +[Toggle(_)] _OutlineVisible("Channel mask", Float) = 1 +[Toggle(_)] _OutlineOverridden("Channel mask", Float) = 0 +_OutlineMaskColor("Channel mask color", Color) = (0, 0, 0, 1) + +[Toggle(_)] _ComposerMaskMode("", Float) = 0 +[Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0 + +////////////////////////////////////////////////////////////////////////////// +////////////////// End of HDRP Matte. ////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +// Avoid HDRP srp batcher error +////////////////// Avoid HDRP srp batcher error /////////////////////////////// +[HideInInspector] emissive("to avoid srp batcher error", Color)= (0, 0, 0, 1) // +////////////////// Avoid HDRP srp batcher error /////////////////////////////// + +// HDRP material default values +////////////////////////////////////////////////////////////////////////////// +////////////////// Beginning of HDRP material default values. //////////////// +////////////////////////////////////////////////////////////////////////////// +_BaseColorMap("BaseColorMap", 2D) = "white" {} +[HideInInspector] _BaseColorMap_MipInfo("_BaseColorMap_MipInfo", Vector) = (0, 0, 0, 0) + +_Metallic("_Metallic", Range(0.0, 1.0)) = 0 +_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 +_MaskMap("MaskMap", 2D) = "white" {} +_SmoothnessRemapMin("SmoothnessRemapMin", Float) = 0.0 +_SmoothnessRemapMax("SmoothnessRemapMax", Float) = 1.0 +_AlphaRemapMin("AlphaRemapMin", Float) = 0.0 // HDRP 14 +_AlphaRemapMax("AlphaRemapMax", Float) = 1.0 // HDRP 14 +_AORemapMin("AORemapMin", Float) = 0.0 +_AORemapMax("AORemapMax", Float) = 1.0 + +// Normal Maps +////////////// _NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map +_NormalMapOS("NormalMapOS", 2D) = "white" {} // Object space normal map - no good default value +_NormalScale("_NormalScale", Range(0.0, 8.0)) = 1 + +_BentNormalMap("_BentNormalMap", 2D) = "bump" {} +_BentNormalMapOS("_BentNormalMapOS", 2D) = "white" {} + +// Height Maps +_HeightMap("HeightMap", 2D) = "black" {} +// Caution: Default value of _HeightAmplitude must be (_HeightMax - _HeightMin) * 0.01 +// Those two properties are computed from the ones exposed in the UI and depends on the displaement mode so they are separate because we don't want to lose information upon displacement mode change. +[HideInInspector] _HeightAmplitude("Height Amplitude", Float) = 0.02 // In world units. This will be computed in the UI. +[HideInInspector] _HeightCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + +[Enum(MinMax, 0, Amplitude, 1)] _HeightMapParametrization("Heightmap Parametrization", Int) = 0 +// These parameters are for vertex displacement/Tessellation +_HeightOffset("Height Offset", Float) = 0 +// MinMax mode +_HeightMin("Heightmap Min", Float) = -1 +_HeightMax("Heightmap Max", Float) = 1 +// Amplitude mode +_HeightTessAmplitude("Amplitude", Float) = 2.0 // in Centimeters +_HeightTessCenter("Height Center", Range(0.0, 1.0)) = 0.5 // In texture space + +// These parameters are for pixel displacement +_HeightPoMAmplitude("Height Amplitude", Float) = 2.0 // In centimeters + +// Detail Maps +_DetailMap("DetailMap", 2D) = "linearGrey" {} +_DetailAlbedoScale("_DetailAlbedoScale", Range(0.0, 2.0)) = 1 +_DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1 +_DetailSmoothnessScale("_DetailSmoothnessScale", Range(0.0, 2.0)) = 1 + +// Tangent Maps +_TangentMap("TangentMap", 2D) = "bump" {} +_TangentMapOS("TangentMapOS", 2D) = "white" {} +_Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0 +_AnisotropyMap("AnisotropyMap", 2D) = "white" {} + +// Diffusion Profile +[HideInInspector] _DiffusionProfile("Obsolete, kept for migration purpose", Int) = 0 +[HideInInspector] _DiffusionProfileAsset("Diffusion Profile Asset", Vector) = (0, 0, 0, 0) +[HideInInspector] _DiffusionProfileHash("Diffusion Profile Hash", Float) = 0 +_SubsurfaceMask("Subsurface Radius", Range(0.0, 1.0)) = 1.0 +_SubsurfaceMaskMap("Subsurface Radius Map", 2D) = "white" {} +_TransmissionMask("Transmission Mask", Range(0.0, 1.0)) = 1.0 +_Thickness("Thickness", Range(0.0, 1.0)) = 1.0 +_ThicknessMap("Thickness Map", 2D) = "white" {} +_ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0) + +// Iridescence +_IridescenceThickness("Iridescence Thickness", Range(0.0, 1.0)) = 1.0 +_IridescenceThicknessMap("Iridescence Thickness Map", 2D) = "white" {} +_IridescenceThicknessRemap("Iridescence Thickness Remap", Vector) = (0, 1, 0, 0) +_IridescenceMask("Iridescence Mask", Range(0.0, 1.0)) = 1.0 +_IridescenceMaskMap("Iridescence Mask Map", 2D) = "white" {} + +// Coat +_CoatMask("Coat Mask", Range(0.0, 1.0)) = 0.0 +_CoatMaskMap("CoatMaskMap", 2D) = "white" {} + +// Specular +[ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0 +_SpecularColor("SpecularColor", Color) = (1, 1, 1, 1) +_SpecularColorMap("SpecularColorMap", 2D) = "white" {} + +// Following options are for the GUI inspector and different from the input parameters above +// These option below will cause different compilation flag. +[Enum(Off, 0, From Ambient Occlusion, 1, From Bent Normals, 2)] _SpecularOcclusionMode("Specular Occlusion Mode", Int) = 1 + +// Emissive +[HDR] _EmissiveColor("EmissiveColor", Color) = (0, 0, 0) +// Used only to serialize the LDR and HDR emissive color in the material UI, +// in the shader only the _EmissiveColor should be used +[HideInInspector] _EmissiveColorLDR("EmissiveColor LDR", Color) = (0, 0, 0) +_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} +[ToggleUI] _AlbedoAffectEmissive("Albedo Affect Emissive", Float) = 0.0 +[HideInInspector] _EmissiveIntensityUnit("Emissive Mode", Int) = 0 +[ToggleUI] _UseEmissiveIntensity("Use Emissive Intensity", Int) = 0 +_EmissiveIntensity("Emissive Intensity", Float) = 1 +_EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0 + +// Distortion +_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} +[ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0 +[ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0 +[Enum(Add, 0, Multiply, 1, Replace, 2)] _DistortionBlendMode("Distortion Blend Mode", Int) = 0 +[HideInInspector] _DistortionSrcBlend("Distortion Blend Src", Int) = 0 +[HideInInspector] _DistortionDstBlend("Distortion Blend Dst", Int) = 0 +[HideInInspector] _DistortionBlurSrcBlend("Distortion Blur Blend Src", Int) = 0 +[HideInInspector] _DistortionBlurDstBlend("Distortion Blur Blend Dst", Int) = 0 +[HideInInspector] _DistortionBlurBlendMode("Distortion Blur Blend Mode", Int) = 0 +_DistortionScale("Distortion Scale", Float) = 1 +_DistortionVectorScale("Distortion Vector Scale", Float) = 2 +_DistortionVectorBias("Distortion Vector Bias", Float) = -1 +_DistortionBlurScale("Distortion Blur Scale", Float) = 1 +_DistortionBlurRemapMin("DistortionBlurRemapMin", Float) = 0.0 +_DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0 + +// Alpha and Transparency +[ToggleUI] _UseShadowThreshold("_UseShadowThreshold", Float) = 0.0 +[ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 +_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 +_AlphaCutoffShadow("_AlphaCutoffShadow", Range(0.0, 1.0)) = 0.5 +_AlphaCutoffPrepass("_AlphaCutoffPrepass", Range(0.0, 1.0)) = 0.5 +_AlphaCutoffPostpass("_AlphaCutoffPostpass", Range(0.0, 1.0)) = 0.5 +[ToggleUI] _TransparentDepthPrepassEnable("_TransparentDepthPrepassEnable", Float) = 0.0 +[ToggleUI] _TransparentBackfaceEnable("_TransparentBackfaceEnable", Float) = 0.0 +[ToggleUI] _TransparentDepthPostpassEnable("_TransparentDepthPostpassEnable", Float) = 0.0 +_TransparentSortPriority("_TransparentSortPriority", Float) = 0 + +// Transparency +[Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0 +[Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0 +_Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.0 +_ThicknessMultiplier("Thickness Multiplier", Float) = 1.0 +_TransmittanceColor("Transmittance Color", Color) = (1.0, 1.0, 1.0) +_TransmittanceColorMap("TransmittanceColorMap", 2D) = "white" {} +_ATDistance("Transmittance Absorption Distance", Float) = 1.0 +[ToggleUI] _TransparentWritingMotionVec("_TransparentWritingMotionVec", Float) = 0.0 + +// Stencil state +// Forward +[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting +[HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 3 // StencilMask.Lighting +// GBuffer +[HideInInspector] _StencilRefGBuffer("_StencilRefGBuffer", Int) = 2 // StencilLightingUsage.RegularLighting +[HideInInspector] _StencilWriteMaskGBuffer("_StencilWriteMaskGBuffer", Int) = 3 // StencilMask.Lighting +// Depth prepass +[HideInInspector] _StencilRefDepth("_StencilRefDepth", Int) = 0 // Nothing +[HideInInspector] _StencilWriteMaskDepth("_StencilWriteMaskDepth", Int) = 32 // DoesntReceiveSSR +// Motion vector pass +[HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilBitMask.ObjectMotionVectors +[HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilBitMask.ObjectMotionVectors +// Distortion vector pass +[HideInInspector] _StencilRefDistortionVec("_StencilRefDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors +[HideInInspector] _StencilWriteMaskDistortionVec("_StencilWriteMaskDistortionVec", Int) = 64 // StencilBitMask.DistortionVectors + +// Blending state +[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 +[HideInInspector] _BlendMode("__blendmode", Float) = 0.0 +[HideInInspector] _SrcBlend("__src", Float) = 1.0 +[HideInInspector] _DstBlend("__dst", Float) = 0.0 +[HideInInspector] _AlphaSrcBlend("__alphaSrc", Float) = 1.0 +[HideInInspector] _AlphaDstBlend("__alphaDst", Float) = 0.0 +[HideInInspector][ToggleUI] _ZWrite("__zw", Float) = 1.0 +[HideInInspector][ToggleUI] _TransparentZWrite("_TransparentZWrite", Float) = 0.0 +[HideInInspector] _CullMode("__cullmode", Float) = 2.0 +[HideInInspector] _CullModeForward("__cullmodeForward", Float) = 2.0 // This mode is dedicated to Forward to correctly handle backface then front face rendering thin transparent +[HideInInspector] _TransparentCullMode("_TransparentCullMode", Int) = 2 // Back culling by default +[HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal +[HideInInspector] _ZTestModeDistortion("_ZTestModeDistortion", Int) = 8 +[HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4 +[Enum(UnityEngine.Rendering.CompareFunction)] _ZTestTransparent("Transparent ZTest", Int) = 4 // Less equal + +[ToggleUI] _EnableFogOnTransparent("Enable Fog", Float) = 1.0 +[ToggleUI] _EnableBlendModePreserveSpecularLighting("Enable Blend Mode Preserve Specular Lighting", Float) = 1.0 + +[ToggleUI] _DoubleSidedEnable("Double sided enable", Float) = 0.0 +[Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1 +[HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0) + +[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase("UV Set for base", Float) = 0 +[Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMapping("Mapping space", Float) = 0.0 +_TexWorldScale("Scale to apply on world coordinate", Float) = 1.0 +[HideInInspector] _InvTilingScale("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1 +[HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0) +[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 + +// Following enum should be material feature flags (i.e bitfield), however due to Gbuffer encoding constrain many combination exclude each other +// so we use this enum as "material ID" which can be interpreted as preset of bitfield of material feature +// The only material feature flag that can be added in all cases is clear coat +[Enum(Subsurface Scattering, 0, Standard, 1, Anisotropy, 2, Iridescence, 3, Specular Color, 4, Translucent, 5)] _MaterialID("MaterialId", Int) = 1 // MaterialId.Standard + +[ToggleUI] _EnableGeometricSpecularAA("EnableGeometricSpecularAA", Float) = 0.0 +_SpecularAAScreenSpaceVariance("SpecularAAScreenSpaceVariance", Range(0.0, 1.0)) = 0.1 +_SpecularAAThreshold("SpecularAAThreshold", Range(0.0, 1.0)) = 0.2 + +_PPDMinSamples("Min sample for POM", Range(1.0, 64.0)) = 5 +_PPDMaxSamples("Max sample for POM", Range(1.0, 64.0)) = 15 +_PPDLodThreshold("Start lod to fade out the POM effect", Range(0.0, 16.0)) = 5 +_PPDPrimitiveLength("Primitive length for POM", Float) = 1 +_PPDPrimitiveWidth("Primitive width for POM", Float) = 1 +[HideInInspector] _InvPrimScale("Inverse primitive scale for non-planar POM", Vector) = (1, 1, 0, 0) + +[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0 +[HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0) +[ToggleUI] _LinkDetailsWithBase("LinkDetailsWithBase", Float) = 1.0 + +[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 +[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVEmissive("UV Set for emissive", Float) = 0 +_TexWorldScaleEmissive("Scale to apply on world coordinate", Float) = 1.0 +[HideInInspector] _UVMappingMaskEmissive("_UVMappingMaskEmissive", Color) = (1, 0, 0, 0) + +// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" +// value that exist to identify if the GI emission need to be enabled. +// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. +// TODO: Fix the code in legacy unity so we can customize the beahvior for GI +_EmissionColor("Color", Color) = (1, 1, 1) + +// HACK: GI Baking system relies on some properties existing in the shader ("_MainTex", "_Cutoff" and "_Color") for opacity handling, so we need to store our version of those parameters in the hard-coded name the GI baking system recognizes. +////////// _MainTex("BaseMap", 2D) = "white" {} +_Color("Color", Color) = (1,1,1,1) +_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 + +[ToggleUI] _SupportDecals("Support Decals", Float) = 1.0 +[ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1.0 +[ToggleUI] _AddPrecomputedVelocity("AddPrecomputedVelocity", Float) = 0.0 +////////////////////////////////////////////////////////////////////////////// +//////////////////// End of HDRP material default values. //////////////////// +////////////////////////////////////////////////////////////////////////////// + +[HideInInspector] _ToonMaterialVersion ("Toon Material Version", Integer ) = 0 diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/CommonProperties.shaderblock.meta b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/CommonProperties.shaderblock.meta new file mode 100644 index 0000000..b1e2571 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/CommonProperties.shaderblock.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: bf400698b8c2d4748a6520ebf24204a3 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/TessellationProperties.shaderblock b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/TessellationProperties.shaderblock new file mode 100644 index 0000000..02db154 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/TessellationProperties.shaderblock @@ -0,0 +1,17 @@ +// Tessellation-specific Properties for Unity Toon Shader Tessellation +// These properties are only present in the tessellation shader + +// Tessellation specific +[Enum(None, 0, Phong, 1)] _TessellationMode("Tessellation mode", Float) = 0 +_TessellationFactor("Tessellation Factor", Range(0.0, 64.0)) = 4.0 +_TessellationFactorMinDistance("Tessellation start fading distance", Float) = 20.0 +_TessellationFactorMaxDistance("Tessellation end fading distance", Float) = 50.0 +_TessellationFactorTriangleSize("Tessellation triangle size", Float) = 100.0 +_TessellationShapeFactor("Tessellation shape factor", Range(0.0, 1.0)) = 0.75 // Only use with Phong +_TessellationBackFaceCullEpsilon("Tessellation back face epsilon", Range(-1.0, 0.0)) = -0.25 + +// Legacy material tessellation values +//Tessellation +_TessEdgeLength("DX11 Tess : Edge length", Range(2, 50)) = 5 +_TessPhongStrength("DX11 Tess : Phong Strength", Range(0, 1)) = 0.5 +_TessExtrusionAmount("DX11 Tess : Extrusion Amount", Range(-0.005, 0.005)) = 0.0 diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/TessellationProperties.shaderblock.meta b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/TessellationProperties.shaderblock.meta new file mode 100644 index 0000000..438ce25 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/TessellationProperties.shaderblock.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 48dde212c621e2b42b938c6e38aa9822 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/UnityToon.shadertemplate b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/UnityToon.shadertemplate new file mode 100644 index 0000000..6b99491 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/UnityToon.shadertemplate @@ -0,0 +1,1165 @@ +Shader "Toon/Toon" { + Properties + { + [COMMON_PROPERTIES] + } + + + HLSLINCLUDE + + #define DISABLE_RP_SHADERS + //------------------------------------------------------------------------------------- + // Variant + //------------------------------------------------------------------------------------- +#ifndef DISABLE_RP_SHADERS +// HDRP Variant + #pragma shader_feature_local _ALPHATEST_ON + #pragma shader_feature_local _DEPTHOFFSET_ON + #pragma shader_feature_local _DOUBLESIDED_ON + #pragma shader_feature_local _ _VERTEX_DISPLACEMENT _PIXEL_DISPLACEMENT + #pragma shader_feature_local _VERTEX_DISPLACEMENT_LOCK_OBJECT_SCALE + #pragma shader_feature_local _DISPLACEMENT_LOCK_TILING_SCALE + #pragma shader_feature_local _PIXEL_DISPLACEMENT_LOCK_OBJECT_SCALE + #pragma shader_feature_local _TESSELLATION_PHONG + #pragma shader_feature_local _ _REFRACTION_PLANE _REFRACTION_SPHERE _REFRACTION_THIN + + #pragma shader_feature_local _ _EMISSIVE_MAPPING_PLANAR _EMISSIVE_MAPPING_TRIPLANAR + #pragma shader_feature_local _ _MAPPING_PLANAR _MAPPING_TRIPLANAR + #pragma shader_feature_local _NORMALMAP_TANGENT_SPACE + #pragma shader_feature_local _ _REQUIRE_UV2 _REQUIRE_UV3 + + #pragma shader_feature_local _NORMALMAP + #pragma shader_feature_local _MASKMAP + #pragma shader_feature_local _BENTNORMALMAP + #pragma shader_feature_local _EMISSIVE_COLOR_MAP + + // _ENABLESPECULAROCCLUSION keyword is obsolete but keep here for compatibility. Do not used + // _ENABLESPECULAROCCLUSION and _SPECULAR_OCCLUSION_X can't exist at the same time (the new _SPECULAR_OCCLUSION replace it) + // When _ENABLESPECULAROCCLUSION is found we define _SPECULAR_OCCLUSION_X so new code to work + #pragma shader_feature_local _ENABLESPECULAROCCLUSION + #pragma shader_feature_local _ _SPECULAR_OCCLUSION_NONE _SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP + #ifdef _ENABLESPECULAROCCLUSION + #define _SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP + #endif + + #pragma shader_feature_local _HEIGHTMAP + #pragma shader_feature_local _TANGENTMAP + #pragma shader_feature_local _ANISOTROPYMAP + #pragma shader_feature_local _DETAIL_MAP + #pragma shader_feature_local _SUBSURFACE_MASK_MAP + #pragma shader_feature_local _THICKNESSMAP + #pragma shader_feature_local _IRIDESCENCE_THICKNESSMAP + #pragma shader_feature_local _SPECULARCOLORMAP + #pragma shader_feature_local _TRANSMITTANCECOLORMAP + + #pragma shader_feature_local _DISABLE_DECALS + #pragma shader_feature_local _DISABLE_SSR + #pragma shader_feature_local _ADD_PRECOMPUTED_VELOCITY + #pragma shader_feature_local _ENABLE_GEOMETRIC_SPECULAR_AA + + // Keyword for transparent + #pragma shader_feature _SURFACE_TYPE_TRANSPARENT + #pragma shader_feature_local _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY + #pragma shader_feature_local _BLENDMODE_PRESERVE_SPECULAR_LIGHTING + #pragma shader_feature_local _ENABLE_FOG_ON_TRANSPARENT + #pragma shader_feature_local _TRANSPARENT_WRITES_MOTION_VEC + + // MaterialFeature are used as shader feature to allow compiler to optimize properly + #pragma shader_feature_local _MATERIAL_FEATURE_SUBSURFACE_SCATTERING + #pragma shader_feature_local _MATERIAL_FEATURE_TRANSMISSION + #pragma shader_feature_local _MATERIAL_FEATURE_ANISOTROPY + #pragma shader_feature_local _MATERIAL_FEATURE_CLEAR_COAT + #pragma shader_feature_local _MATERIAL_FEATURE_IRIDESCENCE + #pragma shader_feature_local _MATERIAL_FEATURE_SPECULAR_COLOR + + + + + // enable dithering LOD crossfade + #pragma multi_compile _ LOD_FADE_CROSSFADE + + //enable GPU instancing support + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + // enable debug shado + // #pragma multi_compile _ UTS_DEBUG_SELFSHADOW + // #pragma multi_compile _ UTS_DEBUG_SHADOWMAP + // #pragma multi_compile _ UTS_DEBUG_SHADOWMAP_NO_OUTLINE + // end of HDRP Variants +#endif //#ifndef DISABLE_RP_SHADERS + + ENDHLSL + + + // *************************** // + // ****** HDRP Subshader ***** // + // *************************** // + SubShader + { + PackageRequirements + { + "com.unity.render-pipelines.high-definition": "10.5.0" + } + // This tags allow to use the shader replacement features + Tags{ "RenderPipeline"="HDRenderPipeline" } + + Pass + { + Name "SceneSelectionPass" + Tags { "LightMode" = "SceneSelectionPass" } + + Cull Off + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // Note: Require _ObjectId and _PassValue variables + + // We reuse depth prepass for the scene selection, allow to handle alpha correctly as well as tessellation and vertex animation + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define SCENESELECTIONPASS // This will drive the output of the scene selection shader + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + #pragma editor_sync_compilation + + ENDHLSL + } + + // Caution: The outline selection in the editor use the vertex shader/hull/domain shader of the first pass declare. So it should not bethe meta pass. + Pass + { + Name "GBuffer" + Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index + + Cull[_CullMode] + ZTest[_ZTestGBuffer] + + Stencil + { + WriteMask[_StencilWriteMaskGBuffer] + Ref[_StencilRefGBuffer] + Comp Always + Pass Replace + } + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma multi_compile _ DOTS_INSTANCING_ON + + + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + #pragma multi_compile _ LIGHT_LAYERS + + #ifndef DEBUG_DISPLAY + // When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer + // Don't do it with debug display mode as it is possible there is no depth prepass in this case + #define SHADERPASS_GBUFFER_BYPASS_ALPHA_TEST + #endif + + #define SHADERPASS SHADERPASS_GBUFFER + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + // #include "MaterialGBufferMacrosUTS.hlsl" // must be above lit.hlsl + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + // #include "EncodeIntoGBufferUTS.hlsl" // must be bellow lit.hlsl + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl" + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + + // Extracts information for lightmapping, GI (emission, albedo, ...) + // This pass it not used during regular rendering. + Pass + { + Name "META" + Tags{ "LightMode" = "META" } + + Cull Off + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // Lightmap memo + // DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light, + // both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON. + + #define SHADERPASS SHADERPASS_LIGHT_TRANSPORT + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "ShadowCaster" + Tags{ "LightMode" = "ShadowCaster" } + + Cull[_CullMode] + + ZClip [_ZClip] + ZWrite On + ZTest LEqual + + ColorMask 0 + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + + #define SHADERPASS SHADERPASS_SHADOWS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "DepthForwardOnly" + Tags{ "LightMode" = "DepthForwardOnly" } + + Cull[_CullMode] + + // To be able to tag stencil with disableSSR information for forward + Stencil + { + WriteMask [_StencilWriteMaskDepth] + Ref [_StencilRefDepth] + Comp Always + Pass Replace + } + + ZWrite On + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // In deferred, depth only pass don't output anything. + // In forward it output the normal buffer + #pragma multi_compile _ WRITE_NORMAL_BUFFER + #pragma multi_compile _ WRITE_MSAA_DEPTH + + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #else + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #endif + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "MotionVectors" + Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity) + + // If velocity pass (motion vectors) is enabled we tag the stencil so it don't perform CameraMotionVelocity + Stencil + { + WriteMask [_StencilWriteMaskMV] + Ref [_StencilRefMV] + Comp Always + Pass Replace + } + + Cull[_CullMode] + + ZWrite On + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #pragma multi_compile _ WRITE_NORMAL_BUFFER + #pragma multi_compile _ WRITE_MSAA_DEPTH + + #define SHADERPASS SHADERPASS_MOTION_VECTORS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #else + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitMotionVectorPass.hlsl" + #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassMotionVectors.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "DistortionVectors" + Tags { "LightMode" = "DistortionVectors" } // This will be only for transparent object based on the RenderQueue index + + Stencil + { + WriteMask [_StencilRefDistortionVec] + Ref [_StencilRefDistortionVec] + Comp Always + Pass Replace + } + + Blend [_DistortionSrcBlend] [_DistortionDstBlend], [_DistortionBlurSrcBlend] [_DistortionBlurDstBlend] + BlendOp Add, [_DistortionBlurBlendOp] + ZTest [_ZTestModeDistortion] + ZWrite off + Cull [_CullMode] + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DISTORTION + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDistortionPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDistortion.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "TransparentDepthPrepass" + Tags{ "LightMode" = "TransparentDepthPrepass" } + + Cull[_CullMode] + ZWrite On + ColorMask 0 + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define CUTOFF_TRANSPARENT_DEPTH_PREPASS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + // Caution: Order is important: TransparentBackface, then Forward/ForwardOnly + Pass + { + Name "TransparentBackface" + Tags { "LightMode" = "TransparentBackface" } + + Blend [_SrcBlend] [_DstBlend], [_AlphaSrcBlend] [_AlphaDstBlend] + ZWrite [_ZWrite] + Cull Front + ColorMask [_ColorMaskTransparentVel] 1 + ZTest [_ZTestTransparent] + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + + // Supported shadow modes per light type + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH + #if UNITY_VERSION >= 60000000 + // fix for https://github.com/Unity-Technologies/com.unity.toonshader/issues/391 + #ifdef SHADOW_MEDIUM + #ifndef PUNCTUAL_SHADOW_MEDIUM + #define PUNCTUAL_SHADOW_MEDIUM + #endif + #ifndef DIRECTIONAL_SHADOW_MEDIUM + #define DIRECTIONAL_SHADOW_MEDIUM + #endif + #endif + + #ifdef SHADOW_HIGH + #ifndef PUNCTUAL_SHADOW_HIGH + #define PUNCTUAL_SHADOW_HIGH + #endif + #ifndef DIRECTIONAL_SHADOW_HIGH + #define DIRECTIONAL_SHADOW_HIGH + #endif + #endif + #endif + #define USE_CLUSTERED_LIGHTLIST // There is not FPTL lighting when using transparent + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + + Name "ForwardOnly" + Tags { "LightMode" = "ForwardOnly" } + + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" +// #pragma multi_compile _ UTS_DEBUG_SHADOWMAP_BINALIZATION + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + // Ensure APV path is taken if available + #pragma multi_compile_fragment _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 + #pragma multi_compile _ SHADOWS_SHADOWMASK + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON + // Supported shadow modes per light type + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH + #if UNITY_VERSION >= 60000000 + // fix for https://github.com/Unity-Technologies/com.unity.toonshader/issues/391 + #ifdef SHADOW_MEDIUM + #ifndef PUNCTUAL_SHADOW_MEDIUM + #define PUNCTUAL_SHADOW_MEDIUM + #endif + #ifndef DIRECTIONAL_SHADOW_MEDIUM + #define DIRECTIONAL_SHADOW_MEDIUM + #endif + #endif + + #ifdef SHADOW_HIGH + #ifndef PUNCTUAL_SHADOW_HIGH + #define PUNCTUAL_SHADOW_HIGH + #endif + #ifndef DIRECTIONAL_SHADOW_HIGH + #define DIRECTIONAL_SHADOW_HIGH + #endif + #endif + #endif + #define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER +// #pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + // In case of opaque we don't want to perform the alpha test, it is done in depth prepass and we use depth equal for ztest (setup from UI) + // Don't do it with debug display mode as it is possible there is no depth prepass in this case + #if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(DEBUG_DISPLAY) + #define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST + #endif + #pragma shader_feature_local _ _SHADINGGRADEMAP + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_ON + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + // controlling mask rendering + #pragma shader_feature _ _IS_CLIPPING_MATTE + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" +#ifdef UNITY_SHADER_VARIABLES_INCLUDED + #include "../../HDRP/Shaders/UtsLightLoop.hlsl" + #include "../../HDRP/Shaders/ShaderPassForwardUTS.hlsl" +#endif + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "TransparentDepthPostpass" + Tags { "LightMode" = "TransparentDepthPostpass" } + + Cull[_CullMode] + ZWrite On + ColorMask 0 + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define CUTOFF_TRANSPARENT_DEPTH_POSTPASS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Tags{ + "RenderType" = "Opaque" + } + Pass{ + Name "Outline" + Tags { + "LightMode" = "SRPDefaultUnlit" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma target 4.5 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + #define SHADOW_LOW + #define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER + + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + // Ensure APV path is taken if available + #pragma multi_compile_fragment _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO _IS_OUTLINE_CLIPPING_YES + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + #pragma shader_feature _ _IS_CLIPPING_MATTE + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + +#ifdef UNITY_SHADER_VARIABLES_INCLUDED + #include "../../HDRP/Shaders/HDRPToonHead.hlsl" + #include "../../HDRP/Shaders/HDRPToonOutline.hlsl" +#endif + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + } + // *************************** // + // ****** URP Subshader ***** // + // *************************** // + SubShader + { + PackageRequirements + { + "com.unity.render-pipelines.universal": "10.5.0" + } + Tags { + "RenderType"="Opaque" + "RenderPipeline" = "UniversalPipeline" + } + +//ToonCoreStart + Pass { + Name "ForwardLit" + Tags{"LightMode" = "UniversalForward"} + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 2.0 + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex vert + #pragma fragment frag + +#ifndef DISABLE_RP_SHADERS + // ------------------------------------- + // urp Material Keywords + // ------------------------------------- + #pragma shader_feature_local _ALPHAPREMULTIPLY_ON + #pragma shader_feature_local _EMISSION + #pragma shader_feature_local _METALLICSPECGLOSSMAP + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A +// #pragma shader_feature _OCCLUSIONMAP + + #pragma shader_feature_local _SPECULARHIGHLIGHTS_OFF + #pragma shader_feature_local _ENVIRONMENTREFLECTIONS_OFF + #pragma shader_feature_local _SPECULAR_SETUP + #pragma shader_feature_local _RECEIVE_SHADOWS_OFF +#endif + // ------------------------------------- + // Lightweight Pipeline keywords + #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN + #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS + #pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS + #pragma multi_compile _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH + #pragma multi_compile _ _FORWARD_PLUS + #if (!defined(UNITY_COMPILER_DXC) && (defined(UNITY_PLATFORM_OSX) || defined(UNITY_PLATFORM_IOS))) || defined(SHADER_API_PS5) + + #if defined(SHADER_API_PS5) || defined(SHADER_API_METAL) + + #define SUPPORTS_FOVEATED_RENDERING_NON_UNIFORM_RASTER 1 + + // On Metal Foveated Rendering is currently not supported with DXC + #pragma warning (disable : 3568) // unknown pragma ignored + + #pragma never_use_dxc metal + #pragma dynamic_branch _ _FOVEATED_RENDERING_NON_UNIFORM_RASTER + + #pragma warning (default : 3568) // restore unknown pragma ignored + + #endif + + #endif + #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 + #pragma multi_compile_fragment _ _LIGHT_LAYERS + + #pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE + // ------------------------------------- + // Unity defined keywords + #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING + #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile_fog + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #define _IS_PASS_FWDBASE + // DoubleShadeWithFeather and ShadingGradeMap use different fragment shader. + #pragma shader_feature_local _ _SHADINGGRADEMAP + + + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_ON + + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" +#ifdef UNIVERSAL_PIPELINE_CORE_INCLUDED + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonHead.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonBody.hlsl" +#endif + ENDHLSL + + } + + Pass { + Name "Outline" + Tags { + "LightMode" = "SRPDefaultUnlit" + } + Cull [_SRPDefaultUnlitColMode] + ColorMask [_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 2.0 + #pragma vertex vert + #pragma fragment frag + + + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO _IS_OUTLINE_CLIPPING_YES + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Outline is implemented in UniversalToonOutline.hlsl. + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + +#ifdef UNIVERSAL_PIPELINE_CORE_INCLUDED + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonHead.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonOutline.hlsl" +#endif + ENDHLSL + } + + Pass + { + Name "Universal2D" + Tags + { + "LightMode" = "Universal2D" + } + + // ------------------------------------- + // Render State Commands + Blend[_SrcBlend][_DstBlend] + ZWrite[_ZWrite] + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 + + // ------------------------------------- + // Shader Stages + #pragma vertex vert + #pragma fragment frag + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON + + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + + // ------------------------------------- + // Includes + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "../../UniversalRP/Shaders/UniversalBasic2D.hlsl" + ENDHLSL + } + + + Pass + { + Name "ShadowCaster" + Tags{"LightMode" = "ShadowCaster"} + + ZWrite On + ZTest LEqual + Cull[_CullMode] + + HLSLPROGRAM + #pragma target 2.0 + + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + #pragma vertex ShadowPassVertex + #pragma fragment ShadowPassFragment + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl" + ENDHLSL + } + + Pass + { + Name "DepthOnly" + Tags{"LightMode" = "DepthOnly"} + + ZWrite On + ColorMask 0 + Cull[_CullMode] + + HLSLPROGRAM + #pragma target 2.0 + + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex DepthOnlyVertex + #pragma fragment DepthOnlyFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl" + ENDHLSL + } + // This pass is used when drawing to a _CameraNormalsTexture texture + Pass + { + Name "DepthNormals" + Tags{"LightMode" = "DepthNormals"} + + ZWrite On + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Version.hlsl" + + + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex DepthNormalsVertex + #pragma fragment DepthNormalsFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _PARALLAXMAP + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl" + + ENDHLSL + } + +//ToonCoreEnd + } + + // ***************************** // + // ****** Legacy Subshader ***** // + // ***************************** // + + SubShader { + Tags { + "RenderType"="Opaque" + } +//ToonCoreStart + Pass { + Name "FORWARD" + Tags { + "LightMode"="ForwardBase" + } + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + //#define UNITY_PASS_FORWARDBASE + #include "UnityCG.cginc" + #include "AutoLight.cginc" + #include "Lighting.cginc" + #pragma multi_compile_fwdbase_fullshadows + #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + #pragma multi_compile _IS_PASS_FWDBASE //[TODO-sin:2025-11-20] Check if this is used. + + #pragma shader_feature_local UTS_RP_BUILTIN + #include_with_pragmas "../../Shaders/BuiltIn/BuiltInToonMode.hlsl" + + ENDCG + } + Pass { + Name "Outline" + Tags { + "LightMode"="ForwardBase" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #include "UnityCG.cginc" + //#pragma fragmentoption ARB_precision_hint_fastest + //#pragma multi_compile_shadowcaster + //#pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Unity Toon Shader 0.5.0 + #pragma multi_compile _ _DISABLE_OUTLINE + //The outline process goes to UTS_Outline.cginc. + #include "../../Legacy/Shaders/UCTS_Outline.cginc" + ENDCG + } + Pass { + Name "FORWARD_DELTA" + Tags { + "LightMode"="ForwardAdd" + } + + Blend One One + Cull[_CullMode] + + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + //#define UNITY_PASS_FORWARDADD + #include "UnityCG.cginc" + #include "AutoLight.cginc" + #include "Lighting.cginc" + //for Unity2018.x + #pragma multi_compile_fwdadd_fullshadows + #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + + #pragma multi_compile _IS_PASS_FWDDELTA //[TODO-sin:2025-11-20] Check if this is used. + + #pragma shader_feature_local UTS_RP_BUILTIN + #include_with_pragmas "../../Shaders/BuiltIn/BuiltInToonMode.hlsl" + + ENDCG + } + Pass { + Name "ShadowCaster" + Tags { + "LightMode"="ShadowCaster" + } + Offset 1, 1 + Cull Off + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + //#define UNITY_PASS_SHADOWCASTER + #include "UnityCG.cginc" + #include "Lighting.cginc" + #pragma fragmentoption ARB_precision_hint_fastest + #pragma multi_compile_shadowcaster + #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + //v.2.0.4 + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + #include "../../Legacy/Shaders/UCTS_ShadowCaster.cginc" + ENDCG + } +//ToonCoreEnd + } + + CustomEditor "UnityEditor.Rendering.Toon.UTS3GUI" +} diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/UnityToon.shadertemplate.meta b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/UnityToon.shadertemplate.meta new file mode 100644 index 0000000..54ebf13 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/UnityToon.shadertemplate.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 5e20c2797536b704fa0201cd9164fe54 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/UnityToonTessellation.shadertemplate b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/UnityToonTessellation.shadertemplate new file mode 100644 index 0000000..e618222 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/UnityToonTessellation.shadertemplate @@ -0,0 +1,1257 @@ +Shader "Toon/Toon (Tessellation)" { + Properties + { + [COMMON_PROPERTIES] + + // Tessellation-specific properties + [TESSELLATION_PROPERTIES] + } + + + HLSLINCLUDE + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #define DISABLE_RP_SHADERS + //------------------------------------------------------------------------------------- + // Variant + //------------------------------------------------------------------------------------- +#ifndef DISABLE_RP_SHADERS + // HDRP Variant + #pragma shader_feature_local _ALPHATEST_ON + #pragma shader_feature_local _DEPTHOFFSET_ON + #pragma shader_feature_local _DOUBLESIDED_ON + #pragma shader_feature_local _ _TESSELLATION_DISPLACEMENT _PIXEL_DISPLACEMENT + #pragma shader_feature_local _VERTEX_DISPLACEMENT_LOCK_OBJECT_SCALE + #pragma shader_feature_local _DISPLACEMENT_LOCK_TILING_SCALE + #pragma shader_feature_local _PIXEL_DISPLACEMENT_LOCK_OBJECT_SCALE + #pragma shader_feature_local _TESSELLATION_PHONG + #pragma shader_feature_local _ _REFRACTION_PLANE _REFRACTION_SPHERE _REFRACTION_THIN + + #pragma shader_feature_local _ _EMISSIVE_MAPPING_PLANAR _EMISSIVE_MAPPING_TRIPLANAR + #pragma shader_feature_local _ _MAPPING_PLANAR _MAPPING_TRIPLANAR + #pragma shader_feature_local _NORMALMAP_TANGENT_SPACE + #pragma shader_feature_local _ _REQUIRE_UV2 _REQUIRE_UV3 + + #pragma shader_feature_local _NORMALMAP + #pragma shader_feature_local _MASKMAP + #pragma shader_feature_local _BENTNORMALMAP + #pragma shader_feature_local _EMISSIVE_COLOR_MAP + + // _ENABLESPECULAROCCLUSION keyword is obsolete but keep here for compatibility. Do not used + // _ENABLESPECULAROCCLUSION and _SPECULAR_OCCLUSION_X can't exist at the same time (the new _SPECULAR_OCCLUSION replace it) + // When _ENABLESPECULAROCCLUSION is found we define _SPECULAR_OCCLUSION_X so new code to work + #pragma shader_feature_local _ENABLESPECULAROCCLUSION + #pragma shader_feature_local _ _SPECULAR_OCCLUSION_NONE _SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP + #ifdef _ENABLESPECULAROCCLUSION + #define _SPECULAR_OCCLUSION_FROM_BENT_NORMAL_MAP + #endif + + #pragma shader_feature_local _HEIGHTMAP + #pragma shader_feature_local _TANGENTMAP + #pragma shader_feature_local _ANISOTROPYMAP + #pragma shader_feature_local _DETAIL_MAP + #pragma shader_feature_local _SUBSURFACE_MASK_MAP + #pragma shader_feature_local _THICKNESSMAP + #pragma shader_feature_local _IRIDESCENCE_THICKNESSMAP + #pragma shader_feature_local _SPECULARCOLORMAP + #pragma shader_feature_local _TRANSMITTANCECOLORMAP + + #pragma shader_feature_local _DISABLE_DECALS + #pragma shader_feature_local _DISABLE_SSR + #pragma shader_feature_local _ADD_PRECOMPUTED_VELOCITY + #pragma shader_feature_local _ENABLE_GEOMETRIC_SPECULAR_AA + + // Keyword for transparent + #pragma shader_feature _SURFACE_TYPE_TRANSPARENT + #pragma shader_feature_local _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY + #pragma shader_feature_local _BLENDMODE_PRESERVE_SPECULAR_LIGHTING + #pragma shader_feature_local _ENABLE_FOG_ON_TRANSPARENT + #pragma shader_feature_local _TRANSPARENT_WRITES_MOTION_VEC + + // MaterialFeature are used as shader feature to allow compiler to optimize properly + #pragma shader_feature_local _MATERIAL_FEATURE_SUBSURFACE_SCATTERING + #pragma shader_feature_local _MATERIAL_FEATURE_TRANSMISSION + #pragma shader_feature_local _MATERIAL_FEATURE_ANISOTROPY + #pragma shader_feature_local _MATERIAL_FEATURE_CLEAR_COAT + #pragma shader_feature_local _MATERIAL_FEATURE_IRIDESCENCE + #pragma shader_feature_local _MATERIAL_FEATURE_SPECULAR_COLOR + + + // enable dithering LOD crossfade + #pragma multi_compile _ LOD_FADE_CROSSFADE + + //enable GPU instancing support + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + // enable debug shado + // #pragma multi_compile _ UTS_DEBUG_SELFSHADOW + // #pragma multi_compile _ UTS_DEBUG_SHADOWMAP + // #pragma multi_compile _ UTS_DEBUG_SHADOWMAP_NO_OUTLINE + // end of HDRP Variants +#endif //#ifndef DISABLE_RP_SHADERS + + + //------------------------------------------------------------------------------------- + // Define + //------------------------------------------------------------------------------------- + #define TESSELLATION_ON + // This shader support vertex modification + #define HAVE_VERTEX_MODIFICATION + #define HAVE_TESSELLATION_MODIFICATION + + // If we use subsurface scattering, enable output split lighting (for forward pass) + #if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) && !defined(_SURFACE_TYPE_TRANSPARENT) + #define OUTPUT_SPLIT_LIGHTING + #endif + + #if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT) + #define _WRITE_TRANSPARENT_MOTION_VECTOR + #endif + + ENDHLSL + + // *************************** // + // ****** HDRP Subshader ***** // + // *************************** // + SubShader + { + PackageRequirements + { + "com.unity.render-pipelines.high-definition": "10.5.0" + } + // This tags allow to use the shader replacement features + Tags{ "RenderPipeline"="HDRenderPipeline" } + + Pass + { + Name "SceneSelectionPass" + Tags { "LightMode" = "SceneSelectionPass" } + + Cull Off + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // Note: Require _ObjectId and _PassValue variables + + // We reuse depth prepass for the scene selection, allow to handle alpha correctly as well as tessellation and vertex animation + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define SCENESELECTIONPASS // This will drive the output of the scene selection shader + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + #pragma editor_sync_compilation + + ENDHLSL + } + + // Caution: The outline selection in the editor use the vertex shader/hull/domain shader of the first pass declare. So it should not bethe meta pass. + Pass + { + Name "GBuffer" + Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index + + Cull[_CullMode] + ZTest[_ZTestGBuffer] + + Stencil + { + WriteMask[_StencilWriteMaskGBuffer] + Ref[_StencilRefGBuffer] + Comp Always + Pass Replace + } + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + + #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch + #pragma multi_compile _ DOTS_INSTANCING_ON + + + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + #pragma multi_compile _ LIGHT_LAYERS + + #ifndef DEBUG_DISPLAY + // When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer + // Don't do it with debug display mode as it is possible there is no depth prepass in this case + #define SHADERPASS_GBUFFER_BYPASS_ALPHA_TEST + #endif + + #define SHADERPASS SHADERPASS_GBUFFER + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + // #include "MaterialGBufferMacrosUTS.hlsl" // must be above lit.hlsl + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + // #include "EncodeIntoGBufferUTS.hlsl" // must be bellow lit.hlsl + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl" + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + + // Extracts information for lightmapping, GI (emission, albedo, ...) + // This pass it not used during regular rendering. + Pass + { + Name "META" + Tags{ "LightMode" = "META" } + + Cull Off + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // Lightmap memo + // DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light, + // both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON. + + #define SHADERPASS SHADERPASS_LIGHT_TRANSPORT + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + + ENDHLSL + } + + Pass + { + Name "ShadowCaster" + Tags{ "LightMode" = "ShadowCaster" } + + Cull[_CullMode] + + ZClip [_ZClip] + ZWrite On + ZTest LEqual + + ColorMask 0 + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + + #define SHADERPASS SHADERPASS_SHADOWS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + Name "DepthForwardOnly" + Tags{ "LightMode" = "DepthForwardOnly" } + + Cull[_CullMode] + + // To be able to tag stencil with disableSSR information for forward + Stencil + { + WriteMask [_StencilWriteMaskDepth] + Ref [_StencilRefDepth] + Comp Always + Pass Replace + } + + ZWrite On + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + // In deferred, depth only pass don't output anything. + // In forward it output the normal buffer + #pragma multi_compile _ WRITE_NORMAL_BUFFER + #pragma multi_compile _ WRITE_MSAA_DEPTH + + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #else + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #endif + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + Name "MotionVectors" + Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity) + + // If velocity pass (motion vectors) is enabled we tag the stencil so it don't perform CameraMotionVelocity + Stencil + { + WriteMask [_StencilWriteMaskMV] + Ref [_StencilRefMV] + Comp Always + Pass Replace + } + + Cull[_CullMode] + + ZWrite On + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #pragma multi_compile _ WRITE_NORMAL_BUFFER + #pragma multi_compile _ WRITE_MSAA_DEPTH + + #define SHADERPASS SHADERPASS_MOTION_VECTORS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #ifdef WRITE_NORMAL_BUFFER // If enabled we need all regular interpolator + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #else + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitMotionVectorPass.hlsl" + #endif + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassMotionVectors.hlsl" + + // TODO: Tesselation can't work with velocity for now... + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + Name "DistortionVectors" + Tags { "LightMode" = "DistortionVectors" } // This will be only for transparent object based on the RenderQueue index + + Stencil + { + WriteMask [_StencilRefDistortionVec] + Ref [_StencilRefDistortionVec] + Comp Always + Pass Replace + } + + Blend [_DistortionSrcBlend] [_DistortionDstBlend], [_DistortionBlurSrcBlend] [_DistortionBlurDstBlend] + BlendOp Add, [_DistortionBlurBlendOp] + ZTest [_ZTestModeDistortion] + ZWrite off + Cull [_CullMode] + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DISTORTION + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDistortionPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDistortion.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + Name "TransparentDepthPrepass" + Tags{ "LightMode" = "TransparentDepthPrepass" } + + Cull[_CullMode] + ZWrite On + ColorMask 0 + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define CUTOFF_TRANSPARENT_DEPTH_PREPASS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + // Caution: Order is important: TransparentBackface, then Forward/ForwardOnly + Pass + { + Name "TransparentBackface" + Tags { "LightMode" = "TransparentBackface" } + + Blend [_SrcBlend] [_DstBlend], [_AlphaSrcBlend] [_AlphaDstBlend] + ZWrite [_ZWrite] + Cull Front + ColorMask [_ColorMaskTransparentVel] 1 + ZTest [_ZTestTransparent] + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + + // Supported shadow modes per light type + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH + #if UNITY_VERSION >= 60000000 + // fix for https://github.com/Unity-Technologies/com.unity.toonshader/issues/391 + #ifdef SHADOW_MEDIUM + #ifndef PUNCTUAL_SHADOW_MEDIUM + #define PUNCTUAL_SHADOW_MEDIUM + #endif + #ifndef DIRECTIONAL_SHADOW_MEDIUM + #define DIRECTIONAL_SHADOW_MEDIUM + #endif + #endif + + #ifdef SHADOW_HIGH + #ifndef PUNCTUAL_SHADOW_HIGH + #define PUNCTUAL_SHADOW_HIGH + #endif + #ifndef DIRECTIONAL_SHADOW_HIGH + #define DIRECTIONAL_SHADOW_HIGH + #endif + #endif + #endif + #define USE_CLUSTERED_LIGHTLIST // There is not FPTL lighting when using transparent + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + + Name "ForwardOnly" + Tags { "LightMode" = "ForwardOnly" } + + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" +// #pragma multi_compile _ UTS_DEBUG_SHADOWMAP_BINALIZATION + #pragma multi_compile _ DEBUG_DISPLAY + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile _ SHADOWS_SHADOWMASK + // Setup DECALS_OFF so the shader stripper can remove variants + #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON + // Supported shadow modes per light type + #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH + #if UNITY_VERSION >= 60000000 + // fix for https://github.com/Unity-Technologies/com.unity.toonshader/issues/391 + #ifdef SHADOW_MEDIUM + #ifndef PUNCTUAL_SHADOW_MEDIUM + #define PUNCTUAL_SHADOW_MEDIUM + #endif + #ifndef DIRECTIONAL_SHADOW_MEDIUM + #define DIRECTIONAL_SHADOW_MEDIUM + #endif + #endif + + #ifdef SHADOW_HIGH + #ifndef PUNCTUAL_SHADOW_HIGH + #define PUNCTUAL_SHADOW_HIGH + #endif + #ifndef DIRECTIONAL_SHADOW_HIGH + #define DIRECTIONAL_SHADOW_HIGH + #endif + #endif + #endif + #define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER +// #pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + // In case of opaque we don't want to perform the alpha test, it is done in depth prepass and we use depth equal for ztest (setup from UI) + // Don't do it with debug display mode as it is possible there is no depth prepass in this case + #if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(DEBUG_DISPLAY) + #define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST + #endif + #pragma shader_feature_local _ _SHADINGGRADEMAP + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_ON + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + // controlling mask rendering + #pragma shader_feature _ _IS_CLIPPING_MATTE + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" +#ifdef UNITY_SHADER_VARIABLES_INCLUDED + #include "../../HDRP/Shaders/UtsLightLoop.hlsl" + #include "../../HDRP/Shaders/ShaderPassForwardUTS.hlsl" +#endif + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Pass + { + Name "TransparentDepthPostpass" + Tags { "LightMode" = "TransparentDepthPostpass" } + + Cull[_CullMode] + ZWrite On + ColorMask 0 + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define SHADERPASS SHADERPASS_DEPTH_ONLY + #define CUTOFF_TRANSPARENT_DEPTH_POSTPASS + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl" + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + Tags{ + "RenderType" = "Opaque" + } + Pass{ + Name "Outline" + Tags { + "LightMode" = "SRPDefaultUnlit" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 5.0 + #include "../../HDRP/Shaders/UtsHDRP.hlsl" + #define AREA_SHADOW_LOW + #define SHADERPASS SHADERPASS_FORWARD + #define SHADOW_LOW + #define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER + + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO _IS_OUTLINE_CLIPPING_YES + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + #pragma shader_feature _ _IS_CLIPPING_MATTE + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" + + #ifdef DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #endif + + // The light loop (or lighting architecture) is in charge to: + // - Define light list + // - Define the light loop + // - Setup the constant/data + // - Do the reflection hierarchy + // - Provide sampling function for shadowmap, ies, cookie and reflection (depends on the specific use with the light loops like index array or atlas or single and texture format (cubemap/latlong)) + + #define HAS_LIGHTLOOP + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" + + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" + +#ifdef UNITY_SHADER_VARIABLES_INCLUDED + #include "../../HDRP/Shaders/HDRPToonHead.hlsl" + #include "../../HDRP/Shaders/HDRPToonOutline.hlsl" +#endif + + #pragma vertex Vert + #pragma fragment Frag + #pragma hull Hull + #pragma domain Domain + + ENDHLSL + } + + } + // *************************** // + // ****** URP Subshader ***** // + // *************************** // + SubShader + { + PackageRequirements + { + "com.unity.render-pipelines.universal": "10.5.0" + } + Tags { + "RenderType"="Opaque" + "RenderPipeline" = "UniversalPipeline" + } + +//ToonCoreStart + Pass { + Name "ForwardLit" + Tags{"LightMode" = "UniversalForward"} + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 2.0 + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex vert + #pragma fragment frag + +#ifndef DISABLE_RP_SHADERS + // ------------------------------------- + // urp Material Keywords + // ------------------------------------- + #pragma shader_feature_local _ALPHAPREMULTIPLY_ON + #pragma shader_feature_local _EMISSION + #pragma shader_feature_local _METALLICSPECGLOSSMAP + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A +// #pragma shader_feature _OCCLUSIONMAP + + #pragma shader_feature_local _SPECULARHIGHLIGHTS_OFF + #pragma shader_feature_local _ENVIRONMENTREFLECTIONS_OFF + #pragma shader_feature_local _SPECULAR_SETUP + #pragma shader_feature_local _RECEIVE_SHADOWS_OFF +#endif + // ------------------------------------- + // Lightweight Pipeline keywords + #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN + #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS + #pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS + #pragma multi_compile _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH + #pragma multi_compile _ _FORWARD_PLUS + #if (!defined(UNITY_COMPILER_DXC) && (defined(UNITY_PLATFORM_OSX) || defined(UNITY_PLATFORM_IOS))) || defined(SHADER_API_PS5) + + #if defined(SHADER_API_PS5) || defined(SHADER_API_METAL) + + #define SUPPORTS_FOVEATED_RENDERING_NON_UNIFORM_RASTER 1 + + // On Metal Foveated Rendering is currently not supported with DXC + #pragma warning (disable : 3568) // unknown pragma ignored + + #pragma never_use_dxc metal + #pragma dynamic_branch _ _FOVEATED_RENDERING_NON_UNIFORM_RASTER + + #pragma warning (default : 3568) // restore unknown pragma ignored + + #endif + + #endif + #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 + #pragma multi_compile_fragment _ _LIGHT_LAYERS + + #pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE + // ------------------------------------- + // Unity defined keywords + #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING + #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile _ DIRLIGHTMAP_COMBINED + #pragma multi_compile _ LIGHTMAP_ON + #pragma multi_compile _ DYNAMICLIGHTMAP_ON + #pragma multi_compile_fog + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #pragma instancing_options renderinglayer + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #define _IS_PASS_FWDBASE + // DoubleShadeWithFeather and ShadingGradeMap use different fragment shader. + #pragma shader_feature_local _ _SHADINGGRADEMAP + + + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_ON + + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" +#ifdef UNIVERSAL_PIPELINE_CORE_INCLUDED + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonHead.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonBody.hlsl" +#endif + ENDHLSL + + } + + Pass { + Name "Outline" + Tags { + "LightMode" = "SRPDefaultUnlit" + } + Cull [_SRPDefaultUnlitColMode] + ColorMask [_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + + HLSLPROGRAM + #pragma target 2.0 + #pragma vertex vert + #pragma fragment frag + + + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO _IS_OUTLINE_CLIPPING_YES + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Outline is implemented in UniversalToonOutline.hlsl. + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + +#ifdef UNIVERSAL_PIPELINE_CORE_INCLUDED + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonHead.hlsl" + #include "../../UniversalRP/Shaders/UniversalToonOutline.hlsl" +#endif + ENDHLSL + } + + Pass + { + Name "Universal2D" + Tags + { + "LightMode" = "Universal2D" + } + + // ------------------------------------- + // Render State Commands + Blend[_SrcBlend][_DstBlend] + ZWrite[_ZWrite] + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 + + // ------------------------------------- + // Shader Stages + #pragma vertex vert + #pragma fragment frag + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON + + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + + // ------------------------------------- + // Includes + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "../../UniversalRP/Shaders/UniversalBasic2D.hlsl" + ENDHLSL + } + + Pass + { + Name "ShadowCaster" + Tags{"LightMode" = "ShadowCaster"} + + ZWrite On + ZTest LEqual + Cull[_CullMode] + + HLSLPROGRAM + #pragma target 2.0 + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + // ------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + #pragma vertex ShadowPassVertex + #pragma fragment ShadowPassFragment + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl" + ENDHLSL + } + + Pass + { + Name "DepthOnly" + Tags{"LightMode" = "DepthOnly"} + + ZWrite On + ColorMask 0 + Cull[_CullMode] + + HLSLPROGRAM + #pragma target 2.0 + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex DepthOnlyVertex + #pragma fragment DepthOnlyFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl" + ENDHLSL + } + // This pass is used when drawing to a _CameraNormalsTexture texture + Pass + { + Name "DepthNormals" + Tags{"LightMode" = "DepthNormals"} + + ZWrite On + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 + +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Version.hlsl" +#ifndef VERSION_GREATER_EQUAL +#define VERSION_GREATER_EQUAL(x, y) 1 +#endif +#if (VERSION_GREATER_EQUAL(10, 0)) + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + #pragma vertex DepthNormalsVertex + #pragma fragment DepthNormalsFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _PARALLAXMAP + #pragma shader_feature_local _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7 + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl" + #else + #pragma multi_compile _ DOTS_INSTANCING_ON + #endif + + #include "../../UniversalRP/Shaders/UniversalToonInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl" +#endif + ENDHLSL + } + +//ToonCoreEnd + } + + // ***************************** // + // ****** Legacy Subshader ***** // + // ***************************** // + + SubShader { + Tags { + "RenderType"="Opaque" + } + Pass { + Name "Outline" + Tags { + "LightMode"="ForwardBase" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #include "UnityCG.cginc" + //#pragma fragmentoption ARB_precision_hint_fastest + //#pragma multi_compile_shadowcaster + //#pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + #pragma target 3.0 + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Unity Toon Shader 0.5.0 + #pragma multi_compile _ _DISABLE_OUTLINE + //The outline process goes to UTS_Outline.cginc. + #include "../../Legacy/Shaders/UCTS_Outline.cginc" + ENDCG + } +//ToonCoreStart + Pass { + Name "FORWARD" + Tags { + "LightMode"="ForwardBase" + } + ZWrite[_ZWriteMode] + Cull[_CullMode] + Blend SrcAlpha OneMinusSrcAlpha + Stencil { + + Ref[_StencilNo] + + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #define TESSELLATION_ON + #pragma target 5.0 + #pragma vertex tess_VertexInput + #pragma hull hs_VertexInput + #pragma domain ds_surf + #pragma fragment frag + + #ifdef TESSELLATION_ON + #include "../../Legacy/Shaders/UCTS_Tess.cginc" + #endif + //#define UNITY_PASS_FORWARDBASE + #include "UnityCG.cginc" + #include "AutoLight.cginc" + #include "Lighting.cginc" + #pragma multi_compile_fwdbase_fullshadows +// #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + #pragma target 5.0 + + #pragma multi_compile _IS_PASS_FWDBASE //[TODO-sin:2025-11-20] Check if this is used. + + #pragma shader_feature_local UTS_RP_BUILTIN + #include_with_pragmas "../../Shaders/BuiltIn/BuiltInToonMode.hlsl" + + ENDCG + } + Pass { + Name "Outline" + Tags { + "LightMode"="ForwardBase" + } + Cull[_SRPDefaultUnlitColMode] + ColorMask[_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha + Stencil + { + Ref[_StencilNo] + Comp[_StencilComp] + Pass[_StencilOpPass] + Fail[_StencilOpFail] + + } + CGPROGRAM + #define TESSELLATION_ON + #pragma target 5.0 + #pragma vertex tess_VertexInput + #pragma hull hs_VertexInput + #pragma domain ds_surf + #pragma fragment frag + #ifdef TESSELLATION_ON + #include "../../Legacy/Shaders/UCTS_Tess.cginc" + #endif + #include "UnityCG.cginc" + //#pragma fragmentoption ARB_precision_hint_fastest + //#pragma multi_compile_shadowcaster + //#pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + + //V.2.0.4 + #pragma multi_compile _IS_OUTLINE_CLIPPING_NO + #pragma multi_compile _OUTLINE_NML _OUTLINE_POS + // Unity Toon Shader 0.5.0 + #pragma multi_compile _ _DISABLE_OUTLINE + //The outline process goes to UTS_Outline.cginc. + #include "../../Legacy/Shaders/UCTS_Outline_Tess.cginc" + ENDCG + } + Pass { + Name "FORWARD_DELTA" + Tags { + "LightMode"="ForwardAdd" + } + + Blend One One + Cull[_CullMode] + + + CGPROGRAM + #define TESSELLATION_ON + #pragma target 5.0 + #pragma vertex tess_VertexInput + #pragma hull hs_VertexInput + #pragma domain ds_surf + #pragma fragment frag + + #ifdef TESSELLATION_ON + #include "../../Legacy/Shaders/UCTS_Tess.cginc" + #endif + //#define UNITY_PASS_FORWARDADD + #include "UnityCG.cginc" + #include "AutoLight.cginc" + #include "Lighting.cginc" + //for Unity2018.x + #pragma multi_compile_fwdadd_fullshadows +// #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + // DoubleShadeWithFeather and ShadingGradeMap use different fragment shader. + #pragma shader_feature_local _ _SHADINGGRADEMAP + // used in ShadingGradeMap + #pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON + #pragma shader_feature _IS_ANGELRING_ON + // used in DoubleShadeWithFeather + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + #pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION + //v.2.0.4 + + #pragma multi_compile _IS_PASS_FWDDELTA //[TODO-sin:2025-11-20] Check if this is used. + + #pragma shader_feature_local UTS_RP_BUILTIN + #include_with_pragmas "../../Shaders/BuiltIn/BuiltInToonMode.hlsl" + + ENDCG + } + Pass { + Name "ShadowCaster" + Tags { + "LightMode"="ShadowCaster" + } + Offset 1, 1 + Cull Off + + CGPROGRAM + #define TESSELLATION_ON + #pragma target 5.0 + #pragma vertex tess_VertexInput + #pragma hull hs_VertexInput + #pragma domain ds_surf + #pragma fragment frag + #ifdef TESSELLATION_ON + #include "../../Legacy/Shaders/UCTS_Tess.cginc" + #endif + //#define UNITY_PASS_SHADOWCASTER + #include "UnityCG.cginc" + #include "Lighting.cginc" + #pragma fragmentoption ARB_precision_hint_fastest + #pragma multi_compile_shadowcaster +// #pragma multi_compile_fog + #pragma only_renderers d3d9 d3d11 glcore gles gles3 playstation xboxone xboxseries vulkan metal switch + //v.2.0.4 + #pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE + // Unity Toon Shader 0.5.0 + #pragma multi_compile _ _DISABLE_OUTLINE + #include "../../Legacy/Shaders/UCTS_ShadowCaster_Tess.cginc" + ENDCG + + } +//ToonCoreEnd + } + + CustomEditor "UnityEditor.Rendering.Toon.UTS3GUI" +} diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/UnityToonTessellation.shadertemplate.meta b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/UnityToonTessellation.shadertemplate.meta new file mode 100644 index 0000000..c200d34 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/Common/Parts/UnityToonTessellation.shadertemplate.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 06a664ca361bde14892cdd760229e68c +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP.meta b/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP.meta new file mode 100644 index 0000000..533bf11 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 49006fd45b045264286a74b5c82f7b66 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ObjectTransform.hlsl b/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ObjectTransform.hlsl new file mode 100644 index 0000000..bc794b9 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ObjectTransform.hlsl @@ -0,0 +1,17 @@ +#pragma once + +inline float4 UnityObjectToClipPosInstanced(in float3 pos) { + return mul(UNITY_MATRIX_VP, mul(GetObjectToWorldMatrix(), float4(pos, 1.0))); +} +#define UnityObjectToClipPos UnityObjectToClipPosInstanced + + +inline float3 UnityObjectToWorldNormal(in float3 norm) +{ + #ifdef UNITY_ASSUME_UNIFORM_SCALING + return UnityObjectToWorldDir(norm); + #else + // mul(IT_M, norm) => mul(norm, I_M) => {dot(norm, I_M.col0), dot(norm, I_M.col1), dot(norm, I_M.col2)} + return normalize(mul(norm, (float3x3)GetWorldToObjectMatrix())); + #endif +} diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ObjectTransform.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ObjectTransform.hlsl.meta new file mode 100644 index 0000000..a1165fe --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ObjectTransform.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9b41c14789eff344cb5a038c3548f99e +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ShapeLight2D.hlsl b/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ShapeLight2D.hlsl new file mode 100644 index 0000000..df4a0cf --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ShapeLight2D.hlsl @@ -0,0 +1,99 @@ +#pragma once + + +#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl" //_ShapeLightTexture + +struct ShapeLightResult { + half4 mod; + half4 add; +}; + +//---------------------------------------------------------------------------------------------------------------------- + +ShapeLightResult CombinedShapeLight(in half4 mask, in half2 lightingUV) +{ + ShapeLightResult ret = (ShapeLightResult)0; + + #if defined(DEBUG_DISPLAY) + half4 debugColor = 0; + + if (CanDebugOverrideOutputColor(surfaceData, inputData, debugColor)) + { + ret.mod = ret.add = debugColor; + return ret; + } + #endif + +#if USE_SHAPE_LIGHT_TYPE_0 + half4 shapeLight0 = SAMPLE_TEXTURE2D(_ShapeLightTexture0, sampler_ShapeLightTexture0, lightingUV); + + if (any(_ShapeLightMaskFilter0)) + { + half4 processedMask = (1 - _ShapeLightInvertedFilter0) * mask + _ShapeLightInvertedFilter0 * (1 - mask); + shapeLight0 *= dot(processedMask, _ShapeLightMaskFilter0); + } + + half4 shapeLight0Modulate = shapeLight0 * _ShapeLightBlendFactors0.x; + half4 shapeLight0Additive = shapeLight0 * _ShapeLightBlendFactors0.y; +#else + half4 shapeLight0Modulate = 0; + half4 shapeLight0Additive = 0; +#endif + +#if USE_SHAPE_LIGHT_TYPE_1 + half4 shapeLight1 = SAMPLE_TEXTURE2D(_ShapeLightTexture1, sampler_ShapeLightTexture1, lightingUV); + + if (any(_ShapeLightMaskFilter1)) + { + half4 processedMask = (1 - _ShapeLightInvertedFilter1) * mask + _ShapeLightInvertedFilter1 * (1 - mask); + shapeLight1 *= dot(processedMask, _ShapeLightMaskFilter1); + } + + half4 shapeLight1Modulate = shapeLight1 * _ShapeLightBlendFactors1.x; + half4 shapeLight1Additive = shapeLight1 * _ShapeLightBlendFactors1.y; +#else + half4 shapeLight1Modulate = 0; + half4 shapeLight1Additive = 0; +#endif + +#if USE_SHAPE_LIGHT_TYPE_2 + half4 shapeLight2 = SAMPLE_TEXTURE2D(_ShapeLightTexture2, sampler_ShapeLightTexture2, lightingUV); + + if (any(_ShapeLightMaskFilter2)) + { + half4 processedMask = (1 - _ShapeLightInvertedFilter2) * mask + _ShapeLightInvertedFilter2 * (1 - mask); + shapeLight2 *= dot(processedMask, _ShapeLightMaskFilter2); + } + + half4 shapeLight2Modulate = shapeLight2 * _ShapeLightBlendFactors2.x; + half4 shapeLight2Additive = shapeLight2 * _ShapeLightBlendFactors2.y; +#else + half4 shapeLight2Modulate = 0; + half4 shapeLight2Additive = 0; +#endif + +#if USE_SHAPE_LIGHT_TYPE_3 + half4 shapeLight3 = SAMPLE_TEXTURE2D(_ShapeLightTexture3, sampler_ShapeLightTexture3, lightingUV); + + if (any(_ShapeLightMaskFilter3)) + { + half4 processedMask = (1 - _ShapeLightInvertedFilter3) * mask + _ShapeLightInvertedFilter3 * (1 - mask); + shapeLight3 *= dot(processedMask, _ShapeLightMaskFilter3); + } + + half4 shapeLight3Modulate = shapeLight3 * _ShapeLightBlendFactors3.x; + half4 shapeLight3Additive = shapeLight3 * _ShapeLightBlendFactors3.y; +#else + half4 shapeLight3Modulate = 0; + half4 shapeLight3Additive = 0; +#endif + + half4 finalOutput; +#if !USE_SHAPE_LIGHT_TYPE_0 && !USE_SHAPE_LIGHT_TYPE_1 && !USE_SHAPE_LIGHT_TYPE_2 && ! USE_SHAPE_LIGHT_TYPE_3 +#else + ret.mod = shapeLight0Modulate + shapeLight1Modulate + shapeLight2Modulate + shapeLight3Modulate; + ret.add = shapeLight0Additive + shapeLight1Additive + shapeLight2Additive + shapeLight3Additive; +#endif + + return ret; +} diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ShapeLight2D.hlsl.meta b/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ShapeLight2D.hlsl.meta new file mode 100644 index 0000000..0bd1bb1 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ShapeLight2D.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 5bc7437a7c5f9e543b48e4927ebaa2f2 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ToonURP_3Das2D.shader b/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ToonURP_3Das2D.shader new file mode 100644 index 0000000..b872ee7 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ToonURP_3Das2D.shader @@ -0,0 +1,589 @@ +Shader "Toon/Toon 3D as 2D (URP)"{ + Properties{ + + _BaseColor ("Base Color", Color) = (1,1,1,1) + _MainTex ("Main Texture", 2D) = "white" {} + + //Three Colors + _1st_ShadeColor ("1st Shade Color", Color) = (0.5,0.5,0.5,1) + _1st_ShadeMap ("1st Shade Map", 2D) = "white" {} + [Toggle(_)] _Use_BaseAs1st ("Use BaseMap as 1st_ShadeMap", Integer ) = 0 + _2nd_ShadeColor ("2nd Shade Color", Color) = (0.1,0.1,0.1,1) + _2nd_ShadeMap ("2nd Shade Map", 2D) = "white" {} + [Toggle(_)] _Use_1stAs2nd ("Use 1st ShadeMap as 2nd ShadeMap", Integer ) = 0 + + //Start and Feather + _BaseTo1st_ShadeStart ("Base to 1st Shade Start", Range(0, 1)) = 0.5 + _BaseTo1st_ShadeFeather ("Base to 1st Shade Feather", Range(0, 1)) = 0.1 + _1stTo2nd_ShadeStart ("1st to 2nd Shade Start", Range(0, 1)) = 0.25 + _1stTo2nd_ShadeFeather ("1st to 2nd Shade Feather", Range(0, 1)) = 0.1 + + _2DLightStrength ("2D Light Strength", Range(0,1)) = 1 + + _MaskTex("Mask", 2D) = "white" {} + _NormalMap("Normal Map", 2D) = "bump" {} + _BumpScale ("Normal Scale", Range(0, 1)) = 1 + + [HideInInspector] _White("Tint", Color) = (1,1,1,1) // Added to break SRP batching. Work around for issue with SRP Batching + + //Directional Light + _DirectionalLight_Use ("Use Directional Light", Integer) = 0 + _DirectionalLight_Direction ("Directional Light Direction", Vector) = (0,-1,0,0) + _DirectionalLight_Color("Directional Light Color", Color) = (1,1,1,1) + _DirectionalLight_Intensity ("Directional Light Intensity", float) = 0.5 + _DirectionalLight_DiffuseStrength ("Directional Light: Diffuse Strength", Range(0,1)) = 0.5 + + _DirectionalLight_ViewPosition ("Directional Light: View Position", Vector) = (0,0,1,0) + _HighlightColor ("Highlight Color", Color) = (1,1,1,1) + _HighlightTex ("HighColor Map", 2D) = "white" {} + _DirectionalLight_HighlightMode ("Directional Light: Highlight Mode", Integer) = 0 //0: Hard, 1: Soft + _DirectionalLight_HighlightStrength ("Directional Light: Highlight Strength", Range(0,1)) = 0.5 + _DirectionalLight_HighlightSize ("Directional Light: Highlight Size", Range(0,1)) = 0.3 + + //Outline + _OutlineMode("Outline Mode", Integer) = 0 + _OutlineWidth ("Outline Width", Float ) = 5 + _OutlineWidthMap ("Outline Width Map", 2D) = "white" {} + _OutlineColor ("Outline Color", Color) = (0.1,0.1,0.1,1) + _OutlineTex ("Outline Tex", 2D) = "white" {} + _Outline_BaseColorBlend ("Blend Base Color to Outline", Range(0,1) ) = 0.5 + _Outline_LightColorBlend ("Blend Light Color to Outline", Range(0,1) ) = 0.5 + _OutlineOffsetZ ("Outline Z Offset", Float) = 0.75 + _OutlineNear ("Outline Near", Float ) = 0.5 + _OutlineFar ("Outline Far", Float ) = 100 + _Outline_UseNormalMap ("Outline: Use Outline Normal Map", Integer ) = 0 + _Outline_NormalMap ("Outline Normal Map", 2D) = "bump" {} + + [HideInInspector] _ToonMaterialVersion ("Toon Material Version", Integer ) = 0 + + } + + SubShader{ + PackageRequirements { + "com.unity.render-pipelines.universal": "17.3.0" //Unity 6.3+ + } + Tags{ + "Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" + } + + Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha + Cull Back + ZWrite On + + Stencil{ + Ref 128 // Put this in the last bit of our stencil value for maximum compatibility with sprite mask + Comp always + Pass replace + } + + Pass{ + Tags{ + "LightMode" = "Universal2D" + } + + HLSLPROGRAM + #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl" + + #pragma vertex ToonVertex + #pragma fragment ToonFragment + + //USE_SHAPE_LIGHT keywords + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/ShapeLightShared.hlsl" + + // GPU Instancing + #pragma multi_compile_instancing + #pragma multi_compile _ DEBUG_DISPLAY + + struct Attributes { + float3 positionOS : POSITION; + float2 uv : TEXCOORD0; + float3 normal : NORMAL; + float4 tangent : TANGENT; + UNITY_VERTEX_INPUT_INSTANCE_ID + }; + + struct Varyings { + float4 positionCS : SV_POSITION; + float2 uv : TEXCOORD0; + half2 lightingUV : TEXCOORD1; + float3 normalWS : TEXCOORD2; + float4 tangentWS : TEXCOORD3; + float3 positionWS : TEXCOORD4; + UNITY_VERTEX_OUTPUT_STEREO + }; + + float4 _White; + + TEXTURE2D(_MainTex); + SAMPLER(sampler_MainTex); + UNITY_TEXTURE_STREAMING_DEBUG_VARS_FOR_TEX(_MainTex); + + TEXTURE2D(_MaskTex); + SAMPLER(sampler_MaskTex); + + TEXTURE2D(_NormalMap); + SAMPLER(sampler_NormalMap); + + + CBUFFER_START(UnityPerMaterial) + half4 _BaseColor; + float _BumpScale; + + //Three colors + float4 _1st_ShadeColor; + int _Use_BaseAs1st; + float4 _2nd_ShadeColor; + int _Use_1stAs2nd; + + //Start and Feather + float _BaseTo1st_ShadeStart; + float _BaseTo1st_ShadeFeather; + float _1stTo2nd_ShadeStart; + float _1stTo2nd_ShadeFeather; + + float _2DLightStrength; + + int _DirectionalLight_Use; + float3 _DirectionalLight_Direction; + float4 _DirectionalLight_Color; + float _DirectionalLight_Intensity; + float _DirectionalLight_DiffuseStrength; + + float3 _DirectionalLight_ViewPosition; + float4 _HighlightColor; + int _DirectionalLight_HighlightMode; + float _DirectionalLight_HighlightStrength; + float _DirectionalLight_HighlightSize; + + CBUFFER_END + +//---------------------------------------------------------------------------------------------------------------------- + float4 _MainTex_ST; + + TEXTURE2D(_1st_ShadeMap); + TEXTURE2D(_2nd_ShadeMap); + + TEXTURE2D(_HighlightTex); + SAMPLER(sampler_HighlightTex); + float4 _HighlightTex_ST; + + #include "ObjectTransform.hlsl" + #include "ShapeLight2D.hlsl" + + //_HDREmulationScale declaration + #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/ShapeLightVariables.hlsl" + + Varyings ToonVertex(Attributes input) { + + Varyings o = (Varyings) 0; + UNITY_SETUP_INSTANCE_ID(input); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); + + o.positionCS = TransformObjectToHClip(input.positionOS); + const float3 normalWS = TransformObjectToWorldDir(input.normal); + + o.uv = input.uv; + o.lightingUV = half2(ComputeScreenPos(o.positionCS / o.positionCS.w).xy); + o.normalWS = normalWS; + + const float3 tangentWS = normalize( mul( GetObjectToWorldMatrix(), float4( input.tangent.xyz, 0 ) ).xyz); + o.tangentWS = float4(tangentWS, input.tangent.w); + o.positionWS = TransformObjectToWorld(input.positionOS); + + return o; + } + + + float3 ThreeColorsLinearShading( + float3 baseColor, + float3 firstColor, + float3 secondColor, + float3 baseTo1stStart, // t=0: use base, t=1: transition + float3 baseTo1stFeather, + float3 firstToSecondStart, //t=0: use base, t=1: transition + float3 firstToSecondFeather, + float dotNL) // dot(N.L) + { + const float t = saturate(1 - dotNL); //t = 0: light, t=1: dark shaded + + const float invBaseTo1stStart = 1 - baseTo1stStart; + const float invBaseTo2ndStart = 1 - firstToSecondStart; + + const float s1 = smoothstep(invBaseTo1stStart, invBaseTo1stStart + baseTo1stFeather,t); + const float s2 = smoothstep(invBaseTo2ndStart, invBaseTo2ndStart + firstToSecondFeather,t); + + float3 c01 = lerp(baseColor,firstColor, s1); + float3 c12 = lerp(c01, secondColor, s2); + return c12; + } + + + half4 CombinedShapeLightAndToon(ShapeLightResult shapeLightResult, SurfaceData2D surfaceData, + in float2 uv, + in float3 tangentWS, in float3 bitangentWS, in float3 normalWS, in float3 positionWS) + { + const half alpha = surfaceData.alpha; + + float3x3 tangentTransform = float3x3( tangentWS, bitangentWS, normalWS); + const float3 normalTS = surfaceData.normalTS; + float3 perturbedNormalWS = normalize(mul( normalTS, tangentTransform )); // Perturbed normals + + half4 light2dMod = shapeLightResult.mod; + half4 light2dAdd = shapeLightResult.add; + + const float light2dIntensity = max( + light2dMod.r * light2dAdd.r, max( + light2dMod.g + light2dAdd.g, + light2dMod.b + light2dAdd.b)); + + const half4 mainTex = half4(surfaceData.albedo, alpha); + const float3 baseAlbedo = _BaseColor.rgb * mainTex.rgb; + + //1st and 2nd Shade + const float4 firstShadeTex = lerp( + SAMPLE_TEXTURE2D(_1st_ShadeMap, sampler_MainTex, TRANSFORM_TEX(uv, _MainTex)), mainTex, + _Use_BaseAs1st); + const float3 firstShadeAlbedo = _1st_ShadeColor.rgb * firstShadeTex.rgb; + + const float4 secondShadeTex = lerp( + SAMPLE_TEXTURE2D(_2nd_ShadeMap, sampler_MainTex, TRANSFORM_TEX(uv, _MainTex)), firstShadeTex, + _Use_1stAs2nd); + const float3 secondShadeAlbedo = _2nd_ShadeColor.rgb * secondShadeTex.rgb; + + //perform 3 color linear shading with 2D colors and lights + const float3 color2D = ThreeColorsLinearShading( + (baseAlbedo * light2dMod + light2dAdd).rgb, + (firstShadeAlbedo * light2dMod + light2dAdd).rgb, + (secondShadeAlbedo * light2dMod + light2dAdd).rgb, + _BaseTo1st_ShadeStart, _BaseTo1st_ShadeFeather, + _1stTo2nd_ShadeStart, _1stTo2nd_ShadeFeather, light2dIntensity); + + + + //Toon Directional Light + const float3 directionalLightColorAndUse = _DirectionalLight_Color.rgb * _DirectionalLight_Use; + const float3 directionalLightDirection = normalize(-_DirectionalLight_Direction); + const float dotNL = 0.5 * dot( perturbedNormalWS, directionalLightDirection) + 0.5; + + const float3 toonDiffuseColor = ThreeColorsLinearShading( + baseAlbedo * directionalLightColorAndUse, + firstShadeAlbedo * directionalLightColorAndUse, + secondShadeAlbedo * directionalLightColorAndUse, + _BaseTo1st_ShadeStart, _BaseTo1st_ShadeFeather, + _1stTo2nd_ShadeStart, _1stTo2nd_ShadeFeather, + dotNL); + + const float3 finalDiffuseColor = color2D * _2DLightStrength + + toonDiffuseColor * _DirectionalLight_DiffuseStrength; + + //Highlight + const float3 viewDirection = normalize(_DirectionalLight_ViewPosition - positionWS); + const float3 halfDirection = normalize(viewDirection + directionalLightDirection); + float dotHN_01 = 0.5 * dot(halfDirection,perturbedNormalWS) + 0.5; + + const float highlight = + lerp( (1.0 - step(dotHN_01,(1.0 - pow(abs(_DirectionalLight_HighlightSize),5)))), + pow(abs(dotHN_01),exp2(lerp(11,1,_DirectionalLight_HighlightSize))), + _DirectionalLight_HighlightMode ); + + + const float4 highlightTex = SAMPLE_TEXTURE2D(_HighlightTex, sampler_HighlightTex, TRANSFORM_TEX(uv, _HighlightTex)); + const float3 highlightAlbedo = highlightTex.rgb * _HighlightColor.rgb; + const float3 highlightFactor = directionalLightColorAndUse * _DirectionalLight_HighlightStrength; + + const float3 finalHighlightColor = highlightAlbedo * highlightFactor * highlight; + + const float3 finalColor = _HDREmulationScale * (finalDiffuseColor + finalHighlightColor); + + return float4(finalColor,alpha); + } + + + half4 ToonFragment(Varyings input) : SV_Target { + const half4 main = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv); + const half4 mask = SAMPLE_TEXTURE2D(_MaskTex, sampler_MaskTex, input.uv); + const half3 normalTS = UnpackNormalScale(SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, input.uv), _BumpScale); + + SurfaceData2D surfaceData; + + const float3 normalWS = normalize(input.normalWS); + const float3 tangentWS = normalize(input.tangentWS); + const float3 bitangentWS = normalize(cross(normalWS, tangentWS) * input.tangentWS.w); + + const float alpha = main.a; + + InitializeSurfaceData(main.rgb, alpha, mask, normalTS, surfaceData); + + #if defined(DEBUG_DISPLAY) + SETUP_DEBUG_TEXTURE_DATA_2D_NO_TS(inputData, input.positionWS, input.positionCS, _MainTex); + surfaceData.normalWS = input.normalWS; + #endif + + if (alpha == 0.0) + discard; + + ShapeLightResult shapeLightResult = CombinedShapeLight(mask, input.lightingUV); + + + return CombinedShapeLightAndToon(shapeLightResult, surfaceData, input.uv, + tangentWS, bitangentWS, normalWS, input.positionWS); + } + + + ENDHLSL + } + +//---------------------------------------------------------------------------------------------------------------------- + Pass { + Name "Outline" + Tags { + "LightMode" = "SRPDefaultUnlit" + } +// Cull [_SRPDefaultUnlitColMode] +// ColorMask [_SPRDefaultUnlitColorMask] + Blend SrcAlpha OneMinusSrcAlpha +// Stencil +// { +// Ref[_StencilNo] +// Comp[_StencilComp] +// Pass[_StencilOpPass] +// Fail[_StencilOpFail] +// +// } + + + HLSLPROGRAM + #pragma target 3.0 + #pragma vertex OutlineVertex + #pragma fragment OutlineFragment + + #pragma multi_compile TOON_OUTLINE_NORMAL TOON_OUTLINE_POS + // Outline is implemented in UniversalToonOutline.hlsl. + // #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + // #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl" + + //USE_SHAPE_LIGHT keywords + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/ShapeLightShared.hlsl" + + //_HDREmulationScale declaration + #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/ShapeLightVariables.hlsl" + + struct OutlineVertexInput { + float4 vertex : POSITION; + float3 normal : NORMAL; + float4 tangent : TANGENT; + float2 texcoord0 : TEXCOORD0; + UNITY_VERTEX_INPUT_INSTANCE_ID + }; + + struct OutlineVertexOutput { + float4 pos : SV_POSITION; + float2 uv0 : TEXCOORD0; + half2 lightingUV : TEXCOORD1; + UNITY_VERTEX_OUTPUT_STEREO + }; + + TEXTURE2D(_MainTex); + SAMPLER(sampler_MainTex); + float4 _MainTex_ST; + + TEXTURE2D(_MaskTex); + SAMPLER(sampler_MaskTex); + + TEXTURE2D(_OutlineWidthMap); + SAMPLER(sampler_OutlineWidthMap); + float4 _OutlineWidthMap_ST; + + TEXTURE2D(_OutlineTex); + SAMPLER(sampler_OutlineTex); + float4 _OutlineTex_ST; + + TEXTURE2D(_Outline_NormalMap); + SAMPLER(sampler_Outline_NormalMap); + float4 _Outline_NormalMap_ST; + int _Outline_UseNormalMap; + + CBUFFER_START(UnityPerMaterial) + + float _2DLightStrength; + int _DirectionalLight_Use; + float4 _DirectionalLight_Color; + float _DirectionalLight_DiffuseStrength; + + half4 _BaseColor; + float _OutlineOffsetZ; + float _OutlineWidth; + float _OutlineNear; + float _OutlineFar; + float4 _OutlineColor; + float _Outline_BaseColorBlend; + float _Outline_LightColorBlend; + + CBUFFER_END + + #include "ObjectTransform.hlsl" + #include "ShapeLight2D.hlsl" + + OutlineVertexOutput OutlineVertex(OutlineVertexInput v) { + OutlineVertexOutput o = (OutlineVertexOutput) 0; + UNITY_SETUP_INSTANCE_ID(input); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); + + const float2 uv = v.texcoord0; + o.uv0 = v.texcoord0; + + const float4 objPos = mul (GetObjectToWorldMatrix(), float4(0,0,0,1) ); + + const float outlineWidthAlbedo = SAMPLE_TEXTURE2D_LOD(_OutlineWidthMap, sampler_OutlineWidthMap, + TRANSFORM_TEX(uv, _OutlineWidthMap),0).r; + const float outlineWidth = _OutlineWidth * 0.001 * outlineWidthAlbedo; + + float finalOutlineWidth = outlineWidth * smoothstep( _OutlineFar, _OutlineNear, distance(objPos.rgb,_WorldSpaceCameraPos) ); + + float3 newPos; +#ifdef TOON_OUTLINE_NORMAL + + //TBN + const float3 normalDir = UnityObjectToWorldNormal(v.normal); + const float3 tangentDir = normalize( mul( GetObjectToWorldMatrix(), float4( v.tangent.xyz, 0.0 ) ).xyz ); + const float3 bitangentDir = normalize(cross(normalDir, tangentDir) * v.tangent.w); + float3x3 tangentTransform = float3x3(tangentDir, bitangentDir, normalDir); + + //Outline normal map + const float4 customNormalMap = SAMPLE_TEXTURE2D_LOD( + _Outline_NormalMap, sampler_Outline_NormalMap, TRANSFORM_TEX(uv, _Outline_NormalMap),0); + const float3 normalTS = UnpackNormal(customNormalMap); + const float3 outlineNormalMapWS = normalize(mul(normalTS.xyz, tangentTransform)); + + const float3 outlineDir = lerp(v.normal, outlineNormalMapWS, _Outline_UseNormalMap); + + newPos = float4(v.vertex.xyz + outlineDir * finalOutlineWidth,1); + o.pos = TransformObjectToHClip(newPos); +#elif TOON_OUTLINE_POS + const float3 normalizedPos = normalize(v.vertex.xyz); + const float signPN = sign(dot(normalizedPos,normalize(v.normal))); + o.pos = UnityObjectToClipPos(float4(v.vertex.xyz + signPN * normalizedPos * finalOutlineWidth, 1)); +#endif + const float scaledOutlineOffsetZ = _OutlineOffsetZ * -0.01; + o.pos.z = o.pos.z + scaledOutlineOffsetZ; + + o.lightingUV = half2(ComputeScreenPos(o.pos / o.pos.w).xy); + return o; + } + + + half4 OutlineFragment(OutlineVertexOutput i) : SV_Target { + + const half4 mask = SAMPLE_TEXTURE2D(_MaskTex, sampler_MaskTex, i.uv0); + const half2 lightingUV = i.lightingUV; + + const float2 Set_UV0 = i.uv0; + float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)); + float3 Set_BaseColor = _BaseColor.rgb * _MainTex_var.rgb; + + const float3 outlineTex = tex2D(sampler_OutlineTex,TRANSFORM_TEX(Set_UV0, _OutlineTex)).rgb; + const float3 outlineAlbedo = outlineTex * _OutlineColor.rgb; + + //Blend with baseColor + const float3 outlineBaseBlend = lerp(outlineAlbedo, outlineAlbedo * Set_BaseColor, _Outline_BaseColorBlend); + + //Blend with light + ShapeLightResult shapeLightResult = CombinedShapeLight(mask, lightingUV); + const float3 color2D = (outlineBaseBlend.rgb * shapeLightResult.mod.rgb) + shapeLightResult.add.rgb; + const float3 colorToon = outlineBaseBlend.rgb * _DirectionalLight_Color.rgb * _DirectionalLight_Use; + const float3 outlineLightColor = (color2D * _2DLightStrength) + + (colorToon * _DirectionalLight_DiffuseStrength); + + const float3 outlineBaseAndLightBlend = lerp(outlineBaseBlend, outlineLightColor, _Outline_LightColorBlend); + + return float4(_HDREmulationScale * outlineBaseAndLightBlend,1.0); + } + + + ENDHLSL + } + + +//---------------------------------------------------------------------------------------------------------------------- + Pass{ + Tags{ + "LightMode" = "NormalsRendering" + } + + HLSLPROGRAM + #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl" + + #pragma vertex NormalsRenderingVertex + #pragma fragment NormalsRenderingFragment + + // GPU Instancing + #pragma multi_compile_instancing + + struct Attributes { + COMMON_2D_NORMALS_INPUTS + }; + + struct Varyings { + COMMON_2D_NORMALS_OUTPUTS + }; + + float4 _White; + + #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Normals2DCommon.hlsl" + + Varyings NormalsRenderingVertex(Attributes input) { + return CommonNormalsVertex(input); + } + + half4 NormalsRenderingFragment(Varyings input) : SV_Target { + return CommonNormalsFragment(input, _White); + } + ENDHLSL + } + + Pass{ + Tags{ + "LightMode" = "UniversalForward" "Queue"="Transparent" "RenderType"="Transparent" + } + + HLSLPROGRAM + #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl" + + #pragma vertex UnlitVertex + #pragma fragment UnlitFragment + + // GPU Instancing + #pragma multi_compile_instancing + + struct Attributes { + COMMON_2D_INPUTS + }; + + struct Varyings { + COMMON_2D_OUTPUTS + }; + + float4 _White; + + #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/2DCommon.hlsl" + + Varyings UnlitVertex(Attributes input) { + return CommonUnlitVertex(input); + } + + half4 UnlitFragment(Varyings input) : SV_Target { + return CommonUnlitFragment(input, _White); + } + ENDHLSL + } + + } + + CustomEditor "UnityEditor.Rendering.Toon.UnityToon3Das2DGUI" + +} + + +//[Note-sin: 2025-11-24] Texture that only needs one channel at the moment +//1. _OutlineWidthMap diff --git a/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ToonURP_3Das2D.shader.meta b/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ToonURP_3Das2D.shader.meta new file mode 100644 index 0000000..dca3b76 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Shaders/URP/ToonURP_3Das2D.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 60d646244f75ab84f8eb12819a6d87ff +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UTSHelpURLAttribute.cs b/BJH/Assets/BJH/3dtest/Runtime/UTSHelpURLAttribute.cs new file mode 100644 index 0000000..cb54de0 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UTSHelpURLAttribute.cs @@ -0,0 +1,17 @@ +using UnityEngine; + +namespace Unity.Rendering.Toon { +internal class UTSHelpURLAttribute : HelpURLAttribute { + + internal UTSHelpURLAttribute(string pageName) + : base(GetPageLink(pageName)) { + } + + static string GetPageLink(string pageName) => string.Format(DOC_URL, + ToonConstants.PACKAGE_NAME, ToonConstants.PACKAGE_VERSION_MAJOR_MINOR, pageName); + +//---------------------------------------------------------------------------------------------------------------------- + const string DOC_URL = "https://docs.unity3d.com/Packages/{0}@{1}/manual/{2}.html"; + +} +} \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/UTSHelpURLAttribute.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/UTSHelpURLAttribute.cs.meta new file mode 100644 index 0000000..e4453e5 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UTSHelpURLAttribute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0a5dac3febee3d741874fee99df66754 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/Unity.ToonShader.asmdef b/BJH/Assets/BJH/3dtest/Runtime/Unity.ToonShader.asmdef new file mode 100644 index 0000000..b92ca9e --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Unity.ToonShader.asmdef @@ -0,0 +1,33 @@ +{ + "name": "Unity.Toonshader", + "references": [ + "GUID:df380645f10b7bc4b97d4f5eb6303d95", + "GUID:3eae0364be2026648bf74846acb8a731", + "GUID:457756d89b35d2941b3e7b37b4ece6f1" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [ + { + "name": "com.unity.render-pipelines.high-definition", + "expression": "", + "define": "HDRP_IS_INSTALLED_FOR_UTS" + }, + { + "name": "com.unity.render-pipelines.universal", + "expression": "", + "define": "URP_IS_INSTALLED_FOR_UTS" + }, + { + "name": "com.unity.render-pipelines.core", + "expression": "", + "define": "SRPCORE_IS_INSTALLED_FOR_UTS" + } + ], + "noEngineReferences": false +} \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/Unity.ToonShader.asmdef.meta b/BJH/Assets/BJH/3dtest/Runtime/Unity.ToonShader.asmdef.meta new file mode 100644 index 0000000..ded319e --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/Unity.ToonShader.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: edb4b6a0ed74e0148ab4215de39cc4b9 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan.meta new file mode 100644 index 0000000..868104f --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8bb9b2274f9dd3a4097bf170e5d479ac +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common.meta new file mode 100644 index 0000000..b0cc586 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1594b78137fae81489239dfac9edd8e0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor.meta new file mode 100644 index 0000000..0303199 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d83e6c11f45163843af2d9a321f433b8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/AssemblyInfo.cs b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/AssemblyInfo.cs new file mode 100644 index 0000000..b98af70 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; +[assembly: InternalsVisibleTo("Unity.ToonShader.GraphicsTest.Editor")] + diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/AssemblyInfo.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/AssemblyInfo.cs.meta new file mode 100644 index 0000000..f171633 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/AssemblyInfo.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: d738f4626d5dac244bf5cc9b31d2fdc0 \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/Scripts.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/Scripts.meta new file mode 100644 index 0000000..6b0fc0f --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1ec6717d783050d46a12791fa08c4aba +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/Scripts/SpringManagerInspector.cs b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/Scripts/SpringManagerInspector.cs new file mode 100644 index 0000000..448bc31 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/Scripts/SpringManagerInspector.cs @@ -0,0 +1,26 @@ +using UnityEditor; +using UnityEngine; + +namespace UnityChan.Editor { +[CustomEditor(typeof(SpringManager))] +public class SpringManagerInspector : UnityEditor.Editor { + public override void OnInspectorGUI() { + DrawDefaultInspector(); + + SpringManager manager = (SpringManager)target; + + if (GUILayout.Button("Init From Children")) { + SpringBone[] springBones = manager.GetComponentsInChildren(true); + SerializedProperty springBonesProp = serializedObject.FindProperty(nameof(SpringManager.m_springBones)); + + springBonesProp.arraySize = springBones.Length; + for (int i = 0; i < springBones.Length; i++) { + springBonesProp.GetArrayElementAtIndex(i).objectReferenceValue = springBones[i]; + } + + serializedObject.ApplyModifiedProperties(); + } + } +} + +} \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/Scripts/SpringManagerInspector.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/Scripts/SpringManagerInspector.cs.meta new file mode 100644 index 0000000..b9a985f --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/Scripts/SpringManagerInspector.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 83c3e5189a7b4834e89619ac152117b8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/UnityChan.Common.Editor.asmdef b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/UnityChan.Common.Editor.asmdef new file mode 100644 index 0000000..84f01a0 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/UnityChan.Common.Editor.asmdef @@ -0,0 +1,18 @@ +{ + "name": "UnityChan.Editor", + "rootNamespace": "", + "references": [ + "GUID:b345186b07ed1cb48851ec93cb78ca71" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/UnityChan.Common.Editor.asmdef.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/UnityChan.Common.Editor.asmdef.meta new file mode 100644 index 0000000..ee3731c --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Editor/UnityChan.Common.Editor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1d84e079c2939be41996b4cc37e6b3d4 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime.meta new file mode 100644 index 0000000..c07020e --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4cb9c611c458ad44ca22fb834c3ec0ee +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/AssemblyInfo.cs b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/AssemblyInfo.cs new file mode 100644 index 0000000..7cbe0a9 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/AssemblyInfo.cs @@ -0,0 +1,5 @@ +using System.Runtime.CompilerServices; +[assembly: InternalsVisibleTo("UnityChan.Editor")] + +[assembly: InternalsVisibleTo("Unity.ToonShader.GraphicsTest")] +[assembly: InternalsVisibleTo("Unity.ToonShader.GraphicsTest.Editor")] diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/AssemblyInfo.cs.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/AssemblyInfo.cs.meta new file mode 100644 index 0000000..7af2741 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/AssemblyInfo.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 9a61ec2068c5c5745a3f4ce621c77237 diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Materials.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Materials.meta new file mode 100644 index 0000000..949de33 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Materials.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7bc474fc608f46746b6fc4a90fd803f8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Materials/Stage.mat b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Materials/Stage.mat new file mode 100644 index 0000000..b2835c1 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Materials/Stage.mat @@ -0,0 +1,522 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Stage + m_Shader: {fileID: 4800000, guid: be891319084e9d147b09d89e80ce60e0, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: + - _ALPHATEST_ON + - _EMISSIVE_SIMPLE + - _IS_ANGELRING_OFF + - _IS_CLIPPING_TRANSMODE + - _IS_OUTLINE_CLIPPING_YES + - _OUTLINE_NML + m_InvalidKeywords: + - _EMISSION + m_LightmapFlags: 1 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: 3000 + stringTagMap: + IgnoreProjection: true + RenderType: Transparent + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _1st_ShadeMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _2nd_ShadeMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _AngelRing_Sampler: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _AnisotropyMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BakedNormal: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BaseColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BentNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BentNormalMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ClippingMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _CoatMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DistortionVectorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissiveColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Emissive_Tex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _HeightMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _HighColor_Tex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _IridescenceMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _IridescenceThicknessMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: 3d1fac570c82df745a7f0a358ec55b0b, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MatCap_Sampler: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NormalMapForMatCap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NormalMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OutlineTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Outline_Sampler: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Set_1st_ShadePosition: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Set_2nd_ShadePosition: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Set_HighColorMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Set_MatcapMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Set_RimLightMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ShadingGradeMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecularColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SubsurfaceMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TangentMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TangentMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ThicknessMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TransmittanceColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _1st2nd_Shades_Feather: 0.25 + - _1st_ShadeColor_Feather: 0.25 + - _1st_ShadeColor_Step: 0.8 + - _2nd_ShadeColor_Feather: 0.25 + - _2nd_ShadeColor_Step: 0.5 + - _AORemapMax: 1 + - _AORemapMin: 0 + - _ARSampler_AlphaOn: 0 + - _AR_OffsetU: 0 + - _AR_OffsetV: 0.3 + - _ATDistance: 1 + - _AddPrecomputedVelocity: 0 + - _Add_Antipodean_RimLight: 0 + - _AlbedoAffectEmissive: 0 + - _AlphaCutoff: 0.5 + - _AlphaCutoffEnable: 0 + - _AlphaCutoffPostpass: 0.5 + - _AlphaCutoffPrepass: 0.5 + - _AlphaCutoffShadow: 0.5 + - _AlphaDstBlend: 0 + - _AlphaRemapMax: 1 + - _AlphaRemapMin: 0 + - _AlphaSrcBlend: 1 + - _AngelRing: 0 + - _AngelRingOverridden: 0 + - _AngelRingVisible: 1 + - _Anisotropy: 0 + - _Ap_RimLight_FeatherOff: 0 + - _Ap_RimLight_Power: 0.1 + - _AutoRenderQueue: 1 + - _BaseColorOverridden: 0 + - _BaseColorVisible: 1 + - _BaseColor_Step: 0.8 + - _BaseShade_Feather: 0.25 + - _Base_Speed: 0 + - _BlendMode: 0 + - _BlurLevelMatcap: 0 + - _BlurLevelSGM: 0 + - _BumpScale: 1 + - _BumpScaleMatcap: 1 + - _CameraRolling_Stabilizer: 0 + - _ClippingMatteMode: 0 + - _ClippingMode: 2 + - _Clipping_Level: 0 + - _CoatMask: 0 + - _ColorShift_Speed: 0 + - _ComposerMaskMode: 0 + - _CullMode: 2 + - _CullModeForward: 2 + - _Cutoff: 0.404 + - _DepthOffsetEnable: 0 + - _DetailAlbedoScale: 1 + - _DetailNormalMapScale: 1 + - _DetailNormalScale: 1 + - _DetailSmoothnessScale: 1 + - _DiffusionProfile: 0 + - _DiffusionProfileHash: 0 + - _DisplacementLockObjectScale: 1 + - _DisplacementLockTilingScale: 1 + - _DisplacementMode: 0 + - _DistortionBlendMode: 0 + - _DistortionBlurBlendMode: 0 + - _DistortionBlurDstBlend: 0 + - _DistortionBlurRemapMax: 1 + - _DistortionBlurRemapMin: 0 + - _DistortionBlurScale: 1 + - _DistortionBlurSrcBlend: 0 + - _DistortionDepthTest: 1 + - _DistortionDstBlend: 0 + - _DistortionEnable: 0 + - _DistortionScale: 1 + - _DistortionSrcBlend: 0 + - _DistortionVectorBias: -1 + - _DistortionVectorScale: 2 + - _DoubleSidedEnable: 0 + - _DoubleSidedNormalMode: 1 + - _DstBlend: 0 + - _EMISSIVE: 0 + - _EmissiveColorMode: 1 + - _EmissiveExposureWeight: 1 + - _EmissiveIntensity: 1 + - _EmissiveIntensityUnit: 0 + - _EnableBlendModePreserveSpecularLighting: 1 + - _EnableFogOnTransparent: 1 + - _EnableGeometricSpecularAA: 0 + - _EnergyConservingSpecularColor: 1 + - _Farthest_Distance: 100 + - _FirstShadeOverridden: 0 + - _FirstShadeVisible: 1 + - _GI_Intensity: 0 + - _GlossMapScale: 1 + - _Glossiness: 0 + - _GlossyReflections: 1 + - _HeightAmplitude: 0.02 + - _HeightCenter: 0.5 + - _HeightMapParametrization: 0 + - _HeightMax: 1 + - _HeightMin: -1 + - _HeightOffset: 0 + - _HeightPoMAmplitude: 2 + - _HeightTessAmplitude: 2 + - _HeightTessCenter: 0.5 + - _HighColor_Power: 0 + - _HighlightOverridden: 0 + - _HighlightVisible: 1 + - _InvTilingScale: 1 + - _Inverse_Clipping: 0 + - _Inverse_MatcapMask: 0 + - _Inverse_Z_Axis_BLD: 1 + - _Ior: 1 + - _IridescenceMask: 1 + - _IridescenceThickness: 1 + - _IsBaseMapAlphaAsClippingMask: 1 + - _Is_BLD: 0 + - _Is_BakedNormal: 0 + - _Is_BlendAddToHiColor: 0 + - _Is_BlendAddToMatCap: 1 + - _Is_BlendBaseColor: 0 + - _Is_ColorShift: 0 + - _Is_Filter_HiCutPointLightColor: 1 + - _Is_Filter_LightColor: 1 + - _Is_LightColor_1st_Shade: 1 + - _Is_LightColor_2nd_Shade: 1 + - _Is_LightColor_AR: 1 + - _Is_LightColor_Ap_RimLight: 1 + - _Is_LightColor_Base: 1 + - _Is_LightColor_HighColor: 1 + - _Is_LightColor_MatCap: 1 + - _Is_LightColor_Outline: 1 + - _Is_LightColor_RimLight: 1 + - _Is_NormalMapForMatCap: 0 + - _Is_NormalMapToBase: 0 + - _Is_NormalMapToHighColor: 0 + - _Is_NormalMapToRimLight: 0 + - _Is_Ortho: 0 + - _Is_OutlineTex: 0 + - _Is_PingPong_Base: 0 + - _Is_SpecularToHighColor: 0 + - _Is_UseTweakHighColorOnShadow: 0 + - _Is_UseTweakMatCapOnShadow: 0 + - _Is_ViewCoord_Scroll: 0 + - _Is_ViewShift: 0 + - _LightDirection_MaskOn: 0 + - _LinkDetailsWithBase: 1 + - _MatCap: 0 + - _MaterialID: 1 + - _Metallic: 0 + - _Mode: 1 + - _Nearest_Distance: 0.5 + - _NormalMapSpace: 0 + - _NormalScale: 1 + - _OUTLINE: 0 + - _ObjectSpaceUVMapping: 0 + - _OcclusionStrength: 1 + - _Offset_X_Axis_BLD: -0.05 + - _Offset_Y_Axis_BLD: 0.09 + - _Offset_Z: 0 + - _OutlineOverridden: 0 + - _OutlineVisible: 1 + - _Outline_Width: 0 + - _PPDLodThreshold: 5 + - _PPDMaxSamples: 15 + - _PPDMinSamples: 5 + - _PPDPrimitiveLength: 1 + - _PPDPrimitiveWidth: 1 + - _Parallax: 0.02 + - _ReceivesSSR: 1 + - _RefractionModel: 0 + - _RimLight: 0 + - _RimLightOverridden: 0 + - _RimLightVisible: 1 + - _RimLight_FeatherOff: 0 + - _RimLight_InsideMask: 0.0001 + - _RimLight_Power: 0.1 + - _Rotate_EmissiveUV: 0 + - _Rotate_MatCapUV: 0 + - _Rotate_NormalMapForMatCapUV: 0 + - _SPRDefaultUnlitColorMask: 0 + - _SRPDefaultUnlitColMode: 2 + - _SSRefractionProjectionModel: 0 + - _Scroll_EmissiveU: 0 + - _Scroll_EmissiveV: 0 + - _SecondShadeOverridden: 0 + - _SecondShadeVisible: 1 + - _Set_SystemShadowsToBase: 1 + - _ShadeColor_Step: 0.5 + - _Smoothness: 0.5 + - _SmoothnessRemapMax: 1 + - _SmoothnessRemapMin: 0 + - _SmoothnessTextureChannel: 0 + - _SpecularAAScreenSpaceVariance: 0.1 + - _SpecularAAThreshold: 0.2 + - _SpecularHighlights: 1 + - _SpecularOcclusionMode: 1 + - _SrcBlend: 1 + - _StencilComp: 0 + - _StencilMode: 0 + - _StencilNo: 1 + - _StencilOpFail: 0 + - _StencilOpPass: 0 + - _StencilRef: 2 + - _StencilRefDepth: 0 + - _StencilRefDistortionVec: 64 + - _StencilRefGBuffer: 2 + - _StencilRefMV: 128 + - _StencilWriteMask: 3 + - _StencilWriteMaskDepth: 32 + - _StencilWriteMaskDistortionVec: 64 + - _StencilWriteMaskGBuffer: 3 + - _StencilWriteMaskMV: 128 + - _StepOffset: 0 + - _SubsurfaceMask: 1 + - _SupportDecals: 1 + - _SurfaceType: 0 + - _TexWorldScale: 1 + - _TexWorldScaleEmissive: 1 + - _Thickness: 1 + - _ThicknessMultiplier: 1 + - _TransmissionEnable: 1 + - _TransmissionMask: 1 + - _TransparentBackfaceEnable: 0 + - _TransparentCullMode: 2 + - _TransparentDepthPostpassEnable: 0 + - _TransparentDepthPrepassEnable: 0 + - _TransparentEnabled: 1 + - _TransparentSortPriority: 0 + - _TransparentWritingMotionVec: 0 + - _TransparentZWrite: 0 + - _TweakHighColorOnShadow: 0 + - _TweakMatCapOnShadow: 0 + - _Tweak_HighColorMaskLevel: 0 + - _Tweak_LightDirection_MaskLevel: 0 + - _Tweak_MatCapUV: 0 + - _Tweak_MatcapMaskLevel: 0 + - _Tweak_RimLightMaskLevel: 0 + - _Tweak_ShadingGradeMapLevel: 0 + - _Tweak_SystemShadowsLevel: 0 + - _Tweak_transparency: 0 + - _UVBase: 0 + - _UVDetail: 0 + - _UVEmissive: 0 + - _UVSec: 0 + - _Unlit_Intensity: 0 + - _UseEmissiveIntensity: 0 + - _UseShadowThreshold: 0 + - _Use_1stAs2nd: 1 + - _Use_BaseAs1st: 1 + - _ZOverDrawMode: 1 + - _ZTestDepthEqualForOpaque: 4 + - _ZTestGBuffer: 4 + - _ZTestModeDistortion: 8 + - _ZTestTransparent: 4 + - _ZWrite: 1 + - _ZWriteMode: 0 + - _isUnityToonshader: 1 + - _simpleUI: 0 + - _utsTechnique: 0 + - _utsVersionX: 0 + - _utsVersionY: 11 + - _utsVersionZ: 0 + m_Colors: + - _1st_ShadeColor: {r: 0.7264151, g: 0.7264151, b: 0.7264151, a: 1} + - _2nd_ShadeColor: {r: 0.509434, g: 0.509434, b: 0.509434, a: 1} + - _AngelRingMaskColor: {r: 0, g: 1, b: 0, a: 1} + - _AngelRing_Color: {r: 1, g: 1, b: 1, a: 1} + - _Ap_RimLightColor: {r: 1, g: 1, b: 1, a: 1} + - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _BaseColorMap_MipInfo: {r: 0, g: 0, b: 0, a: 0} + - _BaseColorMaskColor: {r: 1, g: 1, b: 1, a: 1} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _ColorShift: {r: 0, g: 0, b: 0, a: 1} + - _DiffusionProfileAsset: {r: 0, g: 0, b: 0, a: 0} + - _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0} + - _EmissionColor: {r: 0.08014706, g: 0.0975355, b: 0.1, a: 1} + - _EmissiveColor: {r: 0, g: 0, b: 0, a: 1} + - _EmissiveColorLDR: {r: 0, g: 0, b: 0, a: 1} + - _Emissive_Color: {r: 0, g: 0, b: 0, a: 1} + - _FirstShadeMaskColor: {r: 0, g: 1, b: 1, a: 1} + - _HighColor: {r: 0, g: 0, b: 0, a: 1} + - _HighlightMaskColor: {r: 1, g: 1, b: 0, a: 1} + - _InvPrimScale: {r: 1, g: 1, b: 0, a: 0} + - _IridescenceThicknessRemap: {r: 0, g: 1, b: 0, a: 0} + - _MatCapColor: {r: 1, g: 1, b: 1, a: 1} + - _OutlineMaskColor: {r: 0, g: 0, b: 0, a: 1} + - _Outline_Color: {r: 0.5, g: 0.5, b: 0.5, a: 1} + - _RimLightColor: {r: 1, g: 1, b: 1, a: 1} + - _RimLightMaskColor: {r: 1, g: 0, b: 1, a: 1} + - _SecondShadeMaskColor: {r: 0, g: 0, b: 1, a: 1} + - _SpecularColor: {r: 1, g: 1, b: 1, a: 1} + - _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0} + - _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1} + - _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0} + - _UVMappingMask: {r: 1, g: 0, b: 0, a: 0} + - _UVMappingMaskEmissive: {r: 1, g: 0, b: 0, a: 0} + - _ViewShift: {r: 0, g: 0, b: 0, a: 1} + - emissive: {r: 0, g: 0, b: 0, a: 1} + m_BuildTextureStacks: [] + m_AllowLocking: 1 diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Materials/Stage.mat.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Materials/Stage.mat.meta new file mode 100644 index 0000000..fc99255 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Materials/Stage.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3161fc0b8824b584f86cee2ca727fbe1 +timeCreated: 1452332289 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Materials/Target.mat b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Materials/Target.mat new file mode 100644 index 0000000..8e8a3d4 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Materials/Target.mat @@ -0,0 +1,521 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Target + m_Shader: {fileID: 4800000, guid: be891319084e9d147b09d89e80ce60e0, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: + - _EMISSIVE_SIMPLE + - _IS_ANGELRING_OFF + - _IS_CLIPPING_OFF + - _IS_OUTLINE_CLIPPING_NO + - _OUTLINE_NML + m_InvalidKeywords: + - _EMISSION + m_LightmapFlags: 1 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: + IgnoreProjection: False + RenderType: Opaque + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _1st_ShadeMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _2nd_ShadeMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _AngelRing_Sampler: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _AnisotropyMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BakedNormal: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BaseColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BentNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BentNormalMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ClippingMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _CoatMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DistortionVectorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissiveColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Emissive_Tex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _HeightMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _HighColor_Tex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _IridescenceMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _IridescenceThicknessMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MatCap_Sampler: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NormalMapForMatCap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NormalMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OutlineTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Outline_Sampler: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Set_1st_ShadePosition: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Set_2nd_ShadePosition: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Set_HighColorMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Set_MatcapMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Set_RimLightMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ShadingGradeMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecularColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SubsurfaceMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TangentMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TangentMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ThicknessMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TransmittanceColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _1st2nd_Shades_Feather: 0.448 + - _1st_ShadeColor_Feather: 0.458 + - _1st_ShadeColor_Step: 1 + - _2nd_ShadeColor_Feather: 0.448 + - _2nd_ShadeColor_Step: 0.245 + - _AORemapMax: 1 + - _AORemapMin: 0 + - _ARSampler_AlphaOn: 0 + - _AR_OffsetU: 0 + - _AR_OffsetV: 0.3 + - _ATDistance: 1 + - _AddPrecomputedVelocity: 0 + - _Add_Antipodean_RimLight: 0 + - _AlbedoAffectEmissive: 0 + - _AlphaCutoff: 0.5 + - _AlphaCutoffEnable: 0 + - _AlphaCutoffPostpass: 0.5 + - _AlphaCutoffPrepass: 0.5 + - _AlphaCutoffShadow: 0.5 + - _AlphaDstBlend: 0 + - _AlphaRemapMax: 1 + - _AlphaRemapMin: 0 + - _AlphaSrcBlend: 1 + - _AngelRing: 0 + - _AngelRingOverridden: 0 + - _AngelRingVisible: 1 + - _Anisotropy: 0 + - _Ap_RimLight_FeatherOff: 0 + - _Ap_RimLight_Power: 0.1 + - _AutoRenderQueue: 1 + - _BaseColorOverridden: 0 + - _BaseColorVisible: 1 + - _BaseColor_Step: 1 + - _BaseShade_Feather: 0.458 + - _Base_Speed: 0 + - _BlendMode: 0 + - _BlurLevelMatcap: 0 + - _BlurLevelSGM: 0 + - _BumpScale: 1 + - _BumpScaleMatcap: 1 + - _CameraRolling_Stabilizer: 0 + - _ClippingMatteMode: 0 + - _ClippingMode: 0 + - _Clipping_Level: 0 + - _CoatMask: 0 + - _ColorShift_Speed: 0 + - _ComposerMaskMode: 0 + - _CullMode: 2 + - _CullModeForward: 2 + - _Cutoff: 0.5 + - _DepthOffsetEnable: 0 + - _DetailAlbedoScale: 1 + - _DetailNormalMapScale: 1 + - _DetailNormalScale: 1 + - _DetailSmoothnessScale: 1 + - _DiffusionProfile: 0 + - _DiffusionProfileHash: 0 + - _DisplacementLockObjectScale: 1 + - _DisplacementLockTilingScale: 1 + - _DisplacementMode: 0 + - _DistortionBlendMode: 0 + - _DistortionBlurBlendMode: 0 + - _DistortionBlurDstBlend: 0 + - _DistortionBlurRemapMax: 1 + - _DistortionBlurRemapMin: 0 + - _DistortionBlurScale: 1 + - _DistortionBlurSrcBlend: 0 + - _DistortionDepthTest: 1 + - _DistortionDstBlend: 0 + - _DistortionEnable: 0 + - _DistortionScale: 1 + - _DistortionSrcBlend: 0 + - _DistortionVectorBias: -1 + - _DistortionVectorScale: 2 + - _DoubleSidedEnable: 0 + - _DoubleSidedNormalMode: 1 + - _DstBlend: 0 + - _EMISSIVE: 0 + - _EmissiveColorMode: 1 + - _EmissiveExposureWeight: 1 + - _EmissiveIntensity: 1 + - _EmissiveIntensityUnit: 0 + - _EnableBlendModePreserveSpecularLighting: 1 + - _EnableFogOnTransparent: 1 + - _EnableGeometricSpecularAA: 0 + - _EnergyConservingSpecularColor: 1 + - _Farthest_Distance: 100 + - _FirstShadeOverridden: 0 + - _FirstShadeVisible: 1 + - _GI_Intensity: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _HeightAmplitude: 0.02 + - _HeightCenter: 0.5 + - _HeightMapParametrization: 0 + - _HeightMax: 1 + - _HeightMin: -1 + - _HeightOffset: 0 + - _HeightPoMAmplitude: 2 + - _HeightTessAmplitude: 2 + - _HeightTessCenter: 0.5 + - _HighColor_Power: 0 + - _HighlightOverridden: 0 + - _HighlightVisible: 1 + - _InvTilingScale: 1 + - _Inverse_Clipping: 0 + - _Inverse_MatcapMask: 0 + - _Inverse_Z_Axis_BLD: 1 + - _Ior: 1 + - _IridescenceMask: 1 + - _IridescenceThickness: 1 + - _IsBaseMapAlphaAsClippingMask: 0 + - _Is_BLD: 0 + - _Is_BakedNormal: 0 + - _Is_BlendAddToHiColor: 0 + - _Is_BlendAddToMatCap: 1 + - _Is_BlendBaseColor: 0 + - _Is_ColorShift: 0 + - _Is_Filter_HiCutPointLightColor: 1 + - _Is_Filter_LightColor: 1 + - _Is_LightColor_1st_Shade: 1 + - _Is_LightColor_2nd_Shade: 1 + - _Is_LightColor_AR: 1 + - _Is_LightColor_Ap_RimLight: 1 + - _Is_LightColor_Base: 1 + - _Is_LightColor_HighColor: 1 + - _Is_LightColor_MatCap: 1 + - _Is_LightColor_Outline: 1 + - _Is_LightColor_RimLight: 1 + - _Is_NormalMapForMatCap: 0 + - _Is_NormalMapToBase: 0 + - _Is_NormalMapToHighColor: 0 + - _Is_NormalMapToRimLight: 0 + - _Is_Ortho: 0 + - _Is_OutlineTex: 0 + - _Is_PingPong_Base: 0 + - _Is_SpecularToHighColor: 0 + - _Is_UseTweakHighColorOnShadow: 0 + - _Is_UseTweakMatCapOnShadow: 0 + - _Is_ViewCoord_Scroll: 0 + - _Is_ViewShift: 0 + - _LightDirection_MaskOn: 0 + - _LinkDetailsWithBase: 1 + - _MatCap: 0 + - _MaterialID: 1 + - _Metallic: 0 + - _Mode: 0 + - _Nearest_Distance: 0.5 + - _NormalMapSpace: 0 + - _NormalScale: 1 + - _OUTLINE: 0 + - _ObjectSpaceUVMapping: 0 + - _OcclusionStrength: 1 + - _Offset_X_Axis_BLD: -0.05 + - _Offset_Y_Axis_BLD: 0.09 + - _Offset_Z: 0 + - _OutlineOverridden: 0 + - _OutlineVisible: 1 + - _Outline_Width: 0 + - _PPDLodThreshold: 5 + - _PPDMaxSamples: 15 + - _PPDMinSamples: 5 + - _PPDPrimitiveLength: 1 + - _PPDPrimitiveWidth: 1 + - _Parallax: 0.02 + - _ReceivesSSR: 1 + - _RefractionModel: 0 + - _RimLight: 0 + - _RimLightOverridden: 0 + - _RimLightVisible: 1 + - _RimLight_FeatherOff: 0 + - _RimLight_InsideMask: 0.0001 + - _RimLight_Power: 0.1 + - _Rotate_EmissiveUV: 0 + - _Rotate_MatCapUV: 0 + - _Rotate_NormalMapForMatCapUV: 0 + - _SPRDefaultUnlitColorMask: 15 + - _SRPDefaultUnlitColMode: 1 + - _SSRefractionProjectionModel: 0 + - _Scroll_EmissiveU: 0 + - _Scroll_EmissiveV: 0 + - _SecondShadeOverridden: 0 + - _SecondShadeVisible: 1 + - _Set_SystemShadowsToBase: 1 + - _ShadeColor_Step: 0.245 + - _Smoothness: 0.5 + - _SmoothnessRemapMax: 1 + - _SmoothnessRemapMin: 0 + - _SmoothnessTextureChannel: 0 + - _SpecularAAScreenSpaceVariance: 0.1 + - _SpecularAAThreshold: 0.2 + - _SpecularHighlights: 1 + - _SpecularOcclusionMode: 1 + - _SrcBlend: 1 + - _StencilComp: 0 + - _StencilMode: 0 + - _StencilNo: 1 + - _StencilOpFail: 0 + - _StencilOpPass: 0 + - _StencilRef: 2 + - _StencilRefDepth: 0 + - _StencilRefDistortionVec: 64 + - _StencilRefGBuffer: 2 + - _StencilRefMV: 128 + - _StencilWriteMask: 3 + - _StencilWriteMaskDepth: 32 + - _StencilWriteMaskDistortionVec: 64 + - _StencilWriteMaskGBuffer: 3 + - _StencilWriteMaskMV: 128 + - _StepOffset: 0 + - _SubsurfaceMask: 1 + - _SupportDecals: 1 + - _SurfaceType: 0 + - _TexWorldScale: 1 + - _TexWorldScaleEmissive: 1 + - _Thickness: 1 + - _ThicknessMultiplier: 1 + - _TransmissionEnable: 1 + - _TransmissionMask: 1 + - _TransparentBackfaceEnable: 0 + - _TransparentCullMode: 2 + - _TransparentDepthPostpassEnable: 0 + - _TransparentDepthPrepassEnable: 0 + - _TransparentEnabled: 0 + - _TransparentSortPriority: 0 + - _TransparentWritingMotionVec: 0 + - _TransparentZWrite: 0 + - _TweakHighColorOnShadow: 0 + - _TweakMatCapOnShadow: 0 + - _Tweak_HighColorMaskLevel: 0 + - _Tweak_LightDirection_MaskLevel: 0 + - _Tweak_MatCapUV: 0 + - _Tweak_MatcapMaskLevel: 0 + - _Tweak_RimLightMaskLevel: 0 + - _Tweak_ShadingGradeMapLevel: 0 + - _Tweak_SystemShadowsLevel: 0 + - _Tweak_transparency: 0 + - _UVBase: 0 + - _UVDetail: 0 + - _UVEmissive: 0 + - _UVSec: 0 + - _Unlit_Intensity: 0 + - _UseEmissiveIntensity: 0 + - _UseShadowThreshold: 0 + - _Use_1stAs2nd: 0 + - _Use_BaseAs1st: 0 + - _ZOverDrawMode: 0 + - _ZTestDepthEqualForOpaque: 4 + - _ZTestGBuffer: 4 + - _ZTestModeDistortion: 8 + - _ZTestTransparent: 4 + - _ZWrite: 1 + - _ZWriteMode: 1 + - _isUnityToonshader: 1 + - _simpleUI: 0 + - _utsTechnique: 0 + - _utsVersionX: 0 + - _utsVersionY: 11 + - _utsVersionZ: 0 + m_Colors: + - _1st_ShadeColor: {r: 0.46630716, g: 0.46630716, b: 0.46630716, a: 1} + - _2nd_ShadeColor: {r: 0, g: 0, b: 0, a: 1} + - _AngelRingMaskColor: {r: 0, g: 1, b: 0, a: 1} + - _AngelRing_Color: {r: 1, g: 1, b: 1, a: 1} + - _Ap_RimLightColor: {r: 1, g: 1, b: 1, a: 1} + - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _BaseColorMap_MipInfo: {r: 0, g: 0, b: 0, a: 0} + - _BaseColorMaskColor: {r: 1, g: 1, b: 1, a: 1} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _ColorShift: {r: 0, g: 0, b: 0, a: 1} + - _DiffusionProfileAsset: {r: 0, g: 0, b: 0, a: 0} + - _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _EmissiveColor: {r: 0, g: 0, b: 0, a: 1} + - _EmissiveColorLDR: {r: 0, g: 0, b: 0, a: 1} + - _Emissive_Color: {r: 0, g: 0, b: 0, a: 1} + - _FirstShadeMaskColor: {r: 0, g: 1, b: 1, a: 1} + - _HighColor: {r: 0, g: 0, b: 0, a: 1} + - _HighlightMaskColor: {r: 1, g: 1, b: 0, a: 1} + - _InvPrimScale: {r: 1, g: 1, b: 0, a: 0} + - _IridescenceThicknessRemap: {r: 0, g: 1, b: 0, a: 0} + - _MatCapColor: {r: 1, g: 1, b: 1, a: 1} + - _OutlineMaskColor: {r: 0, g: 0, b: 0, a: 1} + - _Outline_Color: {r: 0.5, g: 0.5, b: 0.5, a: 1} + - _RimLightColor: {r: 1, g: 1, b: 1, a: 1} + - _RimLightMaskColor: {r: 1, g: 0, b: 1, a: 1} + - _SecondShadeMaskColor: {r: 0, g: 0, b: 1, a: 1} + - _SpecularColor: {r: 1, g: 1, b: 1, a: 1} + - _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0} + - _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1} + - _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0} + - _UVMappingMask: {r: 1, g: 0, b: 0, a: 0} + - _UVMappingMaskEmissive: {r: 1, g: 0, b: 0, a: 0} + - _ViewShift: {r: 0, g: 0, b: 0, a: 1} + - emissive: {r: 0, g: 0, b: 0, a: 1} + m_BuildTextureStacks: [] + m_AllowLocking: 1 diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Materials/Target.mat.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Materials/Target.mat.meta new file mode 100644 index 0000000..3abe36f --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Materials/Target.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b31a96faf9f25a941908823bcec3f7f8 +timeCreated: 1452366976 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Prefabs.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Prefabs.meta new file mode 100644 index 0000000..f8dbfb3 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Prefabs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: abb46494dbe5de54db7eb0563eea863b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Prefabs/Target.fbx b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Prefabs/Target.fbx new file mode 100644 index 0000000..8a4f992 Binary files /dev/null and b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Prefabs/Target.fbx differ diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Prefabs/Target.fbx.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Prefabs/Target.fbx.meta new file mode 100644 index 0000000..bed3b04 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Prefabs/Target.fbx.meta @@ -0,0 +1,118 @@ +fileFormatVersion: 2 +guid: 713ccdba7a92725428570ec12c8ac217 +ModelImporter: + serializedVersion: 20300 + internalIDToNameTable: + - first: + 1: 100000 + second: //RootNode + - first: + 4: 400000 + second: //RootNode + - first: + 23: 2300000 + second: //RootNode + - first: + 33: 3300000 + second: //RootNode + - first: + 43: 4300000 + second: Target1 + externalObjects: {} + materials: + materialImportMode: 0 + materialName: 0 + materialSearch: 1 + materialLocation: 0 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + importAnimatedCustomProperties: 0 + importConstraints: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + extraUserProperties: [] + clipAnimations: [] + isReadable: 1 + meshes: + lODScreenPercentages: [] + globalScale: 3 + meshCompression: 0 + addColliders: 0 + useSRGBMaterialColor: 1 + sortHierarchyByName: 1 + importVisibility: 0 + importBlendShapes: 1 + importCameras: 0 + importLights: 0 + fileIdsGeneration: 1 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + keepQuads: 0 + weldVertices: 1 + bakeAxisConversion: 0 + preserveHierarchy: 0 + skinWeightsMode: 0 + maxBonesPerVertex: 4 + minBoneWeight: 0.001 + meshOptimizationFlags: -1 + indexFormat: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVMarginMethod: 0 + secondaryUVMinLightmapResolution: 40 + secondaryUVMinObjectScale: 1 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 4 + normalCalculationMode: 0 + legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 1 + blendShapeNormalImportMode: 1 + normalSmoothingSource: 0 + referencedClips: [] + importAnimation: 0 + humanDescription: + serializedVersion: 3 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + globalScale: 3 + rootMotionBoneName: + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 0 + lastHumanDescriptionAvatarSource: {instanceID: 0} + autoGenerateAvatarMappingIfUnspecified: 1 + animationType: 0 + humanoidOversampling: 1 + avatarSetup: 0 + addHumanoidExtraRootOnlyWhenUsingAvatar: 0 + remapMaterialsIfMaterialImportModeIsNone: 1 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects.meta new file mode 100644 index 0000000..98b0ef5 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c1c47cc41bf15414f8b46a7cb8eaee82 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/BodyAnimationPreviewerUI.asset b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/BodyAnimationPreviewerUI.asset new file mode 100644 index 0000000..48e4056 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/BodyAnimationPreviewerUI.asset @@ -0,0 +1,17 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4243274e0bc7c2b4b9765aedb3a830bd, type: 3} + m_Name: BodyAnimationPreviewerUI + m_EditorClassIdentifier: + m_uiTemplate: {fileID: 9197481963319205126, guid: c45666af71053374fa83d5c577abafff, type: 3} + m_uiStyle: {fileID: 7433441132597879392, guid: b61711e3669c04f4293d684846248bf2, type: 3} + m_rootUIStyle: {fileID: 7433441132597879392, guid: 7587a2a9bb8fc5749b77b69d9b9393b7, type: 3} diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/BodyAnimationPreviewerUI.asset.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/BodyAnimationPreviewerUI.asset.meta new file mode 100644 index 0000000..0715bf0 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/BodyAnimationPreviewerUI.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 60df92036c4557744b1abf745fb379b9 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/FaceAnimationPreviewerUI.asset b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/FaceAnimationPreviewerUI.asset new file mode 100644 index 0000000..09069ec --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/FaceAnimationPreviewerUI.asset @@ -0,0 +1,17 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4243274e0bc7c2b4b9765aedb3a830bd, type: 3} + m_Name: FaceAnimationPreviewerUI + m_EditorClassIdentifier: + m_uiTemplate: {fileID: 9197481963319205126, guid: ad652ed8ec12ae64ea06ba4c154e61be, type: 3} + m_uiStyle: {fileID: 7433441132597879392, guid: b61711e3669c04f4293d684846248bf2, type: 3} + m_rootUIStyle: {fileID: 7433441132597879392, guid: 7587a2a9bb8fc5749b77b69d9b9393b7, type: 3} diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/FaceAnimationPreviewerUI.asset.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/FaceAnimationPreviewerUI.asset.meta new file mode 100644 index 0000000..872a557 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/FaceAnimationPreviewerUI.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ad9a044f7de76e2468828ef58b43a593 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/WindPreviewerUI.asset b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/WindPreviewerUI.asset new file mode 100644 index 0000000..c246db3 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/WindPreviewerUI.asset @@ -0,0 +1,17 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4243274e0bc7c2b4b9765aedb3a830bd, type: 3} + m_Name: WindPreviewerUI + m_EditorClassIdentifier: + m_uiTemplate: {fileID: 9197481963319205126, guid: c38f05ebcbea8ad41a2fa7506937d0ac, type: 3} + m_uiStyle: {fileID: 7433441132597879392, guid: b61711e3669c04f4293d684846248bf2, type: 3} + m_rootUIStyle: {fileID: 7433441132597879392, guid: 7587a2a9bb8fc5749b77b69d9b9393b7, type: 3} diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/WindPreviewerUI.asset.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/WindPreviewerUI.asset.meta new file mode 100644 index 0000000..c0e77bf --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/ScriptableObjects/WindPreviewerUI.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c1c109f5877ad0245a091ddbeec007f3 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Scripts.meta b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Scripts.meta new file mode 100644 index 0000000..6798950 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2b0667030ca80044d9e24ab8e23edcfb +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Scripts/AnimationButtonUISelector.cs b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Scripts/AnimationButtonUISelector.cs new file mode 100644 index 0000000..f31ea83 --- /dev/null +++ b/BJH/Assets/BJH/3dtest/Runtime/UnityChan/Common/Runtime/Scripts/AnimationButtonUISelector.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UIElements; + +namespace UnityChan { + +public class AnimationButtonUISelector { + + public void AddButton(Button button, int stateHash, int animationIndex) { + + m_bodyAnimationButtons.Add(button); + m_animatorStateHash2Index[stateHash] = animationIndex; + } + + public void Select(int stateHash) { + if (!m_animatorStateHash2Index.TryGetValue(stateHash, out int animationIndex)) { + return; + } + + if (animationIndex == m_selectedButtonIndex) { + return; + } + + int newIndex = m_animatorStateHash2Index[stateHash]; + if (m_selectedButtonIndex != INVALID_BUTTON_INDEX) + m_bodyAnimationButtons[m_selectedButtonIndex].RemoveFromClassList("selected"); + m_selectedButtonIndex = newIndex; + m_bodyAnimationButtons[m_selectedButtonIndex].AddToClassList("selected"); + } + +//---------------------------------------------------------------------------------------------------------------------- + + private readonly List