[WIP] Alpha blending enabled
This commit is contained in:
1 parent
c9384eb795
commit
ad90e5897a
6 files changed
+20
-31
No files matched your search
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
layout(set = 1, binding = 1) uniform sampler2D texSampler[];
|
layout(set = 1, binding = 1) uniform sampler2D texSampler[];
|
||||||
|
|
||||||
layout(location = 0) in vec4 fragColor;
|
layout(location = 0) in vec3 fragColor;
|
||||||
layout(location = 1) in vec2 fragTexCoord;
|
layout(location = 1) in vec2 fragTexCoord;
|
||||||
layout(location = 2) in flat uint instanceTextureId;
|
layout(location = 2) in flat uint instanceTextureId;
|
||||||
|
|
||||||
@@ -17,5 +17,5 @@ void main() {
|
|||||||
/* if (sampled.a < 0.1)
|
/* if (sampled.a < 0.1)
|
||||||
discard;
|
discard;
|
||||||
outColor = sampled; */
|
outColor = sampled; */
|
||||||
outColor = fragColor * texture(texSampler[instanceTextureId], fragTexCoord).r;
|
outColor = vec4(fragColor, texture(texSampler[instanceTextureId], fragTexCoord).r);
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ layout(binding = 0) uniform UniformBufferObject {
|
|||||||
} ubo;
|
} ubo;
|
||||||
|
|
||||||
layout(location = 0) in vec3 inPosition;
|
layout(location = 0) in vec3 inPosition;
|
||||||
layout(location = 1) in vec4 inColor;
|
layout(location = 1) in vec3 inColor;
|
||||||
layout(location = 2) in vec2 inTexCoord;
|
layout(location = 2) in vec2 inTexCoord;
|
||||||
|
|
||||||
layout(location = 3) in vec3 instancePosition;
|
layout(location = 3) in vec3 instancePosition;
|
||||||
@@ -15,7 +15,7 @@ layout(location = 4) in vec3 instanceRotation;
|
|||||||
layout(location = 5) in float instanceScale;
|
layout(location = 5) in float instanceScale;
|
||||||
layout(location = 6) in uint instanceTextureId;
|
layout(location = 6) in uint instanceTextureId;
|
||||||
|
|
||||||
layout(location = 0) out vec4 fragColor;
|
layout(location = 0) out vec3 fragColor;
|
||||||
layout(location = 1) out vec2 fragTexCoord;
|
layout(location = 1) out vec2 fragTexCoord;
|
||||||
layout(location = 2) out uint outInstanceTextureId;
|
layout(location = 2) out uint outInstanceTextureId;
|
||||||
|
|
||||||
|
|||||||
+11
-11
@@ -44,25 +44,24 @@ void rse_graphics_test_function(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rse_fonts_initialize();
|
rse_fonts_initialize();
|
||||||
rse_fonts_load_from_file("/usr/share/fonts/JetBrainsMonoNerdFont/JetBrainsMonoNerdFont-Medium.ttf");
|
|
||||||
|
|
||||||
// FIXME: Temporary array of vertices, for testing purposes
|
// FIXME: Temporary array of vertices, for testing purposes
|
||||||
struct rse_vertex_t vertices[] = {{{-0.5f, -0.5f, 0.0f}, {1.0f, 0.0f, 0.0f, 1.0f}, {0.0f, 0.0f}},
|
struct rse_vertex_t vertices[] = {{{-0.5f, -0.5f, 0.0f}, {1.0f, 0.0f, 0.0f}, {0.0f, 0.0f}},
|
||||||
{{0.5f, -0.5f, 0.0f}, {0.0f, 1.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
|
{{0.5f, -0.5f, 0.0f}, {0.0f, 1.0f, 0.0f}, {1.0f, 0.0f}},
|
||||||
{{0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, 1.0f, 1.0f}, {1.0f, 1.0f}},
|
{{0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 1.0f}},
|
||||||
{{-0.5f, 0.5f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 1.0f}}};
|
{{-0.5f, 0.5f, 0.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 1.0f}}};
|
||||||
|
|
||||||
struct rse_vertex_t vertices2[] = {{{-0.5f, -0.5f, -0.5f}, {1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}},
|
struct rse_vertex_t vertices2[] = {{{-0.5f, -0.5f, -0.5f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}},
|
||||||
{{0.5f, -0.5f, -0.5f}, {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 0.0f}},
|
{{0.5f, -0.5f, -0.5f}, {1.0f, 1.0f, 1.0f}, {1.0f, 0.0f}},
|
||||||
{{0.5f, 0.5f, -0.5f}, {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 1.0f}},
|
{{0.5f, 0.5f, -0.5f}, {1.0f, 1.0f, 1.0f}, {1.0f, 1.0f}},
|
||||||
{{-0.5f, 0.5f, -0.5f}, {1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 1.0f}}};
|
{{-0.5f, 0.5f, -0.5f}, {1.0f, 1.0f, 1.0f}, {0.0f, 1.0f}}};
|
||||||
|
|
||||||
// FIXME: Temporary array of vertices, for testing purposes
|
// FIXME: Temporary array of vertices, for testing purposes
|
||||||
uint16_t indices[] = {0, 1, 2, 2, 3, 0};
|
uint16_t indices[] = {0, 1, 2, 2, 3, 0};
|
||||||
|
|
||||||
uint16_t mesh_id = create_mesh(vertices, indices, 6, 6);
|
uint16_t mesh_id = create_mesh(vertices, indices, 6, 6);
|
||||||
create_mesh_instance(mesh_id, (struct rse_instance_data_t){
|
create_mesh_instance(mesh_id, (struct rse_instance_data_t){
|
||||||
{0.0f, 0.0f, 0.0f},
|
{0.0f, 0.0f, 0.4f},
|
||||||
{0.0f, 0.0f, rse_math_deg_to_radians(45.0f)},
|
{0.0f, 0.0f, rse_math_deg_to_radians(45.0f)},
|
||||||
1.0f,
|
1.0f,
|
||||||
tex_id_2
|
tex_id_2
|
||||||
@@ -83,7 +82,8 @@ void rse_graphics_test_function(void)
|
|||||||
tex_id_2
|
tex_id_2
|
||||||
});
|
});
|
||||||
|
|
||||||
rse_print_text("Hello World!", (struct vec3_t){-1.0f, 0.0f, 0.0f}, 0.3f);
|
rse_fonts_load_from_file("/usr/share/fonts/JetBrainsMonoNerdFont/JetBrainsMonoNerdFont-Medium.ttf");
|
||||||
|
rse_print_text("Hello World!", (struct vec3_t){-1.0f, 0.0f, 0.9f}, 0.3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
rse_err_t rse_graphics_run(void)
|
rse_err_t rse_graphics_run(void)
|
||||||
|
|||||||
@@ -22,17 +22,6 @@ struct vec3_t {
|
|||||||
float z;
|
float z;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 4 points vector, useful for colors with alpha channel
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
struct vec4_t {
|
|
||||||
float x;
|
|
||||||
float y;
|
|
||||||
float z;
|
|
||||||
float w;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* 4x4 matrix.
|
/* 4x4 matrix.
|
||||||
* [x_1 | x_2 | x_3 | x_4]
|
* [x_1 | x_2 | x_3 | x_4]
|
||||||
* [y_1 | y_2 | y_3 | y_4]
|
* [y_1 | y_2 | y_3 | y_4]
|
||||||
|
|||||||
@@ -98,16 +98,16 @@ rse_err_t rse_fonts_load_from_file(const char* file_path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
font_vertices[0] = (struct rse_vertex_t) {
|
font_vertices[0] = (struct rse_vertex_t) {
|
||||||
{g_fonts_data[iter].bearing_x, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}
|
{g_fonts_data[iter].bearing_x, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}
|
||||||
};
|
};
|
||||||
font_vertices[1] = (struct rse_vertex_t) {
|
font_vertices[1] = (struct rse_vertex_t) {
|
||||||
{g_fonts_data[iter].bearing_x + g_fonts_data[iter].width, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 0.0f}
|
{g_fonts_data[iter].bearing_x + g_fonts_data[iter].width, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f}, {1.0f, 0.0f}
|
||||||
};
|
};
|
||||||
font_vertices[2] = (struct rse_vertex_t) {
|
font_vertices[2] = (struct rse_vertex_t) {
|
||||||
{g_fonts_data[iter].bearing_x + g_fonts_data[iter].width, g_fonts_data[iter].height, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, {1.0f, 1.0f}
|
{g_fonts_data[iter].bearing_x + g_fonts_data[iter].width, g_fonts_data[iter].height, 0.0f}, {1.0f, 1.0f, 1.0f}, {1.0f, 1.0f}
|
||||||
};
|
};
|
||||||
font_vertices[3] = (struct rse_vertex_t) {
|
font_vertices[3] = (struct rse_vertex_t) {
|
||||||
{g_fonts_data[iter].bearing_x, g_fonts_data[iter].height, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 1.0f}
|
{g_fonts_data[iter].bearing_x, g_fonts_data[iter].height, 0.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 1.0f}
|
||||||
};
|
};
|
||||||
|
|
||||||
g_fonts_data[iter].mesh_id = create_mesh(font_vertices, font_indices, 8, 6);
|
g_fonts_data[iter].mesh_id = create_mesh(font_vertices, font_indices, 8, 6);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ extern struct rse_vulkan_state_t g_vulkan_state;
|
|||||||
struct rse_vertex_t
|
struct rse_vertex_t
|
||||||
{
|
{
|
||||||
struct vec3_t pos;
|
struct vec3_t pos;
|
||||||
struct vec4_t color;
|
struct vec3_t color;
|
||||||
struct vec3_t tex_coords;
|
struct vec3_t tex_coords;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user