[User error] Model normals not updated every model frame

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Model normals not updated every model frame

Postby Nash » Wed May 15, 2019 7:05 pm

Test file sent via PM to dpJudas.

Steps to reproduce:

Just walk up to a door and press +use to open it. The doors are actually Actors with an animated model (2 frames). Using gl_ssao_debug 4, you can clearly see that the model normals are only correct for its initial frame - as the model animates, the normals aren't updated.

Note that the model only has 2 frames - opened and closed. Interpolation is taken advantage of here to make the door look like it's opening and closing smoothly. If you disable model interpolation (gl_interpolate_model_frames 0) you can see the true nature of the model animation. :) I am only mentioning this detail because if this ticket were to be fixed, the model normal recalculation would have to take interpolation into account.

Same in OpenGL and Vulkan.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Model normals not updated every model frame

Postby Marisa Kirisame » Thu May 16, 2019 3:47 pm

User avatar
Marisa Kirisame
ZScript Magician
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: Marisa Kirisame#4689
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Model normals not updated every model frame

Postby dpJudas » Thu May 16, 2019 4:03 pm

I can't remember what I pushed back then. But whatever it was, seems it broke again (or was never fully repaired).
dpJudas
 
 
 
Joined: 28 May 2016

Re: Model normals not updated every model frame

Postby Nash » Thu May 16, 2019 5:10 pm




@MK: not sure if what you reported is the same problem but take a look at these. Door closed and door open. Notice that in the opened one, the normals of the swinging part of the door is completely wrong.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Model normals not updated every model frame

Postby Nash » Thu May 16, 2019 5:39 pm

Conclusion: this is a fault of the Blender MD3 exporter I'm using. It seems that normals in an animated MD3 has to be recalculated per-frame (???????????) and the exporter currently only writes the correct normals for the first frame.

I was wrong. It's not the exporter's fault. Here's the real cause of this problem:

I parented the door mesh to the door bone without an Armature modifier (just plain object parenting) - this will NOT work because even though it LOOKS like your animation is working, Blender doesn't really "see" the transform, therefore you won't get the correct normals for every frame.

I fixed this by properly parenting the door mesh to the bone with an Armature modifier, be sure it had the correct weight painting (it's just one bone, basically select the entire mesh and give every vertex a weight of 1.0), and now the normals are exported correctly every frame.

Can be closed I suppose.
Last edited by Nash on Thu May 16, 2019 6:28 pm, edited 1 time in total.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Model normals not updated every model frame

Postby Marisa Kirisame » Thu May 16, 2019 6:07 pm

Oh...
User avatar
Marisa Kirisame
ZScript Magician
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: Marisa Kirisame#4689
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
Graphics Processor: nVidia with Vulkan support


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 2 guests