Hi All, From my understanding the derivative instructions ddx,ddy,fwidth etc. Use 2x2 blocks of pixels to compute the derivative. Can someone please explain: 1.) What happens on triangle boundaries where a triangle only intersects one or 2 pixels of the 2x2 region 2.) The exact formula for the derivatives for each pixel in the 2x2 block. For example, given the block: a b c d the ddx derivative for pixel a/b/c/d could be ((b-a)+(d-c))/2 or it could be b-a for a/b and d-c for c/d. I have scoured the net and haven't found a good reference for this. I have found that if I draw a box and take the derivative of a complicated calculated value that *sometimes* i get artifacts on the border of the box's polygons. I imagine this is due to how it is computed on polygon boundaries. Any help would be appreciated. Cheers! Eric [Edited by - WizardOfOzzz on January 9, 2008 8:16:57 PM]
Sponsor:

#2 Members - Reputation: 798
Posted 09 January 2008 - 02:42 PM
Quote:
Original post by WizardOfOzzz
From my understanding the derivative instructions ddx,ddy,fwidth etc. Use 2x2 blocks of pixels to compute the derivative.
That's correct.
Quote:
Original post by WizardOfOzzz
1.) What happens on triangle boundaries where a triangle only intersects one or 2 pixels of the 2x2 region
The shader is evaluated for all of the pixels in the 2x2 "quad", even if some of them fall outside of the triangle.
Quote:
Original post by WizardOfOzzz
2.) The exact formula for the derivatives for each pixel in the 2x2 block. For example, given the block:
a b
c d
IIRC the ddx(a) and ddx(b) will be (b-a), ddy(a) and ddy© will be (c-a) and so on.
Quote:
Original post by WizardOfOzzz
I have found that if I draw a box and take the derivative of a complicated calculated value that *sometimes* i get artifacts on the border of the box's polygons.
This problem can indeed occur if you're computing some function that is undefined or otherwise not well-behaved outside of the normal triangle interpolant range. Similar problems can occur with multi-sampling, but there you can often solve them using "centroid" interpolation. I don't recall exactly how derivatives interact with centroid interpolation but I wouldn't be surprised if it is implementation-dependent.
반응형
'그래픽스(Graphics) > Shader' 카테고리의 다른 글
Subsurface scattering (0) | 2013.07.14 |
---|---|
셰이더에서 사용되는 어쎔명령들 (0) | 2013.06.08 |
셰이더 변수,함수들 (0) | 2013.06.03 |
웹에서 셰이더 보기 웹 GLSL (0) | 2013.06.03 |
SSAO( Screen Space Ambient Occlusion ) (0) | 2013.05.20 |