Vulkan fixes
This commit is contained in:
@@ -57,7 +57,7 @@ fun layer_view_frag(input: vert_out): float4 {
|
||||
}
|
||||
// else {
|
||||
var tex_sample: float4 = sample_lod(tex, sampler_linear, input.tex, 0.0);
|
||||
tex_sample.rgb *= tex_sample.a;
|
||||
tex_sample.rgb = tex_sample.rgb * tex_sample.a;
|
||||
return tex_sample * input.col;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ function make_bake_position_normal(kong: node_shader_t) {
|
||||
node_shader_add_out(kong, "position: float3");
|
||||
node_shader_add_out(kong, "normal: float3");
|
||||
node_shader_add_constant(kong, "W: float4x4", "_world_matrix");
|
||||
node_shader_write_vert(kong, "output.position = float4(constants.W * float4(input.pos.xyz, 1.0)).xyz;");
|
||||
node_shader_write_vert(kong, "output.position = (constants.W * float4(input.pos.xyz, 1.0)).xyz;");
|
||||
node_shader_write_vert(kong, "output.normal = float3(input.nor.xy, input.pos.w);");
|
||||
node_shader_write_vert(kong, "var tpos: float2 = float2(input.tex.x * 2.0 - 1.0, (1.0 - input.tex.y) * 2.0 - 1.0);");
|
||||
node_shader_write_vert(kong, "output.pos = float4(tpos, 0.0, 1.0);");
|
||||
|
||||
@@ -19,7 +19,7 @@ function make_brush_run(kong: node_shader_t) {
|
||||
node_shader_add_constant(kong, "invVP: float4x4", "_inv_view_proj_matrix");
|
||||
node_shader_write_frag(kong, "var winp: float4 = float4(float2(constants.inp.x, 1.0 - constants.inp.y) * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);");
|
||||
node_shader_write_frag(kong, "winp = constants.invVP * winp;");
|
||||
node_shader_write_frag(kong, "winp.xyz /= winp.w;");
|
||||
node_shader_write_frag(kong, "winp.xyz = winp.xyz / winp.w;");
|
||||
kong.frag_wposition = true;
|
||||
|
||||
if (config_raw.brush_angle_reject || context_raw.xray) {
|
||||
@@ -29,7 +29,7 @@ function make_brush_run(kong: node_shader_t) {
|
||||
node_shader_write_frag(kong, "var wn: float3;");
|
||||
node_shader_write_frag(kong, "wn.z = 1.0 - abs(g0.x) - abs(g0.y);");
|
||||
// node_shader_write_frag(kong, "wn.xy = wn.z >= 0.0 ? g0.xy : octahedron_wrap(g0.xy);");
|
||||
node_shader_write_frag(kong, "if (wn.z >= 0.0) { wn.xy = g0.xy; } else { wn.xy = octahedron_wrap(g0.xy); }");
|
||||
node_shader_write_frag(kong, "if (wn.z >= 0.0) { wn.x = g0.x; wn.y = g0.y; } else { var f2: float2 = octahedron_wrap(g0.xy); wn.x = f2.x; wn.y = f2.y; }");
|
||||
node_shader_write_frag(kong, "wn = normalize(wn);");
|
||||
node_shader_write_frag(kong, "var plane_dist: float = dot(wn, winp.xyz - input.wposition);");
|
||||
|
||||
@@ -45,7 +45,7 @@ function make_brush_run(kong: node_shader_t) {
|
||||
|
||||
node_shader_write_frag(kong, "var winplast: float4 = float4(float2(constants.inplast.x, 1.0 - constants.inplast.y) * 2.0 - 1.0, depthlast * 2.0 - 1.0, 1.0);");
|
||||
node_shader_write_frag(kong, "winplast = constants.invVP * winplast;");
|
||||
node_shader_write_frag(kong, "winplast.xyz /= winplast.w;");
|
||||
node_shader_write_frag(kong, "winplast.xyz = winplast.xyz / winplast.w;");
|
||||
|
||||
node_shader_write_frag(kong, "var pa: float3 = input.wposition - winp.xyz;");
|
||||
if (context_raw.xray) {
|
||||
|
||||
@@ -93,7 +93,7 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
node_shader_add_texture(kong, "gbuffer0");
|
||||
node_shader_add_texture(kong, "gbuffer1");
|
||||
node_shader_add_texture(kong, "gbuffer2");
|
||||
node_shader_write_frag(kong, "var fragcoord: float2 = (input.wvpposition.xy / input.wvpposition.w) * 0.5 + 0.5;");
|
||||
node_shader_write_frag(kong, "var fragcoord: float2 = (input.wvpposition.x / input.wvpposition.w, input.wvpposition.y / input.wvpposition.w) * 0.5 + 0.5;");
|
||||
node_shader_write_frag(kong, "fragcoord.y = 1.0 - fragcoord.y;");
|
||||
node_shader_write_frag(kong, "var gbuffer0_sample: float4 = sample_lod(gbuffer0, sampler_linear, fragcoord, 0.0);");
|
||||
node_shader_write_frag(kong, "var gbuffer1_sample: float4 = sample_lod(gbuffer1, sampler_linear, fragcoord, 0.0);");
|
||||
@@ -481,7 +481,7 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
node_shader_write_frag(kong, "output[1].rgb = pow3(output[1].rgb, float3(2.2, 2.2, 2.2));"); ////
|
||||
}
|
||||
|
||||
node_shader_write_frag(kong, "n /= (abs(n.x) + abs(n.y) + abs(n.z));");
|
||||
node_shader_write_frag(kong, "n = n / (abs(n.x) + abs(n.y) + abs(n.z));");
|
||||
// node_shader_write_frag(kong, "n.xy = n.z >= 0.0 ? n.xy : octahedron_wrap(n.xy);");
|
||||
node_shader_write_frag(kong, "if (n.z < 0.0) { n.xy = octahedron_wrap(n.xy); }");
|
||||
node_shader_write_frag(kong, "output[0] = float4(n.xy, roughness, pack_f32_i16(metallic, uint(int(matid * 255.0) % float(3))));");
|
||||
|
||||
@@ -124,7 +124,7 @@ function make_mesh_preview_run(data: material_t, matcon: material_context_t): no
|
||||
node_shader_write_frag(kong, "n = normalize(TBN * n);");
|
||||
}
|
||||
|
||||
node_shader_write_frag(kong, "n /= (abs(n.x) + abs(n.y) + abs(n.z));");
|
||||
node_shader_write_frag(kong, "n = n / (abs(n.x) + abs(n.y) + abs(n.z));");
|
||||
// node_shader_write_frag(kong, "n.xy = n.z >= 0.0 ? n.xy : octahedron_wrap(n.xy);");
|
||||
node_shader_write_frag(kong, "if (n.z < 0.0) { n.xy = octahedron_wrap(n.xy); }");
|
||||
// uint matid = uint(0);
|
||||
|
||||
@@ -158,7 +158,7 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad
|
||||
node_shader_write_frag(kong, "var wn: float3;");
|
||||
node_shader_write_frag(kong, "wn.z = 1.0 - abs(g0.x) - abs(g0.y);");
|
||||
// node_shader_write_frag(kong, "wn.xy = wn.z >= 0.0 ? g0.xy : octahedron_wrap(g0.xy);");
|
||||
node_shader_write_frag(kong, "if (wn.z >= 0.0) { wn.xy = g0.xy; } else { wn.xy = octahedron_wrap(g0.xy); }");
|
||||
node_shader_write_frag(kong, "if (wn.z >= 0.0) { wn.x = g0.x; wn.y = g0.y; } else { var f2: float2 = octahedron_wrap(g0.xy); wn.x = f2.x; wn.y = f2.y; }");
|
||||
node_shader_write_frag(kong, "wn = normalize(wn);");
|
||||
kong.frag_n = true;
|
||||
let angle: f32 = context_raw.brush_angle_reject_dot;
|
||||
@@ -346,7 +346,7 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad
|
||||
|
||||
// Manual blending to preserve memory
|
||||
kong.frag_wvpposition = true;
|
||||
node_shader_write_frag(kong, "var sample_tc: float2 = float2(input.wvpposition.xy / input.wvpposition.w) * 0.5 + 0.5;");
|
||||
node_shader_write_frag(kong, "var sample_tc: float2 = float2(input.wvpposition.x / input.wvpposition.w, input.wvpposition.y / input.wvpposition.w) * 0.5 + 0.5;");
|
||||
node_shader_write_frag(kong, "sample_tc.y = 1.0 - sample_tc.y;");
|
||||
node_shader_add_texture(kong, "paintmask");
|
||||
node_shader_write_frag(kong, "var sample_mask: float = sample_lod(paintmask, sampler_linear, sample_tc, 0.0).r;");
|
||||
|
||||
@@ -60,7 +60,7 @@ fun bloom_downsample_pass_frag(input: vert_out): float4 {
|
||||
|
||||
contribution_factor /= max(epsilon, brightness);
|
||||
|
||||
color.rgb *= contribution_factor;
|
||||
color.rgb = color.rgb * contribution_factor;
|
||||
}
|
||||
|
||||
color.a = 1.0;
|
||||
|
||||
@@ -59,7 +59,7 @@ fun deferred_light_vert(input: vert_in): vert_out {
|
||||
// NDC (at the back of cube)
|
||||
var v: float4 = float4(input.pos.xy, 1.0, 1.0);
|
||||
v = constants.invVP * v;
|
||||
v.xyz /= v.w;
|
||||
v.xyz = v.xyz / v.w;
|
||||
output.view_ray = v.xyz - constants.eye;
|
||||
|
||||
return output;
|
||||
@@ -174,10 +174,15 @@ fun deferred_light_frag(input: vert_out): float4 {
|
||||
var n: float3;
|
||||
n.z = 1.0 - abs(g0.x) - abs(g0.y);
|
||||
if (n.z >= 0.0) {
|
||||
n.xy = g0.xy;
|
||||
//n.xy = g0.xy;
|
||||
n.x = g0.x;
|
||||
n.y = g0.y;
|
||||
}
|
||||
else {
|
||||
n.xy = octahedron_wrap(g0.xy);
|
||||
//n.xy = octahedron_wrap(g0.xy);
|
||||
var f2: float2 = octahedron_wrap(g0.xy);
|
||||
n.x = f2.x;
|
||||
n.y = f2.y;
|
||||
}
|
||||
n = normalize(n);
|
||||
|
||||
@@ -222,7 +227,7 @@ fun deferred_light_frag(input: vert_out): float4 {
|
||||
|
||||
//envl.rgb += prefiltered_color * (f0 * env_brdf.x + env_brdf.y) * 1.5;
|
||||
envl.rgb = envl.rgb + (prefiltered_color * (f0 * env_brdf.x + env_brdf.y) * 1.5);
|
||||
envl.rgb *= constants.envmap_data.w * occ;
|
||||
envl.rgb = envl.rgb * constants.envmap_data.w * occ;
|
||||
|
||||
var color: float4;
|
||||
color.rgb = envl.rgb;
|
||||
|
||||
@@ -37,7 +37,7 @@ fun histogram_pass_frag(input: vert_out): float4 {
|
||||
sample_lod(tex, sampler_linear, float2(0.8, 0.2), 0.0).rgb +
|
||||
sample_lod(tex, sampler_linear, float2(0.2, 0.8), 0.0).rgb +
|
||||
sample_lod(tex, sampler_linear, float2(0.8, 0.8), 0.0).rgb;
|
||||
color.rgb /= 5.0;
|
||||
color.rgb = color.rgb / 5.0;
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ fun ssao_pass_vert(input: vert_in): vert_out {
|
||||
|
||||
fun get_projected_coord(hit_coord: float3): float2 {
|
||||
var projected_coord: float4 = constants.P * float4(hit_coord, 1.0);
|
||||
projected_coord.xy /= projected_coord.w;
|
||||
projected_coord.xy = projected_coord.xy / projected_coord.w;
|
||||
projected_coord.xy = projected_coord.xy * 0.5 + 0.5;
|
||||
projected_coord.y = 1.0 - projected_coord.y;
|
||||
return projected_coord.xy;
|
||||
@@ -130,10 +130,15 @@ fun ssao_pass_frag(input: vert_out): float {
|
||||
var n: float3;
|
||||
n.z = 1.0 - abs(enc.x) - abs(enc.y);
|
||||
if (n.z >= 0.0) {
|
||||
n.xy = enc.xy;
|
||||
//n.xy = enc.xy;
|
||||
n.x = enc.x;
|
||||
n.y = enc.y;
|
||||
}
|
||||
else {
|
||||
n.xy = octahedron_wrap(enc.xy);
|
||||
//n.xy = octahedron_wrap(enc.xy);
|
||||
var f2: float2 = octahedron_wrap(enc.xy);
|
||||
n.x = f2.x;
|
||||
n.y = f2.y;
|
||||
}
|
||||
n = normalize(constants.V3 * n);
|
||||
|
||||
|
||||
@@ -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>;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user