-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHolisticWaves.shader
More file actions
58 lines (52 loc) · 1.65 KB
/
Copy pathHolisticWaves.shader
File metadata and controls
58 lines (52 loc) · 1.65 KB
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
Shader "Holistic/Waves"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Color ("Tint Color", Color) = (1,1,1,1)
_Freq ("Frequency", Range(0, 100)) = 12
_Amplitude ("Amplitede", Range(0, 10)) = 1
_Speed ("Speed", Range(0, 60)) = 10
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert fullforwardshadows vertex:vert
sampler2D _MainTex;
fixed4 _Color;
float _Freq;
float _Amplitude;
float _Speed;
struct Input
{
float2 uv_MainTex;
float3 vertColor;
};
struct appdata
{
float4 vertex: POSITION;
float3 normal: NORMAL;
float4 texcoord: TEXCOORD0;
float4 texcoord1: TEXCOORD1; // You need texcoord1 for the lightmap
float4 texcoord2: TEXCOORD2; // You need texcoord2 for dynamic GI
};
void vert(inout appdata v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input, o);
float t = _Time * _Speed;
float waveHeigh = sin(v.vertex.x * _Freq + t) * _Amplitude;
v.vertex.y = v.vertex.y + waveHeigh;
// Penny's normal calculation is broken anyway
// v.normal = normalize(float3(v.normal.x + waveHeigh, v.normal.y, v.normal.z));
o.vertColor = waveHeigh + 2;
}
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb * IN.vertColor;
}
ENDCG
}
FallBack "Diffuse"
}