Closed sshukul closed 5 years ago
So I looked into this a bit more and got the issue "semi-fixed" now by adding this to line 241 of MOAIGfxDeviceMtxCache.cpp inside SetVertexTransform() :
this->UpdateShaderGlobals ();
It looks like there was an UpdatePipelineTransforms() call at the end of the SetVertexTransform() function in 1.5 but this is missing from 1.7. The UpdateShaderGlobals() function looks like it's new equivalent.
This almost fixes the issue to where the world global is being updated for things like scale.
The problem is it's not consistent and occasionally doesn't update ... for example, in my game I've got a player character that's made of a MOAITransform which is the parent to many separate MOAIProp2D objects for the body parts (like head, arms, legs etc.). It's done that way using a Moai plugin for Spriter. With this new fix, the world transform updates most of the time, but after a few switches back and forth to the scale, one of the props will not get the updated transform, so it's lighting is backwards compared to the rest of the body, like so:
http://i.imgur.com/4mY2wp2.jpg
Notice the shoulder / upper arm prop is lighted backwards compared to the rest ... this is because it's GLOBAL_WORLD matrix is not being updated in the shader after the -1 scale is applied to the prop, even when the rest of the props are updated with the correct matrix value.
Any guesses as to why this could be happening or where I should look to investigate further guys? This has me stumped for the last few days even after making what looks like progress on the issue.
I can confirm this issue is somehow fixed in the latest version, closing.
Nope sorry, not fixed, still reproduceable. If someone is willing to look into this I can provide some sample code to reproduce, thanks.
This is finally fixed in Moai 2.0! Will mark as closed once merged into moai-dev.
As per the second to last entry in the forum post.
It looks like the World transform matrix is not being set or properly in the shader using the new MOAIShaderProgram class and the GLOBAL_WORLD enum introduced in 1.6, instead of the pre 1.6 UNIFORM_WORLD enum. It looks like the matrix may be getting initialised and bound in the shader but isn't getting updated for things like scale or rotation transforms.
I'm using it for a normal mapped point lighting shader which worked well pre-1.6 but with the changes the world matrix doesn't seem to account for such transforms (for example when the player prop is flipped to face another direction, the lighting flips with it instead of adjusting as if it kept coming from the same point).
Here is the full shader code:
Is this a bug or does the transform matrix need to be set differently somehow?
Many thanks for looking into it, as of now I am unable to release on iOS without upgrading to 1.6 because of 64 bit compilation, and this is holding it back.