|
|
|
|
@ -1,420 +0,0 @@
|
|
|
|
|
/*
|
|
|
|
|
#version:1# (machine generated, don't edit!)
|
|
|
|
|
|
|
|
|
|
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
|
|
|
|
|
|
|
|
|
Cmdline:
|
|
|
|
|
sokol-shdc -i shader_op.glsl -o ./jai/shader_op.jai -l glsl430:glsl300es:metal_macos -f sokol_jai
|
|
|
|
|
|
|
|
|
|
Overview:
|
|
|
|
|
=========
|
|
|
|
|
Shader program: 'op':
|
|
|
|
|
Get shader desc: op_shader_desc(sg_query_backend())
|
|
|
|
|
Vertex Shader: vs_op
|
|
|
|
|
Fragment Shader: fs_op
|
|
|
|
|
Attributes:
|
|
|
|
|
ATTR_op_position => 0
|
|
|
|
|
ATTR_op_uv => 1
|
|
|
|
|
Bindings:
|
|
|
|
|
Image 'optex':
|
|
|
|
|
Image type: ._2D
|
|
|
|
|
Sample type: .FLOAT
|
|
|
|
|
Multisampled: false
|
|
|
|
|
Bind slot: IMG_optex => 0
|
|
|
|
|
Sampler 'opsmp':
|
|
|
|
|
Type: .FILTERING
|
|
|
|
|
Bind slot: SMP_opsmp => 0
|
|
|
|
|
*/
|
|
|
|
|
ATTR_op_position :: 0;
|
|
|
|
|
ATTR_op_uv :: 1;
|
|
|
|
|
IMG_optex :: 0;
|
|
|
|
|
SMP_opsmp :: 0;
|
|
|
|
|
/*
|
|
|
|
|
#version 430
|
|
|
|
|
|
|
|
|
|
layout(location = 0) in vec2 position;
|
|
|
|
|
layout(location = 0) out vec2 texcoord;
|
|
|
|
|
layout(location = 1) in vec2 uv;
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
|
|
|
|
gl_Position = vec4(position, 0.5, 1.0);
|
|
|
|
|
texcoord = uv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
vs_op_source_glsl430 := u8.[
|
|
|
|
|
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,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,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,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,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,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,
|
|
|
|
|
0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
|
|
|
|
0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,
|
|
|
|
|
0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,
|
|
|
|
|
0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,
|
|
|
|
|
0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
|
|
|
|
|
|
|
|
|
];
|
|
|
|
|
/*
|
|
|
|
|
#version 430
|
|
|
|
|
|
|
|
|
|
layout(binding = 16) uniform sampler2D optex_opsmp;
|
|
|
|
|
|
|
|
|
|
layout(location = 0) in vec2 texcoord;
|
|
|
|
|
layout(location = 0) out vec4 frag_color;
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
|
|
|
|
vec2 _28 = vec2(1.0) / vec2(textureSize(optex_opsmp, 0));
|
|
|
|
|
float result = 0.0;
|
|
|
|
|
for (int x = -3; x < 3; x++)
|
|
|
|
|
{
|
|
|
|
|
for (int y = -3; y < 3; y++)
|
|
|
|
|
{
|
|
|
|
|
result += texture(optex_opsmp, texcoord + (vec2(float(x), float(y)) * _28)).x;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
float _84 = result * 0.02777777798473834991455078125;
|
|
|
|
|
frag_color = vec4(_84, _84, _84, 1.0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
fs_op_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,0x6f,0x70,0x74,0x65,0x78,0x5f,0x6f,0x70,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,
|
|
|
|
|
0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,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,0x66,0x72,0x61,0x67,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,0x32,0x20,0x5f,0x32,0x38,0x20,
|
|
|
|
|
0x3d,0x20,0x76,0x65,0x63,0x32,0x28,0x31,0x2e,0x30,0x29,0x20,0x2f,0x20,0x76,0x65,
|
|
|
|
|
0x63,0x32,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x53,0x69,0x7a,0x65,0x28,0x6f,
|
|
|
|
|
0x70,0x74,0x65,0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x30,0x29,0x29,0x3b,
|
|
|
|
|
0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x72,0x65,0x73,0x75,0x6c,
|
|
|
|
|
0x74,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,
|
|
|
|
|
0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x20,0x3d,0x20,0x2d,0x33,0x3b,0x20,0x78,0x20,
|
|
|
|
|
0x3c,0x20,0x33,0x3b,0x20,0x78,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
|
|
|
|
|
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,
|
|
|
|
|
0x20,0x79,0x20,0x3d,0x20,0x2d,0x33,0x3b,0x20,0x79,0x20,0x3c,0x20,0x33,0x3b,0x20,
|
|
|
|
|
0x79,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,
|
|
|
|
|
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x72,0x65,0x73,0x75,0x6c,
|
|
|
|
|
0x74,0x20,0x2b,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x6f,0x70,0x74,
|
|
|
|
|
0x65,0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,
|
|
|
|
|
0x72,0x64,0x20,0x2b,0x20,0x28,0x76,0x65,0x63,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74,
|
|
|
|
|
0x28,0x78,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,0x79,0x29,0x29,0x20,0x2a,
|
|
|
|
|
0x20,0x5f,0x32,0x38,0x29,0x29,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
|
|
|
|
0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
|
|
|
|
|
0x6f,0x61,0x74,0x20,0x5f,0x38,0x34,0x20,0x3d,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,
|
|
|
|
|
0x20,0x2a,0x20,0x30,0x2e,0x30,0x32,0x37,0x37,0x37,0x37,0x37,0x37,0x37,0x39,0x38,
|
|
|
|
|
0x34,0x37,0x33,0x38,0x33,0x34,0x39,0x39,0x31,0x34,0x35,0x35,0x30,0x37,0x38,0x31,
|
|
|
|
|
0x32,0x35,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,
|
|
|
|
|
0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x38,0x34,0x2c,0x20,0x5f,
|
|
|
|
|
0x38,0x34,0x2c,0x20,0x5f,0x38,0x34,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,
|
|
|
|
|
0x0a,0x0a,0x00,
|
|
|
|
|
];
|
|
|
|
|
/*
|
|
|
|
|
#version 300 es
|
|
|
|
|
|
|
|
|
|
layout(location = 0) in vec2 position;
|
|
|
|
|
out vec2 texcoord;
|
|
|
|
|
layout(location = 1) in vec2 uv;
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
|
|
|
|
gl_Position = vec4(position, 0.5, 1.0);
|
|
|
|
|
texcoord = uv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
vs_op_source_glsl300es := u8.[
|
|
|
|
|
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,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,0x70,0x6f,
|
|
|
|
|
0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,
|
|
|
|
|
0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,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,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
|
|
|
|
|
0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,
|
|
|
|
|
0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,
|
|
|
|
|
0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,
|
|
|
|
|
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,0x65,0x78,0x63,0x6f,
|
|
|
|
|
0x6f,0x72,0x64,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
|
|
|
|
];
|
|
|
|
|
/*
|
|
|
|
|
#version 300 es
|
|
|
|
|
precision mediump float;
|
|
|
|
|
precision highp int;
|
|
|
|
|
|
|
|
|
|
uniform highp sampler2D optex_opsmp;
|
|
|
|
|
|
|
|
|
|
in highp vec2 texcoord;
|
|
|
|
|
layout(location = 0) out highp vec4 frag_color;
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
|
|
|
|
highp vec2 _28 = vec2(1.0) / vec2(textureSize(optex_opsmp, 0));
|
|
|
|
|
highp float result = 0.0;
|
|
|
|
|
for (int x = -3; x < 3; x++)
|
|
|
|
|
{
|
|
|
|
|
for (int y = -3; y < 3; y++)
|
|
|
|
|
{
|
|
|
|
|
result += texture(optex_opsmp, texcoord + (vec2(float(x), float(y)) * _28)).x;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
highp float _84 = result * 0.02777777798473834991455078125;
|
|
|
|
|
frag_color = vec4(_84, _84, _84, 1.0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
fs_op_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,0x6f,0x70,0x74,0x65,0x78,0x5f,0x6f,0x70,0x73,
|
|
|
|
|
0x6d,0x70,0x3b,0x0a,0x0a,0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,
|
|
|
|
|
0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,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,0x66,0x72,0x61,0x67,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,
|
|
|
|
|
0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x5f,0x32,0x38,0x20,0x3d,
|
|
|
|
|
0x20,0x76,0x65,0x63,0x32,0x28,0x31,0x2e,0x30,0x29,0x20,0x2f,0x20,0x76,0x65,0x63,
|
|
|
|
|
0x32,0x28,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x53,0x69,0x7a,0x65,0x28,0x6f,0x70,
|
|
|
|
|
0x74,0x65,0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x30,0x29,0x29,0x3b,0x0a,
|
|
|
|
|
0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,
|
|
|
|
|
0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,
|
|
|
|
|
0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x20,0x3d,0x20,0x2d,
|
|
|
|
|
0x33,0x3b,0x20,0x78,0x20,0x3c,0x20,0x33,0x3b,0x20,0x78,0x2b,0x2b,0x29,0x0a,0x20,
|
|
|
|
|
0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,
|
|
|
|
|
0x20,0x28,0x69,0x6e,0x74,0x20,0x79,0x20,0x3d,0x20,0x2d,0x33,0x3b,0x20,0x79,0x20,
|
|
|
|
|
0x3c,0x20,0x33,0x3b,0x20,0x79,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
|
|
|
|
0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
|
|
|
|
0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x2b,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,
|
|
|
|
|
0x65,0x28,0x6f,0x70,0x74,0x65,0x78,0x5f,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x74,
|
|
|
|
|
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x28,0x76,0x65,0x63,0x32,0x28,
|
|
|
|
|
0x66,0x6c,0x6f,0x61,0x74,0x28,0x78,0x29,0x2c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x28,
|
|
|
|
|
0x79,0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x38,0x29,0x29,0x2e,0x78,0x3b,0x0a,0x20,
|
|
|
|
|
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,
|
|
|
|
|
0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,
|
|
|
|
|
0x38,0x34,0x20,0x3d,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x2a,0x20,0x30,0x2e,
|
|
|
|
|
0x30,0x32,0x37,0x37,0x37,0x37,0x37,0x37,0x37,0x39,0x38,0x34,0x37,0x33,0x38,0x33,
|
|
|
|
|
0x34,0x39,0x39,0x31,0x34,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x3b,0x0a,0x20,
|
|
|
|
|
0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,
|
|
|
|
|
0x76,0x65,0x63,0x34,0x28,0x5f,0x38,0x34,0x2c,0x20,0x5f,0x38,0x34,0x2c,0x20,0x5f,
|
|
|
|
|
0x38,0x34,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
|
|
|
|
];
|
|
|
|
|
/*
|
|
|
|
|
#include <metal_stdlib>
|
|
|
|
|
#include <simd/simd.h>
|
|
|
|
|
|
|
|
|
|
using namespace metal;
|
|
|
|
|
|
|
|
|
|
struct main0_out
|
|
|
|
|
{
|
|
|
|
|
float2 texcoord [[user(locn0)]];
|
|
|
|
|
float4 gl_Position [[position]];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct main0_in
|
|
|
|
|
{
|
|
|
|
|
float2 position [[attribute(0)]];
|
|
|
|
|
float2 uv [[attribute(1)]];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
vertex main0_out main0(main0_in in [[stage_in]])
|
|
|
|
|
{
|
|
|
|
|
main0_out out = {};
|
|
|
|
|
out.gl_Position = float4(in.position, 0.5, 1.0);
|
|
|
|
|
out.texcoord = in.uv;
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
vs_op_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,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,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,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,0x32,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,0x32,0x20,0x75,0x76,0x20,0x5b,
|
|
|
|
|
0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,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,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,0x6f,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
|
|
|
|
|
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x69,0x6e,0x2e,
|
|
|
|
|
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,
|
|
|
|
|
0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x74,0x65,0x78,
|
|
|
|
|
0x63,0x6f,0x6f,0x72,0x64,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x75,0x76,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 frag_color [[color(0)]];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct main0_in
|
|
|
|
|
{
|
|
|
|
|
float2 texcoord [[user(locn0)]];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> optex [[texture(0)]], sampler opsmp [[sampler(0)]])
|
|
|
|
|
{
|
|
|
|
|
main0_out out = {};
|
|
|
|
|
float2 _28 = float2(1.0) / float2(int2(optex.get_width(), optex.get_height()));
|
|
|
|
|
float result = 0.0;
|
|
|
|
|
for (int x = -3; x < 3; x++)
|
|
|
|
|
{
|
|
|
|
|
for (int y = -3; y < 3; y++)
|
|
|
|
|
{
|
|
|
|
|
result += optex.sample(opsmp, (in.texcoord + (float2(float(x), float(y)) * _28))).x;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
float _84 = result * 0.02777777798473834991455078125;
|
|
|
|
|
out.frag_color = float4(_84, _84, _84, 1.0);
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
fs_op_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,0x66,0x72,0x61,0x67,0x5f,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,
|
|
|
|
|
0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,
|
|
|
|
|
0x6c,0x6f,0x63,0x6e,0x30,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,0x6f,0x70,0x74,0x65,0x78,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,
|
|
|
|
|
0x6f,0x70,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,0x32,0x38,0x20,0x3d,
|
|
|
|
|
0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x31,0x2e,0x30,0x29,0x20,0x2f,0x20,0x66,
|
|
|
|
|
0x6c,0x6f,0x61,0x74,0x32,0x28,0x69,0x6e,0x74,0x32,0x28,0x6f,0x70,0x74,0x65,0x78,
|
|
|
|
|
0x2e,0x67,0x65,0x74,0x5f,0x77,0x69,0x64,0x74,0x68,0x28,0x29,0x2c,0x20,0x6f,0x70,
|
|
|
|
|
0x74,0x65,0x78,0x2e,0x67,0x65,0x74,0x5f,0x68,0x65,0x69,0x67,0x68,0x74,0x28,0x29,
|
|
|
|
|
0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x72,0x65,
|
|
|
|
|
0x73,0x75,0x6c,0x74,0x20,0x3d,0x20,0x30,0x2e,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
|
|
|
|
0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x20,0x3d,0x20,0x2d,0x33,0x3b,
|
|
|
|
|
0x20,0x78,0x20,0x3c,0x20,0x33,0x3b,0x20,0x78,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,
|
|
|
|
|
0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,
|
|
|
|
|
0x69,0x6e,0x74,0x20,0x79,0x20,0x3d,0x20,0x2d,0x33,0x3b,0x20,0x79,0x20,0x3c,0x20,
|
|
|
|
|
0x33,0x3b,0x20,0x79,0x2b,0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
|
|
|
|
0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x72,0x65,
|
|
|
|
|
0x73,0x75,0x6c,0x74,0x20,0x2b,0x3d,0x20,0x6f,0x70,0x74,0x65,0x78,0x2e,0x73,0x61,
|
|
|
|
|
0x6d,0x70,0x6c,0x65,0x28,0x6f,0x70,0x73,0x6d,0x70,0x2c,0x20,0x28,0x69,0x6e,0x2e,
|
|
|
|
|
0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x20,0x2b,0x20,0x28,0x66,0x6c,0x6f,0x61,
|
|
|
|
|
0x74,0x32,0x28,0x66,0x6c,0x6f,0x61,0x74,0x28,0x78,0x29,0x2c,0x20,0x66,0x6c,0x6f,
|
|
|
|
|
0x61,0x74,0x28,0x79,0x29,0x29,0x20,0x2a,0x20,0x5f,0x32,0x38,0x29,0x29,0x29,0x2e,
|
|
|
|
|
0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,
|
|
|
|
|
0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x38,0x34,
|
|
|
|
|
0x20,0x3d,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x20,0x2a,0x20,0x30,0x2e,0x30,0x32,
|
|
|
|
|
0x37,0x37,0x37,0x37,0x37,0x37,0x37,0x39,0x38,0x34,0x37,0x33,0x38,0x33,0x34,0x39,
|
|
|
|
|
0x39,0x31,0x34,0x35,0x35,0x30,0x37,0x38,0x31,0x32,0x35,0x3b,0x0a,0x20,0x20,0x20,
|
|
|
|
|
0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,
|
|
|
|
|
0x3d,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x5f,0x38,0x34,0x2c,0x20,0x5f,0x38,
|
|
|
|
|
0x34,0x2c,0x20,0x5f,0x38,0x34,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,
|
|
|
|
|
0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,
|
|
|
|
|
0x0a,0x00,
|
|
|
|
|
];
|
|
|
|
|
op_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
|
|
|
|
desc: sg_shader_desc;
|
|
|
|
|
desc.label = "op_shader";
|
|
|
|
|
if backend == {
|
|
|
|
|
case .GLCORE;
|
|
|
|
|
desc.vertex_func.source = xx *vs_op_source_glsl430;
|
|
|
|
|
desc.vertex_func.entry = "main";
|
|
|
|
|
desc.fragment_func.source = xx *fs_op_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 = "uv";
|
|
|
|
|
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 = "optex_opsmp";
|
|
|
|
|
case .GLES3;
|
|
|
|
|
desc.vertex_func.source = xx *vs_op_source_glsl300es;
|
|
|
|
|
desc.vertex_func.entry = "main";
|
|
|
|
|
desc.fragment_func.source = xx *fs_op_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 = "uv";
|
|
|
|
|
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 = "optex_opsmp";
|
|
|
|
|
case .METAL_MACOS;
|
|
|
|
|
desc.vertex_func.source = xx *vs_op_source_metal_macos;
|
|
|
|
|
desc.vertex_func.entry = "main0";
|
|
|
|
|
desc.fragment_func.source = xx *fs_op_source_metal_macos;
|
|
|
|
|
desc.fragment_func.entry = "main0";
|
|
|
|
|
desc.attrs[0].base_type = .FLOAT;
|
|
|
|
|
desc.attrs[1].base_type = .FLOAT;
|
|
|
|
|
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;
|
|
|
|
|
}
|