Vulkan fixes

This commit is contained in:
luboslenco
2025-06-08 21:44:05 +02:00
parent 73fca805d2
commit f519a78359
15 changed files with 53 additions and 28 deletions
+1
View File
@@ -135,6 +135,7 @@ declare function i32_to_string_hex(i: i32): string;
declare function i64_to_string(i: i64): string;
declare function u64_to_string(i: u64): string;
declare function f32_to_string(f: f32): string;
declare function f32_to_string_with_zeros(f: f32): string;
declare function json_parse(s: string): any;
declare function json_parse_to_map(s: string): map_t<string, string>;
+3 -1
View File
@@ -60,7 +60,9 @@ function shader_data_get_context(raw: shader_data_t, name: string): shader_conte
}
function shader_context_create(raw: shader_context_t): shader_context_t {
raw._ = {};
if (raw._ == null) {
raw._ = {};
}
shader_context_parse_vertex_struct(raw);
return shader_context_compile(raw);
}
+4
View File
@@ -238,5 +238,9 @@ function node_shader_get(raw: node_shader_t): string {
s += "\tfragment = kong_frag;\n";
s += "}\n";
////
iron_log(s);
////
return s;
}
+3
View File
@@ -44,6 +44,9 @@ function node_shader_context_create(material: material_t, props: shader_context_
depth_attachment: props.depth_attachment
};
let rw: shader_context_t = raw.data;
rw._ = {};
if (props.color_writes_red != null) {
raw.data.color_writes_red = props.color_writes_red;
}
+13 -8
View File
@@ -207,12 +207,12 @@ function parser_material_finalize(con: node_shader_context_t) {
if (kong.frag_wposition) {
node_shader_add_constant(kong, "W: float4x4", "_world_matrix");
node_shader_add_out(kong, "wposition: float3");
node_shader_write_attrib_vert(kong, "output.wposition = float4(constants.W * float4(input.pos.xyz, 1.0)).xyz;");
node_shader_write_attrib_vert(kong, "output.wposition = (constants.W * float4(input.pos.xyz, 1.0)).xyz;");
}
if (kong.frag_vposition) {
node_shader_add_constant(kong, "WV: float4x4", "_world_view_matrix");
node_shader_add_out(kong, "vposition: float3");
node_shader_write_attrib_vert(kong, "output.vposition = float4(constants.WV * float4(input.pos.xyz, 1.0)).xyz;");
node_shader_write_attrib_vert(kong, "output.vposition = (constants.WV * float4(input.pos.xyz, 1.0)).xyz;");
}
if (kong.frag_mposition) {
node_shader_add_out(kong, "mposition: float3");
@@ -230,7 +230,7 @@ function parser_material_finalize(con: node_shader_context_t) {
if (kong.frag_vvec_cam) {
node_shader_add_constant(kong, "WV: float4x4", "_world_view_matrix");
node_shader_add_out(kong, "eye_dir_cam: float3");
node_shader_write_attrib_vert(kong, "output.eye_dir_cam = float4(constants.WV * float4(input.pos.xyz, 1.0)).xyz;");
node_shader_write_attrib_vert(kong, "output.eye_dir_cam = (constants.WV * float4(input.pos.xyz, 1.0)).xyz;");
node_shader_write_attrib_vert(kong, "output.eye_dir_cam.z *= -1.0;");
node_shader_write_attrib_frag(kong, "var vvec_cam: float3 = normalize(input.eye_dir_cam);");
}
@@ -1927,19 +1927,24 @@ function parser_material_texture_store(node: ui_node_t, tex: bind_tex_t, tex_nam
}
function parser_material_vec1(v: f32): string {
return "float(" + v + ")";
return f32_to_string_with_zeros(v);
// return "float(" + v + ")";
// return v + "";
}
function parser_material_vec3(v: f32_array_t): string {
let v0: f32 = v[0];
let v1: f32 = v[1];
let v2: f32 = v[2];
// let v0: f32 = v[0];
// let v1: f32 = v[1];
// let v2: f32 = v[2];
let v0: string = f32_to_string_with_zeros(v[0]);
let v1: string = f32_to_string_with_zeros(v[1]);
let v2: string = f32_to_string_with_zeros(v[2]);
return "float3(" + v0 + ", " + v1 + ", " + v2 + ")";
}
function parser_material_to_vec3(s: string): string {
return "float3(" + s + ")";
// return "float3(" + s + ")";
return "float3(" + s + ", " + s + ", " + s + ")";
}
function parser_material_node_by_type(nodes: ui_node_t[], ntype: string): ui_node_t {