How to implement HeightMap smoothing using Thrust

Posted by igal k on Stack Overflow See other posts from Stack Overflow or by igal k
Published on 2011-11-19T17:22:39Z Indexed on 2011/11/19 17:51 UTC
Read the original article Hit count: 207

Filed under:
|

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).

© Stack Overflow or respective owner

Related posts about cuda

Related posts about thrust