I'm currently developing a shader which requires me to blur the image first.
However, there have been some weird bugs plagging me for a while.
In DX9, in areas where depth returns 0, the screen blacks out, and outside of those, it flickers a lot. From what I can tell, that means one of the textures is not being rendered properly.
The awkward part though, is that the only fix I've found for this is to reload the shader. No changes to variables or code, nor changing where I look, just reload a few times. Eventually, it starts working again, if not instantly. This happens only once in a while, which makes it even weirder.
In DX11, it never displays this issue. However, I've recently messed with matrices and the vertex shader in hopes of improving performance (which sadly didn't), and that created another weird glitch: one of the textures just spazzes out depending on where I look, and does so intermittently. Reloading the shader does not fix it. So, what fixed it? Changed:
I have had similar bugs with infinity literals or NaNs in the code, check for divisions though 0 under certain circumstances and so on. Can you post the entire shader code maybe? It's difficult to give tips without seeing the code itself.
Have you tried to reduce the usage of TEXCOORD ? (you don't need to interpolate zw anyways)
I've bumped into some weird stuffs when having 3+ texcoord before (presumably some sort of register overflow? ), either in reshaderFX, or in enb FX11/FX9 on gtx680.
hardly any document or discussion on this problem then the supposedly 8 or 32 limit...those ppl in gamedev would probably just gonna tell you to load up PIX to check.(which is actually a viable option though.)
(though, SMAA does use more then 4 texcoord register...making the whole thing even weirder...)
Sorry about the lack of replies, but I've been bedridden for a while now :/
Still am, but I'm also getting sick of doing nothing at all...
SO, tested most of the stuff said here... and not much, really. Not even the fix that I mentioned myself, that only disguises part of the problem.
DX9 bug still occurs regardless. I think this may have to do with initializations somewhere, but I just can't find a fix.
As for DX11, I tested around a bit, and it seems to happen when the framerate is higher.
Since the performance improvements were nil, and after testing suggested solutions but having mixed results (flickering still happens, one way or the other), I rolled back to before messing around with vertex shaders and matrices. That resolved that issue, but... I realized that there was still some slight blur problems.
I was negating the effect of the pingpong between frames (oops), making it uneven. After fixing that, I ended up with yet another issue... the blur itself was flickering. After more testing, it seems like the pingpong uniform is not changing correctly, making it harder to blend properly, since it should swap direction every frame, but seems to miss some. (Note that flickering should occur, but at the ratio I'm using, it's not noticeable, which wasn't the case.)
So, I created a 1x1 texture, and swap it at the beggining of every frame. That fixed the issue, though not optimally.
first, here's what I've gather so far from the source code on "pingpong"
the pingpong uniform updates per frame, not per pass
the second component of "step" provides a random step increment of ouput instead of constant step,
the step is framerate independent, mening it is not constant step between frame
the minimum increment step is 0.05,
there's a hidden annotation "smoothing" to decrease step when value is near the end points.
secondly, the pixeloffset you're using has min/max offset 72 pixel, which is "flipping as expected", with frequency defined by your pingpong term, which I assumed is what you intended for the shader, and was not what I fixed with the provided solutions, (I can have both type of flickering happened in the same time.)
this is what I saw, and fixed: (obviously sth is fuck up texcoord and position)