[2.1+] MeshLodGenerator wants FLOAT3, but importV2+DearrangeToInefficient gives FLOAT4 Topic is solved

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
rujialiu
Goblin
Posts: 296
Joined: Mon May 09, 2016 8:21 am
x 35

[2.1+] MeshLodGenerator wants FLOAT3, but importV2+DearrangeToInefficient gives FLOAT4

Post by rujialiu »

Hi!

When calling MeshLodGenerator with a meshv1 imported from meshv2, we got an assertion failed:

Code: Select all

    void LodInputProviderMesh::addVertexData(LodData* data, v1::VertexData* vertexData, bool useSharedVertexLookup)
    {
        if ((useSharedVertexLookup && !mSharedVertexLookup.empty()))   // We already loaded the shared vertex buffer.
        {
            return;
        }
        OgreAssert(vertexData->vertexCount != 0, "");

        // Locate position element and the buffer to go with it.
        const v1::VertexElement* elemPos = vertexData->vertexDeclaration->
                                           findElementBySemantic(VES_POSITION);

        // Only float supported.
        OgreAssert(elemPos->getSize() == 12, "");  ////////// failed here. Looks like it wants FLOAT3 for VES_POSITION
All of our v2 meshes uses HALF4 for VES_POSITION. It has a dearrangeToInefficient methods to convert from half/qtangents to floats, but it got FLOAT4 instead of FLOAT3, which MeshLodGenerator doesn't like. I tried to remove the assert and it doesn't crash anymore. We haven't finished our codes so we don't know whether the result will be ok, but it looks like the assertion should be asserting FLOAT3 OR FLOAT4 instead of FLOAT3 only?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5299
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: [2.1+] MeshLodGenerator wants FLOAT3, but importV2+DearrangeToInefficient gives FLOAT4

Post by dark_sylinc »

What semantic? Pos, normal or tangents?
rujialiu
Goblin
Posts: 296
Joined: Mon May 09, 2016 8:21 am
x 35

Re: [2.1+] MeshLodGenerator wants FLOAT3, but importV2+DearrangeToInefficient gives FLOAT4

Post by rujialiu »

dark_sylinc wrote: Wed Apr 03, 2019 3:09 pm What semantic? Pos, normal or tangents?
According to the assertion code, it looks like position only. And I think when dearrange to inefficient, qtangent converts to float3 normal and float3 tangent?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5299
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: [2.1+] MeshLodGenerator wants FLOAT3, but importV2+DearrangeToInefficient gives FLOAT4

Post by dark_sylinc »

Nevermind, I just looked at the code and it's VES_POSITION.

Anyway, it shouldn't matter. Judging from the code, it uses an abstracted way to read from the vertex (although a bit inefficient, this is good, it can adapt to different vertex definitions), thus it just ignores the 4th element in the float.

This is also not a problem because the .w should be filled with 1.0f

I'll fix up the assert
rujialiu
Goblin
Posts: 296
Joined: Mon May 09, 2016 8:21 am
x 35

Re: [2.1+] MeshLodGenerator wants FLOAT3, but importV2+DearrangeToInefficient gives FLOAT4

Post by rujialiu »

dark_sylinc wrote: Wed Apr 03, 2019 3:49 pm I'll fix up the assert
Thanks!! But today the MeshLodGenerator crashed on a rather big (>60MB) v2 mesh. Will try to provide more info tomorrow. I hope it handles meshes of this size (e.g. not using quadratic memory etc :P)
Post Reply