quakeforge/libs/video/renderer/vulkan/shader/quakebsp.frag
Bill Currie 3168550935 [vulkan] Upload lightmap data to the gpu and use it
The lightmaps aren't updated at all yet, so everything is static.
Figuring out how lightmap data gets to the gpu was a chore thanks to the
spaghetti in the bsp data, and then I'd forgotten that I was
pre-expanding the light data to rgb so wound up with weird lightmaps,
but without water or particles, demo1 is getting 5000fps at 800x450, and
it seems to be CPU limited.
2024-01-19 15:45:04 +09:00

42 lines
1 KiB
GLSL

#version 450
layout (set = 3, binding = 0) uniform sampler2DArray Texture;
layout (set = 4, binding = 0) uniform sampler2D Lightmap;
layout (push_constant) uniform PushConstants {
vec4 fog;
float time;
float alpha;
};
layout (location = 0) in vec4 tl_st;
layout (location = 1) in vec3 direction;
layout (location = 2) in vec3 normal;
layout (location = 3) in vec4 position;
layout (location = 4) in vec4 color;
layout (location = 0) out vec4 frag_color;
vec4
fogBlend (vec4 color)
{
float az = fog.a * gl_FragCoord.z / gl_FragCoord.w;
vec3 fog_color = fog.rgb;
float fog_factor = exp (-az * az);
return vec4 (mix (fog_color.rgb, color.rgb, fog_factor), color.a);
}
void
main (void)
{
vec3 t_st = vec3 (tl_st.xy, 0);
vec3 e_st = vec3 (tl_st.xy, 1);
vec2 l_st = vec2 (tl_st.zw);
vec4 c = texture (Texture, t_st) * color;
vec4 e = texture (Texture, e_st);
vec4 l = texture (Lightmap, l_st);
frag_color = c * l + e;//fogBlend (c);
}