$P1,P2,P3;{\left(h1,h2,h3,h4\right)}_{i,j}$

$0\le i<n;0\le j<n$

$\Delta u=\frac{h1+h3-h2-h4}{2}$

$\Delta v=\frac{h1+h2-h3-h4}{2}$

${h}^{\prime}=\frac{h1+h2+h3+h4}{4}$

$Dte{x}^{2}=\frac{\parallel P3-P1{\parallel}^{2}}{{n}^{2}}$

$\widehat{No}=\hat{NormalMatrix\left(Interpolate\left({N}_{P1},{N}_{P2},{N}_{P3};i,j\right)\right)}$

${T}_{initial}=NormalMatrix\left(P3-P1\right)$

${B}_{initial}=NormalMatrix\left(P2-\frac{P1+p3}{2}\right)$

Given ($\widehat{No}$), Orthonormalize

(${T}_{initial},{B}_{initial}$), yielding ($\widehat{T},\widehat{B}$)...

${N}_{T}=\widehat{T}\frac{\Delta u}{\sqrt{{c}^{2}+\Delta {u}^{2}+\Delta {v}^{2}}}$

${N}_{B}=\widehat{B}\frac{\Delta v}{\sqrt{{c}^{2}+\Delta {u}^{2}+\Delta {v}^{2}}}$

${N}_{z}=\widehat{No}\sqrt{1-{N}_{T}^{2}-{N}_{B}^{2}}$

Where the matrix may be helpful:

$\left[\begin{array}{ccc}\hfill \u27e8\widehat{T}\u27e9\hfill & \hfill \u27e8\widehat{B}\u27e9\hfill & \hfill \u27e8\widehat{No}\u27e9\hfill \end{array}\right]$

It’s assumed that 1 output-point is to

result, from 4 input-heights.

If (Pmax) is the maximum pixel-value,

(Hmax) is the maximum height or depth

in 3D, and (Dtex) is the distance between

Texels in 3D, Then:

${h}^{\prime}=\frac{h1+h2+h3+h4}{4}\left(\frac{Hmax}{Pmax}\right)$

$c=\frac{PmaxDtex}{Hmax}$

(Dtex) could also be the known distance

between undisplaced input-points. And,

since only (c-squared) will ever be used,

the squares of (Dtex) and (Hmax) may also

be used, if (Pmax) is to be squared by itself,

and then the resulting (c) not squared again,

since their computation may be cheaper on

the GPU, than the actual computation of (Dtex),

which would require that another square root

be computed.

After all, the programming of certain shaders

may make it more diﬃcult, to displace the

texel-sampling-point by (1 texel), than it is

just to sample the texture according to (more

than 1 input-point texture-coordinate-set),

within one shader invocation. This can be

due to mip-mapping.

BTW: I have not yet shown, how to compute

the deltas in texture-coordinates, to arrive

at (h1, h2, h3, h4) above:

$DT{C}_{T}=\frac{T{C}_{P3}-T{C}_{P1}}{2n}$

$DT{C}_{B}=\frac{2T{C}_{P2}-T{C}_{P1}-T{C}_{P3}}{4n}$

However, if input-point-distances are to be

used, then the tangent-mapping would also

need to be modiﬁed, so that the tangent-vector

will become one of the tessellation axes,

derived from one of the sides of the input

geometry. The bitangent-vector could then

either be computed from re-crossing (with the

derived normal-vector of the output-

geometry), or from an arbitrary other side of

the input geometry, subject to Gram-Schmidt

orthonormalization. In either case, care

should be taken also to make sure, that the sign

of the bitangent-vector, corresponds to the

secondary direction, in which tessellation did

in fact take place.

OTOH, the coder could ﬁnd that he’s been given

an input to the GS, which is already tessellated -

but as (1 triangle), in case DirectX11- or OpenGL4-

methods were being used. In that case, sub-

optimal equations may result, much like so:

$P1,P2,P3;h1,h2,h3$

$\Delta u=h3-h1$

$\Delta v=h2-\frac{\left(h1+h3\right)}{2}$

${h}^{\prime}=\frac{h1+h2+h3}{3}\left(\frac{Hmax}{Pmax}\right)$

$Dte{x}^{2}=\parallel P3-P1{\parallel}^{2}$

$\widehat{No}=\hat{NormalMatrix\left({N}_{P1}+{N}_{P2}+{N}_{P3}\right)}$

${T}_{initial}=NormalMatrix\left(P3-P1\right)$

${B}_{initial}=NormalMatrix\left(P2-\frac{\left(P1+P3\right)}{2}\right)$

The wide hat means ’normalize’, and I think

that only 1 Micropolygon-point could result, per

GS input-triangle.