nteragadev Posted July 17, 2014 Share Posted July 17, 2014 It's more glaring in my custom mesh but you can also see it in the included "crawler" mesh, Top is "textured" and bottom are "textured + lighting". When the lighting is turned on, the mesh distorts. Both of these examples are from the same exact view. In the crawler you can see the neck silhouette has altered. In mine...well it speaks for itself. Unusable levels of distortion. I also tested the fpsautopistol mesh and it too distorts, though the distortions are not detrimental to its appearance. The distortions carry over straight into the game itself. I'm using the LWdemo in hopes of determining whether to purchase. If this is a demo-only issue, I would like to know. If not, I am concerned since I am a modeler/texture artist. Link to comment Share on other sites More sharing options...
nteragadev Posted July 17, 2014 Author Share Posted July 17, 2014 Okay, looking into it further, it is directly related to materials with animations included. On the left is my mesh with the crawler mat applied to the chest and neck. On the right is no mat. What's interesting is even though the mat is different the distortion points are identical. Not pictured but relevant, the test I did with a static material, looked the same as no material as far as distortions go. Link to comment Share on other sites More sharing options...
Josh Posted July 17, 2014 Share Posted July 17, 2014 That is rather odd. Looks like a small inaccuracy in the weighting equation. We did recently modify the FBX importer to deal with something like this, but I can't promise this exact issue was fixed without seeing your FBX models. My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
nteragadev Posted July 17, 2014 Author Share Posted July 17, 2014 I used a blender exporter that exports straight to leadwerks asset formats, mdls and mats. I can try the FBX exporter but I figured a direct export would be the ideal. If FBX works better and avoids this issue I will happily switch. It's worth noting that some distortion occurs even with included assets like the crawler and fpsautopistol models. Link to comment Share on other sites More sharing options...
Josh Posted July 17, 2014 Share Posted July 17, 2014 I am guessing it's an issue of the bone weights not being normalized in the vertex shader. If you can post a model that easily shows the problem I will test it. My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
nteragadev Posted July 17, 2014 Author Share Posted July 17, 2014 I've PMed you the link. The problem is most obvious around the hands and the chest and neck. Link to comment Share on other sites More sharing options...
Josh Posted July 17, 2014 Share Posted July 17, 2014 Thanks for pointing that out. A small change in the shader fixed it. In the file "Shaders/Model/Animated/diffuse.shader" find this block of code in the vertex source: mat4 animmatrix = bone.matrix[vertex_boneindices[0]] * vertex_boneweights[0]; animmatrix += bone.matrix[vertex_boneindices[1]] * vertex_boneweights[1]; animmatrix += bone.matrix[vertex_boneindices[2]] * vertex_boneweights[2]; animmatrix += bone.matrix[vertex_boneindices[3]] * vertex_boneweights[3]; Replace it with this: vec4 wt = vertex_boneweights; float m = wt[0]+wt[1]+wt[2]+wt[3]; wt[0]/=m; wt[1]/=m; wt[2]/=m; wt[3]/=m; mat4 animmatrix = bone.matrix[vertex_boneindices[0]] * wt[0]; animmatrix += bone.matrix[vertex_boneindices[1]] * wt[1]; animmatrix += bone.matrix[vertex_boneindices[2]] * wt[2]; animmatrix += bone.matrix[vertex_boneindices[3]] * wt[3]; Before: After: This fix will make it into the official build in the next update. 1 My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
nteragadev Posted July 17, 2014 Author Share Posted July 17, 2014 Awesome! That's wonderful. Thank you very much sir! Bonus question, will the problem crop back up if I have to use a different shader? Link to comment Share on other sites More sharing options...
Josh Posted July 17, 2014 Share Posted July 17, 2014 There are three animated shaders. You must make this fix in all three. Or wait for the next update to go out, and it will be fixed for you. 1 My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts