OSDN Git Service

Added Assets for main menu
[mindgames/Mindgames_main.git] / Mindgames / Library / PackageCache / com.unity.visualeffectgraph@6.9.0-preview / Shaders / VFXInit.template
1 #pragma kernel CSMain
2 ${VFXGlobalInclude}
3 ${VFXGlobalDeclaration}
4 ${VFXPerPassInclude}
5
6 RWByteAddressBuffer attributeBuffer;
7 ByteAddressBuffer sourceAttributeBuffer;
8
9 CBUFFER_START(initParams)
10 #if !VFX_USE_SPAWNER_FROM_GPU
11     uint nbSpawned;                                     // Numbers of particle spawned
12     uint spawnIndex;                            // Index of the first particle spawned
13     uint dispatchWidth;
14 #else
15     uint offsetInAdditionalOutput;
16         uint nbMax;
17 #endif
18         uint systemSeed;
19 CBUFFER_END
20
21 #if VFX_USE_ALIVE_CURRENT
22 RWStructuredBuffer<uint> deadListIn;
23 ByteAddressBuffer deadListCount; // This is bad to use a SRV to fetch deadList count but Unity API currently prevent from copying to CB
24 #endif
25
26 #if VFX_USE_SPAWNER_FROM_GPU
27 StructuredBuffer<uint> eventList;
28 ByteAddressBuffer inputAdditional;
29 #endif
30
31 ${VFXGeneratedBlockFunction}
32
33 [numthreads(NB_THREADS_PER_GROUP,1,1)]
34 void CSMain(uint3 groupId          : SV_GroupID,
35             uint3 groupThreadId    : SV_GroupThreadID)
36 {
37     uint id = groupThreadId.x + groupId.x * NB_THREADS_PER_GROUP;
38 #if !VFX_USE_SPAWNER_FROM_GPU
39     id += groupId.y * dispatchWidth * NB_THREADS_PER_GROUP;
40 #endif
41
42 #if VFX_USE_SPAWNER_FROM_GPU
43     uint maxThreadId = inputAdditional.Load((offsetInAdditionalOutput * 2 + 0) << 2);
44     uint currentSpawnIndex = inputAdditional.Load((offsetInAdditionalOutput * 2 + 1) << 2) - maxThreadId;
45 #else
46     uint maxThreadId = nbSpawned;
47     uint currentSpawnIndex = spawnIndex;
48 #endif
49
50 #if VFX_USE_ALIVE_CURRENT
51     maxThreadId = min(maxThreadId, deadListCount.Load(0x0));
52 #elif VFX_USE_SPAWNER_FROM_GPU
53     maxThreadId = min(maxThreadId, nbMax); //otherwise, nbSpawned already clamped on CPU
54 #endif
55
56     if (id < maxThreadId)
57     {
58 #if VFX_USE_SPAWNER_FROM_GPU
59         int sourceIndex = eventList[id];
60 #endif
61         uint particleIndex = id + currentSpawnIndex;
62                 
63 #if !VFX_USE_SPAWNER_FROM_GPU
64         ${VFXComputeSourceIndex}
65 #endif
66         ${VFXLoadAttributes}
67 #if VFX_USE_PARTICLEID_CURRENT
68          particleId = particleIndex;
69 #endif
70 #if VFX_USE_SEED_CURRENT
71         seed = WangHash(particleIndex ^ systemSeed);
72 #endif
73         
74         ${VFXProcessBlocks}
75
76 #if VFX_USE_ALIVE_CURRENT
77         if (alive)
78         {
79                         uint deadIndex = deadListIn.DecrementCounter();
80             uint index = deadListIn[deadIndex];
81             ${VFXStoreAttributes}
82         }
83 #else
84         uint index = particleIndex;
85         ${VFXStoreAttributes}
86 #endif
87     }
88 }