Unity: Difference between revisions

From David's Wiki
Created page with "__FORCETOC__ == Shaders == Unity Shaders are written in HLSL. Unity supports the standard vertex, geometry, fragments shader pipeline. They also have their own variation o..."
 
No edit summary
Line 15: Line 15:
To copy data to and from the GPU, use a <source enclose="none">ComputeBuffer</source>.
To copy data to and from the GPU, use a <source enclose="none">ComputeBuffer</source>.
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.
<--
<!--
Example:
Example:
<syntaxhighlight lang="C#">
<syntaxhighlight lang="C#">

Revision as of 17:00, 17 August 2019



Shaders

Unity Shaders are written in HLSL. Unity supports the standard vertex, geometry, fragments shader pipeline. They also have their own variation of surface shaders. 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.