Use additive blending for the ribbon in GL and Vulkan

This commit is contained in:
Jean-André Santoni 2017-05-22 01:29:56 +02:00
parent 1bd07c34c7
commit 0b1716650b
8 changed files with 47 additions and 21 deletions

View File

@ -12,6 +12,6 @@ static const char *stock_fragment_xmb = GLSL(
vec3 normal=normalize(cross(X,Y));
float c = (1.0 - dot(normal, up));
c = (1.0 - cos(c*c))/3.0;
gl_FragColor = vec4(1.0, 1.0, 1.0, c);
gl_FragColor = vec4(c, c, c, 1.0);
}
);

View File

@ -5,6 +5,6 @@ static const char *stock_fragment_xmb_ribbon_simple = GLSL(
void main()
{
gl_FragColor = vec4(1.0, 1.0, 1.0, 0.05);
gl_FragColor = vec4(0.05, 0.05, 0.05, 1.0);
}
);

View File

@ -477,6 +477,19 @@ static void vulkan_init_pipelines(
vkCreateShaderModule(vk->context->device,
&module_info, NULL, &shader_stages[1].module);
switch (i >> 1)
{
case 0:
case 1:
blend_attachment.srcColorBlendFactor = VK_BLEND_FACTOR_ONE;
blend_attachment.dstColorBlendFactor = VK_BLEND_FACTOR_ONE;
break;
default:
blend_attachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
blend_attachment.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
break;
}
input_assembly.topology = i & 1 ?
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP :
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;

View File

@ -17,5 +17,5 @@ void main()
vec3 normal = normalize(cross(x, y));
float c = 1.0 - dot(normal, up);
c = (1.0 - cos(c * c)) / 3.0;
FragColor = vec4(1.0, 1.0, 1.0, c);
FragColor = vec4(c, c, c, 1.0);
}

View File

@ -1,4 +1,4 @@
{0x07230203,0x00010000,0x00080001,0x0000002d,
{0x07230203,0x00010000,0x000d0001,0x0000002f,
0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,
0x00000000,0x0003000e,0x00000000,0x00000001,
@ -16,15 +16,15 @@
0x00040005,0x00000011,0x6d726f6e,0x00006c61,
0x00030005,0x00000017,0x00000063,0x00050005,
0x00000027,0x67617246,0x6f6c6f43,0x00000072,
0x00030005,0x0000002a,0x004f4255,0x00050006,
0x0000002a,0x00000000,0x656d6974,0x00000000,
0x00050005,0x0000002c,0x736e6f63,0x746e6174,
0x00030005,0x0000002c,0x004f4255,0x00050006,
0x0000002c,0x00000000,0x656d6974,0x00000000,
0x00050005,0x0000002e,0x736e6f63,0x746e6174,
0x00000073,0x00040047,0x0000000b,0x0000001e,
0x00000000,0x00040047,0x00000027,0x0000001e,
0x00000000,0x00050048,0x0000002a,0x00000000,
0x00000023,0x00000000,0x00030047,0x0000002a,
0x00000002,0x00040047,0x0000002c,0x00000022,
0x00000000,0x00040047,0x0000002c,0x00000021,
0x00000000,0x00050048,0x0000002c,0x00000000,
0x00000023,0x00000000,0x00030047,0x0000002c,
0x00000002,0x00040047,0x0000002e,0x00000022,
0x00000000,0x00040047,0x0000002e,0x00000021,
0x00000000,0x00020013,0x00000002,0x00030021,
0x00000003,0x00000002,0x00030016,0x00000006,
0x00000020,0x00040017,0x00000007,0x00000006,
@ -40,9 +40,9 @@
0x00000025,0x00000006,0x00000004,0x00040020,
0x00000026,0x00000003,0x00000025,0x0004003b,
0x00000026,0x00000027,0x00000003,0x0003001e,
0x0000002a,0x00000006,0x00040020,0x0000002b,
0x00000002,0x0000002a,0x0004003b,0x0000002b,
0x0000002c,0x00000002,0x00050036,0x00000002,
0x0000002c,0x00000006,0x00040020,0x0000002d,
0x00000002,0x0000002c,0x0004003b,0x0000002d,
0x0000002e,0x00000002,0x00050036,0x00000002,
0x00000004,0x00000000,0x00000003,0x000200f8,
0x00000005,0x0004003b,0x00000008,0x00000009,
0x00000007,0x0004003b,0x00000008,0x0000000e,
@ -73,6 +73,8 @@
0x00050088,0x00000006,0x00000024,0x00000022,
0x00000023,0x0003003e,0x00000017,0x00000024,
0x0004003d,0x00000006,0x00000028,0x00000017,
0x00070050,0x00000025,0x00000029,0x00000018,
0x00000018,0x00000018,0x00000028,0x0003003e,
0x00000027,0x00000029,0x000100fd,0x00010038}
0x0004003d,0x00000006,0x00000029,0x00000017,
0x0004003d,0x00000006,0x0000002a,0x00000017,
0x00070050,0x00000025,0x0000002b,0x00000028,
0x00000029,0x0000002a,0x00000018,0x0003003e,
0x00000027,0x0000002b,0x000100fd,0x00010038}

View File

@ -4,5 +4,5 @@ precision mediump float;
layout(location = 0) out vec4 FragColor;
void main()
{
FragColor = vec4(1.0, 1.0, 1.0, 0.05);
FragColor = vec4(0.05, 0.05, 0.05, 1.0);
}

View File

@ -1,4 +1,4 @@
{0x07230203,0x00010000,0x00080001,0x0000000d,
{0x07230203,0x00010000,0x000d0001,0x0000000d,
0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,
0x00000000,0x0003000e,0x00000000,0x00000001,
@ -19,8 +19,8 @@
0x00000006,0x00000004,0x00040020,0x00000008,
0x00000003,0x00000007,0x0004003b,0x00000008,
0x00000009,0x00000003,0x0004002b,0x00000006,
0x0000000a,0x3f800000,0x0004002b,0x00000006,
0x0000000b,0x3d4ccccd,0x0007002c,0x00000007,
0x0000000a,0x3d4ccccd,0x0004002b,0x00000006,
0x0000000b,0x3f800000,0x0007002c,0x00000007,
0x0000000c,0x0000000a,0x0000000a,0x0000000a,
0x0000000b,0x00050036,0x00000002,0x00000004,
0x00000000,0x00000003,0x000200f8,0x00000005,

View File

@ -167,6 +167,17 @@ static void menu_display_gl_draw_pipeline(void *data)
draw->coords = (struct video_coords*)(&ca->coords);
draw->matrix_data = NULL;
switch (draw->pipeline.id)
{
case VIDEO_SHADER_MENU:
case VIDEO_SHADER_MENU_2:
glBlendFunc(GL_ONE, GL_ONE);
break;
default:
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
break;
}
switch (draw->pipeline.id)
{
case VIDEO_SHADER_MENU: