Closed Lamoot closed 2 years ago
Ah, I didn't hook up some of the values. Fix will come.
Ready for review. In summary:
I tested this in a few different situations and things look to work well:
Have you tested alpha blended and alpha tested materials with this?
Ah, I haven't yet tested the alpha stuff. Can do later today.
Transparency is based on the material Blend Mode options? The dropdown with Opaque, Alpha Clip, Alpha Blend? Is there anything else that needs to be taken into account to how the texture is set up?
The alpha values for the model are configured in the Material Properties panel -> Settings -> Alpha Blend or Alpha Clip. When using Specular BSDF and connecting "alpha" to "transparency" the alpha is inverted whereas in the Principled Shader it works correctly. Therefore if we change to use the Specular BSDF, the alpha values probably need to be somehow inverted inside the Blender.
I hooked the exported transparency values to the specular shader. In the docs we should be very explicit that in Blender when viewing the transparency value alone, the result will match, but when testing a texture with alpha channel, users should invert the value. This is because the script automatically invert the transparency value at export, but we can't fix this with the texture ourselves.
I found a potential issue when exporting a material without a texture, I'll investigate first, before this can be merged.
I found a potential issue when exporting a material without a texture, I'll investigate first, before this can be merged.
Nevermind about that. It looks to be something with (my local?) build that makes all materials shadeless. It's not connected to the exporter, since the Land Racer, which was exported before any of this material exporter work was done, also shows shadeless in OpenMW.
We'll need to add a check when there are no valid material nodes present. It throws an error currently.
We'll need to add a check when there are no valid material nodes present. It throws an error currently.
Hmmm, this might already work as intended. I've tried exporting a mesh with various material / node combinations but I can't reproduce the error. Could've been some other reason for an error.
In any case, it can always be fixed if someone else stumbles upon it.
Is this ready?
I'd prefer to go over it one more time, but from what I've used it, it works well and as intended.
Will wait :)
I went over the export process with various different options and didn't get any errors or weird results. I'm confident it works well enough to be merged. If something comes up there's always the issue tracker where it can be reported.
Until now the exporter took the "Principles BSDF" shader node of the active material and used that to write COLLADA material values. It was only half working, as the principled shader is meant for PBR and its values don't match what COLLADA supports. Due to that, quite a few of the exported values were hard-coded and not exposed to the user.
This change makes it so that the "Specular BSDF" shader node and its values are used instead. The textures also work (though for OpenMW only the diffuse slot needs to be taken). Haven't done extensive testing yet.
Solves 1. issue in https://github.com/OpenMW/collada-exporter/issues/12