1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#ifndef POI_VERTEX_MANIPULATION
#define POI_VERTEX_MANIPULATION
#include "CGI_PoiMath.cginc"
float4 _VertexManipulationLocalTranslation;
float4 _VertexManipulationLocalRotation;
float4 _VertexManipulationLocalScale;
float4 _VertexManipulationWorldTranslation;
float _VertexManipulationHeight;
float _VertexManipulationHeightBias;
#if defined(PROP_VERTEXMANIPULATIONHEIGHTMASK) || !defined(OPTIMIZER_ENABLED)
sampler2D _VertexManipulationHeightMask; float4 _VertexManipulationHeightMask_ST;
#endif
float2 _VertexManipulationHeightPan;
//Vertex Glitching
float _EnableVertexGlitch;
float _VertexGlitchThreshold;
float _VertexGlitchFrequency;
float _VertexGlitchStrength;
// Rounding
float _VertexRoundingDivision;
float _VertexRoundingEnabled;
void applyLocalVertexTransformation(inout float3 normal, inout float4 tangent, inout float4 vertex)
{
normal = rotate_with_quaternion(normal, float4(0,0,0,1).xyz);
tangent.xyz = rotate_with_quaternion(tangent.xyz, float4(0,0,0,1).xyz);
vertex = transform(vertex, float4(0,0,0,1), float4(0,0,0,1), float4(1,1,1,1));
//vertex = float4(vertex.x + sin(_Time.y*1.5 + vertex.y * 50) * .75 * smoothstep( .3, -1, vertex.y), vertex.y, vertex.z + cos(_Time.y*1.5 + vertex.y * 50) * .75 * smoothstep( .3, -1, vertex.y), 1);
}
void applyLocalVertexTransformation(inout float3 normal, inout float4 vertex)
{
normal = rotate_with_quaternion(normal, float4(0,0,0,1).xyz);
vertex = transform(vertex, float4(0,0,0,1), float4(0,0,0,1), float4(1,1,1,1));
//vertex = float4(vertex.x + sin(_Time.y*1.5 + vertex.y * 50) * .75 * smoothstep( .3, -1, vertex.y), vertex.y, vertex.z + cos(_Time.y*1.5 + vertex.y * 50) * .75 * smoothstep( .3, -1, vertex.y), 1);
}
void applyWorldVertexTransformation(inout float4 worldPos, inout float4 localPos, inout float3 worldNormal, float2 uv)
{
#if defined(PROP_VERTEXMANIPULATIONHEIGHTMASK) || !defined(OPTIMIZER_ENABLED)
float3 heightOffset = (tex2Dlod(_VertexManipulationHeightMask, float4(TRANSFORM_TEX(uv, _VertexManipulationHeightMask) + float4(0,0,0,0) * _Time.x, 0, 0)).r - float(0)) * float(0) * worldNormal;
#else
float3 heightOffset = float(0) * worldNormal;
#endif
worldPos.rgb += float4(0,0,0,1).xyz/* * float4(0,0,0,1).w*/ + heightOffset;
localPos.xyz = mul(unity_WorldToObject, worldPos).xyz;
}
void applyWorldVertexTransformationShadow(inout float4 worldPos, inout float4 localPos, float3 worldNormal, float2 uv)
{
#if defined(PROP_VERTEXMANIPULATIONHEIGHTMASK) || !defined(OPTIMIZER_ENABLED)
float3 heightOffset = (tex2Dlod(_VertexManipulationHeightMask, float4(TRANSFORM_TEX(uv, _VertexManipulationHeightMask) + float4(0,0,0,0) * _Time.x, 0, 0)).r - float(0)) * float(0) * worldNormal;
#else
float3 heightOffset = float(0) * worldNormal;
#endif
worldPos.rgb += float4(0,0,0,1).xyz/* * float4(0,0,0,1).w*/ + heightOffset;
localPos.xyz = mul(unity_WorldToObject, worldPos).xyz;
}
void applyVertexRounding(inout float4 worldPos, inout float4 localPos)
{
if (float(0))
{
worldPos.xyz = (ceil(worldPos.xyz * float(500)) / float(500)) - 1 / float(500) * .5;
localPos = mul(unity_WorldToObject, worldPos);
}
}
void applyVertexGlitching(inout float4 worldPos, inout float4 localPos)
{
if(_EnableVertexGlitch)
{
float3 forward = getCameraPosition() - mul(unity_ObjectToWorld, float4(0, 0, 0, 1)).xyz;
forward.y = 0;
forward = normalize(forward);
float3 glitchDirection = normalize(cross(float3(0, 1, 0), forward));
float glitchAmount = frac(sin(dot(_Time.xy + worldPos.y, float2(12.9898, 78.233))) * 43758.5453123) * 2 - 1;
/*
float uvl = worldPos.y * _VertexGlitchDensity + _Time.x * _VertexGlitchMapPanSpeed;
float uvr = worldPos.y * _VertexGlitchDensity - _Time.x * _VertexGlitchMapPanSpeed;
float glitchAmountLeft = tex2Dlod(_VertexGlitchMap, float4(uvl, uvl, 0, 0)).r;
float glitchAmountRight = -tex2Dlod(_VertexGlitchMap, float4(uvr, uvr, 0, 0)).r;
float glitchAmount = glitchAmountLeft + glitchAmountRight;
*/
float time = _Time.y * _VertexGlitchFrequency;
float randomGlitch = (sin(time) + sin(2.2 * time + 5.52) + sin(2.9 * time + 0.93) + sin(4.6 * time + 8.94)) / 4;
worldPos.xyz += glitchAmount * glitchDirection * (_VertexGlitchStrength * .01) * step(_VertexGlitchThreshold, randomGlitch);
localPos = mul(unity_WorldToObject, worldPos);
}
}
#endif
//
|