Why are dFdx/ddx and dFdy/ddy 2 dimension variables when quering a 2d texture?
Asked Answered
F

2

6

I cannot seem to understand this, shouldn't the derivative/change along the U or V coordinate in a 2d texture/array be single dimension variable as we are checking it only along ddx (U coordinate) or ddy (V coordinate)?

Frentz answered 4/7, 2014 at 7:31 Comment(0)
P
7

There are 4 distinct partial derivatives here: du/dx, dv/dx, du/dy, and dv/dy. None of those four values need be zero, unless the texture image coordinates happen to be perfectly aligned to the display screen axes. In general the texture coordinate axes need not be aligned to the screen display axes. X and Y (display viewport axes) are not the same directions as U and V (texture image axes).

Diagram showing relationship of UV and XY

In other words, the Jacobian matrix that relates the 2D screen/viewport coordinate system to the 2D texture/image UV coordinate system contains 4 entries: Two per adjustable parameter.

Parthinia answered 4/7, 2014 at 17:18 Comment(2)
This is the clearest explanation I have seen regarding ddx, ddy and textures. Taking it a notch further: vec2 dx_vtc = dFdx(texture_coordinate); Is dx_vtc made of the following components du/dx, dv/dx respectively?Frentz
@Frentz Yes, that's how I understand it: [du/dx, dv/dx] = dFdx([u, v])Parthinia
H
0

You are computing the derivative of a variable (such as the uv-coordinate of a texture) with respect to the screenspace in either the x or y direction. Or in other words you could say that the function answer the question: "what change will happend to this variable when I move one pixel to [the left]/[up]".

Hickok answered 4/7, 2014 at 10:43 Comment(1)
I still don't see it, as you said this is computed either in the x or in the y direction, not both at the same time. So ddx would be the change when I move one pixel left only, or is there some basic misunderstanding on my side?Frentz

© 2022 - 2024 — McMap. All rights reserved.