mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-12 19:31:41 +00:00
Implement Singlepass Terrain Render
This commit is contained in:
parent
49a8c0ad36
commit
87dd7ffc4a
35 changed files with 1658 additions and 951 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue