169 lines
7.4 KiB
C
169 lines
7.4 KiB
C
|
|
#pragma once
|
||
|
|
/*
|
||
|
|
#version:1# (machine generated, don't edit!)
|
||
|
|
|
||
|
|
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||
|
|
|
||
|
|
Cmdline:
|
||
|
|
sokol-shdc -i ./projects/examples/samples/shapes-sapp.glsl -o F:\dev\luajit\repos\sokol-luajit\bin\shaderbin\shader_gen_shapes.h -l glsl410 -f sokol
|
||
|
|
|
||
|
|
Overview:
|
||
|
|
=========
|
||
|
|
Shader program: 'shapes':
|
||
|
|
Get shader desc: shapes_shader_desc(sg_query_backend());
|
||
|
|
Vertex Shader: vs_shapes
|
||
|
|
Fragment Shader: fs_shapes
|
||
|
|
Attributes:
|
||
|
|
ATTR_shapes_position => 0
|
||
|
|
ATTR_shapes_normal => 1
|
||
|
|
ATTR_shapes_texcoord => 2
|
||
|
|
ATTR_shapes_color0 => 3
|
||
|
|
Bindings:
|
||
|
|
Uniform block 'vs_params':
|
||
|
|
C struct: vs_params_t
|
||
|
|
Bind slot: UB_vs_params => 0
|
||
|
|
*/
|
||
|
|
#if !defined(SOKOL_GFX_INCLUDED)
|
||
|
|
#error "Please include sokol_gfx.h before shader_gen_shapes.h"
|
||
|
|
#endif
|
||
|
|
#if !defined(SOKOL_SHDC_ALIGN)
|
||
|
|
#if defined(_MSC_VER)
|
||
|
|
#define SOKOL_SHDC_ALIGN(a) __declspec(align(a))
|
||
|
|
#else
|
||
|
|
#define SOKOL_SHDC_ALIGN(a) __attribute__((aligned(a)))
|
||
|
|
#endif
|
||
|
|
#endif
|
||
|
|
#define ATTR_shapes_position (0)
|
||
|
|
#define ATTR_shapes_normal (1)
|
||
|
|
#define ATTR_shapes_texcoord (2)
|
||
|
|
#define ATTR_shapes_color0 (3)
|
||
|
|
#define UB_vs_params (0)
|
||
|
|
#pragma pack(push,1)
|
||
|
|
SOKOL_SHDC_ALIGN(16) typedef struct vs_params_t {
|
||
|
|
hmm_mat4 mvp;
|
||
|
|
float draw_mode;
|
||
|
|
uint8_t _pad_68[12];
|
||
|
|
} vs_params_t;
|
||
|
|
#pragma pack(pop)
|
||
|
|
/*
|
||
|
|
#version 410
|
||
|
|
|
||
|
|
uniform vec4 vs_params[5];
|
||
|
|
layout(location = 0) in vec4 position;
|
||
|
|
layout(location = 0) out vec4 color;
|
||
|
|
layout(location = 1) in vec3 normal;
|
||
|
|
layout(location = 2) in vec2 texcoord;
|
||
|
|
layout(location = 3) in vec4 color0;
|
||
|
|
|
||
|
|
void main()
|
||
|
|
{
|
||
|
|
gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * position;
|
||
|
|
if (vs_params[4].x == 0.0)
|
||
|
|
{
|
||
|
|
color = vec4((normal + vec3(1.0)) * 0.5, 1.0);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
if (vs_params[4].x == 1.0)
|
||
|
|
{
|
||
|
|
color = vec4(texcoord, 0.0, 1.0);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
color = color0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
*/
|
||
|
|
static const uint8_t vs_shapes_source_glsl410[621] = {
|
||
|
|
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x31,0x30,0x0a,0x0a,0x75,0x6e,
|
||
|
|
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,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,0x30,0x29,0x20,0x69,0x6e,
|
||
|
|
0x20,0x76,0x65,0x63,0x34,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,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,
|
||
|
|
0x33,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,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,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,0x33,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,
|
||
|
|
0x6c,0x6f,0x72,0x30,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,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,
|
||
|
|
0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,
|
||
|
|
0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||
|
|
0x73,0x5b,0x32,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,
|
||
|
|
0x33,0x5d,0x29,0x20,0x2a,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,
|
||
|
|
0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||
|
|
0x73,0x5b,0x34,0x5d,0x2e,0x78,0x20,0x3d,0x3d,0x20,0x30,0x2e,0x30,0x29,0x0a,0x20,
|
||
|
|
0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,
|
||
|
|
0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x6e,0x6f,0x72,0x6d,0x61,
|
||
|
|
0x6c,0x20,0x2b,0x20,0x76,0x65,0x63,0x33,0x28,0x31,0x2e,0x30,0x29,0x29,0x20,0x2a,
|
||
|
|
0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||
|
|
0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,
|
||
|
|
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x76,0x73,0x5f,
|
||
|
|
0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2e,0x78,0x20,0x3d,0x3d,0x20,0x31,
|
||
|
|
0x2e,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
|
||
|
|
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,
|
||
|
|
0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x2c,
|
||
|
|
0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||
|
|
0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x65,0x6c,
|
||
|
|
0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,
|
||
|
|
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,
|
||
|
|
0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||
|
|
0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a,0x00,
|
||
|
|
};
|
||
|
|
/*
|
||
|
|
#version 410
|
||
|
|
|
||
|
|
layout(location = 0) out vec4 frag_color;
|
||
|
|
layout(location = 0) in vec4 color;
|
||
|
|
|
||
|
|
void main()
|
||
|
|
{
|
||
|
|
frag_color = color;
|
||
|
|
}
|
||
|
|
|
||
|
|
*/
|
||
|
|
static const uint8_t fs_shapes_source_glsl410[135] = {
|
||
|
|
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x31,0x30,0x0a,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,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,0x34,0x20,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,0x66,
|
||
|
|
0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,
|
||
|
|
0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||
|
|
};
|
||
|
|
static inline const sg_shader_desc* shapes_shader_desc(sg_backend backend) {
|
||
|
|
if (backend == SG_BACKEND_GLCORE) {
|
||
|
|
static sg_shader_desc desc;
|
||
|
|
static bool valid;
|
||
|
|
if (!valid) {
|
||
|
|
valid = true;
|
||
|
|
desc.vertex_func.source = (const char*)vs_shapes_source_glsl410;
|
||
|
|
desc.vertex_func.entry = "main";
|
||
|
|
desc.fragment_func.source = (const char*)fs_shapes_source_glsl410;
|
||
|
|
desc.fragment_func.entry = "main";
|
||
|
|
desc.attrs[0].glsl_name = "position";
|
||
|
|
desc.attrs[1].glsl_name = "normal";
|
||
|
|
desc.attrs[2].glsl_name = "texcoord";
|
||
|
|
desc.attrs[3].glsl_name = "color0";
|
||
|
|
desc.uniform_blocks[0].stage = SG_SHADERSTAGE_VERTEX;
|
||
|
|
desc.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
|
||
|
|
desc.uniform_blocks[0].size = 80;
|
||
|
|
desc.uniform_blocks[0].glsl_uniforms[0].type = SG_UNIFORMTYPE_FLOAT4;
|
||
|
|
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 5;
|
||
|
|
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "vs_params";
|
||
|
|
desc.label = "shapes_shader";
|
||
|
|
}
|
||
|
|
return &desc;
|
||
|
|
}
|
||
|
|
return 0;
|
||
|
|
}
|