add submodule with package
This commit is contained in:
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "Assets/ru.chikalin.textdecal"]
|
||||||
|
path = Assets/ru.chikalin.textdecal
|
||||||
|
url = gituser@git.chikalin.ru:unity/ru.chikalin.textdecal.git
|
||||||
@@ -8,7 +8,7 @@ Material:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name: LiberationSans SDF Material
|
m_Name: LiberationSans SDF Material
|
||||||
m_Shader: {fileID: 4800000, guid: c47dfb763ac2d4f838ac57291e49f2d8, type: 3}
|
m_Shader: {fileID: 4800000, guid: 970b94dd738345c3ab1ac4418c017ad4, type: 3}
|
||||||
m_Parent: {fileID: 0}
|
m_Parent: {fileID: 0}
|
||||||
m_ModifiedSerializedProperties: 0
|
m_ModifiedSerializedProperties: 0
|
||||||
m_ValidKeywords: []
|
m_ValidKeywords: []
|
||||||
@@ -27,14 +27,21 @@ Material:
|
|||||||
m_Texture: {fileID: 28684132378477856}
|
m_Texture: {fileID: 28684132378477856}
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MaskTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
m_Ints: []
|
m_Ints: []
|
||||||
m_Floats:
|
m_Floats:
|
||||||
- _ColorMask: 15
|
- _ColorMask: 15
|
||||||
- _CullMode: 0
|
- _CullMode: 0
|
||||||
- _FaceDilate: 0
|
- _FaceDilate: 0
|
||||||
- _GradientScale: 10
|
- _GradientScale: 10
|
||||||
|
- _MaskEdgeSoftness: 0.01
|
||||||
|
- _MaskInverse: 0
|
||||||
- _MaskSoftnessX: 0
|
- _MaskSoftnessX: 0
|
||||||
- _MaskSoftnessY: 0
|
- _MaskSoftnessY: 0
|
||||||
|
- _MaskWipeControl: 0.5
|
||||||
- _OutlineSoftness: 0
|
- _OutlineSoftness: 0
|
||||||
- _OutlineWidth: 0
|
- _OutlineWidth: 0
|
||||||
- _PerspectiveFilter: 0.875
|
- _PerspectiveFilter: 0.875
|
||||||
@@ -64,6 +71,7 @@ Material:
|
|||||||
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
|
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _FaceColor: {r: 1, g: 1, b: 1, a: 1}
|
- _FaceColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
- _MaskEdgeColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
|
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
- _UnderlayColor: {r: 0, g: 0, b: 0, a: 0.5}
|
- _UnderlayColor: {r: 0, g: 0, b: 0, a: 0.5}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
@@ -753,8 +753,8 @@ MonoBehaviour:
|
|||||||
m_Calls: []
|
m_Calls: []
|
||||||
m_text: SAMPLE DECAL !!!!
|
m_text: SAMPLE DECAL !!!!
|
||||||
m_isRightToLeft: 0
|
m_isRightToLeft: 0
|
||||||
m_fontAsset: {fileID: 11400000, guid: f84ba4af5f59a4e5db5d23c9c3580b8c, type: 2}
|
m_fontAsset: {fileID: 11400000, guid: 9d2d7c952bc8c4e968019a926227e17b, type: 2}
|
||||||
m_sharedMaterial: {fileID: 2180264, guid: f84ba4af5f59a4e5db5d23c9c3580b8c, type: 2}
|
m_sharedMaterial: {fileID: 2180264, guid: 9d2d7c952bc8c4e968019a926227e17b, type: 2}
|
||||||
m_fontSharedMaterials: []
|
m_fontSharedMaterials: []
|
||||||
m_fontMaterial: {fileID: 0}
|
m_fontMaterial: {fileID: 0}
|
||||||
m_fontMaterials: []
|
m_fontMaterials: []
|
||||||
@@ -848,7 +848,7 @@ MeshRenderer:
|
|||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
- {fileID: 2180264, guid: f84ba4af5f59a4e5db5d23c9c3580b8c, type: 2}
|
- {fileID: 2180264, guid: 9d2d7c952bc8c4e968019a926227e17b, type: 2}
|
||||||
m_StaticBatchInfo:
|
m_StaticBatchInfo:
|
||||||
firstSubMesh: 0
|
firstSubMesh: 0
|
||||||
subMeshCount: 0
|
subMeshCount: 0
|
||||||
|
|||||||
903
Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF - Fallback.asset
Executable file → Normal file
903
Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF - Fallback.asset
Executable file → Normal file
File diff suppressed because one or more lines are too long
1
Assets/ru.chikalin.textdecal
Submodule
1
Assets/ru.chikalin.textdecal
Submodule
Submodule Assets/ru.chikalin.textdecal added at 60c62cff8e
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 49577d9d367734e03a9a58c7a3ab767f
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 79dc5f64f8f784006ac0b95236c409ea
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 13be3d1fd837c45d18bc454ea344a07f
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 376 B |
@@ -1,140 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 469b6893bf7f64d7aabcc96056534092
|
|
||||||
TextureImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 13
|
|
||||||
mipmaps:
|
|
||||||
mipMapMode: 0
|
|
||||||
enableMipMap: 0
|
|
||||||
sRGBTexture: 1
|
|
||||||
linearTexture: 0
|
|
||||||
fadeOut: 0
|
|
||||||
borderMipMap: 0
|
|
||||||
mipMapsPreserveCoverage: 0
|
|
||||||
alphaTestReferenceValue: 0.5
|
|
||||||
mipMapFadeDistanceStart: 1
|
|
||||||
mipMapFadeDistanceEnd: 3
|
|
||||||
bumpmap:
|
|
||||||
convertToNormalMap: 0
|
|
||||||
externalNormalMap: 0
|
|
||||||
heightScale: 0.25
|
|
||||||
normalMapFilter: 0
|
|
||||||
flipGreenChannel: 0
|
|
||||||
isReadable: 0
|
|
||||||
streamingMipmaps: 0
|
|
||||||
streamingMipmapsPriority: 0
|
|
||||||
vTOnly: 0
|
|
||||||
ignoreMipmapLimit: 0
|
|
||||||
grayScaleToAlpha: 0
|
|
||||||
generateCubemap: 6
|
|
||||||
cubemapConvolution: 0
|
|
||||||
seamlessCubemap: 0
|
|
||||||
textureFormat: 1
|
|
||||||
maxTextureSize: 2048
|
|
||||||
textureSettings:
|
|
||||||
serializedVersion: 2
|
|
||||||
filterMode: 1
|
|
||||||
aniso: 1
|
|
||||||
mipBias: 0
|
|
||||||
wrapU: 1
|
|
||||||
wrapV: 1
|
|
||||||
wrapW: 0
|
|
||||||
nPOTScale: 0
|
|
||||||
lightmap: 0
|
|
||||||
compressionQuality: 50
|
|
||||||
spriteMode: 1
|
|
||||||
spriteExtrude: 1
|
|
||||||
spriteMeshType: 0
|
|
||||||
alignment: 0
|
|
||||||
spritePivot: {x: 0.5, y: 0.5}
|
|
||||||
spritePixelsToUnits: 100
|
|
||||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
|
||||||
spriteGenerateFallbackPhysicsShape: 0
|
|
||||||
alphaUsage: 1
|
|
||||||
alphaIsTransparency: 1
|
|
||||||
spriteTessellationDetail: -1
|
|
||||||
textureType: 8
|
|
||||||
textureShape: 1
|
|
||||||
singleChannelComponent: 0
|
|
||||||
flipbookRows: 1
|
|
||||||
flipbookColumns: 1
|
|
||||||
maxTextureSizeSet: 0
|
|
||||||
compressionQualitySet: 0
|
|
||||||
textureFormatSet: 0
|
|
||||||
ignorePngGamma: 0
|
|
||||||
applyGammaDecoding: 0
|
|
||||||
swizzle: 50462976
|
|
||||||
cookieLightType: 0
|
|
||||||
platformSettings:
|
|
||||||
- serializedVersion: 3
|
|
||||||
buildTarget: DefaultTexturePlatform
|
|
||||||
maxTextureSize: 32
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 0
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
ignorePlatformSupport: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
- serializedVersion: 3
|
|
||||||
buildTarget: Standalone
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
ignorePlatformSupport: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
- serializedVersion: 3
|
|
||||||
buildTarget: iPhone
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
ignorePlatformSupport: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
- serializedVersion: 3
|
|
||||||
buildTarget: Android
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
ignorePlatformSupport: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
spriteSheet:
|
|
||||||
serializedVersion: 2
|
|
||||||
sprites: []
|
|
||||||
outline: []
|
|
||||||
physicsShape: []
|
|
||||||
bones: []
|
|
||||||
spriteID: 5e97eb03825dee720800000000000000
|
|
||||||
internalID: 0
|
|
||||||
vertices: []
|
|
||||||
indices:
|
|
||||||
edges: []
|
|
||||||
weights: []
|
|
||||||
secondaryTextures: []
|
|
||||||
nameFileIdTable: {}
|
|
||||||
mipmapLimitGroupName:
|
|
||||||
pSDRemoveMatte: 0
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "ru.chikalin.textdecal.Editor",
|
|
||||||
"rootNamespace": "",
|
|
||||||
"references": [],
|
|
||||||
"includePlatforms": [],
|
|
||||||
"excludePlatforms": [],
|
|
||||||
"allowUnsafeCode": false,
|
|
||||||
"overrideReferences": false,
|
|
||||||
"precompiledReferences": [],
|
|
||||||
"autoReferenced": true,
|
|
||||||
"defineConstraints": [],
|
|
||||||
"versionDefines": [],
|
|
||||||
"noEngineReferences": false
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 25f5278effa244d848aa745584da360b
|
|
||||||
AssemblyDefinitionImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 1464671579a347db9035dc15a0a3522d
|
|
||||||
timeCreated: 1731754848
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: a33edb5f64dd3406c9f8979987cd9578
|
|
||||||
TextScriptImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 5ff47fb2004f24817b35372d740188da
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,307 +0,0 @@
|
|||||||
using System;
|
|
||||||
using TMPro;
|
|
||||||
using UnityEngine;
|
|
||||||
using Object = UnityEngine.Object;
|
|
||||||
|
|
||||||
namespace ru.chikalin.textdecal
|
|
||||||
{
|
|
||||||
[ExecuteAlways]
|
|
||||||
[RequireComponent(typeof(TMP_Text))]
|
|
||||||
[DefaultExecutionOrder(11)]
|
|
||||||
[AddComponentMenu("Mesh/TextMeshPro - Decal")]
|
|
||||||
[HelpURL("https://assetstore.unity.com/")] // todo
|
|
||||||
#if UNITY_2021_2_OR_NEWER
|
|
||||||
[Icon("Editor/Resources/Icons/sticker.png")] // todo
|
|
||||||
#endif
|
|
||||||
public class TextMeshProDecal : MonoBehaviour
|
|
||||||
{
|
|
||||||
private const int VolumetricVertexCount = 8;
|
|
||||||
private const int VolumetricTrianglesCount = 36;
|
|
||||||
|
|
||||||
private readonly int[] _volumetricTriangles =
|
|
||||||
{
|
|
||||||
0, 1, 2, //face front
|
|
||||||
2, 3, 0,
|
|
||||||
1, 5, 6, //face top
|
|
||||||
6, 2, 1,
|
|
||||||
3, 2, 6, //face right
|
|
||||||
6, 7, 3,
|
|
||||||
4, 5, 1, //face left
|
|
||||||
1, 0, 4,
|
|
||||||
4, 0, 3, //face back
|
|
||||||
3, 7, 4,
|
|
||||||
7, 6, 5, //face bottom
|
|
||||||
5, 4, 7
|
|
||||||
};
|
|
||||||
|
|
||||||
[Tooltip("Volumetric mesh depth")] public float depth = 1;
|
|
||||||
private Vector3 _depthVector;
|
|
||||||
|
|
||||||
private TMP_Text _text;
|
|
||||||
private Vector3[] _vertices;
|
|
||||||
private int[] _triangles;
|
|
||||||
private Color[] _colors;
|
|
||||||
private Vector2[] _uv;
|
|
||||||
private Vector2[] _uv2;
|
|
||||||
private Vector2[] _uv4;
|
|
||||||
private Vector2[] _uv5;
|
|
||||||
private Vector2[] _uv6;
|
|
||||||
private Vector2[] _uv7;
|
|
||||||
private Vector2[] _uv8;
|
|
||||||
|
|
||||||
private Mesh _volumetricMesh;
|
|
||||||
|
|
||||||
private Mesh VolumetricMesh
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_volumetricMesh != null) return _volumetricMesh;
|
|
||||||
_volumetricMesh = new Mesh
|
|
||||||
{
|
|
||||||
hideFlags = HideFlags.HideAndDontSave
|
|
||||||
};
|
|
||||||
#if DEVELOPMENT_BUILD || UNITY_EDITOR
|
|
||||||
_volumetricMesh.name = "TextMeshPro Decal Mesh";
|
|
||||||
#endif
|
|
||||||
_volumetricMesh.MarkDynamic();
|
|
||||||
return _volumetricMesh;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private MeshFilter _meshFilter;
|
|
||||||
|
|
||||||
private MeshFilter MeshFilter
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_meshFilter != null) return _meshFilter;
|
|
||||||
_meshFilter = GetComponent<MeshFilter>();
|
|
||||||
if (_meshFilter != null) return _meshFilter;
|
|
||||||
_meshFilter = gameObject.AddComponent<MeshFilter>();
|
|
||||||
_meshFilter.hideFlags = HideFlags.HideInInspector | HideFlags.HideAndDontSave;
|
|
||||||
return _meshFilter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Awake()
|
|
||||||
{
|
|
||||||
_text = GetComponent<TMP_Text>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnEnable()
|
|
||||||
{
|
|
||||||
UpdateDepthVector();
|
|
||||||
_text.OnPreRenderText += OnPreRenderText;
|
|
||||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(OnTextChangedEvent);
|
|
||||||
OnPreRenderText(_text.textInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDisable()
|
|
||||||
{
|
|
||||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Remove(OnTextChangedEvent);
|
|
||||||
_text.OnPreRenderText -= OnPreRenderText;
|
|
||||||
|
|
||||||
_text.ForceMeshUpdate();
|
|
||||||
MeshFilter.sharedMesh = _text.mesh;
|
|
||||||
if (_volumetricMesh != null)
|
|
||||||
{
|
|
||||||
DestroyImmediate(_volumetricMesh);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnTextChangedEvent(Object obj)
|
|
||||||
{
|
|
||||||
if (obj != _text || !string.IsNullOrEmpty(_text.text)) return;
|
|
||||||
|
|
||||||
// force update if text is empty
|
|
||||||
OnPreRenderText(_text.textInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnPreRenderText(TMP_TextInfo textInfo)
|
|
||||||
{
|
|
||||||
// todo remove
|
|
||||||
if (_text.isVolumetricText)
|
|
||||||
{
|
|
||||||
var textMesh = _text.mesh;
|
|
||||||
MeshFilter.sharedMesh = textMesh;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PrepareMeshData(textInfo);
|
|
||||||
var characterIndex = 0;
|
|
||||||
for (var i = 0; i < textInfo.characterCount; i++)
|
|
||||||
{
|
|
||||||
var characterInfo = textInfo.characterInfo[i];
|
|
||||||
if (!characterInfo.isVisible) continue;
|
|
||||||
var materialIndex = characterInfo.materialReferenceIndex;
|
|
||||||
var meshInfo = textInfo.meshInfo[materialIndex];
|
|
||||||
AddCharacter(characterInfo, meshInfo, characterIndex++);
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateMesh();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add volumetric mesh for a character
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="charInfo">TextMesh character info</param>
|
|
||||||
/// <param name="meshInfo">TextMesh mesh info</param>
|
|
||||||
/// <param name="characterIndex">Character index</param>
|
|
||||||
private void AddCharacter(TMP_CharacterInfo charInfo, TMP_MeshInfo meshInfo, int characterIndex)
|
|
||||||
{
|
|
||||||
var volumetricVertexIndex = characterIndex * VolumetricVertexCount;
|
|
||||||
var vertexIndex = charInfo.vertexIndex;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* copy TextMesh vertices
|
|
||||||
*/
|
|
||||||
var bl = meshInfo.vertices[vertexIndex + 0];
|
|
||||||
var tl = meshInfo.vertices[vertexIndex + 1];
|
|
||||||
var tr = meshInfo.vertices[vertexIndex + 2];
|
|
||||||
var br = meshInfo.vertices[vertexIndex + 3];
|
|
||||||
_vertices[volumetricVertexIndex + 0] = bl;
|
|
||||||
_vertices[volumetricVertexIndex + 1] = tl;
|
|
||||||
_vertices[volumetricVertexIndex + 2] = tr;
|
|
||||||
_vertices[volumetricVertexIndex + 3] = br;
|
|
||||||
/*
|
|
||||||
* Extrude face to make a cube
|
|
||||||
*/
|
|
||||||
_vertices[volumetricVertexIndex + 4] = bl + _depthVector;
|
|
||||||
_vertices[volumetricVertexIndex + 5] = tl + _depthVector;
|
|
||||||
_vertices[volumetricVertexIndex + 6] = tr + _depthVector;
|
|
||||||
_vertices[volumetricVertexIndex + 7] = br + _depthVector;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fill volumetric triangles
|
|
||||||
*/
|
|
||||||
for (var i = 0; i < _volumetricTriangles.Length; i++)
|
|
||||||
{
|
|
||||||
_triangles[characterIndex * VolumetricTrianglesCount + i] = volumetricVertexIndex + _volumetricTriangles[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copy TextMesh UVs
|
|
||||||
*/
|
|
||||||
_uv[volumetricVertexIndex + 0] = charInfo.vertex_BL.uv;
|
|
||||||
_uv[volumetricVertexIndex + 1] = charInfo.vertex_TL.uv;
|
|
||||||
_uv[volumetricVertexIndex + 2] = charInfo.vertex_TR.uv;
|
|
||||||
_uv[volumetricVertexIndex + 3] = charInfo.vertex_BR.uv;
|
|
||||||
_uv[volumetricVertexIndex + 4] = charInfo.vertex_BL.uv;
|
|
||||||
_uv[volumetricVertexIndex + 5] = charInfo.vertex_TL.uv;
|
|
||||||
_uv[volumetricVertexIndex + 6] = charInfo.vertex_TR.uv;
|
|
||||||
_uv[volumetricVertexIndex + 7] = charInfo.vertex_BR.uv;
|
|
||||||
|
|
||||||
_uv2[volumetricVertexIndex + 0] = charInfo.vertex_BL.uv2;
|
|
||||||
_uv2[volumetricVertexIndex + 1] = charInfo.vertex_TL.uv2;
|
|
||||||
_uv2[volumetricVertexIndex + 2] = charInfo.vertex_TR.uv2;
|
|
||||||
_uv2[volumetricVertexIndex + 3] = charInfo.vertex_BR.uv2;
|
|
||||||
_uv2[volumetricVertexIndex + 4] = charInfo.vertex_BL.uv2;
|
|
||||||
_uv2[volumetricVertexIndex + 5] = charInfo.vertex_TL.uv2;
|
|
||||||
_uv2[volumetricVertexIndex + 6] = charInfo.vertex_TR.uv2;
|
|
||||||
_uv2[volumetricVertexIndex + 7] = charInfo.vertex_BR.uv2;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Additional mesh data for decal shader
|
|
||||||
*/
|
|
||||||
// character bottom left vertex position
|
|
||||||
var uv4 = new Vector2(bl.x, bl.y);
|
|
||||||
// character bottom left UV
|
|
||||||
var uv5 = charInfo.vertex_BL.uv;
|
|
||||||
|
|
||||||
// character 3D size
|
|
||||||
var width = Vector3.Distance(br, bl);
|
|
||||||
var height = Vector3.Distance(tr, br);
|
|
||||||
var uv6 = new Vector2(width, height);
|
|
||||||
|
|
||||||
// character UV size
|
|
||||||
var uvWidth = Vector2.Distance(charInfo.vertex_BR.uv, charInfo.vertex_BL.uv);
|
|
||||||
var uvHeight = Vector2.Distance(charInfo.vertex_TR.uv, charInfo.vertex_BR.uv);
|
|
||||||
var uv7 = new Vector2(uvWidth, uvHeight);
|
|
||||||
|
|
||||||
// character 3D Z-rotation
|
|
||||||
var angle = Vector3.SignedAngle(Vector3.up, tl - bl, Vector3.forward);
|
|
||||||
var uv8 = Mathf.Deg2Rad * angle;
|
|
||||||
|
|
||||||
for (var i = 0; i < VolumetricVertexCount; i++)
|
|
||||||
{
|
|
||||||
_uv4[volumetricVertexIndex + i] = uv4;
|
|
||||||
_uv5[volumetricVertexIndex + i] = uv5;
|
|
||||||
_uv6[volumetricVertexIndex + i] = uv6;
|
|
||||||
_uv7[volumetricVertexIndex + i] = uv7;
|
|
||||||
_colors[volumetricVertexIndex + i] = charInfo.color;
|
|
||||||
_uv8[volumetricVertexIndex + i].x = uv8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateMesh()
|
|
||||||
{
|
|
||||||
var mesh = VolumetricMesh;
|
|
||||||
mesh.Clear();
|
|
||||||
mesh.vertices = _vertices;
|
|
||||||
mesh.triangles = _triangles;
|
|
||||||
mesh.uv = _uv;
|
|
||||||
mesh.uv2 = _uv2;
|
|
||||||
mesh.colors = _colors;
|
|
||||||
mesh.uv4 = _uv4;
|
|
||||||
mesh.uv5 = _uv5;
|
|
||||||
mesh.uv6 = _uv6;
|
|
||||||
mesh.uv7 = _uv7;
|
|
||||||
mesh.uv8 = _uv8;
|
|
||||||
if (MeshFilter.sharedMesh != mesh)
|
|
||||||
{
|
|
||||||
MeshFilter.sharedMesh = mesh;
|
|
||||||
}
|
|
||||||
|
|
||||||
mesh.RecalculateBounds();
|
|
||||||
mesh.MarkModified();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PrepareMeshData(TMP_TextInfo textInfo)
|
|
||||||
{
|
|
||||||
var size = textInfo.characterInfo.Length;
|
|
||||||
var vertexSize = size * VolumetricVertexCount;
|
|
||||||
UpdateArray(ref _vertices, vertexSize);
|
|
||||||
UpdateArray(ref _triangles, size * VolumetricTrianglesCount);
|
|
||||||
UpdateArray(ref _colors, vertexSize);
|
|
||||||
UpdateArray(ref _uv, vertexSize);
|
|
||||||
UpdateArray(ref _uv2, vertexSize);
|
|
||||||
UpdateArray(ref _uv4, vertexSize);
|
|
||||||
UpdateArray(ref _uv5, vertexSize);
|
|
||||||
UpdateArray(ref _uv6, vertexSize);
|
|
||||||
UpdateArray(ref _uv7, vertexSize);
|
|
||||||
UpdateArray(ref _uv8, vertexSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void UpdateArray<T>(ref T[] array, int size)
|
|
||||||
{
|
|
||||||
if (array == null)
|
|
||||||
{
|
|
||||||
array = new T[size];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array.Length < size)
|
|
||||||
{
|
|
||||||
Array.Resize(ref array, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
Array.Clear(array, 0, array.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
|
||||||
private void OnValidate()
|
|
||||||
{
|
|
||||||
if (_text != null)
|
|
||||||
{
|
|
||||||
_text.ForceMeshUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateDepthVector();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private void UpdateDepthVector() => _depthVector = new Vector3(0, 0, depth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: f6e705d8c563048b898ce13a6b9685f6
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "ru.chikalin.textdecal",
|
|
||||||
"rootNamespace": "",
|
|
||||||
"references": [
|
|
||||||
"GUID:6055be8ebefd69e48b49212b09b47b2f"
|
|
||||||
],
|
|
||||||
"includePlatforms": [],
|
|
||||||
"excludePlatforms": [],
|
|
||||||
"allowUnsafeCode": false,
|
|
||||||
"overrideReferences": false,
|
|
||||||
"precompiledReferences": [],
|
|
||||||
"autoReferenced": true,
|
|
||||||
"defineConstraints": [],
|
|
||||||
"versionDefines": [],
|
|
||||||
"noEngineReferences": false
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 0e44c6c2b705f4e62a3d71ee60ad59d8
|
|
||||||
AssemblyDefinitionImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 16a036b72a9a1406c89fdada1f443844
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: ab00d5e636fda4407af11cfac51b958c
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: f84ba4af5f59a4e5db5d23c9c3580b8c
|
|
||||||
NativeFormatImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
mainObjectFileID: 11400000
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
// Simplified SDF shader:
|
|
||||||
// - No Shading Option (bevel / bump / env map)
|
|
||||||
// - No Glow Option
|
|
||||||
// - Softness is applied on both side of the outline
|
|
||||||
|
|
||||||
Shader "TextMeshPro/Mobile/Decal/Distance Field SSD" {
|
|
||||||
|
|
||||||
Properties {
|
|
||||||
_FaceColor ("Face Color", Color) = (1,1,1,1)
|
|
||||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
|
||||||
|
|
||||||
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
|
||||||
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
|
|
||||||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
|
||||||
|
|
||||||
_UnderlayColor ("Border Color", Color) = (0,0,0,.5)
|
|
||||||
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
|
|
||||||
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
|
|
||||||
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
|
|
||||||
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0
|
|
||||||
|
|
||||||
_WeightNormal ("Weight Normal", float) = 0
|
|
||||||
_WeightBold ("Weight Bold", float) = .5
|
|
||||||
|
|
||||||
_ShaderFlags ("Flags", float) = 0
|
|
||||||
_ScaleRatioA ("Scale RatioA", float) = 1
|
|
||||||
_ScaleRatioB ("Scale RatioB", float) = 1
|
|
||||||
_ScaleRatioC ("Scale RatioC", float) = 1
|
|
||||||
|
|
||||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
|
||||||
_TextureWidth ("Texture Width", float) = 512
|
|
||||||
_TextureHeight ("Texture Height", float) = 512
|
|
||||||
_GradientScale ("Gradient Scale", float) = 5
|
|
||||||
_ScaleX ("Scale X", float) = 1
|
|
||||||
_ScaleY ("Scale Y", float) = 1
|
|
||||||
_PerspectiveFilter ("Perspective Correction", Range(0, 1)) = 0.875
|
|
||||||
_Sharpness ("Sharpness", Range(-1,1)) = 0
|
|
||||||
|
|
||||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
|
||||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
|
||||||
|
|
||||||
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
|
||||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
|
||||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
|
||||||
_MaskTex ("Mask Texture", 2D) = "white" {}
|
|
||||||
_MaskInverse ("Inverse", float) = 0
|
|
||||||
_MaskEdgeColor ("Edge Color", Color) = (1,1,1,1)
|
|
||||||
_MaskEdgeSoftness ("Edge Softness", Range(0, 1)) = 0.01
|
|
||||||
_MaskWipeControl ("Wipe Position", Range(0, 1)) = 0.5
|
|
||||||
|
|
||||||
_StencilComp ("Stencil Comparison", Float) = 8
|
|
||||||
_Stencil ("Stencil ID", Float) = 0
|
|
||||||
_StencilOp ("Stencil Operation", Float) = 0
|
|
||||||
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
|
||||||
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
|
||||||
|
|
||||||
_CullMode ("Cull Mode", Float) = 0
|
|
||||||
_ColorMask ("Color Mask", Float) = 15
|
|
||||||
}
|
|
||||||
|
|
||||||
SubShader {
|
|
||||||
Tags {
|
|
||||||
"Queue"="Transparent"
|
|
||||||
"IgnoreProjector"="True"
|
|
||||||
"RenderType"="Transparent"
|
|
||||||
}
|
|
||||||
|
|
||||||
Stencil
|
|
||||||
{
|
|
||||||
Ref [_Stencil]
|
|
||||||
Comp [_StencilComp]
|
|
||||||
Pass [_StencilOp]
|
|
||||||
ReadMask [_StencilReadMask]
|
|
||||||
WriteMask [_StencilWriteMask]
|
|
||||||
}
|
|
||||||
|
|
||||||
Cull [_CullMode]
|
|
||||||
ZWrite Off
|
|
||||||
Lighting Off
|
|
||||||
Fog { Mode Off }
|
|
||||||
ZTest [unity_GUIZTestMode]
|
|
||||||
Blend One OneMinusSrcAlpha
|
|
||||||
ColorMask [_ColorMask]
|
|
||||||
|
|
||||||
Pass {
|
|
||||||
HLSLPROGRAM
|
|
||||||
#pragma vertex VertShader
|
|
||||||
#pragma fragment PixShader
|
|
||||||
#pragma shader_feature __ OUTLINE_ON
|
|
||||||
#pragma shader_feature __ UNDERLAY_ON UNDERLAY_INNER
|
|
||||||
|
|
||||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
|
||||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
|
||||||
|
|
||||||
// #include "UnityCG.cginc"
|
|
||||||
// #include "UnityUI.cginc"
|
|
||||||
#include "TMPro_Properties.cginc"
|
|
||||||
|
|
||||||
#include "TMPro_Decal.cginc"
|
|
||||||
|
|
||||||
ENDHLSL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 970b94dd738345c3ab1ac4418c017ad4
|
|
||||||
timeCreated: 1731679485
|
|
||||||
@@ -1,301 +0,0 @@
|
|||||||
// Simplified SDF shader:
|
|
||||||
// - No Shading Option (bevel / bump / env map)
|
|
||||||
// - No Glow Option
|
|
||||||
// - Softness is applied on both side of the outline
|
|
||||||
|
|
||||||
Shader "TextMeshPro/Mobile/Distance Field/Decal Text" {
|
|
||||||
|
|
||||||
Properties {
|
|
||||||
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
|
|
||||||
_Color ("Color", Color) = (1,1,1,1)
|
|
||||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
|
||||||
|
|
||||||
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
|
||||||
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
|
|
||||||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
|
||||||
|
|
||||||
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0,.5)
|
|
||||||
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
|
|
||||||
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
|
|
||||||
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
|
|
||||||
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0
|
|
||||||
|
|
||||||
_WeightNormal ("Weight Normal", float) = 0
|
|
||||||
_WeightBold ("Weight Bold", float) = .5
|
|
||||||
|
|
||||||
_ShaderFlags ("Flags", float) = 0
|
|
||||||
_ScaleRatioA ("Scale RatioA", float) = 1
|
|
||||||
_ScaleRatioB ("Scale RatioB", float) = 1
|
|
||||||
_ScaleRatioC ("Scale RatioC", float) = 1
|
|
||||||
|
|
||||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
|
||||||
_TextureWidth ("Texture Width", float) = 512
|
|
||||||
_TextureHeight ("Texture Height", float) = 512
|
|
||||||
_GradientScale ("Gradient Scale", float) = 5
|
|
||||||
_ScaleX ("Scale X", float) = 1
|
|
||||||
_ScaleY ("Scale Y", float) = 1
|
|
||||||
_PerspectiveFilter ("Perspective Correction", Range(0, 1)) = 0.875
|
|
||||||
_Sharpness ("Sharpness", Range(-1,1)) = 0
|
|
||||||
|
|
||||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
|
||||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
|
||||||
|
|
||||||
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
|
||||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
|
||||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
|
||||||
|
|
||||||
_StencilComp ("Stencil Comparison", Float) = 8
|
|
||||||
_Stencil ("Stencil ID", Float) = 0
|
|
||||||
_StencilOp ("Stencil Operation", Float) = 0
|
|
||||||
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
|
||||||
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
|
||||||
|
|
||||||
_CullMode ("Cull Mode", Float) = 0
|
|
||||||
_ColorMask ("Color Mask", Float) = 15
|
|
||||||
}
|
|
||||||
|
|
||||||
SubShader {
|
|
||||||
Tags
|
|
||||||
{
|
|
||||||
"Queue"="Transparent"
|
|
||||||
"IgnoreProjector"="True"
|
|
||||||
"RenderType"="Transparent"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Stencil
|
|
||||||
{
|
|
||||||
Ref [_Stencil]
|
|
||||||
Comp [_StencilComp]
|
|
||||||
Pass [_StencilOp]
|
|
||||||
ReadMask [_StencilReadMask]
|
|
||||||
WriteMask [_StencilWriteMask]
|
|
||||||
}
|
|
||||||
|
|
||||||
Cull [_CullMode]
|
|
||||||
ZWrite Off
|
|
||||||
Lighting Off
|
|
||||||
Fog { Mode Off }
|
|
||||||
ZTest [unity_GUIZTestMode]
|
|
||||||
Blend One OneMinusSrcAlpha
|
|
||||||
ColorMask [_ColorMask]
|
|
||||||
|
|
||||||
Pass {
|
|
||||||
HLSLPROGRAM
|
|
||||||
#pragma vertex VertShader
|
|
||||||
#pragma fragment PixShader
|
|
||||||
#pragma shader_feature __ OUTLINE_ON
|
|
||||||
#pragma shader_feature __ UNDERLAY_ON UNDERLAY_INNER
|
|
||||||
|
|
||||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
|
||||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
|
||||||
|
|
||||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
|
|
||||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
||||||
|
|
||||||
CBUFFER_START(UnityPerMaterial)
|
|
||||||
uniform float4 _Color;
|
|
||||||
#include "TMPro_Properties.cginc"
|
|
||||||
CBUFFER_END
|
|
||||||
|
|
||||||
struct vertex_t {
|
|
||||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
||||||
float3 vertex : POSITION;
|
|
||||||
float3 normal : NORMAL;
|
|
||||||
float4 color : COLOR;
|
|
||||||
float2 texcoord0 : TEXCOORD0;
|
|
||||||
float2 texcoord1 : TEXCOORD1;
|
|
||||||
float2 texcoord3 : TEXCOORD3; // vertex left bottom position
|
|
||||||
float2 texcoord4 : TEXCOORD4; // UV left bottom position
|
|
||||||
float2 texcoord5 : TEXCOORD5; // vertex width, height
|
|
||||||
float2 texcoord6 : TEXCOORD6; // UV width, height
|
|
||||||
float2 texcoord7 : TEXCOORD7; // rotation (x - angle)
|
|
||||||
};
|
|
||||||
|
|
||||||
struct pixel_t {
|
|
||||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
||||||
UNITY_VERTEX_OUTPUT_STEREO
|
|
||||||
float4 vertex : SV_POSITION;
|
|
||||||
float4 faceColor : COLOR;
|
|
||||||
float4 outlineColor : COLOR1;
|
|
||||||
float4 texcoord0 : TEXCOORD0; // Texture UV, Mask UV
|
|
||||||
half4 param : TEXCOORD1; // Scale(x), BiasIn(y), BiasOut(z), Bias(w)
|
|
||||||
half4 mask : TEXCOORD2; // Position in clip space(xy), Softness(zw)
|
|
||||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
|
||||||
float4 texcoord1 : TEXCOORD3; // Texture UV, alpha, reserved
|
|
||||||
half2 underlayParam : TEXCOORD4; // Scale(x), Bias(y)
|
|
||||||
#endif
|
|
||||||
float4 vert_data : TEXCOORD5; // vertex left bottom position (x, y), vertex width (z), height (w)
|
|
||||||
float4 uv_data : TEXCOORD6; // UV left bottom position (x, y), UV width (z), height (w)
|
|
||||||
float2 rot_data : TEXCOORD7; // sin(a), cos(a)
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
pixel_t VertShader(vertex_t input)
|
|
||||||
{
|
|
||||||
pixel_t output = (pixel_t)0;
|
|
||||||
|
|
||||||
UNITY_SETUP_INSTANCE_ID(input);
|
|
||||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
|
||||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
|
||||||
|
|
||||||
float bold = step(input.texcoord1.y, 0);
|
|
||||||
|
|
||||||
float3 vert = input.vertex;
|
|
||||||
vert.x += _VertexOffsetX;
|
|
||||||
vert.y += _VertexOffsetY;
|
|
||||||
float4 vPosition = GetVertexPositionInputs(input.vertex).positionCS;
|
|
||||||
|
|
||||||
float2 pixelSize = vPosition.w;
|
|
||||||
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
|
|
||||||
|
|
||||||
float scale = rsqrt(dot(pixelSize, pixelSize));
|
|
||||||
scale *= abs(input.texcoord1.y) * _GradientScale * (_Sharpness + 1);
|
|
||||||
if(UNITY_MATRIX_P[3][3] == 0) scale = lerp(abs(scale) * (1 - _PerspectiveFilter), scale, abs(dot(TransformObjectToWorld(input.normal.xyz), normalize(TransformWorldToViewDir(vert)))));
|
|
||||||
|
|
||||||
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
|
|
||||||
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
|
|
||||||
|
|
||||||
float layerScale = scale;
|
|
||||||
|
|
||||||
scale /= 1 + (_OutlineSoftness * _ScaleRatioA * scale);
|
|
||||||
float bias = (0.5 - weight) * scale - 0.5;
|
|
||||||
float outline = _OutlineWidth * _ScaleRatioA * 0.5 * scale;
|
|
||||||
|
|
||||||
float opacity = input.color.a;
|
|
||||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
|
||||||
opacity = 1.0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_FaceColor.a = min(_FaceColor.a, _Color.a);
|
|
||||||
float4 faceColor = float4(input.color.rgb, opacity) * _FaceColor;
|
|
||||||
faceColor.rgb *= faceColor.a;
|
|
||||||
|
|
||||||
float4 outlineColor = _OutlineColor;
|
|
||||||
outlineColor.a *= opacity;
|
|
||||||
outlineColor.rgb *= outlineColor.a;
|
|
||||||
outlineColor = lerp(faceColor, outlineColor, sqrt(min(1.0, (outline * 2))));
|
|
||||||
|
|
||||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
|
||||||
layerScale /= 1 + ((_UnderlaySoftness * _ScaleRatioC) * layerScale);
|
|
||||||
float layerBias = (.5 - weight) * layerScale - .5 - ((_UnderlayDilate * _ScaleRatioC) * .5 * layerScale);
|
|
||||||
|
|
||||||
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
|
|
||||||
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
|
|
||||||
float2 layerOffset = float2(x, y);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Generate UV for the Masking Texture
|
|
||||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
|
||||||
float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
|
|
||||||
|
|
||||||
// Populate structure for pixel shader
|
|
||||||
output.vertex = vPosition;
|
|
||||||
output.faceColor = faceColor;
|
|
||||||
output.outlineColor = outlineColor;
|
|
||||||
output.texcoord0 = float4(input.texcoord0.x, input.texcoord0.y, maskUV.x, maskUV.y);
|
|
||||||
output.param = half4(scale, bias - outline, bias + outline, bias);
|
|
||||||
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
|
|
||||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
|
||||||
output.texcoord1 = float4(input.texcoord0 + layerOffset, input.color.a, 0);
|
|
||||||
output.underlayParam = half2(layerScale, layerBias);
|
|
||||||
#endif
|
|
||||||
output.vert_data = float4(input.texcoord3.xy, input.texcoord5.xy);
|
|
||||||
output.uv_data = float4(input.texcoord4.xy, input.texcoord6.xy);
|
|
||||||
const float angle = input.texcoord7.x;
|
|
||||||
output.rot_data = float2(sin(angle), cos(angle));
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
float invLerp(const float from, const float to, const float value)
|
|
||||||
{
|
|
||||||
return (value - from) / (to - from);
|
|
||||||
}
|
|
||||||
|
|
||||||
float remap(const float origFrom, const float origTo, const float targetFrom, const float targetTo, const float value)
|
|
||||||
{
|
|
||||||
const float rel = invLerp(origFrom, origTo, value);
|
|
||||||
return lerp(targetFrom, targetTo, rel);
|
|
||||||
}
|
|
||||||
|
|
||||||
float3 rotate(const float3 input, float2 m)
|
|
||||||
{
|
|
||||||
const float c = m.y; // cos(a)
|
|
||||||
const float s = m.x; // sin(a)
|
|
||||||
return mul(input, float3x3(c,-s, 0, s, c , 0, 0, 0, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// PIXEL SHADER
|
|
||||||
float4 PixShader(pixel_t input) : SV_Target
|
|
||||||
{
|
|
||||||
UNITY_SETUP_INSTANCE_ID(input);
|
|
||||||
|
|
||||||
// decal start
|
|
||||||
const float2 uv = (input.vertex.xy / _ScaledScreenParams.xy);
|
|
||||||
#if UNITY_REVERSED_Z
|
|
||||||
float depth = SampleSceneDepth(uv);
|
|
||||||
#else
|
|
||||||
// Adjust Z to match NDC for OpenGL ([-1, 1])
|
|
||||||
float depth = lerp(UNITY_NEAR_CLIP_VALUE, 1, SampleSceneDepth(uv));
|
|
||||||
#endif
|
|
||||||
const float3 world_pos = ComputeWorldSpacePosition(uv, depth, UNITY_MATRIX_I_VP);
|
|
||||||
float3 local_pos = TransformWorldToObject(world_pos);
|
|
||||||
// move local space to left bottom vertex position
|
|
||||||
local_pos -= float3(input.vert_data.xy, 0);
|
|
||||||
local_pos = rotate(local_pos,input.rot_data);
|
|
||||||
|
|
||||||
const float width = input.vert_data.z;
|
|
||||||
const float height = input.vert_data.w;
|
|
||||||
float4 decal_clip = float4(0, 0, 1, 1);
|
|
||||||
decal_clip.x = step(0, local_pos.x) * (1 - step(width, local_pos.x));
|
|
||||||
decal_clip.y = step(0, local_pos.y) * (1 - step(height, local_pos.y));
|
|
||||||
|
|
||||||
// remap from (0..vertex_size) to (uv.start..uv.end)
|
|
||||||
local_pos.x = remap(0, width, input.uv_data.x, input.uv_data.x + input.uv_data.z, local_pos.x);
|
|
||||||
local_pos.y = remap(0, height, input.uv_data.y, input.uv_data.y + input.uv_data.w, local_pos.y);
|
|
||||||
// decal end
|
|
||||||
|
|
||||||
// half d = tex2D(_MainTex, input.texcoord0.xy).a * input.param.x;
|
|
||||||
half d = tex2D(_MainTex, local_pos.xy).a * input.param.x;
|
|
||||||
half4 c = input.faceColor * saturate(d - input.param.w);
|
|
||||||
|
|
||||||
c *= decal_clip.x * decal_clip.y * decal_clip.z;
|
|
||||||
|
|
||||||
#ifdef OUTLINE_ON
|
|
||||||
c = lerp(input.outlineColor, input.faceColor, saturate(d - input.param.z));
|
|
||||||
c *= saturate(d - input.param.y);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if UNDERLAY_ON
|
|
||||||
d = tex2D(_MainTex, input.texcoord1.xy).a * input.underlayParam.x;
|
|
||||||
c += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * saturate(d - input.underlayParam.y) * (1 - c.a);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if UNDERLAY_INNER
|
|
||||||
half sd = saturate(d - input.param.z);
|
|
||||||
d = tex2D(_MainTex, input.texcoord1.xy).a * input.underlayParam.x;
|
|
||||||
c += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * (1 - saturate(d - input.underlayParam.y)) * sd * (1 - c.a);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
|
||||||
#if UNITY_UI_CLIP_RECT
|
|
||||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * input.mask.zw);
|
|
||||||
c *= m.x * m.y;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
|
||||||
c *= input.texcoord1.z;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if UNITY_UI_ALPHACLIP
|
|
||||||
clip(c.a - 0.001);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
ENDHLSL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: c47dfb763ac2d4f838ac57291e49f2d8
|
|
||||||
ShaderImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
defaultTextures: []
|
|
||||||
nonModifiableTextures: []
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,227 +0,0 @@
|
|||||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
|
|
||||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
||||||
#include <HLSLSupport.cginc>
|
|
||||||
|
|
||||||
struct vertex_t
|
|
||||||
{
|
|
||||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
||||||
float4 position : POSITION;
|
|
||||||
float3 normal : NORMAL;
|
|
||||||
float4 color : COLOR;
|
|
||||||
float4 texcoord0 : TEXCOORD0;
|
|
||||||
float2 texcoord1 : TEXCOORD1;
|
|
||||||
float2 texcoord3 : TEXCOORD3; // vertex left bottom position
|
|
||||||
float2 texcoord4 : TEXCOORD4; // UV left bottom position
|
|
||||||
float2 texcoord5 : TEXCOORD5; // vertex width, height
|
|
||||||
float2 texcoord6 : TEXCOORD6; // UV width, height
|
|
||||||
float2 texcoord7 : TEXCOORD7; // rotation (x - angle)
|
|
||||||
};
|
|
||||||
|
|
||||||
struct pixel_t
|
|
||||||
{
|
|
||||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
||||||
UNITY_VERTEX_OUTPUT_STEREO
|
|
||||||
float4 position : SV_POSITION;
|
|
||||||
float4 faceColor : COLOR;
|
|
||||||
float4 outlineColor : COLOR1;
|
|
||||||
float4 texcoord0 : TEXCOORD0;
|
|
||||||
float4 param : TEXCOORD1; // x = weight, y = no longer used
|
|
||||||
float2 mask : TEXCOORD2;
|
|
||||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
|
||||||
float4 texcoord1 : TEXCOORD3;
|
|
||||||
float2 underlayParam : TEXCOORD4;
|
|
||||||
#endif
|
|
||||||
float4 vert_data : TEXCOORD5; // vertex left bottom position (x, y), vertex width (z), height (w)
|
|
||||||
float4 uv_data : TEXCOORD6; // UV left bottom position (x, y), UV width (z), height (w)
|
|
||||||
float2 rot_data : TEXCOORD7; // sin(a), cos(a)
|
|
||||||
};
|
|
||||||
|
|
||||||
float4 SRGBToLinear(float4 rgba)
|
|
||||||
{
|
|
||||||
return float4(lerp(rgba.rgb / 12.92f, pow((rgba.rgb + 0.055f) / 1.055f, 2.4f), step(0.04045f, rgba.rgb)), rgba.a);
|
|
||||||
}
|
|
||||||
|
|
||||||
float _UIMaskSoftnessX;
|
|
||||||
float _UIMaskSoftnessY;
|
|
||||||
|
|
||||||
pixel_t VertShader(vertex_t input)
|
|
||||||
{
|
|
||||||
pixel_t output;
|
|
||||||
|
|
||||||
UNITY_INITIALIZE_OUTPUT(pixel_t, output);
|
|
||||||
UNITY_SETUP_INSTANCE_ID(input);
|
|
||||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
|
||||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
|
||||||
|
|
||||||
float bold = step(input.texcoord0.w, 0);
|
|
||||||
|
|
||||||
float4 vert = input.position;
|
|
||||||
vert.x += _VertexOffsetX;
|
|
||||||
vert.y += _VertexOffsetY;
|
|
||||||
|
|
||||||
float4 vPosition = GetVertexPositionInputs(vert).positionCS;
|
|
||||||
|
|
||||||
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
|
|
||||||
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
|
|
||||||
|
|
||||||
// Generate UV for the Masking Texture
|
|
||||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
|
||||||
float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
|
|
||||||
|
|
||||||
float4 color = input.color;
|
|
||||||
#if (FORCE_LINEAR && !UNITY_COLORSPACE_GAMMA)
|
|
||||||
color = SRGBToLinear(input.color);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
float opacity = color.a;
|
|
||||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
|
||||||
opacity = 1.0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
float4 faceColor = float4(color.rgb, opacity) * _FaceColor;
|
|
||||||
faceColor.rgb *= faceColor.a;
|
|
||||||
|
|
||||||
float4 outlineColor = _OutlineColor;
|
|
||||||
outlineColor.a *= opacity;
|
|
||||||
outlineColor.rgb *= outlineColor.a;
|
|
||||||
|
|
||||||
output.position = vPosition;
|
|
||||||
output.faceColor = faceColor;
|
|
||||||
output.outlineColor = outlineColor;
|
|
||||||
output.texcoord0 = float4(input.texcoord0.xy, maskUV.xy);
|
|
||||||
output.param = float4(0.5 - weight, 0, _OutlineWidth * _ScaleRatioA * 0.5, 0);
|
|
||||||
|
|
||||||
float2 mask = float2(0, 0);
|
|
||||||
#if UNITY_UI_CLIP_RECT
|
|
||||||
mask = vert.xy * 2 - clampedRect.xy - clampedRect.zw;
|
|
||||||
#endif
|
|
||||||
output.mask = mask;
|
|
||||||
|
|
||||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
|
||||||
float4 underlayColor = _UnderlayColor;
|
|
||||||
underlayColor.rgb *= underlayColor.a;
|
|
||||||
|
|
||||||
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
|
|
||||||
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
|
|
||||||
|
|
||||||
output.texcoord2 = float4(input.texcoord0 + float2(x, y), input.color.a, 0);
|
|
||||||
output.underlayColor = underlayColor;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// decal
|
|
||||||
output.vert_data = float4(input.texcoord3.xy, input.texcoord5.xy);
|
|
||||||
output.uv_data = float4(input.texcoord4.xy, input.texcoord6.xy);
|
|
||||||
const float angle = input.texcoord7.x;
|
|
||||||
output.rot_data = float2(sin(angle), cos(angle));
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
float invLerp(const float from, const float to, const float value)
|
|
||||||
{
|
|
||||||
return (value - from) / (to - from);
|
|
||||||
}
|
|
||||||
|
|
||||||
float remap(const float origFrom, const float origTo, const float targetFrom, const float targetTo, const float value)
|
|
||||||
{
|
|
||||||
const float rel = invLerp(origFrom, origTo, value);
|
|
||||||
return lerp(targetFrom, targetTo, rel);
|
|
||||||
}
|
|
||||||
|
|
||||||
float3 rotate(const float3 input, float2 m)
|
|
||||||
{
|
|
||||||
const float c = m.y; // cos(a)
|
|
||||||
const float s = m.x; // sin(a)
|
|
||||||
return mul(input, float3x3(c,-s, 0, s, c , 0, 0, 0, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 PixShader(pixel_t input) : SV_Target
|
|
||||||
{
|
|
||||||
UNITY_SETUP_INSTANCE_ID(input);
|
|
||||||
|
|
||||||
// decal start
|
|
||||||
const float2 uv = (input.position.xy / _ScaledScreenParams.xy);
|
|
||||||
#if UNITY_REVERSED_Z
|
|
||||||
float depth = SampleSceneDepth(uv);
|
|
||||||
#else
|
|
||||||
// Adjust Z to match NDC for OpenGL ([-1, 1])
|
|
||||||
float depth = lerp(UNITY_NEAR_CLIP_VALUE, 1, SampleSceneDepth(uv));
|
|
||||||
#endif
|
|
||||||
const float3 world_pos = ComputeWorldSpacePosition(uv, depth, UNITY_MATRIX_I_VP);
|
|
||||||
float3 local_pos = TransformWorldToObject(world_pos);
|
|
||||||
// move local space to left bottom vertex position
|
|
||||||
local_pos -= float3(input.vert_data.xy, 0);
|
|
||||||
local_pos = rotate(local_pos,input.rot_data);
|
|
||||||
const float width = input.vert_data.z;
|
|
||||||
const float height = input.vert_data.w;
|
|
||||||
float4 decal_clip = float4(0, 0, 1, 1);
|
|
||||||
decal_clip.x = step(0, local_pos.x) * (1 - step(width, local_pos.x));
|
|
||||||
decal_clip.y = step(0, local_pos.y) * (1 - step(height, local_pos.y));
|
|
||||||
|
|
||||||
// remap from (0..vertex_size) to (uv.start..uv.end)
|
|
||||||
local_pos.x = remap(0, width, input.uv_data.x, input.uv_data.x + input.uv_data.z, local_pos.x);
|
|
||||||
local_pos.y = remap(0, height, input.uv_data.y, input.uv_data.y + input.uv_data.w, local_pos.y);
|
|
||||||
// decal end
|
|
||||||
|
|
||||||
// float d = tex2D(_MainTex, input.texcoord0.xy).a;
|
|
||||||
float d = tex2D(_MainTex, local_pos.xy).a;
|
|
||||||
|
|
||||||
float pixelSize = abs(ddx(input.texcoord0.y)) + abs(ddy(input.texcoord0.y));
|
|
||||||
pixelSize *= _TextureHeight * 0.75;
|
|
||||||
float scale = 1 / pixelSize * _GradientScale * (_Sharpness + 1);
|
|
||||||
|
|
||||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
|
||||||
float layerScale = scale;
|
|
||||||
layerScale /= 1 + ((_UnderlaySoftness * _ScaleRatioC) * layerScale);
|
|
||||||
float layerBias = input.param.x * layerScale - .5 - ((_UnderlayDilate * _ScaleRatioC) * .5 * layerScale);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// scale /= 1 + (_OutlineSoftness * _ScaleRatioA * scale);
|
|
||||||
|
|
||||||
float4 faceColor = input.faceColor * saturate((d - input.param.x) * scale + 0.5);
|
|
||||||
faceColor *= decal_clip.x * decal_clip.y * decal_clip.z;
|
|
||||||
|
|
||||||
#if OUTLINE_ON
|
|
||||||
float4 outlineColor = lerp(input.faceColor, input.outlineColor, sqrt(min(1.0, input.param.z * scale * 2)));
|
|
||||||
faceColor = lerp(outlineColor, input.faceColor, saturate((d - input.param.x - input.param.z) * scale + 0.5));
|
|
||||||
faceColor *= saturate((d - input.param.x + input.param.z) * scale + 0.5);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if UNDERLAY_ON
|
|
||||||
d = tex2D(_MainTex, input.texcoord2.xy).a * layerScale;
|
|
||||||
faceColor += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * saturate(d - layerBias) * (1 - faceColor.a);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if UNDERLAY_INNER
|
|
||||||
float bias = input.param.x * scale - 0.5;
|
|
||||||
float sd = saturate(d * scale - bias - input.param.z);
|
|
||||||
d = tex2D(_MainTex, input.texcoord2.xy).a * layerScale;
|
|
||||||
faceColor += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * (1 - saturate(d - layerBias)) * sd * (1 - faceColor.a);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MASKING
|
|
||||||
float a = abs(_MaskInverse - tex2D(_MaskTex, input.texcoord0.zw).a);
|
|
||||||
float t = a + (1 - _MaskWipeControl) * _MaskEdgeSoftness - _MaskWipeControl;
|
|
||||||
a = saturate(t / _MaskEdgeSoftness);
|
|
||||||
faceColor.rgb = lerp(_MaskEdgeColor.rgb * faceColor.a, faceColor.rgb, a);
|
|
||||||
faceColor *= a;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Alternative implementation to UnityGet2DClipping with support for softness
|
|
||||||
#if UNITY_UI_CLIP_RECT
|
|
||||||
half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
|
|
||||||
float2 maskZW = 0.25 / (0.25 * maskSoftness + 1 / scale);
|
|
||||||
float2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * maskZW);
|
|
||||||
faceColor *= m.x * m.y;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
|
||||||
faceColor *= input.texcoord2.z;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if UNITY_UI_ALPHACLIP
|
|
||||||
clip(faceColor.a - 0.001);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return faceColor;
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 83b6a32242774237aba4e25f0535f2a5
|
|
||||||
timeCreated: 1731679606
|
|
||||||
@@ -1,167 +0,0 @@
|
|||||||
#include <HLSLSupport.cginc>
|
|
||||||
|
|
||||||
struct vertex_t
|
|
||||||
{
|
|
||||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
||||||
float4 position : POSITION;
|
|
||||||
float3 normal : NORMAL;
|
|
||||||
float4 color : COLOR;
|
|
||||||
float4 texcoord0 : TEXCOORD0;
|
|
||||||
float2 texcoord1 : TEXCOORD1;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct pixel_t
|
|
||||||
{
|
|
||||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
||||||
UNITY_VERTEX_OUTPUT_STEREO
|
|
||||||
float4 position : SV_POSITION;
|
|
||||||
float4 faceColor : COLOR;
|
|
||||||
float4 outlineColor : COLOR1;
|
|
||||||
float4 texcoord0 : TEXCOORD0;
|
|
||||||
float4 param : TEXCOORD1; // x = weight, y = no longer used
|
|
||||||
float2 mask : TEXCOORD2;
|
|
||||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
|
||||||
float4 texcoord2 : TEXCOORD3;
|
|
||||||
float4 underlayColor : COLOR2;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
float4 SRGBToLinear(float4 rgba)
|
|
||||||
{
|
|
||||||
return float4(lerp(rgba.rgb / 12.92f, pow((rgba.rgb + 0.055f) / 1.055f, 2.4f), step(0.04045f, rgba.rgb)), rgba.a);
|
|
||||||
}
|
|
||||||
|
|
||||||
float _UIMaskSoftnessX;
|
|
||||||
float _UIMaskSoftnessY;
|
|
||||||
|
|
||||||
pixel_t VertShader(vertex_t input)
|
|
||||||
{
|
|
||||||
pixel_t output;
|
|
||||||
|
|
||||||
UNITY_INITIALIZE_OUTPUT(pixel_t, output);
|
|
||||||
UNITY_SETUP_INSTANCE_ID(input);
|
|
||||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
|
||||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
|
||||||
|
|
||||||
float bold = step(input.texcoord0.w, 0);
|
|
||||||
|
|
||||||
float4 vert = input.position;
|
|
||||||
vert.x += _VertexOffsetX;
|
|
||||||
vert.y += _VertexOffsetY;
|
|
||||||
|
|
||||||
float4 vPosition = UnityObjectToClipPos(vert);
|
|
||||||
|
|
||||||
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
|
|
||||||
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
|
|
||||||
|
|
||||||
// Generate UV for the Masking Texture
|
|
||||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
|
||||||
float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
|
|
||||||
|
|
||||||
float4 color = input.color;
|
|
||||||
#if (FORCE_LINEAR && !UNITY_COLORSPACE_GAMMA)
|
|
||||||
color = SRGBToLinear(input.color);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
float opacity = color.a;
|
|
||||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
|
||||||
opacity = 1.0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
float4 faceColor = float4(color.rgb, opacity) * _FaceColor;
|
|
||||||
faceColor.rgb *= faceColor.a;
|
|
||||||
|
|
||||||
float4 outlineColor = _OutlineColor;
|
|
||||||
outlineColor.a *= opacity;
|
|
||||||
outlineColor.rgb *= outlineColor.a;
|
|
||||||
|
|
||||||
output.position = vPosition;
|
|
||||||
output.faceColor = faceColor;
|
|
||||||
output.outlineColor = outlineColor;
|
|
||||||
output.texcoord0 = float4(input.texcoord0.xy, maskUV.xy);
|
|
||||||
output.param = float4(0.5 - weight, 0, _OutlineWidth * _ScaleRatioA * 0.5, 0);
|
|
||||||
|
|
||||||
float2 mask = float2(0, 0);
|
|
||||||
#if UNITY_UI_CLIP_RECT
|
|
||||||
mask = vert.xy * 2 - clampedRect.xy - clampedRect.zw;
|
|
||||||
#endif
|
|
||||||
output.mask = mask;
|
|
||||||
|
|
||||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
|
||||||
float4 underlayColor = _UnderlayColor;
|
|
||||||
underlayColor.rgb *= underlayColor.a;
|
|
||||||
|
|
||||||
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
|
|
||||||
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
|
|
||||||
|
|
||||||
output.texcoord2 = float4(input.texcoord0 + float2(x, y), input.color.a, 0);
|
|
||||||
output.underlayColor = underlayColor;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 PixShader(pixel_t input) : SV_Target
|
|
||||||
{
|
|
||||||
UNITY_SETUP_INSTANCE_ID(input);
|
|
||||||
|
|
||||||
float d = tex2D(_MainTex, input.texcoord0.xy).a;
|
|
||||||
|
|
||||||
float pixelSize = abs(ddx(input.texcoord0.y)) + abs(ddy(input.texcoord0.y));
|
|
||||||
pixelSize *= _TextureHeight * 0.75;
|
|
||||||
float scale = 1 / pixelSize * _GradientScale * (_Sharpness + 1);
|
|
||||||
|
|
||||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
|
||||||
float layerScale = scale;
|
|
||||||
layerScale /= 1 + ((_UnderlaySoftness * _ScaleRatioC) * layerScale);
|
|
||||||
float layerBias = input.param.x * layerScale - .5 - ((_UnderlayDilate * _ScaleRatioC) * .5 * layerScale);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
scale /= 1 + (_OutlineSoftness * _ScaleRatioA * scale);
|
|
||||||
|
|
||||||
float4 faceColor = input.faceColor * saturate((d - input.param.x) * scale + 0.5);
|
|
||||||
|
|
||||||
#if OUTLINE_ON
|
|
||||||
float4 outlineColor = lerp(input.faceColor, input.outlineColor, sqrt(min(1.0, input.param.z * scale * 2)));
|
|
||||||
faceColor = lerp(outlineColor, input.faceColor, saturate((d - input.param.x - input.param.z) * scale + 0.5));
|
|
||||||
faceColor *= saturate((d - input.param.x + input.param.z) * scale + 0.5);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if UNDERLAY_ON
|
|
||||||
d = tex2D(_MainTex, input.texcoord2.xy).a * layerScale;
|
|
||||||
faceColor += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * saturate(d - layerBias) * (1 - faceColor.a);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if UNDERLAY_INNER
|
|
||||||
float bias = input.param.x * scale - 0.5;
|
|
||||||
float sd = saturate(d * scale - bias - input.param.z);
|
|
||||||
d = tex2D(_MainTex, input.texcoord2.xy).a * layerScale;
|
|
||||||
faceColor += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * (1 - saturate(d - layerBias)) * sd * (1 - faceColor.a);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MASKING
|
|
||||||
float a = abs(_MaskInverse - tex2D(_MaskTex, input.texcoord0.zw).a);
|
|
||||||
float t = a + (1 - _MaskWipeControl) * _MaskEdgeSoftness - _MaskWipeControl;
|
|
||||||
a = saturate(t / _MaskEdgeSoftness);
|
|
||||||
faceColor.rgb = lerp(_MaskEdgeColor.rgb * faceColor.a, faceColor.rgb, a);
|
|
||||||
faceColor *= a;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Alternative implementation to UnityGet2DClipping with support for softness
|
|
||||||
#if UNITY_UI_CLIP_RECT
|
|
||||||
half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
|
|
||||||
float2 maskZW = 0.25 / (0.25 * maskSoftness + 1 / scale);
|
|
||||||
float2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * maskZW);
|
|
||||||
faceColor *= m.x * m.y;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
|
||||||
faceColor *= input.texcoord2.z;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if UNITY_UI_ALPHACLIP
|
|
||||||
clip(faceColor.a - 0.001);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return faceColor;
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 5c3c90976a974ebfab085411aba35ac1
|
|
||||||
timeCreated: 1731679510
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
// UI Editable properties
|
|
||||||
uniform sampler2D _FaceTex; // Alpha : Signed Distance
|
|
||||||
uniform float _FaceUVSpeedX;
|
|
||||||
uniform float _FaceUVSpeedY;
|
|
||||||
uniform float4 _FaceColor; // RGBA : Color + Opacity
|
|
||||||
uniform float _FaceDilate; // v[ 0, 1]
|
|
||||||
uniform float _OutlineSoftness; // v[ 0, 1]
|
|
||||||
|
|
||||||
uniform sampler2D _OutlineTex; // RGBA : Color + Opacity
|
|
||||||
uniform float _OutlineUVSpeedX;
|
|
||||||
uniform float _OutlineUVSpeedY;
|
|
||||||
uniform float4 _OutlineColor; // RGBA : Color + Opacity
|
|
||||||
uniform float _OutlineWidth; // v[ 0, 1]
|
|
||||||
|
|
||||||
uniform float _Bevel; // v[ 0, 1]
|
|
||||||
uniform float _BevelOffset; // v[-1, 1]
|
|
||||||
uniform float _BevelWidth; // v[-1, 1]
|
|
||||||
uniform float _BevelClamp; // v[ 0, 1]
|
|
||||||
uniform float _BevelRoundness; // v[ 0, 1]
|
|
||||||
|
|
||||||
uniform sampler2D _BumpMap; // Normal map
|
|
||||||
uniform float _BumpOutline; // v[ 0, 1]
|
|
||||||
uniform float _BumpFace; // v[ 0, 1]
|
|
||||||
|
|
||||||
uniform samplerCUBE _Cube; // Cube / sphere map
|
|
||||||
uniform float4 _ReflectFaceColor; // RGB intensity
|
|
||||||
uniform float4 _ReflectOutlineColor;
|
|
||||||
//uniform float _EnvTiltX; // v[-1, 1]
|
|
||||||
//uniform float _EnvTiltY; // v[-1, 1]
|
|
||||||
uniform float3 _EnvMatrixRotation;
|
|
||||||
uniform float4x4 _EnvMatrix;
|
|
||||||
|
|
||||||
uniform float4 _SpecularColor; // RGB intensity
|
|
||||||
uniform float _LightAngle; // v[ 0,Tau]
|
|
||||||
uniform float _SpecularPower; // v[ 0, 1]
|
|
||||||
uniform float _Reflectivity; // v[ 5, 15]
|
|
||||||
uniform float _Diffuse; // v[ 0, 1]
|
|
||||||
uniform float _Ambient; // v[ 0, 1]
|
|
||||||
|
|
||||||
uniform float4 _UnderlayColor; // RGBA : Color + Opacity
|
|
||||||
uniform float _UnderlayOffsetX; // v[-1, 1]
|
|
||||||
uniform float _UnderlayOffsetY; // v[-1, 1]
|
|
||||||
uniform float _UnderlayDilate; // v[-1, 1]
|
|
||||||
uniform float _UnderlaySoftness; // v[ 0, 1]
|
|
||||||
|
|
||||||
uniform float4 _GlowColor; // RGBA : Color + Intesity
|
|
||||||
uniform float _GlowOffset; // v[-1, 1]
|
|
||||||
uniform float _GlowOuter; // v[ 0, 1]
|
|
||||||
uniform float _GlowInner; // v[ 0, 1]
|
|
||||||
uniform float _GlowPower; // v[ 1, 1/(1+4*4)]
|
|
||||||
|
|
||||||
// API Editable properties
|
|
||||||
uniform float _ShaderFlags;
|
|
||||||
uniform float _WeightNormal;
|
|
||||||
uniform float _WeightBold;
|
|
||||||
|
|
||||||
uniform float _ScaleRatioA;
|
|
||||||
uniform float _ScaleRatioB;
|
|
||||||
uniform float _ScaleRatioC;
|
|
||||||
|
|
||||||
uniform float _VertexOffsetX;
|
|
||||||
uniform float _VertexOffsetY;
|
|
||||||
|
|
||||||
//uniform float _UseClipRect;
|
|
||||||
uniform float _MaskID;
|
|
||||||
uniform sampler2D _MaskTex;
|
|
||||||
uniform float4 _MaskCoord;
|
|
||||||
uniform float4 _ClipRect; // bottom left(x,y) : top right(z,w)
|
|
||||||
uniform float _MaskSoftnessX;
|
|
||||||
uniform float _MaskSoftnessY;
|
|
||||||
|
|
||||||
// Font Atlas properties
|
|
||||||
uniform sampler2D _MainTex;
|
|
||||||
uniform float _TextureWidth;
|
|
||||||
uniform float _TextureHeight;
|
|
||||||
uniform float _GradientScale;
|
|
||||||
uniform float _ScaleX;
|
|
||||||
uniform float _ScaleY;
|
|
||||||
uniform float _PerspectiveFilter;
|
|
||||||
uniform float _Sharpness;
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 49536a91d8d94eddb186152f0eca69a7
|
|
||||||
timeCreated: 1731660883
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "ru.chikalin.textdecal",
|
|
||||||
"displayName": "TextMeshPro Decal",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "Decal for TextMeshPro",
|
|
||||||
"license": "Refer to LICENSE.md file",
|
|
||||||
"samples": [
|
|
||||||
{
|
|
||||||
"displayName": "URP Sample",
|
|
||||||
"description": "URP Sample",
|
|
||||||
"path": "Samples~/URP Sample"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"displayName": "VR Sample",
|
|
||||||
"description": "VR Sample",
|
|
||||||
"path": "Samples~/VR Sample"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"author": {
|
|
||||||
"name": "Kirill Chikalin",
|
|
||||||
"email": "kirill@chikalin.ru",
|
|
||||||
"url": "https://chikalin.ru"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 2198c2eb9b77743f780423eb7e1e638b
|
|
||||||
TextScriptImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
Reference in New Issue
Block a user