Hi.

I’m implementing an effect in the vertex shader where the plane geometry is stretched to match the previous modelViewMatrix.

The problem is that when the difference between the current modelViewMatrix and the previous modelViewMatrix decreases, the plane shakes, and when the difference finally becomes 0, it disappears.

I’ve been searching and testing for this problem all day.

Can anyone tell me what I’m doing wrong?

Here’s the fiddle and video.

I’m inclined to think that the problem is here:

```
vec3 normal2 = normalize((modelViewMatrix * vec4( position, 1.0 ) - uPreviousModelViewMatrix * vec4( position, 1.0 )).xyz);
```

When both matrices become too close, the resulting vector might become 0 and then, `normalize`

fails (visually, the result will be disappearing polygons).

I think there must be some logic in the shader that deals with this situation in a different way.

A quick test whether this is the cause might be to add a small displacement to the vector before normalization:

```
vec3 normal2 = normalize((...).xyz+vec3(0.00001));
```

Does the plane flicker again?

The flicker magically disappeared!

Thank you so much for your kind explanation.

I’ll think about what you said.

Thank you!

1 Like