**Refactor meshes format to support custom vertex layouts and new flexible api to access mesh data**
#3044 #2667
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "Engine/Serialization/FileWriteStream.h"
|
||||
#include "Engine/Graphics/RenderTools.h"
|
||||
#include "Engine/Graphics/Textures/TextureData.h"
|
||||
#include "Engine/Graphics/PixelFormatSampler.h"
|
||||
#include "Engine/Graphics/PixelFormatExtensions.h"
|
||||
#include "Engine/Utilities/AnsiPathTempFile.h"
|
||||
#include "Engine/Platform/File.h"
|
||||
@@ -199,7 +200,7 @@ bool TextureTool::ExportTextureStb(ImageType type, const StringView& path, const
|
||||
#endif
|
||||
|
||||
// Convert into RGBA8
|
||||
const auto sampler = GetSampler(texture->Format);
|
||||
const auto sampler = PixelFormatSampler::Get(texture->Format);
|
||||
if (sampler == nullptr)
|
||||
{
|
||||
LOG(Warning, "Texture data format {0} is not supported.", (int32)textureData.Format);
|
||||
@@ -218,7 +219,7 @@ bool TextureTool::ExportTextureStb(ImageType type, const StringView& path, const
|
||||
{
|
||||
for (int32 x = 0; x < texture->Width; x++)
|
||||
{
|
||||
Color color = SamplePoint(sampler, x, y, srcData->Data.Get(), srcData->RowPitch);
|
||||
Color color = sampler->SamplePoint(srcData->Data.Get(), x, y, srcData->RowPitch);
|
||||
if (sRGB)
|
||||
color = Color::SrgbToLinear(color);
|
||||
*(ptr + x + y * texture->Width) = color.ToFloat4();
|
||||
@@ -234,7 +235,7 @@ bool TextureTool::ExportTextureStb(ImageType type, const StringView& path, const
|
||||
{
|
||||
for (int32 x = 0; x < texture->Width; x++)
|
||||
{
|
||||
Color color = SamplePoint(sampler, x, y, srcData->Data.Get(), srcData->RowPitch);
|
||||
Color color = sampler->SamplePoint(srcData->Data.Get(), x, y, srcData->RowPitch);
|
||||
if (sRGB)
|
||||
color = Color::SrgbToLinear(color);
|
||||
*(ptr + x + y * texture->Width) = Color32(color);
|
||||
@@ -623,7 +624,7 @@ bool TextureTool::ConvertStb(TextureData& dst, const TextureData& src, const Pix
|
||||
dst.Items.Resize(arraySize, false);
|
||||
auto formatSize = PixelFormatExtensions::SizeInBytes(textureData->Format);
|
||||
auto components = PixelFormatExtensions::ComputeComponentsCount(textureData->Format);
|
||||
auto sampler = TextureTool::GetSampler(textureData->Format);
|
||||
auto sampler = PixelFormatSampler::Get(textureData->Format);
|
||||
if (!sampler)
|
||||
{
|
||||
LOG(Warning, "Cannot convert image. Unsupported format {0}", static_cast<int32>(textureData->Format));
|
||||
@@ -747,7 +748,7 @@ bool TextureTool::ConvertStb(TextureData& dst, const TextureData& src, const Pix
|
||||
#endif
|
||||
{
|
||||
int32 bytesPerPixel = PixelFormatExtensions::SizeInBytes(dstFormat);
|
||||
auto dstSampler = TextureTool::GetSampler(dstFormat);
|
||||
auto dstSampler = PixelFormatSampler::Get(dstFormat);
|
||||
if (!dstSampler)
|
||||
{
|
||||
LOG(Warning, "Cannot convert image. Unsupported format {0}", static_cast<int32>(dstFormat));
|
||||
@@ -782,10 +783,10 @@ bool TextureTool::ConvertStb(TextureData& dst, const TextureData& src, const Pix
|
||||
for (int32 x = 0; x < mipWidth; x++)
|
||||
{
|
||||
// Sample source texture
|
||||
Color color = TextureTool::SamplePoint(sampler, x, y, srcMip.Data.Get(), srcMip.RowPitch);
|
||||
Color color = sampler->SamplePoint(srcMip.Data.Get(), x, y, srcMip.RowPitch);
|
||||
|
||||
// Store destination texture
|
||||
TextureTool::Store(dstSampler, x, y, dstMip.Data.Get(), dstMip.RowPitch, color);
|
||||
sampler->Store(dstMip.Data.Get(), x, y, dstMip.RowPitch, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -802,7 +803,7 @@ bool TextureTool::ResizeStb(PixelFormat format, TextureMipData& dstMip, const Te
|
||||
auto components = PixelFormatExtensions::ComputeComponentsCount(format);
|
||||
auto srcMipWidth = srcMip.RowPitch / formatSize;
|
||||
auto srcMipHeight = srcMip.DepthPitch / srcMip.RowPitch;
|
||||
auto sampler = GetSampler(format);
|
||||
auto sampler = PixelFormatSampler::Get(format);
|
||||
|
||||
// Allocate memory
|
||||
dstMip.RowPitch = dstMipWidth * formatSize;
|
||||
@@ -869,8 +870,8 @@ bool TextureTool::ResizeStb(PixelFormat format, TextureMipData& dstMip, const Te
|
||||
for (int32 x = 0; x < dstMipWidth; x++)
|
||||
{
|
||||
const Float2 uv((float)x / dstMipWidth, (float)y / dstMipHeight);
|
||||
Color color = SamplePoint(sampler, uv, srcMip.Data.Get(), srcSize, srcMip.RowPitch);
|
||||
Store(sampler, x, y, dstMip.Data.Get(), dstMip.RowPitch, color);
|
||||
Color color = sampler->SamplePoint(srcMip.Data.Get(), uv, srcSize, srcMip.RowPitch);
|
||||
sampler->Store(dstMip.Data.Get(), x, y, dstMip.RowPitch, color);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user