Quantcast
Channel: Questions in topic: "compute shader"
Viewing all articles
Browse latest Browse all 287

Texture sampling will move when sampled same position.

$
0
0
I'm facing a sampling problem. I'm trying to use Compute Shader via `SampleLevel` method. I've written shader code like below. [numthreads(8,8,1)] void Test(uint2 id : SV_DispatchThreadID) { float w, h; _SourceTexture.GetDimensions(w, h); float2 uv = float2(id.x/w, id.y/h); float4 t = _SourceTexture.SampleLevel(_LinearClamp, uv, 0); _ResultTexture[id] = t; } And it will be dispatched like below. int kernel = _shader.FindKernel("Test"); _shader.SetTexture(kernel, "_SourceTexture", _previewBuffer.Current); _shader.SetTexture(kernel, "_ResultTexture", _previewBuffer.Other); _shader.Dispatch(kernel, _previewBuffer.Width / 8, _previewBuffer.Height / 8, 1); _previewBuffer.Swap(); _preview.texture = _previewBuffer.Current; The texture will swap each frame. So I'm wondering why the shader code sampled same position but the texture will move toward up-right. I also attached a movie for the problem. Does anyone have any idea? ![alt text][1] [1]: https://i.gyazo.com/c57379fb76ea8d5f44a3f3f3fa5ae483.gif

Viewing all articles
Browse latest Browse all 287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>