Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ComputeShaderExample.compute 612B

12345678910111213141516
  1. // Each #kernel tells which function to compile; you can have many kernels
  2. #pragma kernel CSMain
  3. // Create a StructuredBuffer/ComputeBuffer with read only flag.
  4. StructuredBuffer<int> inputData;
  5. // Create a StructuredBuffer/ComputeBuffer with read & write flag.
  6. RWStructuredBuffer<int> outputData;
  7. // We allocate 20 threads one for each number given to the shader.
  8. // CSMain is the entry point we use we have to define the entry points as kernel.
  9. [numthreads(20,1,1)]
  10. void CSMain (uint3 id : SV_DispatchThreadID)
  11. {
  12. // We use the thead id as index for the data.
  13. outputData[id.x] = 2 * inputData[id.x];
  14. }