-
Notifications
You must be signed in to change notification settings - Fork 3
/
SpeedTreeHDRP_ASE.shader
8868 lines (8097 loc) · 403 KB
/
SpeedTreeHDRP_ASE.shader
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Made with Amplify Shader Editor
// Available at the Unity Asset Store - http://u3d.as/y3X
Shader "Nature/SpeedTreeHDRP_ASE"
{
Properties
{
[HideInInspector] _EmissionColor("Emission Color", Color) = (1,1,1,1)
[HideInInspector] _AlphaCutoff("Alpha Cutoff ", Range(0, 1)) = 0.5
_HueVariation("HueVariation", Color) = (1,0.5,0,0.1019608)
[HideInInspector]_ST_WindBranchWhip("_ST_WindBranchWhip", Vector) = (0,0,0,0)
[HideInInspector]_ST_WindBranchTwitch("_ST_WindBranchTwitch", Vector) = (0,0,0,0)
[HideInInspector]_ST_WindBranchAdherences("_ST_WindBranchAdherences", Vector) = (0,0,0,0)
[HideInInspector]_ST_WindTurbulences("_ST_WindTurbulences", Vector) = (0,0,0,0)
[HideInInspector]_ST_WindBranch("_ST_WindBranch", Vector) = (0,0,0,0)
_GlobalTimerId("GlobalTimerId", Int) = 0
[HideInInspector]_ST_WindFrondRipple("_ST_WindFrondRipple", Vector) = (0,0,0,0)
_MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
_Color("Main Color", Color) = (1,1,1,1)
_Cutoff("Alpha Cutoff", Range( 0 , 1)) = 0.333
_DetailTex("Detail", 2D) = "white" {}
_BumpMap("Normal Map", 2D) = "bump" {}
_Metallic("Metallic", Range( 0 , 1)) = 1
_Smoothness("Smoothness", Range( 0 , 1)) = 0
[Enum(UnityEngine.Rendering.CullMode)]_Cull("Cull", Int) = 0
[ASEEnd][Enum(None,0,Fastest,1,Fast,2,Better,3,Best,4,Palm,5)]_WindQuality("Wind Quality", Int) = 0
[HideInInspector]_ST_WindLeaf2Twitch("_ST_WindLeaf2Twitch", Vector) = (0,0,0,0)
[HideInInspector]_ST_WindLeaf2Tumble("_ST_WindLeaf2Tumble", Vector) = (0,0,0,0)
[HideInInspector]_ST_WindLeaf2Ripple("_ST_WindLeaf2Ripple", Vector) = (0,0,0,0)
[HideInInspector]_ST_WindLeaf1Twitch("_ST_WindLeaf1Twitch", Vector) = (0,0,0,0)
[HideInInspector]_ST_WindLeaf1Tumble("_ST_WindLeaf1Tumble", Vector) = (0,0,0,0)
[HideInInspector]_ST_WindLeaf1Ripple("_ST_WindLeaf1Ripple", Vector) = (0,0,0,0)
[HideInInspector]_ST_WindBranchAnchor("_ST_WindBranchAnchor", Vector) = (0,0,0,0)
[HideInInspector]_ST_WindAnimation("_ST_WindAnimation", Vector) = (0,0,0,0)
[HideInInspector]_ST_WindGlobal("_ST_WindGlobal", Vector) = (0,0,0,0)
[HideInInspector]_ST_WindVector("_ST_WindVector", Vector) = (0,0,0,0)
[HideInInspector] _RenderQueueType("Render Queue Type", Float) = 1
[HideInInspector] [ToggleUI] _AddPrecomputedVelocity("Add Precomputed Velocity", Float) = 1
[HideInInspector] _StencilRef("Stencil Ref", Int) = 0
[HideInInspector] _StencilWriteMask("Stencil Write Mask", Int) = 6
[HideInInspector] _StencilRefDepth("Stencil Ref Depth", Int) = 8
[HideInInspector] _StencilWriteMaskDepth("Stencil Write Mask Depth", Int) = 8
[HideInInspector] _StencilRefMV("Stencil Ref MV", Int) = 40
[HideInInspector] _StencilWriteMaskMV("Stencil Write Mask MV", Int) = 40
[HideInInspector] _StencilRefDistortionVec("Stencil Ref Distortion Vec", Int) = 4
[HideInInspector] _StencilWriteMaskDistortionVec("Stencil Write Mask Distortion Vec", Int) = 4
[HideInInspector] _StencilWriteMaskGBuffer("Stencil Write Mask GBuffer", Int) = 14
[HideInInspector] _StencilRefGBuffer("Stencil Ref GBuffer", Int) = 10
[HideInInspector] _ZTestGBuffer("ZTest GBuffer", Int) = 4
[HideInInspector] [ToggleUI] _RequireSplitLighting("Require Split Lighting", Float) = 0
[HideInInspector] [ToggleUI] _ReceivesSSR("Receives SSR", Float) = 1
[HideInInspector] _SurfaceType("Surface Type", Float) = 0
[HideInInspector] _BlendMode("Blend Mode", Float) = 0
[HideInInspector] _SrcBlend("Src Blend", Float) = 1
[HideInInspector] _DstBlend("Dst Blend", Float) = 0
[HideInInspector] _AlphaSrcBlend("Alpha Src Blend", Float) = 1
[HideInInspector] _AlphaDstBlend("Alpha Dst Blend", Float) = 0
[HideInInspector] [ToggleUI] _ZWrite("ZWrite", Float) = 1
[HideInInspector] [ToggleUI] _TransparentZWrite("Transparent ZWrite", Float) = 1
[HideInInspector] _CullMode("Cull Mode", Float) = 2
[HideInInspector] _TransparentSortPriority("Transparent Sort Priority", Int) = 0
[HideInInspector] [ToggleUI] _EnableFogOnTransparent("Enable Fog On Transparent", Float) = 1
[HideInInspector] _CullModeForward("Cull Mode Forward", Float) = 2
[HideInInspector] [Enum(Front, 1, Back, 2)] _TransparentCullMode("Transparent Cull Mode", Float) = 2
[HideInInspector] _ZTestDepthEqualForOpaque("ZTest Depth Equal For Opaque", Int) = 4
[HideInInspector] [Enum(UnityEngine.Rendering.CompareFunction)] _ZTestTransparent("ZTest Transparent", Float) = 4
[HideInInspector] [ToggleUI] _TransparentBackfaceEnable("Transparent Backface Enable", Float) = 0
[HideInInspector] [ToggleUI] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 1
[HideInInspector] [ToggleUI] _UseShadowThreshold("Use Shadow Threshold", Float) = 0
[HideInInspector] [ToggleUI] _DoubleSidedEnable("Double Sided Enable", Float) = 0
[HideInInspector] [Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double Sided Normal Mode", Float) = 2
[HideInInspector] _DoubleSidedConstants("DoubleSidedConstants", Vector) = (1,1,-1,0)
//_TessPhongStrength( "Tess Phong Strength", Range( 0, 1 ) ) = 0.5
//_TessValue( "Tess Max Tessellation", Range( 1, 32 ) ) = 16
//_TessMin( "Tess Min Distance", Float ) = 10
//_TessMax( "Tess Max Distance", Float ) = 25
//_TessEdgeLength ( "Tess Edge length", Range( 2, 50 ) ) = 16
//_TessMaxDisp( "Tess Max Displacement", Float ) = 25
}
SubShader
{
LOD 0
Tags { "RenderPipeline"="HDRenderPipeline" "RenderType"="Opaque" "Queue"="Geometry" }
HLSLINCLUDE
#pragma target 4.5
#pragma only_renderers d3d11 ps4 xboxone vulkan metal switch
#pragma multi_compile_instancing
#pragma instancing_options renderinglayer
struct GlobalSurfaceDescription // GBuffer Forward META TransparentBackface
{
float3 Albedo;
float3 Normal;
float3 BentNormal;
float3 Specular;
float CoatMask;
float Metallic;
float3 Emission;
float Smoothness;
float Occlusion;
float Alpha;
float AlphaClipThreshold;
float AlphaClipThresholdShadow;
float AlphaClipThresholdDepthPrepass;
float AlphaClipThresholdDepthPostpass;
float SpecularAAScreenSpaceVariance;
float SpecularAAThreshold;
float SpecularOcclusion;
float DepthOffset;
//Refraction
float RefractionIndex;
float3 RefractionColor;
float RefractionDistance;
//SSS/Translucent
float Thickness;
float SubsurfaceMask;
float DiffusionProfile;
//Anisotropy
float Anisotropy;
float3 Tangent;
//Iridescent
float IridescenceMask;
float IridescenceThickness;
//BakedGI
float3 BakedGI;
float3 BakedBackGI;
};
struct AlphaSurfaceDescription // ShadowCaster
{
float Alpha;
float AlphaClipThreshold;
float AlphaClipThresholdShadow;
float DepthOffset;
};
struct SceneSurfaceDescription // SceneSelection
{
float Alpha;
float AlphaClipThreshold;
float DepthOffset;
};
struct PrePassSurfaceDescription // DepthPrePass
{
float Alpha;
float AlphaClipThresholdDepthPrepass;
float DepthOffset;
};
struct PostPassSurfaceDescription //DepthPostPass
{
float Alpha;
float AlphaClipThresholdDepthPostpass;
float DepthOffset;
};
struct SmoothSurfaceDescription // MotionVectors DepthOnly
{
float3 Normal;
float Smoothness;
float Alpha;
float AlphaClipThreshold;
float DepthOffset;
};
struct DistortionSurfaceDescription //Distortion
{
float Alpha;
float2 Distortion;
float DistortionBlur;
float AlphaClipThreshold;
};
float4 FixedTess( float tessValue )
{
return tessValue;
}
float CalcDistanceTessFactor (float4 vertex, float minDist, float maxDist, float tess, float4x4 o2w, float3 cameraPos )
{
float3 wpos = mul(o2w,vertex).xyz;
float dist = distance (wpos, cameraPos);
float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0) * tess;
return f;
}
float4 CalcTriEdgeTessFactors (float3 triVertexFactors)
{
float4 tess;
tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z);
tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z);
tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y);
tess.w = (triVertexFactors.x + triVertexFactors.y + triVertexFactors.z) / 3.0f;
return tess;
}
float CalcEdgeTessFactor (float3 wpos0, float3 wpos1, float edgeLen, float3 cameraPos, float4 scParams )
{
float dist = distance (0.5 * (wpos0+wpos1), cameraPos);
float len = distance(wpos0, wpos1);
float f = max(len * scParams.y / (edgeLen * dist), 1.0);
return f;
}
float DistanceFromPlaneASE (float3 pos, float4 plane)
{
return dot (float4(pos,1.0f), plane);
}
bool WorldViewFrustumCull (float3 wpos0, float3 wpos1, float3 wpos2, float cullEps, float4 planes[6] )
{
float4 planeTest;
planeTest.x = (( DistanceFromPlaneASE(wpos0, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
(( DistanceFromPlaneASE(wpos1, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
(( DistanceFromPlaneASE(wpos2, planes[0]) > -cullEps) ? 1.0f : 0.0f );
planeTest.y = (( DistanceFromPlaneASE(wpos0, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
(( DistanceFromPlaneASE(wpos1, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
(( DistanceFromPlaneASE(wpos2, planes[1]) > -cullEps) ? 1.0f : 0.0f );
planeTest.z = (( DistanceFromPlaneASE(wpos0, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
(( DistanceFromPlaneASE(wpos1, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
(( DistanceFromPlaneASE(wpos2, planes[2]) > -cullEps) ? 1.0f : 0.0f );
planeTest.w = (( DistanceFromPlaneASE(wpos0, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
(( DistanceFromPlaneASE(wpos1, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
(( DistanceFromPlaneASE(wpos2, planes[3]) > -cullEps) ? 1.0f : 0.0f );
return !all (planeTest);
}
float4 DistanceBasedTess( float4 v0, float4 v1, float4 v2, float tess, float minDist, float maxDist, float4x4 o2w, float3 cameraPos )
{
float3 f;
f.x = CalcDistanceTessFactor (v0,minDist,maxDist,tess,o2w,cameraPos);
f.y = CalcDistanceTessFactor (v1,minDist,maxDist,tess,o2w,cameraPos);
f.z = CalcDistanceTessFactor (v2,minDist,maxDist,tess,o2w,cameraPos);
return CalcTriEdgeTessFactors (f);
}
float4 EdgeLengthBasedTess( float4 v0, float4 v1, float4 v2, float edgeLength, float4x4 o2w, float3 cameraPos, float4 scParams )
{
float3 pos0 = mul(o2w,v0).xyz;
float3 pos1 = mul(o2w,v1).xyz;
float3 pos2 = mul(o2w,v2).xyz;
float4 tess;
tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
return tess;
}
float4 EdgeLengthBasedTessCull( float4 v0, float4 v1, float4 v2, float edgeLength, float maxDisplacement, float4x4 o2w, float3 cameraPos, float4 scParams, float4 planes[6] )
{
float3 pos0 = mul(o2w,v0).xyz;
float3 pos1 = mul(o2w,v1).xyz;
float3 pos2 = mul(o2w,v2).xyz;
float4 tess;
if (WorldViewFrustumCull(pos0, pos1, pos2, maxDisplacement, planes))
{
tess = 0.0f;
}
else
{
tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
tess.w = (tess.x + tess.y + tess.z) / 3.0f;
}
return tess;
}
ENDHLSL
Pass
{
Name "GBuffer"
Tags { "LightMode"="GBuffer" }
Cull [_Cull]
ZTest [_ZTestGBuffer]
Stencil
{
Ref [_StencilRefGBuffer]
WriteMask [_StencilWriteMaskGBuffer]
Comp Always
Pass Replace
Fail Keep
ZFail Keep
}
HLSLPROGRAM
#define _SPECULAR_OCCLUSION_FROM_AO 1
#define ASE_ABSOLUTE_VERTEX_POS 1
#define HAVE_MESH_MODIFICATION
#define ASE_SRP_VERSION 100202
#pragma shader_feature _SURFACE_TYPE_TRANSPARENT
#pragma shader_feature_local _DOUBLESIDED_ON
#pragma shader_feature_local _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY
#pragma shader_feature_local _ENABLE_FOG_ON_TRANSPARENT
#pragma shader_feature_local _ALPHATEST_ON
#if !defined(DEBUG_DISPLAY) && defined(_ALPHATEST_ON)
#define SHADERPASS_GBUFFER_BYPASS_ALPHA_TEST
#endif
#define SHADERPASS SHADERPASS_GBUFFER
#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
#pragma multi_compile _ LIGHT_LAYERS
#pragma vertex Vert
#pragma fragment Frag
//#define UNITY_MATERIAL_LIT
#if defined(_MATERIAL_FEATURE_SUBSURFACE_SCATTERING) && !defined(_SURFACE_TYPE_TRANSPARENT)
#define OUTPUT_SPLIT_LIGHTING
#endif
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/NormalSurfaceGradient.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphHeader.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#ifdef DEBUG_DISPLAY
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
#endif
CBUFFER_START( UnityPerMaterial )
float4 _ST_WindLeaf1Tumble;
float4 _HueVariation;
float4 _ST_WindBranchAnchor;
float4 _ST_WindVector;
float4 _Color;
float4 _ST_WindBranchTwitch;
float4 _ST_WindLeaf1Twitch;
float4 _ST_WindLeaf2Ripple;
float4 _ST_WindLeaf2Tumble;
float4 _ST_WindBranch;
float4 _ST_WindBranchWhip;
float4 _ST_WindLeaf2Twitch;
float4 _ST_WindGlobal;
float4 _ST_WindBranchAdherences;
float4 _ST_WindFrondRipple;
float4 _ST_WindAnimation;
float4 _ST_WindTurbulences;
float4 _ST_WindLeaf1Ripple;
float _Metallic;
int _WindQuality;
int _GlobalTimerId;
float _Cutoff;
int _Cull;
float _Smoothness;
float4 _EmissionColor;
float _AlphaCutoff;
float _RenderQueueType;
#ifdef _ADD_PRECOMPUTED_VELOCITY
float _AddPrecomputedVelocity;
#endif
float _StencilRef;
float _StencilWriteMask;
float _StencilRefDepth;
float _StencilWriteMaskDepth;
float _StencilRefMV;
float _StencilWriteMaskMV;
float _StencilRefDistortionVec;
float _StencilWriteMaskDistortionVec;
float _StencilWriteMaskGBuffer;
float _StencilRefGBuffer;
float _ZTestGBuffer;
float _RequireSplitLighting;
float _ReceivesSSR;
float _SurfaceType;
float _BlendMode;
float _SrcBlend;
float _DstBlend;
float _AlphaSrcBlend;
float _AlphaDstBlend;
float _ZWrite;
float _TransparentZWrite;
float _CullMode;
float _TransparentSortPriority;
float _EnableFogOnTransparent;
float _CullModeForward;
float _TransparentCullMode;
float _ZTestDepthEqualForOpaque;
float _ZTestTransparent;
float _TransparentBackfaceEnable;
float _AlphaCutoffEnable;
float _UseShadowThreshold;
float _DoubleSidedEnable;
float _DoubleSidedNormalMode;
float4 _DoubleSidedConstants;
#ifdef TESSELLATION_ON
float _TessPhongStrength;
float _TessValue;
float _TessMin;
float _TessMax;
float _TessEdgeLength;
float _TessMaxDisp;
#endif
CBUFFER_END
float4 _GlobalTimers[100];
sampler2D _MainTex;
sampler2D _DetailTex;
sampler2D _BumpMap;
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalUtilities.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
#define ASE_NEEDS_VERT_POSITION
#define ASE_NEEDS_VERT_NORMAL
#define ASE_NEEDS_FRAG_NORMAL
#define ASE_NEEDS_FRAG_COLOR
#pragma shader_feature_local GEOM_TYPE_BRANCH GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_BRANCH_DETAIL
#pragma shader_feature_local EFFECT_HUE_VARIATION
#pragma shader_feature_local GEOM_TYPE_BRANCH_DETAIL
#pragma shader_feature_local EFFECT_BUMP
#if defined(_DOUBLESIDED_ON) && !defined(ASE_NEED_CULLFACE)
#define ASE_NEED_CULLFACE 1
#endif
struct AttributesMesh
{
float3 positionOS : POSITION;
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
float4 uv1 : TEXCOORD1;
float4 uv2 : TEXCOORD2;
float4 ase_texcoord : TEXCOORD0;
float4 ase_color : COLOR;
float4 ase_texcoord3 : TEXCOORD3;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct PackedVaryingsMeshToPS
{
float4 positionCS : SV_Position;
float3 interp00 : TEXCOORD0;
float3 interp01 : TEXCOORD1;
float4 interp02 : TEXCOORD2;
float4 interp03 : TEXCOORD3;
float4 interp04 : TEXCOORD4;
float4 ase_texcoord5 : TEXCOORD5;
float4 ase_color : COLOR;
float4 ase_texcoord6 : TEXCOORD6;
float3 ase_normal : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
#if defined(SHADER_STAGE_FRAGMENT) && defined(ASE_NEED_CULLFACE)
FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
#endif
};
void CalculateWindInputs( float windQuality, out float3 rotatedWindVector, out float3 rotatedBranchAnchor, float4 windVector, float4 windBranchAnchor )
{
if (windQuality <= 0) // WIND_QUALITY_NONE
{
rotatedWindVector = float3(0.0f, 0.0f, 0.0f);
rotatedBranchAnchor = float3(0.0f, 0.0f, 0.0f);
}
else
{
// compute rotated wind parameters
if (length(windVector) > 0) {
rotatedWindVector = normalize(mul(windVector.xyz, (float3x3)UNITY_MATRIX_M));
} else {
rotatedWindVector = 0;
}
rotatedBranchAnchor = normalize(mul(windBranchAnchor.xyz, (float3x3)UNITY_MATRIX_M)) * windBranchAnchor.w;
}
}
float3 OffsetLeavesVertex( float3 VertexPos, float ColorAlpha, float3 texcoord1, float2 texcoord3 )
{
float lodValue = unity_LODFade.x;
VertexPos -= texcoord1.xyz;
bool isFacingLeaf = ColorAlpha == 0;
if (isFacingLeaf) {
#ifdef LOD_FADE_PERCENTAGE
VertexPos *= lerp(1.0, texcoord1.w, lodValue);
#endif
// face camera-facing leaf to camera
float offsetLen = length(VertexPos);
VertexPos = mul(VertexPos.xyz, (float3x3) transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V))); // inv(MV) * finalPosition
VertexPos = normalize(VertexPos) * offsetLen; // make sure the offset vector is still scaled
}
else
{
#ifdef LOD_FADE_PERCENTAGE
float3 lodPosition = float3(texcoord1.w, texcoord3.x, texcoord3.y);
VertexPos = lerp(VertexPos, lodPosition, lodValue);
#endif
}
return VertexPos;
}
float4 CubicSmooth( float4 vData )
{
return vData * vData * (3.0 - 2.0 * vData);
}
float4 TriangleWave( float4 vData )
{
return abs((frac(vData + 0.5) * 2.0) - 1.0);
}
float3 UnpackNormalFromFloat( float3 fValue )
{
float3 vDecodeKey = float3(16.0, 1.0, 0.0625);
// decode into [0,1] range
float3 vDecodedValue = frac(fValue / vDecodeKey);
// move back into [-1,1] range & normalize
return (vDecodedValue * 2.0 - 1.0);
}
float3 ClampToNonZero( float3 data )
{
if (length(data) > 0) {
return data;
} else {
return float3(0.0001, 0.0001, 0.0001);
}
}
float4 ComplexOscillationInputs( float fTime, float fOffset, float fTwitchFreqScale, float fWeight, int bWhip )
{
if (bWhip > 0) {
return float4(fTime + fOffset, fTime * fTwitchFreqScale + fOffset, fTwitchFreqScale * 0.5 * (fTime + fOffset), fTime + fOffset + (1.0 - fWeight));
} else {
return float4(fTime + fOffset, fTime * fTwitchFreqScale + fOffset, fTwitchFreqScale * 0.5 * (fTime + fOffset), 0.0);
}
}
float4 SimpleOscillationInputs( float fTime, float fOffset, float fWeight, int bWhip )
{
if (bWhip)
return float4(fTime + fOffset, fTime * 0.689 + fOffset, 0.0, fTime + fOffset + (1.0 - fWeight));
else
return float4(fTime + fOffset, fTime * 0.689 + fOffset, 0.0, 0.0);
}
float3 GetInstancePos( )
{
return GetAbsolutePositionWS(float3(UNITY_MATRIX_M[0].w, UNITY_MATRIX_M[1].w, UNITY_MATRIX_M[2].w));
}
float ComputeWindAdjust( float3 vPos, float4 windGlobal )
{
// compute how much the height contributes
float fAdjust = max(vPos.y - (1.0 / windGlobal.z) * 0.25, 0.0) * windGlobal.z;
if (fAdjust != 0.0) {
float s = sign(fAdjust);
fAdjust = pow(abs(fAdjust), windGlobal.w) * s;
}
return fAdjust;
}
float3 SwizzleCombineMoveAmount( float3 vPos, float3 vRotatedWindVector, float fMoveAmount )
{
float fLength = length(vPos);
vPos.xz += vRotatedWindVector.xz * fMoveAmount;
vPos.xyz = normalize(vPos.xyz) * fLength;
return vPos;
}
float3x3 RotationMatrix( float3 vAxis, float fAngle )
{
// compute sin/cos of fAngle
float2 vSinCos;
#ifdef OPENGL
vSinCos.x = sin(fAngle);
vSinCos.y = cos(fAngle);
#else
sincos(fAngle, vSinCos.x, vSinCos.y);
#endif
const float c = vSinCos.y;
const float s = vSinCos.x;
const float t = 1.0 - c;
const float x = vAxis.x;
const float y = vAxis.y;
const float z = vAxis.z;
return float3x3(t * x * x + c, t * x * y - s * z, t * x * z + s * y,
t * x * y + s * z, t * y * y + c, t * y * z - s * x,
t * x * z - s * y, t * y * z + s * x, t * z * z + c);
}
void BuildSurfaceData(FragInputs fragInputs, inout GlobalSurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData, out float3 bentNormalWS)
{
ZERO_INITIALIZE(SurfaceData, surfaceData);
surfaceData.specularOcclusion = 1.0;
// surface data
surfaceData.baseColor = surfaceDescription.Albedo;
surfaceData.perceptualSmoothness = surfaceDescription.Smoothness;
surfaceData.ambientOcclusion = surfaceDescription.Occlusion;
surfaceData.metallic = surfaceDescription.Metallic;
surfaceData.coatMask = surfaceDescription.CoatMask;
#ifdef _SPECULAR_OCCLUSION_CUSTOM
surfaceData.specularOcclusion = surfaceDescription.SpecularOcclusion;
#endif
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
surfaceData.subsurfaceMask = surfaceDescription.SubsurfaceMask;
#endif
#if defined(_HAS_REFRACTION) || defined(_MATERIAL_FEATURE_TRANSMISSION)
surfaceData.thickness = surfaceDescription.Thickness;
#endif
#if defined( _MATERIAL_FEATURE_SUBSURFACE_SCATTERING ) || defined( _MATERIAL_FEATURE_TRANSMISSION )
surfaceData.diffusionProfileHash = asuint(surfaceDescription.DiffusionProfile);
#endif
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
surfaceData.specularColor = surfaceDescription.Specular;
#endif
#ifdef _MATERIAL_FEATURE_ANISOTROPY
surfaceData.anisotropy = surfaceDescription.Anisotropy;
#endif
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
surfaceData.iridescenceMask = surfaceDescription.IridescenceMask;
surfaceData.iridescenceThickness = surfaceDescription.IridescenceThickness;
#endif
// refraction
#ifdef _HAS_REFRACTION
if( _EnableSSRefraction )
{
surfaceData.ior = surfaceDescription.RefractionIndex;
surfaceData.transmittanceColor = surfaceDescription.RefractionColor;
surfaceData.atDistance = surfaceDescription.RefractionDistance;
surfaceData.transmittanceMask = ( 1.0 - surfaceDescription.Alpha );
surfaceDescription.Alpha = 1.0;
}
else
{
surfaceData.ior = 1.0;
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
surfaceData.atDistance = 1.0;
surfaceData.transmittanceMask = 0.0;
surfaceDescription.Alpha = 1.0;
}
#else
surfaceData.ior = 1.0;
surfaceData.transmittanceColor = float3( 1.0, 1.0, 1.0 );
surfaceData.atDistance = 1.0;
surfaceData.transmittanceMask = 0.0;
#endif
// material features
surfaceData.materialFeatures = MATERIALFEATUREFLAGS_LIT_STANDARD;
#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING;
#endif
#ifdef _MATERIAL_FEATURE_TRANSMISSION
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_TRANSMISSION;
#endif
#ifdef _MATERIAL_FEATURE_ANISOTROPY
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_ANISOTROPY;
#endif
#ifdef ASE_LIT_CLEAR_COAT
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_CLEAR_COAT;
#endif
#ifdef _MATERIAL_FEATURE_IRIDESCENCE
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_IRIDESCENCE;
#endif
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR;
#endif
// others
#if defined (_MATERIAL_FEATURE_SPECULAR_COLOR) && defined (_ENERGY_CONSERVING_SPECULAR)
surfaceData.baseColor *= ( 1.0 - Max3( surfaceData.specularColor.r, surfaceData.specularColor.g, surfaceData.specularColor.b ) );
#endif
#ifdef _DOUBLESIDED_ON
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
#else
float3 doubleSidedConstants = float3( 1.0, 1.0, 1.0 );
#endif
// normals
float3 normalTS = float3(0.0f, 0.0f, 1.0f);
normalTS = surfaceDescription.Normal;
GetNormalWS( fragInputs, normalTS, surfaceData.normalWS, doubleSidedConstants );
surfaceData.geomNormalWS = fragInputs.tangentToWorld[2];
bentNormalWS = surfaceData.normalWS;
#ifdef ASE_BENT_NORMAL
GetNormalWS( fragInputs, surfaceDescription.BentNormal, bentNormalWS, doubleSidedConstants );
#endif
surfaceData.tangentWS = normalize( fragInputs.tangentToWorld[ 0 ].xyz );
#ifdef _MATERIAL_FEATURE_ANISOTROPY
surfaceData.tangentWS = TransformTangentToWorld( surfaceDescription.Tangent, fragInputs.tangentToWorld );
#endif
surfaceData.tangentWS = Orthonormalize( surfaceData.tangentWS, surfaceData.normalWS );
// decals
#if HAVE_DECALS
if( _EnableDecals )
{
DecalSurfaceData decalSurfaceData = GetDecalSurfaceData(posInput, fragInputs.tangentToWorld[2], surfaceDescription.Alpha);
ApplyDecalToSurfaceData(decalSurfaceData, fragInputs.tangentToWorld[2], surfaceData);
}
#endif
#if defined(_SPECULAR_OCCLUSION_CUSTOM)
#elif defined(_SPECULAR_OCCLUSION_FROM_AO_BENT_NORMAL)
surfaceData.specularOcclusion = GetSpecularOcclusionFromBentAO( V, bentNormalWS, surfaceData.normalWS, surfaceData.ambientOcclusion, PerceptualSmoothnessToPerceptualRoughness( surfaceData.perceptualSmoothness ) );
#elif defined(_AMBIENT_OCCLUSION) && defined(_SPECULAR_OCCLUSION_FROM_AO)
surfaceData.specularOcclusion = GetSpecularOcclusionFromAmbientOcclusion( ClampNdotV( dot( surfaceData.normalWS, V ) ), surfaceData.ambientOcclusion, PerceptualSmoothnessToRoughness( surfaceData.perceptualSmoothness ) );
#endif
#ifdef _ENABLE_GEOMETRIC_SPECULAR_AA
surfaceData.perceptualSmoothness = GeometricNormalFiltering( surfaceData.perceptualSmoothness, fragInputs.tangentToWorld[ 2 ], surfaceDescription.SpecularAAScreenSpaceVariance, surfaceDescription.SpecularAAThreshold );
#endif
// debug
#if defined(DEBUG_DISPLAY)
if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
{
surfaceData.metallic = 0;
}
ApplyDebugToSurfaceData(fragInputs.tangentToWorld, surfaceData);
#endif
}
void GetSurfaceAndBuiltinData(GlobalSurfaceDescription surfaceDescription, FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
{
#ifdef LOD_FADE_CROSSFADE
LODDitheringTransition(ComputeFadeMaskSeed(V, posInput.positionSS), unity_LODFade.x);
#endif
#ifdef _DOUBLESIDED_ON
float3 doubleSidedConstants = _DoubleSidedConstants.xyz;
#else
float3 doubleSidedConstants = float3( 1.0, 1.0, 1.0 );
#endif
ApplyDoubleSidedFlipOrMirror( fragInputs, doubleSidedConstants );
#ifdef _ALPHATEST_ON
DoAlphaTest( surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold );
#endif
#ifdef _DEPTHOFFSET_ON
builtinData.depthOffset = surfaceDescription.DepthOffset;
ApplyDepthOffsetPositionInput( V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput );
#endif
float3 bentNormalWS;
BuildSurfaceData( fragInputs, surfaceDescription, V, posInput, surfaceData, bentNormalWS );
InitBuiltinData( posInput, surfaceDescription.Alpha, bentNormalWS, -fragInputs.tangentToWorld[ 2 ], fragInputs.texCoord1, fragInputs.texCoord2, builtinData );
#ifdef _ASE_BAKEDGI
builtinData.bakeDiffuseLighting = surfaceDescription.BakedGI;
#endif
#ifdef _ASE_BAKEDBACKGI
builtinData.backBakeDiffuseLighting = surfaceDescription.BakedBackGI;
#endif
builtinData.emissiveColor = surfaceDescription.Emission;
#if (SHADERPASS == SHADERPASS_DISTORTION)
builtinData.distortion = surfaceDescription.Distortion;
builtinData.distortionBlur = surfaceDescription.DistortionBlur;
#else
builtinData.distortion = float2(0.0, 0.0);
builtinData.distortionBlur = 0.0;
#endif
PostInitBuiltinData(V, posInput, surfaceData, builtinData);
}
PackedVaryingsMeshToPS VertexFunction(AttributesMesh inputMesh )
{
PackedVaryingsMeshToPS outputPackedVaryingsMeshToPS;
UNITY_SETUP_INSTANCE_ID(inputMesh);
UNITY_TRANSFER_INSTANCE_ID(inputMesh, outputPackedVaryingsMeshToPS);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( outputPackedVaryingsMeshToPS );
float3 temp_output_1_0_g4 = inputMesh.positionOS;
float3 appendResult213 = (float3(inputMesh.uv1.xyz));
float3 lerpResult13_g4 = lerp( temp_output_1_0_g4 , appendResult213 , unity_LODFade.x);
#ifdef LOD_FADE_PERCENTAGE
float3 staticSwitch14_g4 = lerpResult13_g4;
#else
float3 staticSwitch14_g4 = temp_output_1_0_g4;
#endif
float3 temp_output_344_0 = staticSwitch14_g4;
float3 appendResult331 = (float3(inputMesh.uv2.xyz));
float2 appendResult336 = (float2(inputMesh.ase_texcoord.xy));
float2 break10_g314 = appendResult336;
float ifLocalVar11_g314 = 0;
UNITY_BRANCH
if( break10_g314.x >= 0.75 )
ifLocalVar11_g314 = break10_g314.x;
else
ifLocalVar11_g314 = 0.75;
float4 temp_cast_3 = (( ifLocalVar11_g314 + ( ( _GlobalTimers[_GlobalTimerId].y + break10_g314.y ) * _ST_WindFrondRipple.z ) )).xxxx;
float4 vData7_g316 = temp_cast_3;
float4 localTriangleWave7_g316 = TriangleWave( vData7_g316 );
float4 vData6_g316 = localTriangleWave7_g316;
float4 localCubicSmooth6_g316 = CubicSmooth( vData6_g316 );
#ifdef GEOM_TYPE_FROND
float3 staticSwitch343 = ( temp_output_344_0 + ( appendResult331.y * ( ( localCubicSmooth6_g316 + float4( -0.5,-0.5,-0.5,-0.5 ) ) * float4( 2,2,2,2 ) ).x * _ST_WindFrondRipple.y * inputMesh.normalOS ) );
#else
float3 staticSwitch343 = temp_output_344_0;
#endif
int temp_output_40_0_g300 = _WindQuality;
float3 VertexPos286 = inputMesh.positionOS;
float3 appendResult112 = (float3(_Color.r , _Color.g , _Color.b));
float4 appendResult281 = (float4(( appendResult112 * inputMesh.ase_color.r ) , _Color.a));
float4 appendResult243 = (float4(appendResult281));
float ColorAlpha286 = appendResult243.a;
float3 texcoord1286 = appendResult213;
float2 texcoord3286 = inputMesh.ase_texcoord3.xy;
float3 localOffsetLeavesVertex286 = OffsetLeavesVertex( VertexPos286 , ColorAlpha286 , texcoord1286 , texcoord3286 );
float3 temp_output_6_0_g300 = localOffsetLeavesVertex286;
int temp_output_2_0_g301 = temp_output_40_0_g300;
float4 break25_g300 = inputMesh.uv2;
float3 temp_cast_5 = (break25_g300.z).xxx;
float3 fValue10_g305 = temp_cast_5;
float3 localUnpackNormalFromFloat10_g305 = UnpackNormalFromFloat( fValue10_g305 );
float temp_output_4_0_g301 = break25_g300.w;
float ifLocalVar19_g301 = 0;
if( temp_output_4_0_g301 <= 0.0 )
ifLocalVar19_g301 = _ST_WindLeaf1Ripple.y;
else
ifLocalVar19_g301 = _ST_WindLeaf2Ripple.y;
float2 break24_g300 = appendResult213.xy;
float4 break18_g301 = _GlobalTimers[_GlobalTimerId];
float4 appendResult10_g303 = (float4(( ( break24_g300.x + break24_g300.y ) + break18_g301.y ) , 0.0 , 0.0 , 0.0));
float4 vData7_g304 = appendResult10_g303;
float4 localTriangleWave7_g304 = TriangleWave( vData7_g304 );
float4 vData6_g304 = localTriangleWave7_g304;
float4 localCubicSmooth6_g304 = CubicSmooth( vData6_g304 );
float temp_output_8_0_g301 = break25_g300.x;
float3 temp_output_52_0_g301 = ( temp_output_6_0_g300 + ( localUnpackNormalFromFloat10_g305 * ( ifLocalVar19_g301 * ( ( localCubicSmooth6_g304 + float4( -0.5,-0.5,-0.5,-0.5 ) ) * float4( 2,2,2,2 ) ).x ) * temp_output_8_0_g301 ) );
float temp_output_10_0_g301 = break25_g300.y;
float3 temp_cast_7 = (temp_output_10_0_g301).xxx;
float3 fValue10_g313 = temp_cast_7;
float3 localUnpackNormalFromFloat10_g313 = UnpackNormalFromFloat( fValue10_g313 );
float3 temp_output_5_0_g306 = localUnpackNormalFromFloat10_g313;
float3 vAxis6_g309 = temp_output_5_0_g306;
float temp_output_3_0_g306 = temp_output_8_0_g301;
float4 ifLocalVar32_g301 = 0;
if( temp_output_4_0_g301 <= 0.0 )
ifLocalVar32_g301 = _ST_WindLeaf1Tumble;
else
ifLocalVar32_g301 = _ST_WindLeaf2Tumble;
float4 break34_g301 = ifLocalVar32_g301;
float temp_output_22_0_g306 = frac( ( temp_output_10_0_g301 * 30.3 ) );
float temp_output_25_0_g306 = ( temp_output_22_0_g306 + temp_output_22_0_g306 + temp_output_22_0_g306 );
float temp_output_7_0_g306 = break18_g301.z;
float4 appendResult34_g306 = (float4(( temp_output_25_0_g306 + temp_output_7_0_g306 ) , ( ( temp_output_7_0_g306 * 0.75 ) + ( temp_output_25_0_g306 * -1.0 ) ) , ( ( temp_output_7_0_g306 * 0.01 ) + temp_output_25_0_g306 ) , ( temp_output_25_0_g306 + ( temp_output_7_0_g306 * 1.0 ) )));
float4 vData7_g308 = appendResult34_g306;
float4 localTriangleWave7_g308 = TriangleWave( vData7_g308 );
float4 vData6_g308 = localTriangleWave7_g308;
float4 localCubicSmooth6_g308 = CubicSmooth( vData6_g308 );
float4 temp_output_27_0_g306 = ( ( localCubicSmooth6_g308 + float4( -0.5,-0.5,-0.5,-0.5 ) ) * float4( 2,2,2,2 ) );
float4 break47_g306 = temp_output_27_0_g306;
float fAngle6_g309 = ( temp_output_3_0_g306 * break34_g301.z * ( break47_g306.x + ( break47_g306.y * break47_g306.y ) ) );
float3x3 localRotationMatrix6_g309 = RotationMatrix( vAxis6_g309 , fAngle6_g309 );
int localCalculateWindInputs291 = ( 0 );
float windQuality291 = (float)_WindQuality;
float3 rotatedWindVector291 = float3( 0,0,0 );
float3 rotatedBranchAnchor291 = float3( 0,0,0 );
float4 windVector291 = _ST_WindVector;
float4 windBranchAnchor291 = _ST_WindBranchAnchor;
{
if (windQuality291 <= 0) // WIND_QUALITY_NONE
{
rotatedWindVector291 = float3(0.0f, 0.0f, 0.0f);
rotatedBranchAnchor291 = float3(0.0f, 0.0f, 0.0f);
}
else
{
// compute rotated wind parameters
if (length(windVector291) > 0) {
rotatedWindVector291 = normalize(mul(windVector291.xyz, (float3x3)UNITY_MATRIX_M));
} else {
rotatedWindVector291 = 0;
}
rotatedBranchAnchor291 = normalize(mul(windBranchAnchor291.xyz, (float3x3)UNITY_MATRIX_M)) * windBranchAnchor291.w;
}
}
float3 data116_g306 = rotatedWindVector291;
float3 localClampToNonZero116_g306 = ClampToNonZero( data116_g306 );
float3 break57_g306 = cross( temp_output_5_0_g306 , localClampToNonZero116_g306 );
float dotResult55_g306 = dot( float3( 0,0,0 ) , temp_output_5_0_g306 );
float clampResult56_g306 = clamp( dotResult55_g306 , -1.0 , 1.0 );
float3 appendResult59_g306 = (float3(break57_g306.x , ( clampResult56_g306 + break57_g306.y ) , break57_g306.z));
float3 normalizeResult60_g306 = normalize( appendResult59_g306 );
float3 vAxis6_g312 = normalizeResult60_g306;
float3 break9_g310 = float3( 0,0,0 );
float temp_output_4_0_g310 = ( _GlobalTimers[_GlobalTimerId].y + temp_output_25_0_g306 );
float4 appendResult12_g310 = (float4(( break9_g310.x + break9_g310.z + temp_output_4_0_g310 ) , ( ( 0.87 * temp_output_4_0_g310 ) + break9_g310.y ) , 0.0 , 0.0));
float4 vData7_g311 = appendResult12_g310;
float4 localTriangleWave7_g311 = TriangleWave( vData7_g311 );
float4 vData6_g311 = localTriangleWave7_g311;
float4 localCubicSmooth6_g311 = CubicSmooth( vData6_g311 );
float4 break14_g310 = ( ( localCubicSmooth6_g311 + float4( -0.5,-0.5,-0.5,-0.5 ) ) * float4( 2,2,2,2 ) );
float4 ifLocalVar35_g301 = 0;
if( temp_output_4_0_g301 <= 0.0 )
ifLocalVar35_g301 = _ST_WindLeaf1Twitch;
else
ifLocalVar35_g301 = _ST_WindLeaf2Twitch;
float3 appendResult37_g301 = (float3(ifLocalVar35_g301.xyz));
float3 break76_g306 = appendResult37_g301;
float4 break109_g306 = temp_output_27_0_g306;
float fAngle6_g312 = ( temp_output_3_0_g306 * ( ( acos( clampResult56_g306 ) * break34_g301.w ) + ( pow( saturate( ( ( ( break14_g310.x * break14_g310.y * break14_g310.y ) + 1.0 ) * 0.5 ) ) , break76_g306.y ) * break76_g306.x ) + ( ( break109_g306.y + ( ( break109_g306.x * break109_g306.x ) * -1.0 ) ) * break34_g301.y ) ) );
float3x3 localRotationMatrix6_g312 = RotationMatrix( vAxis6_g312 , fAngle6_g312 );
float3x3 temp_output_86_0_g306 = mul( localRotationMatrix6_g309, localRotationMatrix6_g312 );
float3 temp_output_1_0_g306 = temp_output_52_0_g301;
float3 normalizeResult91_g306 = normalize( mul( temp_output_86_0_g306, temp_output_1_0_g306 ) );
float3 ifLocalVar27_g301 = 0;
if( temp_output_2_0_g301 == 4 )
ifLocalVar27_g301 = ( normalizeResult91_g306 * length( temp_output_1_0_g306 ) );
else
ifLocalVar27_g301 = temp_output_52_0_g301;
float3 ifLocalVar2_g300 = 0;
if( temp_output_40_0_g300 <= 1.0 )
ifLocalVar2_g300 = temp_output_6_0_g300;
else
ifLocalVar2_g300 = ifLocalVar27_g301;
float3 ifLocalVar1_g300 = 0;
if( temp_output_40_0_g300 >= 5.0 )
ifLocalVar1_g300 = temp_output_6_0_g300;
else
ifLocalVar1_g300 = ifLocalVar2_g300;
#if defined(GEOM_TYPE_BRANCH)
float3 staticSwitch214 = staticSwitch343;
#elif defined(GEOM_TYPE_FROND)
float3 staticSwitch214 = staticSwitch343;
#elif defined(GEOM_TYPE_LEAF)
float3 staticSwitch214 = ( appendResult213 + ifLocalVar1_g300 );
#elif defined(GEOM_TYPE_BRANCH_DETAIL)
float3 staticSwitch214 = staticSwitch343;
#else
float3 staticSwitch214 = staticSwitch343;
#endif
float3 temp_output_3_0_g844 = staticSwitch214;
int temp_output_24_0_g844 = _WindQuality;
float4 break32_g844 = inputMesh.ase_texcoord;
float2 appendResult31_g844 = (float2(break32_g844.z , break32_g844.w));
float2 break34_g844 = appendResult31_g844;
float temp_output_5_0_g845 = break34_g844.y;
float3 temp_cast_10 = (temp_output_5_0_g845).xxx;
float3 fValue10_g846 = temp_cast_10;
float3 localUnpackNormalFromFloat10_g846 = UnpackNormalFromFloat( fValue10_g846 );
float temp_output_4_0_g845 = break34_g844.x;
int temp_output_7_0_g847 = 0;
int temp_output_10_0_g847 = 1;
float3 localGetInstancePos40_g844 = GetInstancePos();
float3 break17_g845 = localGetInstancePos40_g844;
float temp_output_3_0_g847 = ( break17_g845.x + break17_g845.y + _GlobalTimers[_GlobalTimerId].y );
float fTime28_g847 = temp_output_3_0_g847;
float temp_output_4_0_g847 = temp_output_5_0_g845;
float fOffset28_g847 = temp_output_4_0_g847;
float fTwitchFreqScale28_g847 = _ST_WindBranchTwitch.y;
float temp_output_5_0_g847 = temp_output_4_0_g845;
float fWeight28_g847 = temp_output_5_0_g847;
int bWhip28_g847 = temp_output_7_0_g847;
float4 localComplexOscillationInputs28_g847 = ComplexOscillationInputs( fTime28_g847 , fOffset28_g847 , fTwitchFreqScale28_g847 , fWeight28_g847 , bWhip28_g847 );
float4 vData7_g849 = localComplexOscillationInputs28_g847;
float4 localTriangleWave7_g849 = TriangleWave( vData7_g849 );