@@ -361,7 +361,8 @@ typedef struct {
361
361
typedef struct {
362
362
struct { float x , y , z ; } position ;
363
363
uint32_t normal ;
364
- struct { float u , v ; } uv ;
364
+ struct { uint16_t u , v ; } uv ;
365
+ struct { uint16_t u , v ; } uv2 ;
365
366
struct { uint8_t r , g , b , a ; } color ;
366
367
uint32_t tangent ;
367
368
} ModelVertex ;
@@ -809,8 +810,9 @@ bool lovrGraphicsInit(GraphicsConfig* config) {
809
810
.attributes [0 ] = { 0 , 10 , offsetof(ShapeVertex , position ), GPU_TYPE_F32x3 },
810
811
.attributes [1 ] = { 0 , 11 , offsetof(ShapeVertex , normal ), GPU_TYPE_F32x3 },
811
812
.attributes [2 ] = { 0 , 12 , offsetof(ShapeVertex , uv ), GPU_TYPE_F32x2 },
812
- .attributes [3 ] = { 1 , 13 , 16 , GPU_TYPE_F32x4 },
813
- .attributes [4 ] = { 1 , 14 , 0 , GPU_TYPE_F32x4 }
813
+ .attributes [3 ] = { 1 , 13 , 0 , GPU_TYPE_F32x2 },
814
+ .attributes [4 ] = { 1 , 14 , 16 , GPU_TYPE_F32x4 },
815
+ .attributes [5 ] = { 1 , 15 , 0 , GPU_TYPE_F32x4 }
814
816
};
815
817
816
818
state .vertexFormats [VERTEX_POINT ] = (gpu_vertex_format ) {
@@ -820,8 +822,9 @@ bool lovrGraphicsInit(GraphicsConfig* config) {
820
822
.attributes [0 ] = { 0 , 10 , 0 , GPU_TYPE_F32x3 },
821
823
.attributes [1 ] = { 1 , 11 , 0 , GPU_TYPE_F32x4 },
822
824
.attributes [2 ] = { 1 , 12 , 0 , GPU_TYPE_F32x4 },
823
- .attributes [3 ] = { 1 , 13 , 16 , GPU_TYPE_F32x4 },
824
- .attributes [4 ] = { 1 , 14 , 0 , GPU_TYPE_F32x4 }
825
+ .attributes [3 ] = { 1 , 13 , 0 , GPU_TYPE_F32x2 },
826
+ .attributes [4 ] = { 1 , 14 , 16 , GPU_TYPE_F32x4 },
827
+ .attributes [5 ] = { 1 , 15 , 0 , GPU_TYPE_F32x4 }
825
828
};
826
829
827
830
state .vertexFormats [VERTEX_GLYPH ] = (gpu_vertex_format ) {
@@ -831,8 +834,9 @@ bool lovrGraphicsInit(GraphicsConfig* config) {
831
834
.attributes [0 ] = { 0 , 10 , offsetof(GlyphVertex , position ), GPU_TYPE_F32x2 },
832
835
.attributes [1 ] = { 1 , 11 , 0 , GPU_TYPE_F32x4 },
833
836
.attributes [2 ] = { 0 , 12 , offsetof(GlyphVertex , uv ), GPU_TYPE_UN16x2 },
834
- .attributes [3 ] = { 0 , 13 , offsetof(GlyphVertex , color ), GPU_TYPE_UN8x4 },
835
- .attributes [4 ] = { 1 , 14 , 0 , GPU_TYPE_F32x4 }
837
+ .attributes [3 ] = { 1 , 13 , 0 , GPU_TYPE_F32x2 },
838
+ .attributes [4 ] = { 0 , 14 , offsetof(GlyphVertex , color ), GPU_TYPE_UN8x4 },
839
+ .attributes [5 ] = { 1 , 15 , 0 , GPU_TYPE_F32x4 }
836
840
};
837
841
838
842
state .vertexFormats [VERTEX_MODEL ] = (gpu_vertex_format ) {
@@ -841,9 +845,10 @@ bool lovrGraphicsInit(GraphicsConfig* config) {
841
845
.bufferStrides [0 ] = sizeof (ModelVertex ),
842
846
.attributes [0 ] = { 0 , 10 , offsetof(ModelVertex , position ), GPU_TYPE_F32x3 },
843
847
.attributes [1 ] = { 0 , 11 , offsetof(ModelVertex , normal ), GPU_TYPE_SN10x3 },
844
- .attributes [2 ] = { 0 , 12 , offsetof(ModelVertex , uv ), GPU_TYPE_F32x2 },
845
- .attributes [3 ] = { 0 , 13 , offsetof(ModelVertex , color ), GPU_TYPE_UN8x4 },
846
- .attributes [4 ] = { 0 , 14 , offsetof(ModelVertex , tangent ), GPU_TYPE_SN10x3 }
848
+ .attributes [2 ] = { 0 , 12 , offsetof(ModelVertex , uv ), GPU_TYPE_UN16x2 },
849
+ .attributes [3 ] = { 0 , 13 , offsetof(ModelVertex , uv2 ), GPU_TYPE_UN16x2 },
850
+ .attributes [4 ] = { 0 , 14 , offsetof(ModelVertex , color ), GPU_TYPE_UN8x4 },
851
+ .attributes [5 ] = { 0 , 15 , offsetof(ModelVertex , tangent ), GPU_TYPE_SN10x3 }
847
852
};
848
853
849
854
state .vertexFormats [VERTEX_EMPTY ] = (gpu_vertex_format ) {
@@ -852,8 +857,9 @@ bool lovrGraphicsInit(GraphicsConfig* config) {
852
857
.attributes [0 ] = { 1 , 10 , 0 , GPU_TYPE_F32x3 },
853
858
.attributes [1 ] = { 1 , 11 , 0 , GPU_TYPE_F32x3 },
854
859
.attributes [2 ] = { 1 , 12 , 0 , GPU_TYPE_F32x2 },
855
- .attributes [3 ] = { 1 , 13 , 16 , GPU_TYPE_F32x4 },
856
- .attributes [4 ] = { 1 , 14 , 0 , GPU_TYPE_F32x4 }
860
+ .attributes [3 ] = { 1 , 13 , 0 , GPU_TYPE_F32x2 },
861
+ .attributes [4 ] = { 1 , 14 , 16 , GPU_TYPE_F32x4 },
862
+ .attributes [5 ] = { 1 , 15 , 0 , GPU_TYPE_F32x4 }
857
863
};
858
864
859
865
float16Init ();
@@ -4958,7 +4964,8 @@ Model* lovrModelCreate(const ModelInfo* info) {
4958
4964
{ .length = data -> vertexCount , .stride = sizeof (ModelVertex ), .fieldCount = 5 },
4959
4965
{ .name = "VertexPosition" , .type = TYPE_F32x3 , .offset = offsetof(ModelVertex , position ) },
4960
4966
{ .name = "VertexNormal" , .type = TYPE_SN10x3 , .offset = offsetof(ModelVertex , normal ) },
4961
- { .name = "VertexUV" , .type = TYPE_F32x2 , .offset = offsetof(ModelVertex , uv ) },
4967
+ { .name = "VertexUV" , .type = TYPE_UN16x2 , .offset = offsetof(ModelVertex , uv ) },
4968
+ { .name = "VertexUV2" , .type = TYPE_UN16x2 , .offset = offsetof(ModelVertex , uv2 ) },
4962
4969
{ .name = "VertexColor" , .type = TYPE_UN8x4 , .offset = offsetof(ModelVertex , color ) },
4963
4970
{ .name = "VertexTangent" , .type = TYPE_SN10x3 , .offset = offsetof(ModelVertex , tangent ) }
4964
4971
}
@@ -5105,9 +5112,12 @@ Model* lovrModelCreate(const ModelInfo* info) {
5105
5112
uint32_t count = attributes [ATTR_POSITION ]-> count ;
5106
5113
size_t stride = sizeof (ModelVertex );
5107
5114
5115
+ ModelAttribute * uv2 = attributes [ATTR_UV2 ] ? attributes [ATTR_UV2 ] : attributes [ATTR_UV ];
5116
+
5108
5117
lovrModelDataCopyAttribute (data , attributes [ATTR_POSITION ], vertexData + 0 , F32 , 3 , false, count , stride , 0 );
5109
5118
lovrModelDataCopyAttribute (data , attributes [ATTR_NORMAL ], vertexData + 12 , SN10x3 , 1 , false, count , stride , 0 );
5110
- lovrModelDataCopyAttribute (data , attributes [ATTR_UV ], vertexData + 16 , F32 , 2 , false, count , stride , 0 );
5119
+ lovrModelDataCopyAttribute (data , attributes [ATTR_UV ], vertexData + 16 , U16 , 2 , true, count , stride , 0 );
5120
+ lovrModelDataCopyAttribute (data , uv2 , vertexData + 20 , U16 , 2 , true, count , stride , 0 );
5111
5121
lovrModelDataCopyAttribute (data , attributes [ATTR_COLOR ], vertexData + 24 , U8 , 4 , true, count , stride , 255 );
5112
5122
lovrModelDataCopyAttribute (data , attributes [ATTR_TANGENT ], vertexData + 28 , SN10x3 , 1 , false, count , stride , 0 );
5113
5123
vertexData += count * stride ;
0 commit comments