2
$\begingroup$

I'm doing linear tweening of a cyllinder to a cone of equal radius and height in OpenGL. I know parametric equations of both of them, so I derived vertex normals accordingly. Now, I know, that proper interpolation of normals here should be quadratic, but, for some reason, linear looks better.

Let's call cyllinder $C(u,v) := (r\cos(u),\ v,\ r\sin(u))$

and the cone $K(u,v) := (\frac{r\cos(u)(h-v)}{h},\ v,\ \frac{r\sin(u)(h-v)}{h})$ where $u \in [0, 2\pi]$ and $v \in [0,h]$. $r, h$ are radius and height, respectively.

At the moment $t \in [0,1]$, body has equation $T(u,v) := (1-t)C(u,v)+tK(u,v)$.

Given that the normals are computed using partial derivative cross product formula, we get that normal to $T$ at $(u,v)$ is

$$(1-t)^2(C'_u\times C'_v)+t^2(K'_u \times K'_v)+t(1-t)M(u,v),$$ where $M(u,v) := C'_u \times K'_v+K'_u \times C'_v$.

So, apart from $M$, vertex normals to $T$ can be expressed as a quadratic inerpolation of corresponding normals for $C$ and $K$.

Linear interpolation of normals does not work perfectly, but performs way better in general, because whenever I try and implement the correct interpolation formula, somewhere halfway through, all those polygons in the mesh become very apparent.

For the reference GL_NORMALIZE is on, but I store parametrically generated normals (so I can apply my formula for intermediary bodies).

$\endgroup$
3
  • 1
    $\begingroup$ So what is your question? $\endgroup$
    – Simon F
    Sep 11, 2017 at 15:20
  • $\begingroup$ Mainly, I'm wondering if I'm missing something obvious in this scenario. Also, I'm quite surprised that cheating way looks much better than proper way. $\endgroup$
    – Drinkwater
    Sep 11, 2017 at 16:10
  • $\begingroup$ What if you try to normalize also before passing your calculated normals to glNormalXXX(). As documentation says: "normal vectors are normalized to unit length AFTER transformation and before lighting". So in cases when interpolated normal has really small length (may happen during interpolation if C and K normals look in opposite directions) it may be distorted even more after transformation. This may happen in both interpolation schemes, but could be that effect is more visible if using quadratic interpolation $\endgroup$
    – alariq
    Sep 18, 2017 at 11:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.