kong test
This commit is contained in:
@@ -38,9 +38,7 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
|
||||
node_shader_add_out(kong, "tex_coord: float2");
|
||||
kong.frag_wvpposition = true;
|
||||
node_shader_add_out(kong, "prevwvpposition: float4");
|
||||
node_shader_add_uniform(kong, "VP: float4x4", "_view_proj_matrix");
|
||||
node_shader_add_uniform(kong, "prevWVP: float4x4", "_prev_world_view_proj_matrix");
|
||||
kong.vert_wposition = true;
|
||||
|
||||
let texture_count: i32 = 0;
|
||||
@@ -57,13 +55,6 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
let brush_scale: f32 = context_raw.brush_scale;
|
||||
node_shader_add_uniform(kong, "tex_scale: float", "_tex_unpack");
|
||||
node_shader_write_vert(kong, "tex_coord = tex * " + brush_scale + " * tex_scale;");
|
||||
if (make_material_height_used && displace_strength > 0) {
|
||||
node_shader_add_uniform(kong, "invW: float4x4", "_inv_world_matrix");
|
||||
node_shader_write_vert(kong, "prevwvpposition = prevWVP * (invW * float4(wposition, 1.0));");
|
||||
}
|
||||
else {
|
||||
node_shader_write_vert(kong, "prevwvpposition = prevWVP * float4(pos.xyz, 1.0);");
|
||||
}
|
||||
|
||||
kong.frag_out = "float4[3]";
|
||||
kong.frag_n = true;
|
||||
@@ -136,7 +127,7 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
if (context_raw.viewport_shader != null) {
|
||||
node_shader_write_frag(kong, "output_color: float3;");
|
||||
js_call_ptr(context_raw.viewport_shader, kong);
|
||||
node_shader_write_frag(kong, "output[1] = float4(output_color, 1.0);");
|
||||
node_shader_write_frag(kong, "output[1].rgba = float4(output_color, 1.0);");
|
||||
}
|
||||
else if (context_raw.render_mode == render_mode_t.FORWARD && context_raw.viewport_mode != viewport_mode_t.PATH_TRACE) {
|
||||
kong.frag_wposition = true;
|
||||
@@ -144,7 +135,7 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
node_shader_write_frag(kong, "var f0: float3 = lerp(float3(0.04, 0.04, 0.04), basecol, metallic);");
|
||||
kong.frag_vvec = true;
|
||||
node_shader_write_frag(kong, "var dotnv: float = max(0.0, dot(n, vvec));");
|
||||
node_shader_write_frag(kong, "var env_brdf: float2 = senvmap_brdf[int2(vec2(roughness, 1.0 - dotnv) * 256.0)].xy;");
|
||||
node_shader_write_frag(kong, "var env_brdf: float2 = senvmap_brdf[int2(float2(roughness, 1.0 - dotnv) * 256.0)].xy;");
|
||||
node_shader_add_uniform(kong, "envmap_num_mipmaps: int", "_envmap_num_mipmaps");
|
||||
node_shader_add_uniform(kong, "envmap_data: float4", "_envmap_data"); // angle, sin(angle), cos(angle), strength
|
||||
node_shader_write_frag(kong, "var wreflect: float3 = reflect(-vvec, n);");
|
||||
@@ -152,39 +143,39 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
node_shader_add_function(frag, str_envmap_equirect);
|
||||
node_shader_write_frag(kong, "var prefiltered_color: float3 = sample_lod(senvmap_radiance, envmap_equirect(wreflect, envmap_data.x), envlod).rgb;");
|
||||
node_shader_add_uniform(kong, "shirr: float4[7]", "_envmap_irradiance");
|
||||
node_shader_add_function(kong, str_sh_irradiance());
|
||||
node_shader_add_function(kong, str_sh_irradiance);
|
||||
node_shader_write_frag(kong, "var indirect: float3 = albedo * (sh_irradiance(float3(n.x * envmap_data.z - n.y * envmap_data.y, n.x * envmap_data.y + n.y * envmap_data.z, n.z), shirr) / 3.14159265);");
|
||||
node_shader_write_frag(kong, "indirect += prefiltered_color * (f0 * env_brdf.x + env_brdf.y) * 1.5;");
|
||||
node_shader_write_frag(kong, "indirect *= envmap_data.w * occlusion;");
|
||||
node_shader_write_frag(kong, "output[1] = float4(indirect, 1.0);");
|
||||
node_shader_write_frag(kong, "output[1].rgba = float4(indirect, 1.0);");
|
||||
}
|
||||
else { // Deferred, Pathtraced
|
||||
node_shader_write_frag(kong, "output[1] = float4(basecol, occlusion);");
|
||||
node_shader_write_frag(kong, "output[1].rgba = float4(basecol, occlusion);");
|
||||
}
|
||||
}
|
||||
else if (context_raw.viewport_mode == viewport_mode_t.BASE_COLOR) {
|
||||
node_shader_write_frag(kong, "output[1] = float4(basecol, 1.0);");
|
||||
node_shader_write_frag(kong, "output[1].rgba = float4(basecol, 1.0);");
|
||||
}
|
||||
else if (context_raw.viewport_mode == viewport_mode_t.NORMAL_MAP) {
|
||||
node_shader_write_frag(kong, "output[1] = float4(ntex.rgb, 1.0);");
|
||||
node_shader_write_frag(kong, "output[1].rgba = float4(ntex.rgb, 1.0);");
|
||||
}
|
||||
else if (context_raw.viewport_mode == viewport_mode_t.OCCLUSION) {
|
||||
node_shader_write_frag(kong, "output[1] = float4(float3(occlusion, occlusion, occlusion), 1.0);");
|
||||
node_shader_write_frag(kong, "output[1].rgba = float4(float3(occlusion, occlusion, occlusion), 1.0);");
|
||||
}
|
||||
else if (context_raw.viewport_mode == viewport_mode_t.ROUGHNESS) {
|
||||
node_shader_write_frag(kong, "output[1] = float4(float3(roughness, roughness, roughness), 1.0);");
|
||||
node_shader_write_frag(kong, "output[1].rgba = float4(float3(roughness, roughness, roughness), 1.0);");
|
||||
}
|
||||
else if (context_raw.viewport_mode == viewport_mode_t.METALLIC) {
|
||||
node_shader_write_frag(kong, "output[1] = float4(float3(metallic, metallic, metallic), 1.0);");
|
||||
node_shader_write_frag(kong, "output[1].rgba = float4(float3(metallic, metallic, metallic), 1.0);");
|
||||
}
|
||||
else if (context_raw.viewport_mode == viewport_mode_t.OPACITY) {
|
||||
node_shader_write_frag(kong, "output[1] = float4(float3(texpaint_sample.a, texpaint_sample.a, texpaint_sample.a), 1.0);");
|
||||
node_shader_write_frag(kong, "output[1].rgba = float4(float3(texpaint_sample.a, texpaint_sample.a, texpaint_sample.a), 1.0);");
|
||||
}
|
||||
else if (context_raw.viewport_mode == viewport_mode_t.HEIGHT) {
|
||||
node_shader_write_frag(kong, "output[1] = float4(float3(height, height, height), 1.0);");
|
||||
node_shader_write_frag(kong, "output[1].rgba = float4(float3(height, height, height), 1.0);");
|
||||
}
|
||||
else {
|
||||
node_shader_write_frag(kong, "output[1] = float4(1.0, 0.0, 1.0, 1.0);"); // Pink
|
||||
node_shader_write_frag(kong, "output[1].rgba = float4(1.0, 0.0, 1.0, 1.0);"); // Pink
|
||||
}
|
||||
|
||||
if (context_raw.viewport_mode != viewport_mode_t.LIT && context_raw.viewport_mode != viewport_mode_t.PATH_TRACE) {
|
||||
@@ -192,9 +183,10 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
}
|
||||
|
||||
node_shader_write_frag(kong, "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, "output[0] = float4(n.xy, roughness, pack_f32_i16(metallic, uint(int(matid * 255.0) % 3)));");
|
||||
node_shader_write_frag(kong, "output[2] = float4(0.0, 0.0, tex_coord.xy);");
|
||||
// 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].rgba = float4(n.xy, roughness, pack_f32_i16(metallic, uint(int(matid * 255.0) % 3)));");
|
||||
node_shader_write_frag(kong, "output[2].rgba = float4(0.0, 0.0, tex_coord.xy);");
|
||||
|
||||
parser_material_finalize(con_mesh);
|
||||
con_mesh.data.shader_from_source = true;
|
||||
|
||||
Reference in New Issue
Block a user