Albeoris / Memoria

Final Fantasy IX tools
MIT License
374 stars 49 forks source link

Soulcage: realism shader straight edges #780

Open snouz opened 2 months ago

snouz commented 2 months ago

image

@EricHu33

EricHu33 commented 2 months ago

You mean the blocky appearance?

It's intended behaviour, the boss's mesh are simply too low poly and blocky. thus apply lighting will have this kind of apperance. While most character and monster can get away by smooth the mesh normal at runtime. This boss's blocky 3d model can not be fix by smooth algo. The only way to fix it is use a 3d model with higher polycount. Which is out of my reach atm.

edit : maybe I can try to exclude the boss to have custom shader apply....I'll think about it.

EricHu33 commented 2 months ago

(I think some picture may explain it better than my poor English)

Below is a little compare between low poly shading ball and high poly shading ball. Same lighting angle, same light intensity. the only difference is the polycount.

This just shows how 3d model itself plays a big part of realtime shading. image image image

barkermn01 commented 2 months ago

Yeah i would agree with @EricHu33 this is not a bug in Memoria as it stands, it should be a mod fixes this by adding higher poly models however I'm not sure if Memoria actually support that (outside my knowledge level)

snouz commented 2 months ago

Not sure I truly understand. Other models, for example other monsters, don't seem particularly more detailed, and yet the separation between dark and light is blurred. Is there a fundamental difference?

image

EricHu33 commented 2 months ago

The answer is simple - Soulcage 3d model is just different. how they model the 3d mesh just making it become blocky. Therefore - This boss's blocky 3d model can not be fix by smooth algo. How well my smooth normal algo fix the model is case by case. In most case it's enough. in some cases it's not. It will affect by how the model's face/vertex was layout in the first place.

Since the original game is not shaded. they can get away with this problem (and many other issue tbh, some model's are simply not in today's standard).

But once we applied shading. These kind of issue will shows up. And the ideal way to fix it will be modify the 3d model itself.

EricHu33 commented 2 months ago

I can tried to giving this boss a larger angle threshold for smooth normal (It determinds within what angle 2 triangle faces are conisdered to connect face, therefor needs to smooth out)

The angle is 120 now, I'll tried a larger angle and see if it works for soulcage. Making it too large usually has nagative impact on the appearance. But we can make soulcage a special case.

image

barkermn01 commented 2 months ago

The angle is 120 now, I'll tried a larger angle and see if it works for soulcage. Making it too large usually has nagative impact on the appearance. But we can make soulcage a special case.

is there a way to check if there is a custom model loaded before you do that, if someone create a new model we probably don't want it to do that for the new model version

Tirlititi commented 2 months ago

There is no custom model importation in Memoria yet. I don't want to write a FBX importer myself (or an importer for another suitable 3D model format) and I didn't find a good one available at the time I searched for it.

iwubcode commented 1 month ago

@Tirlititi - sorry, I know this is a while after you posted and you may already be aware but maybe check out GLTF? Seems like there's a package available for C# ( https://github.com/vpenades/SharpGLTF ) if you're interested.

Tirlititi commented 1 month ago

That looks very good indeed. Since it isn't FBX, I am not sure if we can use it directly though. It doesn't import 3D model assets into UnityEngine.GameObject but rather into SharpGLTF.Schema2.ModelRoot (and the same with materials, animations...). Although both seem to be very similar, doing a converter would be an overkill I think. It might be that we could use SharpGLTF.Schema2.ModelRoot directly though.

So that's a good track but alas it still requires some work, possibly a heavy one, to implement it in Memoria.

barkermn01 commented 1 month ago

There is no custom model importation in Memoria yet. I don't want to write a FBX importer myself (or an importer for another suitable 3D model format) and I didn't find a good one available at the time I searched for it.

Do we have to? i was thinking about just using Unities Prefab system, Unity can load Prefabs, then it's on the mod creators to create the prefab and being that unity is free for this kind of stuff i think it would work. (source https://discussions.unity.com/t/loading-prefab-from-path/190053/4 ) at bit of topic for this but then so i will create a new issue Feature Request to look into this.

EricHu33 commented 1 month ago

It's not that easy, prefab itself is a Unity Editor feature, which Memoria have no access (We can't open memoria inside unity editor). The prefab generation are all in Unity Editor. We can only use prefab-related API for assets that already exist by the time FF9 PC build the exe.

To load a data that similar to prefab at runtime you need to write a serializer by your own.

https://discussions.unity.com/t/unity-create-prefab-at-runtime/668688/9

barkermn01 commented 1 month ago

It's not that easy, prefab itself is a Unity Editor feature, which Memoria have no access (We can't open memoria inside unity editor). The prefab generation are all in Unity Editor. We can only use prefab-related API for assets that already exist by the time FF9 PC build the exe.

To load a data that similar to prefab at runtime you need to write a serializer by your own.

https://discussions.unity.com/t/unity-create-prefab-at-runtime/668688/9

It appears there has been a misunderstanding regarding my statement. I suggested that mod creators could utilize the Unity Editor to create prefabs. Memoria has the capability to access Unity's coded systems, which should enable us to perform various actions within the engine to load the package. In fact, we often load custom assets, as demonstrated by the complete voice acting system. Furthermore, we can also block all sounds from entering the Unity Engine Core and redirect them to SoLoud. This illustrates how closely Memoria is integrated with the Unity Engine.

What I mean is that mod creators should use the Unity Editor to create assets (models, textures, shaders, etc.) and then compile them into an Asset Bundle. Memoria then employs the Asset Bundle within the Unity Engine. This code is already part of Unity's codebase, allowing Memoria to invoke it. Essentially, Unity creates the Bundle, fully converting it to Unity's format, eliminating the need for parsing anything. It's precisely what the editor does when you import an FBX file—it converts it to its format. Thus, the conversion process is already handled.

https://docs.unity3d.com/Manual/LoadingResourcesatRuntime.html

Please note that I have verified this should be feasible, as it is similar to how modding occurs in Unreal Engine, where people build packages to be loaded by the engine that inject and override base files. The only difference is that Unreal Engine automatically loads files; we would simply need to program Unity to load files, which is significantly easier without the need to align cumbersome signatures.

EricHu33 commented 1 month ago

It appears there has been a misunderstanding regarding my statement. I suggested that mod creators could utilize the Unity Editor to create prefabs. Memoria has the capability to access Unity's coded systems, which should enable us to perform various actions within the engine to load the package. In fact, we often load custom assets, as demonstrated by the complete voice acting system. Furthermore, we can also block all sounds from entering the Unity Engine Core and redirect them to SoLoud. This illustrates how closely Memoria is integrated with the Unity Engine.

Ah I see, I now understand it more clearly, thanks for the clairify.