Surface glitches on a scaled model

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Surface glitches on a scaled model

Re: Surface glitches on a scaled model

by Rachael » Sat Feb 22, 2025 12:24 pm

phantombeta wrote: Sat Feb 22, 2025 5:56 am

Code: Select all

		vWorldNormal = vec4(normalize((NormalModelMatrix * vec4(normalize(bones.Normal), 1.0)).xyz), 1.0);
		vEyeNormal = vec4(normalize((NormalViewMatrix * vec4(normalize(vWorldNormal.xyz), 1.0)).xyz), 1.0);
Did this as proposed.

Re: Surface glitches on a scaled model

by Enjay » Sat Feb 22, 2025 6:45 am

Yep.

I had a go myself before. I found the right file, but couldn't figure out the syntax.

phantombeta's change does it.


Re: Surface glitches on a scaled model

by phantombeta » Sat Feb 22, 2025 5:56 am

Renormalizing the normals does seem to fix it.
Changing

Code: Select all

		vWorldNormal = NormalModelMatrix * vec4(normalize(bones.Normal), 1.0);
		vEyeNormal = NormalViewMatrix * vec4(normalize(vWorldNormal.xyz), 1.0);
to

Code: Select all

		vWorldNormal = vec4(normalize((NormalModelMatrix * vec4(normalize(bones.Normal), 1.0)).xyz), 1.0);
		vEyeNormal = vec4(normalize((NormalViewMatrix * vec4(normalize(vWorldNormal.xyz), 1.0)).xyz), 1.0);
in shaders/glsl/main.vp works.
(Removing the w component is necessary or it'll be normalized wrong and break the ones that aren't scaled)

Surface glitches on a scaled model

by Enjay » Sat Feb 22, 2025 3:51 am

Noticed in 4.14.0 plus git build from 21 Feb 2025.

Short version: Glitches on the surface of a scaled model can happen with Vanilla sector lighting mode.
dpJudas has provided both an explanation and a possible solution:
dpJudas wrote: Sat Feb 22, 2025 3:32 am Doom originally used different light calculations for sides and flats. The vanilla light mode doesn't know if something is a side or a flat, so what it does instead is to look at the normal of the surface and see if its mostly horizontal or mostly vertical. If its horizontal it uses the side math for the light, and if its vertical it uses the flat math.

The spots on the satellite dish must be exactly at the point where it changes mode. My guess is that scaling the model also scales the normal vectors on the model, but the vanilla light mode seemingly doesn't normalize the vector before using it. Perhaps adding a "normal = normalize(normal)" line in the vertex shader would fix the issue for that model.
More info in this thread: viewtopic.php?t=80200

Example file: https://aspectsweb.co.uk/enjay/doom/Tes ... ellite.pk3
Just load in Doom2 and play map01.

Screenshots:



Top