Open macksal opened 3 years ago
Hello, Sorry for the late reply. I unfortunately do not have too much time to dedicate to this. However, maybe a point which could help. There are two versions of the algorithm, the "grain-wise" and the "pixel-wise" version. Only the pixel-wise version is parallelised (and therefore in the GPU version), and this algorithm looks at the output pixels. Maybe this will help. Kind regards, Alasdair Newson
Thanks Alasdair, I am comparing the GPU implementation of the pixel-wise algorithm in this repo and the CPU implementation of the same in the "film_grain_rendering" repo. It appears to be a typo so while I don't mind if it is fixed or not, hopefully the open issue will alert anyone who is also working with the algorithm :)
Fantastic library! This was a useful catch. All you need to do is change this line
to
float4 src_im_sxsy = tex2D(tex_src_im, (int)max(floor(cellCornerX),0.0), (int)max(floor(cellCornerY),0.0));
That said, there's not much of a difference visually.
I've noticed that in the CUDA implementation of the pixel-wise grain algorithm, the sampling of the input image when iterating through cells is as follows:
This gets the value of the image at (xGaussian, yGaussian), which is the coordinates of the output pixel, not the input pixel covering the relevant cell.
The CPU implementation seems to be correctly based on (cellCornerX, cellCornerY):
I've read the published article (which has been a fantastic resource) which seems to confirm that the sampling should be at the cell's pixel coordinates: