Skip to content

Commit cb0a7d7

Browse files
committed
Using a "blue noise" texture instead of the crappy value/white noise, which is somewhat less noticeable (thanks to reddit user ahcookies for the recommendation, and Cristoph Peters for the texture).
Also decided to limit the sample count to 128, as there really wasn't a visual difference compared to 64.
1 parent 380314f commit cb0a7d7

19 files changed

+305
-862
lines changed
212 Bytes
Binary file not shown.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
Shader "Custom/Vegetation"
2+
{
3+
Properties
4+
{
5+
_MainTex ("Base Color", 2D) = "white" {}
6+
[Normal] [NoScaleOffset]
7+
_NormalMap ("Normal Map", 2D) = "bump" {}
8+
_Metallic ("Metallic", Range(0, 1)) = 0
9+
_Gloss ("Gloss", Range(0, 1)) = 0.1336244
10+
11+
[Space(10)] [NoScaleOffset]
12+
_WindNoise ("Wind Noise", 2D) = "gray" {}
13+
_WindNoiseScale ("Wind Noise Position Scale", Float ) = .1
14+
_WindNoiseSpeed ("Wind Noise Speed", Float ) = .1
15+
_WindNoiseStrength ("Wind Noise Strength", Range(0,10)) = .3
16+
17+
[Space(10)]
18+
_Wind_Direction ("Wind_Direction", Vector) = (1,0,1,0)
19+
_WindFrequency ("Wind Frequency", Float ) = 1.5
20+
_WindAmplitude ("Wind Amplitude", Float ) = 0.03
21+
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
22+
}
23+
SubShader
24+
{
25+
Tags { "RenderType" = "TreeTransparentCutout" }
26+
LOD 200
27+
28+
CGPROGRAM
29+
#pragma surface surf Standard vertex:vert alphatest:_Cutoff addshadow fullforwardshadows
30+
31+
#pragma target 3.0
32+
33+
sampler2D _MainTex; uniform float4 _MainTex_ST;
34+
sampler2D _NormalMap;
35+
sampler2D _WindNoise;
36+
37+
struct appdata
38+
{
39+
float4 vertex : POSITION;
40+
float3 normal : NORMAL;
41+
float4 tangent : TANGENT;
42+
float4 color : COLOR;
43+
float2 uv : TEXCOORD0;
44+
float2 texcoord1 : TEXCOORD1;
45+
float2 texcoord2 : TEXCOORD2;
46+
UNITY_VERTEX_INPUT_INSTANCE_ID
47+
};
48+
49+
struct Input
50+
{
51+
float4 pos : SV_POSITION;
52+
float2 texcoord : TEXCOORD0;
53+
54+
UNITY_VERTEX_INPUT_INSTANCE_ID
55+
UNITY_VERTEX_OUTPUT_STEREO
56+
};
57+
58+
fixed4 _Wind_Direction;
59+
half _Metallic;
60+
half _Gloss;
61+
float _WindNoiseScale;
62+
float _WindNoiseSpeed;
63+
float _WindNoiseStrength;
64+
65+
float _WindFrequency;
66+
float _WindAmplitude;
67+
68+
// #pragma instancing_options assumeuniformscaling
69+
UNITY_INSTANCING_CBUFFER_START(Props)
70+
// put more per-instance properties here
71+
UNITY_INSTANCING_CBUFFER_END
72+
73+
void vert(inout appdata v, out Input o)
74+
{
75+
UNITY_INITIALIZE_OUTPUT(Input, o);
76+
UNITY_SETUP_INSTANCE_ID(v);
77+
UNITY_TRANSFER_INSTANCE_ID(v, o);
78+
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
79+
80+
o.texcoord = TRANSFORM_TEX(v.uv, _MainTex);
81+
82+
float3 pos = mul(v.vertex, unity_ObjectToWorld);
83+
float noiseA = tex2Dlod(_WindNoise, float4(pos.xz * _WindNoiseScale + _Time.x * float2(_WindNoiseSpeed, _WindNoiseSpeed), 0.0, 0.0)).r * _WindNoiseStrength;
84+
85+
v.vertex.xyz += (mul(_Wind_Direction.xyz, unity_WorldToObject) * v.color.r * sin(v.color.b*3.141592654 + (_Time.y + noiseA) *_WindFrequency) *_WindAmplitude);
86+
o.pos = UnityObjectToClipPos(v.vertex);
87+
}
88+
89+
void surf(Input IN, inout SurfaceOutputStandard o)
90+
{
91+
fixed4 c = tex2D(_MainTex, IN.texcoord);
92+
o.Albedo = c.rgb;
93+
94+
o.Normal = UnpackNormal(tex2D(_NormalMap, IN.texcoord));
95+
o.Metallic = _Metallic;
96+
o.Smoothness = _Gloss;
97+
o.Alpha = c.a;
98+
}
99+
ENDCG
100+
}
101+
FallBack "Diffuse"
102+
}

Assets/PCSS/Demo/Demo Assets/Palm Trees/Shaders/Vegetation_shader_01_2016.shader.meta renamed to Assets/PCSS/Demo/Demo Assets/Palm Trees/Shaders/Vegetation.shader.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/PCSS/Demo/Demo Assets/Palm Trees/Shaders/Vegetation_shader_01_2016.shader

Lines changed: 0 additions & 709 deletions
This file was deleted.
388 KB
Loading

Assets/PCSS/Demo/Demo Assets/Palm Trees/Textures/Tiling Perlin Noise.png.meta

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
192 Bytes
Binary file not shown.

Assets/PCSS/Demo/PCSS Demo.unity

2.7 KB
Binary file not shown.
0 Bytes
Binary file not shown.

Assets/PCSS/Demo/PCSS Demo/LightingData.asset.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)