Download

Write to specific pixel on PixelShader Material

Hey guys!.. i’m not sure this is possible without creating a custom shader, but i’m in need of re ordering a RenderTarget with offsets from another render target.
The prime idea is that, one image holds information about a heightfield, while the other image holds information about the horizontal displacement of said heightfield, both images are used on the Position offset of the vertex.

I’m queueing the render thread to access the height on a specific point of the material, this is already working and would be finished if not by the horizontal displacement.
Because the horizontal displacement adds an offset to the vertex (that could range from really small to kinda big (not much, but enough to be noticeable), i’m looking for ways to get the height of a point in space AFTER the displacement has affected.

Because i don’t want to queue the entire image or iterate through it to search for the points that, after displaced, end up in my position… (that would take way too much time to be used in real time)… i was thinking on creating a solution using a shader, that goes something like this (in pseudo code)

  • On a specific pixel (a,b) => read Height of the heightfield
  • On the same pixel, read horizontal displacement (x,y)
  • Store the height of the pixel on DisplacedHeightImage[a+x,b+y] = Heightfield[a,b]

Is something like this possible on the material editor ? or do i have to create an usf shader?

Will bump only this time

I’m not sure I completely understand what you are trying to do, but doesn’t the Absolute World Position node give an option to return the position without or WITH the material offsets?

No, i’m thinking more like, write to this specific pixel… but now i see that it really doesn’t make sense in the material editor (only when the material draws to the render target).
So it seems the only way around it is to create an usf shader?