pouët.net

Go to bottom

Shader derivatives

category: code [glöplog]
the output of the shader derivative functions (fDx and fDy) looks like shit. it's half the original texture res, and it doesn't look very precise. am I doing it wrong, or should I calculate it manually?
added on the 2010-09-29 22:33:35 by xernobyl xernobyl
RTFM
added on the 2010-09-29 22:35:43 by decipher decipher
JFGI
added on the 2010-09-29 22:37:51 by ferris ferris
WWJD
TOGTFO
xernobyl - as decipher so eloquently put it: they are exactly half res, as they are done by simple differencing between the 2x2 of pixels rendered.
added on the 2010-09-29 23:24:23 by hornet hornet
DDX DDY FWIDTH
added on the 2010-09-29 23:24:43 by unc unc
@Decipher I prefer the twitter version.
added on the 2010-09-29 23:34:10 by xernobyl xernobyl
like hornet nicely did it.
added on the 2010-09-29 23:34:26 by xernobyl xernobyl
You can't do the derivative yourself, at least not in general.
added on the 2010-09-30 00:29:21 by kusma kusma
Yeah I was also wondering about it, if you can calculate the derivative of a function from a single value on the function graph, well get ready for the Nobel or something.
added on the 2010-09-30 13:07:40 by decipher decipher
I can have several textures you know?
added on the 2010-09-30 15:39:19 by xernobyl xernobyl
Read: I can have several half-sized derivatives \o/ party.
added on the 2010-09-30 15:53:01 by ferris ferris
Quote:
if you can calculate the derivative of a function from a single value on the function graph, well get ready for the Nobel or something.

Fields Medal.
added on the 2010-09-30 17:40:10 by krabob krabob
There's a funny story about that... apparently there's no Nobel for math because Nobel's wife was having an affair with a mathematician.
added on the 2010-09-30 18:16:52 by xernobyl xernobyl
Quote:
apparently there's no Nobel for math because Nobel's wife was having an affair with a mathematician.


Full of win.
added on the 2010-09-30 18:39:15 by ferris ferris
Why should it be half size?
shouldn't it be just -1px from the side and -1px from the top or bottom?
yeah, it could be done on full reso.
added on the 2010-09-30 18:56:26 by Oswald Oswald
It has to do with hardware sampling, the hardware always takes 4 samples. That's why you have the fetch4 / gather4 instruction.
added on the 2010-09-30 19:39:58 by xernobyl xernobyl
even then, why isn't it upscaled (and interpolated) to full size?
Maybe because that'd be trivial to a user? :)
added on the 2010-10-01 04:27:09 by ferris ferris
xenobyl - The 2x2-rendering is bound to how the rasterizer works, not the sampler, so it's unrelated to fetch4.
added on the 2010-10-01 11:31:59 by hornet hornet
xrl: basically the rasterizer does everything in 2x2 quads that are computed in one step. Back in the day this way the simplest solution to get an approximation of the texture coordinate derivatives for determining which mipmap level to use. And then in SM3 they were all like "if every GPU rasterizes 2x2 pixels in parallel anyway we can simply add an instruction that gets you the derivative of any value in the shader 'for free'" and then went on rejoicing.
added on the 2010-10-01 11:57:07 by kb_ kb_
added on the 2010-10-01 14:03:31 by trc_wm trc_wm
and afaik, that's why rasterizing polygons that are smaller than two pixels is so inefficient - the HW is always shading a minimum of 2x2 pixels.
added on the 2010-10-01 19:26:53 by iq iq

login

Go to top