Created
February 12, 2020 03:51
-
-
Save dorodo95/d4e7e24618b510d54aa9523e8ac7e5ac to your computer and use it in GitHub Desktop.
Compute shader issue (.compute)
This file contains hidden or 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 StartKernel | |
#pragma kernel StepKernel | |
RWTexture2D<float4> _outTex; | |
RWTexture2D<float4> _inTex; | |
float hash(float2 uv) | |
{ | |
return sin(dot(float2(49104.3, 13059.2), uv)); | |
} | |
float Random(float2 uv) | |
{ | |
float seed = hash(uv); | |
float x = frac(seed * 19204.3); | |
return float(x); | |
} | |
[numthreads(8, 8, 1)] | |
void StartKernel (uint3 id : SV_DispatchThreadID) | |
{ | |
float _random = Random(id.xy); | |
_inTex[id.xy] = float4(_random.rrr,1); | |
} | |
[numthreads(8, 8, 1)] | |
void StepKernel(uint3 id : SV_DispatchThreadID) | |
{ | |
_outTex[id.xy] = _inTex[id.xy]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment