Sprite clipping with 3D & shader

Have a question, suggestion, or comment about Aleph One's features and functionality (Lua, MML, the engine itself, etc)? Post such topics here.
Post Reply
User avatar
ravenshining
Vidmaster
Posts: 892
Joined: Jun 17th '17, 22:50
Location: Hawai'i

I've long been bothered by an issue where sprites get clipped by walls and floors, especially explosion effects and corpses. Today, I did some testing and narrowed it down to occuring under the shader renderer when a 3D plugin is running.

Typical, all shots clip through the wall:
BiggerGunsNearby_0062.jpg
They also pass though corners:
BiggerGunsNearby_0065.jpg
This happens in the original, with all plugins disabled except 3D scenery, at minimum resolution:
TheRose_0017.jpg
This is using the Feb. 26 2017 build under Debian 8 on a Nvidia Quadro FX 1600M
User avatar
The Man
Vidmaster
Posts: 1203
Joined: Aug 6th '08, 05:23
Location: Sarasota, FL
Contact:

Thanks for making this thread; I’d been noticing this happening and had been wondering what the hell was causing it. I’ve noticed several much more conspicuous examples in my own play; I may either take a screenshot or point to a specific frame in a YT video I’ve uploaded tomorrow.

Which option do I disable to stop this behaviour until it gets fixed? 3D models? Bump mapping? Something else?

(FWIW, it’s also happening in the most recent 2015 release as well, AFAICT.)
User avatar
treellama
Vidmaster
Posts: 6110
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

If you switch to the OpenGL (Classic) renderer and turn the Z-buffer off (this will cause clipping issues with 3D models, so disable those as well) it should look OK. If you want 3D models or the shader renderer, you're out of luck; we have to use the Z-buffer and it will cause projectiles to clip where they intersect with walls and models.
User avatar
TrajansRow
Born on Board
Posts: 70
Joined: Sep 29th '16, 15:53

There are probably a few ways to improve sprite rendering alongside 3D models, if anyone wanted to put in the effort. One might be to have a second depth target for the 3D model shader. That would permit sprites to be depth tested against models, but not walls or floors.
User avatar
ravenshining
Vidmaster
Posts: 892
Joined: Jun 17th '17, 22:50
Location: Hawai'i

I was very tired when I posted and apparently forgot to mention that the Shader renderer works fine as long as a 3D-model plugin isn't loaded. I can set shader and enable 3D models, but it's not until the game actually has a 3D plugin to load does it start clipping.

I *could* use classic OpenGL, although it tends to make me nauseous, and means I can't have bump maps. Interesting, if I enable the Z-buffer under classic, all the sprites and models dissappear.

One problem I could see with your suggestion Trajan is when a sprite is partially covered by liquid, in that case you do want the liquid texture to intersect the sprite. Here's another idea, what if sprites that impact a surface were oriented along the surface? Might look weird at extreme angles but better than being clipped. Or, again specifically for impact effect sprites, what if the sprite was drawn at a distance away from the wall equal to, say, the first frame's x-offset?

Meanwhile for corpses and scenery items, on my end I could alter the frame data to avoid intersections with the floor. Won't solve the problem for any other scenarios and may again look weird at certain angles, but it's something I can do.
User avatar
TrajansRow
Born on Board
Posts: 70
Joined: Sep 29th '16, 15:53

I’m pretty sure partially submerged sprites are drawn in two halves, so even that doesn’t need the depth test.

With z-buffering in classic, could you tell if a small portion of some sprites below the floor were visible?

What you might be thinking of is glPolygonOffset. That could solve the wall clipping problem by tweaking the depth test to favor more of the sprite. That could cause incorrect results if a sprite were near a 3D model, but may be better than clipping at every surface.


If you don’t care too much about perfect sorting relative to 3D objects, just set the depth function to GL_ALWAYS in that node sprite helper function (or whatever it is) and call it a day.
User avatar
treellama
Vidmaster
Posts: 6110
Joined: Jun 2nd '06, 02:05
Location: Pittsburgh
Contact:

ravenshining wrote:I was very tired when I posted and apparently forgot to mention that the Shader renderer works fine as long as a 3D-model plugin isn't loaded. I can set shader and enable 3D models, but it's not until the game actually has a 3D plugin to load does it start clipping.
I thought we put in a hack to disable the depth test when 3D models were not in use, but I couldn't find it in the code when I went to reply. That was a long time ago. Sounds like you have your answer though.
User avatar
ravenshining
Vidmaster
Posts: 892
Joined: Jun 17th '17, 22:50
Location: Hawai'i

So, after almost a year now, I finally have a real answer, at least for typical object replacement models if not decorative, non-solid models. While looking into how to make my own 3D models for Aleph One, I found this in the MML documentation:
Hopper wrote:• force_sprite_depth: require sprites to be depth-sorted inside the model (default: false)
This flag, active only in the shader renderer, will force sprites to strictly obey the Z-buffer. This allows sprites to be drawn correctly between different sections of a model (good for open models, like a house), but at the expense of clipping artifacts between sprites and walls/floors. In the default case, sprites are drawn entirely behind or entirely in front of the model. Use this flag sparingly, as the side effects are quite noticeable.
Looking through Tacticus's 3D model plugin, it appears he enabled this option for the biohazard crate, which is rather unnecessary as you can't walk through the biohazard crate. So, I disabled it, and voilá! No more clipping sprites!

I was afraid disabling it might make my escape-pod start to Arrival impossible, but this was not the case: in first person view, you still appear to be inside the escape pod, only in 3rd person view do you appear to be superimposed.
User avatar
Ku-rin
Born on Board
Posts: 59
Joined: Feb 15th '19, 15:14
Location: Not Invented Here

Hahaha, after our discussion I was looking through the MML documentation and saw that... "Ah, that sounds like it but it's disabled by default, sooo..." Of course I didn't have that enabled in *my* stuff, but at 2 in the morning I'm as clever as a rock.

Good detective work!
User avatar
General Tacticus
Cyborg
Posts: 209
Joined: Apr 5th '13, 04:27

Whoops, I think the flag was left there from when I pasted in a segment of script from another thing i was working on at the time.
Post Reply