Skip to content

Commit

Permalink
Support r_skyalpha
Browse files Browse the repository at this point in the history
  • Loading branch information
temx committed Apr 18, 2023
1 parent 4321c79 commit fa31bfd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Quake/gl_rmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,7 @@ void R_CreatePipelineLayouts ()
GL_SetObjectName ((uint64_t)vulkan_globals.sky_pipeline_layout[0].handle, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "sky_pipeline_layout");
vulkan_globals.sky_pipeline_layout[0].push_constant_range = push_constant_range;

push_constant_range.size = 24 * sizeof (float);
push_constant_range.size = 25 * sizeof (float);
pipeline_layout_create_info.setLayoutCount = 2;

err = vkCreatePipelineLayout (vulkan_globals.device, &pipeline_layout_create_info, NULL, &vulkan_globals.sky_pipeline_layout[1].handle);
Expand Down
5 changes: 3 additions & 2 deletions Quake/gl_sky.c
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ void Sky_DrawSky (cb_context_t *cbx)
else
memcpy (color, skyflatcolor, 3 * sizeof (float));

float constant_values[24];
float constant_values[25];
memcpy (constant_values, vulkan_globals.view_projection_matrix, sizeof (vulkan_globals.view_projection_matrix));
constant_values[16] = CLAMP (0.0f, color[0], 1.0f);
constant_values[17] = CLAMP (0.0f, color[1], 1.0f);
Expand Down Expand Up @@ -986,7 +986,8 @@ void Sky_DrawSky (cb_context_t *cbx)
cbx->cb, VK_PIPELINE_BIND_POINT_GRAPHICS, vulkan_globals.sky_layer_pipeline[indirect].layout.handle, 0, 2, descriptor_sets, 0, NULL);
memcpy (&constant_values[20], r_refdef.vieworg, sizeof (r_refdef.vieworg));
constant_values[23] = cl.time - (int)cl.time / 16 * 16;
R_PushConstants (cbx, VK_SHADER_STAGE_ALL_GRAPHICS, 0, 24 * sizeof (float), constant_values);
constant_values[24] = r_skyalpha.value;
R_PushConstants (cbx, VK_SHADER_STAGE_ALL_GRAPHICS, 0, 25 * sizeof (float), constant_values);
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions Shaders/sky_layer.frag
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ layout (push_constant) uniform PushConsts
float fog_density;
vec3 eye_pos;
float time;
float alpha;
}
push_constants;

Expand All @@ -26,6 +27,7 @@ void main ()
vec4 solid_layer = texture (solid_tex, uv + push_constants.time / 16.0f);
vec4 alpha_layer = texture (alpha_tex, uv + push_constants.time / 8.0f);

alpha_layer.a *= push_constants.alpha;
out_frag_color = vec4 ((solid_layer.rgb * (1.0f - alpha_layer.a) + alpha_layer.rgb * alpha_layer.a), 1.0f);

if (push_constants.fog_density > 0.0f)
Expand Down

0 comments on commit fa31bfd

Please sign in to comment.