I have a custom gaussian blur compute shader for a custom pp effect I am working on, but the results are offset in the positive uv direction (i.e. towards top left of the screen). Does anyone know why this might be the case or how to fix this issue? The only thing I could think about is that I am using the unity macros “RW_TEXTURE2D_X” & “COORD_TEXTURE2D_X” and sampling/writing for different perspectives/eyes or somehing but then why would it be skewed to in the y direction as well…
EDIT: I suppose bilinear sampling is not supported for the used sampling method and/or uvs are getting truncated? That would result in pixel values being sampled that are too far to the bottom left of the image.
EDIT 2: I have implemented discrete filtering and indeed the offset disappears. That just makes me wonder whether it is possible to use linear sampling with the provided unity macros or compute shaders in general and what the alternatives are. Also (small rant warning) why are unity macros never documented anywhere? try googling RW_TEXTURE2D_X this post is probably one of the top results at this point…
I am currently not using VR and the screenshot below is just from the unity in-game view.
this image shows a scene masked with the blur values to showcase the offset.
I haven’t had experience with the macro COORD_TEXTURE2D_X so this was a good find.
just an aside question as I am still learning these kind of processess, at what point would your uvs not be 0-1 when doing a full screen blit? (assuming thats what you are doing)
I am using a compute shader here, so the id.xy coordinates are integer coordinates from 0-Resolution.
I kinda thought COORD_TEXTURE2D_X would do the job or something but I actually am not sure what it is doing exactly (just that it was needed ) (probably just vr related selection of which dimension/slice of the _XR texture to sample). edit: looked it up, it just adds the SLICE_ARRAY_INDEX macro to the pixelCoord position. i.e. feed it an int2 and it returns an int3 with the corresponding index as third vector param. which is basicly just 0 unless using stereo instancing for vr.
The only place in which i convert to 0-1 uvs is when i divide by float2(_ResultWidth, _ResultHeight) in my second post.