veloren/assets/voxygen/shaders/include/rain_occlusion.glsl

37 lines
1.1 KiB
Plaintext
Raw Normal View History

2022-03-15 18:04:21 +00:00
#ifndef RAIN_OCCLUSION_GLSL
#define RAIN_OCCLUSION_GLSL
// Use with sampler2DShadow
layout(set = 1, binding = 4)
uniform texture2D t_directed_occlusion_maps;
layout(set = 1, binding = 5)
uniform samplerShadow s_directed_occlusion_maps;
layout (std140, set = 0, binding = 14)
uniform u_rain_occlusion {
mat4 occlusionMatrices;
mat4 occlusion_texture_mat;
};
float rain_occlusion_at(in vec3 fragPos)
{
float bias = 0.5;
2022-03-15 18:04:21 +00:00
float diskRadius = 0.01;
const vec3 sampleOffsetDirections[20] = vec3[]
(
vec3( 1, 1, 1), vec3( 1, -1, 1), vec3(-1, -1, 1), vec3(-1, 1, 1),
vec3( 1, 1, -1), vec3( 1, -1, -1), vec3(-1, -1, -1), vec3(-1, 1, -1),
vec3( 1, 1, 0), vec3( 1, -1, 0), vec3(-1, -1, 0), vec3(-1, 1, 0),
vec3( 1, 0, 1), vec3(-1, 0, 1), vec3( 1, 0, -1), vec3(-1, 0, -1),
vec3( 0, 1, 1), vec3( 0, -1, 1), vec3( 0, -1, -1), vec3( 0, 1, -1)
);
vec4 rain_pos = occlusion_texture_mat * vec4(fragPos - vec3(0, 0, bias), 1.0);
2022-03-15 18:04:21 +00:00
float visibility = textureProj(sampler2DShadow(t_directed_occlusion_maps, s_directed_occlusion_maps), rain_pos);
return visibility;
}
#endif