OpenMW / collada-exporter

"Better" Collada exporter for Blender, orignally developed by the Godot Engine community
https://godotengine.org
GNU General Public License v2.0
6 stars 1 forks source link

Material pipeline fixes #12

Closed Lamoot closed 2 years ago

Lamoot commented 2 years ago

There are a few issues with how materials are set-up in Blender and what is then exported. The two I recently encountered are:

  1. The material is exported with RGB(1, 1, 1) <emission> to offset how the shadowed sides of models are very dark. It works decently during daytime but breaks during night, when they objects don't look shaded enough emission_day_night Here we should have <emission> at RGB(0, 0, 0) unless it's enabled in the material. For alleviating the initial dark shading issue we should hook up some Blender value to <ambient>

  2. Texture paths in the exported file depend on the relative location of the source .blend file and .dds texture file. Currently I fix this manually by editing the .dae file and making sure the texture paths go from ../../../../../Tree/textures/leaves.dds to textures/leaves.dds To keep in mind is that the valid path can be different depending if the texture is in textures/ subfolders.

Lamoot commented 2 years ago

I've looked a bit more into the 1. issue and how various values appear in OpenMW. For <emission> we should take the emission value of the principles BSDF material node or fall back to RGB(0, 0, 0) if the node is for some reason not available. For <ambient> it should be simplest to take nelsson's proposal from Discord to use bpy.data.worlds["World"].color and write it to <ambient>.

And of course document all of this.

Lamoot commented 2 years ago

Testing, bpy.context.scene.world.color works nicely here and is easy to access.

For the rest, I'm thinking of a workflow where we get all the required values from the Specular BSDF shader node. It's a shader based on the same legacy system that Collada uses and contains all the values we need. specular_shader_setup

This would work so that this shader node is REQUIRED in the material. Otherwise it defaults to some sane values. This node is the best way to mirror the Blender - Collada values in a way that it's clear to users.

Lamoot commented 2 years ago
  1. Issue: materials are always exported as double-sided. Not sure if and how this affects performance, but disabling doube-sided might be desired for artistic reasons. The parameter can be hooked to bpy.data.materials["Material"].use_backface_culling property in Blender.
Lamoot commented 2 years ago

All of the mentioned issues have been fixed by https://github.com/OpenMW/collada-exporter/pull/14 so I'm closing the issue as resolved.