Moved shaders to new directory
This commit is contained in:
parent
0b3f8340e3
commit
99b226237a
1244 changed files with 0 additions and 0 deletions
40
shaders/hlsl/computeshader/edgedetect.comp
Normal file
40
shaders/hlsl/computeshader/edgedetect.comp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright 2020 Google LLC
|
||||
|
||||
Texture2D inputImage : register(t0);
|
||||
RWTexture2D<float4> resultImage : register(u1);
|
||||
|
||||
float conv(float kernel[9], in float data[9], in float denom, in float offset)
|
||||
{
|
||||
float res = 0.0;
|
||||
for (int i=0; i<9; ++i)
|
||||
{
|
||||
res += kernel[i] * data[i];
|
||||
}
|
||||
return saturate(res/denom + offset);
|
||||
}
|
||||
|
||||
[numthreads(16, 16, 1)]
|
||||
void main(uint3 GlobalInvocationID : SV_DispatchThreadID)
|
||||
{
|
||||
float imageData[9];
|
||||
// Fetch neighbouring texels
|
||||
int n = -1;
|
||||
for (int i=-1; i<2; ++i)
|
||||
{
|
||||
for(int j=-1; j<2; ++j)
|
||||
{
|
||||
n++;
|
||||
float3 rgb = inputImage[uint2(GlobalInvocationID.x + i, GlobalInvocationID.y + j)].rgb;
|
||||
imageData[n] = (rgb.r + rgb.g + rgb.b) / 3.0;
|
||||
}
|
||||
}
|
||||
|
||||
float kernel[9];
|
||||
kernel[0] = -1.0/8.0; kernel[1] = -1.0/8.0; kernel[2] = -1.0/8.0;
|
||||
kernel[3] = -1.0/8.0; kernel[4] = 1.0; kernel[5] = -1.0/8.0;
|
||||
kernel[6] = -1.0/8.0; kernel[7] = -1.0/8.0; kernel[8] = -1.0/8.0;
|
||||
|
||||
float4 res = float4(conv(kernel, imageData, 0.1, 0.0).xxx, 1.0);
|
||||
|
||||
resultImage[int2(GlobalInvocationID.xy)] = res;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue