Unity: Difference between revisions
No edit summary |
No edit summary |
||
Line 12: | Line 12: | ||
=== Compute Shaders === | === Compute Shaders === | ||
To use a compute shader, add a < | To use a compute shader, add a <code>ComputeShader</code> reference to your C# script. | ||
To copy data to and from the GPU, use a < | To copy data to and from the GPU, use a <code>ComputeBuffer</code>. | ||
You can copy standard floats arrays as well as Unity Vector2, Vector3, and Vector4 structs. | You can copy standard floats arrays as well as Unity Vector2, Vector3, and Vector4 structs. | ||
<!-- | <!-- |
Revision as of 17:06, 17 August 2019
Shaders
Unity shaders are written in HLSL.
Unity supports the standard vertex, geometry, fragment shader pipeline.
They also have their own variation of fragment shaders called surface shaders which automatically handle lighting.
Compute shaders are useful for doing parallel computation on the GPU.
Results from compute shaders can be used on the graphical shaders without being copied back to the CPU.
Compute Shaders
To use a compute shader, add a ComputeShader
reference to your C# script.
To copy data to and from the GPU, use a ComputeBuffer
.
You can copy standard floats arrays as well as Unity Vector2, Vector3, and Vector4 structs.