Flatkit 추가 및 설정
This commit is contained in:
3
Assets/FlatKit/Shaders/Editor.meta
Normal file
3
Assets/FlatKit/Shaders/Editor.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff97b1e260454ab0b34b884df8e27cf1
|
||||
timeCreated: 1551041666
|
||||
58
Assets/FlatKit/Shaders/Editor/MaterialPropertyExtensions.cs
Normal file
58
Assets/FlatKit/Shaders/Editor/MaterialPropertyExtensions.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace FlatKit.Editor {
|
||||
internal static class MaterialPropertyExtensions {
|
||||
public static ShaderPropertyType GetShaderPropertyType(this MaterialProperty property) {
|
||||
#if UNITY_6000_2_OR_NEWER
|
||||
return property.propertyType;
|
||||
#else
|
||||
return property.type switch {
|
||||
MaterialProperty.PropType.Color => ShaderPropertyType.Color,
|
||||
MaterialProperty.PropType.Vector => ShaderPropertyType.Vector,
|
||||
MaterialProperty.PropType.Float => ShaderPropertyType.Float,
|
||||
MaterialProperty.PropType.Range => ShaderPropertyType.Range,
|
||||
MaterialProperty.PropType.Texture => ShaderPropertyType.Texture,
|
||||
_ => ShaderPropertyType.Float,
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
public static ShaderPropertyFlags GetShaderPropertyFlags(this MaterialProperty property) {
|
||||
#if UNITY_6000_2_OR_NEWER
|
||||
return property.propertyFlags;
|
||||
#else
|
||||
var flags = ShaderPropertyFlags.None;
|
||||
if ((property.flags & MaterialProperty.PropFlags.HideInInspector) != 0) {
|
||||
flags |= ShaderPropertyFlags.HideInInspector;
|
||||
}
|
||||
|
||||
if ((property.flags & MaterialProperty.PropFlags.NoScaleOffset) != 0) {
|
||||
flags |= ShaderPropertyFlags.NoScaleOffset;
|
||||
}
|
||||
|
||||
if ((property.flags & MaterialProperty.PropFlags.PerRendererData) != 0) {
|
||||
flags |= ShaderPropertyFlags.PerRendererData;
|
||||
}
|
||||
|
||||
if ((property.flags & MaterialProperty.PropFlags.Normal) != 0) {
|
||||
flags |= ShaderPropertyFlags.Normal;
|
||||
}
|
||||
|
||||
if ((property.flags & MaterialProperty.PropFlags.HDR) != 0) {
|
||||
flags |= ShaderPropertyFlags.HDR;
|
||||
}
|
||||
|
||||
if ((property.flags & MaterialProperty.PropFlags.Gamma) != 0) {
|
||||
flags |= ShaderPropertyFlags.Gamma;
|
||||
}
|
||||
|
||||
if ((property.flags & MaterialProperty.PropFlags.NonModifiableTextureData) != 0) {
|
||||
flags |= ShaderPropertyFlags.NonModifiableTextureData;
|
||||
}
|
||||
|
||||
return flags;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d3efcc567a614203b135261649ee197
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
126
Assets/FlatKit/Shaders/Editor/ObjectOutlineEditorUtils.cs
Normal file
126
Assets/FlatKit/Shaders/Editor/ObjectOutlineEditorUtils.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using FlatKit;
|
||||
using JetBrains.Annotations;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
public static class ObjectOutlineEditorUtils {
|
||||
private static readonly GUIStyle RichHelpBoxStyle = new(EditorStyles.helpBox) { richText = true };
|
||||
|
||||
public static void SetActive(Material material, bool active) {
|
||||
// Work directly with the active URP Renderer Data to avoid dependency on a Camera context.
|
||||
var rendererData = GetRendererData();
|
||||
if (rendererData == null) {
|
||||
const string m = "<b>ScriptableRendererData</b> is required to manage per-object outlines.\n" +
|
||||
"Please assign a <b>URP Asset</b> in the Graphics settings.";
|
||||
EditorGUILayout.LabelField(m, RichHelpBoxStyle);
|
||||
return;
|
||||
}
|
||||
|
||||
// Find existing feature on the renderer data.
|
||||
var feature = rendererData.rendererFeatures
|
||||
.FirstOrDefault(f => f != null && f.GetType() == typeof(ObjectOutlineRendererFeature));
|
||||
|
||||
// Create feature on demand when enabling outlines.
|
||||
if (feature == null && active) {
|
||||
feature = ScriptableObject.CreateInstance<ObjectOutlineRendererFeature>();
|
||||
feature.name = "Flat Kit Per Object Outline";
|
||||
AddRendererFeature(rendererData, feature);
|
||||
|
||||
var addedMsg = $"<color=grey>[Flat Kit]</color> <b>Added</b> <color=green>{feature.name}</color> Renderer " +
|
||||
$"Feature to <b>{rendererData.name}</b>.";
|
||||
Debug.Log(addedMsg, rendererData);
|
||||
}
|
||||
|
||||
// If disabling and there's no feature, nothing to do.
|
||||
if (feature == null) return;
|
||||
|
||||
// Register/unregister the material and check usage.
|
||||
if (feature is not ObjectOutlineRendererFeature outlineFeature) {
|
||||
Debug.LogError("ObjectOutlineRendererFeature not found");
|
||||
return;
|
||||
}
|
||||
|
||||
var featureIsUsed = outlineFeature.RegisterMaterial(material, active);
|
||||
|
||||
// Remove the feature asset if no materials are using it anymore.
|
||||
if (!featureIsUsed) {
|
||||
RemoveRendererFeature(rendererData, feature);
|
||||
var removedMsg = $"<color=grey>[Flat Kit]</color> <b>Removed</b> <color=green>{feature.name}</color> Renderer " +
|
||||
$"Feature from <b>{rendererData.name}</b> because no materials are using it.";
|
||||
Debug.Log(removedMsg, rendererData);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddRendererFeature(ScriptableRendererData rendererData, ScriptableRendererFeature feature) {
|
||||
// Save the asset as a sub-asset.
|
||||
AssetDatabase.AddObjectToAsset(feature, rendererData);
|
||||
rendererData.rendererFeatures.Add(feature);
|
||||
rendererData.SetDirty();
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
private static void RemoveRendererFeature(ScriptableRendererData rendererData, ScriptableRendererFeature feature) {
|
||||
rendererData.rendererFeatures.Remove(feature);
|
||||
rendererData.SetDirty();
|
||||
|
||||
// Remove the asset.
|
||||
AssetDatabase.RemoveObjectFromAsset(feature);
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
[CanBeNull]
|
||||
private static ScriptableRenderer GetRenderer(Camera camera) {
|
||||
if (!camera) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var additionalCameraData = camera.GetComponent<UniversalAdditionalCameraData>();
|
||||
if (!additionalCameraData) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var renderer = additionalCameraData.scriptableRenderer;
|
||||
return renderer;
|
||||
}
|
||||
|
||||
private static List<ScriptableRendererFeature> GetRendererFeatures(ScriptableRenderer renderer) {
|
||||
var property =
|
||||
typeof(ScriptableRenderer).GetProperty("rendererFeatures", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (property == null) return null;
|
||||
var features = property.GetValue(renderer) as List<ScriptableRendererFeature>;
|
||||
return features;
|
||||
}
|
||||
|
||||
internal static ScriptableRendererData GetRendererData() {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
var srpAsset = GraphicsSettings.defaultRenderPipeline;
|
||||
#else
|
||||
var srpAsset = GraphicsSettings.renderPipelineAsset;
|
||||
#endif
|
||||
if (srpAsset == null) {
|
||||
const string m = "<b>Flat Kit</b> No SRP asset found. Please assign a URP Asset in the Graphics settings " +
|
||||
"to enable per-object outlines.";
|
||||
Debug.LogError(m);
|
||||
return null;
|
||||
}
|
||||
|
||||
var field = typeof(UniversalRenderPipelineAsset).GetField("m_RendererDataList",
|
||||
BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
var rendererDataList = (ScriptableRendererData[])field!.GetValue(srpAsset);
|
||||
|
||||
var rendererData = rendererDataList.FirstOrDefault();
|
||||
if (rendererData == null) {
|
||||
Debug.LogError("No ScriptableRendererData found");
|
||||
return null;
|
||||
}
|
||||
|
||||
return rendererData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b52ec40d323041e7b931cd4b15ec8306
|
||||
timeCreated: 1720322479
|
||||
1026
Assets/FlatKit/Shaders/Editor/StylizedSurfaceEditor.cs
Normal file
1026
Assets/FlatKit/Shaders/Editor/StylizedSurfaceEditor.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0bde8f608f6b473fb5938a0a218648cf
|
||||
timeCreated: 1551041742
|
||||
320
Assets/FlatKit/Shaders/Editor/TerrainEditor.cs
Normal file
320
Assets/FlatKit/Shaders/Editor/TerrainEditor.cs
Normal file
@@ -0,0 +1,320 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Experimental.Rendering;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace FlatKit {
|
||||
public class TerrainEditor : StylizedSurfaceEditor, ITerrainLayerCustomUI {
|
||||
private class StylesLayer
|
||||
{
|
||||
public readonly GUIContent warningHeightBasedBlending = new GUIContent("Height-based blending is disabled if you have more than four TerrainLayer materials!");
|
||||
|
||||
public readonly GUIContent enableHeightBlend = new GUIContent("Enable Height-based Blend", "Blend terrain layers based on height values.");
|
||||
public readonly GUIContent heightTransition = new GUIContent("Height Transition", "Size in world units of the smooth transition between layers.");
|
||||
public readonly GUIContent enableInstancedPerPixelNormal = new GUIContent("Enable Per-pixel Normal", "Enable per-pixel normal when the terrain uses instanced rendering.");
|
||||
|
||||
public readonly GUIContent diffuseTexture = new GUIContent("Diffuse");
|
||||
public readonly GUIContent colorTint = new GUIContent("Color Tint");
|
||||
public readonly GUIContent opacityAsDensity = new GUIContent("Opacity as Density", "Enable Density Blend (if unchecked, opacity is used as Smoothness)");
|
||||
public readonly GUIContent normalMapTexture = new GUIContent("Normal Map");
|
||||
public readonly GUIContent normalScale = new GUIContent("Normal Scale");
|
||||
public readonly GUIContent maskMapTexture = new GUIContent("Mask", "R: Metallic\nG: AO\nB: Height\nA: Smoothness");
|
||||
public readonly GUIContent maskMapTextureWithoutHeight = new GUIContent("Mask Map", "R: Metallic\nG: AO\nA: Smoothness");
|
||||
public readonly GUIContent channelRemapping = new GUIContent("Channel Remapping");
|
||||
public readonly GUIContent defaultValues = new GUIContent("Channel Default Values");
|
||||
public readonly GUIContent metallic = new GUIContent("R: Metallic");
|
||||
public readonly GUIContent ao = new GUIContent("G: AO");
|
||||
public readonly GUIContent height = new GUIContent("B: Height");
|
||||
public readonly GUIContent heightParametrization = new GUIContent("Parametrization");
|
||||
public readonly GUIContent heightAmplitude = new GUIContent("Amplitude (cm)");
|
||||
public readonly GUIContent heightBase = new GUIContent("Base (cm)");
|
||||
public readonly GUIContent heightMin = new GUIContent("Min (cm)");
|
||||
public readonly GUIContent heightMax = new GUIContent("Max (cm)");
|
||||
public readonly GUIContent heightCm = new GUIContent("B: Height (cm)");
|
||||
public readonly GUIContent smoothness = new GUIContent("A: Smoothness");
|
||||
}
|
||||
|
||||
static StylesLayer s_Styles = null;
|
||||
|
||||
private static StylesLayer styles {
|
||||
get {
|
||||
if (s_Styles == null) s_Styles = new StylesLayer();
|
||||
return s_Styles;
|
||||
}
|
||||
}
|
||||
|
||||
// Height blend params
|
||||
MaterialProperty enableHeightBlend = null;
|
||||
const string kEnableHeightBlend = "_EnableHeightBlend";
|
||||
|
||||
MaterialProperty heightTransition = null;
|
||||
const string kHeightTransition = "_HeightTransition";
|
||||
|
||||
// Per-pixel Normal (while instancing)
|
||||
MaterialProperty enableInstancedPerPixelNormal = null;
|
||||
const string kEnableInstancedPerPixelNormal = "_EnableInstancedPerPixelNormal";
|
||||
|
||||
private bool m_ShowChannelRemapping = false;
|
||||
enum HeightParametrization
|
||||
{
|
||||
Amplitude,
|
||||
MinMax
|
||||
};
|
||||
private HeightParametrization m_HeightParametrization = HeightParametrization.Amplitude;
|
||||
|
||||
private static bool DoesTerrainUseMaskMaps(TerrainLayer[] terrainLayers)
|
||||
{
|
||||
for (int i = 0; i < terrainLayers.Length; ++i)
|
||||
{
|
||||
if (terrainLayers[i].maskMapTexture != null)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void FindMaterialProperties(MaterialProperty[] props)
|
||||
{
|
||||
enableHeightBlend = FindProperty(kEnableHeightBlend, props, false);
|
||||
heightTransition = FindProperty(kHeightTransition, props, false);
|
||||
enableInstancedPerPixelNormal = FindProperty(kEnableInstancedPerPixelNormal, props, false);
|
||||
}
|
||||
|
||||
static public void SetupMaterialKeywords(Material material)
|
||||
{
|
||||
bool enableHeightBlend = (material.HasProperty(kEnableHeightBlend) && material.GetFloat(kEnableHeightBlend) > 0);
|
||||
CoreUtils.SetKeyword(material, "_TERRAIN_BLEND_HEIGHT", enableHeightBlend);
|
||||
|
||||
bool enableInstancedPerPixelNormal = material.GetFloat(kEnableInstancedPerPixelNormal) > 0.0f;
|
||||
CoreUtils.SetKeyword(material, "_TERRAIN_INSTANCED_PERPIXEL_NORMAL", enableInstancedPerPixelNormal);
|
||||
}
|
||||
|
||||
static public bool TextureHasAlpha(Texture2D inTex)
|
||||
{
|
||||
if (inTex != null)
|
||||
{
|
||||
return GraphicsFormatUtility.HasAlphaChannel(GraphicsFormatUtility.GetGraphicsFormat(inTex.format, true));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnGUI(MaterialEditor materialEditorIn, MaterialProperty[] properties) {
|
||||
base.OnGUI(materialEditorIn, properties);
|
||||
FindMaterialProperties(properties);
|
||||
|
||||
bool optionsChanged = false;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
{
|
||||
if (enableHeightBlend != null)
|
||||
{
|
||||
//EditorGUI.indentLevel++;
|
||||
materialEditorIn.ShaderProperty(enableHeightBlend, styles.enableHeightBlend);
|
||||
if (enableHeightBlend.floatValue > 0)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.HelpBox(styles.warningHeightBasedBlending.text, MessageType.Info);
|
||||
materialEditorIn.ShaderProperty(heightTransition, styles.heightTransition);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
//EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
optionsChanged = true;
|
||||
}
|
||||
|
||||
bool enablePerPixelNormalChanged = false;
|
||||
|
||||
// Since Instanced Per-pixel normal is actually dependent on instancing enabled or not, it is not
|
||||
// important to check it in the GUI. The shader will make sure it is enabled/disabled properly.s
|
||||
if (enableInstancedPerPixelNormal != null)
|
||||
{
|
||||
//EditorGUI.indentLevel++;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
materialEditorIn.ShaderProperty(enableInstancedPerPixelNormal, styles.enableInstancedPerPixelNormal);
|
||||
enablePerPixelNormalChanged = EditorGUI.EndChangeCheck();
|
||||
//EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
if (optionsChanged || enablePerPixelNormalChanged)
|
||||
{
|
||||
foreach (var obj in materialEditorIn.targets)
|
||||
{
|
||||
SetupMaterialKeywords((Material)obj);
|
||||
}
|
||||
}
|
||||
|
||||
// We should always do this call at the end
|
||||
materialEditorIn.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
bool ITerrainLayerCustomUI.OnTerrainLayerGUI(TerrainLayer terrainLayer, Terrain terrain)
|
||||
{
|
||||
var terrainLayers = terrain.terrainData.terrainLayers;
|
||||
|
||||
// Don't use the member field enableHeightBlend as ShaderGUI.OnGUI might not be called if the material UI is folded.
|
||||
// heightblend shouldn't be available if we are in multi-pass mode, because it is guaranteed to be broken.
|
||||
bool heightBlendAvailable = (terrainLayers.Length <= 4);
|
||||
bool heightBlend = heightBlendAvailable && terrain.materialTemplate.HasProperty(kEnableHeightBlend) && (terrain.materialTemplate.GetFloat(kEnableHeightBlend) > 0);
|
||||
|
||||
terrainLayer.diffuseTexture = EditorGUILayout.ObjectField(styles.diffuseTexture, terrainLayer.diffuseTexture, typeof(Texture2D), false) as Texture2D;
|
||||
TerrainLayerUtility.ValidateDiffuseTextureUI(terrainLayer.diffuseTexture);
|
||||
|
||||
var diffuseRemapMin = terrainLayer.diffuseRemapMin;
|
||||
var diffuseRemapMax = terrainLayer.diffuseRemapMax;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
bool enableDensity = false;
|
||||
if (terrainLayer.diffuseTexture != null)
|
||||
{
|
||||
var rect = GUILayoutUtility.GetLastRect();
|
||||
rect.y += 16 + 4;
|
||||
rect.width = EditorGUIUtility.labelWidth + 64;
|
||||
rect.height = 16;
|
||||
|
||||
++EditorGUI.indentLevel;
|
||||
|
||||
var diffuseTint = new Color(diffuseRemapMax.x, diffuseRemapMax.y, diffuseRemapMax.z);
|
||||
diffuseTint = EditorGUI.ColorField(rect, styles.colorTint, diffuseTint, true, false, false);
|
||||
diffuseRemapMax.x = diffuseTint.r;
|
||||
diffuseRemapMax.y = diffuseTint.g;
|
||||
diffuseRemapMax.z = diffuseTint.b;
|
||||
diffuseRemapMin.x = diffuseRemapMin.y = diffuseRemapMin.z = 0;
|
||||
|
||||
if (!heightBlend)
|
||||
{
|
||||
rect.y = rect.yMax + 2;
|
||||
enableDensity = EditorGUI.Toggle(rect, styles.opacityAsDensity, diffuseRemapMin.w > 0);
|
||||
}
|
||||
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
diffuseRemapMax.w = 1;
|
||||
diffuseRemapMin.w = enableDensity ? 1 : 0;
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
terrainLayer.diffuseRemapMin = diffuseRemapMin;
|
||||
terrainLayer.diffuseRemapMax = diffuseRemapMax;
|
||||
}
|
||||
|
||||
// Display normal map UI
|
||||
terrainLayer.normalMapTexture = EditorGUILayout.ObjectField(styles.normalMapTexture, terrainLayer.normalMapTexture, typeof(Texture2D), false) as Texture2D;
|
||||
TerrainLayerUtility.ValidateNormalMapTextureUI(terrainLayer.normalMapTexture, TerrainLayerUtility.CheckNormalMapTextureType(terrainLayer.normalMapTexture));
|
||||
|
||||
if (terrainLayer.normalMapTexture != null)
|
||||
{
|
||||
var rect = GUILayoutUtility.GetLastRect();
|
||||
rect.y += 16 + 4;
|
||||
rect.width = EditorGUIUtility.labelWidth + 64;
|
||||
rect.height = 16;
|
||||
|
||||
++EditorGUI.indentLevel;
|
||||
terrainLayer.normalScale = EditorGUI.FloatField(rect, styles.normalScale, terrainLayer.normalScale);
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
|
||||
// Display the mask map UI and the remap controls
|
||||
terrainLayer.maskMapTexture = EditorGUILayout.ObjectField(heightBlend ? styles.maskMapTexture : styles.maskMapTextureWithoutHeight, terrainLayer.maskMapTexture, typeof(Texture2D), false) as Texture2D;
|
||||
TerrainLayerUtility.ValidateMaskMapTextureUI(terrainLayer.maskMapTexture);
|
||||
|
||||
var maskMapRemapMin = terrainLayer.maskMapRemapMin;
|
||||
var maskMapRemapMax = terrainLayer.maskMapRemapMax;
|
||||
var smoothness = terrainLayer.smoothness;
|
||||
var metallic = terrainLayer.metallic;
|
||||
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
m_ShowChannelRemapping = EditorGUILayout.Foldout(m_ShowChannelRemapping, terrainLayer.maskMapTexture != null ? s_Styles.channelRemapping : s_Styles.defaultValues);
|
||||
|
||||
if (m_ShowChannelRemapping)
|
||||
{
|
||||
if (terrainLayer.maskMapTexture != null)
|
||||
{
|
||||
float min, max;
|
||||
min = maskMapRemapMin.x; max = maskMapRemapMax.x;
|
||||
EditorGUILayout.MinMaxSlider(s_Styles.metallic, ref min, ref max, 0, 1);
|
||||
maskMapRemapMin.x = min; maskMapRemapMax.x = max;
|
||||
|
||||
min = maskMapRemapMin.y; max = maskMapRemapMax.y;
|
||||
EditorGUILayout.MinMaxSlider(s_Styles.ao, ref min, ref max, 0, 1);
|
||||
maskMapRemapMin.y = min; maskMapRemapMax.y = max;
|
||||
|
||||
if (heightBlend)
|
||||
{
|
||||
EditorGUILayout.LabelField(styles.height);
|
||||
++EditorGUI.indentLevel;
|
||||
m_HeightParametrization = (HeightParametrization)EditorGUILayout.EnumPopup(styles.heightParametrization, m_HeightParametrization);
|
||||
if (m_HeightParametrization == HeightParametrization.Amplitude)
|
||||
{
|
||||
// (height - heightBase) * amplitude
|
||||
float amplitude = Mathf.Max(maskMapRemapMax.z - maskMapRemapMin.z, Mathf.Epsilon); // to avoid divide by zero
|
||||
float heightBase = maskMapRemapMin.z / amplitude;
|
||||
amplitude = EditorGUILayout.FloatField(styles.heightAmplitude, amplitude * 100) / 100;
|
||||
heightBase = EditorGUILayout.FloatField(styles.heightBase, heightBase * 100) / 100;
|
||||
maskMapRemapMin.z = heightBase * amplitude;
|
||||
maskMapRemapMax.z = (1.0f - heightBase) * amplitude;
|
||||
}
|
||||
else
|
||||
{
|
||||
maskMapRemapMin.z = EditorGUILayout.FloatField(styles.heightMin, maskMapRemapMin.z * 100) / 100;
|
||||
maskMapRemapMax.z = EditorGUILayout.FloatField(styles.heightMax, maskMapRemapMax.z * 100) / 100;
|
||||
}
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
|
||||
min = maskMapRemapMin.w; max = maskMapRemapMax.w;
|
||||
EditorGUILayout.MinMaxSlider(s_Styles.smoothness, ref min, ref max, 0, 1);
|
||||
maskMapRemapMin.w = min; maskMapRemapMax.w = max;
|
||||
}
|
||||
else
|
||||
{
|
||||
metallic = EditorGUILayout.Slider(s_Styles.metallic, metallic, 0, 1);
|
||||
// AO and Height are still exclusively controlled via the maskRemap controls
|
||||
// metallic and smoothness have their own values as fields within the LayerData.
|
||||
maskMapRemapMax.y = EditorGUILayout.Slider(s_Styles.ao, maskMapRemapMax.y, 0, 1);
|
||||
if (heightBlend)
|
||||
{
|
||||
maskMapRemapMax.z = EditorGUILayout.FloatField(s_Styles.heightCm, maskMapRemapMax.z * 100) / 100;
|
||||
}
|
||||
|
||||
// There's a possibility that someone could slide max below the existing min value
|
||||
// so we'll just protect against that by locking the min value down a little bit.
|
||||
// In the case of height (Z), we are trying to set min to no lower than zero value unless
|
||||
// max goes negative. Zero is a good sensible value for the minimum. For AO (Y), we
|
||||
// don't need this extra protection step because the UI blocks us from going negative
|
||||
// anyway. In both cases, pushing the slider below the min value will lock them together,
|
||||
// but min will be "left behind" if you go back up.
|
||||
maskMapRemapMin.y = Mathf.Min(maskMapRemapMin.y, maskMapRemapMax.y);
|
||||
maskMapRemapMin.z = Mathf.Min(Mathf.Max(0, maskMapRemapMin.z), maskMapRemapMax.z);
|
||||
|
||||
if (TextureHasAlpha(terrainLayer.diffuseTexture))
|
||||
{
|
||||
GUIStyle warnStyle = new GUIStyle(GUI.skin.label);
|
||||
warnStyle.wordWrap = true;
|
||||
GUILayout.Label("Smoothness is controlled by diffuse alpha channel", warnStyle);
|
||||
}
|
||||
else
|
||||
smoothness = EditorGUILayout.Slider(s_Styles.smoothness, smoothness, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
terrainLayer.maskMapRemapMin = maskMapRemapMin;
|
||||
terrainLayer.maskMapRemapMax = maskMapRemapMax;
|
||||
terrainLayer.smoothness = smoothness;
|
||||
terrainLayer.metallic = metallic;
|
||||
}
|
||||
--EditorGUI.indentLevel;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
TerrainLayerUtility.TilingSettingsUI(terrainLayer);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/FlatKit/Shaders/Editor/TerrainEditor.cs.meta
Normal file
3
Assets/FlatKit/Shaders/Editor/TerrainEditor.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17bd6c3b6c7c433c897e5a36eba47b46
|
||||
timeCreated: 1645650454
|
||||
157
Assets/FlatKit/Shaders/Editor/Tooltips.cs
Normal file
157
Assets/FlatKit/Shaders/Editor/Tooltips.cs
Normal file
@@ -0,0 +1,157 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FlatKit.StylizedSurface {
|
||||
public static class Tooltips {
|
||||
// @formatter:off
|
||||
public static readonly Dictionary<string, string> Map = new Dictionary<string, string> {
|
||||
{ "Color", "Primary color of the material. This color is usually the most visible." }, {
|
||||
"Cel Shading Mode", "Lets you choose how the coloring/shading is applied.\n" +
|
||||
"- 'None' uses only flat Color parameter above, no primary cel is added;\n" +
|
||||
"- 'Single' adds a primary cel layer;\n" +
|
||||
"- 'Steps' works with a special texture for adding as many cels as there are in the texture;\n" +
|
||||
"- 'Curve' works with a special texture, but unlike 'Steps', it uses a smooth interpolated one."
|
||||
},
|
||||
{ "Color Shaded", "Color of the cel layer. Usually it is the dark part of cel shaded objects." },
|
||||
{ "Self Shading Size", "How much of the object is covered with the cel layer." }, {
|
||||
"Edge Size",
|
||||
"How smooth the transition between cel layers is. Values to the left mean 'sharper', values to the right are 'smoother'."
|
||||
}, {
|
||||
"Localized Shading",
|
||||
"Can also be called the \"flatness\" value. Defines how spread out the shading is across " +
|
||||
"the object. The value of 0 distributes the color transition gradually across the whole " +
|
||||
"object. The value of 1 makes shading fully flat."
|
||||
},
|
||||
{ "Enable Extra Cel Layer", "If one cel is not enough, here's another one." }, {
|
||||
"Enable Specular",
|
||||
"Toggle specular highlight on/off. Specular is a highlight that appears on shiny surfaces, " +
|
||||
"like metal or glass. It is kind of a glare effect."
|
||||
},
|
||||
{ "Specular Color", "Color of specular highlight. Usually it is white or very bright." }, {
|
||||
"Specular Size",
|
||||
"How big the specular highlight is. Values to the left mean 'smaller', values to the right are 'bigger'."
|
||||
}, {
|
||||
"Specular Edge Smoothness",
|
||||
"How smooth or sharp the specular highlight is. Values to the left mean 'sharper', values to the right are 'smoother'."
|
||||
}, {
|
||||
"Enable Rim",
|
||||
"Enables a rim highlight on the edges of the object. It can be used as a pseudo-outline layer or even as an additional color layer."
|
||||
},
|
||||
{ "Rim Color", "Color of the rim highlight. Usually it is bright." }, {
|
||||
"Light Align",
|
||||
"Position of the rim highlight that depends on light direction. Use this to move the rim part on the mesh."
|
||||
},
|
||||
{ "Rim Size", "How big the rim highlight is." }, {
|
||||
"Rim Edge Smoothness",
|
||||
"How smooth or sharp the rim part is. Values to the left mean 'sharper', values to the right are 'smoother'."
|
||||
},
|
||||
|
||||
// Height gradient.
|
||||
{
|
||||
"Enable Height Gradient",
|
||||
"Height gradient enables a color overlay that gradually changes across the vertical axis."
|
||||
},
|
||||
{ "Gradient Color", "Sets the color of the gradient overlay part." }, {
|
||||
"[DR_GRADIENT_ON]Space", "Whether the gradient should be in World or Local space.\n" +
|
||||
"- World space means that the `Center` parameter is relative to the world origin.\n" +
|
||||
"- Local space means that the `Center` parameter is relative to the object's pivot point."
|
||||
},
|
||||
{ "Center X", "X coordinate of the middle gradient point." },
|
||||
{ "Center Y", "Y coordinate of the middle gradient point." },
|
||||
{ "Size", "How stretched the gradient is." },
|
||||
{ "Gradient Angle", "Rotates the gradient on the mesh." },
|
||||
|
||||
// Outline.
|
||||
{ "Enable Outline", "Enables an outline layer on the material." },
|
||||
{ "[DR_OUTLINE_ON]Width", "Thickness of the outline." },
|
||||
{ "[DR_OUTLINE_ON]Color", "Color of the outline." }, {
|
||||
"[DR_OUTLINE_ON]Scale", "Controls a way of stretching the model uniformly. This is used rarely, " +
|
||||
"typically on symmetrical objects when the model can't have smooth normals."
|
||||
}, {
|
||||
"[DR_OUTLINE_ON]Smooth Normals", "Processes the mesh and creates a copy of it with smoothed normals " +
|
||||
"baked into a UV channel.\nPlease see our online documentation " +
|
||||
"(https://flatkit.dustyroom.com) for more details."
|
||||
}, {
|
||||
"[DR_OUTLINE_ON]Depth Offset", "Pushes the outline further from the camera. Use this if you are seeing " +
|
||||
"outlines intersecting the object."
|
||||
}, {
|
||||
"[DR_OUTLINE_ON]Space", "Whether the outline should be in Clip (aka Screen) or Local space. Different " +
|
||||
"objects require different space, so try both."
|
||||
}, {
|
||||
"Camera Distance Impact", "How much the distance between the object and the camera influences the " +
|
||||
"outline width. This is useful for making outlines thinner on distant objects."
|
||||
}, {
|
||||
"Enable Vertex Colors", "Uses mesh vertex color in object's appearance.\n" +
|
||||
"Vertex colors are colors that are stored in the mesh itself. They can be painted in 3D " +
|
||||
"modeling software like Blender or Maya. Vertex colors are usually used for additional " +
|
||||
"color layers."
|
||||
}, {
|
||||
"Light Color Contribution",
|
||||
"How much the color of real-time lights (directional, point or spot) influences the color of the object.\n" +
|
||||
"Has no effect when the lighting is baked as that color is already included in the lightmap and/or light probes."
|
||||
}, {
|
||||
"Point / Spot Light Edge",
|
||||
"Sharpness of the transition between lit and unlit parts of the surface when using point or spot lights."
|
||||
}, {
|
||||
"Override Light Direction",
|
||||
"Enables overriding of light direction. Use it when you want to re-align the shaded part for the current material only."
|
||||
},
|
||||
{ "Pitch", "Moves the shaded part across world-space X coordinate" },
|
||||
{ "Yaw", "Moves the shaded part across world-space Y coordinate" },
|
||||
|
||||
// Shadows.
|
||||
{
|
||||
"Mode", "Use this menu to let the current material receive shadows.\n" +
|
||||
"- 'Multiply' parameter multiplies black shadow over existing colors of shading;\n" +
|
||||
"- 'Color' parameter applies freely colored shadow over existing colors of shading."
|
||||
},
|
||||
{ "Power", "How opaque the received shadows are." },
|
||||
{ "[_UNITYSHADOWMODE_COLOR]Color", "Color of the received shadows." }, {
|
||||
"Sharpness",
|
||||
"How smooth or sharp the received shadows are. Values to the left mean 'sharper', values to the right are 'smoother'."
|
||||
},
|
||||
{
|
||||
"Shadow Occlusion",
|
||||
"Mask received Unity shadows in areas where normals face away from the light. Useful to " +
|
||||
"remove shadows that 'go through' objects."
|
||||
},
|
||||
|
||||
// Texture maps.
|
||||
{ "Albedo", "Main texture of the material. It is also known as 'Diffuse'." },
|
||||
{
|
||||
"Mix Into Shading",
|
||||
"Uses the main texture when calculating lighting and shading colors. When disabled, the Environment Lighting of the scene has a greater impact on the material."
|
||||
},
|
||||
{ "Texture Impact", "How opaque or transparent the texture is." },
|
||||
{
|
||||
"Blending Mode", "Select which blending mode to use for the texture:\n" +
|
||||
"-'Add' adds the texture to the existing colors of shading;\n" +
|
||||
"-'Multiply' multiplies the texture over the existing colors of shading;\n" +
|
||||
"-'Interpolate' (only Detail Map) blends the texture with the existing colors of shading."
|
||||
},
|
||||
{
|
||||
"Detail Map",
|
||||
"A texture that is used to add small details to the surface. There is no principal difference " +
|
||||
"between this texture and the main one, except that it is usually smaller and has more details."
|
||||
},
|
||||
{ "Detail Color", "The color to be applied to the detail map." },
|
||||
{ "Detail Impact", "How visible the detail map is." },
|
||||
|
||||
{ "Normal Map", "Also known as 'Bump Map'. This texture contains normals applied to the surface." }, {
|
||||
"Emission Map", "A texture representing the parts of the object that emit light. It is usually used for " +
|
||||
"glowing signs, screens, lights, etc."
|
||||
}, {
|
||||
"Emission Color",
|
||||
"The color of the emitted light. Note that this is an HDR value. When combined with Bloom " +
|
||||
"post-processing, it can be used to create a glowing effect."
|
||||
},
|
||||
{ "Base Alpha Cutoff", "Allows controlling which pixels to render based on the texture alpha values." }, {
|
||||
"Surface Type",
|
||||
"Whether the object is opaque or transparent. This defines the render queue of the material."
|
||||
},
|
||||
{ "Render Faces", "Whether to render the Front, Back or both faces of the mesh." },
|
||||
{ "Alpha Clipping", "Allows controlling which pixels to render based on the texture alpha values." },
|
||||
{ "Enable GPU Instancing", "GPU Instancing allows rendering many copies of the same mesh at once." },
|
||||
};
|
||||
// @formatter:on
|
||||
}
|
||||
}
|
||||
3
Assets/FlatKit/Shaders/Editor/Tooltips.cs.meta
Normal file
3
Assets/FlatKit/Shaders/Editor/Tooltips.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00e8e0985db344a089f2cb512edbcd4a
|
||||
timeCreated: 1604769966
|
||||
8
Assets/FlatKit/Shaders/GradientSkybox.meta
Normal file
8
Assets/FlatKit/Shaders/GradientSkybox.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4812b3e07fe854cc496508ebe35eea72
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/FlatKit/Shaders/GradientSkybox/Editor.meta
Normal file
9
Assets/FlatKit/Shaders/GradientSkybox/Editor.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86faafcc11517418fa1da0c53aa3c21a
|
||||
folderAsset: yes
|
||||
timeCreated: 1481364771
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
public class GradientSkyboxEditor : UnityEditor.MaterialEditor {
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
serializedObject.Update();
|
||||
|
||||
var theShader = serializedObject.FindProperty ("m_Shader");
|
||||
|
||||
if (isVisible && !theShader.hasMultipleDifferentValues && theShader.objectReferenceValue != null) {
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
base.OnInspectorGUI();
|
||||
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
var dirPitch = GetMaterialProperty(targets, "_DirectionPitch");
|
||||
var dirYaw = GetMaterialProperty(targets, "_DirectionYaw");
|
||||
|
||||
var dirPitchRad = dirPitch.floatValue * Mathf.Deg2Rad;
|
||||
var dirYawRad = dirYaw.floatValue * Mathf.Deg2Rad;
|
||||
|
||||
var direction = new Vector4(Mathf.Sin(dirPitchRad) * Mathf.Sin(dirYawRad), Mathf.Cos(dirPitchRad),
|
||||
Mathf.Sin(dirPitchRad) * Mathf.Cos(dirYawRad), 0.0f);
|
||||
GetMaterialProperty(targets, "_Direction").vectorValue = direction;
|
||||
|
||||
PropertiesChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb06f6d66c6c3423c82d8b5ed585ec3e
|
||||
timeCreated: 1453992704
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
79
Assets/FlatKit/Shaders/GradientSkybox/GradientSkybox.shader
Normal file
79
Assets/FlatKit/Shaders/GradientSkybox/GradientSkybox.shader
Normal file
@@ -0,0 +1,79 @@
|
||||
Shader "FlatKit/GradientSkybox" {
|
||||
|
||||
Properties {
|
||||
_Color2 ("Top Color", Color) = (0.97, 0.67, 0.51, 0)
|
||||
_Color1 ("Bottom Color", Color) = (0, 0.7, 0.74, 0)
|
||||
|
||||
[Space]
|
||||
_Intensity ("Intensity", Range (0, 2)) = 1.0
|
||||
_Exponent ("Exponent", Range (0, 3)) = 1.0
|
||||
|
||||
[Space]
|
||||
_DirectionYaw ("Direction X angle", Range (0, 180)) = 0
|
||||
_DirectionPitch ("Direction Y angle", Range (0, 180)) = 0
|
||||
|
||||
[Space]
|
||||
_NoiseIntensity ("Noise Intensity", Range (0, 0.25)) = 0.0
|
||||
|
||||
[HideInInspector]
|
||||
_Direction ("Direction", Vector) = (0, 1, 0, 0)
|
||||
}
|
||||
|
||||
CGINCLUDE
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata {
|
||||
float4 position : POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 position : SV_POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
half4 _Color1;
|
||||
half4 _Color2;
|
||||
half3 _Direction;
|
||||
half _Intensity;
|
||||
half _Exponent;
|
||||
half _NoiseIntensity;
|
||||
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.position = UnityObjectToClipPos(v.position);
|
||||
o.texcoord = v.texcoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : COLOR {
|
||||
const half d = dot(normalize(i.texcoord), _Direction) * 0.5f + 0.5f;
|
||||
float t = pow(d, _Exponent);
|
||||
t += frac(sin(dot(t, float4(12.9898, 78.233, 45.164, 94.673))) * 43758.5453) * _NoiseIntensity;
|
||||
return lerp(_Color1, _Color2, t) * _Intensity;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
|
||||
SubShader {
|
||||
Tags { "RenderType"="Background" "Queue"="Background" }
|
||||
|
||||
Pass {
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
Fog { Mode Off }
|
||||
CGPROGRAM
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "GradientSkyboxEditor"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e32cae2a5bbfb41888ef2ba8391ab87d
|
||||
labels:
|
||||
- Unlit
|
||||
- Shader
|
||||
- Flat
|
||||
- Gradient
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
99
Assets/FlatKit/Shaders/LightPlane.shader
Normal file
99
Assets/FlatKit/Shaders/LightPlane.shader
Normal file
@@ -0,0 +1,99 @@
|
||||
Shader "FlatKit/LightPlane" {
|
||||
Properties
|
||||
{
|
||||
[Header(Color alpha controls opacity)]
|
||||
[HDR]_Color ("Color", Color) = (0.5, 0.5, 0.5, 1.0)
|
||||
|
||||
[Space(15)]
|
||||
_Depth ("Depth Fade Distance", Range(1.0, 500.0)) = 100.0
|
||||
|
||||
[Space]
|
||||
_CameraDistanceFadeFar("Camera Distance Fade Far", Float) = 10.0
|
||||
_CameraDistanceFadeClose("Camera Distance Fade Close", Float) = 0.0
|
||||
|
||||
[Space]
|
||||
_UvFadeX("UV Fade X", Range(0, 10)) = 0.1
|
||||
_UvFadeY("UV Fade Y", Range(0, 10)) = 0.1
|
||||
[ToggleOff]_AllowAlphaOverflow("Allow Alpha Overflow", Float) = 0.0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags{"Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent"}
|
||||
LOD 200
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
Lighting Off ZWrite Off
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma shader_feature _ _ALLOWALPHAOVERFLOW_OFF
|
||||
#pragma multi_compile_fog;
|
||||
#pragma target 3.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
fixed4 _Color;
|
||||
float _Depth;
|
||||
float _CameraDistanceFadeFar, _CameraDistanceFadeClose;
|
||||
float _UvFadeX, _UvFadeY;
|
||||
|
||||
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
|
||||
|
||||
struct appdata{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f{
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
float3 dist :TEXCOORD3;
|
||||
float4 projPos : TEXCOORD2;
|
||||
float4 vertex : SV_POSITION;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert (appdata i){
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(i);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.vertex = UnityObjectToClipPos(i.vertex);
|
||||
o.uv = i.texcoord;
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
o.dist = UnityObjectToViewPos(i.vertex);
|
||||
|
||||
o.projPos = ComputeScreenPos(o.vertex);
|
||||
UNITY_TRANSFER_DEPTH(o.projPos);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_TARGET
|
||||
{
|
||||
fixed4 c = _Color;
|
||||
const float scene_depth = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
|
||||
const float object_depth = i.projPos.z + length(i.dist);
|
||||
const float depth_fade = saturate((scene_depth - object_depth) / _Depth);
|
||||
c.a *= saturate((depth_fade * length(i.dist) - _CameraDistanceFadeClose) / (_CameraDistanceFadeFar - _CameraDistanceFadeClose));
|
||||
|
||||
const float fade_uv_x = pow(smoothstep(1, 0, abs(i.uv.x * 2 - 1)), _UvFadeX);
|
||||
const float fade_uv_y = pow(smoothstep(1, 0, abs(i.uv.y * 2 - 1)), _UvFadeY);
|
||||
c.a *= fade_uv_x * fade_uv_y;
|
||||
|
||||
#ifdef _ALLOWALPHAOVERFLOW_OFF
|
||||
c.a = saturate(c.a);
|
||||
#endif
|
||||
UNITY_APPLY_FOG(i.fogCoord, c);
|
||||
return c;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
9
Assets/FlatKit/Shaders/LightPlane.shader.meta
Normal file
9
Assets/FlatKit/Shaders/LightPlane.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de78d2ec04e9f4735a68f342480140f6
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/FlatKit/Shaders/StylizedSurface.meta
Normal file
8
Assets/FlatKit/Shaders/StylizedSurface.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4bbce7a266a4ae14d89eb67845dda82d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/FlatKit/Shaders/StylizedSurface/LibraryUrp.meta
Normal file
8
Assets/FlatKit/Shaders/StylizedSurface/LibraryUrp.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 118ff3e3b1cef4a79837b12635233239
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,282 @@
|
||||
#ifndef FLATKIT_LIGHTING_DR_INCLUDED
|
||||
#define FLATKIT_LIGHTING_DR_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
inline half NdotLTransition(half3 normal, half3 lightDir, half selfShadingSize, half shadowEdgeSize, half flatness) {
|
||||
const half NdotL = dot(normal, lightDir);
|
||||
const half angleDiff = saturate((NdotL * 0.5 + 0.5) - selfShadingSize);
|
||||
const half angleDiffTransition = smoothstep(0, shadowEdgeSize, angleDiff);
|
||||
return lerp(angleDiff, angleDiffTransition, flatness);
|
||||
}
|
||||
|
||||
inline half NdotLTransitionPrimary(half3 normal, half3 lightDir) {
|
||||
return NdotLTransition(normal, lightDir, _SelfShadingSize, _ShadowEdgeSize, _Flatness);
|
||||
}
|
||||
|
||||
#if defined(DR_CEL_EXTRA_ON)
|
||||
inline half NdotLTransitionExtra(half3 normal, half3 lightDir) {
|
||||
return NdotLTransition(normal, lightDir, _SelfShadingSizeExtra, _ShadowEdgeSizeExtra, _FlatnessExtra);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline half NdotLTransitionTexture(half3 normal, half3 lightDir, sampler2D stepTex) {
|
||||
const half NdotL = dot(normal, lightDir);
|
||||
const half angleDiff = saturate((NdotL * 0.5 + 0.5) - _SelfShadingSize * 0.0);
|
||||
const half4 rampColor = tex2D(stepTex, half2(angleDiff, 0.5));
|
||||
// NOTE: The color channel here corresponds to the texture format in the shader editor script.
|
||||
const half angleDiffTransition = rampColor.r;
|
||||
return angleDiffTransition;
|
||||
}
|
||||
|
||||
inline void ApplyLightToColor(Light light, inout half3 c) {
|
||||
#if defined(_UNITYSHADOWMODE_MULTIPLY)
|
||||
c *= lerp(1, light.shadowAttenuation, _UnityShadowPower);
|
||||
#endif
|
||||
#if defined(_UNITYSHADOWMODE_COLOR)
|
||||
c = lerp(lerp(c, _UnityShadowColor.rgb, _UnityShadowColor.a), c, light.shadowAttenuation);
|
||||
#endif
|
||||
|
||||
c.rgb *= light.color * light.distanceAttenuation;
|
||||
}
|
||||
|
||||
half3 LightingPhysicallyBased_DSTRM(Light light, InputData inputData)
|
||||
{
|
||||
// If all light in the scene is baked, we use custom light direction for the cel shading.
|
||||
#if defined(LIGHTMAP_ON)
|
||||
light.direction = _LightmapDirection;
|
||||
#else
|
||||
light.direction = lerp(light.direction, _LightmapDirection, _OverrideLightmapDir);
|
||||
#endif
|
||||
|
||||
half4 c = _BaseColor;
|
||||
|
||||
#if defined(_CELPRIMARYMODE_SINGLE)
|
||||
const half NdotLTPrimary = NdotLTransitionPrimary(inputData.normalWS, light.direction);
|
||||
c = lerp(_ColorDim, c, NdotLTPrimary);
|
||||
#endif // _CELPRIMARYMODE_SINGLE
|
||||
|
||||
#if defined(_CELPRIMARYMODE_STEPS)
|
||||
const half NdotLTSteps = NdotLTransitionTexture(inputData.normalWS, light.direction, _CelStepTexture);
|
||||
c = lerp(_ColorDimSteps, c, NdotLTSteps);
|
||||
#endif // _CELPRIMARYMODE_STEPS
|
||||
|
||||
#if defined(_CELPRIMARYMODE_CURVE)
|
||||
const half NdotLTCurve = NdotLTransitionTexture(inputData.normalWS, light.direction, _CelCurveTexture);
|
||||
c = lerp(_ColorDimCurve, c, NdotLTCurve);
|
||||
#endif // _CELPRIMARYMODE_CURVE
|
||||
|
||||
#if defined(DR_CEL_EXTRA_ON)
|
||||
const half NdotLTExtra = NdotLTransitionExtra(inputData.normalWS, light.direction);
|
||||
c = lerp(_ColorDimExtra, c, NdotLTExtra);
|
||||
#endif // DR_CEL_EXTRA_ON
|
||||
|
||||
#if defined(DR_GRADIENT_ON)
|
||||
const float angleRadians = _GradientAngle / 180.0 * PI;
|
||||
#if defined(_GRADIENTSPACE_WORLD)
|
||||
const float2 position = inputData.positionWS.xy;
|
||||
#else
|
||||
const float2 position = TransformWorldToObject(inputData.positionWS).xy;
|
||||
#endif
|
||||
const float posGradRotated = (position.x - _GradientCenterX) * sin(angleRadians) +
|
||||
(position.y - _GradientCenterY) * cos(angleRadians);
|
||||
const half gradientFactor = saturate((_GradientSize * 0.5 - posGradRotated) / _GradientSize);
|
||||
c = lerp(c, _ColorGradient, gradientFactor);
|
||||
#endif // DR_GRADIENT_ON
|
||||
|
||||
const half NdotL = dot(inputData.normalWS, light.direction);
|
||||
|
||||
#if defined(DR_RIM_ON)
|
||||
const float rim = 1.0 - dot(inputData.viewDirectionWS, inputData.normalWS);
|
||||
const float rimSpread = 1.0 - _FlatRimSize - NdotL * _FlatRimLightAlign;
|
||||
const float rimEdgeSmooth = _FlatRimEdgeSmoothness;
|
||||
const float rimTransition = smoothstep(rimSpread - rimEdgeSmooth * 0.5, rimSpread + rimEdgeSmooth * 0.5, rim);
|
||||
c.rgb = lerp(c.rgb, _FlatRimColor.rgb, rimTransition * _FlatRimColor.a);
|
||||
#endif // DR_RIM_ON
|
||||
|
||||
#if defined(DR_SPECULAR_ON)
|
||||
// Halfway between lighting direction and view vector.
|
||||
const float3 halfVector = normalize(light.direction + inputData.viewDirectionWS);
|
||||
const float NdotH = dot(inputData.normalWS, halfVector) * 0.5 + 0.5;
|
||||
const float specular = saturate(pow(abs(NdotH), 100.0 * (1.0 - _FlatSpecularSize) * (1.0 - _FlatSpecularSize)));
|
||||
const float specularTransition = smoothstep(0.5 - _FlatSpecularEdgeSmoothness * 0.1,
|
||||
0.5 + _FlatSpecularEdgeSmoothness * 0.1, specular);
|
||||
c = lerp(c, _FlatSpecularColor, specularTransition);
|
||||
#endif // DR_SPECULAR_ON
|
||||
|
||||
#if defined(_UNITYSHADOW_OCCLUSION)
|
||||
const float occludedAttenuation = smoothstep(0.25, 0.0, -min(NdotL, 0));
|
||||
light.shadowAttenuation *= occludedAttenuation;
|
||||
light.distanceAttenuation *= occludedAttenuation;
|
||||
#endif
|
||||
|
||||
ApplyLightToColor(light, c.rgb);
|
||||
return c.rgb;
|
||||
}
|
||||
|
||||
void StylizeLight(inout Light light)
|
||||
{
|
||||
const half shadowAttenuation = saturate(light.shadowAttenuation * _UnityShadowSharpness);
|
||||
light.shadowAttenuation = shadowAttenuation;
|
||||
|
||||
const float distanceAttenuation = smoothstep(0, _LightFalloffSize + 0.001, light.distanceAttenuation);
|
||||
light.distanceAttenuation = distanceAttenuation;
|
||||
|
||||
/*
|
||||
#if LIGHTMAP_ON
|
||||
const half3 lightColor = 0;
|
||||
#else
|
||||
*/
|
||||
const half3 lightColor = lerp(half3(1, 1, 1), light.color, _LightContribution);
|
||||
/*
|
||||
#endif
|
||||
*/
|
||||
light.color = lightColor;
|
||||
}
|
||||
|
||||
half4 UniversalFragment_DSTRM(InputData inputData, SurfaceData surfaceData, float2 uv)
|
||||
{
|
||||
const half4 shadowMask = CalculateShadowMask(inputData);
|
||||
|
||||
#if VERSION_GREATER_EQUAL(10, 0)
|
||||
Light mainLight = GetMainLight(inputData.shadowCoord, inputData.positionWS, shadowMask);
|
||||
#else
|
||||
Light mainLight = GetMainLight(inputData.shadowCoord);
|
||||
#endif
|
||||
|
||||
#if UNITY_VERSION >= 202220
|
||||
uint meshRenderingLayers = GetMeshRenderingLayer();
|
||||
#elif VERSION_GREATER_EQUAL(12, 0)
|
||||
uint meshRenderingLayers = GetMeshRenderingLightLayer();
|
||||
#endif
|
||||
|
||||
#if LIGHTMAP_ON
|
||||
mainLight.distanceAttenuation = 1.0;
|
||||
#endif
|
||||
|
||||
StylizeLight(mainLight);
|
||||
|
||||
#if defined(_SCREEN_SPACE_OCCLUSION)
|
||||
AmbientOcclusionFactor aoFactor = GetScreenSpaceAmbientOcclusion(inputData.normalizedScreenSpaceUV);
|
||||
mainLight.color *= aoFactor.directAmbientOcclusion;
|
||||
inputData.bakedGI *= aoFactor.indirectAmbientOcclusion;
|
||||
#endif
|
||||
|
||||
MixRealtimeAndBakedGI(mainLight, inputData.normalWS, inputData.bakedGI, shadowMask);
|
||||
|
||||
// Apply Flat Kit stylizing to `inputData.bakedGI` (which is half3).
|
||||
#if LIGHTMAP_ON
|
||||
// Apply cel shading. Can also separate modes by `#if defined(_CELPRIMARYMODE_SINGLE)` etc.
|
||||
// length(inputData.bakedGI) can be replaced with inputData.bakedGI to use light map color more directly.
|
||||
/*
|
||||
float lighmapEdgeSize = saturate(_ShadowEdgeSize * 10.0);
|
||||
inputData.bakedGI = lerp(_ColorDim.rgb, _BaseColor.rgb,
|
||||
smoothstep(_SelfShadingSize - lighmapEdgeSize, _SelfShadingSize + lighmapEdgeSize, length(inputData.bakedGI)));
|
||||
|
||||
// Apply shadow modes
|
||||
#if defined(_UNITYSHADOWMODE_MULTIPLY)
|
||||
inputData.bakedGI = lerp(1, inputData.bakedGI, (1 - inputData.bakedGI) * _UnityShadowPower);
|
||||
#endif
|
||||
#if defined(_UNITYSHADOWMODE_COLOR)
|
||||
inputData.bakedGI = lerp(inputData.bakedGI, _UnityShadowColor.rgb, _UnityShadowColor.a * inputData.bakedGI);
|
||||
#endif
|
||||
*/
|
||||
#endif
|
||||
|
||||
const half4 albedo = half4(surfaceData.albedo + surfaceData.emission, surfaceData.alpha);
|
||||
|
||||
const float2 detailUV = TRANSFORM_TEX(uv, _DetailMap);
|
||||
const half4 detail = SAMPLE_TEXTURE2D(_DetailMap, sampler_DetailMap, detailUV);
|
||||
|
||||
#if defined(_BASEMAP_PREMULTIPLY)
|
||||
const half3 brdf = albedo.rgb;
|
||||
#else
|
||||
const half3 brdf = _BaseColor.rgb;
|
||||
#endif
|
||||
|
||||
BRDFData brdfData;
|
||||
InitializeBRDFData(brdf, 1.0 - 1.0 / kDielectricSpec.a, 0, 0, surfaceData.alpha, brdfData);
|
||||
half3 color = GlobalIllumination(brdfData, inputData.bakedGI, 1.0, inputData.normalWS, inputData.viewDirectionWS);
|
||||
#if VERSION_GREATER_EQUAL(12, 0)
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(mainLight.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
#endif
|
||||
color += LightingPhysicallyBased_DSTRM(mainLight, inputData);
|
||||
|
||||
#if defined(_ADDITIONAL_LIGHTS)
|
||||
uint pixelLightCount = GetAdditionalLightsCount();
|
||||
|
||||
#if USE_FORWARD_PLUS
|
||||
for (uint lightIndex = 0; lightIndex < min(URP_FP_DIRECTIONAL_LIGHTS_COUNT, MAX_VISIBLE_LIGHTS); lightIndex++)
|
||||
{
|
||||
FORWARD_PLUS_SUBTRACTIVE_LIGHT_CHECK
|
||||
|
||||
Light light = GetAdditionalLight(lightIndex, inputData.positionWS, shadowMask);//, aoFactor);
|
||||
StylizeLight(light);
|
||||
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
{
|
||||
color += LightingPhysicallyBased_DSTRM(light, inputData);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
LIGHT_LOOP_BEGIN(pixelLightCount)
|
||||
Light light = GetAdditionalLight(lightIndex, inputData.positionWS, shadowMask);//, aoFactor);
|
||||
StylizeLight(light);
|
||||
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
{
|
||||
color += LightingPhysicallyBased_DSTRM(light, inputData);
|
||||
}
|
||||
LIGHT_LOOP_END
|
||||
#endif
|
||||
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
color += inputData.vertexLighting * brdfData.diffuse;
|
||||
#endif
|
||||
|
||||
// Base map.
|
||||
{
|
||||
#if defined(_TEXTUREBLENDINGMODE_ADD)
|
||||
color += lerp(half3(0.0f, 0.0f, 0.0f), albedo.rgb, _TextureImpact);
|
||||
#else // _TEXTUREBLENDINGMODE_MULTIPLY
|
||||
color *= lerp(half3(1.0f, 1.0f, 1.0f), albedo.rgb, _TextureImpact);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Detail map.
|
||||
{
|
||||
#if defined(_DETAILMAPBLENDINGMODE_ADD)
|
||||
color += lerp(0, _DetailMapColor.rgb, detail.rgb * _DetailMapImpact).rgb;
|
||||
#endif
|
||||
#if defined(_DETAILMAPBLENDINGMODE_MULTIPLY)
|
||||
// color *= lerp(1, _DetailMapColor.rgb, detail.rgb * _DetailMapImpact).rgb;
|
||||
color *= lerp(1, detail.rgb * _DetailMapColor.rgb, _DetailMapImpact).rgb;
|
||||
#endif
|
||||
#if defined(_DETAILMAPBLENDINGMODE_INTERPOLATE)
|
||||
color = lerp(color, detail.rgb, _DetailMapImpact * _DetailMapColor.rgb * detail.a).rgb;
|
||||
#endif
|
||||
}
|
||||
|
||||
color += surfaceData.emission;
|
||||
|
||||
#ifdef _DBUFFER
|
||||
// Modified `DBuffer.hlsl` function `ApplyDecalToBaseColor` to use light attenuation.
|
||||
FETCH_DBUFFER(DBuffer, _DBufferTexture, int2(inputData.positionCS.xy));
|
||||
DecalSurfaceData decalSurfaceData;
|
||||
DECODE_FROM_DBUFFER(DBuffer, decalSurfaceData);
|
||||
half3 decalColor = decalSurfaceData.baseColor.xyz;
|
||||
ApplyLightToColor(mainLight, decalColor);
|
||||
color.xyz = color.xyz * decalSurfaceData.baseColor.w + decalColor;
|
||||
#endif
|
||||
|
||||
return half4(color, surfaceData.alpha);
|
||||
}
|
||||
|
||||
#endif // FLATKIT_LIGHTING_DR_INCLUDED
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d645ee52b3eb44f2dacb6784216d7712
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,279 @@
|
||||
#ifndef FLATKIT_LIGHT_PASS_DR_INCLUDED
|
||||
#define FLATKIT_LIGHT_PASS_DR_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
// Check is needed because in Unity 2021 they use two different URP versions - 14 on desktop and 12 on mobile.
|
||||
#if !VERSION_LOWER(13, 0)
|
||||
#if defined(LOD_FADE_CROSSFADE)
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
|
||||
#endif
|
||||
#endif
|
||||
#include "Lighting_DR.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float3 normalOS : NORMAL;
|
||||
float4 tangentOS : TANGENT;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 staticLightmapUV : TEXCOORD1;
|
||||
float2 dynamicLightmapUV : TEXCOORD2;
|
||||
|
||||
#if defined(DR_VERTEX_COLORS_ON)
|
||||
float4 color : COLOR;
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
|
||||
float3 positionWS : TEXCOORD1; // xyz: posWS
|
||||
|
||||
#ifdef _NORMALMAP
|
||||
float4 normalWS : TEXCOORD2; // xyz: normal, w: viewDir.x
|
||||
float4 tangentWS : TEXCOORD3; // xyz: tangent, w: viewDir.y
|
||||
float4 bitangentWS : TEXCOORD4; // xyz: bitangent, w: viewDir.z
|
||||
#else
|
||||
float3 normalWS : TEXCOORD2;
|
||||
float3 viewDir : TEXCOORD3;
|
||||
#endif
|
||||
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
half4 fogFactorAndVertexLight : TEXCOORD5; // x: fogFactor, yzw: vertex light
|
||||
#else
|
||||
half fogFactor : TEXCOORD5;
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
float4 shadowCoord : TEXCOORD6;
|
||||
#endif
|
||||
|
||||
DECLARE_LIGHTMAP_OR_SH(staticLightmapUV, vertexSH, 7);
|
||||
|
||||
#ifdef DYNAMICLIGHTMAP_ON
|
||||
float2 dynamicLightmapUV : TEXCOORD8; // Dynamic lightmap UVs
|
||||
#endif
|
||||
|
||||
float4 positionCS : SV_POSITION;
|
||||
|
||||
#if defined(DR_VERTEX_COLORS_ON)
|
||||
float4 VertexColor : COLOR;
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
/// ---------------------------------------------------------------------------
|
||||
// Library/PackageCache/com.unity.render-pipelines.universal@16.0.5/Shaders/SimpleLitForwardPass.hlsl
|
||||
void InitializeInputData_DR(Varyings input, half3 normalTS, out InputData inputData)
|
||||
{
|
||||
inputData = (InputData)0;
|
||||
|
||||
inputData.positionWS = input.positionWS;
|
||||
inputData.positionCS = input.positionCS;
|
||||
|
||||
#ifdef _NORMALMAP
|
||||
half3 viewDirWS = half3(input.normalWS.w, input.tangentWS.w, input.bitangentWS.w);
|
||||
#if VERSION_GREATER_EQUAL(12, 0)
|
||||
inputData.tangentToWorld = half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz);
|
||||
inputData.normalWS = TransformTangentToWorld(normalTS, inputData.tangentToWorld);
|
||||
#else
|
||||
float sgn = input.tangentWS.w; // should be either +1 or -1
|
||||
float3 bitangent = sgn * cross(input.normalWS.xyz, input.tangentWS.xyz);
|
||||
inputData.normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWS.xyz));
|
||||
#endif
|
||||
#else
|
||||
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(inputData.positionWS);
|
||||
inputData.normalWS = input.normalWS;
|
||||
#endif
|
||||
|
||||
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
|
||||
viewDirWS = SafeNormalize(viewDirWS);
|
||||
|
||||
inputData.viewDirectionWS = viewDirWS;
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
inputData.shadowCoord = input.shadowCoord;
|
||||
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
||||
inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
|
||||
#else
|
||||
inputData.shadowCoord = float4(0, 0, 0, 0);
|
||||
#endif
|
||||
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
inputData.fogCoord = InitializeInputDataFog(float4(inputData.positionWS, 1.0), input.fogFactorAndVertexLight.x);
|
||||
inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
|
||||
#else
|
||||
#if VERSION_GREATER_EQUAL(12, 0)
|
||||
inputData.fogCoord = InitializeInputDataFog(float4(inputData.positionWS, 1.0), input.fogFactor);
|
||||
#endif
|
||||
inputData.vertexLighting = half3(0, 0, 0);
|
||||
#endif
|
||||
|
||||
#if defined(DYNAMICLIGHTMAP_ON)
|
||||
inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.dynamicLightmapUV, input.vertexSH, inputData.normalWS);
|
||||
inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV);
|
||||
#elif !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
|
||||
|
||||
#if UNITY_VERSION >= 60000012
|
||||
inputData.bakedGI = SAMPLE_GI(input.vertexSH,
|
||||
GetAbsolutePositionWS(inputData.positionWS),
|
||||
inputData.normalWS,
|
||||
inputData.viewDirectionWS,
|
||||
input.positionCS.xy,
|
||||
/* probeOcclusion */ 0,
|
||||
inputData.shadowMask);
|
||||
#else // UNITY_VERSION >= 60000012
|
||||
inputData.bakedGI = SAMPLE_GI(input.vertexSH,
|
||||
GetAbsolutePositionWS(inputData.positionWS),
|
||||
inputData.normalWS,
|
||||
inputData.viewDirectionWS,
|
||||
input.positionCS.xy
|
||||
);
|
||||
#endif // UNITY_VERSION >= 60000012
|
||||
|
||||
#else // !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
|
||||
inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.vertexSH, inputData.normalWS);
|
||||
inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV);
|
||||
#endif // !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
|
||||
|
||||
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS);
|
||||
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
#if defined(DYNAMICLIGHTMAP_ON)
|
||||
inputData.dynamicLightmapUV = input.dynamicLightmapUV.xy;
|
||||
#endif
|
||||
#if defined(LIGHTMAP_ON)
|
||||
inputData.staticLightmapUV = input.staticLightmapUV;
|
||||
#else
|
||||
inputData.vertexSH = input.vertexSH;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
Varyings StylizedPassVertex(Attributes input)
|
||||
{
|
||||
#if defined(CURVEDWORLD_IS_INSTALLED) && !defined(CURVEDWORLD_DISABLED_ON)
|
||||
#ifdef CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
CURVEDWORLD_TRANSFORM_VERTEX_AND_NORMAL(input.positionOS, input.normalOS, input.tangentOS)
|
||||
#else
|
||||
CURVEDWORLD_TRANSFORM_VERTEX(input.positionOS)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Varyings output = (Varyings)0;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
const VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normalOS, input.tangentOS);
|
||||
|
||||
#if defined(_FOG_FRAGMENT)
|
||||
half fogFactor = 0;
|
||||
#else
|
||||
half fogFactor = ComputeFogFactor(vertexInput.positionCS.z);
|
||||
#endif
|
||||
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
||||
output.positionWS.xyz = vertexInput.positionWS;
|
||||
output.positionCS = vertexInput.positionCS;
|
||||
|
||||
half3 viewDirWS = GetCameraPositionWS() - vertexInput.positionWS;
|
||||
|
||||
#ifdef _NORMALMAP
|
||||
output.normalWS = half4(normalInput.normalWS, viewDirWS.x);
|
||||
output.tangentWS = half4(normalInput.tangentWS, viewDirWS.y);
|
||||
output.bitangentWS = half4(normalInput.bitangentWS, viewDirWS.z);
|
||||
#else
|
||||
output.normal = NormalizeNormalPerVertex(normalInput.normalWS);
|
||||
output.viewDir = viewDirWS;
|
||||
#endif
|
||||
|
||||
OUTPUT_LIGHTMAP_UV(input.staticLightmapUV, unity_LightmapST, output.staticLightmapUV);
|
||||
#ifdef DYNAMICLIGHTMAP_ON
|
||||
output.dynamicLightmapUV = input.dynamicLightmapUV.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
||||
#endif
|
||||
|
||||
#if UNITY_VERSION >= 60000010
|
||||
float4 probeOcclusion;
|
||||
OUTPUT_SH4(vertexInput.positionWS, output.normalWS.xyz, GetWorldSpaceNormalizeViewDir(vertexInput.positionWS), output.vertexSH, probeOcclusion);
|
||||
#elif UNITY_VERSION >= 202317
|
||||
OUTPUT_SH4(vertexInput.positionWS, output.normalWS.xyz, GetWorldSpaceNormalizeViewDir(vertexInput.positionWS), output.vertexSH);
|
||||
#elif UNITY_VERSION >= 202310
|
||||
OUTPUT_SH(vertexInput.positionWS, output.normalWS.xyz, GetWorldSpaceNormalizeViewDir(vertexInput.positionWS), output.vertexSH);
|
||||
#else
|
||||
OUTPUT_SH(output.normalWS.xyz, output.vertexSH);
|
||||
#endif
|
||||
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
half3 vertexLight = VertexLighting(vertexInput.positionWS, normalInput.normalWS);
|
||||
output.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
|
||||
#else
|
||||
output.fogFactor = fogFactor;
|
||||
#endif
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
output.shadowCoord = GetShadowCoord(vertexInput);
|
||||
#endif
|
||||
|
||||
#if defined(DR_VERTEX_COLORS_ON)
|
||||
output.VertexColor = input.color;
|
||||
#endif
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 StylizedPassFragment(Varyings input) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
|
||||
SurfaceData surfaceData;
|
||||
InitializeSimpleLitSurfaceData(input.uv, surfaceData);
|
||||
|
||||
#if defined(LOD_FADE_CROSSFADE) && !VERSION_LOWER(13, 0)
|
||||
LODFadeCrossFade(input.positionCS);
|
||||
#endif
|
||||
|
||||
InputData inputData;
|
||||
InitializeInputData_DR(input, surfaceData.normalTS, inputData);
|
||||
#if UNITY_VERSION >= 202330
|
||||
SETUP_DEBUG_TEXTURE_DATA(inputData, input.uv);
|
||||
#elif UNITY_VERSION >= 202210
|
||||
SETUP_DEBUG_TEXTURE_DATA(inputData, input.uv, _BaseMap);
|
||||
#endif
|
||||
|
||||
// Apply vertex color before shading (default behavior). Remove the #if block and uncomment below to apply after
|
||||
// shading.
|
||||
#if defined(DR_VERTEX_COLORS_ON)
|
||||
_BaseColor.rgb *= input.VertexColor.rgb;
|
||||
#endif
|
||||
|
||||
// Computes direct light contribution.
|
||||
half4 color = UniversalFragment_DSTRM(inputData, surfaceData, input.uv);
|
||||
|
||||
/*
|
||||
#if defined(DR_VERTEX_COLORS_ON)
|
||||
color.rgb *= input.VertexColor.rgb;
|
||||
#endif
|
||||
*/
|
||||
|
||||
color.rgb = MixFog(color.rgb, inputData.fogCoord);
|
||||
#if UNITY_VERSION >= 202220
|
||||
color.a = OutputAlpha(color.a, IsSurfaceTypeTransparent(_Surface));
|
||||
#else
|
||||
color.a = OutputAlpha(color.a, _Surface);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
#endif // FLATKIT_LIGHT_PASS_DR_INCLUDED
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2126186b3a4f84079b81ce8d14b60126
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,215 @@
|
||||
#ifndef FLAT_KIT_STYLIZED_INPUT_INCLUDED
|
||||
#define FLAT_KIT_STYLIZED_INPUT_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
|
||||
|
||||
// NOTE: Do not ifdef the properties here as SRP batcher can not handle different layouts.
|
||||
|
||||
#ifndef FLATKIT_TERRAIN
|
||||
#if _FORWARD_PLUS && UNITY_VERSION < 600000
|
||||
CBUFFER_START(UnityPerMaterialNoBatching)
|
||||
#else
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// See `SimpleLitInput.hlsl` and `LitInput.hlsl` for reference
|
||||
|
||||
float4 _BaseMap_ST;
|
||||
float4 _DetailMap_ST;
|
||||
|
||||
#ifndef FLATKIT_TERRAIN
|
||||
half4 _BaseColor;
|
||||
half _Cutoff;
|
||||
half _Surface;
|
||||
#endif
|
||||
|
||||
half4 _EmissionColor;
|
||||
half4 _UnityShadowColor;
|
||||
|
||||
// --- _CELPRIMARYMODE_SINGLE
|
||||
half4 _ColorDim;
|
||||
// --- _CELPRIMARYMODE_SINGLE
|
||||
|
||||
// --- DR_SPECULAR_ON
|
||||
half4 _FlatSpecularColor;
|
||||
float _FlatSpecularSize;
|
||||
float _FlatSpecularEdgeSmoothness;
|
||||
// --- DR_SPECULAR_ON
|
||||
|
||||
// --- DR_RIM_ON
|
||||
half4 _FlatRimColor;
|
||||
float _FlatRimSize;
|
||||
float _FlatRimEdgeSmoothness;
|
||||
float _FlatRimLightAlign;
|
||||
// --- DR_RIM_ON
|
||||
|
||||
// --- _CELPRIMARYMODE_STEPS
|
||||
half4 _ColorDimSteps;
|
||||
sampler2D _CelStepTexture;
|
||||
// --- _CELPRIMARYMODE_STEPS
|
||||
|
||||
// --- _CELPRIMARYMODE_CURVE
|
||||
half4 _ColorDimCurve;
|
||||
sampler2D _CelCurveTexture;
|
||||
// --- _CELPRIMARYMODE_CURVE
|
||||
|
||||
// --- DR_CEL_EXTRA_ON
|
||||
half4 _ColorDimExtra;
|
||||
half _SelfShadingSizeExtra;
|
||||
half _ShadowEdgeSizeExtra;
|
||||
half _FlatnessExtra;
|
||||
// --- DR_CEL_EXTRA_ON
|
||||
|
||||
// --- DR_GRADIENT_ON
|
||||
half4 _ColorGradient;
|
||||
half _GradientCenterX;
|
||||
half _GradientCenterY;
|
||||
half _GradientSize;
|
||||
half _GradientAngle;
|
||||
// --- DR_GRADIENT_ON
|
||||
|
||||
half _TextureImpact;
|
||||
|
||||
half _SelfShadingSize;
|
||||
half _ShadowEdgeSize;
|
||||
half _LightContribution;
|
||||
half _LightFalloffSize;
|
||||
half _Flatness;
|
||||
|
||||
half _UnityShadowPower;
|
||||
half _UnityShadowSharpness;
|
||||
|
||||
half _OverrideLightmapDir;
|
||||
half3 _LightmapDirection;
|
||||
|
||||
half _DetailMapImpact;
|
||||
half4 _DetailMapColor;
|
||||
|
||||
half4 _OutlineColor;
|
||||
half _OutlineWidth;
|
||||
half _OutlineScale;
|
||||
half _OutlineDepthOffset;
|
||||
half _CameraDistanceImpact;
|
||||
|
||||
#ifndef FLATKIT_TERRAIN
|
||||
CBUFFER_END
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_DOTS_INSTANCING_ENABLED
|
||||
UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _BaseColor)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Cutoff)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Surface)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _EmissionColor)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4 , _UnityShadowColor)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _ColorDim)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _FlatSpecularColor)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _FlatSpecularSize)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _FlatSpecularEdgeSmoothness)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _FlatRimColor)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _FlatRimSize)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _FlatRimEdgeSmoothness)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _FlatRimLightAlign)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _ColorDimSteps)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _ColorDimCurve)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _ColorDimExtra)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _SelfShadingSizeExtra)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _ShadowEdgeSizeExtra)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _FlatnessExtra)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _ColorGradient)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _GradientCenterX)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _GradientCenterY)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _GradientSize)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _GradientAngle)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _TextureImpact)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _SelfShadingSize)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _ShadowEdgeSize)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _LightContribution)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _LightFalloffSize)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _Flatness)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _UnityShadowPower)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _UnityShadowSharpness)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _OverrideLightmapDir)
|
||||
UNITY_DOTS_INSTANCED_PROP(float3, _LightmapDirection)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _DetailMapImpact)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _DetailMapColor)
|
||||
UNITY_DOTS_INSTANCED_PROP(float4, _OutlineColor)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _OutlineWidth)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _OutlineScale)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _OutlineDepthOffset)
|
||||
UNITY_DOTS_INSTANCED_PROP(float , _CameraDistanceImpact)
|
||||
UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)
|
||||
|
||||
#define _BaseColor UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4 , _BaseColor)
|
||||
#define _Cutoff UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _Cutoff)
|
||||
#define _Surface UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _Surface)
|
||||
#define _EmissionColor UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4 , _EmissionColor)
|
||||
#define _UnityShadowColor UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4 , _UnityShadowColor)
|
||||
#define _ColorDim UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4 , _ColorDim)
|
||||
#define _FlatSpecularColor UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4 , _FlatSpecularColor)
|
||||
#define _FlatSpecularSize UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _FlatSpecularSize)
|
||||
#define _FlatSpecularEdgeSmoothness UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _FlatSpecularEdgeSmoothness)
|
||||
#define _FlatRimColor UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4 , _FlatRimColor)
|
||||
#define _FlatRimSize UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _FlatRimSize)
|
||||
#define _FlatRimEdgeSmoothness UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _FlatRimEdgeSmoothness)
|
||||
#define _FlatRimLightAlign UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _FlatRimLightAlign)
|
||||
#define _ColorDimSteps UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4 , _ColorDimSteps)
|
||||
#define _ColorDimCurve UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4 , _ColorDimCurve)
|
||||
#define _ColorDimExtra UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4 , _ColorDimExtra)
|
||||
#define _SelfShadingSizeExtra UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _SelfShadingSizeExtra)
|
||||
#define _ShadowEdgeSizeExtra UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _ShadowEdgeSizeExtra)
|
||||
#define _FlatnessExtra UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _FlatnessExtra)
|
||||
#define _ColorGradient UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4 , _ColorGradient)
|
||||
#define _GradientCenterX UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _GradientCenterX)
|
||||
#define _GradientCenterY UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _GradientCenterY)
|
||||
#define _GradientSize UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _GradientSize)
|
||||
#define _GradientAngle UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _GradientAngle)
|
||||
#define _TextureImpact UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _TextureImpact)
|
||||
#define _SelfShadingSize UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _SelfShadingSize)
|
||||
#define _ShadowEdgeSize UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _ShadowEdgeSize)
|
||||
#define _LightContribution UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _LightContribution)
|
||||
#define _LightFalloffSize UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _LightFalloffSize)
|
||||
#define _Flatness UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _Flatness)
|
||||
#define _UnityShadowPower UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _UnityShadowPower)
|
||||
#define _UnityShadowSharpness UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _UnityShadowSharpness)
|
||||
#define _OverrideLightmapDir UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _OverrideLightmapDir)
|
||||
#define _LightmapDirection UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float3 , _LightmapDirection)
|
||||
#define _DetailMapImpact UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _DetailMapImpact)
|
||||
#define _DetailMapColor UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4 , _DetailMapColor)
|
||||
#define _OutlineColor UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4 , _OutlineColor)
|
||||
#define _OutlineWidth UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _OutlineWidth)
|
||||
#define _OutlineScale UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _OutlineScale)
|
||||
#define _OutlineDepthOffset UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _OutlineDepthOffset)
|
||||
#define _CameraDistanceImpact UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float , _CameraDistanceImpact)
|
||||
#endif
|
||||
|
||||
inline void InitializeSimpleLitSurfaceData(float2 uv, out SurfaceData outSurfaceData)
|
||||
{
|
||||
outSurfaceData = (SurfaceData)0;
|
||||
|
||||
half4 albedo = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap));
|
||||
outSurfaceData.alpha = albedo.a * _BaseColor.a;
|
||||
AlphaDiscard(outSurfaceData.alpha, _Cutoff);
|
||||
|
||||
outSurfaceData.albedo = albedo.rgb;
|
||||
#ifdef _ALPHAPREMULTIPLY_ON
|
||||
outSurfaceData.albedo *= outSurfaceData.alpha;
|
||||
#endif
|
||||
|
||||
outSurfaceData.metallic = 0.0; // unused
|
||||
outSurfaceData.specular = 0.0; // unused
|
||||
outSurfaceData.smoothness = 0.0; // unused
|
||||
outSurfaceData.normalTS = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap));
|
||||
outSurfaceData.occlusion = 1.0; // unused
|
||||
outSurfaceData.emission = SampleEmission(uv, _EmissionColor.rgb, TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap));
|
||||
}
|
||||
|
||||
half4 SampleSpecularSmoothness(half2 uv, half alpha, half4 specColor, TEXTURE2D_PARAM(specMap, sampler_specMap))
|
||||
{
|
||||
half4 specularSmoothness = half4(0.0h, 0.0h, 0.0h, 1.0h);
|
||||
return specularSmoothness;
|
||||
}
|
||||
|
||||
#endif // FLAT_KIT_STYLIZED_INPUT_INCLUDED
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3d750baac0e54925a4ad89a109d7561
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,154 @@
|
||||
#ifndef FLATKIT_TERRAIN_LIT_PASSES_DR_INCLUDED
|
||||
#define FLATKIT_TERRAIN_LIT_PASSES_DR_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl"
|
||||
#include "LibraryUrp/StylizedInput.hlsl"
|
||||
|
||||
#ifdef TERRAIN_GBUFFER
|
||||
FragmentOutput SplatmapFragment_DSTRM(Varyings IN)
|
||||
#else
|
||||
half4 SplatmapFragment_DSTRM(Varyings IN) : SV_TARGET
|
||||
#endif
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);
|
||||
#ifdef _ALPHATEST_ON
|
||||
ClipHoles(IN.uvMainAndLM.xy);
|
||||
#endif
|
||||
|
||||
half3 normalTS = half3(0.0h, 0.0h, 1.0h);
|
||||
#ifdef TERRAIN_SPLAT_BASEPASS
|
||||
half3 albedo = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uvMainAndLM.xy).rgb;
|
||||
half smoothness = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uvMainAndLM.xy).a;
|
||||
half metallic = SAMPLE_TEXTURE2D(_MetallicTex, sampler_MetallicTex, IN.uvMainAndLM.xy).r;
|
||||
half alpha = 1;
|
||||
half occlusion = 1;
|
||||
#else
|
||||
|
||||
half4 hasMask = half4(_LayerHasMask0, _LayerHasMask1, _LayerHasMask2, _LayerHasMask3);
|
||||
half4 masks[4];
|
||||
ComputeMasks(masks, hasMask, IN);
|
||||
|
||||
float2 splatUV = (IN.uvMainAndLM.xy * (_Control_TexelSize.zw - 1.0f) + 0.5f) * _Control_TexelSize.xy;
|
||||
half4 splatControl = SAMPLE_TEXTURE2D(_Control, sampler_Control, splatUV);
|
||||
|
||||
#ifdef _TERRAIN_BLEND_HEIGHT
|
||||
// disable Height Based blend when there are more than 4 layers (multi-pass breaks the normalization)
|
||||
if (_NumLayersCount <= 4)
|
||||
HeightBasedSplatModify(splatControl, masks);
|
||||
#endif
|
||||
|
||||
half weight;
|
||||
half4 mixedDiffuse;
|
||||
half4 defaultSmoothness;
|
||||
SplatmapMix(IN.uvMainAndLM, IN.uvSplat01, IN.uvSplat23, splatControl, weight, mixedDiffuse, defaultSmoothness, normalTS);
|
||||
half3 albedo = mixedDiffuse.rgb;
|
||||
|
||||
half4 defaultMetallic = half4(_Metallic0, _Metallic1, _Metallic2, _Metallic3);
|
||||
half4 defaultOcclusion = half4(_MaskMapRemapScale0.g, _MaskMapRemapScale1.g, _MaskMapRemapScale2.g, _MaskMapRemapScale3.g) +
|
||||
half4(_MaskMapRemapOffset0.g, _MaskMapRemapOffset1.g, _MaskMapRemapOffset2.g, _MaskMapRemapOffset3.g);
|
||||
|
||||
half4 maskSmoothness = half4(masks[0].a, masks[1].a, masks[2].a, masks[3].a);
|
||||
defaultSmoothness = lerp(defaultSmoothness, maskSmoothness, hasMask);
|
||||
half smoothness = dot(splatControl, defaultSmoothness);
|
||||
|
||||
half4 maskMetallic = half4(masks[0].r, masks[1].r, masks[2].r, masks[3].r);
|
||||
defaultMetallic = lerp(defaultMetallic, maskMetallic, hasMask);
|
||||
half metallic = dot(splatControl, defaultMetallic);
|
||||
|
||||
half4 maskOcclusion = half4(masks[0].g, masks[1].g, masks[2].g, masks[3].g);
|
||||
defaultOcclusion = lerp(defaultOcclusion, maskOcclusion, hasMask);
|
||||
half occlusion = dot(splatControl, defaultOcclusion);
|
||||
half alpha = weight;
|
||||
#endif
|
||||
|
||||
InputData inputData;
|
||||
InitializeInputData(IN, normalTS, inputData);
|
||||
|
||||
// If lightmap is enabled, flip the normal if the lightmap is flipped.
|
||||
/*
|
||||
#if defined(LIGHTMAP_ON)
|
||||
const half lightmapWorkaroundFlip = -1.0;
|
||||
inputData.normalWS = lightmapWorkaroundFlip * inputData.normalWS;
|
||||
#endif
|
||||
*/
|
||||
|
||||
#if UNITY_VERSION > 202340
|
||||
SETUP_DEBUG_TEXTURE_DATA_FOR_TEX(inputData, IN.uvMainAndLM.xy, _BaseMap);
|
||||
#elif VERSION_GREATER_EQUAL(12, 1)
|
||||
SETUP_DEBUG_TEXTURE_DATA(inputData, IN.uvMainAndLM.xy, _BaseMap);
|
||||
#endif
|
||||
|
||||
#if defined(_DBUFFER)
|
||||
half3 specular = half3(0.0h, 0.0h, 0.0h);
|
||||
ApplyDecal(IN.clipPos,
|
||||
albedo,
|
||||
specular,
|
||||
inputData.normalWS,
|
||||
metallic,
|
||||
occlusion,
|
||||
smoothness);
|
||||
#endif
|
||||
|
||||
#if UNITY_VERSION > 60000012 // Minor version not precise, somewhere between 6.0.4 and 6.0.23.
|
||||
InitializeBakedGIData(IN, inputData);
|
||||
#endif
|
||||
|
||||
#ifdef TERRAIN_GBUFFER
|
||||
|
||||
BRDFData brdfData;
|
||||
InitializeBRDFData(albedo, metallic, /* specular */ half3(0.0h, 0.0h, 0.0h), smoothness, alpha, brdfData);
|
||||
|
||||
half4 color;
|
||||
color.rgb = GlobalIllumination(brdfData, inputData.bakedGI, occlusion, inputData.normalWS, inputData.viewDirectionWS);
|
||||
color.a = alpha;
|
||||
|
||||
SplatmapFinalColor(color, inputData.fogCoord);
|
||||
|
||||
return BRDFDataToGbuffer(brdfData, inputData, smoothness, color.rgb);
|
||||
|
||||
#else
|
||||
{
|
||||
_BaseColor.rgb *= albedo;
|
||||
|
||||
#ifdef _CELPRIMARYMODE_SINGLE
|
||||
_ColorDim.rgb *= albedo;
|
||||
#endif
|
||||
|
||||
#ifdef _CELPRIMARYMODE_STEPS
|
||||
_ColorDimSteps.rgb *= albedo;
|
||||
#endif
|
||||
|
||||
#ifdef _CELPRIMARYMODE_CURVE
|
||||
_ColorDimCurve.rgb *= albedo;
|
||||
#endif
|
||||
|
||||
#ifdef DR_CEL_EXTRA_ON
|
||||
_ColorDimExtra.rgb *= albedo;
|
||||
#endif
|
||||
|
||||
#ifdef DR_GRADIENT_ON
|
||||
_ColorGradient.rgb *= albedo;
|
||||
#endif
|
||||
}
|
||||
|
||||
SurfaceData surfaceData;
|
||||
surfaceData.albedo = albedo;
|
||||
surfaceData.alpha = alpha;
|
||||
surfaceData.emission = 0;
|
||||
surfaceData.specular = 0;
|
||||
surfaceData.smoothness = smoothness;
|
||||
surfaceData.metallic = metallic;
|
||||
surfaceData.occlusion = occlusion;
|
||||
surfaceData.normalTS = normalTS;
|
||||
surfaceData.clearCoatMask = 0;
|
||||
surfaceData.clearCoatSmoothness = 0;
|
||||
|
||||
half4 color = UniversalFragment_DSTRM(inputData, surfaceData, IN.uvMainAndLM.xy);
|
||||
|
||||
SplatmapFinalColor(color, inputData.fogCoord);
|
||||
|
||||
return half4(color.rgb, 1.0h);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // FLATKIT_TERRAIN_LIT_PASSES_DR_INCLUDED
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5217ff6887a39405aa992142275ec2c0
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
640
Assets/FlatKit/Shaders/StylizedSurface/StylizedSurface.shader
Normal file
640
Assets/FlatKit/Shaders/StylizedSurface/StylizedSurface.shader
Normal file
@@ -0,0 +1,640 @@
|
||||
Shader "FlatKit/Stylized Surface"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[MainColor] _BaseColor ("Color", Color) = (1,1,1,1)
|
||||
|
||||
[KeywordEnum(None, Single, Steps, Curve)]_CelPrimaryMode("Cel Shading Mode", Float) = 1
|
||||
_ColorDim ("[_CELPRIMARYMODE_SINGLE]Color Shaded", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_ColorDimSteps ("[_CELPRIMARYMODE_STEPS]Color Shaded", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_ColorDimCurve ("[_CELPRIMARYMODE_CURVE]Color Shaded", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_SelfShadingSize ("[_CELPRIMARYMODE_SINGLE]Self Shading Size", Range(0, 1)) = 0.5
|
||||
_ShadowEdgeSize ("[_CELPRIMARYMODE_SINGLE]Edge Size", Range(0, 0.5)) = 0.05
|
||||
_Flatness ("[_CELPRIMARYMODE_SINGLE]Localized Shading", Range(0, 1)) = 1.0
|
||||
|
||||
[IntRange]_CelNumSteps ("[_CELPRIMARYMODE_STEPS]Number Of Steps", Range(1, 10)) = 3.0
|
||||
_CelStepTexture ("[_CELPRIMARYMODE_STEPS][LAST_PROP_STEPS]Cel steps", 2D) = "black" {}
|
||||
_CelCurveTexture ("[_CELPRIMARYMODE_CURVE][LAST_PROP_CURVE]Ramp", 2D) = "black" {}
|
||||
|
||||
[Space(10)]
|
||||
[Toggle(DR_CEL_EXTRA_ON)] _CelExtraEnabled("Enable Extra Cel Layer", Int) = 0
|
||||
_ColorDimExtra ("[DR_CEL_EXTRA_ON]Color Shaded", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_SelfShadingSizeExtra ("[DR_CEL_EXTRA_ON]Self Shading Size", Range(0, 1)) = 0.6
|
||||
_ShadowEdgeSizeExtra ("[DR_CEL_EXTRA_ON]Edge Size", Range(0, 0.5)) = 0.05
|
||||
_FlatnessExtra ("[DR_CEL_EXTRA_ON]Localized Shading", Range(0, 1)) = 1.0
|
||||
|
||||
[Space(10)]
|
||||
[Toggle(DR_SPECULAR_ON)] _SpecularEnabled("Enable Specular", Int) = 0
|
||||
[HDR] _FlatSpecularColor("[DR_SPECULAR_ON]Specular Color", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_FlatSpecularSize("[DR_SPECULAR_ON]Specular Size", Range(0.0, 1.0)) = 0.1
|
||||
_FlatSpecularEdgeSmoothness("[DR_SPECULAR_ON]Specular Edge Smoothness", Range(0.0, 1.0)) = 0
|
||||
|
||||
[Space(10)]
|
||||
[Toggle(DR_RIM_ON)] _RimEnabled("Enable Rim", Int) = 0
|
||||
[HDR] _FlatRimColor("[DR_RIM_ON]Rim Color", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_FlatRimLightAlign("[DR_RIM_ON]Light Align", Range(0.0, 1.0)) = 0
|
||||
_FlatRimSize("[DR_RIM_ON]Rim Size", Range(0, 1)) = 0.5
|
||||
_FlatRimEdgeSmoothness("[DR_RIM_ON]Rim Edge Smoothness", Range(0, 1)) = 0.5
|
||||
|
||||
[Space(10)]
|
||||
[Toggle(DR_GRADIENT_ON)] _GradientEnabled("Enable Height Gradient", Int) = 0
|
||||
[HDR] _ColorGradient("[DR_GRADIENT_ON]Gradient Color", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
[KeywordEnum(World, Local)]_GradientSpace("[DR_GRADIENT_ON]Space", Float) = 0
|
||||
_GradientCenterX("[DR_GRADIENT_ON]Center X", Float) = 0
|
||||
_GradientCenterY("[DR_GRADIENT_ON]Center Y", Float) = 0
|
||||
_GradientSize("[DR_GRADIENT_ON]Size", Float) = 10.0
|
||||
_GradientAngle("[DR_GRADIENT_ON]Gradient Angle", Range(0, 360)) = 0
|
||||
|
||||
[Space(10)]
|
||||
[Toggle(DR_OUTLINE_ON)] _OutlineEnabled("Enable Outline", Int) = 0
|
||||
_OutlineWidth("[DR_OUTLINE_ON]Width", Float) = 1.0
|
||||
_OutlineColor("[DR_OUTLINE_ON]Color", Color) = (1, 1, 1, 1)
|
||||
_OutlineScale("[DR_OUTLINE_ON]Scale", Float) = 1.0
|
||||
[Toggle(DR_OUTLINE_SMOOTH_NORMALS)] _VertexExtrusionSmoothNormals("[DR_OUTLINE_ON]Smooth Normals", Float) = 0.0
|
||||
_OutlineDepthOffset("[DR_OUTLINE_ON]Depth Offset", Range(0, 1)) = 0.0
|
||||
[KeywordEnum(Screen, Object)] _OutlineSpace("[DR_OUTLINE_ON]Space", Float) = 0.0
|
||||
_CameraDistanceImpact("[DR_OUTLINE_ON][_OUTLINESPACE_SCREEN]Camera Distance Impact", Range(0, 1)) = 0.0
|
||||
|
||||
[Space(10)]
|
||||
[Toggle(DR_VERTEX_COLORS_ON)] _VertexColorsEnabled("Enable Vertex Colors", Int) = 0
|
||||
|
||||
_LightContribution("[FOLDOUT(Advanced Lighting){6}]Light Color Contribution", Range(0, 1)) = 0
|
||||
_LightFalloffSize("Point / Spot Light Edge", Range(0, 1)) = 0
|
||||
|
||||
// Used to provide light direction to cel shading if all light in the scene is baked.
|
||||
[Toggle(DR_ENABLE_LIGHTMAP_DIR)]_OverrideLightmapDir("Override Light Direction", Int) = 0
|
||||
_LightmapDirectionPitch("[DR_ENABLE_LIGHTMAP_DIR]Pitch", Range(0, 360)) = 0
|
||||
_LightmapDirectionYaw("[DR_ENABLE_LIGHTMAP_DIR]Yaw", Range(0, 360)) = 0
|
||||
[HideInInspector] _LightmapDirection("Direction", Vector) = (0, 1, 0, 0)
|
||||
|
||||
[KeywordEnum(None, Multiply, Color)] _UnityShadowMode ("[FOLDOUT(Unity Built-in Shadows){5}]Mode", Float) = 0
|
||||
_UnityShadowPower("[_UNITYSHADOWMODE_MULTIPLY]Power", Range(0, 1)) = 0.2
|
||||
_UnityShadowColor("[_UNITYSHADOWMODE_COLOR]Color", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_UnityShadowSharpness("Sharpness", Range(1, 10)) = 1.0
|
||||
[Toggle(_UNITYSHADOW_OCCLUSION)]_UnityShadowOcclusion("Shadow Occlusion", Int) = 0
|
||||
|
||||
[MainTexture] _BaseMap("[FOLDOUT(Texture Maps){11}]Albedo", 2D) = "white" {}
|
||||
[Toggle(_BASEMAP_PREMULTIPLY)]_BaseMapPremultiply("[_]Mix Into Shading", Int) = 0
|
||||
[KeywordEnum(Multiply, Add)]_TextureBlendingMode("[_]Blending Mode", Float) = 0
|
||||
_TextureImpact("[_]Texture Impact", Range(0, 1)) = 1.0
|
||||
|
||||
_DetailMap("Detail Map", 2D) = "white" {}
|
||||
_DetailMapColor("[]Detail Color", Color) = (1,1,1,1)
|
||||
[KeywordEnum(Multiply, Add, Interpolate)]_DetailMapBlendingMode("[]Blending Mode", Float) = 0
|
||||
_DetailMapImpact("[]Detail Impact", Range(0, 1)) = 0.0
|
||||
|
||||
_BumpMap ("Normal Map", 2D) = "bump" {}
|
||||
|
||||
_EmissionMap ("Emission Map", 2D) = "white" {}
|
||||
[HDR]_EmissionColor("Emission Color", Color) = (1, 1, 1, 1)
|
||||
|
||||
[HideInInspector] _Cutoff ("Base Alpha Cutoff", Range (0, 1)) = .5
|
||||
|
||||
// Blending state
|
||||
[HideInInspector] _Surface("__surface", Float) = 0.0
|
||||
[HideInInspector] _Blend("__blend", Float) = 0.0
|
||||
[HideInInspector] _AlphaClip("__clip", Float) = 0.0
|
||||
[HideInInspector] _SrcBlend("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend("__dst", Float) = 0.0
|
||||
[HideInInspector] _ZWrite("__zw", Float) = 1.0
|
||||
[HideInInspector] _Cull("__cull", Float) = 2.0
|
||||
|
||||
// Editmode props
|
||||
[HideInInspector] _QueueOffset("Queue Offset", Float) = 0.0
|
||||
|
||||
/* start CurvedWorld */
|
||||
//[CurvedWorldBendSettings] _CurvedWorldBendSettings("0|1|1", Vector) = (0, 0, 0, 0)
|
||||
/* end CurvedWorld */
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "IgnoreProjector" = "True"}
|
||||
LOD 300
|
||||
|
||||
HLSLINCLUDE
|
||||
// #define FLAT_KIT_DOTS_INSTANCING_ON // Uncomment to enable DOTS instancing
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Version.hlsl"
|
||||
ENDHLSL
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ForwardLit"
|
||||
Tags {"LightMode" = "UniversalForwardOnly"}
|
||||
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma shader_feature_local_fragment __ _CELPRIMARYMODE_SINGLE _CELPRIMARYMODE_STEPS _CELPRIMARYMODE_CURVE
|
||||
#pragma shader_feature_local_fragment DR_CEL_EXTRA_ON
|
||||
#pragma shader_feature_local_fragment DR_GRADIENT_ON
|
||||
#pragma shader_feature_local_fragment __ _GRADIENTSPACE_WORLD _GRADIENTSPACE_LOCAL
|
||||
#pragma shader_feature_local_fragment DR_SPECULAR_ON
|
||||
#pragma shader_feature_local_fragment DR_RIM_ON
|
||||
#pragma shader_feature_local DR_VERTEX_COLORS_ON
|
||||
#pragma shader_feature_local_fragment DR_ENABLE_LIGHTMAP_DIR
|
||||
#pragma shader_feature_local_fragment __ _UNITYSHADOWMODE_MULTIPLY _UNITYSHADOWMODE_COLOR
|
||||
#pragma shader_feature_local_fragment _TEXTUREBLENDINGMODE_MULTIPLY _TEXTUREBLENDINGMODE_ADD
|
||||
#pragma shader_feature_local_fragment _UNITYSHADOW_OCCLUSION
|
||||
#pragma shader_feature_local_fragment _BASEMAP_PREMULTIPLY
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
// #pragma shader_feature_local_fragment _ _SPECGLOSSMAP _SPECULAR_COLOR
|
||||
// #pragma shader_feature_local_fragment _GLOSSINESS_FROM_BASE_ALPHA
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
#pragma shader_feature_local _RECEIVE_SHADOWS_OFF
|
||||
#if UNITY_VERSION >= 600000
|
||||
#pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
|
||||
#endif
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
#if VERSION_GREATER_EQUAL(11, 0)
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
|
||||
#else
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
|
||||
#endif
|
||||
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
||||
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
|
||||
#pragma multi_compile _ SHADOWS_SHADOWMASK
|
||||
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
|
||||
#if VERSION_GREATER_EQUAL(12, 0)
|
||||
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
|
||||
#pragma multi_compile _ _LIGHT_LAYERS
|
||||
#pragma multi_compile_fragment _ _LIGHT_COOKIES
|
||||
#endif
|
||||
#if UNITY_VERSION >= 202220 && UNITY_VERSION < 600000
|
||||
#pragma multi_compile_fragment _ _WRITE_RENDERING_LAYERS
|
||||
#endif
|
||||
#if UNITY_VERSION >= 600000
|
||||
#pragma multi_compile _ _FORWARD_PLUS
|
||||
#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
|
||||
#define _ENVIRONMENTREFLECTIONS_OFF 1 // Fixes flickering when Probe Blending is enabled on Renderer.
|
||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT
|
||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
|
||||
#else
|
||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT
|
||||
#endif
|
||||
#if UNITY_VERSION >= 60000012
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
|
||||
#endif
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile_fog
|
||||
#if UNITY_VERSION >= 202220
|
||||
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
|
||||
#pragma multi_compile_fragment _ DEBUG_DISPLAY
|
||||
#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
|
||||
#endif
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options renderinglayer
|
||||
#if defined(FLAT_KIT_DOTS_INSTANCING_ON)
|
||||
#pragma target 4.5
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
#endif
|
||||
|
||||
// Detail map.
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#pragma shader_feature_local_fragment _DETAILMAPBLENDINGMODE_MULTIPLY _DETAILMAPBLENDINGMODE_ADD _DETAILMAPBLENDINGMODE_INTERPOLATE
|
||||
|
||||
TEXTURE2D(_DetailMap);
|
||||
SAMPLER(sampler_DetailMap);
|
||||
|
||||
#pragma vertex StylizedPassVertex
|
||||
#pragma fragment StylizedPassFragment
|
||||
#if UNITY_VERSION >= 202230
|
||||
#define BUMP_SCALE_NOT_SUPPORTED 1
|
||||
#endif
|
||||
|
||||
// TODO: Toggle _NORMALMAP from the editor script.
|
||||
#define _NORMALMAP
|
||||
|
||||
#include "LibraryUrp/StylizedInput.hlsl"
|
||||
#include "LibraryUrp/LitForwardPass_DR.hlsl"
|
||||
#include "LibraryUrp/Lighting_DR.hlsl"
|
||||
|
||||
/* start CurvedWorld */
|
||||
//#define CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_X_POSITIVE
|
||||
//#define CURVEDWORLD_BEND_ID_1
|
||||
//#pragma shader_feature_local CURVEDWORLD_DISABLED_ON
|
||||
//#pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
//#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"
|
||||
/* end CurvedWorld */
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
// Renderer Feature outline pass.
|
||||
Name "Outline"
|
||||
Tags{"LightMode" = "Outline"}
|
||||
|
||||
Cull Front
|
||||
|
||||
HLSLPROGRAM
|
||||
#include "LibraryUrp/StylizedInput.hlsl"
|
||||
|
||||
#pragma vertex VertexProgram
|
||||
#pragma fragment FragmentProgram
|
||||
|
||||
#pragma multi_compile _ DR_OUTLINE_ON
|
||||
#pragma multi_compile _ DR_OUTLINE_SMOOTH_NORMALS
|
||||
#pragma multi_compile __ _OUTLINESPACE_SCREEN _OUTLINESPACE_OBJECT
|
||||
#pragma multi_compile_fog
|
||||
|
||||
/* start CurvedWorld */
|
||||
//#define CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_X_POSITIVE
|
||||
//#define CURVEDWORLD_BEND_ID_1
|
||||
//#pragma shader_feature_local CURVEDWORLD_DISABLED_ON
|
||||
//#pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
//#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"
|
||||
/* end CurvedWorld */
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
#if defined(DR_OUTLINE_SMOOTH_NORMALS)
|
||||
float4 uv2 : TEXCOORD2;
|
||||
#endif
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float fogCoord : TEXCOORD1;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
float4 ObjectToClipPos(float4 pos)
|
||||
{
|
||||
return mul(UNITY_MATRIX_VP, mul(UNITY_MATRIX_M, float4(pos.xyz, 1)));
|
||||
}
|
||||
|
||||
float4 ObjectToClipDir(float3 dir)
|
||||
{
|
||||
return mul(UNITY_MATRIX_VP, mul(UNITY_MATRIX_M, float4(dir.xyz, 0)));
|
||||
}
|
||||
|
||||
VertexOutput VertexProgram(VertexInput v)
|
||||
{
|
||||
#if defined(CURVEDWORLD_IS_INSTALLED) && !defined(CURVEDWORLD_DISABLED_ON)
|
||||
CURVEDWORLD_TRANSFORM_VERTEX(v.position)
|
||||
#endif
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
#if defined(DR_OUTLINE_ON)
|
||||
#if defined(DR_OUTLINE_SMOOTH_NORMALS)
|
||||
float3 objectScale = abs(UNITY_MATRIX_M[0].xyz) + abs(UNITY_MATRIX_M[1].xyz) + abs(UNITY_MATRIX_M[2].xyz);
|
||||
v.normal = v.uv2.xyz / objectScale;
|
||||
#endif
|
||||
|
||||
#if defined(_OUTLINESPACE_OBJECT)
|
||||
float3 offset = v.normal * _OutlineWidth * 0.01;
|
||||
float4 clipPosition = ObjectToClipPos(v.position * _OutlineScale + float4(offset, 0));
|
||||
#else
|
||||
float4 clipPosition = ObjectToClipPos(v.position * _OutlineScale);
|
||||
const float3 clipNormal = ObjectToClipDir(v.normal).xyz;
|
||||
const float2 aspectRatio = float2(_ScreenParams.x / _ScreenParams.y, 1);
|
||||
const half cameraDistanceImpact = lerp(clipPosition.w, 4.0, _CameraDistanceImpact);
|
||||
const float2 offset = normalize(clipNormal.xy) / aspectRatio * _OutlineWidth * cameraDistanceImpact * 0.005;
|
||||
clipPosition.xy += offset;
|
||||
#endif
|
||||
|
||||
// Depth offset
|
||||
{
|
||||
const half outlineDepthOffset = _OutlineDepthOffset * .1;
|
||||
#if UNITY_REVERSED_Z
|
||||
clipPosition.z -= outlineDepthOffset;
|
||||
#else
|
||||
clipPosition.z += outlineDepthOffset * (1.0 - UNITY_NEAR_CLIP_VALUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
o.position = clipPosition;
|
||||
o.fogCoord = ComputeFogFactor(o.position.z);
|
||||
#endif
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 FragmentProgram(VertexOutput i) : SV_TARGET
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
half4 color = _OutlineColor;
|
||||
color.rgb = MixFog(color.rgb, i.fogCoord);
|
||||
return color;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// All the following passes are from URP SimpleLit.shader.
|
||||
// UsePass "Universal Render Pipeline/Simple Lit/..." - not included in build and produces z-buffer glitches in
|
||||
// local and global outlines combination.
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags{"LightMode" = "ShadowCaster"}
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
ColorMask 0
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _GLOSSINESS_FROM_BASE_ALPHA
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#if defined(FLAT_KIT_DOTS_INSTANCING_ON)
|
||||
#pragma target 4.5
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
#endif
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#if UNITY_VERSION >= 202220
|
||||
#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
|
||||
#endif
|
||||
|
||||
// This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias
|
||||
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
|
||||
#pragma vertex ShadowPassVertex
|
||||
#pragma fragment ShadowPassFragment
|
||||
|
||||
#include "LibraryUrp/StylizedInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
|
||||
|
||||
/* start CurvedWorld */
|
||||
//#define CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_X_POSITIVE
|
||||
//#define CURVEDWORLD_BEND_ID_1
|
||||
//#pragma shader_feature_local CURVEDWORLD_DISABLED_ON
|
||||
//#pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
//#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"
|
||||
/* end CurvedWorld */
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "GBuffer"
|
||||
Tags{"LightMode" = "UniversalGBuffer"}
|
||||
|
||||
ZWrite[_ZWrite]
|
||||
ZTest LEqual
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
// #pragma shader_feature _ALPHAPREMULTIPLY_ON
|
||||
// #pragma shader_feature_local_fragment _ _SPECGLOSSMAP _SPECULAR_COLOR
|
||||
// #pragma shader_feature_local_fragment _GLOSSINESS_FROM_BASE_ALPHA
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
#pragma shader_feature_local _RECEIVE_SHADOWS_OFF
|
||||
#if UNITY_VERSION >= 600000
|
||||
#pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
|
||||
#endif
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
|
||||
//#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
||||
//#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
|
||||
#pragma multi_compile_fragment _ _LIGHT_LAYERS
|
||||
#if UNITY_VERSION >= 600000
|
||||
#define _ENVIRONMENTREFLECTIONS_OFF 1 // Fixes flickering when Probe Blending is enabled on Renderer.
|
||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT
|
||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
|
||||
#else
|
||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT
|
||||
#endif
|
||||
#if UNITY_VERSION >= 60000012
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
|
||||
#endif
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
|
||||
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
|
||||
#pragma multi_compile _ SHADOWS_SHADOWMASK
|
||||
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
|
||||
#if UNITY_VERSION >= 600000
|
||||
#pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
|
||||
#endif
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options renderinglayer
|
||||
#if defined(FLAT_KIT_DOTS_INSTANCING_ON)
|
||||
#pragma target 4.5
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
#endif
|
||||
|
||||
#pragma vertex LitPassVertexSimple
|
||||
#pragma fragment LitPassFragmentSimple
|
||||
|
||||
#define BUMP_SCALE_NOT_SUPPORTED 1
|
||||
|
||||
#include "LibraryUrp/StylizedInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/SimpleLitGBufferPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DepthOnly"
|
||||
Tags{"LightMode" = "DepthOnly"}
|
||||
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex DepthOnlyVertex
|
||||
#pragma fragment DepthOnlyFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _GLOSSINESS_FROM_BASE_ALPHA
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#if UNITY_VERSION >= 202220
|
||||
#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
|
||||
#endif
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#if defined(FLAT_KIT_DOTS_INSTANCING_ON)
|
||||
#pragma target 4.5
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
#endif
|
||||
|
||||
#include "LibraryUrp/StylizedInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
|
||||
|
||||
/* start CurvedWorld */
|
||||
//#define CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_X_POSITIVE
|
||||
//#define CURVEDWORLD_BEND_ID_1
|
||||
//#pragma shader_feature_local CURVEDWORLD_DISABLED_ON
|
||||
//#pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
//#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"
|
||||
/* end CurvedWorld */
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass is used when drawing to a _CameraNormalsTexture texture
|
||||
Pass
|
||||
{
|
||||
Name "DepthNormals"
|
||||
Tags{"LightMode" = "DepthNormals"}
|
||||
|
||||
ZWrite On
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex DepthNormalsVertex
|
||||
#pragma fragment DepthNormalsFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _GLOSSINESS_FROM_BASE_ALPHA
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#if UNITY_VERSION >= 202220
|
||||
#pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
|
||||
// Universal Pipeline keywords
|
||||
#pragma multi_compile_fragment _ _WRITE_RENDERING_LAYERS
|
||||
#endif
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#if defined(FLAT_KIT_DOTS_INSTANCING_ON)
|
||||
#pragma target 4.5
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
#endif
|
||||
|
||||
#include "LibraryUrp/StylizedInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl"
|
||||
|
||||
/* start CurvedWorld */
|
||||
//#define CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_X_POSITIVE
|
||||
//#define CURVEDWORLD_BEND_ID_1
|
||||
//#pragma shader_feature_local CURVEDWORLD_DISABLED_ON
|
||||
//#pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
//#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"
|
||||
/* end CurvedWorld */
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass it not used during regular rendering, only for lightmap baking.
|
||||
Pass
|
||||
{
|
||||
Name "Meta"
|
||||
Tags{ "LightMode" = "Meta" }
|
||||
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex UniversalVertexMeta
|
||||
#pragma fragment UniversalFragmentMetaSimple
|
||||
#if UNITY_VERSION >= 202220
|
||||
#pragma shader_feature EDITOR_VISUALIZATION
|
||||
#endif
|
||||
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
#pragma shader_feature_local_fragment _SPECGLOSSMAP
|
||||
|
||||
#include "LibraryUrp/StylizedInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/SimpleLitMetaPass.hlsl"
|
||||
|
||||
/* start CurvedWorld */
|
||||
//#define CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_X_POSITIVE
|
||||
//#define CURVEDWORLD_BEND_ID_1
|
||||
//#pragma shader_feature_local CURVEDWORLD_DISABLED_ON
|
||||
//#pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
//#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"
|
||||
/* end CurvedWorld */
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "Universal2D"
|
||||
Tags{ "LightMode" = "Universal2D" }
|
||||
Tags{ "RenderType" = "Transparent" "Queue" = "Transparent" }
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
|
||||
#include "LibraryUrp/StylizedInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
|
||||
|
||||
/* start CurvedWorld */
|
||||
//#define CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_X_POSITIVE
|
||||
//#define CURVEDWORLD_BEND_ID_1
|
||||
//#pragma shader_feature_local CURVEDWORLD_DISABLED_ON
|
||||
//#pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
//#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"
|
||||
/* end CurvedWorld */
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
Fallback "Hidden/Universal Render Pipeline/FallbackError"
|
||||
CustomEditor "StylizedSurfaceEditor"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bee44b4a58655ee4cbff107302a3e131
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,406 @@
|
||||
Shader "FlatKit/Stylized Surface With Outline"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[MainColor] _BaseColor ("Color", Color) = (1,1,1,1)
|
||||
|
||||
[Space(10)]
|
||||
[KeywordEnum(None, Single, Steps, Curve)]_CelPrimaryMode("Cel Shading Mode", Float) = 1
|
||||
_ColorDim ("[_CELPRIMARYMODE_SINGLE]Color Shaded", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_ColorDimSteps ("[_CELPRIMARYMODE_STEPS]Color Shaded", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_ColorDimCurve ("[_CELPRIMARYMODE_CURVE]Color Shaded", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_SelfShadingSize ("[_CELPRIMARYMODE_SINGLE]Self Shading Size", Range(0, 1)) = 0.5
|
||||
_ShadowEdgeSize ("[_CELPRIMARYMODE_SINGLE]Shadow Edge Size", Range(0, 0.5)) = 0.05
|
||||
_Flatness ("[_CELPRIMARYMODE_SINGLE]Localized Shading", Range(0, 1)) = 1.0
|
||||
|
||||
[IntRange]_CelNumSteps ("[_CELPRIMARYMODE_STEPS]Number Of Steps", Range(1, 10)) = 3.0
|
||||
_CelStepTexture ("[_CELPRIMARYMODE_STEPS][LAST_PROP_STEPS]Cel steps", 2D) = "black" {}
|
||||
_CelCurveTexture ("[_CELPRIMARYMODE_CURVE][LAST_PROP_CURVE]Ramp", 2D) = "black" {}
|
||||
|
||||
[Space(10)]
|
||||
[Toggle(DR_CEL_EXTRA_ON)] _CelExtraEnabled("Enable Extra Cel Layer", Int) = 0
|
||||
_ColorDimExtra ("[DR_CEL_EXTRA_ON]Color Shaded", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_SelfShadingSizeExtra ("[DR_CEL_EXTRA_ON]Self Shading Size", Range(0, 1)) = 0.6
|
||||
_ShadowEdgeSizeExtra ("[DR_CEL_EXTRA_ON]Shadow Edge Size", Range(0, 0.5)) = 0.05
|
||||
_FlatnessExtra ("[DR_CEL_EXTRA_ON]Localized Shading", Range(0, 1)) = 1.0
|
||||
|
||||
[Space(10)]
|
||||
[Toggle(DR_SPECULAR_ON)] _SpecularEnabled("Enable Specular", Int) = 0
|
||||
[HDR] _FlatSpecularColor("[DR_SPECULAR_ON]Specular Color", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_FlatSpecularSize("[DR_SPECULAR_ON]Specular Size", Range(0.0, 1.0)) = 0.1
|
||||
_FlatSpecularEdgeSmoothness("[DR_SPECULAR_ON]Specular Edge Smoothness", Range(0.0, 1.0)) = 0
|
||||
|
||||
[Space(10)]
|
||||
[Toggle(DR_RIM_ON)] _RimEnabled("Enable Rim", Int) = 0
|
||||
[HDR] _FlatRimColor("[DR_RIM_ON]Rim Color", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_FlatRimLightAlign("[DR_RIM_ON]Light Align", Range(0.0, 1.0)) = 0
|
||||
_FlatRimSize("[DR_RIM_ON]Rim Size", Range(0, 1)) = 0.5
|
||||
_FlatRimEdgeSmoothness("[DR_RIM_ON]Rim Edge Smoothness", Range(0, 1)) = 0.5
|
||||
|
||||
[Space(10)]
|
||||
[Toggle(DR_GRADIENT_ON)] _GradientEnabled("Enable Height Gradient", Int) = 0
|
||||
[HDR] _ColorGradient("[DR_GRADIENT_ON]Gradient Color", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_GradientCenterX("[DR_GRADIENT_ON]Center X", Float) = 0
|
||||
_GradientCenterY("[DR_GRADIENT_ON]Center Y", Float) = 0
|
||||
_GradientSize("[DR_GRADIENT_ON]Size", Float) = 10.0
|
||||
_GradientAngle("[DR_GRADIENT_ON]Gradient Angle", Range(0, 360)) = 0
|
||||
|
||||
[Space(10)]
|
||||
[Toggle(DR_VERTEX_COLORS_ON)] _VertexColorsEnabled("Enable Vertex Colors", Int) = 0
|
||||
|
||||
_LightContribution("[FOLDOUT(Advanced Lighting){5}]Light Color Contribution", Range(0, 1)) = 0
|
||||
_LightFalloffSize("Light edge width (point / spot)", Range(0, 1)) = 0
|
||||
|
||||
// Used to provide light direction to cel shading if all light in the scene is baked.
|
||||
[Space(5)]
|
||||
[Toggle(DR_ENABLE_LIGHTMAP_DIR)]_OverrideLightmapDir("Override light direction", Int) = 0
|
||||
_LightmapDirectionPitch("[DR_ENABLE_LIGHTMAP_DIR]Pitch", Range(0, 360)) = 0
|
||||
_LightmapDirectionYaw("[DR_ENABLE_LIGHTMAP_DIR]Yaw", Range(0, 360)) = 0
|
||||
[HideInInspector] _LightmapDirection("Direction", Vector) = (0, 1, 0, 0)
|
||||
|
||||
[KeywordEnum(None, Multiply, Color)] _UnityShadowMode ("[FOLDOUT(Unity Built-in Shadows){4}]Mode", Float) = 0
|
||||
_UnityShadowPower("[_UNITYSHADOWMODE_MULTIPLY]Power", Range(0, 1)) = 0.2
|
||||
_UnityShadowColor("[_UNITYSHADOWMODE_COLOR]Color", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_UnityShadowSharpness("Sharpness", Range(1, 10)) = 1.0
|
||||
|
||||
[MainTexture] _BaseMap("[FOLDOUT(Texture maps){6}]Albedo", 2D) = "white" {}
|
||||
[Space][KeywordEnum(Multiply, Add)]_TextureBlendingMode("[_]Blending Mode", Float) = 0
|
||||
[Space]_TextureImpact("[_]Texture Impact", Range(0, 1)) = 1.0
|
||||
[Space(20)]_BumpMap ("Normal Map", 2D) = "bump" {}
|
||||
_EmissionMap ("Emission Map", 2D) = "black" {}
|
||||
[HDR]_EmissionColor("Emission Color", Color) = (1, 1, 1, 1)
|
||||
|
||||
[HideInInspector] _Cutoff ("Base Alpha cutoff", Range (0, 1)) = .5
|
||||
|
||||
// Blending state
|
||||
[HideInInspector] _Surface("__surface", Float) = 0.0
|
||||
[HideInInspector] _Blend("__blend", Float) = 0.0
|
||||
[HideInInspector] _AlphaClip("__clip", Float) = 0.0
|
||||
[HideInInspector] _SrcBlend("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend("__dst", Float) = 0.0
|
||||
[HideInInspector] _ZWrite("__zw", Float) = 1.0
|
||||
[HideInInspector] _Cull("__cull", Float) = 2.0
|
||||
|
||||
// Editmode props
|
||||
[HideInInspector] _QueueOffset("Queue offset", Float) = 0.0
|
||||
|
||||
// --------------------- OUTLINE PROPS -----------------------
|
||||
_OutlineColor("[FOLDOUT(Outline){5}]Color", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_OutlineWidth("Width", Float) = 0.01
|
||||
_OutlineScale("Scale", Float) = 1.0
|
||||
_OutlineDepthOffset("Depth Offset", Range(0, 1)) = 0.0
|
||||
_CameraDistanceImpact("Camera Distance Impact", Range(0, 1)) = 0.0
|
||||
|
||||
/* start CurvedWorld */
|
||||
//[CurvedWorldBendSettings] _CurvedWorldBendSettings("0|1|1", Vector) = (0, 0, 0, 0)
|
||||
/* end CurvedWorld */
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "IgnoreProjector" = "True"
|
||||
}
|
||||
LOD 300
|
||||
|
||||
UsePass "FlatKit/Stylized Surface/ForwardLit"
|
||||
Pass
|
||||
{
|
||||
Cull Front
|
||||
|
||||
CGPROGRAM
|
||||
#include "UnityInstancing.cginc"
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
/* start CurvedWorld */
|
||||
//#define CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_X_POSITIVE
|
||||
//#define CURVEDWORLD_BEND_ID_1
|
||||
//#pragma shader_feature_local CURVEDWORLD_DISABLED_ON
|
||||
//#pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
//#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"
|
||||
/* end CurvedWorld */
|
||||
|
||||
#pragma vertex VertexProgram
|
||||
#pragma fragment FragmentProgram
|
||||
|
||||
#pragma multi_compile_fog
|
||||
|
||||
UNITY_INSTANCING_BUFFER_START(OutlineProps)
|
||||
UNITY_DEFINE_INSTANCED_PROP(half4, _OutlineColor)
|
||||
UNITY_DEFINE_INSTANCED_PROP(half, _OutlineWidth)
|
||||
UNITY_DEFINE_INSTANCED_PROP(half, _OutlineScale)
|
||||
UNITY_DEFINE_INSTANCED_PROP(half, _OutlineDepthOffset)
|
||||
UNITY_DEFINE_INSTANCED_PROP(half, _CameraDistanceImpact)
|
||||
UNITY_INSTANCING_BUFFER_END(OutlineProps)
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
|
||||
/* start CurvedWorld */
|
||||
#if defined(CURVEDWORLD_IS_INSTALLED) && !defined(CURVEDWORLD_DISABLED_ON)
|
||||
#ifdef CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
float4 tangent : TANGENT;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float3 normal : NORMAL;
|
||||
|
||||
UNITY_FOG_COORDS(0)
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
VertexOutput VertexProgram(VertexInput v)
|
||||
{
|
||||
VertexOutput o;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
|
||||
/* start CurvedWorld */
|
||||
#if defined(CURVEDWORLD_IS_INSTALLED) && !defined(CURVEDWORLD_DISABLED_ON)
|
||||
#ifdef CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
CURVEDWORLD_TRANSFORM_VERTEX_AND_NORMAL(v.position, v.normal, v.tangent)
|
||||
#else
|
||||
CURVEDWORLD_TRANSFORM_VERTEX(v.position)
|
||||
#endif
|
||||
#endif
|
||||
/* end CurvedWorld */
|
||||
|
||||
UNITY_INITIALIZE_OUTPUT(VertexOutput, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
float4 clipPosition = UnityObjectToClipPos(v.position * _OutlineScale);
|
||||
const float3 clipNormal = mul((float3x3)UNITY_MATRIX_VP, mul((float3x3)UNITY_MATRIX_M, v.normal));
|
||||
const half outlineWidth = UNITY_ACCESS_INSTANCED_PROP(OutlineProps, _OutlineWidth);
|
||||
const half cameraDistanceImpact = lerp(clipPosition.w, 4.0, _CameraDistanceImpact);
|
||||
const float2 offset = normalize(clipNormal.xy) / _ScreenParams.xy * outlineWidth * cameraDistanceImpact
|
||||
* 2.0;
|
||||
clipPosition.xy += offset;
|
||||
const half outlineDepthOffset = UNITY_ACCESS_INSTANCED_PROP(OutlineProps, _OutlineDepthOffset);
|
||||
clipPosition.z -= outlineDepthOffset;
|
||||
o.position = clipPosition;
|
||||
o.normal = clipNormal;
|
||||
|
||||
UNITY_TRANSFER_FOG(o, o.position);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 FragmentProgram(VertexOutput i) : SV_TARGET
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
half4 color = UNITY_ACCESS_INSTANCED_PROP(OutlineProps, _OutlineColor);
|
||||
UNITY_APPLY_FOG(i.fogCoord, color);
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// All the following passes are from URP SimpleLit.shader.
|
||||
// UsePass "Universal Render Pipeline/Simple Lit/..." - produces z-buffer glitches in local and global outlines combination.
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "ShadowCaster"
|
||||
}
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
ColorMask 0
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _GLOSSINESS_FROM_BASE_ALPHA
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#pragma vertex ShadowPassVertex
|
||||
#pragma fragment ShadowPassFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/SimpleLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "GBuffer"
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "UniversalGBuffer"
|
||||
}
|
||||
|
||||
ZWrite[_ZWrite]
|
||||
ZTest LEqual
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
//#pragma shader_feature _ALPHAPREMULTIPLY_ON
|
||||
#pragma shader_feature_local_fragment _ _SPECGLOSSMAP _SPECULAR_COLOR
|
||||
#pragma shader_feature_local_fragment _GLOSSINESS_FROM_BASE_ALPHA
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
#pragma shader_feature_local _RECEIVE_SHADOWS_OFF
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
|
||||
//#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
||||
//#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ _SHADOWS_SOFT
|
||||
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#pragma vertex LitPassVertexSimple
|
||||
#pragma fragment LitPassFragmentSimple
|
||||
#define BUMP_SCALE_NOT_SUPPORTED 1
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/SimpleLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/SimpleLitGBufferPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DepthOnly"
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "DepthOnly"
|
||||
}
|
||||
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex DepthOnlyVertex
|
||||
#pragma fragment DepthOnlyFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _GLOSSINESS_FROM_BASE_ALPHA
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/SimpleLitInput.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 vertex DepthNormalsVertex
|
||||
#pragma fragment DepthNormalsFragment
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _GLOSSINESS_FROM_BASE_ALPHA
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/SimpleLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass it not used during regular rendering, only for lightmap baking.
|
||||
Pass
|
||||
{
|
||||
Name "Meta"
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "Meta"
|
||||
}
|
||||
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex UniversalVertexMeta
|
||||
#pragma fragment UniversalFragmentMetaSimple
|
||||
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
#pragma shader_feature_local_fragment _SPECGLOSSMAP
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/SimpleLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/SimpleLitMetaPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "Universal2D"
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "Universal2D"
|
||||
}
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Transparent" "Queue" = "Transparent"
|
||||
}
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/SimpleLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
Fallback "Hidden/Universal Render Pipeline/FallbackError"
|
||||
CustomEditor "StylizedSurfaceEditor"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7e38193b7f064d7380403618fd8b69e
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
397
Assets/FlatKit/Shaders/StylizedSurface/Terrain.shader
Normal file
397
Assets/FlatKit/Shaders/StylizedSurface/Terrain.shader
Normal file
@@ -0,0 +1,397 @@
|
||||
Shader "FlatKit/Terrain"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Space(10)]
|
||||
[KeywordEnum(None, Single, Steps, Curve)]_CelPrimaryMode("Cel Shading Mode", Float) = 1
|
||||
_ColorDim ("[_CELPRIMARYMODE_SINGLE]Color Shaded", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_ColorDimSteps ("[_CELPRIMARYMODE_STEPS]Color Shaded", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_ColorDimCurve ("[_CELPRIMARYMODE_CURVE]Color Shaded", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_SelfShadingSize ("[_CELPRIMARYMODE_SINGLE]Self Shading Size", Range(0, 1)) = 0.5
|
||||
_ShadowEdgeSize ("[_CELPRIMARYMODE_SINGLE]Shadow Edge Size", Range(0, 0.5)) = 0.05
|
||||
_Flatness ("[_CELPRIMARYMODE_SINGLE]Localized Shading", Range(0, 1)) = 1.0
|
||||
|
||||
[IntRange]_CelNumSteps ("[_CELPRIMARYMODE_STEPS]Number Of Steps", Range(1, 10)) = 3.0
|
||||
_CelStepTexture ("[_CELPRIMARYMODE_STEPS][LAST_PROP_STEPS]Cel steps", 2D) = "black" {}
|
||||
_CelCurveTexture ("[_CELPRIMARYMODE_CURVE][LAST_PROP_CURVE]Ramp", 2D) = "black" {}
|
||||
|
||||
[Space(10)]
|
||||
[Toggle(DR_CEL_EXTRA_ON)] _CelExtraEnabled("Enable Extra Cel Layer", Int) = 0
|
||||
_ColorDimExtra ("[DR_CEL_EXTRA_ON]Color Shaded", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_SelfShadingSizeExtra ("[DR_CEL_EXTRA_ON]Self Shading Size", Range(0, 1)) = 0.6
|
||||
_ShadowEdgeSizeExtra ("[DR_CEL_EXTRA_ON]Shadow Edge Size", Range(0, 0.5)) = 0.05
|
||||
_FlatnessExtra ("[DR_CEL_EXTRA_ON]Localized Shading", Range(0, 1)) = 1.0
|
||||
|
||||
[Space(10)]
|
||||
[Toggle(DR_SPECULAR_ON)] _SpecularEnabled("Enable Specular", Int) = 0
|
||||
[HDR] _FlatSpecularColor("[DR_SPECULAR_ON]Specular Color", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_FlatSpecularSize("[DR_SPECULAR_ON]Specular Size", Range(0.0, 1.0)) = 0.1
|
||||
_FlatSpecularEdgeSmoothness("[DR_SPECULAR_ON]Specular Edge Smoothness", Range(0.0, 1.0)) = 0
|
||||
|
||||
[Space(10)]
|
||||
[Toggle(DR_RIM_ON)] _RimEnabled("Enable Rim", Int) = 0
|
||||
[HDR] _FlatRimColor("[DR_RIM_ON]Rim Color", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_FlatRimLightAlign("[DR_RIM_ON]Light Align", Range(0.0, 1.0)) = 0
|
||||
_FlatRimSize("[DR_RIM_ON]Rim Size", Range(0, 1)) = 0.5
|
||||
_FlatRimEdgeSmoothness("[DR_RIM_ON]Rim Edge Smoothness", Range(0, 1)) = 0.5
|
||||
|
||||
[Space(10)]
|
||||
[Toggle(DR_GRADIENT_ON)] _GradientEnabled("Enable Height Gradient", Int) = 0
|
||||
[HDR] _ColorGradient("[DR_GRADIENT_ON]Gradient Color", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_GradientCenterX("[DR_GRADIENT_ON]Center X", Float) = 0
|
||||
_GradientCenterY("[DR_GRADIENT_ON]Center Y", Float) = 0
|
||||
_GradientSize("[DR_GRADIENT_ON]Size", Float) = 10.0
|
||||
_GradientAngle("[DR_GRADIENT_ON]Gradient Angle", Range(0, 360)) = 0
|
||||
|
||||
_LightContribution("[FOLDOUT(Advanced Lighting){5}]Light Color Contribution", Range(0, 1)) = 0
|
||||
_LightFalloffSize("Light edge width (point / spot)", Range(0, 1)) = 0
|
||||
|
||||
[Space(5)]
|
||||
// Used to provide light direction to cel shading if all light in the scene is baked.
|
||||
[Toggle(DR_ENABLE_LIGHTMAP_DIR)]_OverrideLightmapDir("Override Light Direction", Int) = 0
|
||||
_LightmapDirectionPitch("[DR_ENABLE_LIGHTMAP_DIR]Pitch", Range(0, 360)) = 0
|
||||
_LightmapDirectionYaw("[DR_ENABLE_LIGHTMAP_DIR]Yaw", Range(0, 360)) = 0
|
||||
[HideInInspector] _LightmapDirection("Direction", Vector) = (0, 1, 0, 0)
|
||||
|
||||
[KeywordEnum(None, Multiply, Color)] _UnityShadowMode ("[FOLDOUT(Unity Built-in Shadows){4}]Mode", Float) = 0
|
||||
_UnityShadowPower("[_UNITYSHADOWMODE_MULTIPLY]Power", Range(0, 1)) = 0.2
|
||||
_UnityShadowColor("[_UNITYSHADOWMODE_COLOR]Color", Color) = (0.85023, 0.85034, 0.85045, 0.85056)
|
||||
_UnityShadowSharpness("Sharpness", Range(1, 10)) = 1.0
|
||||
|
||||
// Editmode props
|
||||
[HideInInspector] _QueueOffset("Queue offset", Float) = 0.0
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
// --------------------------------
|
||||
// --- From `TerrainLit.shader` ---
|
||||
// --------------------------------
|
||||
[HideInInspector] [ToggleUI] _EnableHeightBlend("EnableHeightBlend", Float) = 0.0
|
||||
[HideInInspector] _HeightTransition("Height Transition", Range(0, 1.0)) = 0.0
|
||||
// Layer count is passed down to guide height-blend enable/disable, due
|
||||
// to the fact that heigh-based blend will be broken with multipass.
|
||||
[HideInInspector] [PerRendererData] _NumLayersCount ("Total Layer Count", Float) = 1.0
|
||||
|
||||
// set by terrain engine
|
||||
[HideInInspector] _Control("Control (RGBA)", 2D) = "red" {}
|
||||
[HideInInspector] _Splat3("Layer 3 (A)", 2D) = "grey" {}
|
||||
[HideInInspector] _Splat2("Layer 2 (B)", 2D) = "grey" {}
|
||||
[HideInInspector] _Splat1("Layer 1 (G)", 2D) = "grey" {}
|
||||
[HideInInspector] _Splat0("Layer 0 (R)", 2D) = "grey" {}
|
||||
[HideInInspector] _Normal3("Normal 3 (A)", 2D) = "bump" {}
|
||||
[HideInInspector] _Normal2("Normal 2 (B)", 2D) = "bump" {}
|
||||
[HideInInspector] _Normal1("Normal 1 (G)", 2D) = "bump" {}
|
||||
[HideInInspector] _Normal0("Normal 0 (R)", 2D) = "bump" {}
|
||||
[HideInInspector] _Mask3("Mask 3 (A)", 2D) = "grey" {}
|
||||
[HideInInspector] _Mask2("Mask 2 (B)", 2D) = "grey" {}
|
||||
[HideInInspector] _Mask1("Mask 1 (G)", 2D) = "grey" {}
|
||||
[HideInInspector] _Mask0("Mask 0 (R)", 2D) = "grey" {}
|
||||
[HideInInspector][Gamma] _Metallic0("Metallic 0", Range(0.0, 1.0)) = 0.0
|
||||
[HideInInspector][Gamma] _Metallic1("Metallic 1", Range(0.0, 1.0)) = 0.0
|
||||
[HideInInspector][Gamma] _Metallic2("Metallic 2", Range(0.0, 1.0)) = 0.0
|
||||
[HideInInspector][Gamma] _Metallic3("Metallic 3", Range(0.0, 1.0)) = 0.0
|
||||
[HideInInspector] _Smoothness0("Smoothness 0", Range(0.0, 1.0)) = 0.5
|
||||
[HideInInspector] _Smoothness1("Smoothness 1", Range(0.0, 1.0)) = 0.5
|
||||
[HideInInspector] _Smoothness2("Smoothness 2", Range(0.0, 1.0)) = 0.5
|
||||
[HideInInspector] _Smoothness3("Smoothness 3", Range(0.0, 1.0)) = 0.5
|
||||
|
||||
// used in fallback on old cards & base map
|
||||
[HideInInspector] _MainTex("BaseMap (RGB)", 2D) = "grey" {}
|
||||
[HideInInspector] _BaseColor("Main Color", Color) = (1,1,1,1)
|
||||
|
||||
[HideInInspector] _TerrainHolesTexture("Holes Map (RGB)", 2D) = "white" {}
|
||||
|
||||
[HideInInspector] [ToggleUI] _EnableInstancedPerPixelNormal("Enable Instanced per-pixel normal", Float) = 1.0
|
||||
|
||||
/* start CurvedWorld */
|
||||
//[CurvedWorldBendSettings] _CurvedWorldBendSettings("0|1|1", Vector) = (0, 0, 0, 0)
|
||||
/* end CurvedWorld */
|
||||
}
|
||||
|
||||
HLSLINCLUDE
|
||||
|
||||
#pragma multi_compile_fragment __ _ALPHATEST_ON
|
||||
|
||||
ENDHLSL
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Geometry-100" "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" "IgnoreProjector" = "False" "TerrainCompatible" = "True"}
|
||||
|
||||
HLSLINCLUDE
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Version.hlsl"
|
||||
ENDHLSL
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ForwardLit"
|
||||
Tags { "LightMode" = "UniversalForwardOnly" }
|
||||
HLSLPROGRAM
|
||||
#pragma target 3.0
|
||||
|
||||
#pragma vertex SplatmapVert
|
||||
#pragma fragment SplatmapFragment_DSTRM
|
||||
|
||||
#define _METALLICSPECGLOSSMAP 1
|
||||
#define _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 1
|
||||
|
||||
// -------------------------------------
|
||||
// Flat Kit
|
||||
#pragma shader_feature_local_fragment __ _CELPRIMARYMODE_SINGLE _CELPRIMARYMODE_STEPS _CELPRIMARYMODE_CURVE
|
||||
#pragma shader_feature_local_fragment DR_CEL_EXTRA_ON
|
||||
#pragma shader_feature_local_fragment DR_GRADIENT_ON
|
||||
#pragma shader_feature_local_fragment DR_SPECULAR_ON
|
||||
#pragma shader_feature_local_fragment DR_RIM_ON
|
||||
#pragma shader_feature_local_fragment DR_ENABLE_LIGHTMAP_DIR
|
||||
#pragma shader_feature_local __ _UNITYSHADOWMODE_MULTIPLY _UNITYSHADOWMODE_COLOR
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
#if VERSION_GREATER_EQUAL(11, 0)
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
|
||||
#else
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
|
||||
#endif
|
||||
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
||||
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
|
||||
#pragma multi_compile _ SHADOWS_SHADOWMASK
|
||||
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT
|
||||
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
|
||||
#if VERSION_GREATER_EQUAL(12, 0)
|
||||
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
|
||||
#pragma multi_compile_fragment _ _LIGHT_LAYERS
|
||||
#pragma multi_compile_fragment _ _LIGHT_COOKIES
|
||||
#endif
|
||||
#if UNITY_VERSION >= 202220
|
||||
#pragma multi_compile _ _FORWARD_PLUS
|
||||
#pragma multi_compile_fragment _ _WRITE_RENDERING_LAYERS
|
||||
#endif
|
||||
#if UNITY_VERSION >= 60000000
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
|
||||
#endif
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile_instancing
|
||||
#if UNITY_VERSION >= 202230
|
||||
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
|
||||
#pragma multi_compile_fragment _ DEBUG_DISPLAY
|
||||
#endif
|
||||
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
|
||||
|
||||
#pragma shader_feature_local_fragment _TERRAIN_BLEND_HEIGHT
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _MASKMAP
|
||||
// Sample normal in pixel shader when doing instancing
|
||||
#pragma shader_feature_local _TERRAIN_INSTANCED_PERPIXEL_NORMAL
|
||||
|
||||
// Detail map.
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#pragma shader_feature_local_fragment _DETAILMAPBLENDINGMODE_MULTIPLY _DETAILMAPBLENDINGMODE_ADD _DETAILMAPBLENDINGMODE_INTERPOLATE
|
||||
|
||||
TEXTURE2D(_DetailMap);
|
||||
SAMPLER(sampler_DetailMap);
|
||||
|
||||
#define FLATKIT_TERRAIN 1
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl"
|
||||
#include "LibraryUrp/StylizedInput.hlsl"
|
||||
#include "LibraryUrp/Lighting_DR.hlsl"
|
||||
#include "LibraryUrp/TerrainLitPasses_DR.hlsl"
|
||||
|
||||
/* start CurvedWorld */
|
||||
//#define CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_X_POSITIVE
|
||||
//#define CURVEDWORLD_BEND_ID_1
|
||||
//#pragma shader_feature_local CURVEDWORLD_DISABLED_ON
|
||||
//#pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
//#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"
|
||||
/* end CurvedWorld */
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// Passes from `TerrainLit.shader`.
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags{"LightMode" = "ShadowCaster"}
|
||||
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex ShadowPassVertex
|
||||
#pragma fragment ShadowPassFragment
|
||||
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
|
||||
// This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias
|
||||
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl"
|
||||
|
||||
/* start CurvedWorld */
|
||||
//#define CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_X_POSITIVE
|
||||
//#define CURVEDWORLD_BEND_ID_1
|
||||
//#pragma shader_feature_local CURVEDWORLD_DISABLED_ON
|
||||
//#pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
//#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"
|
||||
/* end CurvedWorld */
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DepthOnly"
|
||||
Tags{"LightMode" = "DepthOnly"}
|
||||
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex DepthOnlyVertex
|
||||
#pragma fragment DepthOnlyFragment
|
||||
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl"
|
||||
|
||||
/* start CurvedWorld */
|
||||
//#define CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_X_POSITIVE
|
||||
//#define CURVEDWORLD_BEND_ID_1
|
||||
//#pragma shader_feature_local CURVEDWORLD_DISABLED_ON
|
||||
//#pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
//#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"
|
||||
/* end CurvedWorld */
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass is used when drawing to a _CameraNormalsTexture texture
|
||||
Pass
|
||||
{
|
||||
Name "DepthNormals"
|
||||
Tags{"LightMode" = "DepthNormals"}
|
||||
|
||||
ZWrite On
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma target 2.0
|
||||
#pragma vertex DepthNormalOnlyVertex
|
||||
#pragma fragment DepthNormalOnlyFragment
|
||||
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#if UNITY_VERSION >= 60000000
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
|
||||
#endif
|
||||
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl"
|
||||
#if VERSION_GREATER_EQUAL(12, 0)
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitDepthNormalsPass.hlsl"
|
||||
#else
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl"
|
||||
#endif
|
||||
|
||||
/* start CurvedWorld */
|
||||
//#define CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_X_POSITIVE
|
||||
//#define CURVEDWORLD_BEND_ID_1
|
||||
//#pragma shader_feature_local CURVEDWORLD_DISABLED_ON
|
||||
//#pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
//#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"
|
||||
/* end CurvedWorld */
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "SceneSelectionPass"
|
||||
Tags { "LightMode" = "SceneSelectionPass" }
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex DepthOnlyVertex
|
||||
#pragma fragment DepthOnlyFragment
|
||||
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
|
||||
|
||||
#define SCENESELECTIONPASS
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl"
|
||||
|
||||
/* start CurvedWorld */
|
||||
//#define CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_X_POSITIVE
|
||||
//#define CURVEDWORLD_BEND_ID_1
|
||||
//#pragma shader_feature_local CURVEDWORLD_DISABLED_ON
|
||||
//#pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
//#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"
|
||||
/* end CurvedWorld */
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// This pass it not used during regular rendering, only for lightmap baking.
|
||||
Pass
|
||||
{
|
||||
Name "Meta"
|
||||
Tags{"LightMode" = "Meta"}
|
||||
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex TerrainVertexMeta
|
||||
#pragma fragment TerrainFragmentMeta
|
||||
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
|
||||
#pragma shader_feature EDITOR_VISUALIZATION
|
||||
#define _METALLICSPECGLOSSMAP 1
|
||||
#define _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A 1
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitMetaPass.hlsl"
|
||||
|
||||
/* start CurvedWorld */
|
||||
//#define CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_X_POSITIVE
|
||||
//#define CURVEDWORLD_BEND_ID_1
|
||||
//#pragma shader_feature_local CURVEDWORLD_DISABLED_ON
|
||||
//#pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
//#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"
|
||||
/* end CurvedWorld */
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
|
||||
}
|
||||
Dependency "AddPassShader" = "Hidden/Flat Kit/Terrain/Lit (Add Pass)"
|
||||
Dependency "BaseMapShader" = "Hidden/Universal Render Pipeline/Terrain/Lit (Base Pass)"
|
||||
Dependency "BaseMapGenShader" = "Hidden/Universal Render Pipeline/Terrain/Lit (Basemap Gen)"
|
||||
|
||||
Fallback "Hidden/Universal Render Pipeline/FallbackError"
|
||||
CustomEditor "FlatKit.TerrainEditor"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fea9ee138d4a84d90a0c3f187fb3cd8a
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
148
Assets/FlatKit/Shaders/StylizedSurface/TerrainLitAdd_DR.shader
Normal file
148
Assets/FlatKit/Shaders/StylizedSurface/TerrainLitAdd_DR.shader
Normal file
@@ -0,0 +1,148 @@
|
||||
Shader "Hidden/Flat Kit/Terrain/Lit (Add Pass)"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
// Layer count is passed down to guide height-blend enable/disable, due
|
||||
// to the fact that heigh-based blend will be broken with multipass.
|
||||
[HideInInspector] [PerRendererData] _NumLayersCount ("Total Layer Count", Float) = 1.0
|
||||
|
||||
// set by terrain engine
|
||||
[HideInInspector] _Control("Control (RGBA)", 2D) = "red" {}
|
||||
[HideInInspector] _Splat3("Layer 3 (A)", 2D) = "white" {}
|
||||
[HideInInspector] _Splat2("Layer 2 (B)", 2D) = "white" {}
|
||||
[HideInInspector] _Splat1("Layer 1 (G)", 2D) = "white" {}
|
||||
[HideInInspector] _Splat0("Layer 0 (R)", 2D) = "white" {}
|
||||
[HideInInspector] _Normal3("Normal 3 (A)", 2D) = "bump" {}
|
||||
[HideInInspector] _Normal2("Normal 2 (B)", 2D) = "bump" {}
|
||||
[HideInInspector] _Normal1("Normal 1 (G)", 2D) = "bump" {}
|
||||
[HideInInspector] _Normal0("Normal 0 (R)", 2D) = "bump" {}
|
||||
[HideInInspector][Gamma] _Metallic0("Metallic 0", Range(0.0, 1.0)) = 0.0
|
||||
[HideInInspector][Gamma] _Metallic1("Metallic 1", Range(0.0, 1.0)) = 0.0
|
||||
[HideInInspector][Gamma] _Metallic2("Metallic 2", Range(0.0, 1.0)) = 0.0
|
||||
[HideInInspector][Gamma] _Metallic3("Metallic 3", Range(0.0, 1.0)) = 0.0
|
||||
[HideInInspector] _Mask3("Mask 3 (A)", 2D) = "grey" {}
|
||||
[HideInInspector] _Mask2("Mask 2 (B)", 2D) = "grey" {}
|
||||
[HideInInspector] _Mask1("Mask 1 (G)", 2D) = "grey" {}
|
||||
[HideInInspector] _Mask0("Mask 0 (R)", 2D) = "grey" {}
|
||||
[HideInInspector] _Smoothness0("Smoothness 0", Range(0.0, 1.0)) = 1.0
|
||||
[HideInInspector] _Smoothness1("Smoothness 1", Range(0.0, 1.0)) = 1.0
|
||||
[HideInInspector] _Smoothness2("Smoothness 2", Range(0.0, 1.0)) = 1.0
|
||||
[HideInInspector] _Smoothness3("Smoothness 3", Range(0.0, 1.0)) = 1.0
|
||||
|
||||
// used in fallback on old cards & base map
|
||||
[HideInInspector] _BaseMap("BaseMap (RGB)", 2D) = "white" {}
|
||||
[HideInInspector] _BaseColor("Main Color", Color) = (1,1,1,1)
|
||||
|
||||
[HideInInspector] _TerrainHolesTexture("Holes Map (RGB)", 2D) = "white" {}
|
||||
|
||||
/* start CurvedWorld */
|
||||
//[CurvedWorldBendSettings] _CurvedWorldBendSettings("0|1|1", Vector) = (0, 0, 0, 0)
|
||||
/* end CurvedWorld */
|
||||
}
|
||||
|
||||
HLSLINCLUDE
|
||||
|
||||
#pragma multi_compile_fragment __ _ALPHATEST_ON
|
||||
|
||||
ENDHLSL
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Geometry-99" "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" "IgnoreProjector" = "True"}
|
||||
|
||||
HLSLINCLUDE
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Version.hlsl"
|
||||
ENDHLSL
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "TerrainAddLit"
|
||||
Tags { "LightMode" = "UniversalForwardOnly" }
|
||||
Blend One One
|
||||
HLSLPROGRAM
|
||||
#pragma target 3.0
|
||||
|
||||
#pragma vertex SplatmapVert
|
||||
#pragma fragment SplatmapFragment_DSTRM
|
||||
|
||||
// -------------------------------------
|
||||
// Flat Kit
|
||||
#pragma shader_feature_local __ _CELPRIMARYMODE_SINGLE _CELPRIMARYMODE_STEPS _CELPRIMARYMODE_CURVE
|
||||
#pragma shader_feature_local DR_CEL_EXTRA_ON
|
||||
#pragma shader_feature_local DR_GRADIENT_ON
|
||||
#pragma shader_feature_local DR_SPECULAR_ON
|
||||
#pragma shader_feature_local DR_RIM_ON
|
||||
#pragma shader_feature_local __ _UNITYSHADOWMODE_MULTIPLY _UNITYSHADOWMODE_COLOR
|
||||
|
||||
// -------------------------------------
|
||||
// Universal Pipeline keywords
|
||||
#if UNITY_VERSION >= 202130
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
|
||||
#else
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
|
||||
#endif
|
||||
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
||||
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
|
||||
#pragma multi_compile _ SHADOWS_SHADOWMASK
|
||||
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT
|
||||
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
|
||||
#if UNITY_VERSION >= 202130
|
||||
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
|
||||
#pragma multi_compile_fragment _ _LIGHT_LAYERS
|
||||
#pragma multi_compile_fragment _ _LIGHT_COOKIES
|
||||
#endif
|
||||
#if UNITY_VERSION >= 202220
|
||||
#pragma multi_compile _ _FORWARD_PLUS
|
||||
#pragma multi_compile_fragment _ _WRITE_RENDERING_LAYERS
|
||||
#endif
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile_instancing
|
||||
#if UNITY_VERSION >= 202230
|
||||
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
|
||||
#pragma multi_compile_fragment _ DEBUG_DISPLAY
|
||||
#endif
|
||||
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap
|
||||
|
||||
#pragma shader_feature_local_fragment _TERRAIN_BLEND_HEIGHT
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _MASKMAP
|
||||
// Sample normal in pixel shader when doing instancing
|
||||
#pragma shader_feature_local _TERRAIN_INSTANCED_PERPIXEL_NORMAL
|
||||
#define TERRAIN_SPLAT_ADDPASS
|
||||
|
||||
#define FLATKIT_TERRAIN 1
|
||||
|
||||
// Detail map.
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#pragma shader_feature_local_fragment _DETAILMAPBLENDINGMODE_MULTIPLY _DETAILMAPBLENDINGMODE_ADD _DETAILMAPBLENDINGMODE_INTERPOLATE
|
||||
|
||||
TEXTURE2D(_DetailMap);
|
||||
SAMPLER(sampler_DetailMap);
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl"
|
||||
#include "LibraryUrp/StylizedInput.hlsl"
|
||||
#include "LibraryUrp/Lighting_DR.hlsl"
|
||||
#include "LibraryUrp/TerrainLitPasses_DR.hlsl"
|
||||
|
||||
/* start CurvedWorld */
|
||||
//#define CURVEDWORLD_BEND_TYPE_CLASSICRUNNER_X_POSITIVE
|
||||
//#define CURVEDWORLD_BEND_ID_1
|
||||
//#pragma shader_feature_local CURVEDWORLD_DISABLED_ON
|
||||
//#pragma shader_feature_local CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
||||
//#include "Assets/Amazing Assets/Curved World/Shaders/Core/CurvedWorldTransform.cginc"
|
||||
/* end CurvedWorld */
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
Fallback "Hidden/Universal Render Pipeline/FallbackError"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1dadb9806728143bfafa4261c249e63b
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user