Allow unclamped colors in Sprite3D
(cherry picked from commit f7dbcf95e1
)
This commit is contained in:
parent
5da2675856
commit
279af47ef9
@ -430,7 +430,7 @@ SpriteBase3D::SpriteBase3D() {
|
|||||||
mesh_array[VS::ARRAY_COLOR] = mesh_colors;
|
mesh_array[VS::ARRAY_COLOR] = mesh_colors;
|
||||||
mesh_array[VS::ARRAY_TEX_UV] = mesh_uvs;
|
mesh_array[VS::ARRAY_TEX_UV] = mesh_uvs;
|
||||||
|
|
||||||
VS::get_singleton()->mesh_add_surface_from_arrays(mesh, VS::PRIMITIVE_TRIANGLE_FAN, mesh_array, Array(), VS::ARRAY_COMPRESS_DEFAULT & ~VS::ARRAY_COMPRESS_TEX_UV);
|
VS::get_singleton()->mesh_add_surface_from_arrays(mesh, VS::PRIMITIVE_TRIANGLE_FAN, mesh_array, Array(), (VS::ARRAY_COMPRESS_DEFAULT & ~VS::ARRAY_COMPRESS_TEX_UV) & ~VS::ARRAY_COMPRESS_COLOR);
|
||||||
const int surface_vertex_len = VS::get_singleton()->mesh_surface_get_array_len(mesh, 0);
|
const int surface_vertex_len = VS::get_singleton()->mesh_surface_get_array_len(mesh, 0);
|
||||||
const int surface_index_len = VS::get_singleton()->mesh_surface_get_array_index_len(mesh, 0);
|
const int surface_index_len = VS::get_singleton()->mesh_surface_get_array_index_len(mesh, 0);
|
||||||
|
|
||||||
@ -554,7 +554,7 @@ void Sprite3D::_draw() {
|
|||||||
|
|
||||||
AABB aabb;
|
AABB aabb;
|
||||||
|
|
||||||
// Everything except position and UV is compressed
|
// Everything except position, color, and UV is compressed
|
||||||
PoolVector<uint8_t>::Write write_buffer = mesh_buffer.write();
|
PoolVector<uint8_t>::Write write_buffer = mesh_buffer.write();
|
||||||
|
|
||||||
int8_t v_normal[4] = {
|
int8_t v_normal[4] = {
|
||||||
@ -571,13 +571,6 @@ void Sprite3D::_draw() {
|
|||||||
(int8_t)CLAMP(tangent.d * 127, -128, 127)
|
(int8_t)CLAMP(tangent.d * 127, -128, 127)
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t v_color[4] = {
|
|
||||||
(uint8_t)CLAMP(int(color.r * 255.0), 0, 255),
|
|
||||||
(uint8_t)CLAMP(int(color.g * 255.0), 0, 255),
|
|
||||||
(uint8_t)CLAMP(int(color.b * 255.0), 0, 255),
|
|
||||||
(uint8_t)CLAMP(int(color.a * 255.0), 0, 255)
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
Vector3 vtx;
|
Vector3 vtx;
|
||||||
vtx[x_axis] = vertices[i][0];
|
vtx[x_axis] = vertices[i][0];
|
||||||
@ -596,7 +589,7 @@ void Sprite3D::_draw() {
|
|||||||
copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_VERTEX]], &v_vertex, sizeof(float) * 3);
|
copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_VERTEX]], &v_vertex, sizeof(float) * 3);
|
||||||
copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_NORMAL]], v_normal, 4);
|
copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_NORMAL]], v_normal, 4);
|
||||||
copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_TANGENT]], v_tangent, 4);
|
copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_TANGENT]], v_tangent, 4);
|
||||||
copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_COLOR]], v_color, 4);
|
copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_COLOR]], color.components, 4 * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
write_buffer.release();
|
write_buffer.release();
|
||||||
@ -917,7 +910,7 @@ void AnimatedSprite3D::_draw() {
|
|||||||
|
|
||||||
AABB aabb;
|
AABB aabb;
|
||||||
|
|
||||||
// Everything except position and UV is compressed
|
// Everything except position, color, and UV is compressed
|
||||||
PoolVector<uint8_t>::Write write_buffer = mesh_buffer.write();
|
PoolVector<uint8_t>::Write write_buffer = mesh_buffer.write();
|
||||||
|
|
||||||
int8_t v_normal[4] = {
|
int8_t v_normal[4] = {
|
||||||
@ -934,13 +927,6 @@ void AnimatedSprite3D::_draw() {
|
|||||||
(int8_t)CLAMP(tangent.d * 127, -128, 127)
|
(int8_t)CLAMP(tangent.d * 127, -128, 127)
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t v_color[4] = {
|
|
||||||
(uint8_t)CLAMP(int(color.r * 255.0), 0, 255),
|
|
||||||
(uint8_t)CLAMP(int(color.g * 255.0), 0, 255),
|
|
||||||
(uint8_t)CLAMP(int(color.b * 255.0), 0, 255),
|
|
||||||
(uint8_t)CLAMP(int(color.a * 255.0), 0, 255)
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
Vector3 vtx;
|
Vector3 vtx;
|
||||||
vtx[x_axis] = vertices[i][0];
|
vtx[x_axis] = vertices[i][0];
|
||||||
@ -959,7 +945,7 @@ void AnimatedSprite3D::_draw() {
|
|||||||
copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_VERTEX]], &v_vertex, sizeof(float) * 3);
|
copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_VERTEX]], &v_vertex, sizeof(float) * 3);
|
||||||
copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_NORMAL]], v_normal, 4);
|
copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_NORMAL]], v_normal, 4);
|
||||||
copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_TANGENT]], v_tangent, 4);
|
copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_TANGENT]], v_tangent, 4);
|
||||||
copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_COLOR]], v_color, 4);
|
copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_COLOR]], color.components, 4 * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
write_buffer.release();
|
write_buffer.release();
|
||||||
|
Loading…
Reference in New Issue
Block a user