I'm currently in the process of writing a small glTF importer based on tinygltf, mostly for fun, and the flexibility that the format (seems to) offer.
I'm at the point where I'm loading meshes correctly, so I'm now tackling loading materials.
tiny_gltf loads the images for you using stb_image, and provide you with a simple array of bytes and the relevant metadata (number of channels, width, height, stuff like this).
workflow is set to
I figured out that I could load this data into an Ogre::Image object this way with Image::loadDynamicImage, then creating a texture (TextureManager::createManual) and feed it that object:
Code: Select all
Ogre::TexturePtr OgreTexture = textureManager->createManual(name,
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TextureType::TEX_TYPE_2D, image.width, image.height,
1, 1, pixelFormat, Ogre::TU_DEFAULT
#ifdef DEBUG_TEXTURE_OUTPUT
| Ogre::TU_RENDERTARGET
#endif
);
OgreTexture->loadImage(OgreImage);
#ifdef DEBUG_TEXTURE_OUTPUT
//This was for debug, for that line to work you nee dthe texture to be declared with "texture usage render target"
OgreTexture->getBuffer()->getRenderTarget()->writeContentsToTimestampedFile(name, ".png");
#endif
The problem I'm having is when creating an HlmsPbs datablock. I can create one and set every parameters I want by code (color, metalness, roughness... All that jazz)
The problem I'm having is when I attempt to set a diffuse texture to my datablock, I'm getting a full black output, that is quite odd:
Code: Select all
datablock->setTexture(Ogre::PbsTextureTypes::PBSM_DIFFUSE, 0, texture);
I tried to solve the problem by myself, but I'm running out of ideas ^^"
It looks like I'm doing something that makes the generated pixel shader just output black pixels, but I don't really know where to look at this point.
Somebody know what I'm doing wrong here? ^^"