Files
armorpaint/paint/sources/make_particle.c
T

20 lines
1.2 KiB
C
Raw Normal View History

2026-03-09 13:17:15 +01:00
#include "global.h"
2026-03-06 12:56:38 +01:00
void make_particle_mask(node_shader_t *kong) {
2025-04-02 22:52:04 +02:00
node_shader_add_out(kong, "wpos: float4");
2025-04-04 23:38:01 +02:00
node_shader_add_constant(kong, "W: float4x4", "_world_matrix");
node_shader_write_attrib_vert(kong, "output.wpos = constants.W * float4(input.pos.xyz, 1.0);");
node_shader_add_constant(kong, "particle_hit: float3", "_particle_hit");
node_shader_add_constant(kong, "particle_hit_last: float3", "_particle_hit_last");
2026-05-11 19:48:30 +02:00
node_shader_add_constant(kong, "particle_radius: float", "_particle_radius");
2025-02-11 14:11:04 +01:00
2025-04-04 23:38:01 +02:00
node_shader_write_frag(kong, "var pa: float3 = input.wpos.xyz - constants.particle_hit;");
node_shader_write_frag(kong, "var ba: float3 = constants.particle_hit_last - constants.particle_hit;");
2026-05-11 19:48:30 +02:00
node_shader_write_frag(kong, "var h: float = clamp(dot(pa, ba) / max(dot(ba, ba), 0.00000001), 0.0, 1.0);");
node_shader_write_frag(kong, "dist = length(pa - ba * h) * (5.0 / constants.particle_radius);");
2025-04-02 22:52:04 +02:00
node_shader_write_frag(kong, "if (dist > 1.0) { discard; }");
2025-07-13 19:06:59 +02:00
node_shader_write_frag(kong, "var str: float = clamp(pow(1.0 / dist * constants.brush_hardness * 0.2, 4.0), 0.0, 1.0) * opacity;");
2025-04-02 22:52:04 +02:00
node_shader_write_frag(kong, "if (str == 0.0) { discard; }");
2024-03-14 15:31:22 +01:00
}