5 return value == _10Bit ? plGALResourceFormat::RGB10A2UIntNormalized
6 : (value == _16Bit ? plGALResourceFormat::RGBAUShortNormalized : plGALResourceFormat::XYZFloat);
12 return value == _10Bit ? plGALResourceFormat::RGB10A2UIntNormalized
13 : (value == _16Bit ? plGALResourceFormat::RGBAUShortNormalized : plGALResourceFormat::XYZWFloat);
21 return value == _16Bit ? plGALResourceFormat::UVHalf : plGALResourceFormat::UVFloat;
32 return plGALResourceFormat::RGBAUByteNormalized;
34 return plGALResourceFormat::RGB10A2UIntNormalized;
36 return plGALResourceFormat::RGBAUShortNormalized;
38 return plGALResourceFormat::RGBAFloat;
39 PL_DEFAULT_CASE_NOT_IMPLEMENTED;
42 return plGALResourceFormat::RGBAUByteNormalized;
54PL_ALWAYS_INLINE
plResult plMeshBufferUtils::EncodeTangent(
const plVec3& vTangent,
float fTangentSign,
plArrayPtr<plUInt8> dest, plMeshNormalPrecision::Enum tangentPrecision)
75 if (conversion == plMeshVertexColorConversion::LinearToSrgb)
79 else if (conversion == plMeshVertexColorConversion::SrgbToLinear)
88 return EncodeFromVec4(finalColor, dest, plGALResourceFormat::RGBAUByteNormalized);
95 return EncodeFromVec3(vNormal * 0.5f +
plVec3(0.5f), dest, destFormat);
99PL_ALWAYS_INLINE
plResult plMeshBufferUtils::EncodeTangent(
const plVec3& vTangent,
float fTangentSign,
plArrayPtr<plUInt8> dest, plGALResourceFormat::Enum destFormat)
102 fTangentSign = (fTangentSign < 0.0f) ? -1.0f : 1.0f;
105 return EncodeFromVec4(vTangent.
GetAsVec4(fTangentSign) * 0.5f +
plVec4(0.5f), dest, destFormat);
111 return EncodeFromVec2(vTexCoord, dest, destFormat);
117 return EncodeFromVec4(vWeights, dest, destFormat);
127PL_ALWAYS_INLINE
plResult plMeshBufferUtils::DecodeTangent(
plArrayPtr<const plUInt8> source,
plVec3& ref_vDestTangent,
float& ref_fDestBiTangentSign, plMeshNormalPrecision::Enum tangentPrecision)
142 PL_SUCCEED_OR_RETURN(DecodeToVec3(source, sourceFormat, tempNormal));
143 ref_vDestNormal = tempNormal * 2.0f -
plVec3(1.0f);
151 PL_SUCCEED_OR_RETURN(DecodeToVec4(source, sourceFormat, tempTangent));
153 ref_fDestBiTangentSign = tempTangent.w * 2.0f - 1.0f;
160 return DecodeToVec2(source, sourceFormat, ref_vDestTexCoord);
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
static float GammaToLinear(float fGamma)
Helper function to convert a float color value from gamma space to linear color space.
Definition Color.cpp:283
static float LinearToGamma(float fGamma)
Helper function to convert a float color value from linear space to gamma color space.
Definition Color.cpp:288
const plVec4Template< Type > GetAsVec4(Type w) const
Returns an plVec4Template with x,y,z from this vector and w set to the parameter.
Definition Vec4_inl.h:35
const plVec3Template< Type > GetAsVec3() const
Returns an plVec3Template with x,y and z from this vector.
Definition Vec4_inl.h:112
static plGALResourceFormat::Enum ToResourceFormat(Enum value)
Convert mesh texcoord precision to actual resource format.
Definition MeshBufferUtils_inl.h:27
static plGALResourceFormat::Enum ToResourceFormatNormal(Enum value)
Convert mesh normal precision to actual resource format used for normals.
Definition MeshBufferUtils_inl.h:3
static plGALResourceFormat::Enum ToResourceFormatTangent(Enum value)
Convert mesh normal precision to actual resource format used for tangents.
Definition MeshBufferUtils_inl.h:10
static plGALResourceFormat::Enum ToResourceFormat(Enum value)
Convert mesh texcoord precision to actual resource format.
Definition MeshBufferUtils_inl.h:19
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54