Successfully rendering and running in web, but gfx bug in debug drawing with font image everywhere

main
parent f2a8a1dcef
commit 9d498b0aad

@ -2737,13 +2737,13 @@ void create_screenspace_gfx_state()
.label = "outline-pass", .label = "outline-pass",
}); });
desc.sample_count = 0; desc.sample_count = 1;
desc.label = "threedee-pass-render-target"; desc.label = "threedee-pass-render-target";
state.threedee_pass_image = sg_make_image(&desc); state.threedee_pass_image = sg_make_image(&desc);
desc.label = "threedee-pass-depth-render-target"; desc.label = "threedee-pass-depth-render-target";
desc.pixel_format = SG_PIXELFORMAT_DEPTH_STENCIL; desc.pixel_format = SG_PIXELFORMAT_DEPTH;
state.threedee_pass_depth_image = sg_make_image(&desc); state.threedee_pass_depth_image = sg_make_image(&desc);
state.threedee_pass = sg_make_pass(&(sg_pass_desc){ state.threedee_pass = sg_make_pass(&(sg_pass_desc){
@ -3300,21 +3300,19 @@ void init(void)
assert(desc); assert(desc);
shd = sg_make_shader(desc); shd = sg_make_shader(desc);
state.threedee_pip = sg_make_pipeline(&(sg_pipeline_desc) state.threedee_pip = sg_make_pipeline(&(sg_pipeline_desc){
{
.shader = shd, .shader = shd,
.depth = { .layout = {.attrs = {
.compare = SG_COMPAREFUNC_LESS_EQUAL,
.write_enabled = true
},
.layout = {
.attrs =
{
[ATTR_threedee_vs_pos_in].format = SG_VERTEXFORMAT_FLOAT3, [ATTR_threedee_vs_pos_in].format = SG_VERTEXFORMAT_FLOAT3,
[ATTR_threedee_vs_uv_in].format = SG_VERTEXFORMAT_FLOAT2, [ATTR_threedee_vs_uv_in].format = SG_VERTEXFORMAT_FLOAT2,
} }},
.depth = {
.pixel_format = SG_PIXELFORMAT_DEPTH,
.compare = SG_COMPAREFUNC_LESS_EQUAL,
.write_enabled = true,
}, },
.colors[0].blend = (sg_blend_state) { // allow transparency .colors[0].blend = (sg_blend_state){
// allow transparency
.enabled = true, .enabled = true,
.src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA, .src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA,
.dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, .dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
@ -3334,6 +3332,7 @@ void init(void)
{ {
.shader = shd, .shader = shd,
.depth = { .depth = {
.pixel_format = SG_PIXELFORMAT_DEPTH,
.compare = SG_COMPAREFUNC_LESS_EQUAL, .compare = SG_COMPAREFUNC_LESS_EQUAL,
.write_enabled = true .write_enabled = true
}, },
@ -7346,7 +7345,7 @@ sapp_desc sokol_main(int argc, char* argv[])
.frame_cb = frame, .frame_cb = frame,
.cleanup_cb = cleanup, .cleanup_cb = cleanup,
.event_cb = event, .event_cb = event,
.sample_count = 4, .sample_count = 1, // bumping this back to 4 is troublesome for web, because there's a mismatch in sample counts. Perhaps we must upgrade to gles3, in doing so, we should upgrade to the newest sokol gfx.
.width = 800, .width = 800,
.height = 600, .height = 600,
//.gl_force_gles2 = true, not sure why this was here in example, look into //.gl_force_gles2 = true, not sure why this was here in example, look into

@ -508,6 +508,7 @@ func main() {
logResponses = os.Getenv("LOG_RESPONSES") != "" logResponses = os.Getenv("LOG_RESPONSES") != ""
doCors = os.Getenv("CORS") != "" doCors = os.Getenv("CORS") != ""
if doCors { log.Println("Doing cors"); }
c = openai.NewClient(api_key) c = openai.NewClient(api_key)
http.HandleFunc("/completion", completion) http.HandleFunc("/completion", completion)

@ -5,6 +5,50 @@
@ctype vec3 Vec3 @ctype vec3 Vec3
@ctype vec2 Vec2 @ctype vec2 Vec2
@block inverse_functions
// Webgl 1 doesn't have inverse() but we need it, pulled from https://github.com/glslify/glsl-inverse/blob/master/index.glsl
mat4 my_inverse(mat4 m) {
float
a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],
a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],
a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],
a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],
b00 = a00 * a11 - a01 * a10,
b01 = a00 * a12 - a02 * a10,
b02 = a00 * a13 - a03 * a10,
b03 = a01 * a12 - a02 * a11,
b04 = a01 * a13 - a03 * a11,
b05 = a02 * a13 - a03 * a12,
b06 = a20 * a31 - a21 * a30,
b07 = a20 * a32 - a22 * a30,
b08 = a20 * a33 - a23 * a30,
b09 = a21 * a32 - a22 * a31,
b10 = a21 * a33 - a23 * a31,
b11 = a22 * a33 - a23 * a32,
det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
return mat4(
a11 * b11 - a12 * b10 + a13 * b09,
a02 * b10 - a01 * b11 - a03 * b09,
a31 * b05 - a32 * b04 + a33 * b03,
a22 * b04 - a21 * b05 - a23 * b03,
a12 * b08 - a10 * b11 - a13 * b07,
a00 * b11 - a02 * b08 + a03 * b07,
a32 * b02 - a30 * b05 - a33 * b01,
a20 * b05 - a22 * b02 + a23 * b01,
a10 * b10 - a11 * b08 + a13 * b06,
a01 * b08 - a00 * b10 - a03 * b06,
a30 * b04 - a31 * b02 + a33 * b00,
a21 * b02 - a20 * b04 - a23 * b00,
a11 * b07 - a10 * b09 - a12 * b06,
a00 * b09 - a01 * b07 + a02 * b06,
a31 * b01 - a30 * b03 - a32 * b00,
a20 * b03 - a21 * b01 + a22 * b00) / det;
}
@end
// for this block, define a variable called `model_space_pos` to be used as an input // for this block, define a variable called `model_space_pos` to be used as an input
@block vs_compute_light_output @block vs_compute_light_output
@ -12,7 +56,7 @@
vec4 frag_pos = view * world_space_frag_pos; vec4 frag_pos = view * world_space_frag_pos;
//@Speed I think we can just take the third row here and be fine. //@Speed I think we can just take the third row here and be fine.
light_dir = normalize(inverse(directional_light_space_matrix) * vec4(0.0, 0.0, -1.0, 0.0)).xyz; light_dir = normalize(my_inverse(directional_light_space_matrix) * vec4(0.0, 0.0, -1.0, 0.0)).xyz;
light_space_fragment_position = directional_light_space_matrix * vec4(world_space_frag_pos.xyz, 1.0); light_space_fragment_position = directional_light_space_matrix * vec4(world_space_frag_pos.xyz, 1.0);
@ -47,6 +91,8 @@ float decode_normalized_float32(vec4 v)
return sign * (v.z*255.0 + v.y); return sign * (v.z*255.0 + v.y);
} }
@include_block inverse_functions
void main() { void main() {
vec4 total_position = vec4(0.0f); vec4 total_position = vec4(0.0f);
@ -104,6 +150,8 @@ uniform vs_params {
vec3 wobble_world_source; vec3 wobble_world_source;
}; };
@include_block inverse_functions
void main() { void main() {
//vec3 transformed_pos = vec3(pos_in.x, pos_in.y + sin(pos_in.x * 5.0 + pos_in.y * 9.0 + time*1.9)*0.045, pos_in.z); //vec3 transformed_pos = vec3(pos_in.x, pos_in.y + sin(pos_in.x * 5.0 + pos_in.y * 9.0 + time*1.9)*0.045, pos_in.z);

@ -23,8 +23,8 @@
#define BUBBLE_LINES_PER_PAGE 2 #define BUBBLE_LINES_PER_PAGE 2
#define AI_MAX_BUBBLE_PAGES_IN_OUTPUT 2 #define AI_MAX_BUBBLE_PAGES_IN_OUTPUT 2
#define ARENA_SIZE (1024*1024*10) #define ARENA_SIZE (1024*1024*20)
#define BIG_ARENA_SIZE (ARENA_SIZE * 8) #define BIG_ARENA_SIZE (ARENA_SIZE * 4)
#ifdef DEVTOOLS #ifdef DEVTOOLS
// server url cannot have trailing slash // server url cannot have trailing slash

Loading…
Cancel
Save