particle shaders

This commit is contained in:
Tuomas Katajisto 2026-03-21 10:59:39 +02:00
parent 1b061f929f
commit 8ab0a1fd6b
3 changed files with 1326 additions and 586 deletions

View File

@ -0,0 +1,637 @@
/*
#version:1# (machine generated, don't edit!)
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
Cmdline:
sokol-shdc -i shader_particle.glsl -o ./jai/shader_particle.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
Overview:
=========
Shader program: 'particle':
Get shader desc: particle_shader_desc(sg_query_backend())
Vertex Shader: vs_particle
Fragment Shader: fs_particle
Attributes:
ATTR_particle_position => 0
ATTR_particle_inst_pos_size => 1
ATTR_particle_inst_uv_rect => 2
ATTR_particle_inst_color => 3
Bindings:
Uniform block 'particle_vs_params':
Jai struct: Particle_Vs_Params
Bind slot: UB_particle_vs_params => 0
Image 'particle_sprite':
Image type: ._2D
Sample type: .FLOAT
Multisampled: false
Bind slot: IMG_particle_sprite => 0
Sampler 'particle_spritesmp':
Type: .FILTERING
Bind slot: SMP_particle_spritesmp => 0
*/
ATTR_particle_position :: 0;
ATTR_particle_inst_pos_size :: 1;
ATTR_particle_inst_uv_rect :: 2;
ATTR_particle_inst_color :: 3;
UB_particle_vs_params :: 0;
IMG_particle_sprite :: 0;
SMP_particle_spritesmp :: 0;
Particle_Vs_Params :: struct {
mvp: [16]float;
cam: [3]float;
_: [4]u8;
};
/*
#version 430
uniform vec4 particle_vs_params[5];
layout(location = 1) in vec4 inst_pos_size;
layout(location = 0) in vec3 position;
layout(location = 0) out vec2 uv_in;
layout(location = 2) in vec4 inst_uv_rect;
layout(location = 1) out vec4 color_in;
layout(location = 3) in vec4 inst_color;
void main()
{
vec3 _53 = inst_pos_size.xyz - particle_vs_params[4].xyz;
_53.y = 0.0;
vec3 look_dir = _53;
if (length(_53) < 9.9999997473787516355514526367188e-05)
{
look_dir = vec3(1.0, 0.0, 0.0);
}
vec3 _63 = look_dir;
vec3 _64 = normalize(_63);
look_dir = _64;
gl_Position = mat4(particle_vs_params[0], particle_vs_params[1], particle_vs_params[2], particle_vs_params[3]) * vec4((inst_pos_size.xyz + (normalize(cross(vec3(0.0, 1.0, 0.0), _64)) * ((position.x - 0.5) * inst_pos_size.w))) + (vec3(0.0, 1.0, 0.0) * (position.y * inst_pos_size.w)), 1.0);
uv_in = vec2(inst_uv_rect.x + (position.x * inst_uv_rect.z), inst_uv_rect.y + (position.y * inst_uv_rect.w));
color_in = inst_color;
}
*/
vs_particle_source_glsl430 := u8.[
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x75,0x6e,
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x61,0x72,0x74,0x69,
0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,
0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,
0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x69,
0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x6c,0x61,
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x6f,0x73,0x69,0x74,
0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
0x63,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,
0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,0x5f,0x72,
0x65,0x63,0x74,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x69,0x6e,0x3b,0x0a,0x6c,0x61,0x79,
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x33,
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,
0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x35,
0x33,0x20,0x3d,0x20,0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,
0x65,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x78,0x79,
0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x35,0x33,0x2e,0x79,0x20,0x3d,0x20,0x30,
0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x6c,0x6f,0x6f,
0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x5f,0x35,0x33,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x69,0x66,0x20,0x28,0x6c,0x65,0x6e,0x67,0x74,0x68,0x28,0x5f,0x35,0x33,0x29,
0x20,0x3c,0x20,0x39,0x2e,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x34,0x37,0x33,0x37,
0x38,0x37,0x35,0x31,0x36,0x33,0x35,0x35,0x35,0x31,0x34,0x35,0x32,0x36,0x33,0x36,
0x37,0x31,0x38,0x38,0x65,0x2d,0x30,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,
0x20,0x3d,0x20,0x76,0x65,0x63,0x33,0x28,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,
0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,
0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x36,0x33,0x20,0x3d,0x20,0x6c,0x6f,0x6f,
0x6b,0x5f,0x64,0x69,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,
0x5f,0x36,0x34,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,
0x5f,0x36,0x33,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,
0x69,0x72,0x20,0x3d,0x20,0x5f,0x36,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,
0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,
0x28,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,
0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x70,
0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
0x73,0x5b,0x32,0x5d,0x2c,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,
0x65,0x63,0x34,0x28,0x28,0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,
0x7a,0x65,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x76,0x65,0x63,0x33,0x28,0x30,
0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,0x5f,
0x36,0x34,0x29,0x29,0x20,0x2a,0x20,0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
0x6e,0x2e,0x78,0x20,0x2d,0x20,0x30,0x2e,0x35,0x29,0x20,0x2a,0x20,0x69,0x6e,0x73,
0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,0x2e,0x77,0x29,0x29,0x29,0x20,
0x2b,0x20,0x28,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,
0x2c,0x20,0x30,0x2e,0x30,0x29,0x20,0x2a,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,
0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,
0x73,0x69,0x7a,0x65,0x2e,0x77,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x75,0x76,0x5f,0x69,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,
0x28,0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x78,0x20,
0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2a,0x20,
0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x7a,0x29,0x2c,
0x20,0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x79,0x20,
0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,
0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x77,0x29,0x29,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x69,0x6e,0x20,0x3d,
0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,
0x00,
];
/*
#version 430
layout(binding = 16) uniform sampler2D particle_sprite_particle_spritesmp;
layout(location = 0) in vec2 uv_in;
layout(location = 0) out vec4 color;
layout(location = 1) in vec4 color_in;
void main()
{
vec2 _12 = uv_in;
_12.y = 1.0 - _12.y;
vec4 _35 = texture(particle_sprite_particle_spritesmp, _12);
if (_35.w < 0.00999999977648258209228515625)
{
discard;
}
color = _35 * color_in;
}
*/
fs_particle_source_glsl430 := u8.[
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,
0x36,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,
0x65,0x72,0x32,0x44,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x73,0x70,
0x72,0x69,0x74,0x65,0x5f,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x73,0x70,
0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,
0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x6c,0x61,
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,
0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,
0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,
0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x69,0x6e,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,
0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,
0x32,0x20,0x5f,0x31,0x32,0x20,0x3d,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x5f,0x31,0x32,0x2e,0x79,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,
0x20,0x5f,0x31,0x32,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,
0x20,0x5f,0x33,0x35,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x70,
0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x73,0x70,0x72,0x69,0x74,0x65,0x5f,0x70,
0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x73,0x70,0x72,0x69,0x74,0x65,0x73,0x6d,
0x70,0x2c,0x20,0x5f,0x31,0x32,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,
0x28,0x5f,0x33,0x35,0x2e,0x77,0x20,0x3c,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,0x39,
0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,0x32,
0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,
0x20,0x3d,0x20,0x5f,0x33,0x35,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x69,
0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#version 300 es
uniform vec4 particle_vs_params[5];
layout(location = 1) in vec4 inst_pos_size;
layout(location = 0) in vec3 position;
out vec2 uv_in;
layout(location = 2) in vec4 inst_uv_rect;
out vec4 color_in;
layout(location = 3) in vec4 inst_color;
void main()
{
vec3 _53 = inst_pos_size.xyz - particle_vs_params[4].xyz;
_53.y = 0.0;
vec3 look_dir = _53;
if (length(_53) < 9.9999997473787516355514526367188e-05)
{
look_dir = vec3(1.0, 0.0, 0.0);
}
vec3 _63 = look_dir;
vec3 _64 = normalize(_63);
look_dir = _64;
gl_Position = mat4(particle_vs_params[0], particle_vs_params[1], particle_vs_params[2], particle_vs_params[3]) * vec4((inst_pos_size.xyz + (normalize(cross(vec3(0.0, 1.0, 0.0), _64)) * ((position.x - 0.5) * inst_pos_size.w))) + (vec3(0.0, 1.0, 0.0) * (position.y * inst_pos_size.w)), 1.0);
uv_in = vec2(inst_uv_rect.x + (position.x * inst_uv_rect.z), inst_uv_rect.y + (position.y * inst_uv_rect.w));
color_in = inst_color;
}
*/
vs_particle_source_glsl300es := u8.[
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x61,
0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
0x5b,0x35,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,
0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,0x3b,
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x33,0x20,0x70,0x6f,
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,
0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,
0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,
0x76,0x65,0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,0x5f,0x72,0x65,0x63,
0x74,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,
0x72,0x5f,0x69,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,
0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x33,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,
0x63,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,
0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,
0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x35,0x33,0x20,0x3d,0x20,0x69,0x6e,0x73,
0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,0x2e,0x78,0x79,0x7a,0x20,0x2d,
0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,
0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x78,0x79,0x7a,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x5f,0x35,0x33,0x2e,0x79,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x76,0x65,0x63,0x33,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,
0x20,0x5f,0x35,0x33,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x6c,0x65,
0x6e,0x67,0x74,0x68,0x28,0x5f,0x35,0x33,0x29,0x20,0x3c,0x20,0x39,0x2e,0x39,0x39,
0x39,0x39,0x39,0x39,0x37,0x34,0x37,0x33,0x37,0x38,0x37,0x35,0x31,0x36,0x33,0x35,
0x35,0x35,0x31,0x34,0x35,0x32,0x36,0x33,0x36,0x37,0x31,0x38,0x38,0x65,0x2d,0x30,
0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x33,
0x28,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,
0x5f,0x36,0x33,0x20,0x3d,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x33,0x20,0x5f,0x36,0x34,0x20,0x3d,0x20,0x6e,
0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x36,0x33,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x5f,0x36,
0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x70,0x61,0x72,0x74,0x69,0x63,
0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,
0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,
0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,
0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x70,
0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x69,0x6e,
0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,0x2e,0x78,0x79,0x7a,0x20,
0x2b,0x20,0x28,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,
0x73,0x73,0x28,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,
0x2c,0x20,0x30,0x2e,0x30,0x29,0x2c,0x20,0x5f,0x36,0x34,0x29,0x29,0x20,0x2a,0x20,
0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2d,0x20,0x30,
0x2e,0x35,0x29,0x20,0x2a,0x20,0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,
0x69,0x7a,0x65,0x2e,0x77,0x29,0x29,0x29,0x20,0x2b,0x20,0x28,0x76,0x65,0x63,0x33,
0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x20,
0x2a,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,
0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,0x2e,0x77,0x29,
0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x5f,
0x69,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x69,0x6e,0x73,0x74,0x5f,0x75,
0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x78,0x20,0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,
0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2a,0x20,0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,
0x5f,0x72,0x65,0x63,0x74,0x2e,0x7a,0x29,0x2c,0x20,0x69,0x6e,0x73,0x74,0x5f,0x75,
0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x79,0x20,0x2b,0x20,0x28,0x70,0x6f,0x73,0x69,
0x74,0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,
0x5f,0x72,0x65,0x63,0x74,0x2e,0x77,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,
0x6f,0x6c,0x6f,0x72,0x5f,0x69,0x6e,0x20,0x3d,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#version 300 es
precision mediump float;
precision highp int;
uniform highp sampler2D particle_sprite_particle_spritesmp;
in highp vec2 uv_in;
layout(location = 0) out highp vec4 color;
in highp vec4 color_in;
void main()
{
highp vec2 _12 = uv_in;
_12.y = 1.0 - _12.y;
highp vec4 _35 = texture(particle_sprite_particle_spritesmp, _12);
if (_35.w < 0.00999999977648258209228515625)
{
discard;
}
color = _35 * color_in;
}
*/
fs_particle_source_glsl300es := u8.[
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,
0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,
0x73,0x70,0x72,0x69,0x74,0x65,0x5f,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,
0x73,0x70,0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x69,0x6e,0x20,0x68,
0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,
0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,
0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20,0x68,
0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x5f,
0x69,0x6e,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
0x32,0x20,0x5f,0x31,0x32,0x20,0x3d,0x20,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x5f,0x31,0x32,0x2e,0x79,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,
0x20,0x5f,0x31,0x32,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,
0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x33,0x35,0x20,0x3d,0x20,0x74,0x65,0x78,
0x74,0x75,0x72,0x65,0x28,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x73,0x70,
0x72,0x69,0x74,0x65,0x5f,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x73,0x70,
0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x2c,0x20,0x5f,0x31,0x32,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x33,0x35,0x2e,0x77,0x20,0x3c,0x20,0x30,
0x2e,0x30,0x30,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,
0x35,0x38,0x32,0x30,0x39,0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x0a,
0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,
0x73,0x63,0x61,0x72,0x64,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,
0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x5f,0x33,0x35,0x20,0x2a,0x20,0x63,
0x6f,0x6c,0x6f,0x72,0x5f,0x69,0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct particle_vs_params
{
float4x4 mvp;
float3 cam;
};
struct main0_out
{
float2 uv_in [[user(locn0)]];
float4 color_in [[user(locn1)]];
float4 gl_Position [[position]];
};
struct main0_in
{
float3 position [[attribute(0)]];
float4 inst_pos_size [[attribute(1)]];
float4 inst_uv_rect [[attribute(2)]];
float4 inst_color [[attribute(3)]];
};
vertex main0_out main0(main0_in in [[stage_in]], constant particle_vs_params& _47 [[buffer(0)]])
{
main0_out out = {};
float3 _53 = in.inst_pos_size.xyz - _47.cam;
_53.y = 0.0;
float3 look_dir = _53;
if (length(_53) < 9.9999997473787516355514526367188e-05)
{
look_dir = float3(1.0, 0.0, 0.0);
}
float3 _63 = look_dir;
float3 _64 = fast::normalize(_63);
look_dir = _64;
out.gl_Position = _47.mvp * float4((in.inst_pos_size.xyz + (fast::normalize(cross(float3(0.0, 1.0, 0.0), _64)) * ((in.position.x - 0.5) * in.inst_pos_size.w))) + (float3(0.0, 1.0, 0.0) * (in.position.y * in.inst_pos_size.w)), 1.0);
out.uv_in = float2(in.inst_uv_rect.x + (in.position.x * in.inst_uv_rect.z), in.inst_uv_rect.y + (in.position.y * in.inst_uv_rect.w));
out.color_in = in.inst_color;
return out;
}
*/
vs_particle_source_metal_macos := u8.[
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x70,
0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,
0x20,0x6d,0x76,0x70,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,
0x20,0x63,0x61,0x6d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,
0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,
0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,0x20,0x5b,0x5b,
0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x5f,
0x69,0x6e,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x31,0x29,
0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,
0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,
0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,
0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,
0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,0x20,0x5b,0x5b,
0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,
0x75,0x76,0x5f,0x72,0x65,0x63,0x74,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,
0x75,0x74,0x65,0x28,0x32,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
0x6f,0x61,0x74,0x34,0x20,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,
0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x33,0x29,0x5d,0x5d,
0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,
0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,
0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,
0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,
0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
0x6d,0x73,0x26,0x20,0x5f,0x34,0x37,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,
0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,
0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x35,0x33,0x20,
0x3d,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,
0x7a,0x65,0x2e,0x78,0x79,0x7a,0x20,0x2d,0x20,0x5f,0x34,0x37,0x2e,0x63,0x61,0x6d,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x5f,0x35,0x33,0x2e,0x79,0x20,0x3d,0x20,0x30,0x2e,
0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x6c,0x6f,
0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,0x3d,0x20,0x5f,0x35,0x33,0x3b,0x0a,0x20,0x20,
0x20,0x20,0x69,0x66,0x20,0x28,0x6c,0x65,0x6e,0x67,0x74,0x68,0x28,0x5f,0x35,0x33,
0x29,0x20,0x3c,0x20,0x39,0x2e,0x39,0x39,0x39,0x39,0x39,0x39,0x37,0x34,0x37,0x33,
0x37,0x38,0x37,0x35,0x31,0x36,0x33,0x35,0x35,0x35,0x31,0x34,0x35,0x32,0x36,0x33,
0x36,0x37,0x31,0x38,0x38,0x65,0x2d,0x30,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,
0x72,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x31,0x2e,0x30,0x2c,0x20,
0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x36,0x33,0x20,
0x3d,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,
0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x36,0x34,0x20,0x3d,0x20,0x66,0x61,0x73,
0x74,0x3a,0x3a,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x5f,0x36,0x33,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6c,0x6f,0x6f,0x6b,0x5f,0x64,0x69,0x72,0x20,
0x3d,0x20,0x5f,0x36,0x34,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,0x34,0x37,
0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x28,0x69,
0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,0x2e,
0x78,0x79,0x7a,0x20,0x2b,0x20,0x28,0x66,0x61,0x73,0x74,0x3a,0x3a,0x6e,0x6f,0x72,
0x6d,0x61,0x6c,0x69,0x7a,0x65,0x28,0x63,0x72,0x6f,0x73,0x73,0x28,0x66,0x6c,0x6f,
0x61,0x74,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,
0x30,0x29,0x2c,0x20,0x5f,0x36,0x34,0x29,0x29,0x20,0x2a,0x20,0x28,0x28,0x69,0x6e,
0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2d,0x20,0x30,0x2e,
0x35,0x29,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x70,0x6f,0x73,
0x5f,0x73,0x69,0x7a,0x65,0x2e,0x77,0x29,0x29,0x29,0x20,0x2b,0x20,0x28,0x66,0x6c,
0x6f,0x61,0x74,0x33,0x28,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x30,
0x2e,0x30,0x29,0x20,0x2a,0x20,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,
0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x70,
0x6f,0x73,0x5f,0x73,0x69,0x7a,0x65,0x2e,0x77,0x29,0x29,0x2c,0x20,0x31,0x2e,0x30,
0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x75,0x76,0x5f,0x69,0x6e,
0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x69,0x6e,0x2e,0x69,0x6e,0x73,
0x74,0x5f,0x75,0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x78,0x20,0x2b,0x20,0x28,0x69,
0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2a,0x20,0x69,
0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x7a,
0x29,0x2c,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x75,0x76,0x5f,0x72,0x65,
0x63,0x74,0x2e,0x79,0x20,0x2b,0x20,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,
0x69,0x6f,0x6e,0x2e,0x79,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,
0x75,0x76,0x5f,0x72,0x65,0x63,0x74,0x2e,0x77,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x69,0x6e,0x20,0x3d,0x20,
0x69,0x6e,0x2e,0x69,0x6e,0x73,0x74,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,
0x0a,0x0a,0x00,
];
/*
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 color [[color(0)]];
};
struct main0_in
{
float2 uv_in [[user(locn0)]];
float4 color_in [[user(locn1)]];
};
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> particle_sprite [[texture(0)]], sampler particle_spritesmp [[sampler(0)]])
{
main0_out out = {};
float2 _12 = in.uv_in;
_12.y = 1.0 - _12.y;
float4 _35 = particle_sprite.sample(particle_spritesmp, _12);
if (_35.w < 0.00999999977648258209228515625)
{
discard_fragment();
}
out.color = _35 * in.color_in;
return out;
}
*/
fs_particle_source_metal_macos := u8.[
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x63,0x6f,
0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x5f,0x69,0x6e,
0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,
0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,
0x6f,0x72,0x5f,0x69,0x6e,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,
0x6e,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,
0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,
0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,
0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x74,0x65,
0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x70,
0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x73,0x70,0x72,0x69,0x74,0x65,0x20,0x5b,
0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,
0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,
0x73,0x70,0x72,0x69,0x74,0x65,0x73,0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,
0x6c,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,
0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f,
0x31,0x32,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x75,0x76,0x5f,0x69,0x6e,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x5f,0x31,0x32,0x2e,0x79,0x20,0x3d,0x20,0x31,0x2e,0x30,0x20,0x2d,
0x20,0x5f,0x31,0x32,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,
0x74,0x34,0x20,0x5f,0x33,0x35,0x20,0x3d,0x20,0x70,0x61,0x72,0x74,0x69,0x63,0x6c,
0x65,0x5f,0x73,0x70,0x72,0x69,0x74,0x65,0x2e,0x73,0x61,0x6d,0x70,0x6c,0x65,0x28,
0x70,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x5f,0x73,0x70,0x72,0x69,0x74,0x65,0x73,
0x6d,0x70,0x2c,0x20,0x5f,0x31,0x32,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,
0x20,0x28,0x5f,0x33,0x35,0x2e,0x77,0x20,0x3c,0x20,0x30,0x2e,0x30,0x30,0x39,0x39,
0x39,0x39,0x39,0x39,0x39,0x37,0x37,0x36,0x34,0x38,0x32,0x35,0x38,0x32,0x30,0x39,
0x32,0x32,0x38,0x35,0x31,0x35,0x36,0x32,0x35,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x64,0x69,0x73,0x63,0x61,0x72,0x64,
0x5f,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,
0x20,0x3d,0x20,0x5f,0x33,0x35,0x20,0x2a,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,
0x72,0x5f,0x69,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,
0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
particle_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
desc: sg_shader_desc;
desc.label = "particle_shader";
if backend == {
case .GLCORE;
desc.vertex_func.source = xx *vs_particle_source_glsl430;
desc.vertex_func.entry = "main";
desc.fragment_func.source = xx *fs_particle_source_glsl430;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = .FLOAT;
desc.attrs[0].glsl_name = "position";
desc.attrs[1].base_type = .FLOAT;
desc.attrs[1].glsl_name = "inst_pos_size";
desc.attrs[2].base_type = .FLOAT;
desc.attrs[2].glsl_name = "inst_uv_rect";
desc.attrs[3].base_type = .FLOAT;
desc.attrs[3].glsl_name = "inst_color";
desc.uniform_blocks[0].stage = .VERTEX;
desc.uniform_blocks[0].layout = .STD140;
desc.uniform_blocks[0].size = 80;
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 5;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "particle_vs_params";
desc.images[0].stage = .FRAGMENT;
desc.images[0].multisampled = false;
desc.images[0].image_type = ._2D;
desc.images[0].sample_type = .FLOAT;
desc.samplers[0].stage = .FRAGMENT;
desc.samplers[0].sampler_type = .FILTERING;
desc.image_sampler_pairs[0].stage = .FRAGMENT;
desc.image_sampler_pairs[0].image_slot = 0;
desc.image_sampler_pairs[0].sampler_slot = 0;
desc.image_sampler_pairs[0].glsl_name = "particle_sprite_particle_spritesmp";
case .GLES3;
desc.vertex_func.source = xx *vs_particle_source_glsl300es;
desc.vertex_func.entry = "main";
desc.fragment_func.source = xx *fs_particle_source_glsl300es;
desc.fragment_func.entry = "main";
desc.attrs[0].base_type = .FLOAT;
desc.attrs[0].glsl_name = "position";
desc.attrs[1].base_type = .FLOAT;
desc.attrs[1].glsl_name = "inst_pos_size";
desc.attrs[2].base_type = .FLOAT;
desc.attrs[2].glsl_name = "inst_uv_rect";
desc.attrs[3].base_type = .FLOAT;
desc.attrs[3].glsl_name = "inst_color";
desc.uniform_blocks[0].stage = .VERTEX;
desc.uniform_blocks[0].layout = .STD140;
desc.uniform_blocks[0].size = 80;
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 5;
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "particle_vs_params";
desc.images[0].stage = .FRAGMENT;
desc.images[0].multisampled = false;
desc.images[0].image_type = ._2D;
desc.images[0].sample_type = .FLOAT;
desc.samplers[0].stage = .FRAGMENT;
desc.samplers[0].sampler_type = .FILTERING;
desc.image_sampler_pairs[0].stage = .FRAGMENT;
desc.image_sampler_pairs[0].image_slot = 0;
desc.image_sampler_pairs[0].sampler_slot = 0;
desc.image_sampler_pairs[0].glsl_name = "particle_sprite_particle_spritesmp";
case .METAL_MACOS;
desc.vertex_func.source = xx *vs_particle_source_metal_macos;
desc.vertex_func.entry = "main0";
desc.fragment_func.source = xx *fs_particle_source_metal_macos;
desc.fragment_func.entry = "main0";
desc.attrs[0].base_type = .FLOAT;
desc.attrs[1].base_type = .FLOAT;
desc.attrs[2].base_type = .FLOAT;
desc.attrs[3].base_type = .FLOAT;
desc.uniform_blocks[0].stage = .VERTEX;
desc.uniform_blocks[0].layout = .STD140;
desc.uniform_blocks[0].size = 80;
desc.uniform_blocks[0].msl_buffer_n = 0;
desc.images[0].stage = .FRAGMENT;
desc.images[0].multisampled = false;
desc.images[0].image_type = ._2D;
desc.images[0].sample_type = .FLOAT;
desc.images[0].msl_texture_n = 0;
desc.samplers[0].stage = .FRAGMENT;
desc.samplers[0].sampler_type = .FILTERING;
desc.samplers[0].msl_sampler_n = 0;
desc.image_sampler_pairs[0].stage = .FRAGMENT;
desc.image_sampler_pairs[0].image_slot = 0;
desc.image_sampler_pairs[0].sampler_slot = 0;
}
return desc;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,54 @@
@vs vs_particle
in vec3 position;
in vec4 inst_pos_size;
in vec4 inst_uv_rect;
in vec4 inst_color;
layout(binding=0) uniform particle_vs_params {
mat4 mvp;
vec3 cam;
};
out vec2 uv_in;
out vec4 color_in;
void main() {
float size = inst_pos_size.w;
vec3 inst_pos = inst_pos_size.xyz;
vec3 local_pos = vec3((position.x - 0.5) * size, position.y * size, 0.0);
vec3 world_up = vec3(0.0, 1.0, 0.0);
vec3 look_dir = inst_pos - cam;
look_dir.y = 0.0;
if (length(look_dir) < 0.0001) look_dir = vec3(1.0, 0.0, 0.0);
look_dir = normalize(look_dir);
vec3 world_right = normalize(cross(world_up, look_dir));
vec3 world_pos = inst_pos + world_right * local_pos.x + world_up * local_pos.y;
gl_Position = mvp * vec4(world_pos, 1.0);
uv_in = vec2(inst_uv_rect.x + position.x * inst_uv_rect.z,
inst_uv_rect.y + position.y * inst_uv_rect.w);
color_in = inst_color;
}
@end
@fs fs_particle
in vec2 uv_in;
in vec4 color_in;
out vec4 color;
layout(binding = 0) uniform texture2D particle_sprite;
layout(binding = 0) uniform sampler particle_spritesmp;
void main() {
vec2 uv = uv_in;
uv.y = 1.0 - uv.y;
vec4 sampled = texture(sampler2D(particle_sprite, particle_spritesmp), uv);
if (sampled.a < 0.01) discard;
color = sampled * color_in;
}
@end
@program particle vs_particle fs_particle