0

This example, GLSL - Calculate Surface Normal, generates a curved surface from a known function, so it can be differentiated "compile-time". Is it possible to do the same if I have z coordinates in a vertex buffer. I need to be able to take partial derivatives in x and y directions. Thus, the four neighboring vertices are needed in order to perform the computation. Is that possible?

user877329
  • 6,717
  • 8
  • 46
  • 88
  • 1
    [`dFdx`, `dFdy` — return the partial derivative of an argument with respect to x or y](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/dFdx.xhtml) – Rabbid76 Sep 23 '21 at 19:49
  • @Rabbid76 "with respect to the window $x$ coordinate", isn't that x after the fragment has been projected? The normal must be computed in before projection, ideally in model space. – user877329 Sep 24 '21 at 06:13
  • `dFdx` and `dFdy` can just be used in the fragment shader. It can be used to compute a derivative of any argument in any space. Have you tried it? See [3D object is colored in a way that looks like a 2D object](https://stackoverflow.com/questions/50921461/3d-object-is-colored-in-a-way-that-looks-like-a-2d-object/50931560#50931560) – Rabbid76 Sep 24 '21 at 06:17

0 Answers0