Implement Singlepass Terrain Render

This commit is contained in:
Lukas Aldershaab 2021-01-01 21:05:21 +01:00
parent 49a8c0ad36
commit 87dd7ffc4a
35 changed files with 1658 additions and 951 deletions

View file

@ -894,6 +894,42 @@ Torque::Path GFXTextureManager::validatePath(const Torque::Path &path)
return correctPath;
}
GBitmap *GFXTextureManager::loadUncompressedTexture(const Torque::Path &path, GFXTextureProfile *profile, U32 width, U32 height)
{
GBitmap* inBitmap = loadUncompressedTexture(path, &GFXTexturePersistentProfile);
if (inBitmap == NULL)
{
Con::warnf("GFXTextureManager::loadUncompressedTexture unable to load texture: %s", path.getFullPath());
return NULL;
}
// Set the format so we don't have to handle which channels are where.
if (!inBitmap->setFormat(GFXFormatR8G8B8A8))
{
Con::warnf("GFXTextureManager::loadUncompressedTexture unable to handle texture format: %s", path.getFullPath());
return NULL;
}
GBitmap* outBmp = new GBitmap(width, height, true, GFXFormatR8G8B8A8);
U8* oBits = (U8*)outBmp->getWritableBits();
for (S32 y = 0; y < width; y++)
{
for (S32 x = 0; x < height; x++)
{
ColorI texelColor = inBitmap->sampleTexel(x / F32(width), y / F32(height), true).toColorI(true);
oBits[(y * width + x) * 4] = texelColor.red;
oBits[(y * width + x) * 4 + 1] = texelColor.green;
oBits[(y * width + x) * 4 + 2] = texelColor.blue;
oBits[(y * width + x) * 4 + 3] = texelColor.alpha;
}
}
return outBmp;
}
GBitmap *GFXTextureManager::loadUncompressedTexture(const Torque::Path &path, GFXTextureProfile *profile)
{
PROFILE_SCOPE(GFXTextureManager_loadUncompressedTexture);