Core/Color: Switch formal from RGBA8 to RGBA32F
This commit is contained in:
@@ -156,7 +156,7 @@ namespace Nz
|
||||
if (!currentMaterial)
|
||||
currentMaterial = AddMaterial("default");
|
||||
|
||||
currentMaterial->ambient = Color(static_cast<UInt8>(r * 255.f), static_cast<UInt8>(g * 255.f), static_cast<UInt8>(b * 255.f));
|
||||
currentMaterial->ambient = Color(r, g, b);
|
||||
}
|
||||
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
|
||||
else
|
||||
@@ -171,7 +171,7 @@ namespace Nz
|
||||
if (!currentMaterial)
|
||||
currentMaterial = AddMaterial("default");
|
||||
|
||||
currentMaterial->diffuse = Color(static_cast<UInt8>(r * 255.f), static_cast<UInt8>(g * 255.f), static_cast<UInt8>(b * 255.f));
|
||||
currentMaterial->diffuse = Color(r, g, b);
|
||||
}
|
||||
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
|
||||
else
|
||||
@@ -186,7 +186,7 @@ namespace Nz
|
||||
if (!currentMaterial)
|
||||
currentMaterial = AddMaterial("default");
|
||||
|
||||
currentMaterial->specular = Color(static_cast<UInt8>(r * 255.f), static_cast<UInt8>(g * 255.f), static_cast<UInt8>(b * 255.f));
|
||||
currentMaterial->specular = Color(r, g, b);
|
||||
}
|
||||
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
|
||||
else
|
||||
@@ -518,27 +518,27 @@ namespace Nz
|
||||
EmitLine();
|
||||
|
||||
Emit("Ka ");
|
||||
Emit(mat.ambient.r / 255.f);
|
||||
Emit(mat.ambient.r);
|
||||
Emit(' ');
|
||||
Emit(mat.ambient.g / 255.f);
|
||||
Emit(mat.ambient.g);
|
||||
Emit(' ');
|
||||
Emit(mat.ambient.b / 255.f);
|
||||
Emit(mat.ambient.b);
|
||||
EmitLine();
|
||||
|
||||
Emit("Kd ");
|
||||
Emit(mat.diffuse.r / 255.f);
|
||||
Emit(mat.diffuse.r);
|
||||
Emit(' ');
|
||||
Emit(mat.diffuse.g / 255.f);
|
||||
Emit(mat.diffuse.g);
|
||||
Emit(' ');
|
||||
Emit(mat.diffuse.b / 255.f);
|
||||
Emit(mat.diffuse.b);
|
||||
EmitLine();
|
||||
|
||||
Emit("Ks ");
|
||||
Emit(mat.specular.r / 255.f);
|
||||
Emit(mat.specular.r);
|
||||
Emit(' ');
|
||||
Emit(mat.specular.g / 255.f);
|
||||
Emit(mat.specular.g);
|
||||
Emit(' ');
|
||||
Emit(mat.specular.b / 255.f);
|
||||
Emit(mat.specular.b);
|
||||
EmitLine();
|
||||
|
||||
if (!NumberEquals(mat.alpha, 1.f))
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Nz
|
||||
{
|
||||
ParameterList data;
|
||||
|
||||
UInt8 alphaValue = static_cast<UInt8>(mtlMat->alpha*255.f);
|
||||
float alphaValue = mtlMat->alpha;
|
||||
|
||||
Color ambientColor(mtlMat->ambient);
|
||||
Color diffuseColor(mtlMat->diffuse);
|
||||
|
||||
@@ -715,7 +715,7 @@ namespace Nz
|
||||
const UInt8* pixel = GetPixelPtr(m_sharedImage->levels[0].get(), PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format), x, y, z, m_sharedImage->width, m_sharedImage->height);
|
||||
|
||||
Color color;
|
||||
if (!PixelFormatInfo::Convert(m_sharedImage->format, PixelFormat::RGBA8, pixel, &color.r))
|
||||
if (!PixelFormatInfo::Convert(m_sharedImage->format, PixelFormat::RGBA32F, pixel, &color.r))
|
||||
NazaraError("Failed to convert image's format to RGBA8");
|
||||
|
||||
return color;
|
||||
|
||||
@@ -269,6 +269,23 @@ namespace Nz
|
||||
return dst;
|
||||
}
|
||||
|
||||
template<>
|
||||
UInt8* ConvertPixels<PixelFormat::BGR8, PixelFormat::RGBA32F>(const UInt8* start, const UInt8* end, UInt8* dst)
|
||||
{
|
||||
float* ptr = reinterpret_cast<float*>(dst);
|
||||
while (start < end)
|
||||
{
|
||||
*ptr++ = start[2] / 255.f;
|
||||
*ptr++ = start[1] / 255.f;
|
||||
*ptr++ = start[0] / 255.f;
|
||||
*ptr++ = 1.f;
|
||||
|
||||
start += 3;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
/**********************************BGRA8**********************************/
|
||||
template<>
|
||||
UInt8* ConvertPixels<PixelFormat::BGRA8, PixelFormat::A8>(const UInt8* start, const UInt8* end, UInt8* dst)
|
||||
@@ -409,6 +426,23 @@ namespace Nz
|
||||
return dst;
|
||||
}
|
||||
|
||||
template<>
|
||||
UInt8* ConvertPixels<PixelFormat::BGRA8, PixelFormat::RGBA32F>(const UInt8* start, const UInt8* end, UInt8* dst)
|
||||
{
|
||||
float* ptr = reinterpret_cast<float*>(dst);
|
||||
while (start < end)
|
||||
{
|
||||
*ptr++ = start[2] / 255.f;
|
||||
*ptr++ = start[1] / 255.f;
|
||||
*ptr++ = start[0] / 255.f;
|
||||
*ptr++ = start[3] / 255.f;
|
||||
|
||||
start += 4;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
/***********************************L8************************************/
|
||||
template<>
|
||||
UInt8* ConvertPixels<PixelFormat::L8, PixelFormat::BGR8>(const UInt8* start, const UInt8* end, UInt8* dst)
|
||||
@@ -534,6 +568,23 @@ namespace Nz
|
||||
return dst;
|
||||
}
|
||||
|
||||
template<>
|
||||
UInt8* ConvertPixels<PixelFormat::L8, PixelFormat::RGBA32F>(const UInt8* start, const UInt8* end, UInt8* dst)
|
||||
{
|
||||
float* ptr = reinterpret_cast<float*>(dst);
|
||||
while (start < end)
|
||||
{
|
||||
*ptr++ = start[0] / 255.f;
|
||||
*ptr++ = start[0] / 255.f;
|
||||
*ptr++ = start[0] / 255.f;
|
||||
*ptr++ = 1.f;
|
||||
|
||||
start += 1;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
/***********************************LA8***********************************/
|
||||
template<>
|
||||
UInt8* ConvertPixels<PixelFormat::LA8, PixelFormat::A8>(const UInt8* start, const UInt8* end, UInt8* dst)
|
||||
@@ -665,6 +716,23 @@ namespace Nz
|
||||
return dst;
|
||||
}
|
||||
|
||||
template<>
|
||||
UInt8* ConvertPixels<PixelFormat::LA8, PixelFormat::RGBA32F>(const UInt8* start, const UInt8* end, UInt8* dst)
|
||||
{
|
||||
float* ptr = reinterpret_cast<float*>(dst);
|
||||
while (start < end)
|
||||
{
|
||||
*ptr++ = start[0] / 255.f;
|
||||
*ptr++ = start[0] / 255.f;
|
||||
*ptr++ = start[0] / 255.f;
|
||||
*ptr++ = start[1] / 255.f;
|
||||
|
||||
start += 2;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
/*********************************RGBA4***********************************/
|
||||
template<>
|
||||
UInt8* ConvertPixels<PixelFormat::RGBA4, PixelFormat::A8>(const UInt8* start, const UInt8* end, UInt8* dst)
|
||||
@@ -1158,6 +1226,23 @@ namespace Nz
|
||||
return dst;
|
||||
}
|
||||
|
||||
template<>
|
||||
UInt8* ConvertPixels<PixelFormat::RGB8, PixelFormat::RGBA32F>(const UInt8* start, const UInt8* end, UInt8* dst)
|
||||
{
|
||||
float* ptr = reinterpret_cast<float*>(dst);
|
||||
while (start < end)
|
||||
{
|
||||
*ptr++ = start[0] / 255.f;
|
||||
*ptr++ = start[1] / 255.f;
|
||||
*ptr++ = start[2] / 255.f;
|
||||
*ptr++ = 1.f;
|
||||
|
||||
start += 3;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
/**********************************RGBA8**********************************/
|
||||
template<>
|
||||
UInt8* ConvertPixels<PixelFormat::RGBA8, PixelFormat::A8>(const UInt8* start, const UInt8* end, UInt8* dst)
|
||||
@@ -1298,6 +1383,22 @@ namespace Nz
|
||||
return dst + count;
|
||||
}
|
||||
|
||||
template<>
|
||||
UInt8* ConvertPixels<PixelFormat::RGBA8, PixelFormat::RGBA32F>(const UInt8* start, const UInt8* end, UInt8* dst)
|
||||
{
|
||||
float* ptr = reinterpret_cast<float*>(dst);
|
||||
while (start < end)
|
||||
{
|
||||
*ptr++ = start[0] / 255.f;
|
||||
*ptr++ = start[1] / 255.f;
|
||||
*ptr++ = start[2] / 255.f;
|
||||
*ptr++ = start[3] / 255.f;
|
||||
|
||||
start += 4;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
template<PixelFormat Format1, PixelFormat Format2>
|
||||
void RegisterConverter()
|
||||
@@ -1515,6 +1616,7 @@ namespace Nz
|
||||
RegisterConverter<PixelFormat::BGR8, PixelFormat::RGB8>();
|
||||
RegisterConverter<PixelFormat::BGR8, PixelFormat::RGBA4>();
|
||||
RegisterConverter<PixelFormat::BGR8, PixelFormat::RGBA8>();
|
||||
RegisterConverter<PixelFormat::BGR8, PixelFormat::RGBA32F>();
|
||||
|
||||
/**********************************BGRA8**********************************/
|
||||
RegisterConverter<PixelFormat::BGRA8, PixelFormat::A8>();
|
||||
@@ -1534,6 +1636,7 @@ namespace Nz
|
||||
RegisterConverter<PixelFormat::BGRA8, PixelFormat::RGB8>();
|
||||
RegisterConverter<PixelFormat::BGRA8, PixelFormat::RGBA4>();
|
||||
RegisterConverter<PixelFormat::BGRA8, PixelFormat::RGBA8>();
|
||||
RegisterConverter<PixelFormat::BGRA8, PixelFormat::RGBA32F>();
|
||||
|
||||
/**********************************DXT1***********************************/
|
||||
///TODO: Décompresseur DXT1
|
||||
@@ -1620,6 +1723,7 @@ namespace Nz
|
||||
RegisterConverter<PixelFormat::L8, PixelFormat::RGB8>();
|
||||
RegisterConverter<PixelFormat::L8, PixelFormat::RGBA4>();
|
||||
RegisterConverter<PixelFormat::L8, PixelFormat::RGBA8>();
|
||||
RegisterConverter<PixelFormat::L8, PixelFormat::RGBA32F>();
|
||||
|
||||
/***********************************LA8***********************************/
|
||||
RegisterConverter<PixelFormat::LA8, PixelFormat::A8>();
|
||||
@@ -1638,6 +1742,7 @@ namespace Nz
|
||||
RegisterConverter<PixelFormat::LA8, PixelFormat::RGB8>();
|
||||
RegisterConverter<PixelFormat::LA8, PixelFormat::RGBA4>();
|
||||
RegisterConverter<PixelFormat::LA8, PixelFormat::RGBA8>();
|
||||
RegisterConverter<PixelFormat::LA8, PixelFormat::RGBA32F>();
|
||||
|
||||
/**********************************RGBA4**********************************/
|
||||
RegisterConverter<PixelFormat::RGBA4, PixelFormat::A8>();
|
||||
@@ -1692,6 +1797,7 @@ namespace Nz
|
||||
RegisterConverter<PixelFormat::RGB8, PixelFormat::RGB8_SRGB>();
|
||||
RegisterConverter<PixelFormat::RGB8, PixelFormat::RGBA4>();
|
||||
RegisterConverter<PixelFormat::RGB8, PixelFormat::RGBA8>();
|
||||
RegisterConverter<PixelFormat::RGB8, PixelFormat::RGBA32F>();
|
||||
|
||||
/**********************************RGBA8**********************************/
|
||||
RegisterConverter<PixelFormat::RGBA8, PixelFormat::A8>();
|
||||
@@ -1711,6 +1817,7 @@ namespace Nz
|
||||
RegisterConverter<PixelFormat::RGBA8, PixelFormat::RGB8>();
|
||||
RegisterConverter<PixelFormat::RGBA8, PixelFormat::RGBA4>();
|
||||
RegisterConverter<PixelFormat::RGBA8, PixelFormat::RGBA8_SRGB>();
|
||||
RegisterConverter<PixelFormat::RGBA8, PixelFormat::RGBA32F>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Nz
|
||||
{
|
||||
std::size_t s_componentStride[ComponentTypeCount] =
|
||||
{
|
||||
4 * sizeof(UInt8), // ComponentType::Color
|
||||
4 * sizeof(float), // ComponentType::Color
|
||||
1 * sizeof(double), // ComponentType::Double1
|
||||
2 * sizeof(double), // ComponentType::Double2
|
||||
3 * sizeof(double), // ComponentType::Double3
|
||||
@@ -31,7 +31,6 @@ namespace Nz
|
||||
2 * sizeof(UInt32), // ComponentType::Int2
|
||||
3 * sizeof(UInt32), // ComponentType::Int3
|
||||
4 * sizeof(UInt32), // ComponentType::Int4
|
||||
4 * sizeof(float) // ComponentType::Quaternion
|
||||
};
|
||||
}
|
||||
VertexDeclaration::VertexDeclaration(VertexInputRate inputRate, std::initializer_list<ComponentEntry> components) :
|
||||
@@ -74,7 +73,6 @@ namespace Nz
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case ComponentType::Color:
|
||||
case ComponentType::Double1:
|
||||
case ComponentType::Double2:
|
||||
case ComponentType::Double3:
|
||||
@@ -88,9 +86,6 @@ namespace Nz
|
||||
case ComponentType::Int3:
|
||||
case ComponentType::Int4:
|
||||
return true;
|
||||
|
||||
case ComponentType::Quaternion:
|
||||
return false;
|
||||
}
|
||||
|
||||
NazaraError("Component type not handled (0x" + NumberToString(UnderlyingCast(type), 16) + ')');
|
||||
@@ -127,7 +122,7 @@ namespace Nz
|
||||
},
|
||||
{
|
||||
VertexComponent::Color,
|
||||
ComponentType::Color,
|
||||
ComponentType::Float4,
|
||||
0
|
||||
},
|
||||
});
|
||||
@@ -170,7 +165,7 @@ namespace Nz
|
||||
},
|
||||
{
|
||||
VertexComponent::Color,
|
||||
ComponentType::Color,
|
||||
ComponentType::Float4,
|
||||
0
|
||||
}
|
||||
});
|
||||
@@ -186,7 +181,7 @@ namespace Nz
|
||||
},
|
||||
{
|
||||
VertexComponent::Color,
|
||||
ComponentType::Color,
|
||||
ComponentType::Float4,
|
||||
0
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user