Update old Float1010102 to FloatR10G10B10A2

This commit is contained in:
Wojtek Figat
2025-01-12 21:22:53 +01:00
parent d751c6a6c6
commit ea96418764
6 changed files with 22 additions and 23 deletions

View File

@@ -779,7 +779,7 @@ bool ModelBase::SaveLOD(WriteStream& stream, const ModelData& modelData, int32 l
const Float3 normal = hasNormals ? mesh.Normals.Get()[vertex] : Float3::UnitZ;
const Float3 tangent = hasTangents ? mesh.Tangents.Get()[vertex] : Float3::UnitX;
const float bitangentSign = hasBitangentSigns ? mesh.BitangentSigns.Get()[vertex] : Float3::Dot(Float3::Cross(Float3::Normalize(Float3::Cross(normal, tangent)), normal), tangent);
const Float1010102 tangentEnc(tangent * 0.5f + 0.5f, (byte)(bitangentSign < 0 ? 1 : 0));
const FloatR10G10B10A2 tangentEnc(tangent * 0.5f + 0.5f, (byte)(bitangentSign < 0 ? 1 : 0));
stream.Write(tangentEnc.Value);
break;
}

View File

@@ -6,7 +6,6 @@
#include "ModelInstanceEntry.h"
#include "Engine/Content/Assets/Material.h"
#include "Engine/Content/Assets/Model.h"
#include "Engine/Core/Log.h"
#include "Engine/Graphics/GPUContext.h"
#include "Engine/Graphics/GPUDevice.h"
#include "Engine/Graphics/RenderTask.h"

View File

@@ -77,8 +77,8 @@ PACK_STRUCT(struct DEPRECATED("Use new MeshAccessor and depend on GPUVertexLayou
{
Float3 Position;
Half2 TexCoord;
Float1010102 Normal;
Float1010102 Tangent;
FloatR10G10B10A2 Normal;
FloatR10G10B10A2 Tangent;
Half2 LightmapUVs;
Color32 Color;
});
@@ -113,8 +113,8 @@ PACK_STRUCT(struct DEPRECATED("Use new MeshAccessor and depend on GPUVertexLayou
PACK_STRUCT(struct DEPRECATED("Use new MeshAccessor and depend on GPUVertexLayout when accessing mesh data.") VB1ElementType18
{
Half2 TexCoord;
Float1010102 Normal;
Float1010102 Tangent;
FloatR10G10B10A2 Normal;
FloatR10G10B10A2 Tangent;
Half2 LightmapUVs;
static GPUVertexLayout* GetLayout();
@@ -143,8 +143,8 @@ PACK_STRUCT(struct DEPRECATED("Use new MeshAccessor and depend on GPUVertexLayou
{
Float3 Position;
Half2 TexCoord;
Float1010102 Normal;
Float1010102 Tangent;
FloatR10G10B10A2 Normal;
FloatR10G10B10A2 Tangent;
Color32 BlendIndices;
Color32 BlendWeights;
});
@@ -171,8 +171,8 @@ PACK_STRUCT(struct DEPRECATED("Use newer format.") VB0SkinnedElementType1
{
Float3 Position;
Half2 TexCoord;
Float1010102 Normal;
Float1010102 Tangent;
FloatR10G10B10A2 Normal;
FloatR10G10B10A2 Tangent;
Color32 BlendIndices;
Color32 BlendWeights;
});
@@ -182,8 +182,8 @@ PACK_STRUCT(struct DEPRECATED("Use new MeshAccessor and depend on GPUVertexLayou
{
Float3 Position;
Half2 TexCoord;
Float1010102 Normal;
Float1010102 Tangent;
FloatR10G10B10A2 Normal;
FloatR10G10B10A2 Tangent;
Color32 BlendIndices;
Half4 BlendWeights;

View File

@@ -1396,14 +1396,14 @@ static PixelFormatSampler PixelFormatSamplers[] =
},
{
PixelFormat::R10G10B10A2_UNorm,
sizeof(Float1010102),
sizeof(FloatR10G10B10A2),
[](const void* ptr)
{
return ((Float1010102*)ptr)->ToFloat4();
return ((FloatR10G10B10A2*)ptr)->ToFloat4();
},
[](void* ptr, const Float4& value)
{
*(Float1010102*)ptr = Float1010102(value.X, value.Y, value.Z, value.W);
*(FloatR10G10B10A2*)ptr = FloatR10G10B10A2(value.X, value.Y, value.Z, value.W);
},
},
{

View File

@@ -562,8 +562,8 @@ void RenderTools::CalculateTangentFrame(FloatR10G10B10A2& resultNormal, FloatR10
Float3 n;
Float4 t;
CalculateTangentFrame(n, t, normal);
resultNormal = Float1010102(n, 0);
resultTangent = Float1010102(t);
resultNormal = FloatR10G10B10A2(n, 0);
resultTangent = FloatR10G10B10A2(t);
}
void RenderTools::CalculateTangentFrame(FloatR10G10B10A2& resultNormal, FloatR10G10B10A2& resultTangent, const Float3& normal, const Float3& tangent)
@@ -572,8 +572,8 @@ void RenderTools::CalculateTangentFrame(FloatR10G10B10A2& resultNormal, FloatR10
Float3 n;
Float4 t;
CalculateTangentFrame(n, t, normal, tangent);
resultNormal = Float1010102(n, 0);
resultTangent = Float1010102(t);
resultNormal = FloatR10G10B10A2(n, 0);
resultTangent = FloatR10G10B10A2(t);
}
void RenderTools::CalculateTangentFrame(Float3& resultNormal, Float4& resultTangent, const Float3& normal)

View File

@@ -28,8 +28,8 @@ PACK_STRUCT(struct TextRenderVertex
{
Float3 Position;
Color32 Color;
Float1010102 Normal;
Float1010102 Tangent;
FloatR10G10B10A2 Normal;
FloatR10G10B10A2 Tangent;
Half2 TexCoord;
static GPUVertexLayout* GetLayout()
@@ -288,8 +288,8 @@ void TextRender::UpdateLayout()
v.Position = Float3(-pos, 0.0f); \
box.Merge(v.Position); \
v.TexCoord = Half2(uv); \
v.Normal = Float1010102(normal * 0.5f + 0.5f, 0); \
v.Tangent = Float1010102(tangent * 0.5f + 0.5f, sign); \
v.Normal = FloatR10G10B10A2(normal * 0.5f + 0.5f, 0); \
v.Tangent = FloatR10G10B10A2(tangent * 0.5f + 0.5f, sign); \
v.Color = color; \
_vb.Write(v)
//