mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-21 14:24:58 +01:00
Improve rain shader
This commit is contained in:
27
shaders/vk14/water_bake.comp
Normal file
27
shaders/vk14/water_bake.comp
Normal file
@@ -0,0 +1,27 @@
|
||||
#version 460 core
|
||||
#define STAGE_COMPUTE 1
|
||||
// the water on the windscreens (water_sim.glsl): the mask of the wipers of a glass baked into its map, once, when the glass is
|
||||
// set up. a thread per texel of the map; the glass is water_counts.z
|
||||
|
||||
// none of the pass set: everything the kernel reads is pushed with its dispatch (set COMPUTE_SET, water_sim.glsl), so it runs
|
||||
// before the passes of the frame set theirs up
|
||||
#define LAYOUT_UI 1
|
||||
#include "common.glsl"
|
||||
#include "water_sim.glsl"
|
||||
|
||||
layout(local_size_x = WATER_GROUP_SIZE) in;
|
||||
|
||||
// the mask of the wipers of the material of the glass (wipermask)
|
||||
layout(set = COMPUTE_SET, binding = 2) uniform sampler2D water_mask;
|
||||
|
||||
void main()
|
||||
{
|
||||
uint slot = water_counts.z;
|
||||
uint texel = gl_GlobalInvocationID.x;
|
||||
if ((slot >= uint(WATER_SLOTS)) || (texel >= uint(WATER_MAP * WATER_MAP)))
|
||||
return;
|
||||
vec2 uv = (vec2(float(texel % uint(WATER_MAP)), float(texel / uint(WATER_MAP))) + 0.5) / float(WATER_MAP);
|
||||
// as much of the mask as a texel of the map covers
|
||||
float lod = log2(max(float(textureSize(water_mask, 0).x) / float(WATER_MAP), 1.0));
|
||||
water_blades[slot * uint(WATER_MAP * WATER_MAP) + texel] = textureLod(water_mask, uv, lod);
|
||||
}
|
||||
Reference in New Issue
Block a user