How to implement HeightMap smoothing using Thrust
- by igal k
I'm trying to implement height map smoothing using Thrust.
Let's say I have a big array ( around 1 million floats).
A known graphics algorithm to implement the above problem is to calculate the average around a given cell.
If for example I need to calculate the value at a given cell[i,j]
what I will basically do is:
cell[i,j] = cell[i-1,j-1] + cell[i-1,j] + cell[i-1,j+1] + cell[i,j-1] + cell[i,j+1] + cell[i+1,j -1] + cell[i+1,j] + cell[i+1,j+1]
cell[i,j] /=9
That's the CPU code. Is there a way to implement it using thrust?
I know that I could use the transform algorithm. But I'm not sure it's correct to access different cells which are occupied but different threads (banks conflicts and so on).