Model displays weird surface effect, but only when scaled

Ask about editing graphics, sounds, models, music, etc here!
Shaders (GLSL) and SNDINFO questions also go here!

Moderators: GZDoom Developers, Raze Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
User avatar
Enjay
 
 
Posts: 26878
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Model displays weird surface effect, but only when scaled

Post by Enjay »

Does anyone know why this is happening?



See the weird circular light spots on the big satellite dish?
The smaller ones do not show the effect, but they use the same model and the same skin. The only difference is that the big one is scaled by a factor of 1.4.

It doesn't matter if I scale the actor in ZScript (or DECORATE), or MODELDEF. When it is scaled, the circles appear. When I set the scale to 1.0, the effect goes away.

I have fixed it by making a copy of the model and scaling it up so that the MD3 is is now the same size as one scaled by 1.4 in game. That has made the effect go away on the big version too.



So, I have fixed the problem, but I wouldn't mind knowing why it happened in the first place.
User avatar
Nash
 
 
Posts: 17481
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: Model displays weird surface effect, but only when scaled

Post by Nash »

That kind of looks like Z-fighting, like as if two of the models are occupying the same spot. Hard to say for sure, though.
User avatar
Enjay
 
 
Posts: 26878
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Model displays weird surface effect, but only when scaled

Post by Enjay »

I know you only said that it kind of looks like it but, to be sure, it's definitely not ZFighting. If it was something in the model causing ZFighting, it would show up on the smaller ones too. I've checked the model as well - no problems there.
It's definitely not two models in the same place either.

It's also not map dependent. I can spawn the big one pretty much anywhere, any map, and I see the effect. As soon as I replace it with a bigger model that isn't scaled, the problem goes away and, as you can see in the first pic the the exact same model, but not scaled up, doesn't show the problem.

However, it's not even specific to the model. The pics I posted were of an adapted version of the Quake2 satellite dish.

This is another model entirely, frankensteined from the Duke Nuken HRP, but still basically the same issue.


and the same solution - a bigger model, scaled in the MD3 instead of using scaling in ZScript or MODELDEF.


It's worth stating that I do have SimSun loaded and applied to these model skins, but even when I remove it, the same thing happens.


Edit: Oh, and it's not ambient occlusion either. I disabled that and the effect still happened.
Edit2: and it happens in Vulkan and OpenGL (but not OpenGL_ES)
User avatar
Tormentor667
Posts: 13554
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany

Re: Model displays weird surface effect, but only when scaled

Post by Tormentor667 »

Still working on Aspects Enjay? ;)
User avatar
Enjay
 
 
Posts: 26878
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Model displays weird surface effect, but only when scaled

Post by Enjay »

Not really, no. It's just a big resources file full of stuff that I used for that and other things. You can probably guess that's a test map just by the way things are all just sitting there in rows beside each other.
User avatar
phantombeta
Posts: 2149
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Model displays weird surface effect, but only when scaled

Post by phantombeta »

Is this with ambient occlusion on? It looks to me like those brighter spots are places where the AO failed to work. Maybe the scaling's breaking the normals?
User avatar
Enjay
 
 
Posts: 26878
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Model displays weird surface effect, but only when scaled

Post by Enjay »

The pictures are with AO on, but (I mentioned in an edit to my last post with pics) that switching off AO doesn't fix the issue.
User avatar
Enjay
 
 
Posts: 26878
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Model displays weird surface effect, but only when scaled

Post by Enjay »

If anyone is interested in looking at it to see if it happens for them, I just threw together this quick demo pk3.

Just load it in GZDoom and start map01.

It'll be interesting to see if it happens with other people and, if not, what the difference in settings are.

As I mentioned before, I have tried with AO on, and in OpenGL and Vulkan. None of these make any difference. I did not notice the effect in OpenGL ES though.

https://aspectsweb.co.uk/enjay/doom/Tes ... ellite.pk3



User avatar
Nash
 
 
Posts: 17481
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: Model displays weird surface effect, but only when scaled

Post by Nash »

Enjay wrote: Fri Feb 21, 2025 7:59 pm If anyone is interested in looking at it to see if it happens for them, I just threw together this quick demo pk3.

Just load it in GZDoom and start map01.

It'll be interesting to see if it happens with other people and, if not, what the difference in settings are.

As I mentioned before, I have tried with AO on, and in OpenGL and Vulkan. None of these make any difference. I did not notice the effect in OpenGL ES though.

https://aspectsweb.co.uk/enjay/doom/Tes ... ellite.pk3



I tried the example file locally on my end. I'm not getting the visual glitches. Strange. Care to post your GZDoom INI? Maybe some settting in there is specifically causing this.

(if you're not comfortable posting the INI publicly, you can do so privately either here on in my Discord DMs, since we have added each other there)
User avatar
Enjay
 
 
Posts: 26878
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Model displays weird surface effect, but only when scaled

Post by Enjay »

Spurred ojn by your post, I just went through options until I found something that made a difference. I should have done that earlier. It didn't take long.

I can post my ini if it's still needed, but I'm pretty sure that I have found the culprit:

Sector Light Mode: Vanilla

With this option set, the effect is present. With the other options, the effect goes away.
And, for info, I just checked VkDoom and it's the same.

Quite why vanilla sector lighting mode creates an effect on the surface of a model, but only if the model is scaled up, I have no idea, but it does seem to. :shrug:
Worth digging further? Worth a bug report?
dpJudas
 
 
Posts: 3159
Joined: Sat May 28, 2016 1:01 pm

Re: Model displays weird surface effect, but only when scaled

Post by dpJudas »

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.
User avatar
Enjay
 
 
Posts: 26878
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Model displays weird surface effect, but only when scaled

Post by Enjay »

Okidokey. Thanks for that explanation. It makes sense. It's interesting that I managed to make a second model that shows basically the same effect. I must have just hit that sweet (sour) spot again simply because I tried to make the new model as close in size and shape as possible to the original Quake2 model. They are the only two models that I have noticed this on though (and I have checked a lot).

Anyway, you've posted both an explanation and a potential fix, so I've posted a bugs thread just so it doesn't get lost.
viewtopic.php?t=80203

Thank you kindly. :)
dpJudas
 
 
Posts: 3159
Joined: Sat May 28, 2016 1:01 pm

Re: Model displays weird surface effect, but only when scaled

Post by dpJudas »

You're welcome. :)

Return to “Assets (and other stuff)”