debug web build
This commit is contained in:
parent
613c87dd1b
commit
f089e2905f
8
build.sh
Executable file
8
build.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd src/shaders/
|
||||
./compile_shaders.sh
|
||||
cd ..
|
||||
cd ..
|
||||
/home/katajisto/bin/jai/bin/jai-linux -x64 first.jai
|
||||
/home/katajisto/bin/jai/bin/jai-linux first.jai - wasm
|
||||
21
first.jai
21
first.jai
@ -1,14 +1,15 @@
|
||||
#run {
|
||||
{
|
||||
process_result, output, error := run_command("bash", "./compile_shaders.sh", working_directory=tprint("%/src/shaders", #filepath));
|
||||
if process_result.exit_code != 0 {
|
||||
log_error("Shader compilation failed.");
|
||||
if output {
|
||||
log_error(output,, logger = runtime_support_default_logger);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
// @ToDo: Fix this so that we are using the freshly compiled Jai files instead of the old ones.
|
||||
// {
|
||||
// process_result, output, error := run_command("bash", "./compile_shaders.sh", working_directory=tprint("%/src/shaders", #filepath));
|
||||
// if process_result.exit_code != 0 {
|
||||
// log_error("Shader compilation failed.");
|
||||
// if output {
|
||||
// log_error(output,, logger = runtime_support_default_logger);
|
||||
// }
|
||||
// exit(1);
|
||||
// }
|
||||
// }
|
||||
opt := get_build_options();
|
||||
args := opt.compile_time_command_line;
|
||||
doWasmBuild := false;
|
||||
|
||||
30
src/main.jai
30
src/main.jai
@ -82,16 +82,19 @@ init_after_mandatory_loads :: () {
|
||||
cam : Camera;
|
||||
|
||||
frame :: () {
|
||||
|
||||
print("FLAG1\n");
|
||||
delta_time = get_time() - last_frame_time;
|
||||
last_frame_time = get_time();
|
||||
|
||||
sfetch_dowork();
|
||||
|
||||
print("FLAG2\n");
|
||||
if mandatory_loads_done() && !init_after_mandatory_done {
|
||||
print("FLAG3\n");
|
||||
init_after_mandatory_loads();
|
||||
init_after_mandatory_done = true;
|
||||
}
|
||||
print("FLAG4\n");
|
||||
|
||||
if !mandatory_loads_done() then return;
|
||||
fonsClearState(state.fons);
|
||||
@ -113,17 +116,20 @@ frame :: () {
|
||||
vs_params : Vs_Params;
|
||||
vs_params.mvp = mvp.floats;
|
||||
|
||||
test : [2]Trixel_Instance;
|
||||
test[0].pos[0] = 0.0;
|
||||
test[0].pos[1] = 0.0;
|
||||
test[0].pos[2] = 0.0;
|
||||
test[0].pos[3] = 1.0;
|
||||
test[1].pos[0] = 1.0;
|
||||
test[1].pos[1] = 0.0;
|
||||
test[1].pos[2] = 0.0;
|
||||
test[1].pos[3] = 1.0;
|
||||
test : [4096]Vector4;
|
||||
|
||||
sg_update_buffer(gPipelines.trixel.bind.storage_buffers[0], *(sg_range.{
|
||||
for x: 0..15 {
|
||||
for y: 0..15 {
|
||||
for z: 0..15 {
|
||||
test[x * 16 * 16 + y * 16 + z].x = x * (1.0 / 16.0);
|
||||
test[x * 16 * 16 + y * 16 + z].y = y * (1.0 / 16.0);
|
||||
test[x * 16 * 16 + y * 16 + z].z = z * (1.0 / 16.0);
|
||||
test[x * 16 * 16 + y * 16 + z].w = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sg_update_buffer(gPipelines.trixel.bind.vertex_buffers[1], *(sg_range.{
|
||||
ptr = test.data,
|
||||
size = size_of(type_of(test)),
|
||||
}));
|
||||
@ -132,7 +138,7 @@ frame :: () {
|
||||
sg_apply_pipeline(gPipelines.trixel.pipeline);
|
||||
sg_apply_bindings(*gPipelines.trixel.bind);
|
||||
sg_apply_uniforms(UB_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) }));
|
||||
sg_draw(0, 36, 2);
|
||||
sg_draw(0, 36, 4096);
|
||||
sg_end_pass();
|
||||
|
||||
ui_pass();
|
||||
|
||||
@ -23,7 +23,7 @@ create_pipelines :: () {
|
||||
create_trixel_pipeline();
|
||||
}
|
||||
|
||||
TRIXEL_SIZE_HALF : float : 1.0/2.0;
|
||||
TRIXEL_SIZE_HALF : float : 1.0/32.0;
|
||||
|
||||
gArbtriMem : [100000*3*9]float;
|
||||
|
||||
@ -32,8 +32,10 @@ create_trixel_pipeline :: () {
|
||||
shader_desc := trixel_shader_desc(sg_query_backend());
|
||||
pipeline.shader = sg_make_shader(*shader_desc);
|
||||
pipeline.layout.buffers[0].stride = 4*3;
|
||||
// pipeline.layout.buffers[1].step_func = .PER_INSTANCE;
|
||||
|
||||
pipeline.layout.attrs[ATTR_trixel_position] = .{ format = .FLOAT3 };
|
||||
pipeline.layout.attrs[ATTR_trixel_position] = .{ format = .FLOAT3, buffer_index = 0 };
|
||||
// pipeline.layout.attrs[ATTR_trixel_inst] = .{ format = .FLOAT4, buffer_index = 1 };
|
||||
pipeline.index_type = .UINT16;
|
||||
|
||||
color_state := sg_color_target_state.{
|
||||
@ -92,11 +94,11 @@ create_trixel_pipeline :: () {
|
||||
|
||||
ibuffer := sg_buffer_desc.{ type = .INDEXBUFFER, data = .{ ptr = indices.data, size = 36 * 2 } };
|
||||
vbuffer := sg_buffer_desc.{ data = .{ ptr = verts.data, size = 24 * 3 * 4 } };
|
||||
instance_buffer := sg_buffer_desc.{ type = .STORAGEBUFFER, size = 4096 * size_of(Vector4)};
|
||||
// instance_buffer := sg_buffer_desc.{ usage = .STREAM, size = 4096 * size_of(Vector4)};
|
||||
|
||||
gPipelines.trixel.bind.index_buffer = sg_make_buffer(*ibuffer);
|
||||
gPipelines.trixel.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer);
|
||||
gPipelines.trixel.bind.storage_buffers[0] = sg_make_buffer(*instance_buffer);
|
||||
gPipelines.trixel.bind.index_buffer = sg_make_buffer(*ibuffer);
|
||||
gPipelines.trixel.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer);
|
||||
// gPipelines.trixel.bind.vertex_buffers[1] = sg_make_buffer(*instance_buffer);
|
||||
}
|
||||
|
||||
create_arbtri_pipeline :: () {
|
||||
|
||||
@ -18,75 +18,44 @@
|
||||
Uniform block 'vs_params':
|
||||
Jai struct: Vs_Params
|
||||
Bind slot: UB_vs_params => 0
|
||||
Storage buffer 'instances':
|
||||
Jai struct: Trixel_Instance
|
||||
Bind slot: SBUF_instances => 0
|
||||
Readonly: true
|
||||
*/
|
||||
ATTR_trixel_position :: 0;
|
||||
UB_vs_params :: 0;
|
||||
SBUF_instances :: 0;
|
||||
Vs_Params :: struct {
|
||||
mvp: [16]float;
|
||||
};
|
||||
Trixel_Instance :: struct {
|
||||
pos: [4]float;
|
||||
}
|
||||
/*
|
||||
#version 430
|
||||
|
||||
struct trixel_instance
|
||||
{
|
||||
vec4 pos;
|
||||
};
|
||||
|
||||
layout(binding = 0, std430) readonly buffer instances
|
||||
{
|
||||
trixel_instance inst[];
|
||||
} _15;
|
||||
|
||||
uniform vec4 vs_params[4];
|
||||
layout(location = 0) in vec4 position;
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * vec4(position.xyz + _15.inst[gl_InstanceID].pos.xyz, 1.0);
|
||||
color = vec4(_15.inst[gl_InstanceID].pos.xyz, 1.0);
|
||||
gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * position;
|
||||
color = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
vs_trixel_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74,
|
||||
0x72,0x75,0x63,0x74,0x20,0x74,0x72,0x69,0x78,0x65,0x6c,0x5f,0x69,0x6e,0x73,0x74,
|
||||
0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,
|
||||
0x70,0x6f,0x73,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
|
||||
0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x30,0x2c,0x20,0x73,0x74,0x64,
|
||||
0x34,0x33,0x30,0x29,0x20,0x72,0x65,0x61,0x64,0x6f,0x6e,0x6c,0x79,0x20,0x62,0x75,
|
||||
0x66,0x66,0x65,0x72,0x20,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x73,0x0a,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x74,0x72,0x69,0x78,0x65,0x6c,0x5f,0x69,0x6e,0x73,0x74,
|
||||
0x61,0x6e,0x63,0x65,0x20,0x69,0x6e,0x73,0x74,0x5b,0x5d,0x3b,0x0a,0x7d,0x20,0x5f,
|
||||
0x31,0x35,0x3b,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,0x34,0x5d,0x3b,0x0a,
|
||||
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,0x76,0x73,0x5f,0x70,0x61,
|
||||
0x72,0x61,0x6d,0x73,0x5b,0x34,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,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,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,0x76,0x65,0x63,0x34,
|
||||
0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,
|
||||
0x5f,0x31,0x35,0x2e,0x69,0x6e,0x73,0x74,0x5b,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,
|
||||
0x61,0x6e,0x63,0x65,0x49,0x44,0x5d,0x2e,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x2c,
|
||||
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,
|
||||
0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x31,0x35,0x2e,0x69,0x6e,0x73,0x74,
|
||||
0x5b,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x5d,0x2e,
|
||||
0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,
|
||||
0x0a,0x0a,0x00,
|
||||
0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,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,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,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,
|
||||
0x31,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,
|
||||
0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 430
|
||||
@ -114,56 +83,34 @@ fs_trixel_source_glsl430 := u8.[
|
||||
/*
|
||||
#version 300 es
|
||||
|
||||
struct trixel_instance
|
||||
{
|
||||
vec4 pos;
|
||||
};
|
||||
|
||||
layout(std430) readonly buffer instances
|
||||
{
|
||||
trixel_instance inst[];
|
||||
} _15;
|
||||
|
||||
uniform vec4 vs_params[4];
|
||||
layout(location = 0) in vec4 position;
|
||||
out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * vec4(position.xyz + _15.inst[gl_InstanceID].pos.xyz, 1.0);
|
||||
color = vec4(_15.inst[gl_InstanceID].pos.xyz, 1.0);
|
||||
gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * position;
|
||||
color = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
*/
|
||||
vs_trixel_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x74,0x72,0x69,0x78,0x65,0x6c,0x5f,0x69,
|
||||
0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,
|
||||
0x63,0x34,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,
|
||||
0x75,0x74,0x28,0x73,0x74,0x64,0x34,0x33,0x30,0x29,0x20,0x72,0x65,0x61,0x64,0x6f,
|
||||
0x6e,0x6c,0x79,0x20,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x69,0x6e,0x73,0x74,0x61,
|
||||
0x6e,0x63,0x65,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x74,0x72,0x69,0x78,0x65,
|
||||
0x6c,0x5f,0x69,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x20,0x69,0x6e,0x73,0x74,0x5b,
|
||||
0x5d,0x3b,0x0a,0x7d,0x20,0x5f,0x31,0x35,0x3b,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,0x34,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,0x6f,0x75,0x74,
|
||||
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,
|
||||
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,0x76,0x65,0x63,
|
||||
0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x79,0x7a,0x20,0x2b,
|
||||
0x20,0x5f,0x31,0x35,0x2e,0x69,0x6e,0x73,0x74,0x5b,0x67,0x6c,0x5f,0x49,0x6e,0x73,
|
||||
0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x5d,0x2e,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,
|
||||
0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x31,0x35,0x2e,0x69,0x6e,0x73,
|
||||
0x74,0x5b,0x67,0x6c,0x5f,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x49,0x44,0x5d,
|
||||
0x2e,0x70,0x6f,0x73,0x2e,0x78,0x79,0x7a,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,
|
||||
0x7d,0x0a,0x0a,0x00,
|
||||
0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,
|
||||
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,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,0x6f,0x75,0x74,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,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,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x31,0x2e,
|
||||
0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,
|
||||
0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
@ -209,9 +156,6 @@ trixel_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "vs_params";
|
||||
desc.storage_buffers[0].stage = .VERTEX;
|
||||
desc.storage_buffers[0].readonly = true;
|
||||
desc.storage_buffers[0].glsl_binding_n = 0;
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_trixel_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
@ -225,9 +169,6 @@ trixel_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "vs_params";
|
||||
desc.storage_buffers[0].stage = .VERTEX;
|
||||
desc.storage_buffers[0].readonly = true;
|
||||
desc.storage_buffers[0].glsl_binding_n = 0;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
@ -1,26 +1,19 @@
|
||||
@vs vs_trixel
|
||||
|
||||
in vec4 position;
|
||||
// in vec4 inst;
|
||||
|
||||
layout(binding=0) uniform vs_params {
|
||||
mat4 mvp;
|
||||
};
|
||||
|
||||
struct trixel_instance {
|
||||
vec4 pos;
|
||||
};
|
||||
|
||||
layout(binding=0) readonly buffer instances {
|
||||
trixel_instance inst[];
|
||||
};
|
||||
|
||||
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
vec3 instancepos = inst[gl_InstanceIndex].pos.xyz;
|
||||
gl_Position = mvp * (vec4(position.xyz + instancepos, 1.0));
|
||||
color = vec4(instancepos, 1.0);
|
||||
// vec3 instancepos = inst.xyz;
|
||||
// gl_Position = mvp * (vec4(position.xyz + instancepos, 1.0));
|
||||
gl_Position = mvp * position;
|
||||
color = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user