ogre-next icon indicating copy to clipboard operation
ogre-next copied to clipboard

"Optimise Vertex Buffers For Shaders" breaks smooth shaded faces

Open Slamy opened this issue 3 years ago • 4 comments

I first thought that this was an ogre bug. But it seems that this converter was to blame. Please have a look at this model. blender

I've exported it using "Optimise Vertex Buffers For Shaders" checked and opened it in the HLMS editor. WithShaderOptimize The specular part looks weird and divided. Then I disabled this option and got this. WithoutShaderOptimize

I don't reallly know why this happens and how. But still I want you to know this.

Slamy avatar Jun 06 '21 16:06 Slamy

moving this to ogre-next, as we merely forward the options to OgreMeshTool for post-processing: https://github.com/OGRECave/blender2ogre/blob/e04087ed80017d017cca93f445cfd6b609a0b32e/io_ogre/util.py#L192-L194

paroj avatar Jun 06 '21 18:06 paroj

Optimization is lossy.

If the mesh is too big (scale problem, e.g. size > 50 units) precision problems appear in the position due to half floating point. This is the most common problem

Same happens for UVs. If UV are outside 0...1 range half floating point may not be accurate enough.

QTangent optimization is the less prone to problems, but I suppose if the topology is funny it could cause trouble specially if the normals or tangents perform near 180° flips across edges

The first thing to do would be to enable each optimization one by one to find the culprit. Once isolated it may be possible to fix by changing the mesh. But depending on the cause, the solution may be to disable that specific flag, because basically it'd be "working as intended" and the optimization simply should not be applied for this case

darksylinc avatar Jun 06 '21 19:06 darksylinc

I mean. Now I know and knowing is half the battle. But how shall this tool proceed from here? I now know this but the next poor soul will fall into this trap again. Concerning psychology the usual user will always click on something which has the term "Optimize" in it.

@paroj There should be at least some sort of warning in the blender2ogre tool next to the check box. Or even rename it to "experimental optimization".

Slamy avatar Jun 07 '21 17:06 Slamy

I agree on the wording/messaging. But "Experimental" would send the wrong message (it's not experimental, it's not going to improve over time).

The technically correct term would be "lossy optimization" or "Optimization (lossy)", but I don't know if it's user friendly enough.

Alternatively: "Strict quality", when disabled we apply optimization

darksylinc avatar Jun 07 '21 17:06 darksylinc