Advertisement
LockdateforGHS

example.

Jun 13th, 2023
2,194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. kernel Grayscale
  2. <   namespace : "YourNamespace";
  3.     vendor : "YourVendor";
  4.     version : 1;
  5.     description : "Converts an image to grayscale.";
  6. >
  7. {
  8.     input image4 src;
  9.     output pixel4 dst;
  10.  
  11.     void evaluatePixel()
  12.     {
  13.         // Get the RGBA color values of the source pixel
  14.         float4 color = sampleNearest(src, outCoord());
  15.  
  16.         // Calculate the grayscale value
  17.         float gray = dot(color.rgb, float3(0.299, 0.587, 0.114));
  18.  
  19.         // Set the grayscale value for each color channel
  20.         dst = float4(gray, gray, gray, color.a);
  21.     }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement