Page 1 of 5

[Patch] 3D Miscellaneous

PostPosted: Wed Mar 15, 2017 6:27 am
by HarryTuttle
Before going in details with fixed shading, (spot)lighting and fog, I'll attach, in preparation for next phase, these random little patches.

Changelog:

- Added caching of remaining polygon header properties. *Could* improve (?) a little bit rendering performance.

- Improved the "hacky" way to promote polygon-as-shadows to layered (stencil) type, fixing some corner case: colored balloons in ECA, speeder-bike laser beam in SWTrilogy (Endor forest chase level), etc.
I've got some idea to discuss about translucent poly and the shadows issue, but more on another topic.

- Ability to load, if present, external vertex and fragment shaders for 3D layer (like the old engine) and scroll fog. It could make debugging easier for now and may be removed on official builds. Path names are hard-coded:
[Supermodel path]/shaders/fragmentShader.glsl
[Supermodel path]/shaders/vertexShader.glsl
[Supermodel path]/shaders/fragmentShaderFog.glsl
[Supermodel path]/shaders/vertexShaderFog.glsl

Update:

Removed leftover debug string, re-uploaded patch.

[Patch] 3D Miscellaneous

PostPosted: Wed Mar 15, 2017 6:41 am
by HarryTuttle
A couple of screenshots:

Before:
swt1.jpeg
Wrong laser colors
swt1.jpeg (217.16 KiB) Viewed 7390 times


After:
swt2.jpeg
Correct laser colors
swt2.jpeg (255.49 KiB) Viewed 7390 times

Re: [Patch] 3D Miscellaneous

PostPosted: Wed Mar 15, 2017 6:50 am
by HarryTuttle
Other two (note the left half of the balloons):

Before:
eca1.jpeg
Wrong shading
eca1.jpeg (226.31 KiB) Viewed 7386 times


After:
eca2.jpeg
Correct shading (well... not really correct, there's also a transparency issue)
eca2.jpeg (225.29 KiB) Viewed 7386 times

Re: [Patch] 3D Miscellaneous

PostPosted: Wed Mar 15, 2017 6:56 am
by Ian
What was up with the laser?
Also should that scene not have fog?

Re: [Patch] 3D Miscellaneous

PostPosted: Wed Mar 15, 2017 7:00 am
by HarryTuttle
Ian wrote:What was up with the laser?
Also should that scene not have fog?


Laser has wrong colors, the scene has fog (checked with real footage). I used the built-in shaders btw.

Re: [Patch] 3D Miscellaneous

PostPosted: Wed Mar 15, 2017 7:03 am
by Ian
How did it end up with the wrong colours ? :)
If i was to guess .. incorrectly stenciling translucent polys.. this is where hacks trip you up >_<

Re: [Patch] 3D Miscellaneous

PostPosted: Wed Mar 15, 2017 7:17 am
by HarryTuttle
Ian wrote:How did it end up with the wrong colours ? :)
If i was to guess .. incorrectly stenciling translucent polys.. this is where hacks trip you up >_<


Exactly :) That's why i tried to target specific instances of polygons used as "shadow", but it's still not perfect, there should be some issue with the shadows in skichamp.

Anyway I wouldn't bother too much since it's a hack anyway and eventually will be replaced with correct emulation.

Re: [Patch] 3D Miscellaneous

PostPosted: Wed Mar 15, 2017 7:23 am
by Ian
The actual stencil bit I found is only used *i think* by the shadows in sega rally. I don't know what other games are doing, or how the h/w is processing them.
There is a stipple alpha bit in header 6, but we aren't sure if it's used

Some of the biggest issues that remain are transparency related. If you try lemans24, it looks quite broken in places. For some reason the depth test is always enabled in the model3, so translucent polys always depth test against each other. It leads to some interesting problems on the original h/w itself.

Re: [Patch] 3D Miscellaneous

PostPosted: Wed Mar 15, 2017 7:44 am
by HarryTuttle
Ian wrote:The actual stencil bit I found is only used *i think* by the shadows in sega rally. I don't know what other games are doing, or how the h/w is processing them.
There is a stipple alpha bit in header 6, but we aren't sure if it's used

Some of the biggest issues that remain are transparency related. If you try lemans24, it looks quite broken in places. For some reason the depth test is always enabled in the model3, so translucent polys always depth test against each other. It leads to some interesting problems on the original h/w itself.


Ok let's anticipate the transparency discussion :D

I'm quite sure that translucent poly are always single sided, I've forced that condition and it seems to solve the remaining issue on meshes that have both single and double sided polys (again those colored balloons...).

I've got instead a theory about the polygon orientation: I think that the Real3D keeps dynamically their face normals toward the camera, this resolves some issues in oceanhunter (the transparent helmets in attract mode), the atmosphere halo around Endor in some open space scene in SWT, etc. Maybe that could be how "shadow-polys" are rendered without flicker, instead of implementing a co-planar check every time.

I'll post some screenshots later. But sadly I've not the skills to mess with vertex/face normals in your 3D engine. You can surely find the way faster. It could be worth a try.

About the depth test: yes, I've seen that odd effect and honestly I'd keep that (again the accuracy thing... :P )

I'm also sure that transparent-not-textured poly are rendered in another, separate, pass in the render pipeline. Last year I've made a proof-of-concept patch on the old engine and it fixed, for example, the priority (visibility) between the snow and the shadows in Sega Rally 2, maybe there're other cases.

Re: [Patch] 3D Miscellaneous

PostPosted: Wed Mar 15, 2017 8:03 am
by HarryTuttle
The "Endor anomaly":
swt3.jpeg
swt3.jpeg (86.07 KiB) Viewed 7358 times

There's what seems to be a flipped triangle creating a seam.

Scuba helmets in Ocean Hunter:
oh1.jpeg
oh1.jpeg (173.05 KiB) Viewed 7358 times