[2.3.0] Materials on Manually Created Mesh Topic is solved

Problems building or running the engine, queries about how to use features etc.
User avatar
haloman30
Halfling
Posts: 43
Joined: Mon Aug 29, 2022 2:53 pm
x 4

[2.3.0] Materials on Manually Created Mesh

Post by haloman30 »

Ogre Version: 2.3.0
Operating System: Windows 7 x64
Render System: Direct3D11

I'm running into an issue currently where materials are not properly applying to meshes that are created manually in C++ code. The meshes themselves appear to be intact and fine, and manual meshes that use vertex colors instead of any textures or PBS material work (though it does require an unlit datablock to be present).

The datablocks themselves appear to be fine, as I can use them on a generic plane mesh (as can be seen in the background of the attached screenshot) - but when I attempt to use them on the mesh, they don't show up and one of them seems to give some sort of error:

Code: Select all

OGRE EXCEPTION(1:InvalidStateException): Renderable needs at least 2 coordinates in UV set #0. Either change the mesh, or change the UV source settings in HlmsPbs::calculateHashForPreCreate at C:\Projects\Ogre\Ogre\ogre-next\Components\Hlms\Pbs\src\OgreHlmsPbs.cpp (line 805)

Not entirely sure what this means exactly - seems to suggest that the renderable (or maybe just a particular submesh) has less than 2 UV coordinates. The vertex layout gets generated at runtime based on the number of UV and color channels in the mesh - but for this particular mesh, this is the layout that it ends up using:

Code: Select all

Ogre::VertexElement2(Ogre::VertexElementType::VET_FLOAT3, Ogre::VertexElementSemantic::VES_POSITION);
Ogre::VertexElement2(Ogre::VertexElementType::VET_FLOAT3, Ogre::VertexElementSemantic::VES_TEXTURE_COORDINATES);

I've also tried applying a datablock to the Ogre::Item that the mesh gets assigned to - but it ends up spitting out the same error as before and doesn't change the appearance of the mesh at all.

The other datablocks don't log any errors - though I don't know if that's because they're "working", or if it's because it just stops trying to use any datablocks as soon as one fails.

The only other potentially relevant detail is that, at shutdown, an exception is thrown when it attempts to free vertex buffers - where it seems the data is already deleted/invalid, however this only happens if the mesh is placed in the scene. Not sure if that's related or if that's a separate issue elsewhere.

Below is an image of the mesh in-engine (and the plane that uses one of the meshes' datablocks):

Image

Any help or clues anyone can share is greatly appreciated!

User avatar
haloman30
Halfling
Posts: 43
Joined: Mon Aug 29, 2022 2:53 pm
x 4

Re: [2.3.0] Materials on Manually Created Mesh

Post by haloman30 »

Alright, some additional details I've managed to sort out:

Turns out that error message from before has nothing to do with it - there was some invalid model data that was getting retained for whatever reason (an issue with my own toolset, not OGRE). I've got that to stop displaying - however, the same crashing at shutdown issue mentioned as well as the main issue of the material not being applied remains.

User avatar
haloman30
Halfling
Posts: 43
Joined: Mon Aug 29, 2022 2:53 pm
x 4

Re: [2.3.0] Materials on Manually Created Mesh

Post by haloman30 »

Another update:

It appears the material issue only happens with PBS datablocks. Upon changing the materials over to unlit, suddenly everything displays correctly:

Image

The crashing at shutdown issue does seem to persist, however - though I'm leaning more towards that being a separate issue rather than related to this, given that it works with unlit materials.

User avatar
haloman30
Halfling
Posts: 43
Joined: Mon Aug 29, 2022 2:53 pm
x 4

Re: [2.3.0] Materials on Manually Created Mesh

Post by haloman30 »

Final update - found the problem!

For anyone else who might happen to run into this - the issue was caused by my own content system. Turns out that materials were defaulting the emissive value to white - which ends up with the objects being pure white with no texture or shading visible.

Fixing that ended up resolving the issue. I am a bit unclear still on the crashing issue, however - if I can't work that out in due time, I'll end up making a separate topic, as I assume that'd be better than burying it in here (though if I do, I'll probably add one more reply so that anyone in the future who runs into the issue can hopefully fix it too).

Image