Created
December 28, 2021 05:57
-
-
Save douduck08/396e2f085ed089e7ebc019b483f6ca24 to your computer and use it in GitHub Desktop.
Unity compute shader template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma kernel CSMain | |
#define THREAD_GROUP_SIZE_X 8 | |
#define THREAD_GROUP_SIZE_Y 8 | |
#define THREAD_GROUP_SIZE_Z 1 | |
// Buffers | |
RWTexture2D<float4> Result; | |
// Functions | |
// Kernels | |
[numthreads(THREAD_GROUP_SIZE_X, THREAD_GROUP_SIZE_Y, THREAD_GROUP_SIZE_Z)] | |
void CSMain ( | |
in uint3 dispatchThreadID : SV_DispatchThreadID, // DispatchThreadID = dot(GroupID, numthreads) + GroupThreadId; | |
in uint groupIndex : SV_GroupIndex, // uint GroupIndex = unique index of a thread inside a group | |
in uint3 groupID : SV_GroupID, // GroupID = index for each dimension inside a ThreadGroupCount | |
in uint3 groupThreadID : SV_GroupThreadID // uint3 GroupThreadId = indices for each dimension inside a group of the current thread | |
) { | |
Result[id.xy] = float4(dispatchThreadID.x & dispatchThreadID.y, (dispatchThreadID.x & 15) / 15.0, (dispatchThreadID.y & 15) / 15.0, 0.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment